예제 #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_information_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_information_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">' . $truename . '</a>';
    if (!$db_is_information_schema) {
        $empty_table = '<a ';
        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_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);
}
예제 #2
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;
예제 #3
0
        if (!empty($each_table['TABLE_ROWS'])) {
            $empty_table = '<a ';
            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);
    }
예제 #4
0
    /**
     * Test for PMA_Tracker::isTracked()
     *
     * @return void
     * @test
     */
    public function testIsTracked()
    {
        $attr = new \ReflectionProperty('PMA_Tracker', 'enabled');
        $attr->setAccessible(true);
        $attr->setValue(null, false);


        $reflection = new \ReflectionProperty('PMA_Tracker', 'pma_table');
        $reflection->setAccessible(true);
        $reflection->setValue(null, 'pma_table_tracking');

        $this->assertFalse(
            PMA_Tracker::isTracked("", "")
        );

        PMA_Tracker::enable();

        $_SESSION['relation'][$GLOBALS['server']]['trackingwork'] = false;

        $this->assertFalse(
            PMA_Tracker::isTracked("", "")
        );

        $_SESSION['relation'][$GLOBALS['server']]['trackingwork'] = true;

        $this->assertTrue(
            PMA_Tracker::isTracked("pma_test_db", "pma_test_table")
        );

        $reflection->setValue(null, 'pma_table_tracking');

        $this->assertFalse(
            PMA_Tracker::isTracked("pma_test_db", "pma_test_table2")
        );
    }
예제 #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);
}
예제 #6
0
/**
 * 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 = '<form method="post" action="tbl_tracking.php' . $url_query . '">';
    $html .= '<select name="table" class="autosubmit">';
    while ($entries = $GLOBALS['dbi']->fetchArray($selectable_tables_sql_result)) {
        if (PMA_Tracker::isTracked($entries['db_name'], $entries['table_name'])) {
            $status = ' (' . __('active') . ')';
        } else {
            $status = ' (' . __('not active') . ')';
        }
        if ($entries['table_name'] == $_REQUEST['table']) {
            $s = ' selected="selected"';
        } else {
            $s = '';
        }
        $html .= '<option value="' . htmlspecialchars($entries['table_name']) . '"' . $s . '>' . htmlspecialchars($entries['db_name']) . ' . ' . htmlspecialchars($entries['table_name']) . $status . '</option>' . "\n";
    }
    $html .= '</select>';
    $html .= '<input type="hidden" name="show_versions_submit" value="1" />';
    $html .= '</form>';
    return $html;
}
예제 #7
0
         $overhead_size += $tbl_stats['Data_free'];
     }
     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 .= '">';
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());
}
예제 #9
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