From d4eb7def46353d3436dba55e169e22017d204bb4 Mon Sep 17 00:00:00 2001 From: cookie Date: Sun, 16 Apr 2006 21:16:22 +0000 Subject: [PATCH] log db changes v 0.01 git-svn-id: svn://svn.cccv.de/engel-system@116 29ba0400-6e00-0410-a75a-ca02368028f8 --- www-ssl/inc/funktion_db.php | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 www-ssl/inc/funktion_db.php diff --git a/www-ssl/inc/funktion_db.php b/www-ssl/inc/funktion_db.php new file mode 100644 index 00000000..ff85d5cd --- /dev/null +++ b/www-ssl/inc/funktion_db.php @@ -0,0 +1,78 @@ +"; + $Diff .= ""; + for ($m = 0 ; $m < $Anzahl_Felder ; $m++) + $Diff .= "". mysql_field_name($Erg, $m). ""; + $Diff .= ""; + for ($n = 0 ; $n < $Zeilen ; $n++) + { + $Diff .= ""; + for ($m = 0 ; $m < $Anzahl_Felder ; $m++) + $Diff .= "".mysql_result($Erg, $n, $m). ""; + $Diff .= ""; + } + $Diff .= ""; + return $Diff; + } + + function db_query( $SQL, $comment) + { + global $con; + + //commed anlyse udn daten sicherung + $Diff = ""; + if( strpos( "#$SQL", "UPDATE") > 0) + { + //Tabellen name ermitteln + $Table_Start = strpos( $SQL, "`"); + $Table_End = strpos( $SQL, "`", $Table_Start+1); + $Table = substr( $SQL, $Table_Start, ($Table_End-$Table_Start+1)); + + //WHERE ermitteln + $Where_Start = strpos( $SQL, "WHERE"); + $Where = substr( $SQL, $Where_Start); + + //Daten auslesen + $Diff .= Ausgabe_Daten( "SELECT * FROM $Table $Where"); + + //execute command + $querry_erg = mysql_query($SQL, $con); + + //Daten auslesen + $Diff .= Ausgabe_Daten( "SELECT * FROM $Table $Where"); + } + else + { + //execute command + $querry_erg = mysql_query($SQL, $con); + } + + //LOG commands in DB + $SQL_SEC = "INSERT INTO `ChangeLog` ( `UID` , `SQLCommad` , `Commend` ) ". + " VALUES ( ". + "'". $_SESSION['UID']. "', ". + "'SQL:
". htmlentities( $SQL, ENT_QUOTES). "

". + "Diff:
$Diff', ". + "'". htmlentities( $comment, ENT_QUOTES). "' );"; + $erg = mysql_query($SQL_SEC, $con); + echo mysql_error($con); + + + return $querry_erg; + }//function db_query( +} + +?>