Translated using Weblate (Indonesian)
[phpmyadmin.git] / db_tracking.php
blob3eb3eeab3d85be00191af81709695e2929bba012
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Tracking configuration for database
6 * @package PhpMyAdmin
7 */
8 use PMA\libraries\Response;
9 use PMA\libraries\Tracker;
11 /**
12 * Run common work
14 require_once 'libraries/common.inc.php';
16 require_once './libraries/tracking.lib.php';
17 require_once 'libraries/display_create_table.lib.php';
19 //Get some js files needed for Ajax requests
20 $response = Response::getInstance();
21 $header = $response->getHeader();
22 $scripts = $header->getScripts();
23 $scripts->addFile('jquery/jquery.tablesorter.js');
24 $scripts->addFile('db_tracking.js');
26 /**
27 * If we are not in an Ajax request, then do the common work and show the links etc.
29 require 'libraries/db_common.inc.php';
30 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
32 // Get the database structure
33 $sub_part = '_structure';
35 list(
36 $tables,
37 $num_tables,
38 $total_num_tables,
39 $sub_part,
40 $is_show_stats,
41 $db_is_system_schema,
42 $tooltip_truename,
43 $tooltip_aliasname,
44 $pos
45 ) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
47 // Work to do?
48 // (here, do not use $_REQUEST['db] as it can be crafted)
49 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
51 Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
52 PMA\libraries\Message::success(
53 __('Tracking data deleted successfully.')
54 )->display();
56 } elseif (isset($_REQUEST['submit_create_version'])) {
58 PMA_createTrackingForMultipleTables($_REQUEST['selected']);
59 PMA\libraries\Message::success(
60 sprintf(
61 __(
62 'Version %1$s was created for selected tables,'
63 . ' tracking is active for them.'
65 htmlspecialchars($_REQUEST['version'])
67 )->display();
69 } elseif (isset($_REQUEST['submit_mult'])) {
71 if (! empty($_REQUEST['selected_tbl'])) {
72 if ($_REQUEST['submit_mult'] == 'delete_tracking') {
74 foreach ($_REQUEST['selected_tbl'] as $table) {
75 Tracker::deleteTracking($GLOBALS['db'], $table);
77 PMA\libraries\Message::success(
78 __('Tracking data deleted successfully.')
79 )->display();
81 } elseif ($_REQUEST['submit_mult'] == 'track') {
83 echo PMA_getHtmlForDataDefinitionAndManipulationStatements(
84 'db_tracking.php' . $url_query,
86 $GLOBALS['db'],
87 $_REQUEST['selected_tbl']
89 exit;
91 } else {
92 PMA\libraries\Message::notice(
93 __('No tables selected.')
94 )->display();
98 // Get tracked data about the database
99 $data = Tracker::getTrackedData($_REQUEST['db'], '', '1');
101 // No tables present and no log exist
102 if ($num_tables == 0 && count($data['ddlog']) == 0) {
103 echo '<p>' , __('No tables found in database.') , '</p>' , "\n";
105 if (empty($db_is_system_schema)) {
106 echo PMA_getHtmlForCreateTable($db);
108 exit;
111 // ---------------------------------------------------------------------------
112 $cfgRelation = PMA_getRelationsParam();
114 // Prepare statement to get HEAD version
115 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
116 PMA\libraries\Util::backquote($cfgRelation['db']) . '.' .
117 PMA\libraries\Util::backquote($cfgRelation['tracking']) .
118 ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($_REQUEST['db']) .
119 '\' ' .
120 ' GROUP BY table_name' .
121 ' ORDER BY table_name ASC';
123 $all_tables_result = PMA_queryAsControlUser($all_tables_query);
125 // If a HEAD version exists
126 if (is_object($all_tables_result)
127 && $GLOBALS['dbi']->numRows($all_tables_result) > 0
129 PMA_displayTrackedTables(
130 $GLOBALS['db'], $all_tables_result, $url_query, $pmaThemeImage,
131 $text_dir, $cfgRelation
135 $untracked_tables = PMA_getUntrackedTables($GLOBALS['db']);
137 // If untracked tables exist
138 if (count($untracked_tables) > 0) {
139 PMA_displayUntrackedTables(
140 $GLOBALS['db'], $untracked_tables, $url_query, $pmaThemeImage, $text_dir
143 // If available print out database log
144 if (count($data['ddlog']) > 0) {
145 $log = '';
146 foreach ($data['ddlog'] as $entry) {
147 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n"
148 . $entry['statement'] . "\n";
150 echo PMA\libraries\Util::getMessage(__('Database Log'), $log);