/**
 * Initializes PBMS database
 *
 * @return bool
 */
function initPBMSDatabase()
{
    // If no other choice then try this.
    $query = "create database IF NOT EXISTS pbms;";
    /*
     * The user may not have privileges to create the 'pbms' database
     * so if it doesn't exist then we perform a select on a pbms system
     * table in an already existing database which will cause the PBMS
     * daemon to create the 'pbms' database.
     */
    $db_array = PMA_DBI_fetch_result('SHOW DATABASES;');
    if (!empty($db_array)) {
        $target = "";
        foreach ($db_array as $current_db) {
            if ($current_db == 'pbms') {
                return true;
            }
            if ($target == "") {
                if ($current_db != 'pbxt' && !PMA_is_system_schema($current_db, true)) {
                    $target = $current_db;
                }
            }
        }
        if ($target != "") {
            // If it exists this table will not contain much
            $query = "select * from {$target}.pbms_metadata_header";
        }
    }
    $result = PMA_DBI_query($query);
    if (!$result) {
        return false;
    }
    return true;
}
Exemple #2
0
function PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query, $column_order, $replication_types, $replication_info)
{
    $out = '';
    if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
        $out .= '<td class="tool">';
        $out .= '<input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ';
        if (!PMA_is_system_schema($current['SCHEMA_NAME'], true)) {
            $out .= (empty($checkall) ? '' : 'checked="checked" ') . '/>';
        } else {
            $out .= ' disabled="disabled" />';
        }
        $out .= '</td>';
    }
    $out .= '<td class="name">' . '        <a onclick="' . 'if (window.parent.openDb &amp;&amp; window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;' . '" href="index.php?' . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME'])) . '" target="_parent">' . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . '</a>' . '</td>';
    foreach ($column_order as $stat_name => $stat) {
        if (array_key_exists($stat_name, $current)) {
            if (is_numeric($stat['footer'])) {
                $column_order[$stat_name]['footer'] += $current[$stat_name];
            }
            if ($stat['format'] === 'byte') {
                list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
            } elseif ($stat['format'] === 'number') {
                $value = PMA_formatNumber($current[$stat_name], 0);
            } else {
                $value = htmlentities($current[$stat_name], 0);
            }
            $out .= '<td class="value">';
            if (isset($stat['description_function'])) {
                $out .= '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
            }
            $out .= $value;
            if (isset($stat['description_function'])) {
                $out .= '</dfn>';
            }
            $out .= '</td>';
            if ($stat['format'] === 'byte') {
                $out .= '<td class="unit">' . $unit . '</td>';
            }
        }
    }
    foreach ($replication_types as $type) {
        if ($replication_info[$type]['status']) {
            $out .= '<td class="tool" style="text-align: center;">';
            if (strlen(array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB'])) > 0) {
                $out .= PMA_getIcon('s_cancel.png', __('Not replicated'));
            } else {
                $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']);
                if (strlen($key) > 0 || $replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1) {
                    // if ($key != null) did not work for index "0"
                    $out .= PMA_getIcon('s_success.png', __('Replicated'));
                }
            }
            $out .= '</td>';
        }
    }
    if ($is_superuser && !PMA_DRIZZLE) {
        $out .= '<td class="tool">' . '<a onclick="' . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');' . '" href="server_privileges.php?' . $url_query . '&amp;checkprivs=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Check privileges for database &quot;%s&quot;.'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . PMA_getIcon('s_rights.png', __('Check Privileges')) . '</a></td>';
    }
    return array($column_order, $out);
}
Exemple #3
0
 /**
  * returns HTML <option>-tags to be used inside <select></select>
  *
  * @param mixed   $selected                   the selected db or true for
  *                                            selecting current db
  * @param boolean $include_information_schema whether include information schema
  *
  * @return string  HTML option tags
  */
 public function getHtmlOptions($selected = '', $include_information_schema = true)
 {
     if (true === $selected) {
         $selected = $this->getDefault();
     }
     $options = '';
     foreach ($this as $each_item) {
         if (false === $include_information_schema && PMA_is_system_schema($each_item)) {
             continue;
         }
         $options .= '<option value="' . htmlspecialchars($each_item) . '"';
         if ($selected === $each_item) {
             $options .= ' selected="selected"';
         }
         $options .= '>' . htmlspecialchars($each_item) . '</option>' . "\n";
     }
     return $options;
 }
