= $filter_ts_from and $timestamp <= $filter_ts_to and
( in_array('*', $filter_users) or in_array($entry['username'], $filter_users) ) )
$entries[] = array( 'id' => $id,
'timestamp' => $timestamp,
'username' => $entry['username'],
'statement' => $entry['statement']
);
$id++;
}
}
// Filtering data manipulation statments
if($_REQUEST['logtype'] == 'data' or $_REQUEST['logtype'] == 'schema_and_data')
{
$id = 0;
foreach( $data['dmlog'] as $entry )
{
$timestamp = strtotime($entry['date']);
if( $timestamp >= $filter_ts_from and $timestamp <= $filter_ts_to and
( in_array('*', $filter_users) or in_array($entry['username'], $filter_users) ) )
$entries[] = array( 'id' => $id,
'timestamp' => $timestamp,
'username' => $entry['username'],
'statement' => $entry['statement']
);
$id++;
}
}
// Sort it
foreach ($entries as $key => $row)
{
$ids[$key] = $row['id'];
$timestamps[$key] = $row['timestamp'];
$usernames[$key] = $row['username'];
$statements[$key] = $row['statement'];
}
array_multisort($timestamps, SORT_ASC, $ids, SORT_ASC, $usernames, SORT_ASC, $statements, SORT_ASC, $entries);
}
// Export as file download
if(isset($_REQUEST['report_export']) and $_REQUEST['export_type'] == 'sqldumpfile')
{
@ini_set('url_rewriter.tags','');
$dump = "# Tracking report for table `" . $_REQUEST['table'] . "`\n" .
"# " . date('Y-m-d H:i:s') . "\n";
foreach($entries as $entry)
$dump .= $entry['statement'];
$filename = 'log_' . $_REQUEST['table'] . '.sql';
header('Content-Type: text/x-sql');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename="' . $filename . '"');
if (PMA_USR_BROWSER_AGENT == 'IE')
{
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
else
{
header('Pragma: no-cache');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
}
echo $dump;
exit();
}
/**
* Gets tables informations
*/
//require './libraries/tbl_info.inc.php';
/**
* Displays top menu links
*/
require_once './libraries/tbl_links.inc.php';
?>
display();
}
}
// Deactivate tracking
if(isset($_REQUEST['submit_deactivate_now']))
{
if(PMA_Tracker::deactivateTracking($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']))
{
$msg = PMA_Message::success(sprintf($strTrackingVersionDeactivated, $GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']));
$msg->display();
}
}
// Activate tracking
if(isset($_REQUEST['submit_activate_now']))
{
if(PMA_Tracker::activateTracking($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']))
{
$msg = PMA_Message::success(sprintf($strTrackingVersionActivated, $GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']));
$msg->display();
}
}
// Export as SQL execution
if(isset($_REQUEST['report_export']) and $_REQUEST['export_type'] == 'execution')
{
foreach($entries as $entry)
$sql_result = PMA_DBI_query( "/*NOTRACK*/\n" . $entry['statement'] );
$msg = PMA_Message::success($strTrackingSQLExecuted);
$msg->display();
}
// Export as SQL dump
if(isset($_REQUEST['report_export']) and $_REQUEST['export_type'] == 'sqldump')
{
$new_query = "# You can execute the dump by creating and using a temporary table. Please ensure that you have the privileges to do that. \n" .
"# Comment out or remove these two lines if you don't need them. \n" .
"\n" .
"CREATE database IF NOT EXISTS pma_temp_db; \n" .
"USE pma_temp_db; \n" .
"\n" .
"/* BEGIN OF SQL DUMP */ \n";
foreach($entries as $entry)
$new_query .= $entry['statement'];
$msg = PMA_Message::success($strTrackingSQLExported);
$msg->display();
$db_temp = $db;
$table_temp = $table;
$db = $table = '';
$GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/sql_query_form.lib.php';
PMA_sqlQueryForm($new_query, 'sql');
$db = $db_temp;
$table = $table_temp;
}
/*
* Schema snapshot
*/
if(isset($_REQUEST['snapshot']))
{
?>
[]
|
|
|
|
|
|
|
$field)
{
?>
' . $field['Field'] . ''."\n";
else
echo '' . $field['Field'] . ' | '."\n";
?>
|
|
|
|
|
|
0)
{
?>
|
|
|
|
|
|
|
|
|
$index)
{
if($index['Non_unique'] == 0)
$str_unique = $strYes;
else
$str_unique = $strNo;
if($index['Packed'] != '')
$str_packed = $strYes;
else
$str_packed = $strNo;
?>
|
|
|
|
|
|
|
|
|
[]
\n";
} // end of report
/*
* List selectable tables
*/
$sql_query = " SELECT DISTINCT db_name, table_name FROM " .
PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." .
PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
" WHERE " . PMA_backquote('db_name') . " = '" . PMA_sqlAddslashes($GLOBALS['db']) . "' " .
" ORDER BY ". PMA_backquote('db_name') . ", " . PMA_backquote('table_name');
$sql_result = PMA_query_as_controluser($sql_query);
if(PMA_DBI_num_rows($sql_result) > 0)
{
?>
0)
{
?>