Example #1
0
function show_audit_trail($id, $table = '')
{
    echo "<h3>Audit Trail</h3>\n";
    if (!$table) {
        $table = substr($_SERVER["PHP_SELF"], 1, -4);
    }
    $db = new $_ENV["DatabaseClass"]();
    $t = new Table();
    $t->heading = "on";
    $t->add_extra = array("View" => array("target" => $_ENV["LogSqlTo"] . ".php"));
    $t->fields = array("UserName", "Table", "SQL", "Was", "At", "IP");
    $t->map_cols = array("UserName" => "User Name", "Table" => "Table", "SQL" => "Database transaction", "Was" => "Old Values", "At" => "Date,TimeStamp", "IP" => "IP Addr");
    $sql = "SELECT * FROM " . $db->qi($_ENV["LogSqlTo"]) . " WHERE " . $db->qi('Table') . "='{$table}' AND " . $db->qi('Key') . "='{$id}' AND `SQL` LIKE 'UPDATE%' order by id desc limit 0,50";
    $db->query($sql);
    if ($t->show_result($db, "default") == 50) {
        echo "<a href=" . $sess->url($_ENV["LogSqlTo"] . ".php") . $sess->add_query(array("Table" => $table, "Key" => $id)) . ">Show More Audit Logs</a>\n";
    }
}