/**
 * returns code for selecting databases
 *
 * @return String HTML code
 */
function PMA_replication_db_multibox()
{
    $multi_values = '';
    $multi_values .= '<select name="db_select[]" size="6" multiple="multiple" id="db_select">';
    foreach ($GLOBALS['pma']->databases as $current_db) {
        if (PMA_is_system_schema($current_db)) {
            continue;
        }
        if (!empty($selectall) || isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|')) {
            $is_selected = ' selected="selected"';
        } else {
            $is_selected = '';
        }
        $current_db = htmlspecialchars($current_db);
        $multi_values .= '                <option value="' . $current_db . '" ' . $is_selected . '>' . $current_db . '</option>';
    }
    // end while
    $multi_values .= '</select>';
    $multi_values .= '<br /><a href="#" id="db_reset_href">' . __('Uncheck All') . '</a>';
    return $multi_values;
}
Exemple #5
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;
 }
Exemple #6
0
/**
 * Get list of replicated databases on master server
 *
 * @param mixed $link mysql link
 *
 * @return array array of replicated databases
 */
function PMA_replication_master_replicated_dbs($link = null)
{
    // let's find out, which databases are replicated
    $data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $link);
    $do_db = array();
    $ignore_db = array();
    if (!empty($data[0]['Binlog_Do_DB'])) {
        $do_db = explode(',', $data[0]['Binlog_Do_DB']);
    }
    if (!empty($data[0]['Binlog_Ignore_DB'])) {
        $ignore_db = explode(',', $data[0]['Binlog_Ignore_DB']);
    }
    $tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $link);
    while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) {
        if (PMA_is_system_schema($tmp_row[0])) {
            continue;
        }
        if (count($do_db) == 0) {
            if (array_search($tmp_row[0], $ignore_db) !== false) {
                continue;
            }
            $dblist[] = $tmp_row[0];
        } else {
            if (array_search($tmp_row[0], $do_db) !== false) {
                $dblist[] = $tmp_row[0];
            }
        }
    }
    // end while
    return $link;
}
Exemple #7
0
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 *
 * @package PhpMyAdmin
 */
if (!defined('PHPMYADMIN')) {
    exit;
}
/**
 * Gets some core libraries
 */
require_once './libraries/common.inc.php';
require_once './libraries/bookmark.lib.php';
// Check parameters
PMA_checkParameters(array('db', 'table'));
$db_is_information_schema = PMA_is_system_schema($db);
/**
 * Set parameters for links
 * @deprecated
 */
$url_query = PMA_generate_common_url($db, $table);
$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_generate_common_url(array('db' => $db));
$err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params);
/**
 * Ensures the database and the table exist (else move to the "parent" script)
 */
