Skip to content

Commit 346f607

Browse files
committed
Fixed problems in db_mysql.inc.phpof the server.
1 parent 4a8b7ec commit 346f607

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

server/lib/classes/db_mysql.inc.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,21 @@ public function datalogSave($db_table, $action, $primary_field, $primary_id, $re
275275
if(isset($record_new['server_id'])) $server_id = $record_new['server_id'];
276276

277277

278-
if($diff_num > 0) {
279-
//print_r($diff_num);
280-
//print_r($diffrec_full);
281-
$diffstr = $app->db->quote(serialize($diffrec_full));
282-
$username = $app->db->quote($_SESSION['s']['user']['username']);
283-
$dbidx = $primary_field.':'.$primary_id;
284-
285-
if($action == 'INSERT') $action = 'i';
286-
if($action == 'UPDATE') $action = 'u';
287-
if($action == 'DELETE') $action = 'd';
288-
$sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')";
289-
$app->db->query($sql);
290-
}
278+
if($diff_num > 0) {
279+
$diffstr = $app->db->quote(serialize($diffrec_full));
280+
if(isset($_SESSION)) {
281+
$username = $app->db->quote($_SESSION['s']['user']['username']);
282+
} else {
283+
$username = 'admin';
284+
}
285+
$dbidx = $primary_field.':'.$primary_id;
286+
287+
if($action == 'INSERT') $action = 'i';
288+
if($action == 'UPDATE') $action = 'u';
289+
if($action == 'DELETE') $action = 'd';
290+
$sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')";
291+
$app->db->query($sql);
292+
}
291293

292294
return true;
293295
}

0 commit comments

Comments
 (0)