Esempio n. 1
0
/**
 * Get the HTML links for action links
 * Actions are, Browse, Search, Browse table label, empty table
 *
 * @param array   $current_table       current table
 * @param boolean $table_is_view       Is table view or not
 * @param string  $tbl_url_query       table url query
 * @param array   $titles              titles and icons for action links
 * @param string  $truename            table name
 * @param boolean $db_is_system_schema is database information schema or not
 * @param string  $url_query           url query
 *
 * @return array ($browse_table, $search_table, $browse_table_label, $empty_table,
 *                $tracking_icon)
 */
function PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_system_schema, $url_query)
{
    $empty_table = '';
    if ($current_table['TABLE_ROWS'] > 0 || $table_is_view) {
        $may_have_rows = true;
    } else {
        $may_have_rows = false;
    }
    $browse_table = '<a href="sql.php' . $tbl_url_query . '&amp;pos=0">';
    if ($may_have_rows) {
        $browse_table .= $titles['Browse'];
    } else {
        $browse_table .= $titles['NoBrowse'];
    }
    $browse_table .= '</a>';
    $search_table = '<a href="tbl_select.php' . $tbl_url_query . '">';
    if ($may_have_rows) {
        $search_table .= $titles['Search'];
    } else {
        $search_table .= $titles['NoSearch'];
    }
    $search_table .= '</a>';
    $browse_table_label = '<a href="sql.php' . $tbl_url_query . '&amp;pos=0" title="' . htmlspecialchars($current_table['TABLE_COMMENT']) . '">' . $truename . '</a>';
    if (!$db_is_system_schema) {
        $empty_table = '<a class="truncate_table_anchor ajax"';
        $empty_table .= ' href="sql.php' . $tbl_url_query . '&amp;sql_query=';
        $empty_table .= urlencode('TRUNCATE ' . PMA_Util::backquote($current_table['TABLE_NAME']));
        $empty_table .= '&amp;message_to_show=' . urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))) . '">';
        if ($may_have_rows) {
            $empty_table .= $titles['Empty'];
        } else {
            $empty_table .= $titles['NoEmpty'];
        }
        $empty_table .= '</a>';
        // truncating views doesn't work
        if ($table_is_view) {
            $empty_table = '&nbsp;';
        }
    }
    $tracking_icon = '';
    if (PMA_Tracker::isActive()) {
        if (PMA_Tracker::isTracked($GLOBALS["db"], $truename)) {
            $tracking_icon = '<a href="tbl_tracking.php' . $url_query . '&amp;table=' . $truename . '">' . PMA_Util::getImage('eye.png', __('Tracking is active.')) . '</a>';
        } elseif (PMA_Tracker::getVersion($GLOBALS["db"], $truename) > 0) {
            $tracking_icon = '<a href="tbl_tracking.php' . $url_query . '&amp;table=' . $truename . '">' . PMA_Util::getImage('eye_grey.png', __('Tracking is not active.')) . '</a>';
        }
    }
    return array($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon);
}
Esempio n. 2
0
 /**
  * Gets the tracking status of a table, is it active or deactive ?
  *
  * @static
  *
  * @param  string $dbname      name of database
  * @param  string $tablename   name of table
  *
  * @return boolean true or false
  */
 public static function isTracked($dbname, $tablename)
 {
     if (!self::$enabled) {
         return false;
     }
     /* We need to avoid attempt to track any queries from PMA_getRelationsParam */
     self::$enabled = false;
     $cfgRelation = PMA_getRelationsParam();
     /* Restore original state */
     self::$enabled = true;
     if (!$cfgRelation['trackingwork']) {
         return false;
     }
     $sql_query = " SELECT tracking_active FROM " . self::$pma_table . " WHERE " . PMA_backquote('db_name') . " = '" . PMA_sqlAddslashes($dbname) . "' " . " AND " . PMA_backquote('table_name') . " = '" . PMA_sqlAddslashes($tablename) . "' " . " ORDER BY version DESC";
     $row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
     if (isset($row['tracking_active']) && $row['tracking_active'] == 1) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
    if (isset($response) && $response->isAjax() && $token_mismatch) {
        $response->isSuccess(false);
        $response->addJSON('message', PMA_Message::error(__('Error: Token mismatch')));
        exit;
    }
} else {
    // end if !defined('PMA_MINIMUM_COMMON')
    // load user preferences
    $GLOBALS['PMA_Config']->loadUserPreferences();
}
// remove sensitive values from session
$GLOBALS['PMA_Config']->set('blowfish_secret', '');
$GLOBALS['PMA_Config']->set('Servers', '');
$GLOBALS['PMA_Config']->set('default_server', '');
/* Tell tracker that it can actually work */
PMA_Tracker::enable();
/**
 * @global boolean $GLOBALS['is_ajax_request']
 * @todo should this be moved to the variables init section above?
 *
 * Check if the current request is an AJAX request, and set is_ajax_request
 * accordingly.  Suppress headers, footers and unnecessary output if set to
 * true
 */
if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
    $GLOBALS['is_ajax_request'] = true;
} else {
    $GLOBALS['is_ajax_request'] = false;
}
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
    PMA_fatalError(__("GLOBALS overwrite attempt"));
Esempio n. 4
0
            if ($GLOBALS['cfg']['AjaxEnable']) {
                $empty_table .= 'class="truncate_table_anchor"';
            }
            $empty_table .= ' href="sql.php?' . $tbl_url_query . '&amp;sql_query=';
            $empty_table .= urlencode('TRUNCATE ' . PMA_backquote($each_table['TABLE_NAME'])) . '&amp;message_to_show=' . urlencode(sprintf(__('Table %s has been emptied'), htmlspecialchars($each_table['TABLE_NAME']))) . '">' . $titles['Empty'] . '</a>';
        } else {
            $empty_table = $titles['NoEmpty'];
        }
        $drop_query = 'DROP ' . ($table_is_view ? 'VIEW' : 'TABLE') . ' ' . PMA_backquote($each_table['TABLE_NAME']);
        $drop_message = sprintf($table_is_view ? __('View %s has been dropped') : __('Table %s has been dropped'), str_replace(' ', '&nbsp;', htmlspecialchars($each_table['TABLE_NAME'])));
    }
    $tracking_icon = '';
    if (PMA_Tracker::isActive()) {
        if (PMA_Tracker::isTracked($GLOBALS["db"], $truename)) {
            $tracking_icon = '<a href="tbl_tracking.php?' . $url_query . '&amp;table=' . $truename . '"><img class="icon" width="14" height="14" src="' . $pmaThemeImage . 'eye.png" alt="' . __('Tracking is active.') . '" title="' . __('Tracking is active.') . '" /></a>';
        } elseif (PMA_Tracker::getVersion($GLOBALS["db"], $truename) > 0) {
            $tracking_icon = '<a href="tbl_tracking.php?' . $url_query . '&amp;table=' . $truename . '"><img class="icon" width="14" height="14" src="' . $pmaThemeImage . 'eye_grey.png" alt="' . __('Tracking is not active.') . '" title="' . __('Tracking is not active.') . '" /></a>';
        }
    }
    if ($num_columns > 0 && $num_tables > $num_columns && $row_count % $num_columns == 0) {
        $row_count = 1;
        $odd_row = true;
        ?>
    </tr>
</tbody>
</table>
        <?php 
        PMA_TableHeader(false, $server_slave_status);
    }
    $ignored = false;
    $do = false;
Esempio n. 5
0
    $tabs['tracking']['icon'] = 'eye.png';
    $tabs['tracking']['text'] = __('Tracking');
    $tabs['tracking']['link'] = 'tbl_tracking.php';
}
if (!$tbl_is_view && !(isset($db_is_information_schema) && $db_is_information_schema)) {
}
/**
 * Views support a limited number of operations
 */
if ($tbl_is_view && !(isset($db_is_information_schema) && $db_is_information_schema)) {
    $tabs['operation']['icon'] = 'b_tblops.png';
    $tabs['operation']['link'] = 'view_operations.php';
    $tabs['operation']['text'] = __('Operations');
}
if ($table_info_num_rows == 0 && !$tbl_is_view) {
    $tabs['browse']['warning'] = __('Table seems to be empty!');
    $tabs['search']['warning'] = __('Table seems to be empty!');
}
echo PMA_generate_html_tabs($tabs, $url_params);
unset($tabs);
if (PMA_Tracker::isActive() and PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"])) {
    $msg = PMA_Message::notice('<a href="tbl_tracking.php?' . $url_query . '">' . sprintf(__('Tracking of %s.%s is activated.'), htmlspecialchars($GLOBALS["db"]), htmlspecialchars($GLOBALS["table"])) . '</a>');
    $msg->display();
}
/**
 * Displays a message
 */
if (!empty($message)) {
    PMA_showMessage($message);
    unset($message);
}
Esempio n. 6
0
    ?>
<a href="sql.php?<?php 
    echo $url_query;
    ?>
&amp;session_max_rows=all&amp;sql_query=<?php 
    echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()');
    ?>
"><?php 
    if ($cfg['PropertiesIconic']) {
        echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
    }
    echo $strStructPropose;
    ?>
</a><?php 
    echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
    if (PMA_Tracker::isActive()) {
        echo '<a href="tbl_tracking.php?' . $url_query . '">';
        if ($cfg['PropertiesIconic']) {
            echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
        }
        echo $strTrackingTrackTable . '</a>';
    }
    ?>
    
    <br />
<form method="post" action="tbl_addfield.php"
    onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php 
    echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']);
    ?>
', 1)">
    <?php 
Esempio n. 7
0
 /**
  * Returns the db tabs as an array
  *
  * @return array Data for generating db tabs
  */
 private function _getDbTabs()
 {
     $db_is_system_schema = $GLOBALS['dbi']->isSystemSchema($this->_db);
     $num_tables = count($GLOBALS['dbi']->getTables($this->_db));
     $is_superuser = $GLOBALS['dbi']->isSuperuser();
     $isCreateOrGrantUser = $GLOBALS['dbi']->isUserType('grant') || $GLOBALS['dbi']->isUserType('create');
     /**
      * Gets the relation settings
      */
     $cfgRelation = PMA_getRelationsParam();
     $tabs = array();
     $tabs['structure']['link'] = 'db_structure.php';
     $tabs['structure']['text'] = __('Structure');
     $tabs['structure']['icon'] = 'b_props.png';
     $tabs['sql']['link'] = 'db_sql.php';
     $tabs['sql']['text'] = __('SQL');
     $tabs['sql']['icon'] = 'b_sql.png';
     $tabs['search']['text'] = __('Search');
     $tabs['search']['icon'] = 'b_search.png';
     $tabs['search']['link'] = 'db_search.php';
     if ($num_tables == 0) {
         $tabs['search']['warning'] = __('Database seems to be empty!');
     }
     $tabs['qbe']['text'] = __('Query');
     $tabs['qbe']['icon'] = 's_db.png';
     $tabs['qbe']['link'] = 'db_qbe.php';
     if ($num_tables == 0) {
         $tabs['qbe']['warning'] = __('Database seems to be empty!');
     }
     $tabs['export']['text'] = __('Export');
     $tabs['export']['icon'] = 'b_export.png';
     $tabs['export']['link'] = 'db_export.php';
     if ($num_tables == 0) {
         $tabs['export']['warning'] = __('Database seems to be empty!');
     }
     if (!$db_is_system_schema) {
         $tabs['import']['link'] = 'db_import.php';
         $tabs['import']['text'] = __('Import');
         $tabs['import']['icon'] = 'b_import.png';
         $tabs['operation']['link'] = 'db_operations.php';
         $tabs['operation']['text'] = __('Operations');
         $tabs['operation']['icon'] = 'b_tblops.png';
         if (($is_superuser || $isCreateOrGrantUser) && !PMA_DRIZZLE) {
             $tabs['privileges']['link'] = 'server_privileges.php';
             $tabs['privileges']['args']['checkprivsdb'] = $this->_db;
             // stay on database view
             $tabs['privileges']['args']['viewing_mode'] = 'db';
             $tabs['privileges']['text'] = __('Privileges');
             $tabs['privileges']['icon'] = 's_rights.png';
         }
         if (!PMA_DRIZZLE) {
             $tabs['routines']['link'] = 'db_routines.php';
             $tabs['routines']['text'] = __('Routines');
             $tabs['routines']['icon'] = 'b_routines.png';
         }
         if (!PMA_DRIZZLE && PMA_Util::currentUserHasPrivilege('EVENT', $this->_db)) {
             $tabs['events']['link'] = 'db_events.php';
             $tabs['events']['text'] = __('Events');
             $tabs['events']['icon'] = 'b_events.png';
         }
         if (!PMA_DRIZZLE && PMA_Util::currentUserHasPrivilege('TRIGGER', $this->_db)) {
             $tabs['triggers']['link'] = 'db_triggers.php';
             $tabs['triggers']['text'] = __('Triggers');
             $tabs['triggers']['icon'] = 'b_triggers.png';
         }
     }
     if (PMA_Tracker::isActive()) {
         $tabs['tracking']['text'] = __('Tracking');
         $tabs['tracking']['icon'] = 'eye.png';
         $tabs['tracking']['link'] = 'db_tracking.php';
     }
     if (!$db_is_system_schema) {
         $tabs['designer']['text'] = __('Designer');
         $tabs['designer']['icon'] = 'b_relations.png';
         $tabs['designer']['link'] = 'db_designer.php';
         $tabs['designer']['id'] = 'designer_tab';
     }
     if (!$db_is_system_schema && isset($cfgRelation['central_columnswork']) && $cfgRelation['central_columnswork']) {
         $tabs['central_columns']['text'] = __('Central columns');
         $tabs['central_columns']['icon'] = 'centralColumns.png';
         $tabs['central_columns']['link'] = 'db_central_columns.php';
     }
     return $tabs;
 }