Exemple #8
0
        $data = PMA_DBI_fetch_result('SHOW MASTER STATUS', null, null, $src_link); // let's find out, which databases are replicated

        $do_db     = array();
        $ignore_db = array();
        $dblist    = array();

        if (! empty($data[0]['Binlog_Do_DB'])) {
            $do_db     = explode(',', $data[0]['Binlog_Do_DB']);
        }
        if (! empty($data[0]['Binlog_Ignore_DB'])) {
            $ignore_db = explode(',', $data[0]['Binlog_Ignore_DB']);
        }

        $tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $src_link);
        while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) {
            if (PMA_is_system_schema($tmp_row[0])) {
                continue;
            }
            if (count($do_db) == 0) {
                if (array_search($tmp_row[0], $ignore_db) !== false) {
                    continue;
                }
                $dblist[] = $tmp_row[0];

                PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '.PMA_backquote($tmp_row[0]), $trg_link);
            } else {
                if (array_search($tmp_row[0], $do_db) !== false) {
                    $dblist[] = $tmp_row[0];
                    PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '.PMA_backquote($tmp_row[0]), $trg_link);
                }
            }
Exemple #9
0
 /**
  * Counts and returns (or displays) the number of records in a table
  *
  * Revision 13 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param string $db          the current database name
  * @param string $table       the current table name
  * @param bool   $force_exact whether to force an exact count
  * @param bool   $is_view     whether the table is a view
  *
  * @return mixed the number of records if "retain" param is true,
  *               otherwise true
  */
 public static function countRecords($db, $table, $force_exact = false, $is_view = null)
 {
     if (isset(PMA_Table::$cache[$db][$table]['ExactRows'])) {
         $row_count = PMA_Table::$cache[$db][$table]['ExactRows'];
     } else {
         $row_count = false;
         if (null === $is_view) {
             $is_view = PMA_Table::isView($db, $table);
         }
         if (!$force_exact) {
             if (!isset(PMA_Table::$cache[$db][$table]['Rows']) && !$is_view) {
                 $tmp_tables = PMA_DBI_get_tables_full($db, $table);
                 if (isset($tmp_tables[$table])) {
                     PMA_Table::$cache[$db][$table] = $tmp_tables[$table];
                 }
             }
             if (isset(PMA_Table::$cache[$db][$table]['Rows'])) {
                 $row_count = PMA_Table::$cache[$db][$table]['Rows'];
             } else {
                 $row_count = false;
             }
         }
         // for a VIEW, $row_count is always false at this point
         if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
             // Make an exception for views in I_S and D_D schema in Drizzle, as these map to
             // in-memory data and should execute fast enough
             if (!$is_view || PMA_DRIZZLE && PMA_is_system_schema($db)) {
                 $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
             } else {
                 // For complex views, even trying to get a partial record
                 // count could bring down a server, so we offer an
                 // alternative: setting MaxExactCountViews to 0 will bypass
                 // completely the record counting for views
                 if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
                     $row_count = 0;
                 } else {
                     // Counting all rows of a VIEW could be too long, so use
                     // a LIMIT clause.
                     // Use try_query because it can fail (when a VIEW is
                     // based on a table that no longer exists)
                     $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DBI_QUERY_STORE);
                     if (!PMA_DBI_getError()) {
                         $row_count = PMA_DBI_num_rows($result);
                         PMA_DBI_free_result($result);
                     }
                 }
             }
             PMA_Table::$cache[$db][$table]['ExactRows'] = $row_count;
         }
     }
     return $row_count;
 }
