= $filter_ts_from
&& $timestamp <= $filter_ts_to
&& (in_array('*', $filter_users) || $filtered_user)
) {
$tmp_entries[] = array(
'id' => $id,
'timestamp' => $timestamp,
'username' => $entry['username'],
'statement' => $entry['statement']
);
}
$id++;
}
return($tmp_entries);
}
/**
* Function to get html for data definition and data manipulation statements
*
* @param string $url_query url query
* @param int $last_version last version
* @param string $db database
* @param array $selected selected tables
* @param string $type type of the table; table, view or both
*
* @return string
*/
function PMA_getHtmlForDataDefinitionAndManipulationStatements($url_query,
$last_version, $db, $selected, $type = 'both'
) {
$html = '
';
$html .= '
';
$html .= '
';
return $html;
}
/**
* Function to get html for activate/deactivate tracking
*
* @param string $action activate|deactivate
* @param string $url_query url query
* @param int $last_version last version
*
* @return string
*/
function PMA_getHtmlForActivateDeactivateTracking(
$action, $url_query, $last_version
) {
$html = '';
$html .= '';
$html .= '
';
return $html;
}
/**
* Function to get the list versions of the table
*
* @return array
*/
function PMA_getListOfVersionsOfTable()
{
$cfgRelation = PMA_getRelationsParam();
$sql_query = " SELECT * FROM " .
PMA\libraries\Util::backquote($cfgRelation['db']) . "." .
PMA\libraries\Util::backquote($cfgRelation['tracking']) .
" WHERE db_name = '" . $GLOBALS['dbi']->escapeString($_REQUEST['db']) .
"' " .
" AND table_name = '" .
$GLOBALS['dbi']->escapeString($_REQUEST['table']) . "' " .
" ORDER BY version DESC ";
return PMA_queryAsControlUser($sql_query);
}
/**
* Function to get html for displaying last version number
*
* @param array $sql_result sql result
* @param int $last_version last version
* @param array $url_params url parameters
* @param string $url_query url query
* @param string $pmaThemeImage path to theme's image folder
* @param string $text_dir text direction
*
* @return string
*/
function PMA_getHtmlForTableVersionDetails(
$sql_result, $last_version, $url_params,
$url_query, $pmaThemeImage, $text_dir
) {
$tracking_active = false;
$html = '';
if ($tracking_active) {
$html .= PMA_getHtmlForActivateDeactivateTracking(
'deactivate', $url_query, $last_version
);
} else {
$html .= PMA_getHtmlForActivateDeactivateTracking(
'activate', $url_query, $last_version
);
}
return $html;
}
/**
* Function to get the last version number of a table
*
* @param array $sql_result sql result
*
* @return int
*/
function PMA_getTableLastVersionNumber($sql_result)
{
$maxversion = $GLOBALS['dbi']->fetchArray($sql_result);
return intval($maxversion['version']);
}
/**
* Function to get sql results for selectable tables
*
* @return array
*/
function PMA_getSQLResultForSelectableTables()
{
include_once 'libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam();
$sql_query = " SELECT DISTINCT db_name, table_name FROM " .
PMA\libraries\Util::backquote($cfgRelation['db']) . "." .
PMA\libraries\Util::backquote($cfgRelation['tracking']) .
" WHERE db_name = '" . $GLOBALS['dbi']->escapeString($GLOBALS['db']) .
"' " .
" ORDER BY db_name, table_name";
return PMA_queryAsControlUser($sql_query);
}
/**
* Function to get html for selectable table rows
*
* @param array $selectable_tables_sql_result sql results for selectable rows
* @param string $url_query url query
*
* @return string
*/
function PMA_getHtmlForSelectableTables($selectable_tables_sql_result, $url_query)
{
$html = '';
return $html;
}
/**
* Function to get html for tracking report and tracking report export
*
* @param string $url_query url query
* @param array $data data
* @param array $url_params url params
* @param boolean $selection_schema selection schema
* @param boolean $selection_data selection data
* @param boolean $selection_both selection both
* @param int $filter_ts_to filter time stamp from
* @param int $filter_ts_from filter time stamp tp
* @param array $filter_users filter users
*
* @return string
*/
function PMA_getHtmlForTrackingReport($url_query, $data, $url_params,
$selection_schema, $selection_data, $selection_both, $filter_ts_to,
$filter_ts_from, $filter_users
) {
$html = '';
$html .= '' . __('Tracking statements') . ' '
. htmlspecialchars($data['tracking']) . ' ';
$html .= ' ';
list($str1, $str2, $str3, $str4, $str5) = PMA_getHtmlForElementsOfTrackingReport(
$selection_schema, $selection_data, $selection_both
);
// Prepare delete link content here
$drop_image_or_text = '';
if (PMA\libraries\Util::showIcons('ActionLinksMode')) {
$drop_image_or_text .= PMA\libraries\Util::getImage(
'b_drop.png', __('Delete tracking data row from report')
);
}
if (PMA\libraries\Util::showText('ActionLinksMode')) {
$drop_image_or_text .= __('Delete');
}
/*
* First, list tracked data definition statements
*/
if (count($data['ddlog']) == 0 && count($data['dmlog']) == 0) {
$msg = Message::notice(__('No data'));
$msg->display();
}
$html .= PMA_getHtmlForTrackingReportExportForm1(
$data, $url_params, $selection_schema, $selection_data, $selection_both,
$filter_ts_to, $filter_ts_from, $filter_users, $str1, $str2, $str3,
$str4, $str5, $drop_image_or_text
);
$html .= PMA_getHtmlForTrackingReportExportForm2(
$url_params, $str1, $str2, $str3, $str4, $str5
);
$html .= " \n";
return $html;
}
/**
* Generate HTML element for report form
*
* @param boolean $selection_schema selection schema
* @param boolean $selection_data selection data
* @param boolean $selection_both selection both
*
* @return array
*/
function PMA_getHtmlForElementsOfTrackingReport(
$selection_schema, $selection_data, $selection_both
) {
$str1 = ''
. ''
. __('Structure only') . ' '
. ''
. __('Data only') . ' '
. ''
. __('Structure and data') . ' '
. ' ';
$str2 = ' ';
$str3 = ' ';
$str4 = ' ';
$str5 = ' '
. ' ';
return array($str1, $str2, $str3, $str4, $str5);
}
/**
* Generate HTML for export form
*
* @param array $data data
* @param array $url_params url params
* @param boolean $selection_schema selection schema
* @param boolean $selection_data selection data
* @param boolean $selection_both selection both
* @param int $filter_ts_to filter time stamp from
* @param int $filter_ts_from filter time stamp tp
* @param array $filter_users filter users
* @param string $str1 HTML for logtype select
* @param string $str2 HTML for "from date"
* @param string $str3 HTML for "to date"
* @param string $str4 HTML for user
* @param string $str5 HTML for "list report"
* @param string $drop_image_or_text HTML for image or text
*
* @return string HTML for form
*/
function PMA_getHtmlForTrackingReportExportForm1(
$data, $url_params, $selection_schema, $selection_data, $selection_both,
$filter_ts_to, $filter_ts_from, $filter_users, $str1, $str2, $str3,
$str4, $str5, $drop_image_or_text
) {
$ddlog_count = 0;
$html = '';
return $html;
}
/**
* Generate HTML for export form
*
* @param array $url_params Parameters
* @param string $str1 HTML for logtype select
* @param string $str2 HTML for "from date"
* @param string $str3 HTML for "to date"
* @param string $str4 HTML for user
* @param string $str5 HTML for "list report"
*
* @return string HTML for form
*/
function PMA_getHtmlForTrackingReportExportForm2(
$url_params, $str1, $str2, $str3, $str4, $str5
) {
$html = '';
$html .= '';
return $html;
}
/**
* Function to get html for data manipulation statements
*
* @param array $data data
* @param array $filter_users filter users
* @param int $filter_ts_from filter time staml from
* @param int $filter_ts_to filter time stamp to
* @param array $url_params url parameters
* @param int $ddlog_count data definition log count
* @param string $drop_image_or_text drop image or text
*
* @return string
*/
function PMA_getHtmlForDataManipulationStatements($data, $filter_users,
$filter_ts_from, $filter_ts_to, $url_params, $ddlog_count,
$drop_image_or_text
) {
// no need for the secondth returned parameter
list($html,) = PMA_getHtmlForDataStatements(
$data, $filter_users, $filter_ts_from, $filter_ts_to, $url_params,
$drop_image_or_text, 'dmlog', __('Data manipulation statement'),
$ddlog_count, 'dml_versions'
);
return $html;
}
/**
* Function to get html for one data manipulation statement
*
* @param array $entry entry
* @param array $filter_users filter users
* @param int $filter_ts_from filter time stamp from
* @param int $filter_ts_to filter time stamp to
* @param int $line_number line number
* @param array $url_params url parameters
* @param int $offset line number offset
* @param string $drop_image_or_text drop image or text
* @param string $delete_param parameter for delete
*
* @return string
*/
function PMA_getHtmlForOneStatement($entry, $filter_users,
$filter_ts_from, $filter_ts_to, $line_number, $url_params, $offset,
$drop_image_or_text, $delete_param
) {
$statement = PMA\libraries\Util::formatSql($entry['statement'], true);
$timestamp = strtotime($entry['date']);
$filtered_user = in_array($entry['username'], $filter_users);
$html = null;
if ($timestamp >= $filter_ts_from
&& $timestamp <= $filter_ts_to
&& (in_array('*', $filter_users) || $filtered_user)
) {
$html = '';
$html .= '' . $line_number . ' ';
$html .= ''
. htmlspecialchars($entry['date']) . ' ';
$html .= ''
. htmlspecialchars($entry['username']) . ' ';
$html .= '' . $statement . ' ';
$html .= ''
. $drop_image_or_text
. ' ';
$html .= ' ';
}
return $html;
}
/**
* Function to get html for data definition statements in schema snapshot
*
* @param array $data data
* @param array $filter_users filter users
* @param int $filter_ts_from filter time stamp from
* @param int $filter_ts_to filter time stamp to
* @param array $url_params url parameters
* @param string $drop_image_or_text drop image or text
*
* @return array
*/
function PMA_getHtmlForDataDefinitionStatements($data, $filter_users,
$filter_ts_from, $filter_ts_to, $url_params, $drop_image_or_text
) {
list($html, $line_number) = PMA_getHtmlForDataStatements(
$data, $filter_users, $filter_ts_from, $filter_ts_to, $url_params,
$drop_image_or_text, 'ddlog', __('Data definition statement'),
1, 'ddl_versions'
);
return array($html, $line_number);
}
/**
* Function to get html for data statements in schema snapshot
*
* @param array $data data
* @param array $filter_users filter users
* @param int $filter_ts_from filter time stamp from
* @param int $filter_ts_to filter time stamp to
* @param array $url_params url parameters
* @param string $drop_image_or_text drop image or text
* @param string $which_log dmlog|ddlog
* @param string $header_message message for this section
* @param int $line_number line number
* @param string $table_id id for the table element
*
* @return array
*/
function PMA_getHtmlForDataStatements($data, $filter_users,
$filter_ts_from, $filter_ts_to, $url_params, $drop_image_or_text,
$which_log, $header_message, $line_number, $table_id
) {
$offset = $line_number;
$html = '';
$html .= '';
$html .= '';
$html .= '# ';
$html .= '' . __('Date') . ' ';
$html .= '' . __('Username') . ' ';
$html .= '' . $header_message . ' ';
$html .= '' . __('Action') . ' ';
$html .= ' ';
$html .= ' ';
$html .= '';
foreach ($data[$which_log] as $entry) {
$html .= PMA_getHtmlForOneStatement(
$entry, $filter_users, $filter_ts_from, $filter_ts_to,
$line_number, $url_params, $offset, $drop_image_or_text,
'delete_' . $which_log
);
$line_number++;
}
$html .= ' ';
$html .= '
';
return array($html, $line_number);
}
/**
* Function to get html for schema snapshot
*
* @param string $url_query url query
*
* @return string
*/
function PMA_getHtmlForSchemaSnapshot($url_query)
{
$html = '';
$data = Tracker::getTrackedData(
$_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']
);
// Get first DROP TABLE/VIEW and CREATE TABLE/VIEW statements
$drop_create_statements = $data['ddlog'][0]['statement'];
if (mb_strstr($data['ddlog'][0]['statement'], 'DROP TABLE')
|| mb_strstr($data['ddlog'][0]['statement'], 'DROP VIEW')
) {
$drop_create_statements .= $data['ddlog'][1]['statement'];
}
// Print SQL code
$html .= PMA\libraries\Util::getMessage(
sprintf(
__('Version %s snapshot (SQL code)'),
htmlspecialchars($_REQUEST['version'])
),
$drop_create_statements
);
// Unserialize snapshot
$temp = PMA_safeUnserialize($data['schema_snapshot']);
if ($temp === null) {
$temp = array('COLUMNS' => array(), 'INDEXES' => array());
}
$columns = $temp['COLUMNS'];
$indexes = $temp['INDEXES'];
$html .= PMA_getHtmlForColumns($columns);
if (count($indexes) > 0) {
$html .= PMA_getHtmlForIndexes($indexes);
} // endif
$html .= ' ';
return $html;
}
/**
* Function to get html for displaying columns in the schema snapshot
*
* @param array $columns columns
*
* @return string
*/
function PMA_getHtmlForColumns($columns)
{
$html = '' . __('Structure') . ' ';
$html .= '';
$html .= '';
$html .= '';
$html .= '' . __('#') . ' ';
$html .= '' . __('Column') . ' ';
$html .= '' . __('Type') . ' ';
$html .= '' . __('Collation') . ' ';
$html .= '' . __('Null') . ' ';
$html .= '' . __('Default') . ' ';
$html .= '' . __('Extra') . ' ';
$html .= '' . __('Comment') . ' ';
$html .= ' ';
$html .= ' ';
$html .= '';
$index = 1;
foreach ($columns as $field) {
$html .= PMA_getHtmlForField($index++, $field);
}
$html .= ' ';
$html .= '
';
return $html;
}
/**
* Function to get html for field
*
* @param int $index index
* @param array $field field
*
* @return string
*/
function PMA_getHtmlForField($index, $field)
{
$html = '';
$html .= '' . $index . ' ';
$html .= '' . htmlspecialchars($field['Field']);
if ($field['Key'] == 'PRI') {
$html .= ' ' . PMA\libraries\Util::getImage(
'b_primary.png', __('Primary')
);
} elseif (! empty($field['Key'])) {
$html .= ' ' . PMA\libraries\Util::getImage(
'bd_primary.png', __('Index')
);
}
$html .= ' ';
$html .= "\n";
$html .= '' . htmlspecialchars($field['Type']) . ' ';
$html .= '' . htmlspecialchars($field['Collation']) . ' ';
$html .= '' . (($field['Null'] == 'YES') ? __('Yes') : __('No')) . ' ';
$html .= '';
if (isset($field['Default'])) {
$extracted_columnspec = PMA\libraries\Util::extractColumnSpec(
$field['Type']
);
if ($extracted_columnspec['type'] == 'bit') {
// here, $field['Default'] contains something like b'010'
$html .= PMA\libraries\Util::convertBitDefaultValue($field['Default']);
} else {
$html .= htmlspecialchars($field['Default']);
}
} else {
if ($field['Null'] == 'YES') {
$html .= 'NULL ';
} else {
$html .= '' . _pgettext('None for default', 'None') . ' ';
}
}
$html .= ' ';
$html .= '' . htmlspecialchars($field['Extra']) . ' ';
$html .= '' . htmlspecialchars($field['Comment']) . ' ';
$html .= ' ';
return $html;
}
/**
* Function to get html for the indexes in schema snapshot
*
* @param array $indexes indexes
*
* @return string
*/
function PMA_getHtmlForIndexes($indexes)
{
$html = '' . __('Indexes') . ' ';
$html .= '';
$html .= '';
$html .= '';
$html .= '' . __('Keyname') . ' ';
$html .= '' . __('Type') . ' ';
$html .= '' . __('Unique') . ' ';
$html .= '' . __('Packed') . ' ';
$html .= '' . __('Column') . ' ';
$html .= '' . __('Cardinality') . ' ';
$html .= '' . __('Collation') . ' ';
$html .= '' . __('Null') . ' ';
$html .= '' . __('Comment') . ' ';
$html .= ' ';
$html .= ' ';
foreach ($indexes as $index) {
$html .= PMA_getHtmlForIndex($index);
}
$html .= ' ';
$html .= '
';
return $html;
}
/**
* Function to get html for an index in schema snapshot
*
* @param array $index index
*
* @return string
*/
function PMA_getHtmlForIndex($index)
{
if ($index['Non_unique'] == 0) {
$str_unique = __('Yes');
} else {
$str_unique = __('No');
}
if ($index['Packed'] != '') {
$str_packed = __('Yes');
} else {
$str_packed = __('No');
}
$html = '';
$html .= '' . htmlspecialchars($index['Key_name']) . ' ';
$html .= '' . htmlspecialchars($index['Index_type']) . ' ';
$html .= '' . $str_unique . ' ';
$html .= '' . $str_packed . ' ';
$html .= '' . htmlspecialchars($index['Column_name']) . ' ';
$html .= '' . htmlspecialchars($index['Cardinality']) . ' ';
$html .= '' . htmlspecialchars($index['Collation']) . ' ';
$html .= '' . htmlspecialchars($index['Null']) . ' ';
$html .= '' . htmlspecialchars($index['Comment']) . ' ';
$html .= ' ';
return $html;
}
/**
* Function to handle the tracking report
*
* @param array &$data tracked data
*
* @return string HTML for the message
*/
function PMA_deleteTrackingReportRows(&$data)
{
$html = '';
if (isset($_REQUEST['delete_ddlog'])) {
// Delete ddlog row data
$html .= PMA_deleteFromTrackingReportLog(
$data,
'ddlog',
'DDL',
__('Tracking data definition successfully deleted')
);
}
if (isset($_REQUEST['delete_dmlog'])) {
// Delete dmlog row data
$html .= PMA_deleteFromTrackingReportLog(
$data,
'dmlog',
'DML',
__('Tracking data manipulation successfully deleted')
);
}
return $html;
}
/**
* Function to delete from a tracking report log
*
* @param array &$data tracked data
* @param string $which_log ddlog|dmlog
* @param string $type DDL|DML
* @param string $message success message
*
* @return string HTML for the message
*/
function PMA_deleteFromTrackingReportLog(&$data, $which_log, $type, $message)
{
$html = '';
$delete_id = $_REQUEST['delete_' . $which_log];
// Only in case of valid id
if ($delete_id == (int)$delete_id) {
unset($data[$which_log][$delete_id]);
$successfullyDeleted = Tracker::changeTrackingData(
$_REQUEST['db'],
$_REQUEST['table'],
$_REQUEST['version'],
$type,
$data[$which_log]
);
if ($successfullyDeleted) {
$msg = Message::success($message);
} else {
$msg = Message::rawError(__('Query error'));
}
$html .= $msg->getDisplay();
}
return $html;
}
/**
* Function to export as sql dump
*
* @param array $entries entries
*
* @return string HTML SQL query form
*/
function PMA_exportAsSQLDump($entries)
{
$html = '';
$new_query = "# "
. __(
'You can execute the dump by creating and using a temporary database. '
. 'Please ensure that you have the privileges to do so.'
)
. "\n"
. "# " . __('Comment out these two lines if you do not need them.') . "\n"
. "\n"
. "CREATE database IF NOT EXISTS pma_temp_db; \n"
. "USE pma_temp_db; \n"
. "\n";
foreach ($entries as $entry) {
$new_query .= $entry['statement'];
}
$msg = Message::success(
__('SQL statements exported. Please copy the dump or execute it.')
);
$html .= $msg->getDisplay();
$db_temp = $GLOBALS['db'];
$table_temp = $GLOBALS['table'];
$GLOBALS['db'] = $GLOBALS['table'] = '';
include_once './libraries/sql_query_form.lib.php';
$html .= PMA_getHtmlForSqlQueryForm($new_query, 'sql');
$GLOBALS['db'] = $db_temp;
$GLOBALS['table'] = $table_temp;
return $html;
}
/**
* Function to export as sql execution
*
* @param array $entries entries
*
* @return array
*/
function PMA_exportAsSQLExecution($entries)
{
$sql_result = array();
foreach ($entries as $entry) {
$sql_result = $GLOBALS['dbi']->query("/*NOTRACK*/\n" . $entry['statement']);
}
return $sql_result;
}
/**
* Function to export as entries
*
* @param array $entries entries
*
* @return void
*/
function PMA_exportAsFileDownload($entries)
{
@ini_set('url_rewriter.tags', '');
// Replace all multiple whitespaces by a single space
$table = htmlspecialchars(preg_replace('/\s+/', ' ', $_REQUEST['table']));
$dump = "# " . sprintf(
__('Tracking report for table `%s`'), $table
)
. "\n" . "# " . date('Y-m-d H:i:s') . "\n";
foreach ($entries as $entry) {
$dump .= $entry['statement'];
}
$filename = 'log_' . $table . '.sql';
Response::getInstance()->disable();
PMA_downloadHeader(
$filename,
'text/x-sql',
strlen($dump)
);
echo $dump;
exit();
}
/**
* Function to activate or deactivate tracking
*
* @param string $action activate|deactivate
*
* @return string HTML for the success message
*/
function PMA_changeTracking($action)
{
$html = '';
if ($action == 'activate') {
$method = 'activateTracking';
$message = __('Tracking for %1$s was activated at version %2$s.');
} else {
$method = 'deactivateTracking';
$message = __('Tracking for %1$s was deactivated at version %2$s.');
}
$status = Tracker::$method(
$GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version']
);
if ($status) {
$msg = Message::success(
sprintf(
$message,
htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table']),
htmlspecialchars($_REQUEST['version'])
)
);
$html .= $msg->getDisplay();
}
return $html;
}
/**
* Function to get tracking set
*
* @return string
*/
function PMA_getTrackingSet()
{
$tracking_set = '';
// a key is absent from the request if it has been removed from
// tracking_default_statements in the config
if (isset($_REQUEST['alter_table']) && $_REQUEST['alter_table'] == true) {
$tracking_set .= 'ALTER TABLE,';
}
if (isset($_REQUEST['rename_table']) && $_REQUEST['rename_table'] == true) {
$tracking_set .= 'RENAME TABLE,';
}
if (isset($_REQUEST['create_table']) && $_REQUEST['create_table'] == true) {
$tracking_set .= 'CREATE TABLE,';
}
if (isset($_REQUEST['drop_table']) && $_REQUEST['drop_table'] == true) {
$tracking_set .= 'DROP TABLE,';
}
if (isset($_REQUEST['alter_view']) && $_REQUEST['alter_view'] == true) {
$tracking_set .= 'ALTER VIEW,';
}
if (isset($_REQUEST['create_view']) && $_REQUEST['create_view'] == true) {
$tracking_set .= 'CREATE VIEW,';
}
if (isset($_REQUEST['drop_view']) && $_REQUEST['drop_view'] == true) {
$tracking_set .= 'DROP VIEW,';
}
if (isset($_REQUEST['create_index']) && $_REQUEST['create_index'] == true) {
$tracking_set .= 'CREATE INDEX,';
}
if (isset($_REQUEST['drop_index']) && $_REQUEST['drop_index'] == true) {
$tracking_set .= 'DROP INDEX,';
}
if (isset($_REQUEST['insert']) && $_REQUEST['insert'] == true) {
$tracking_set .= 'INSERT,';
}
if (isset($_REQUEST['update']) && $_REQUEST['update'] == true) {
$tracking_set .= 'UPDATE,';
}
if (isset($_REQUEST['delete']) && $_REQUEST['delete'] == true) {
$tracking_set .= 'DELETE,';
}
if (isset($_REQUEST['truncate']) && $_REQUEST['truncate'] == true) {
$tracking_set .= 'TRUNCATE,';
}
$tracking_set = rtrim($tracking_set, ',');
return $tracking_set;
}
/**
* Deletes a tracking version
*
* @param string $version tracking version
*
* @return string HTML of the success message
*/
function PMA_deleteTrackingVersion($version)
{
$html = '';
$versionDeleted = Tracker::deleteTracking(
$GLOBALS['db'],
$GLOBALS['table'],
$version
);
if ($versionDeleted) {
$msg = Message::success(
sprintf(
__('Version %1$s of %2$s was deleted.'),
htmlspecialchars($version),
htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table'])
)
);
$html .= $msg->getDisplay();
}
return $html;
}
/**
* Function to create the tracking version
*
* @return string HTML of the success message
*/
function PMA_createTrackingVersion()
{
$html = '';
$tracking_set = PMA_getTrackingSet();
$versionCreated = Tracker::createVersion(
$GLOBALS['db'],
$GLOBALS['table'],
$_REQUEST['version'],
$tracking_set,
$GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])->isView()
);
if ($versionCreated) {
$msg = Message::success(
sprintf(
__('Version %1$s was created, tracking for %2$s is active.'),
htmlspecialchars($_REQUEST['version']),
htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table'])
)
);
$html .= $msg->getDisplay();
}
return $html;
}
/**
* Create tracking version for multiple tables
*
* @param array $selected list of selected tables
*
* @return void
*/
function PMA_createTrackingForMultipleTables($selected)
{
$tracking_set = PMA_getTrackingSet();
foreach ($selected as $selected_table) {
Tracker::createVersion(
$GLOBALS['db'],
$selected_table,
$_REQUEST['version'],
$tracking_set,
$GLOBALS['dbi']->getTable($GLOBALS['db'], $selected_table)->isView()
);
}
}
/**
* Function to get the entries
*
* @param array $data data
* @param int $filter_ts_from filter time stamp from
* @param int $filter_ts_to filter time stamp to
* @param array $filter_users filter users
*
* @return array
*/
function PMA_getEntries($data, $filter_ts_from, $filter_ts_to, $filter_users)
{
$entries = array();
// Filtering data definition statements
if ($_REQUEST['logtype'] == 'schema'
|| $_REQUEST['logtype'] == 'schema_and_data'
) {
$entries = array_merge(
$entries,
PMA_filterTracking(
$data['ddlog'], $filter_ts_from, $filter_ts_to, $filter_users
)
);
}
// Filtering data manipulation statements
if ($_REQUEST['logtype'] == 'data'
|| $_REQUEST['logtype'] == 'schema_and_data'
) {
$entries = array_merge(
$entries,
PMA_filterTracking(
$data['dmlog'], $filter_ts_from, $filter_ts_to, $filter_users
)
);
}
// Sort it
$ids = $timestamps = $usernames = $statements = array();
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
);
return $entries;
}
/**
* Function to get version status
*
* @param array $version version info
*
* @return string $version_status The status message
*/
function PMA_getVersionStatus($version)
{
if ($version['tracking_active'] == 1) {
return __('active');
} else {
return __('not active');
}
}
/**
* Display untracked tables
*
* @param string $db current database
* @param array $untracked_tables untracked tables
* @param string $url_query url query string
* @param string $pmaThemeImage path to theme's image folder
* @param string $text_dir text direction
*
* @return void
*/
function PMA_displayUntrackedTables(
$db, $untracked_tables, $url_query, $pmaThemeImage, $text_dir
) {
?>
';
$my_link .= PMA\libraries\Util::getIcon('eye.png', __('Track table'));
$my_link .= '';
?>
$value) {
if (is_array($value) && array_key_exists(('is' . $sep . 'group'), $value)
&& $value['is' . $sep . 'group']
) {
$untracked_tables = array_merge(PMA_extractTableNames($value, $db), $untracked_tables); //Recursion step
}
else {
if (is_array($value) && ($testing || Tracker::getVersion($db, $value['Name']) == -1)) {
$untracked_tables[] = $value['Name'];
}
}
}
return $untracked_tables;
}
/**
* Get untracked tables
*
* @param string $db current database
*
* @return array $untracked_tables
*/
function PMA_getUntrackedTables($db)
{
$table_list = PMA\libraries\Util::getTableList($db);
$untracked_tables = PMA_extractTableNames($table_list, $db); //Use helper function to get table list recursively.
return $untracked_tables;
}
/**
* Display tracked tables
*
* @param string $db current database
* @param object $all_tables_result result set of tracked tables
* @param string $url_query url query string
* @param string $pmaThemeImage path to theme's image folder
* @param string $text_dir text direction
* @param array $cfgRelation configuration storage info
*
* @return void
*/
function PMA_displayTrackedTables(
$db, $all_tables_result, $url_query, $pmaThemeImage, $text_dir, $cfgRelation
) {
?>
array(
'label' => __('not active'),
'value' => 'deactivate_now',
'selected' => ($state != 'active')
),
1 => array(
'label' => __('active'),
'value' => 'activate_now',
'selected' => ($state == 'active')
)
);
echo PMA\libraries\Util::toggleButton(
$tbl_link . '&version=' . $version_data['version'],
'toggle_activation',
$options,
null
);
}