Esempio n. 8
0
 /**
  * Returns the db tabs as an array
  *
  * @return array Data for generating db tabs
  */
 private function _getDbTabs()
 {
     $db_is_information_schema = PMA_is_system_schema($this->_db);
     $num_tables = count(PMA_DBI_get_tables($this->_db));
     $is_superuser = PMA_isSuperuser();
     /**
      * Gets the relation settings
      */
     $cfgRelation = PMA_getRelationsParam();
     $tabs = array();
     $tabs['structure']['link'] = 'db_structure.php';
     $tabs['structure']['text'] = __('Structure');
     $tabs['structure']['icon'] = 'b_props.png';
     $tabs['sql']['link'] = 'db_sql.php';
     $tabs['sql']['args']['db_query_force'] = 1;
     $tabs['sql']['text'] = __('SQL');
     $tabs['sql']['icon'] = 'b_sql.png';
     $tabs['search']['text'] = __('Search');
     $tabs['search']['icon'] = 'b_search.png';
     $tabs['search']['link'] = 'db_search.php';
     if ($num_tables == 0) {
         $tabs['search']['warning'] = __('Database seems to be empty!');
     }
     $tabs['qbe']['text'] = __('Query');
     $tabs['qbe']['icon'] = 's_db.png';
     $tabs['qbe']['link'] = 'db_qbe.php';
     if ($num_tables == 0) {
         $tabs['qbe']['warning'] = __('Database seems to be empty!');
     }
     $tabs['export']['text'] = __('Export');
     $tabs['export']['icon'] = 'b_export.png';
     $tabs['export']['link'] = 'db_export.php';
     if ($num_tables == 0) {
         $tabs['export']['warning'] = __('Database seems to be empty!');
     }
     if (!$db_is_information_schema) {
         $tabs['import']['link'] = 'db_import.php';
         $tabs['import']['text'] = __('Import');
         $tabs['import']['icon'] = 'b_import.png';
         $tabs['operation']['link'] = 'db_operations.php';
         $tabs['operation']['text'] = __('Operations');
         $tabs['operation']['icon'] = 'b_tblops.png';
         if ($is_superuser && !PMA_DRIZZLE) {
             $tabs['privileges']['link'] = 'server_privileges.php';
             $tabs['privileges']['args']['checkprivs'] = $this->_db;
             // stay on database view
             $tabs['privileges']['args']['viewing_mode'] = 'db';
             $tabs['privileges']['text'] = __('Privileges');
             $tabs['privileges']['icon'] = 's_rights.png';
         }
         if (!PMA_DRIZZLE) {
             $tabs['routines']['link'] = 'db_routines.php';
             $tabs['routines']['text'] = __('Routines');
             $tabs['routines']['icon'] = 'b_routines.png';
         }
         if (PMA_MYSQL_INT_VERSION >= 50106 && !PMA_DRIZZLE && PMA_Util::currentUserHasPrivilege('EVENT', $this->_db)) {
             $tabs['events']['link'] = 'db_events.php';
             $tabs['events']['text'] = __('Events');
             $tabs['events']['icon'] = 'b_events.png';
         }
         if (!PMA_DRIZZLE && PMA_Util::currentUserHasPrivilege('TRIGGER', $this->_db)) {
             $tabs['triggers']['link'] = 'db_triggers.php';
             $tabs['triggers']['text'] = __('Triggers');
             $tabs['triggers']['icon'] = 'b_triggers.png';
         }
     }
     if (PMA_Tracker::isActive()) {
         $tabs['tracking']['text'] = __('Tracking');
         $tabs['tracking']['icon'] = 'eye.png';
         $tabs['tracking']['link'] = 'db_tracking.php';
     }
     if (!$db_is_information_schema && $cfgRelation['designerwork']) {
         $tabs['designer']['text'] = __('Designer');
         $tabs['designer']['icon'] = 'b_relations.png';
         $tabs['designer']['link'] = 'pmd_general.php';
     }
     return $tabs;
 }
Esempio n. 9
0
    if (!empty($_REQUEST['selected_tbl'])) {
        if ($_REQUEST['submit_mult'] == 'delete_tracking') {
            foreach ($_REQUEST['selected_tbl'] as $table) {
                PMA_Tracker::deleteTracking($GLOBALS['db'], $table);
            }
            PMA_Message::success(__('Tracking data deleted successfully.'))->display();
        } elseif ($_REQUEST['submit_mult'] == 'track') {
            echo PMA_getHtmlForDataDefinitionAndManipulationStatements('db_tracking.php' . $url_query, 0, $GLOBALS['db'], $_REQUEST['selected_tbl']);
            exit;
        }
    } else {
        PMA_Message::notice(__('No tables selected.'))->display();
    }
}
// Get tracked data about the database
$data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
// No tables present and no log exist
if ($num_tables == 0 && count($data['ddlog']) == 0) {
    echo '<p>' . __('No tables found in database.') . '</p>' . "\n";
    if (empty($db_is_system_schema)) {
        echo PMA_getHtmlForCreateTable($db);
    }
    exit;
}
// ---------------------------------------------------------------------------
$cfgRelation = PMA_getRelationsParam();
// Prepare statement to get HEAD version
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['tracking']) . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($_REQUEST['db']) . '\' ' . ' GROUP BY table_name' . ' ORDER BY table_name ASC';
$all_tables_result = PMA_queryAsControlUser($all_tables_query);
// If a HEAD version exists
if ($GLOBALS['dbi']->numRows($all_tables_result) > 0) {
require_once './libraries/bookmark.lib.php';
// Check parameters
PMA_Util::checkParameters(array('db', 'table'));
$db_is_system_schema = $GLOBALS['dbi']->isSystemSchema($db);
/**
 * Set parameters for links
 * @deprecated
 */
$url_query = PMA_URL_getCommon(array('db' => $db, 'table' => $table));
/**
 * Set parameters for links
 */
$url_params = array();
$url_params['db'] = $db;
$url_params['table'] = $table;
/**
 * Defines the urls to return to in case of error in a sql statement
 */
$err_url_0 = $cfg['DefaultTabDatabase'] . PMA_URL_getCommon(array('db' => $db));
$err_url = $cfg['DefaultTabTable'] . PMA_URL_getCommon($url_params);
/**
 * Ensures the database and the table exist (else move to the "parent" script)
 */
require_once './libraries/db_table_exists.lib.php';
if (PMA_Tracker::isActive() && PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"]) && !isset($_REQUEST['submit_deactivate_now']) && !(isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldumpfile')) {
    $temp_msg = '<a href="tbl_tracking.php' . $url_query . '">';
    $temp_msg .= sprintf(__('Tracking of %s is activated.'), htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"]));
    $temp_msg .= '</a>';
    $msg = PMA_Message::notice($temp_msg);
    PMA_Response::getInstance()->addHTML($msg->getDisplay());
}
Esempio n. 11
0
/**
 * Table tracking page
 *
 * @package PhpMyAdmin
 */
// Run common work
require_once './libraries/common.inc.php';
require_once './libraries/tbl_tracking.lib.php';
define('TABLE_MAY_BE_ABSENT', true);
require './libraries/tbl_common.inc.php';
$url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
$url_params['goto'] = 'tbl_tracking.php';
$url_params['back'] = 'tbl_tracking.php';
// Init vars for tracking report
if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
    $data = PMA_Tracker::getTrackedData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version']);
    $selection_schema = false;
    $selection_data = false;
    $selection_both = false;
    if (!isset($_REQUEST['logtype'])) {
        $_REQUEST['logtype'] = 'schema_and_data';
    }
    if ($_REQUEST['logtype'] == 'schema') {
        $selection_schema = true;
    } elseif ($_REQUEST['logtype'] == 'data') {
        $selection_data = true;
    } else {
        $selection_both = true;
    }
    if (!isset($_REQUEST['date_from'])) {
        $_REQUEST['date_from'] = $data['date_from'];
Esempio n. 12
0
$db_is_system_schema = $GLOBALS['dbi']->isSystemSchema($db);
/**
 * Set parameters for links
 * @deprecated
 */
$url_query = PMA_URL_getCommon($db, $table);
/**
 * Set parameters for links
 */
$url_params = array();
$url_params['db'] = $db;
$url_params['table'] = $table;
/**
 * Defines the urls to return to in case of error in a sql statement
 */
$err_url_0 = $cfg['DefaultTabDatabase'] . PMA_URL_getCommon(array('db' => $db));
$err_url = $cfg['DefaultTabTable'] . PMA_URL_getCommon($url_params);
/**
 * Ensures the database and the table exist (else move to the "parent" script)
 */
require_once './libraries/db_table_exists.lib.php';
if (PMA_Tracker::isActive() && PMA_Tracker::isTracked($GLOBALS["db"], $GLOBALS["table"]) && !isset($_REQUEST['submit_deactivate_now'])) {
    $temp_msg = '<a href="tbl_tracking.php?' . $url_query . '">';
    $temp_msg .= sprintf(__('Tracking of %s is activated.'), htmlspecialchars($GLOBALS["db"] . '.' . $GLOBALS["table"]));
    $temp_msg .= '</a>';
    $msg = PMA_Message::notice($temp_msg);
    $msg->display();
}
?>
>>>>>>> b875702c9c06ab5012e52ff4337439b03918f453
Esempio n. 13
0
/**
 * Get untracked tables
 *
 * @param string $db current database
 *
 * @return array $untracked_tables
 */
function PMA_getUntrackedTables($db)
{
    $untracked_tables = array();
    $sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
    // Get list of tables
    $table_list = PMA_Util::getTableList($db);
    // For each table try to get the tracking version
    foreach ($table_list as $key => $value) {
        // If $value is a table group.
        if (array_key_exists('is' . $sep . 'group', $value) && $value['is' . $sep . 'group']) {
            foreach ($value as $temp_table) {
                // If $temp_table is a table with the value for 'Name' is set,
                // rather than a property of the table group.
                if (is_array($temp_table) && array_key_exists('Name', $temp_table)) {
                    $tracking_version = PMA_Tracker::getVersion($db, $temp_table['Name']);
                    if ($tracking_version == -1) {
                        $untracked_tables[] = $temp_table['Name'];
                    }
                }
            }
        } else {
            // If $value is a table.
            if (PMA_Tracker::getVersion($db, $value['Name']) == -1) {
                $untracked_tables[] = $value['Name'];
            }
        }
    }
    return $untracked_tables;
}
Esempio n. 14
0
/**
 * runs a query and returns the result
 *
 * @param string $query query to run
 * @param resource $link mysql link resource
 * @param integer $options
 * @return mixed
 */
function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_rows = true)
{
    //print_r($query);
    if (empty($link)) {
        if (isset($GLOBALS['userlink'])) {
            $link = $GLOBALS['userlink'];
        } else {
            return false;
        }
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true);
    }
    /*
        if ($options == ($options | PMA_DBI_QUERY_STORE)) {
            $r = mysql_query($query, $link);
        } elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
            $r = mysql_unbuffered_query($query, $link);
        } else {
            $r = mysql_query($query, $link);
        }
    */
    $stid = oci_parse($link, $query);
    if (!$stid) {
        $e = oci_error($link);
        // For oci_execute errors pass the statement handle
        PMA_mysqlDie($e['message'], $query);
    }
    $result_sql = oci_execute($stid);
    if (!$result_sql) {
        $e = oci_error($stid);
        // For oci_execute errors pass the statement handle
        //$error_str = ($e['message'])
        //. ($e['sqltext']);
        $sql_str = substr_replace($e['sqltext'], '^', $e['offset'], 0);
        PMA_mysqlDie($e['message'], $sql_str);
    }
    $r = $stid;
    if ($cache_affected_rows) {
        $GLOBALS['cached_affected_rows'] = PMA_DBI_affected_rows($r, $get_from_cache = false);
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true) - $time;
        $hash = md5($query);
        if (isset($_SESSION['debug']['queries'][$hash])) {
            $_SESSION['debug']['queries'][$hash]['count']++;
        } else {
            $_SESSION['debug']['queries'][$hash] = array();
            $_SESSION['debug']['queries'][$hash]['count'] = 1;
            $_SESSION['debug']['queries'][$hash]['query'] = $query;
            $_SESSION['debug']['queries'][$hash]['time'] = $time;
        }
        $trace = array();
        foreach (debug_backtrace() as $trace_step) {
            $trace[] = PMA_Error::relPath($trace_step['file']) . '#' . $trace_step['line'] . ': ' . (isset($trace_step['class']) ? $trace_step['class'] : '') . (isset($trace_step['type']) ? $trace_step['type'] : '') . (isset($trace_step['function']) ? $trace_step['function'] : '') . '(' . (isset($trace_step['params']) ? implode(', ', $trace_step['params']) : '') . ')';
        }
        $_SESSION['debug']['queries'][$hash]['trace'][] = $trace;
    }
    if ($r != FALSE && PMA_Tracker::isActive() == TRUE) {
        PMA_Tracker::handleQuery($query);
    }
    return $r;
}
Esempio n. 15
0
/**
 * Get HTML links for 'Print view', 'Relation view', 'Propose table structure',
 * 'Track table' and 'Move columns'
 *
 * @param string  $url_query           url query
 * @param boolean $tbl_is_view         whether table is view or not
 * @param boolean $db_is_system_schema whether db is information schema or not
 *
 * @return string $html_output
 */