Exemple #10
0
     echo '</fieldset>' . "\n";
 }
 // Displays the results in a table
 if (empty($disp_mode)) {
     // see the "PMA_setDisplayMode()" function in
     // libraries/DisplayResults.class.php
     $disp_mode = 'urdr111101';
 }
 $resultSetContainsUniqueKey = PMA_resultSetContainsUniqueKey($db, $table, $fields_meta);
 // hide edit and delete links:
 // - for information_schema
 // - if the result set does not contain all the columns of a unique key
 //   (unless this is an updatable view)
 $updatableView = trim($analyzed_sql[0]['select_expr_clause']) == '*' && PMA_Table::isUpdatableView($db, $table);
 $editable = $resultSetContainsUniqueKey || $updatableView;
 if (!empty($table) && (PMA_is_system_schema($db) || !$editable)) {
     $disp_mode = 'nnnn110111';
     $msg = PMA_message::notice(__('This table does not contain a unique column.' . ' Grid edit, checkbox, Edit, Copy and Delete features' . ' are not available.'));
     $msg->display();
 }
 if (isset($label)) {
     $msg = PMA_message::success(__('Bookmark %s created'));
     $msg->addParam($label);
     $msg->display();
 }
 // Should be initialized these parameters before parsing
 $showtable = isset($showtable) ? $showtable : null;
 $printview = isset($printview) ? $printview : null;
 $url_query = isset($url_query) ? $url_query : null;
 if (!empty($sql_data) && $sql_data['valid_queries'] > 1 || $is_procedure) {
     $_SESSION['is_multi_query'] = true;
Exemple #11
0
    /**
     * returns array with tables of given db with extended information and grouped
     *
     * @param string   $db           name of db
     * @param string   $tables       name of tables
     * @param integer  $limit_offset list offset
     * @param int|bool $limit_count  max tables to return
     *
     * @return array    (recursive) grouped table list
     */
    public static function getTableList(
        $db, $tables = null, $limit_offset = 0, $limit_count = false
    ) {
        $sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];

        if ($tables === null) {
            $tables = PMA_DBI_get_tables_full(
                $db, false, false, null, $limit_offset, $limit_count
            );
            if ($GLOBALS['cfg']['NaturalOrder']) {
                uksort($tables, 'strnatcasecmp');
            }
        }

        if (count($tables) < 1) {
            return $tables;
        }

        $default = array(
            'Name'      => '',
            'Rows'      => 0,
            'Comment'   => '',
            'disp_name' => '',
        );

        $table_groups = array();

        foreach ($tables as $table_name => $table) {
            // check for correct row count
            if ($table['Rows'] === null) {
                // Do not check exact row count here,
                // if row count is invalid possibly the table is defect
                // and this would break left frame;
                // but we can check row count if this is a view or the
                // information_schema database
                // since PMA_Table::countRecords() returns a limited row count
                // in this case.

                // set this because PMA_Table::countRecords() can use it
                $tbl_is_view = $table['TABLE_TYPE'] == 'VIEW';

                if ($tbl_is_view || PMA_is_system_schema($db)) {
                    $table['Rows'] = PMA_Table::countRecords(
                        $db,
                        $table['Name'],
                        false,
                        true
                    );
                }
            }

            // in $group we save the reference to the place in $table_groups
            // where to store the table info
            if ($GLOBALS['cfg']['NavigationTreeEnableGrouping']
                && $sep && strstr($table_name, $sep)
            ) {
                $parts = explode($sep, $table_name);

                $group =& $table_groups;
                $i = 0;
                $group_name_full = '';
                $parts_cnt = count($parts) - 1;

                while (($i < $parts_cnt)
                    && ($i < $GLOBALS['cfg']['NavigationTreeTableLevel'])
                ) {
                    $group_name = $parts[$i] . $sep;
                    $group_name_full .= $group_name;

                    if (! isset($group[$group_name])) {
                        $group[$group_name] = array();
                        $group[$group_name]['is' . $sep . 'group'] = true;
                        $group[$group_name]['tab' . $sep . 'count'] = 1;
                        $group[$group_name]['tab' . $sep . 'group']
                            = $group_name_full;

                    } elseif (! isset($group[$group_name]['is' . $sep . 'group'])) {
                        $table = $group[$group_name];
                        $group[$group_name] = array();
                        $group[$group_name][$group_name] = $table;
                        unset($table);
                        $group[$group_name]['is' . $sep . 'group'] = true;
                        $group[$group_name]['tab' . $sep . 'count'] = 1;
                        $group[$group_name]['tab' . $sep . 'group']
                            = $group_name_full;

                    } else {
                        $group[$group_name]['tab' . $sep . 'count']++;
                    }

                    $group =& $group[$group_name];
                    $i++;
                }

            } else {
                if (! isset($table_groups[$table_name])) {
                    $table_groups[$table_name] = array();
                }
                $group =& $table_groups;
            }

            $table['disp_name'] = $table['Name'];
            $group[$table_name] = array_merge($default, $table);
        }

        return $table_groups;
    }
/**
 * returns collation of given db
 *
 * @param string $db name of db
 *
 * @return string  collation of $db
 */
function PMA_getDbCollation($db)
{
    if (PMA_is_system_schema($db)) {
        // We don't have to check the collation of the virtual
        // information_schema database: We know it!
        return 'utf8_general_ci';
    }
    if (!$GLOBALS['cfg']['Server']['DisableIS']) {
        // this is slow with thousands of databases
        $sql = PMA_DRIZZLE ? 'SELECT DEFAULT_COLLATION_NAME FROM data_dictionary.SCHEMAS' . ' WHERE SCHEMA_NAME = \'' . PMA_Util::sqlAddSlashes($db) . '\' LIMIT 1' : 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA' . ' WHERE SCHEMA_NAME = \'' . PMA_Util::sqlAddSlashes($db) . '\' LIMIT 1';
        return PMA_DBI_fetch_value($sql);
    } else {
        PMA_DBI_select_db($db);
        $return = PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'collation_database\'', 0, 1);
        if ($db !== $GLOBALS['db']) {
            PMA_DBI_select_db($GLOBALS['db']);
        }
        return $return;
    }
}
 /**
  * Test for system schema detection
  *
  * @param string $schema   schema name
  * @param bool   $expected expected result
  *
  * @return void
  *
  * @dataProvider schemaData
  */
 function testSystemSchema($schema, $expected)
 {
     $this->assertEquals($expected, PMA_is_system_schema($schema));
 }
            echo '    <td>';
            if (isset($mime_map[$field_name])) {
                echo htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype']));
            }
            echo '&nbsp;</td>' . "\n";
        }
        ?>
