Exemplo 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_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);
}
Exemplo n.º 2
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;
Exemplo n.º 3
0
    /**
     * Test for PMA_Tracker::getVersion()
     *
     * @return void
     * @test
     */
    public function testGetVersion()
    {
        if (! PMA_HAS_RUNKIT) {
            $this->markTestSkipped("Cannot redefine constant");
        }

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

        runkit_constant_redefine("PMA_DRIZZLE", true);

        $sql_query = " SELECT MAX(version) FROM pma_table_tracking" .
        " WHERE `db_name` = 'pma''db' " .
        " AND `table_name` = 'pma''table' ";

        $sql_query_drizzle = ' AND tracking & 1 <> 0';

        $sql_query_non_drizzle = " AND FIND_IN_SET('UPDATE',tracking) > 0" ;

        $GLOBALS['controllink'] = null;

        $dbi = $this->getMockBuilder('PMA_DatabaseInterface')
            ->disableOriginalConstructor()
            ->getMock();

        $dbi->expects($this->at(0))
            ->method('query')
            ->with($sql_query . $sql_query_drizzle, null, 0, false)
            ->will($this->returnValue("executed_1"));

        $dbi->expects($this->at(1))
            ->method('fetchArray')
            ->with("executed_1")
            ->will($this->returnValue(array("executed_3")));

        $dbi->expects($this->at(2))
            ->method('query')
            ->with($sql_query . $sql_query_non_drizzle, null, 0, false)
            ->will($this->returnValue("executed_2"));

        $dbi->expects($this->at(3))
            ->method('fetchArray')
            ->with("executed_2")
            ->will($this->returnValue(array()));

        $GLOBALS['dbi'] = $dbi;

        // first assertion
        $this->assertEquals(
            "executed_3",
            PMA_Tracker::getVersion("pma'db", "pma'table", "UPDATE")
        );

        // second assertion
        runkit_constant_redefine("PMA_DRIZZLE", false);
        $this->assertEquals(
            -1,
            PMA_Tracker::getVersion("pma'db", "pma'table", "UPDATE")
        );
    }
Exemplo n.º 4
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;
            ?>
Exemplo n.º 5
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";
Exemplo n.º 6
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;
}