function PMA_getHtmlForOptionalActionLinks($url_query, $tbl_is_view, $db_is_system_schema)
{
    $html_output = '<a href="tbl_printview.php' . $url_query . '" target="print_view">' . PMA_Util::getIcon('b_print.png', __('Print view'), true) . '</a>';
    if (!$tbl_is_view && !$db_is_system_schema) {
        if (!PMA_DRIZZLE) {
            $html_output .= '<a href="sql.php' . $url_query . '&amp;session_max_rows=all&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_Util::backquote($GLOBALS['table']) . ' PROCEDURE ANALYSE()') . '">' . PMA_Util::getIcon('b_tblanalyse.png', __('Propose table structure'), true) . '</a>';
            $html_output .= PMA_Util::showMySQLDocu('procedure_analyse') . "\n";
        }
        if (PMA_Tracker::isActive()) {
            $html_output .= '<a href="tbl_tracking.php' . $url_query . '">' . PMA_Util::getIcon('eye.png', __('Track table'), true) . '</a>';
        }
        $html_output .= '<a href="#" id="move_columns_anchor">' . PMA_Util::getIcon('b_move.png', __('Move columns'), true) . '</a>';
        $html_output .= '<a href="normalization.php' . $url_query . '">' . PMA_Util::getIcon('normalize.png', __('Improve table structure'), true) . '</a>';
    }
    if ($tbl_is_view && !$db_is_system_schema) {
        if (PMA_Tracker::isActive()) {
            $html_output .= '<a href="tbl_tracking.php' . $url_query . '">' . PMA_Util::getIcon('eye.png', __('Track view'), true) . '</a>';
        }
    }
    return $html_output;
}
Esempio n. 16
0
 /**
  * runs a query and returns the result
  *
  * @param string   $query               query to run
  * @param resource $link                mysql link resource
  * @param integer  $options             query options
  * @param bool     $cache_affected_rows whether to cache affected row
  *
  * @return mixed
  */
 public function tryQuery($query, $link = null, $options = 0, $cache_affected_rows = true)
 {
     if (empty($link)) {
         if (isset($GLOBALS['userlink'])) {
             $link = $GLOBALS['userlink'];
         } else {
             return false;
         }
     }
     if ($GLOBALS['cfg']['DBG']['sql']) {
         $time = microtime(true);
     }
     $result = $this->_extension->realQuery($query, $link, $options);
     if ($cache_affected_rows) {
         $GLOBALS['cached_affected_rows'] = $this->affectedRows($link, false);
     }
     if ($GLOBALS['cfg']['DBG']['sql']) {
         $time = microtime(true) - $time;
         $this->_dbgQuery($query, $link, $result, $time);
     }
     if ($result != false && PMA_Tracker::isActive() == true) {
         PMA_Tracker::handleQuery($query);
     }
     return $result;
 }
Esempio n. 17
0
 /**
  * Transforms tracking set for Drizzle, which has no SET type
  *
  * Converts int<>string for Drizzle, does nothing for MySQL
  *
  * @param int|string $tracking_set Set to convert
  *
  * @return int|string
  */
 private static function _transformTrackingSet($tracking_set)
 {
     if (!PMA_DRIZZLE) {
         return $tracking_set;
     }
     // init conversion array (key 3 doesn't exist in calculated array)
     if (isset(self::$_tracking_set_flags[3])) {
         // initialize flags
         $set = self::$_tracking_set_flags;
         $array = array();
         for ($i = 0, $nb = count($set); $i < $nb; $i++) {
             $flag = 1 << $i;
             $array[$flag] = $set[$i];
             $array[$set[$i]] = $flag;
         }
         self::$_tracking_set_flags = $array;
     }
     if (is_numeric($tracking_set)) {
         // int > string conversion
         $aflags = array();
         // count/2 - conversion table has both int > string
         // and string > int values
         for ($i = 0, $nb = count(self::$_tracking_set_flags) / 2; $i < $nb; $i++) {
             $flag = 1 << $i;
             if ($tracking_set & $flag) {
                 $aflags[] = self::$_tracking_set_flags[$flag];
             }
         }
         $flags = implode(',', $aflags);
     } else {
         // string > int conversion
         $flags = 0;
         foreach (explode(',', $tracking_set) as $strflag) {
             if ($strflag == '') {
                 continue;
             }
             $flags |= self::$_tracking_set_flags[$strflag];
         }
     }
     return $flags;
 }
Esempio n. 18
0
/**
 * Get HTML links for 'Print view', 'Relation view', 'Propose table structure',
 * 'Track table' and 'Move columns'
 *
 * @param string  $url_query           url query
 * @param boolean $tbl_is_view         whether table is view or not
 * @param boolean $db_is_system_schema whether db is information schema or not
 * @param string  $tbl_storage_engine  table storage engine
 * @param array   $cfgRelation         current relation parameters
 *
 * @return string $html_output
 */
function PMA_getHtmlForOptionalActionLinks($url_query, $tbl_is_view, $db_is_system_schema, $tbl_storage_engine, $cfgRelation)
{
    $html_output = '<a href="tbl_printview.php?' . $url_query . '" target="print_view">' . PMA_Util::getIcon('b_print.png', __('Print view'), true) . '</a>';
    if (!$tbl_is_view && !$db_is_system_schema) {
        // if internal relations are available, or foreign keys are supported
        // ($tbl_storage_engine comes from libraries/tbl_info.inc.php
        if ($cfgRelation['relwork'] || PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
            $html_output .= '<a href="tbl_relation.php?' . $url_query . '">' . PMA_Util::getIcon('b_relations.png', __('Relation view'), true) . '</a>';
        }
        if (!PMA_DRIZZLE) {
            $html_output .= '<a href="sql.php?' . $url_query . '&amp;session_max_rows=all&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_Util::backquote($GLOBALS['table']) . ' PROCEDURE ANALYSE()') . '">' . PMA_Util::getIcon('b_tblanalyse.png', __('Propose table structure'), true) . '</a>';
            $html_output .= PMA_Util::showMySQLDocu('procedure_analyse') . "\n";
        }
        if (PMA_Tracker::isActive()) {
            $html_output .= '<a href="tbl_tracking.php?' . $url_query . '">' . PMA_Util::getIcon('eye.png', __('Track table'), true) . '</a>';
        }
        $html_output .= '<a href="#" id="move_columns_anchor">' . PMA_Util::getIcon('b_move.png', __('Move columns'), true) . '</a>';
    }
    return $html_output;
}
Esempio n. 19
0
     if (isset($formatted_overhead)) {
         $overhead = $formatted_overhead . ' ' . $overhead_unit;
         unset($formatted_overhead);
     } else {
         $overhead = '-';
     }
 }
 $new_table_string = '<tr>' . "\n";
 $new_table_string .= '<td align="center"> <input type="checkbox" id="checkbox_tbl_" name="selected_tbl[]" value="' . htmlspecialchars($table) . '" /> </td>' . "\n";
 $new_table_string .= '<th>';
 $new_table_string .= '<a href="sql.php' . PMA_generate_common_url($tbl_url_params) . '">' . htmlspecialchars($table) . '</a>';
 if (PMA_Tracker::isActive()) {
     $truename = str_replace(' ', '&nbsp;', htmlspecialchars($table));
     if (PMA_Tracker::isTracked($db, $truename)) {
         $new_table_string .= '<a href="tbl_tracking.php' . PMA_generate_common_url($tbl_url_params) . '"><img class="icon" width="14" height="14" src="' . $pmaThemeImage . 'eye.png" alt="' . __('Tracking is active.') . '" title="' . __('Tracking is active.') . '" /></a>';
     } elseif (PMA_Tracker::getVersion($db, $truename) > 0) {
         $new_table_string .= '<a href="tbl_tracking.php' . PMA_generate_common_url($tbl_url_params) . '"><img class="icon" width="14" height="14" src="' . $pmaThemeImage . 'eye_grey.png" alt="' . __('Tracking is not active.') . '" title="' . __('Tracking is not active.') . '" /></a>';
     }
     unset($truename);
 }
 $new_table_string .= '</th>' . "\n";
 $new_table_string .= '<td>' . $titles['NoBrowse'] . '</td>' . "\n";
 $new_table_string .= '<td><a href="tbl_structure.php' . PMA_generate_common_url($tbl_url_params) . '">' . $titles['Structure'] . '</a></td>' . "\n";
 $new_table_string .= '<td>' . $titles['NoSearch'] . '</td>' . "\n";
 $new_table_string .= '<td><a href="tbl_change.php' . PMA_generate_common_url($tbl_url_params) . '">' . $titles['Insert'] . '</a></td>' . "\n";
 $new_table_string .= '<td>' . $titles['NoEmpty'] . '</td>' . "\n";
 $new_table_string .= '<td><a class="drop_table_anchor" href="sql.php' . PMA_generate_common_url($tbl_url_params) . '&amp;sql_query=';
 $new_table_string .= urlencode('DROP TABLE ' . PMA_backquote($table));
 $new_table_string .= '">';
 $new_table_string .= $titles['Drop'];
 $new_table_string .= '</a></td>' . "\n";
/**
 * runs a query and returns the result
 *
 * @param string   $query               query to run
 * @param resource $link                mysql link resource
 * @param integer  $options             query options
 * @param bool     $cache_affected_rows whether to cache affected row
 *
 * @return mixed
 */
function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_rows = true)
{
    if (empty($link)) {
        if (isset($GLOBALS['userlink'])) {
            $link = $GLOBALS['userlink'];
        } else {
            return false;
        }
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true);
    }
    $r = PMA_DBI_real_query($query, $link, $options);
    if ($cache_affected_rows) {
        $GLOBALS['cached_affected_rows'] = PMA_DBI_affected_rows($link, $get_from_cache = false);
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true) - $time;
        $hash = md5($query);
        if (isset($_SESSION['debug']['queries'][$hash])) {
            $_SESSION['debug']['queries'][$hash]['count']++;
        } else {
            $_SESSION['debug']['queries'][$hash] = array();
            if ($r == false) {
                $_SESSION['debug']['queries'][$hash]['error'] = '<b style="color:red">' . mysqli_error($link) . '</b>';
            }
            $_SESSION['debug']['queries'][$hash]['count'] = 1;
            $_SESSION['debug']['queries'][$hash]['query'] = $query;
            $_SESSION['debug']['queries'][$hash]['time'] = $time;
        }
        $trace = array();
        foreach (debug_backtrace() as $trace_step) {
            $trace[] = PMA_Error::relPath($trace_step['file']) . '#' . $trace_step['line'] . ': ' . (isset($trace_step['class']) ? $trace_step['class'] : '') . (isset($trace_step['type']) ? $trace_step['type'] : '') . (isset($trace_step['function']) ? $trace_step['function'] : '') . '(' . (isset($trace_step['params']) ? implode(', ', $trace_step['params']) : '') . ')';
        }
        $_SESSION['debug']['queries'][$hash]['trace'][] = $trace;
    }
    if ($r != false && PMA_Tracker::isActive() == true) {
        PMA_Tracker::handleQuery($query);
    }
    return $r;
}
Esempio n. 21
0
/**
 * runs a query and returns the result
 *
 * @uses    PMA_DBI_QUERY_STORE
 * @uses    PMA_DBI_QUERY_UNBUFFERED
 * @uses    $GLOBALS['userlink']
 * @uses    MYSQLI_STORE_RESULT
 * @uses    MYSQLI_USE_RESULT
 * @uses    mysqli_query()
 * @uses    defined()
 * @param   string          $query      query to execute
 * @param   object mysqli   $link       mysqli object
 * @param   integer         $options
 * @param   boolean         $cache_affected_rows
 * @return  mixed           true, false or result object
 */
function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_rows = true)
{
    if ($options == ($options | PMA_DBI_QUERY_STORE)) {
        $method = MYSQLI_STORE_RESULT;
    } elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
        $method = MYSQLI_USE_RESULT;
    } else {
        $method = 0;
    }
    if (empty($link)) {
        if (isset($GLOBALS['userlink'])) {
            $link = $GLOBALS['userlink'];
        } else {
            return false;
        }
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true);
    }
    $r = mysqli_query($link, $query, $method);
    if ($cache_affected_rows) {
        $GLOBALS['cached_affected_rows'] = PMA_DBI_affected_rows($link, $get_from_cache = false);
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true) - $time;
        $hash = md5($query);
        if (isset($_SESSION['debug']['queries'][$hash])) {
            $_SESSION['debug']['queries'][$hash]['count']++;
        } else {
            $_SESSION['debug']['queries'][$hash] = array();
            $_SESSION['debug']['queries'][$hash]['count'] = 1;
            $_SESSION['debug']['queries'][$hash]['query'] = $query;
            $_SESSION['debug']['queries'][$hash]['time'] = $time;
        }
        $trace = array();
        foreach (debug_backtrace() as $trace_step) {
            $trace[] = PMA_Error::relPath($trace_step['file']) . '#' . $trace_step['line'] . ': ' . (isset($trace_step['class']) ? $trace_step['class'] : '') . (isset($trace_step['type']) ? $trace_step['type'] : '') . (isset($trace_step['function']) ? $trace_step['function'] : '') . '(' . (isset($trace_step['params']) ? implode(', ', $trace_step['params']) : '') . ')';
        }
        $_SESSION['debug']['queries'][$hash]['trace'][] = $trace;
    }
    if ($r != FALSE && PMA_Tracker::isActive() == TRUE) {
        PMA_Tracker::handleQuery($query);
    }
    return $r;
    // From the PHP manual:
    // "note: returns true on success or false on failure. For SELECT,
    // SHOW, DESCRIBE or EXPLAIN, mysqli_query() will return a result object"
    // so, do not use the return value to feed mysqli_num_rows() if it's
    // a boolean
}
Esempio n. 22
0
/**
 * 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) {
        PMA_Tracker::createVersion($GLOBALS['db'], $selected_table, $_REQUEST['version'], $tracking_set, PMA_Table::isView($GLOBALS['db'], $selected_table));
    }
}
/**
 * runs a query and returns the result
 *
 * @param string   $query               query to run
 * @param resource $link                mysql link resource
 * @param integer  $options             query options
 * @param bool     $cache_affected_rows whether to cache affected row
 *
 * @return mixed
 */
function PMA_DBI_try_query($query, $link = null, $options = 0, $cache_affected_rows = true)
{
    if (empty($link)) {
        if (isset($GLOBALS['userlink'])) {
            $link = $GLOBALS['userlink'];
        } else {
            return false;
        }
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true);
    }
    $result = PMA_DBI_real_query($query, $link, $options);
    if ($cache_affected_rows) {
        $GLOBALS['cached_affected_rows'] = PMA_DBI_affected_rows($link, $get_from_cache = false);
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true) - $time;
        PMA_DBI_DBG_query($query, $link, $result, $time);
    }
    if ($result != false && PMA_Tracker::isActive() == true) {
        PMA_Tracker::handleQuery($query);
    }
    return $result;
}
Esempio n. 24
0
    /**
     * Test for PMA_Tracker::parseQuery
     *
     * @param string $query                  Query to parse
     * @param string $type                   Expected type
     * @param string $identifier             Expected identifier
     * @param string $tablename              Expected tablename
     * @param string $db                     Expected dbname
     * @param string $tablename_after_rename Expected name after rename
     *
     * @return void
     *
     * @test
     * @dataProvider parseQueryData
     */
    public function testParseQuery($query, $type, $identifier, $tablename,
        $db = null, $tablename_after_rename = null
    ) {
        $result = PMA_Tracker::parseQuery($query);

        $this->assertEquals(
            $type,
            $result['type']
        );

        $this->assertEquals(
            $identifier,
            $result['identifier']
        );

        $this->assertEquals(
            $tablename,
            $result['tablename']
        );

        if ($db) {
            $this->assertEquals(
                $db,
                $GLOBALS['db']
            );
        }

        if ($tablename_after_rename) {
            $this->assertEquals(
                $result['tablename_after_rename'],
                $tablename_after_rename
            );
        }
    }
Esempio n. 25
0
/**
 * Function to create the tracking version
 *
 * @return void
 */
function PMA_createTrackingVersion()
{
    $tracking_set = PMA_getTrackingSet();
    $versionCreated = PMA_Tracker::createVersion($GLOBALS['db'], $GLOBALS['table'], $_REQUEST['version'], $tracking_set, PMA_Table::isView($GLOBALS['db'], $GLOBALS['table']));
    if ($versionCreated) {
        $msg = PMA_Message::success(sprintf(__('Version %1$s was created, tracking for %2$s is active.'), htmlspecialchars($_REQUEST['version']), htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table'])));
        $msg->display();
    }
}
Esempio n. 26
0
/**
 * runs a query and returns the result
 *
 * @param string $query query to run
 * @param resource $link mysql link resource
 * @param integer $options
 * @return mixed
 */
function PMA_DBI_try_query($query, $link = null, $options = 0)
{
    if (empty($link)) {
        if (isset($GLOBALS['userlink'])) {
            $link = $GLOBALS['userlink'];
        } else {
            return false;
        }
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true);
    }
    if ($options == ($options | PMA_DBI_QUERY_STORE)) {
        $r = mysql_query($query, $link);
    } elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
        $r = mysql_unbuffered_query($query, $link);
    } else {
        $r = mysql_query($query, $link);
    }
    if ($GLOBALS['cfg']['DBG']['sql']) {
        $time = microtime(true) - $time;
        $hash = md5($query);
        if (isset($_SESSION['debug']['queries'][$hash])) {
            $_SESSION['debug']['queries'][$hash]['count']++;
        } else {
            $_SESSION['debug']['queries'][$hash] = array();
            $_SESSION['debug']['queries'][$hash]['count'] = 1;
            $_SESSION['debug']['queries'][$hash]['query'] = $query;
            $_SESSION['debug']['queries'][$hash]['time'] = $time;
        }
        $trace = array();
        foreach (debug_backtrace() as $trace_step) {
            $trace[] = PMA_Error::relPath($trace_step['file']) . '#' . $trace_step['line'] . ': ' . (isset($trace_step['class']) ? $trace_step['class'] : '') . (isset($trace_step['type']) ? $trace_step['type'] : '') . (isset($trace_step['function']) ? $trace_step['function'] : '') . '(' . (isset($trace_step['params']) ? implode(', ', $trace_step['params']) : '') . ')';
        }
        $_SESSION['debug']['queries'][$hash]['trace'][] = $trace;
    }
    if ($r != FALSE && PMA_Tracker::isActive() == TRUE) {
        PMA_Tracker::handleQuery($query);
    }
    return $r;
}
Esempio n. 27
0
    <table id="noversions" class="data">
    <thead>
    <tr>
        <th style="width: 300px"><?php 
    echo __('Table');
    ?>
</th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <?php 
    // Print out list of untracked tables
    $style = 'odd';
    foreach ($my_tables as $key => $tablename) {
        if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
            $my_link = '<a href="tbl_tracking.php' . $url_query . '&amp;table=' . htmlspecialchars($tablename) . '">';
            $my_link .= PMA_Util::getIcon('eye.png', __('Track table'));
            $my_link .= '</a>';
            ?>
            <tr class="noclick <?php 
            echo $style;
            ?>
">
            <td><?php 
            echo htmlspecialchars($tablename);
            ?>
</td>
            <td><?php 
            echo $my_link;
            ?>
Esempio n. 28
0
// 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) {
    ?>
    <form method="post" action="tbl_tracking.php?<?php 
    echo $url_query;
    ?>
">
    <select name="table">
    <?php 
    while ($entries = PMA_DBI_fetch_array($sql_result)) {
        if (PMA_Tracker::isTracked($entries['db_name'], $entries['table_name'])) {
            $status = ' (' . $strTrackingStatusActive . ')';
        } else {
            $status = ' (' . $strTrackingStatusNotActive . ')';
        }
        if ($entries['table_name'] == $_REQUEST['table']) {
            $s = ' selected="selected"';
        } else {
            $s = '';
        }
        echo '<option value="' . htmlspecialchars($entries['table_name']) . '"' . $s . '>' . htmlspecialchars($entries['db_name']) . ' . ' . htmlspecialchars($entries['table_name']) . $status . '</option>' . "\n";
    }
    ?>
    </select>
    <input type="submit" name="show_versions_submit" value="<?php 
    echo $strTrackingShowVersions;
Esempio n. 29
0
 /**
  * Gets the tracking status of a table, is it active or deactive ?
  *
  * @param string $dbname    name of database
  * @param string $tablename name of table
  *
  * @static
  *
  * @return boolean true or false
  */
 public static function isTracked($dbname, $tablename)
 {
     if (!self::$enabled) {
         return false;
     }
     /* We need to avoid attempt to track any queries
      * from PMA_getRelationsParam
      */
     self::$enabled = false;
     $cfgRelation = PMA_getRelationsParam();
     /* Restore original state */
     self::$enabled = true;
     if (!$cfgRelation['trackingwork']) {
         return false;
     }
     $sql_query = " SELECT tracking_active FROM " . self::_getTrackingTable() . " WHERE db_name = '" . PMA_Util::sqlAddSlashes($dbname) . "' " . " AND table_name = '" . PMA_Util::sqlAddSlashes($tablename) . "' " . " ORDER BY version DESC";
     $row = $GLOBALS['dbi']->fetchArray(PMA_queryAsControlUser($sql_query));
     if (isset($row['tracking_active']) && $row['tracking_active'] == 1) {
         return true;
     } else {
         return false;
     }
 }