</tr>
        <?php 
    }
    // end foreach
    ?>
</tbody>
</table>
    <?php 
    if (!$tbl_is_view && !PMA_is_system_schema($db)) {
        /**
         * Displays indexes
         */
        echo PMA_Index::getView($table, $db, true);
        /**
         * Displays Space usage and row statistics
         *
         */
        if ($cfg['ShowStats']) {
            $nonisam = false;
            if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
                $nonisam = true;
            }
            if ($nonisam == false) {
                // Gets some sizes
            echo '    <th>'. $name .'</th>' . "\n";
        }
    }

    if ($is_superuser && ! PMA_DRIZZLE) {
        echo '    <th>' . ($cfg['PropertiesIconic'] ? '' : __('Action')) . "\n"
           . '    </th>' . "\n";
    }
    echo '</tr>' . "\n"
       . '</thead>' . "\n"
       . '<tbody>' . "\n";

    $odd_row = true;
    foreach ($databases as $current) {
        $tr_class = $odd_row ? 'odd' : 'even';
        if (PMA_is_system_schema($current['SCHEMA_NAME'], true)) {
            $tr_class .= ' noclick';
        }
        echo '<tr class="' . $tr_class . '">' . "\n";
        $odd_row = ! $odd_row;

        list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);

        echo $generated_html;

        echo '</tr>' . "\n";
    } // end foreach ($databases as $key => $current)
    unset($current, $odd_row);

    echo '</tbody><tfoot><tr>' . "\n";
    if ($is_superuser || $cfg['AllowUserDropDatabase']) {
Exemple #16
0
        echo '<div id="profilingchart" style="display:none;">';
        //PMA_chart_profiling($profiling_results);
        echo json_encode($chart_json);
        echo '</div>';
        echo '</fieldset>' . "\n";
    }

    // Displays the results in a table
    if (empty($disp_mode)) {
        // see the "PMA_setDisplayMode()" function in
        // libraries/display_tbl.lib.php
        $disp_mode = 'urdr111101';
    }

    // hide edit and delete links for information_schema
    if (PMA_is_system_schema($db)) {
        $disp_mode = 'nnnn110111';
    }

    if (isset($label)) {
        $message = PMA_message::success(__('Bookmark %s created'));
        $message->addParam($label);
        $message->display();
    }

    PMA_displayTable($result, $disp_mode, $analyzed_sql);
    PMA_DBI_free_result($result);

    // BEGIN INDEX CHECK See if indexes should be checked.
    if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) {
        foreach ($selected as $idx => $tbl_name) {
     echo '</fieldset>' . "\n";
 }
 // Displays the results in a table
 if (empty($disp_mode)) {
     // see the "PMA_setDisplayMode()" function in
     // libraries/DisplayResults.class.php
     $disp_mode = 'urdr111101';
 }
 $resultSetContainsUniqueKey = PMA_resultSetContainsUniqueKey($db, $table, $fields_meta);
 // hide edit and delete links:
 // - for information_schema
 // - if the result set does not contain all the columns of a unique key
 //   and we are not just browing all the columns of an updatable view
 $updatableView = $justBrowsing && trim($analyzed_sql[0]['select_expr_clause']) == '*' && PMA_Table::isUpdatableView($db, $table);
 $editable = $resultSetContainsUniqueKey || $updatableView;
 if (PMA_is_system_schema($db) || !$editable) {
     $disp_mode = 'nnnn110111';
     $msg = PMA_message::notice(__('This table does not contain a unique column.' . ' Grid edit, checkbox, Edit, Copy and Delete features' . ' are not available.'));
     $msg->display();
 }
 if (isset($label)) {
     $msg = PMA_message::success(__('Bookmark %s created'));
     $msg->addParam($label);
     $msg->display();
 }
 // Should be initialized these parameters before parsing
 $showtable = isset($showtable) ? $showtable : null;
 $printview = isset($printview) ? $printview : null;
 $url_query = isset($url_query) ? $url_query : null;
 if (!empty($sql_data) && $sql_data['valid_queries'] > 1 || $is_procedure) {
     $_SESSION['is_multi_query'] = true;
Exemple #18
0
/**
 * returns array with tables of given db with extended information and grouped
 *
 * @param string   $db           name of db
 * @param string   $tables       name of tables
 * @param integer  $limit_offset list offset
 * @param int|bool $limit_count  max tables to return
 *
 * @return  array    (recursive) grouped table list
 */
function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count = false)
{
    $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
    if (null === $tables) {
        $tables = PMA_DBI_get_tables_full($db, false, false, null, $limit_offset, $limit_count);
        if ($GLOBALS['cfg']['NaturalOrder']) {
            uksort($tables, 'strnatcasecmp');
        }
    }
    if (count($tables) < 1) {
        return $tables;
    }
    $default = array('Name' => '', 'Rows' => 0, 'Comment' => '', 'disp_name' => '');
    $table_groups = array();
    // for blobstreaming - list of blobstreaming tables
    // load PMA configuration
    $PMA_Config = $GLOBALS['PMA_Config'];
    foreach ($tables as $table_name => $table) {
        // if BS tables exist
        if (PMA_BS_IsHiddenTable($table_name)) {
            continue;
        }
        // check for correct row count
        if (null === $table['Rows']) {
            // Do not check exact row count here,
            // if row count is invalid possibly the table is defect
            // and this would break left frame;
            // but we can check row count if this is a view or the
            // information_schema database
            // since PMA_Table::countRecords() returns a limited row count
            // in this case.
            // set this because PMA_Table::countRecords() can use it
            $tbl_is_view = $table['TABLE_TYPE'] == 'VIEW';
            if ($tbl_is_view || PMA_is_system_schema($db)) {
                $table['Rows'] = PMA_Table::countRecords($db, $table['Name'], false, true);
            }
        }
        // in $group we save the reference to the place in $table_groups
        // where to store the table info
        if ($GLOBALS['cfg']['LeftFrameDBTree'] && $sep && strstr($table_name, $sep)) {
            $parts = explode($sep, $table_name);
            $group =& $table_groups;
            $i = 0;
            $group_name_full = '';
            $parts_cnt = count($parts) - 1;
            while ($i < $parts_cnt && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
                $group_name = $parts[$i] . $sep;
                $group_name_full .= $group_name;
                if (!isset($group[$group_name])) {
                    $group[$group_name] = array();
                    $group[$group_name]['is' . $sep . 'group'] = true;
                    $group[$group_name]['tab' . $sep . 'count'] = 1;
                    $group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
                } elseif (!isset($group[$group_name]['is' . $sep . 'group'])) {
                    $table = $group[$group_name];
                    $group[$group_name] = array();
                    $group[$group_name][$group_name] = $table;
                    unset($table);
                    $group[$group_name]['is' . $sep . 'group'] = true;
                    $group[$group_name]['tab' . $sep . 'count'] = 1;
                    $group[$group_name]['tab' . $sep . 'group'] = $group_name_full;
                } else {
                    $group[$group_name]['tab' . $sep . 'count']++;
                }
                $group =& $group[$group_name];
                $i++;
            }
        } else {
            if (!isset($table_groups[$table_name])) {
                $table_groups[$table_name] = array();
            }
            $group =& $table_groups;
        }
        if ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested' && $table['Comment'] && $table['Comment'] != 'VIEW') {
            // switch tooltip and name
            $table['disp_name'] = $table['Comment'];
            $table['Comment'] = $table['Name'];
        } else {
            $table['disp_name'] = $table['Name'];
        }
        $group[$table_name] = array_merge($default, $table);
    }
    return $table_groups;
}
Exemple #19
0
        echo '</fieldset>' . "\n";
    }

    // Displays the results in a table
    if (empty($disp_mode)) {
        // see the "PMA_setDisplayMode()" function in
        // libraries/DisplayResults.class.php
        $disp_mode = 'urdr111101';
    }

    $resultSetContainsUniqueKey = PMA_resultSetContainsUniqueKey($db, $table, $fields_meta);

    // hide edit and delete links:
    // - for information_schema
    // - if the result set does not contain all the columns of a unique key
    if (PMA_is_system_schema($db) || ! $resultSetContainsUniqueKey) {
        $disp_mode = 'nnnn110111';
    }

    if (isset($label)) {
        $message = PMA_message::success(__('Bookmark %s created'));
        $message->addParam($label);
        $message->display();
    }

    // Should be initialized these parameters before parsing
    $showtable = isset($showtable) ? $showtable : null;
    $printview = isset($printview) ? $printview : null;
    $url_query = isset($url_query) ? $url_query : null;

    if (! empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {