/**
 * Returns html with Advisor
 *
 * @return string
 */
function PMA_getHtmlForAdvisor()
{
    $output = '<a href="#openAdvisorInstructions">';
    $output .= PMA_Util::getIcon('b_help.png', __('Instructions'));
    $output .= '</a>';
    $output .= '<div id="statustabs_advisor"></div>';
    $output .= '<div id="advisorInstructionsDialog" style="display:none;">';
    $output .= '<p>';
    $output .= __('The Advisor system can provide recommendations ' . 'on server variables by analyzing the server status variables.');
    $output .= '</p>';
    $output .= '<p>';
    $output .= __('Do note however that this system provides recommendations ' . 'based on simple calculations and by rule of thumb which may ' . 'not necessarily apply to your system.');
    $output .= '</p>';
    $output .= '<p>';
    $output .= __('Prior to changing any of the configuration, be sure to know ' . 'what you are changing (by reading the documentation) and how ' . 'to undo the change. Wrong tuning can have a very negative ' . 'effect on performance.');
    $output .= '</p>';
    $output .= '<p>';
    $output .= __('The best way to tune your system would be to change only one ' . 'setting at a time, observe or benchmark your database, and undo ' . 'the change if there was no clearly measurable improvement.');
    $output .= '</p>';
    $output .= '</div>';
    $output .= '<div id="advisorData" style="display:none;">';
    $advisor = new Advisor();
    $output .= htmlspecialchars(json_encode($advisor->run()));
    $output .= '</div>';
    return $output;
}
Ejemplo n.º 2
0
/**
 * Creates a fieldset for adding a new item, if the user has the privileges.
 *
 * @param string $docu String used to create a link to the MySQL docs
 * @param string $priv Privilege to check for adding a new item
 * @param string $name MySQL name of the item
 *
 * @return string An HTML snippet with the link to add a new item
 */
function PMA_RTE_getFooterLinks($docu, $priv, $name)
{
    global $db, $url_query, $ajax_class;
    $icon = 'b_' . strtolower($name) . '_add.png';
    $retval = "";
    $retval .= "<!-- ADD " . $name . " FORM START -->\n";
    $retval .= "<fieldset class='left'>\n";
    $retval .= "<legend>" . _pgettext('Create new procedure', 'New') . "</legend>\n";
    $retval .= "        <div class='wrap'>\n";
    if (PMA_Util::currentUserHasPrivilege($priv, $db)) {
        $retval .= "            <a {$ajax_class['add']} ";
        $retval .= "href='db_" . strtolower($name) . "s.php";
        $retval .= "?{$url_query}&amp;add_item=1' onclick='\$.datepicker.initialized = false;'>";
        $retval .= PMA_Util::getIcon($icon);
        $retval .= PMA_RTE_getWord('add') . "</a>\n";
    } else {
        $retval .= "            " . PMA_Util::getIcon($icon);
        $retval .= PMA_RTE_getWord('no_create') . "\n";
    }
    $retval .= "            " . PMA_Util::showMySQLDocu($docu) . "\n";
    $retval .= "        </div>\n";
    $retval .= "</fieldset>\n";
    $retval .= "<!-- ADD " . $name . " FORM END -->\n\n";
    return $retval;
}
Ejemplo n.º 3
0
/**
 * Returns the html for the sub-page heading
 *
 * @param string $type     Sub page type
 * @param string $link     Link to the official MySQL documentation
 * @param bool   $is_image Display image or icon, true: image, false: icon
 *
 * @return string
 */
function PMA_getHtmlForSubPageHeader($type, $link = '', $is_image = true)
{
    //array contains Sub page icon and text
    $header = array();
    $header['variables']['image'] = 's_vars.png';
    $header['variables']['text'] = __('Server variables and settings');
    $header['engines']['image'] = 'b_engine.png';
    $header['engines']['text'] = __('Storage Engines');
    $header['plugins']['image'] = 'b_engine.png';
    $header['plugins']['text'] = __('Plugins');
    $header['binlog']['image'] = 's_tbl.png';
    $header['binlog']['text'] = __('Binary log');
    $header['collations']['image'] = 's_asci.png';
    $header['collations']['text'] = __('Character Sets and Collations');
    $header['replication']['image'] = 's_replication.png';
    $header['replication']['text'] = __('Replication');
    $header['database_statistics']['image'] = 's_db.png';
    $header['database_statistics']['text'] = __('Databases statistics');
    $header['databases']['image'] = 's_db.png';
    $header['databases']['text'] = __('Databases');
    $header['privileges']['image'] = 'b_usrlist.png';
    $header['privileges']['text'] = __('Privileges');
    if ($is_image) {
        $html = '<h2>' . "\n" . PMA_Util::getImage($header[$type]['image']) . '    ' . $header[$type]['text'] . "\n" . $link . '</h2>' . "\n";
    } else {
        $html = '<h2>' . "\n" . PMA_Util::getIcon($header[$type]['image']) . '    ' . $header[$type]['text'] . "\n" . $link . '</h2>' . "\n";
    }
    return $html;
}
Ejemplo n.º 4
0
 /**
  * Test for getIcon
  *
  * @return void
  */
 function testGetIconWithForceText()
 {
     $GLOBALS['cfg']['ActionLinksMode'] = 'icons';
     $alternate_text = 'alt_str';
     // Here we are checking for an icon embedded inside a span (i.e not a menu
     // bar icon
     $this->assertEquals('<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text . '" class="icon ic_b_comment" />&nbsp;' . $alternate_text . '</span>', PMA_Util::getIcon('b_comment.png', $alternate_text, true, false));
 }
Ejemplo n.º 5
0
    function testGetIconWithForceText()
    {
        $GLOBALS['cfg']['PropertiesIconic'] = true;
        $alternate_text = 'alt_str';

        $this->assertEquals(
            '<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
            . '" class="icon ic_b_comment" /> ' . $alternate_text . '</span>',
            PMA_Util::getIcon('b_comment.png', $alternate_text, true)
        );

    }
Ejemplo n.º 6
0
 /**
  * Test for buildActionTitles
  *
  * @return void
  */
 function testBuildActionTitles()
 {
     $titles = array();
     $titles['Browse'] = PMA_Util::getIcon('b_browse.png', __('Browse'));
     $titles['NoBrowse'] = PMA_Util::getIcon('bd_browse.png', __('Browse'));
     $titles['Search'] = PMA_Util::getIcon('b_select.png', __('Search'));
     $titles['NoSearch'] = PMA_Util::getIcon('bd_select.png', __('Search'));
     $titles['Insert'] = PMA_Util::getIcon('b_insrow.png', __('Insert'));
     $titles['NoInsert'] = PMA_Util::getIcon('bd_insrow.png', __('Insert'));
     $titles['Structure'] = PMA_Util::getIcon('b_props.png', __('Structure'));
     $titles['Drop'] = PMA_Util::getIcon('b_drop.png', __('Drop'));
     $titles['NoDrop'] = PMA_Util::getIcon('bd_drop.png', __('Drop'));
     $titles['Empty'] = PMA_Util::getIcon('b_empty.png', __('Empty'));
     $titles['NoEmpty'] = PMA_Util::getIcon('bd_empty.png', __('Empty'));
     $titles['Edit'] = PMA_Util::getIcon('b_edit.png', __('Edit'));
     $titles['NoEdit'] = PMA_Util::getIcon('bd_edit.png', __('Edit'));
     $titles['Export'] = PMA_Util::getIcon('b_export.png', __('Export'));
     $titles['NoExport'] = PMA_Util::getIcon('bd_export.png', __('Export'));
     $titles['Execute'] = PMA_Util::getIcon('b_nextpage.png', __('Execute'));
     $titles['NoExecute'] = PMA_Util::getIcon('bd_nextpage.png', __('Execute'));
     $titles['Favorite'] = PMA_Util::getIcon('b_favorite.png', '');
     $titles['NoFavorite'] = PMA_Util::getIcon('b_no_favorite.png', '');
     $this->assertEquals($titles, PMA_Util::buildActionTitles());
 }
Ejemplo n.º 7
0
/**
 * Get action titles (image or string array
 *
 * @return array  $titles
 */
function PMA_getActionTitlesArray()
{
    $titles = array();
    $titles['Change'] = PMA_Util::getIcon('b_edit.png', __('Change'));
    $titles['Drop'] = PMA_Util::getIcon('b_drop.png', __('Drop'));
    $titles['NoDrop'] = PMA_Util::getIcon('b_drop.png', __('Drop'));
    $titles['Primary'] = PMA_Util::getIcon('b_primary.png', __('Primary'));
    $titles['Index'] = PMA_Util::getIcon('b_index.png', __('Index'));
    $titles['Unique'] = PMA_Util::getIcon('b_unique.png', __('Unique'));
    $titles['Spatial'] = PMA_Util::getIcon('b_spatial.png', __('Spatial'));
    $titles['IdxFulltext'] = PMA_Util::getIcon('b_ftext.png', __('Fulltext'));
    $titles['NoPrimary'] = PMA_Util::getIcon('bd_primary.png', __('Primary'));
    $titles['NoIndex'] = PMA_Util::getIcon('bd_index.png', __('Index'));
    $titles['NoUnique'] = PMA_Util::getIcon('bd_unique.png', __('Unique'));
    $titles['NoSpatial'] = PMA_Util::getIcon('bd_spatial.png', __('Spatial'));
    $titles['NoIdxFulltext'] = PMA_Util::getIcon('bd_ftext.png', __('Fulltext'));
    $titles['DistinctValues'] = PMA_Util::getIcon('b_browse.png', __('Distinct values'));
    return $titles;
}
Ejemplo n.º 8
0
    $tabs['import']['fragment'] = '#';
    $tabs['import']['attr'] = 'onclick="PMA_querywindowCommit(\'files\');return false;"';
    $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
    $tabs['history']['icon'] = 'b_bookmark.png';
    $tabs['history']['text'] = __('SQL history');
    $tabs['history']['fragment'] = '#';
    $tabs['history']['attr'] = 'onclick="PMA_querywindowCommit(\'history\');return false;"';
    $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
    if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
        $tabs['all']['text'] = __('All');
        $tabs['all']['fragment'] = '#';
        $tabs['all']['attr'] = 'onclick="PMA_querywindowCommit(\'full\');return false;"';
        $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
    }
}
$titles['Change'] = PMA_Util::getIcon('b_edit.png', __('Change'));
$url_query = PMA_URL_getCommon($db, $table);
if (!empty($sql_query)) {
    $show_query = 1;
}
if ($no_js) {
    // ... we redirect to appropriate query sql page
    // works only full if $db and $table is also stored/grabbed from $_COOKIE
    if (strlen($table)) {
        include 'tbl_sql.php';
    } elseif (strlen($db)) {
        include 'db_sql.php';
    } else {
        include 'server_sql.php';
    }
    exit;
/**
 * Get HTML snippet for display user overview page
 *
 * @param string $pmaThemeImage a image source link
 * @param string $text_dir      text directory
 *
 * @return string $html_output
 */
function PMA_getHtmlForUserOverview($pmaThemeImage, $text_dir)
{
    $html_output = '<h2>' . "\n" . PMA_Util::getIcon('b_usrlist.png') . __('Users overview') . "\n" . '</h2>' . "\n";
    $password_column = 'Password';
    if (PMA_Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706) {
        $password_column = 'authentication_string';
    }
    // $sql_query is for the initial-filtered,
    // $sql_query_all is for counting the total no. of users
    $sql_query = $sql_query_all = 'SELECT *,' . " IF(`" . $password_column . "` = _latin1 '', 'N', 'Y') AS 'Password'" . ' FROM `mysql`.`user`';
    $sql_query .= isset($_REQUEST['initial']) ? PMA_rangeOfUsers($_REQUEST['initial']) : '';
    $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;';
    $sql_query_all .= ' ;';
    $res = $GLOBALS['dbi']->tryQuery($sql_query, null, PMA_DatabaseInterface::QUERY_STORE);
    $res_all = $GLOBALS['dbi']->tryQuery($sql_query_all, null, PMA_DatabaseInterface::QUERY_STORE);
    if (!$res) {
        // the query failed! This may have two reasons:
        // - the user does not have enough privileges
        // - the privilege tables use a structure of an earlier version.
        // so let's try a more simple query
        $GLOBALS['dbi']->freeResult($res);
        $GLOBALS['dbi']->freeResult($res_all);
        $sql_query = 'SELECT * FROM `mysql`.`user`';
        $res = $GLOBALS['dbi']->tryQuery($sql_query, null, PMA_DatabaseInterface::QUERY_STORE);
        if (!$res) {
            $html_output .= PMA_getHtmlForViewUsersError();
            $html_output .= PMA_getAddUserHtmlFieldset();
        } else {
            // This message is hardcoded because I will replace it by
            // a automatic repair feature soon.
            $raw = 'Your privilege table structure seems to be older than' . ' this MySQL version!<br />' . 'Please run the <code>mysql_upgrade</code> command' . '(<code>mysql_fix_privilege_tables</code> on older systems)' . ' that should be included in your MySQL server distribution' . ' to solve this problem!';
            $html_output .= PMA_Message::rawError($raw)->getDisplay();
        }
        $GLOBALS['dbi']->freeResult($res);
    } else {
        $db_rights = PMA_getDbRightsForUserOverview();
        // for all initials, even non A-Z
        $array_initials = array();
        /**
         * Displays the initials
         * Also not necessary if there is less than 20 privileges
         */
        if ($GLOBALS['dbi']->numRows($res_all) > 20) {
            $html_output .= PMA_getHtmlForInitials($array_initials);
        }
        /**
         * Display the user overview
         * (if less than 50 users, display them immediately)
         */
        if (isset($_REQUEST['initial']) || isset($_REQUEST['showall']) || $GLOBALS['dbi']->numRows($res) < 50) {
            $html_output .= PMA_getUsersOverview($res, $db_rights, $pmaThemeImage, $text_dir);
        } else {
            $html_output .= PMA_getAddUserHtmlFieldset();
        }
        // end if (display overview)
        if (!$GLOBALS['is_ajax_request'] || !empty($_REQUEST['ajax_page_request'])) {
            $flushnote = new PMA_Message(__('Note: phpMyAdmin gets the users\' privileges directly ' . 'from MySQL\'s privilege tables. The content of these tables ' . 'may differ from the privileges the server uses, ' . 'if they have been changed manually. In this case, ' . 'you should %sreload the privileges%s before you continue.'), PMA_Message::NOTICE);
            $flushLink = '<a href="server_privileges.php' . PMA_URL_getCommon(array('flush_privileges' => 1)) . '" id="reload_privileges_anchor">';
            $flushnote->addParam($flushLink, false);
            $flushnote->addParam('</a>', false);
            $html_output .= $flushnote->getDisplay();
        }
    }
    return $html_output;
}
Ejemplo n.º 10
0
/**
 * Builds the HTML td elements for one database to display in the list
 * of databases from server_databases.php (which can be modified by
 * db_create.php)
 *
 * @param array   $current           current database
 * @param boolean $is_superuser      user status
 * @param string  $url_query         url query
 * @param array   $column_order      column order
 * @param array   $replication_types replication types
 * @param array   $replication_info  replication info
 *
 * @return array $column_order, $out
 */
function PMA_buildHtmlForDb($current, $is_superuser, $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[]" class="checkall" ' . 'title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . 'value="' . htmlspecialchars($current['SCHEMA_NAME']) . '"';
        if ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
            $out .= ' disabled="disabled"';
        }
        $out .= ' /></td>';
    }
    $out .= '<td class="name">' . '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . 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_Util::formatByteDown($current[$stat_name], 3, 1);
            } elseif ($stat['format'] === 'number') {
                $value = PMA_Util::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;">';
            $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB']);
            if (strlen($key) > 0) {
                $out .= PMA_Util::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_Util::getIcon('s_success.png', __('Replicated'));
                }
            }
            $out .= '</td>';
        }
    }
    if ($is_superuser && !PMA_DRIZZLE) {
        $out .= '<td class="tool">' . '<a onclick="' . 'PMA_commonActions.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');' . '" href="server_privileges.php?' . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']) . '&amp;checkprivsdb=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . PMA_Util::getIcon('s_rights.png', __('Check Privileges')) . '</a></td>';
    }
    return array($column_order, $out);
}
Ejemplo n.º 11
0
 /**
  * Get operations that are available on results.
  *
  * @param array   $displayParts the parts to display
  * @param array   $analyzed_sql the analyzed query
  * @param boolean $only_view    Whether to show only view
  *
  * @return string $results_operations_html  html content
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _getResultsOperations($displayParts, $analyzed_sql, $only_view = false)
 {
     global $printview;
     $results_operations_html = '';
     $fields_meta = $this->__get('fields_meta');
     // To safe use in foreach
     $header_shown = false;
     $header = '<fieldset><legend>' . __('Query results operations') . '</legend>';
     $_url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'printview' => '1', 'sql_query' => $this->__get('sql_query'));
     $url_query = PMA_URL_getCommon($_url_params);
     if (!$header_shown) {
         $results_operations_html .= $header;
         $header_shown = true;
     }
     // if empty result set was produced we need to
     // show only view and not other options
     if ($only_view == true) {
         $results_operations_html .= $this->_getLinkForCreateView($analyzed_sql, $url_query);
         if ($header_shown) {
             $results_operations_html .= '</fieldset><br />';
         }
         return $results_operations_html;
     }
     if ($displayParts['ins_row'] == '1' || $displayParts['pview_lnk'] == '1') {
         // Displays "printable view" link if required
         if ($displayParts['pview_lnk'] == '1') {
             $results_operations_html .= PMA_Util::linkOrButton('sql.php' . $url_query, PMA_Util::getIcon('b_print.png', __('Print view'), true), array('target' => 'print_view'), true, true, 'print_view') . "\n";
             if ($_SESSION['tmpval']['pftext']) {
                 $_url_params['pftext'] = self::DISPLAY_FULL_TEXT;
                 $results_operations_html .= PMA_Util::linkOrButton('sql.php' . PMA_URL_getCommon($_url_params), PMA_Util::getIcon('b_print.png', __('Print view (with full texts)'), true), array('target' => 'print_view'), true, true, 'print_view') . "\n";
                 unset($_url_params['pftext']);
             }
         }
         // end displays "printable view"
     }
     // Export link
     // (the url_query has extra parameters that won't be used to export)
     // (the single_table parameter is used in display_export.inc.php
     //  to hide the SQL and the structure export dialogs)
     // If the parser found a PROCEDURE clause
     // (most probably PROCEDURE ANALYSE()) it makes no sense to
     // display the Export link).
     if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == self::QUERY_TYPE_SELECT && !isset($printview) && !isset($analyzed_sql[0]['queryflags']['procedure'])) {
         if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
             $_url_params['single_table'] = 'true';
         }
         if (!$header_shown) {
             $results_operations_html .= $header;
             $header_shown = true;
         }
         $_url_params['unlim_num_rows'] = $this->__get('unlim_num_rows');
         /**
          * At this point we don't know the table name; this can happen
          * for example with a query like
          * SELECT bike_code FROM (SELECT bike_code FROM bikes) tmp
          * As a workaround we set in the table parameter the name of the
          * first table of this database, so that tbl_export.php and
          * the script it calls do not fail
          */
         if (empty($_url_params['table']) && !empty($_url_params['db'])) {
             $_url_params['table'] = $GLOBALS['dbi']->fetchValue("SHOW TABLES");
             /* No result (probably no database selected) */
             if ($_url_params['table'] === false) {
                 unset($_url_params['table']);
             }
         }
         $results_operations_html .= PMA_Util::linkOrButton('tbl_export.php' . PMA_URL_getCommon($_url_params), PMA_Util::getIcon('b_tblexport.png', __('Export'), true), '', true, true, '') . "\n";
         // prepare chart
         $results_operations_html .= PMA_Util::linkOrButton('tbl_chart.php' . PMA_URL_getCommon($_url_params), PMA_Util::getIcon('b_chart.png', __('Display chart'), true), '', true, true, '') . "\n";
         // prepare GIS chart
         $geometry_found = false;
         // If at least one geometry field is found
         foreach ($fields_meta as $meta) {
             if ($meta->type == self::GEOMETRY_FIELD) {
                 $geometry_found = true;
                 break;
             }
         }
         if ($geometry_found) {
             $results_operations_html .= PMA_Util::linkOrButton('tbl_gis_visualization.php' . PMA_URL_getCommon($_url_params), PMA_Util::getIcon('b_globe.gif', __('Visualize GIS data'), true), '', true, true, '') . "\n";
         }
     }
     // CREATE VIEW
     /**
      *
      * @todo detect privileges to create a view
      *       (but see 2006-01-19 note in display_create_table.lib.php,
      *        I think we cannot detect db-specific privileges reliably)
      * Note: we don't display a Create view link if we found a PROCEDURE clause
      */
     if (!$header_shown) {
         $results_operations_html .= $header;
         $header_shown = true;
     }
     $results_operations_html .= $this->_getLinkForCreateView($analyzed_sql, $url_query);
     if ($header_shown) {
         $results_operations_html .= '</fieldset><br />';
     }
     return $results_operations_html;
 }
Ejemplo n.º 12
0
 /**
  * Returns HTML for the dialog to show hidden navigation items.
  *
  * @param string $dbName    database name
  * @param string $itemType  type of the items to include
  * @param string $tableName table name
  *
  * @return string HTML for the dialog to show hidden navigation items
  */
 public function getItemUnhideDialog($dbName, $itemType = null, $tableName = null)
 {
     $html = '<form method="post" action="navigation.php" class="ajax">';
     $html .= '<fieldset>';
     $html .= PMA_URL_getHiddenInputs($dbName, $tableName);
     $navTable = PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . "." . PMA_Util::backquote($GLOBALS['cfgRelation']['navigationhiding']);
     $sqlQuery = "SELECT `item_name`, `item_type` FROM " . $navTable . " WHERE `username`='" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'" . " AND `db_name`='" . PMA_Util::sqlAddSlashes($dbName) . "'" . " AND `table_name`='" . (!empty($tableName) ? PMA_Util::sqlAddSlashes($tableName) : '') . "'";
     $result = PMA_queryAsControlUser($sqlQuery, false);
     $hidden = array();
     if ($result) {
         while ($row = $GLOBALS['dbi']->fetchArray($result)) {
             $type = $row['item_type'];
             if (!isset($hidden[$type])) {
                 $hidden[$type] = array();
             }
             $hidden[$type][] = $row['item_name'];
         }
     }
     $GLOBALS['dbi']->freeResult($result);
     $typeMap = array('event' => __('Events:'), 'function' => __('Functions:'), 'procedure' => __('Procedures:'), 'table' => __('Tables:'), 'view' => __('Views:'));
     if (empty($tableName)) {
         $first = true;
         foreach ($typeMap as $t => $lable) {
             if ((empty($itemType) || $itemType == $t) && isset($hidden[$t])) {
                 $html .= (!$first ? '<br/>' : '') . '<strong>' . $lable . '</strong>';
                 $html .= '<table width="100%"><tbody>';
                 $odd = true;
                 foreach ($hidden[$t] as $hiddenItem) {
                     $html .= '<tr class="' . ($odd ? 'odd' : 'even') . '">';
                     $html .= '<td>' . htmlspecialchars($hiddenItem) . '</td>';
                     $html .= '<td style="width:80px"><a href="navigation.php' . PMA_URL_getCommon() . '&unhideNavItem=true' . '&itemType=' . urlencode($t) . '&itemName=' . urlencode($hiddenItem) . '&dbName=' . urlencode($dbName) . '"' . ' class="unhideNavItem ajax">' . PMA_Util::getIcon('lightbulb.png', __('Show')) . '</a></td>';
                     $odd = !$odd;
                 }
                 $html .= '</tbody></table>';
                 $first = false;
             }
         }
     }
     $html .= '</fieldset>';
     $html .= '</form>';
     return $html;
 }
Ejemplo n.º 13
0
 /**
  * Provides form for displaying point data and also the scatter plot
  * (for tbl_zoom_select.php)
  *
  * @param string $goto Goto URL
  * @param array  $data Array containing SQL query data
  *
  * @return string form's html
  */
 public function getZoomResultsForm($goto, $data)
 {
     $html_output = '';
     $titles = array('Browse' => PMA_Util::getIcon('b_browse.png', __('Browse foreign values')));
     $html_output .= '<form method="post" action="tbl_zoom_select.php"' . ' name="displayResultForm" id="zoom_display_form"' . ' class="ajax"' . '>';
     $html_output .= PMA_URL_getHiddenInputs($this->_db, $this->_table);
     $html_output .= '<input type="hidden" name="goto" value="' . $goto . '" />';
     $html_output .= '<input type="hidden" name="back" value="tbl_zoom_select.php" />';
     $html_output .= '<fieldset id="displaySection">';
     $html_output .= '<legend>' . __('Browse/Edit the points') . '</legend>';
     //JSON encode the data(query result)
     $html_output .= '<center>';
     if (isset($_POST['zoom_submit']) && !empty($data)) {
         $html_output .= '<div id="resizer">';
         $html_output .= '<center><a href="#" onclick="displayHelp();">' . __('How to use') . '</a></center>';
         $html_output .= '<div id="querydata" style="display:none">' . json_encode($data) . '</div>';
         $html_output .= '<div id="querychart"></div>';
         $html_output .= '<button class="button-reset">' . __('Reset zoom') . '</button>';
         $html_output .= '</div>';
     }
     $html_output .= '</center>';
     //Displays rows in point edit form
     $html_output .= '<div id="dataDisplay" style="display:none">';
     $html_output .= '<table><thead>';
     $html_output .= '<tr>';
     $html_output .= '<th>' . __('Column') . '</th>' . '<th>' . __('Null') . '</th>' . '<th>' . __('Value') . '</th>';
     $html_output .= '</tr>';
     $html_output .= '</thead>';
     $html_output .= '<tbody>';
     $odd_row = true;
     for ($column_index = 0, $nb = count($this->_columnNames); $column_index < $nb; $column_index++) {
         $fieldpopup = $this->_columnNames[$column_index];
         $foreignData = PMA_getForeignData($this->_foreigners, $fieldpopup, false, '', '');
         $html_output .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
         $odd_row = !$odd_row;
         //Display column Names
         $html_output .= '<th>' . htmlspecialchars($this->_columnNames[$column_index]) . '</th>';
         //Null checkbox if column can be null
         $html_output .= '<th>' . ($this->_columnNullFlags[$column_index] == 'YES' ? '<input type="checkbox" class="checkbox_null"' . ' name="criteriaColumnNullFlags[' . $column_index . ']"' . ' id="edit_fields_null_id_' . $column_index . '" />' : '');
         $html_output .= '</th>';
         //Column's Input box
         $html_output .= '<th>';
         $html_output .= $this->_getInputbox($foreignData, $fieldpopup, $this->_columnTypes[$column_index], $column_index, $titles, $GLOBALS['cfg']['ForeignKeyMaxLimit'], '', false, true);
         $html_output .= '</th></tr>';
     }
     $html_output .= '</tbody></table>';
     $html_output .= '</div>';
     $html_output .= '<input type="hidden" id="queryID" name="sql_query" />';
     $html_output .= '</form>';
     return $html_output;
 }
/**
 * Get HTML snippet for display user overview page
 *
 * @param string $link_edit         standard link to edit privileges
 * @param string $pmaThemeImage     a image source link
 * @param string $text_dir          text directory
 * @param string $conditional_class if ajaxable 'Ajax' otherwise ''
 * @param string $link_export       standard link to export privileges
 *
 * @return string $html_output
 */
function PMA_getHtmlForDisplayUserOverviewPage($link_edit, $pmaThemeImage, $text_dir, $conditional_class, $link_export)
{
    $html_output = '<h2>' . "\n" . PMA_Util::getIcon('b_usrlist.png') . __('Users overview') . "\n" . '</h2>' . "\n";
    $sql_query = 'SELECT *,' . "       IF(`Password` = _latin1 '', 'N', 'Y') AS 'Password'" . '  FROM `mysql`.`user`';
    $sql_query .= isset($_REQUEST['initial']) ? PMA_rangeOfUsers($_REQUEST['initial']) : '';
    $sql_query .= ' ORDER BY `User` ASC, `Host` ASC;';
    $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);
    if (!$res) {
        // the query failed! This may have two reasons:
        // - the user does not have enough privileges
        // - the privilege tables use a structure of an earlier version.
        // so let's try a more simple query
        $sql_query = 'SELECT * FROM `mysql`.`user`';
        $res = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_STORE);
        if (!$res) {
            $html_output .= PMA_Message::error(__('No Privileges'))->getDisplay();
            PMA_DBI_free_result($res);
            unset($res);
        } else {
            // This message is hardcoded because I will replace it by
            // a automatic repair feature soon.
            $raw = 'Your privilege table structure seems to be older than' . ' this MySQL version!<br />' . 'Please run the <code>mysql_upgrade</code> command' . '(<code>mysql_fix_privilege_tables</code> on older systems)' . ' that should be included in your MySQL server distribution' . ' to solve this problem!';
            $html_output .= PMA_Message::rawError($raw)->getDisplay();
        }
    } else {
        $db_rights = PMA_getDbRightsForUserOverview();
        // for all initials, even non A-Z
        $array_initials = array();
        /**
         * Displays the initials
         * Also not necassary if there is less than 20 privileges
         */
        if (PMA_DBI_num_rows($res) > 20) {
            $html_output .= PMA_getHtmlForDisplayTheInitials($array_initials, $conditional_class);
        }
        /**
         * Display the user overview
         * (if less than 50 users, display them immediately)
         */
        if (isset($_REQUEST['initial']) || isset($_REQUEST['showall']) || PMA_DBI_num_rows($res) < 50) {
            $html_output .= PMA_getUsersOverview($res, $db_rights, $link_edit, $pmaThemeImage, $text_dir, $conditional_class, $link_export);
        } else {
            $html_output .= PMA_getAddUserHtmlFieldset($conditional_class);
        }
        // end if (display overview)
        if (!$GLOBALS['is_ajax_request'] || !empty($_REQUEST['ajax_page_request'])) {
            $flushnote = new PMA_Message(__('Note: phpMyAdmin gets the users\' privileges directly from MySQL\'s privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should %sreload the privileges%s before you continue.'), PMA_Message::NOTICE);
            $flushLink = '<a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;' . 'flush_privileges=1" id="reload_privileges_anchor" ' . 'class="' . $conditional_class . '">';
            $flushnote->addParam($flushLink, false);
            $flushnote->addParam('</a>', false);
            $html_output .= $flushnote->getDisplay();
        }
        return $html_output;
    }
}
/**
 * build html for a row in central columns table
 *
 * @param array   $row     array contains complete information of
 * a particular row of central list table
 * @param boolean $odd_row set true if the row is at odd number position
 * @param int     $row_num position the row in the table
 * @param string  $db      current database
 *
 * @return html of a particular row in the central columns table.
 */
function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
{
    $tableHtml = '<tr data-rownum="' . $row_num . '" id="f_' . $row_num . '" ' . 'class="' . ($odd_row ? 'odd' : 'even') . '">' . PMA_URL_getHiddenInputs($db) . '<input type="hidden" name="edit_save" value="save">' . '<td class="nowrap">' . '<input type="checkbox" class="checkall" name="selected_fld[]" ' . 'value="' . htmlspecialchars($row['col_name']) . '" ' . 'id="checkbox_row_' . $row_num . '"/>' . '</td>' . '<td id="edit_' . $row_num . '" class="edit center">' . '<a href="#">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a></td>' . '<td class="del_row" data-rownum = "' . $row_num . '">' . '<a hrf="#">' . PMA_Util::getIcon('b_drop.png', __('Delete')) . '</a>' . '<input type="submit" data-rownum = "' . $row_num . '"' . ' class="edit_cancel_form" value="Cancel"></td>' . '<td id="save_' . $row_num . '" style="display:none">' . '<input type="submit" data-rownum = "' . $row_num . '"' . ' class="edit_save_form" value="Save"></td>';
    $tableHtml .= '<td name="col_name" class="nowrap">' . '<span>' . htmlspecialchars($row['col_name']) . '</span>' . '<input name="orig_col_name" type="hidden" ' . 'value="' . htmlspecialchars($row['col_name']) . '">' . PMA_getHtmlForColumnName($row_num, 0, 0, array('Field' => $row['col_name']), array('central_columnswork' => false)) . '</td>';
    $tableHtml .= '<td name = "col_type" class="nowrap"><span>' . htmlspecialchars($row['col_type']) . '</span>' . PMA_getHtmlForColumnType($row_num, 1, 0, mb_strtoupper($row['col_type']), array()) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_length">' . '<span>' . ($row['col_length'] ? htmlspecialchars($row['col_length']) : "") . '</span>' . PMA_getHtmlForColumnLength($row_num, 2, 0, 8, $row['col_length']) . '</td>';
    $meta = array();
    if (!isset($row['col_default']) || $row['col_default'] == '') {
        $meta['DefaultType'] = 'NONE';
    } else {
        if ($row['col_default'] == 'CURRENT_TIMESTAMP' || $row['col_default'] == 'NULL') {
            $meta['DefaultType'] = $row['col_default'];
        } else {
            $meta['DefaultType'] = 'USER_DEFINED';
            $meta['DefaultValue'] = $row['col_default'];
        }
    }
    $tableHtml .= '<td class="nowrap" name="col_default"><span>' . (isset($row['col_default']) ? htmlspecialchars($row['col_default']) : 'None') . '</span>' . PMA_getHtmlForColumnDefault($row_num, 3, 0, mb_strtoupper($row['col_type']), '', $meta) . '</td>';
    $tableHtml .= '<td name="collation" class="nowrap">' . '<span>' . htmlspecialchars($row['col_collation']) . '</span>' . PMA_getHtmlForColumnCollation($row_num, 4, 0, array('Collation' => $row['col_collation'])) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_attribute">' . '<span>' . ($row['col_attribute'] ? htmlspecialchars($row['col_attribute']) : "") . '</span>' . PMA_getHtmlForColumnAttribute($row_num, 5, 0, array(), $row['col_attribute'], false, null) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_isNull">' . '<span>' . ($row['col_isNull'] ? __('Yes') : __('No')) . '</span>' . PMA_getHtmlForColumnNull($row_num, 6, 0, array('Null' => $row['col_isNull'])) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_extra"><span>' . htmlspecialchars($row['col_extra']) . '</span>' . PMA_getHtmlForColumnExtra($row_num, 7, 0, array('Extra' => $row['col_extra'])) . '</td>';
    $tableHtml .= '</tr>';
    return $tableHtml;
}
/**
 * Prints Html for Server Variables Items
 *
 * @param Array $variable_doc_links documentation links
 * @param Array $serverVars         global variables
 * @param Array $serverVarsSession  session variables
 *
 * @return string
 */
function PMA_getHtmlForServerVariablesItems($variable_doc_links, $serverVars, $serverVarsSession)
{
    // list of static system variables
    $static_variables = PMA_getStaticSystemVariables();
    $output = '<tbody>';
    $odd_row = true;
    foreach ($serverVars as $name => $value) {
        $has_session_value = isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value;
        $row_class = ($odd_row ? ' odd' : ' even') . ($has_session_value ? ' diffSession' : '');
        $output .= '<tr class="var-row' . $row_class . '">';
        $output .= '<td class="var-action">';
        // Edit Link active only for Dynamic System variables
        if (!in_array(strtolower($name), $static_variables)) {
            $output .= '<a href="#" class="editLink">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>';
        } else {
            $output .= '<span title="' . __('This is a read-only variable and can not be edited') . '" class="read_only_var" >' . PMA_Util::getIcon('bd_edit.png', __('Edit')) . '</span>';
        }
        $output .= '</td>';
        $output .= '<td class="var-name">';
        // To display variable documentation link
        if (isset($variable_doc_links[$name])) {
            $output .= '<span title="' . htmlspecialchars(str_replace('_', ' ', $name)) . '">';
            $output .= PMA_Util::showMySQLDocu($variable_doc_links[$name][1], false, $variable_doc_links[$name][2] . '_' . $variable_doc_links[$name][0], true);
            $output .= htmlspecialchars(str_replace('_', ' ', $name));
            $output .= '</a>';
            $output .= '</span>';
        } else {
            $output .= htmlspecialchars(str_replace('_', ' ', $name));
        }
        $output .= '</td>';
        $output .= '<td class="var-value value' . ($GLOBALS['dbi']->isSuperuser() ? ' editable' : '') . '">&nbsp;' . PMA_formatVariable($name, $value, $variable_doc_links) . '</td>' . '</tr>';
        if ($has_session_value) {
            $output .= '<tr class="var-row' . ($odd_row ? ' odd' : ' even') . '">' . '<td class="var-action"></td>' . '<td class="var-name session">(' . __('Session value') . ')</td>' . '<td class="var-value value">&nbsp;' . PMA_formatVariable($name, $serverVarsSession[$name], $variable_doc_links) . '</td>' . '</tr>';
        }
        $odd_row = !$odd_row;
    }
    $output .= '</tbody>';
    return $output;
}
Ejemplo n.º 17
0
    echo __('Action');
    ?>
</th>
        <th><?php 
    echo __('Show');
    ?>
</th>
    </tr>
    </thead>
    <tbody>
    <?php 
    // Print out information about versions
    $delete = PMA_Util::getIcon('b_drop.png', __('Delete tracking'));
    $versions = PMA_Util::getIcon('b_versions.png', __('Versions'));
    $report = PMA_Util::getIcon('b_report.png', __('Tracking report'));
    $structure = PMA_Util::getIcon('b_props.png', __('Structure snapshot'));
    $style = 'odd';
    while ($one_result = $GLOBALS['dbi']->fetchArray($all_tables_result)) {
        list($table_name, $version_number) = $one_result;
        $table_query = ' SELECT * FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['tracking']) . ' WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($_REQUEST['db']) . '\' AND `table_name`  = \'' . PMA_Util::sqlAddSlashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
        $table_result = PMA_queryAsControlUser($table_query);
        $version_data = $GLOBALS['dbi']->fetchArray($table_result);
        $tmp_link = 'tbl_tracking.php' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
        $delete_link = 'db_tracking.php' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
        $checkbox_id = "selected_tbl_" . htmlspecialchars($version_data['table_name']);
        ?>
        <tr class="<?php 
        echo $style;
        ?>
">
            <td class="center">
Ejemplo n.º 18
0
 /**
  * Show index data
  *
  * @param string  $table      The table name
  * @param string  $schema     The schema name
  * @param boolean $print_mode Whether the output is for the print mode
  *
  * @return string HTML for showing index
  *
  * @access  public
  */
 public static function getView($table, $schema, $print_mode = false)
 {
     $indexes = PMA_Index::getFromTable($table, $schema);
     $no_indexes_class = count($indexes) > 0 ? ' hide' : '';
     $no_indexes = "<div class='no_indexes_defined{$no_indexes_class}'>";
     $no_indexes .= PMA_Message::notice(__('No index defined!'))->getDisplay();
     $no_indexes .= '</div>';
     if (!$print_mode) {
         $r = '<fieldset class="index_info">';
         $r .= '<legend id="index_header">' . __('Indexes');
         $r .= PMA_Util::showMySQLDocu('optimizing-database-structure');
         $r .= '</legend>';
         $r .= $no_indexes;
         if (count($indexes) < 1) {
             $r .= '</fieldset>';
             return $r;
         }
         $r .= PMA_Index::findDuplicates($table, $schema);
     } else {
         $r = '<h3>' . __('Indexes') . '</h3>';
         $r .= $no_indexes;
         if (count($indexes) < 1) {
             return $r;
         }
     }
     $r .= '<table id="table_index">';
     $r .= '<thead>';
     $r .= '<tr>';
     if (!$print_mode) {
         $r .= '<th colspan="2">' . __('Action') . '</th>';
     }
     $r .= '<th>' . __('Keyname') . '</th>';
     $r .= '<th>' . __('Type') . '</th>';
     $r .= '<th>' . __('Unique') . '</th>';
     $r .= '<th>' . __('Packed') . '</th>';
     $r .= '<th>' . __('Column') . '</th>';
     $r .= '<th>' . __('Cardinality') . '</th>';
     $r .= '<th>' . __('Collation') . '</th>';
     $r .= '<th>' . __('Null') . '</th>';
     if (PMA_MYSQL_INT_VERSION > 50500) {
         $r .= '<th>' . __('Comment') . '</th>';
     }
     $r .= '</tr>';
     $r .= '</thead>';
     $r .= '<tbody>';
     $odd_row = true;
     foreach ($indexes as $index) {
         $row_span = ' rowspan="' . $index->getColumnCount() . '" ';
         $r .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
         if (!$print_mode) {
             $this_params = $GLOBALS['url_params'];
             $this_params['index'] = $index->getName();
             $r .= '<td class="edit_index';
             $r .= ' ajax';
             $r .= '" ' . $row_span . '>' . '    <a class="';
             $r .= 'ajax';
             $r .= '" href="tbl_indexes.php' . PMA_URL_getCommon($this_params) . '">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>' . '</td>' . "\n";
             $this_params = $GLOBALS['url_params'];
             if ($index->getName() == 'PRIMARY') {
                 $this_params['sql_query'] = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' DROP PRIMARY KEY;';
                 $this_params['message_to_show'] = __('The primary key has been dropped.');
                 $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY');
             } else {
                 $this_params['sql_query'] = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' DROP INDEX ' . PMA_Util::backquote($index->getName()) . ';';
                 $this_params['message_to_show'] = sprintf(__('Index %s has been dropped.'), $index->getName());
                 $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName() . ';');
             }
             $r .= '<td ' . $row_span . '>';
             $r .= '<input type="hidden" class="drop_primary_key_index_msg"' . ' value="' . $js_msg . '" />';
             $r .= '    <a class="drop_primary_key_index_anchor';
             $r .= ' ajax';
             $r .= '" href="sql.php' . PMA_URL_getCommon($this_params) . '" >' . PMA_Util::getIcon('b_drop.png', __('Drop')) . '</a>' . '</td>' . "\n";
         }
         if (!$print_mode) {
             $r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>';
         } else {
             $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</td>';
         }
         $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getType()) . '</td>';
         $r .= '<td ' . $row_span . '>' . $index->isUnique(true) . '</td>';
         $r .= '<td ' . $row_span . '>' . $index->isPacked(true) . '</td>';
         foreach ($index->getColumns() as $column) {
             if ($column->getSeqInIndex() > 1) {
                 $r .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">';
             }
             $r .= '<td>' . htmlspecialchars($column->getName());
             if ($column->getSubPart()) {
                 $r .= ' (' . $column->getSubPart() . ')';
             }
             $r .= '</td>';
             $r .= '<td>' . htmlspecialchars($column->getCardinality()) . '</td>';
             $r .= '<td>' . htmlspecialchars($column->getCollation()) . '</td>';
             $r .= '<td>' . htmlspecialchars($column->getNull(true)) . '</td>';
             if (PMA_MYSQL_INT_VERSION > 50500 && $column->getSeqInIndex() == 1) {
                 $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getComments()) . '</td>';
             }
             $r .= '</tr>';
         }
         // end foreach $index['Sequences']
         $odd_row = !$odd_row;
     }
     // end while
     $r .= '</tbody>';
     $r .= '</table>';
     if (!$print_mode) {
         $r .= '</fieldset>';
     }
     return $r;
 }
Ejemplo n.º 19
0
/**
 * Get HTML for gis data types
 *
 * @return string an html snippet
 */
function PMA_getHTMLforGisDataTypes()
{
    $edit_str = PMA_Util::getIcon('b_edit.png', __('Edit/Insert'));
    return '<span class="open_gis_editor">' . PMA_Util::linkOrButton('#', $edit_str, array(), false, false, '_blank') . '</span>';
}
Ejemplo n.º 20
0
$biggest_max_file_size = 0;
$url_params['db'] = $db;
$url_params['table'] = $table;
$url_params = PMA_urlParamsInEditMode($url_params, $where_clause_array, $where_clause);
$has_blob_field = false;
foreach ($table_columns as $column) {
    if (PMA_isColumn($column, array('blob', 'tinyblob', 'mediumblob', 'longblob'))) {
        $has_blob_field = true;
        break;
    }
}
//Insert/Edit form
//If table has blob fields we have to disable ajax.
$html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
$html_output .= PMA_URL_getHiddenInputs($_form_params);
$titles['Browse'] = PMA_Util::getIcon('b_browse.png', __('Browse foreign values'));
// user can toggle the display of Function column and column types
// (currently does not work for multi-edits)
if (!$cfg['ShowFunctionFields'] || !$cfg['ShowFieldTypesInDataEditView']) {
    $html_output .= __('Show');
}
if (!$cfg['ShowFunctionFields']) {
    $html_output .= PMA_showTypeOrFunction('function', $url_params, false);
}
if (!$cfg['ShowFieldTypesInDataEditView']) {
    $html_output .= PMA_showTypeOrFunction('type', $url_params, false);
}
$GLOBALS['plugin_scripts'] = array();
foreach ($rows as $row_id => $current_row) {
    if (empty($current_row)) {
        $current_row = array();
Ejemplo n.º 21
0
/**
 * Function to get html for displaying last version number
 *
 * @param array  $sql_result    sql result
 * @param int    $last_version  last version
 * @param array  $url_params    url parameters
 * @param string $url_query     url query
 * @param string $pmaThemeImage path to theme's image folder
 * @param string $text_dir      text direction
 *
 * @return string
 */
function PMA_getHtmlForTableVersionDetails($sql_result, $last_version, $url_params, $url_query, $pmaThemeImage, $text_dir)
{
    $tracking_active = false;
    $html = '<form method="post" action="tbl_tracking.php" name="versionsForm"' . ' id="versionsForm" class="ajax">';
    $html .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
    $html .= '<table id="versions" class="data">';
    $html .= '<thead>';
    $html .= '<tr>';
    $html .= '<th></th>';
    $html .= '<th>' . __('Version') . '</th>';
    $html .= '<th>' . __('Created') . '</th>';
    $html .= '<th>' . __('Updated') . '</th>';
    $html .= '<th>' . __('Status') . '</th>';
    $html .= '<th>' . __('Action') . '</th>';
    $html .= '<th>' . __('Show') . '</th>';
    $html .= '</tr>';
    $html .= '</thead>';
    $html .= '<tbody>';
    $style = 'odd';
    $GLOBALS['dbi']->dataSeek($sql_result, 0);
    $delete = PMA_Util::getIcon('b_drop.png', __('Delete version'));
    $report = PMA_Util::getIcon('b_report.png', __('Tracking report'));
    $structure = PMA_Util::getIcon('b_props.png', __('Structure snapshot'));
    while ($version = $GLOBALS['dbi']->fetchArray($sql_result)) {
        if ($version['version'] == $last_version) {
            if ($version['tracking_active'] == 1) {
                $tracking_active = true;
            } else {
                $tracking_active = false;
            }
        }
        $delete_link = 'tbl_tracking.php' . $url_query . '&amp;version=' . htmlspecialchars($version['version']) . '&amp;submit_delete_version=true';
        $checkbox_id = 'selected_versions_' . htmlspecialchars($version['version']);
        $html .= '<tr class="' . $style . '">';
        $html .= '<td class="center">';
        $html .= '<input type="checkbox" name="selected_versions[]"' . ' class="checkall" id="' . $checkbox_id . '"' . ' value="' . htmlspecialchars($version['version']) . '"/>';
        $html .= '</td>';
        $html .= '<th class="floatright">';
        $html .= '<label for="' . $checkbox_id . '">' . htmlspecialchars($version['version']) . '</label>';
        $html .= '</th>';
        $html .= '<td>' . htmlspecialchars($version['date_created']) . '</td>';
        $html .= '<td>' . htmlspecialchars($version['date_updated']) . '</td>';
        $html .= '<td>' . PMA_getVersionStatus($version) . '</td>';
        $html .= '<td><a class="delete_version_anchor ajax"' . ' href="' . $delete_link . '" >' . $delete . '</a></td>';
        $html .= '<td><a href="tbl_tracking.php';
        $html .= PMA_URL_getCommon($url_params + array('report' => 'true', 'version' => $version['version']));
        $html .= '">' . $report . '</a>';
        $html .= '&nbsp;&nbsp;';
        $html .= '<a href="tbl_tracking.php';
        $html .= PMA_URL_getCommon($url_params + array('snapshot' => 'true', 'version' => $version['version']));
        $html .= '">' . $structure . '</a>';
        $html .= '</td>';
        $html .= '</tr>';
        if ($style == 'even') {
            $style = 'odd';
        } else {
            $style = 'even';
        }
    }
    $html .= '</tbody>';
    $html .= '</table>';
    $html .= PMA_Util::getWithSelected($pmaThemeImage, $text_dir, "versionsForm");
    $html .= PMA_Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete_version', __('Delete version'), 'b_drop.png', 'delete_version');
    $html .= '</form>';
    if ($tracking_active) {
        $html .= PMA_getHtmlForActivateDeactivateTracking('deactivate', $url_query, $last_version);
    } else {
        $html .= PMA_getHtmlForActivateDeactivateTracking('activate', $url_query, $last_version);
    }
    return $html;
}
Ejemplo n.º 22
0
/**
 * build html for a row in central columns table
 *
 * @param array   $row     array contains complete information of
 * a particular row of central list table
 * @param boolean $odd_row set true if the row is at odd number position
 * @param int     $row_num position the row in the table
 * @param string  $db      current database
 *
 * @return html of a particular row in the central columns table.
 */
function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
{
    $tableHtml = '<tr data-rownum="' . $row_num . '" id="f_' . $row_num . '" ' . 'class="' . ($odd_row ? 'odd' : 'even') . '">' . PMA_URL_getHiddenInputs($db) . '<input type="hidden" name="edit_save" value="save">' . '<td class="nowrap">' . '<input type="checkbox" class="checkall" name="selected_fld[]" ' . 'value="' . htmlspecialchars($row['col_name']) . '" ' . 'id="checkbox_row_' . $row_num . '"/>' . '</td>' . '<td id="edit_' . $row_num . '" class="edit center">' . '<a href="#">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a></td>' . '<td class="del_row" data-rownum = "' . $row_num . '">' . '<a hrf="#">' . PMA_Util::getIcon('b_drop.png', __('Delete')) . '</a>' . '<input type="submit" data-rownum = "' . $row_num . '"' . ' class="edit_cancel_form" value="Cancel"></td>' . '<td id="save_' . $row_num . '" style="display:none">' . '<input type="submit" data-rownum = "' . $row_num . '"' . ' class="edit_save_form" value="Save"></td>';
    $tableHtml .= '<td name="col_name" class="nowrap">' . '<span>' . htmlspecialchars($row['col_name']) . '</span>' . '<input name="orig_col_name" type="hidden" ' . 'value="' . htmlspecialchars($row['col_name']) . '">' . PMA\Template::get('columns_definitions/column_name')->render(array('columnNumber' => $row_num, 'ci' => 0, 'ci_offset' => 0, 'columnMeta' => array('Field' => $row['col_name']), 'cfgRelation' => array('centralcolumnswork' => false))) . '</td>';
    $tableHtml .= '<td name = "col_type" class="nowrap"><span>' . htmlspecialchars($row['col_type']) . '</span>' . PMA\Template::get('columns_definitions/column_type')->render(array('columnNumber' => $row_num, 'ci' => 1, 'ci_offset' => 0, 'type_upper' => mb_strtoupper($row['col_type']), 'columnMeta' => array())) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_length">' . '<span>' . ($row['col_length'] ? htmlspecialchars($row['col_length']) : "") . '</span>' . PMA\Template::get('columns_definitions/column_length')->render(array('columnNumber' => $row_num, 'ci' => 2, 'ci_offset' => 0, 'length_values_input_size' => 8, 'length_to_display' => $row['col_length'])) . '</td>';
    $meta = array();
    if (!isset($row['col_default']) || $row['col_default'] == '') {
        $meta['DefaultType'] = 'NONE';
    } else {
        if ($row['col_default'] == 'CURRENT_TIMESTAMP' || $row['col_default'] == 'NULL') {
            $meta['DefaultType'] = $row['col_default'];
        } else {
            $meta['DefaultType'] = 'USER_DEFINED';
            $meta['DefaultValue'] = $row['col_default'];
        }
    }
    $tableHtml .= '<td class="nowrap" name="col_default"><span>' . (isset($row['col_default']) ? htmlspecialchars($row['col_default']) : 'None') . '</span>' . PMA\Template::get('columns_definitions/column_default')->render(array('columnNumber' => $row_num, 'ci' => 3, 'ci_offset' => 0, 'type_upper' => mb_strtoupper($row['col_type']), 'columnMeta' => $meta)) . '</td>';
    $tableHtml .= '<td name="collation" class="nowrap">' . '<span>' . htmlspecialchars($row['col_collation']) . '</span>' . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[' . $row_num . ']', 'field_' . $row_num . '_4', $row['col_collation'], false) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_attribute">' . '<span>' . ($row['col_attribute'] ? htmlspecialchars($row['col_attribute']) : "") . '</span>' . PMA\Template::get('columns_definitions/column_attribute')->render(array('columnNumber' => $row_num, 'ci' => 5, 'ci_offset' => 0, 'extracted_columnspec' => array(), 'columnMeta' => $row['col_attribute'], 'submit_attribute' => false)) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_isNull">' . '<span>' . ($row['col_isNull'] ? __('Yes') : __('No')) . '</span>' . PMA\Template::get('columns_definitions/column_null')->render(array('columnNumber' => $row_num, 'ci' => 6, 'ci_offset' => 0, 'columnMeta' => array('Null' => $row['col_isNull']))) . '</td>';
    $tableHtml .= '<td class="nowrap" name="col_extra"><span>' . htmlspecialchars($row['col_extra']) . '</span>' . PMA\Template::get('columns_definitions/column_extra')->render(array('columnNumber' => $row_num, 'ci' => 7, 'ci_offset' => 0, 'columnMeta' => array('Extra' => $row['col_extra']))) . '</td>';
    $tableHtml .= '</tr>';
    return $tableHtml;
}
 /**
  * Test for PMA_getAddUserHtmlFieldset
  *
  * @return void
  */
 public function testPMAGetAddUserHtmlFieldset()
 {
     $html = PMA_getAddUserHtmlFieldset();
     $this->assertContains(PMA_URL_getCommon(array('adduser' => 1)), $html);
     $this->assertContains(PMA_Util::getIcon('b_usradd.png'), $html);
     $this->assertContains(__('Add user'), $html);
 }
Ejemplo n.º 24
0
/**
 * Prints Html for Server Variables Items
 *
 * @param Array $variable_doc_links documentation links
 *
 * @return string
 */
function PMA_getHtmlForServerVariablesItems($variable_doc_links)
{
    /**
     * Sends the queries and buffers the results
     */
    $serverVarsSession = $GLOBALS['dbi']->fetchResult('SHOW SESSION VARIABLES;', 0, 1);
    $serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
    $output = '<tbody>';
    $odd_row = true;
    foreach ($serverVars as $name => $value) {
        $has_session_value = isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value;
        $row_class = ($odd_row ? ' odd' : ' even') . ($has_session_value ? ' diffSession' : '');
        $output .= '<tr class="var-row' . $row_class . '">';
        $output .= '<td class="var-action">';
        $output .= '<a href="#" class="editLink">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>';
        $output .= '</td>';
        $output .= '<td class="var-name">';
        // To display variable documentation link
        if (isset($variable_doc_links[$name])) {
            $output .= '<span title="' . htmlspecialchars(str_replace('_', ' ', $name)) . '">';
            $output .= PMA_Util::showMySQLDocu($variable_doc_links[$name][1], false, $variable_doc_links[$name][2] . '_' . $variable_doc_links[$name][0], true);
            $output .= htmlspecialchars(str_replace('_', ' ', $name));
            $output .= '</a>';
            $output .= '</span>';
        } else {
            $output .= htmlspecialchars(str_replace('_', ' ', $name));
        }
        $output .= '</td>';
        $output .= '<td class="var-value value' . ($GLOBALS['dbi']->isSuperuser() ? ' editable' : '') . '">&nbsp;' . PMA_formatVariable($name, $value, $variable_doc_links) . '</td>' . '</tr>';
        if ($has_session_value) {
            $output .= '<tr class="var-row' . ($odd_row ? ' odd' : ' even') . '">' . '<td class="var-action"></td>' . '<td class="var-name session">(' . __('Session value') . ')</td>' . '<td class="var-value value">&nbsp;' . PMA_formatVariable($name, $serverVarsSession[$name], $variable_doc_links) . '</td>' . '</tr>';
        }
        $odd_row = !$odd_row;
    }
    $output .= '</tbody>';
    return $output;
}
Ejemplo n.º 25
0
/**
 * Function to get html for bookmark support if bookmarks are enabled. Else will
 * return null
 *
 * @param string $disp_mode      display mode
 * @param bool   $cfgBookmark    configuration setting for bookmarking
 * @param string $sql_query      sql query
 * @param string $db             current database
 * @param string $table          current table
 * @param string $complete_query complete query
 * @param string $bkm_user       bookmarking user
 *
 * @return string $html
 */
function PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $table, $complete_query, $bkm_user)
{
    if ($disp_mode[7] == '1' && (!empty($cfgBookmark) && empty($_GET['id_bookmark'])) && !empty($sql_query)) {
        $goto = 'sql.php' . PMA_URL_getCommon(array('db' => $db, 'table' => $table, 'sql_query' => $sql_query, 'id_bookmark' => 1));
        $bkm_sql_query = urlencode(isset($complete_query) ? $complete_query : $sql_query);
        $html = '<form action="sql.php" method="post"' . ' onsubmit="return ! emptyCheckTheField(this,' . '\'bkm_fields[bkm_label]\');"' . ' id="bookmarkQueryForm">';
        $html .= PMA_URL_getHiddenInputs();
        $html .= '<input type="hidden" name="db"' . ' value="' . htmlspecialchars($db) . '" />';
        $html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
        $html .= '<input type="hidden" name="bkm_fields[bkm_database]"' . ' value="' . htmlspecialchars($db) . '" />';
        $html .= '<input type="hidden" name="bkm_fields[bkm_user]"' . ' value="' . $bkm_user . '" />';
        $html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"' . ' value="' . $bkm_sql_query . '" />';
        $html .= '<fieldset>';
        $html .= '<legend>';
        $html .= PMA_Util::getIcon('b_bookmark.png', __('Bookmark this SQL query'), true);
        $html .= '</legend>';
        $html .= '<div class="formelement">';
        $html .= '<label for="fields_label_">' . __('Label:') . '</label>';
        $html .= '<input type="text" id="fields_label_"' . ' name="bkm_fields[bkm_label]" value="" />';
        $html .= '</div>';
        $html .= '<div class="formelement">';
        $html .= '<input type="checkbox" name="bkm_all_users"' . ' id="bkm_all_users" value="true" />';
        $html .= '<label for="bkm_all_users">' . __('Let every user access this bookmark') . '</label>';
        $html .= '</div>';
        $html .= '<div class="clearfloat"></div>';
        $html .= '</fieldset>';
        $html .= '<fieldset class="tblFooters">';
        $html .= '<input type="hidden" name="store_bkm" value="1" />';
        $html .= '<input type="submit"' . ' value="' . __('Bookmark this SQL query') . '" />';
        $html .= '</fieldset>';
        $html .= '</form>';
    } else {
        $html = null;
    }
    return $html;
}
Ejemplo n.º 26
0
/**
 * Function to get html for an entire row in foreign key form
 *
 * @param array  $one_key            Single foreign key constraint
 * @param bool   $odd_row            whether odd or even row
 * @param array  $columns            Array of table columns
 * @param int    $i                  Row number
 * @param array  $options_array      Options array
 * @param string $tbl_storage_engine table storage engine
 * @param string $db                 Database
 *
 * @return string html
 */
function PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i, $options_array, $tbl_storage_engine, $db)
{
    $html_output = '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
    // Drop key anchor.
    $html_output .= '<td>';
    if (isset($one_key['constraint'])) {
        $drop_fk_query = 'ALTER TABLE ' . PMA_Util::backquote($GLOBALS['table']) . ' DROP FOREIGN KEY ' . PMA_Util::backquote($one_key['constraint']) . ';';
        $this_params = $GLOBALS['url_params'];
        $this_params['goto'] = 'tbl_relation.php';
        $this_params['back'] = 'tbl_relation.php';
        $this_params['sql_query'] = $drop_fk_query;
        $this_params['message_to_show'] = sprintf(__('Foreign key constraint %s has been dropped'), $one_key['constraint']);
        $js_msg = PMA_jsFormat('ALTER TABLE ' . $GLOBALS['table'] . ' DROP FOREIGN KEY ' . $one_key['constraint'] . ';');
        $html_output .= '<input type="hidden" class="drop_foreign_key_msg"' . ' value="' . $js_msg . '" />';
        $html_output .= '    <a class="drop_foreign_key_anchor';
        $html_output .= ' ajax';
        $html_output .= '" href="sql.php' . PMA_URL_getCommon($this_params) . '" >' . PMA_Util::getIcon('b_drop.png', __('Drop')) . '</a>';
    }
    $html_output .= '</td>';
    $html_output .= '<td>';
    $html_output .= '<span class="formelement clearfloat">';
    $constraint_name = isset($one_key['constraint']) ? $one_key['constraint'] : '';
    $html_output .= '<input type="text" name="constraint_name[' . $i . ']"' . ' value="' . htmlspecialchars($constraint_name) . '"' . ' placeholder="' . __('Constraint name') . '" />';
    $html_output .= '</span>' . "\n";
    $html_output .= '<div class="floatleft">';
    $html_output .= '<span class="formelement">';
    // For ON DELETE and ON UPDATE, the default action
    // is RESTRICT as per MySQL doc; however, a SHOW CREATE TABLE
    // won't display the clause if it's set as RESTRICT.
    $on_delete = isset($one_key['on_delete']) ? $one_key['on_delete'] : 'RESTRICT';
    $html_output .= PMA_generateDropdown('ON DELETE', 'on_delete[' . $i . ']', $options_array, $on_delete);
    $html_output .= '</span>' . "\n";
    $html_output .= '<span class="formelement">' . "\n";
    $on_update = isset($one_key['on_update']) ? $one_key['on_update'] : 'RESTRICT';
    $html_output .= PMA_generateDropdown('ON UPDATE', 'on_update[' . $i . ']', $options_array, $on_update);
    $html_output .= '</span>';
    $html_output .= '</div>';
    $column_array = array();
    $column_array[''] = '';
    foreach ($columns as $column) {
        if (!empty($column['Key'])) {
            $column_array[$column['Field']] = $column['Field'];
        }
    }
    $html_output .= '</span>' . "\n";
    $html_output .= '</td>';
    $html_output .= '<td>';
    if (isset($one_key['index_list'])) {
        foreach ($one_key['index_list'] as $key => $column) {
            $html_output .= '<span class="formelement clearfloat">';
            $html_output .= PMA_generateDropdown('', 'foreign_key_fields_name[' . $i . '][]', $column_array, $column);
            $html_output .= '</span>';
        }
    } else {
        $html_output .= '<span class="formelement clearfloat">';
        $html_output .= PMA_generateDropdown('', 'foreign_key_fields_name[' . $i . '][]', $column_array, '');
        $html_output .= '</span>';
    }
    $html_output .= '<a class="formelement clearfloat add_foreign_key_field"' . ' href="" data-index="' . $i . '">' . __('+ Add column') . '</a>';
    $html_output .= '</td>';
    $html_output .= '<td>';
    $foreign_table = false;
    // foreign database dropdown
    $foreign_db = isset($one_key['ref_db_name']) ? $one_key['ref_db_name'] : $db;
    $html_output .= '<span class="formelement clearfloat">';
    $html_output .= PMA_generateRelationalDropdown('destination_foreign_db[' . $i . ']', $GLOBALS['pma']->databases, $foreign_db, __('Database'));
    // end of foreign database dropdown
    $html_output .= '</td>';
    $html_output .= '<td>';
    // foreign table dropdown
    $tables = array();
    if ($foreign_db) {
        $foreign_table = isset($one_key['ref_table_name']) ? $one_key['ref_table_name'] : '';
        // In Drizzle, 'SHOW TABLE STATUS' will show status only for the tables
        // which are currently in the table cache. Hence we have to use
        // 'SHOW TABLES' and manualy retrieve table engine values.
        if (PMA_DRIZZLE) {
            $tables_rs = $GLOBALS['dbi']->query('SHOW TABLES FROM ' . PMA_Util::backquote($foreign_db), null, PMA_DatabaseInterface::QUERY_STORE);
            while ($row = $GLOBALS['dbi']->fetchArray($tables_rs)) {
                $engine = PMA_Table::sGetStatusInfo($foreign_db, $row[0], 'Engine');
                if (isset($engine) && mb_strtoupper($engine) == $tbl_storage_engine) {
                    $tables[] = $row[0];
                }
            }
        } else {
            $tables_rs = $GLOBALS['dbi']->query('SHOW TABLE STATUS FROM ' . PMA_Util::backquote($foreign_db), null, PMA_DatabaseInterface::QUERY_STORE);
            while ($row = $GLOBALS['dbi']->fetchRow($tables_rs)) {
                if (isset($row[1]) && mb_strtoupper($row[1]) == $tbl_storage_engine) {
                    $tables[] = $row[0];
                }
            }
        }
    }
    $html_output .= '<span class="formelement clearfloat">';
    $html_output .= PMA_generateRelationalDropdown('destination_foreign_table[' . $i . ']', $tables, $foreign_table, __('Table'));
    $html_output .= '</span>';
    // end of foreign table dropdown
    $html_output .= '</td>';
    $html_output .= '<td>';
    // foreign column dropdown
    if ($foreign_db && $foreign_table) {
        foreach ($one_key['ref_index_list'] as $foreign_column) {
            $table_obj = new PMA_Table($foreign_table, $foreign_db);
            $columns = $table_obj->getUniqueColumns(false, false);
            $html_output .= '<span class="formelement clearfloat">';
            $html_output .= PMA_generateRelationalDropdown('destination_foreign_column[' . $i . '][]', $columns, $foreign_column, __('Column'));
            $html_output .= '</span>';
        }
    } else {
        $html_output .= '<span class="formelement clearfloat">';
        $html_output .= PMA_generateRelationalDropdown('destination_foreign_column[' . $i . '][]', array(), '', __('Column'));
        $html_output .= '</span>';
    }
    // end of foreign column dropdown
    $html_output .= '</td>';
    $html_output .= '</tr>';
    return $html_output;
}
Ejemplo n.º 27
0
/**
 * Returns HTML for the 'user groups' table
 *
 * @return string HTML for the 'user groups' table
 */
function PMA_getHtmlForUserGroupsTable()
{
    $tabs = PMA_Util::getMenuTabList();
    $html_output = '<h2>' . __('User groups') . '</h2>';
    $groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
    $sql_query = "SELECT * FROM " . $groupTable . " ORDER BY `usergroup` ASC";
    $result = PMA_queryAsControlUser($sql_query, false);
    if ($result && $GLOBALS['dbi']->numRows($result)) {
        $html_output .= '<form name="userGroupsForm" id="userGroupsForm"' . ' action="server_privileges.php" method="post">';
        $html_output .= PMA_URL_getHiddenInputs();
        $html_output .= '<table id="userGroupsTable">';
        $html_output .= '<thead><tr>';
        $html_output .= '<th style="white-space: nowrap">' . __('User group') . '</th>';
        $html_output .= '<th>' . __('Server level tabs') . '</th>';
        $html_output .= '<th>' . __('Database level tabs') . '</th>';
        $html_output .= '<th>' . __('Table level tabs') . '</th>';
        $html_output .= '<th>' . __('Action') . '</th>';
        $html_output .= '</tr></thead>';
        $html_output .= '<tbody>';
        $odd = true;
        $userGroups = array();
        while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
            $groupName = $row['usergroup'];
            if (!isset($userGroups[$groupName])) {
                $userGroups[$groupName] = array();
            }
            $userGroups[$groupName][$row['tab']] = $row['allowed'];
        }
        foreach ($userGroups as $groupName => $tabs) {
            $html_output .= '<tr class="' . ($odd ? 'odd' : 'even') . '">';
            $html_output .= '<td>' . htmlspecialchars($groupName) . '</td>';
            $html_output .= '<td>' . _getAllowedTabNames($tabs, 'server') . '</td>';
            $html_output .= '<td>' . _getAllowedTabNames($tabs, 'db') . '</td>';
            $html_output .= '<td>' . _getAllowedTabNames($tabs, 'table') . '</td>';
            $html_output .= '<td>';
            $html_output .= '<a class="" href="server_user_groups.php' . PMA_URL_getCommon(array('viewUsers' => 1, 'userGroup' => $groupName)) . '">' . PMA_Util::getIcon('b_usrlist.png', __('View users')) . '</a>';
            $html_output .= '&nbsp;&nbsp;';
            $html_output .= '<a class="" href="server_user_groups.php' . PMA_URL_getCommon(array('editUserGroup' => 1, 'userGroup' => $groupName)) . '">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>';
            $html_output .= '&nbsp;&nbsp;';
            $html_output .= '<a class="deleteUserGroup ajax"' . ' href="server_user_groups.php' . PMA_URL_getCommon(array('deleteUserGroup' => 1, 'userGroup' => $groupName)) . '">' . PMA_Util::getIcon('b_drop.png', __('Delete')) . '</a>';
            $html_output .= '</td>';
            $html_output .= '</tr>';
            $odd = !$odd;
        }
        $html_output .= '</tbody>';
        $html_output .= '</table>';
        $html_output .= '</form>';
    }
    $GLOBALS['dbi']->freeResult($result);
    $html_output .= '<fieldset id="fieldset_add_user_group">';
    $html_output .= '<a href="server_user_groups.php' . PMA_URL_getCommon(array('addUserGroup' => 1)) . '">' . PMA_Util::getIcon('b_usradd.png') . __('Add user group') . '</a>';
    $html_output .= '</fieldset>';
    return $html_output;
}
Ejemplo n.º 28
0
/**
 * Prints link templates
 *
 * @return string
 */
function PMA_getHtmlForLinkTemplates()
{
    $url = 'server_variables.php' . PMA_URL_getCommon(array());
    $output = '<a style="display: none;" href="#" class="editLink">';
    $output .= PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>';
    $output .= '<a style="display: none;" href="' . $url . '" class="ajax saveLink">';
    $output .= PMA_Util::getIcon('b_save.png', __('Save')) . '</a> ';
    $output .= '<a style="display: none;" href="#" class="cancelLink">';
    $output .= PMA_Util::getIcon('b_close.png', __('Cancel')) . '</a> ';
    $output .= PMA_Util::getImage('b_help.png', __('Documentation'), array('style' => 'display:none', 'id' => 'docImage'));
    return $output;
}
Ejemplo n.º 29
0
 /**
  * Return HTML ul.
  *
  * @return string
  */
 public function getHtmlList()
 {
     // Remove Recent/Favorite tables that don't exist.
     foreach ($this->_tables as $tbl) {
         if (!$GLOBALS['dbi']->getColumns($tbl['db'], $tbl['table'])) {
             $this->remove($tbl['db'], $tbl['table']);
         }
     }
     $html = '';
     if (count($this->_tables)) {
         if ($this->_tableType == 'recent') {
             foreach ($this->_tables as $table) {
                 $html .= '<li class="warp_link">';
                 $html .= '<a href="sql.php?server=' . $GLOBALS['server'] . '&db=' . $table['db'] . '&table=' . $table['table'] . '&token=' . $_SESSION[' PMA_token '] . '">`' . $table['db'] . '`.`' . $table['table'] . '`</a>';
                 $html .= '</li>';
             }
         } else {
             foreach ($this->_tables as $table) {
                 $html .= '<li class="warp_link">';
                 $html .= '<a class="ajax favorite_table_anchor"';
                 $fav_params = array('db' => $table['db'], 'ajax_request' => true, 'favorite_table' => $table['table'], 'remove_favorite' => true);
                 $fav_rm_url = 'db_structure.php' . PMA_URL_getCommon($fav_params);
                 $html .= 'href="' . $fav_rm_url . '" title="' . __("Remove from Favorites") . '" data-favtargetn="' . $table['db'] . "." . $table['table'] . '" >' . PMA_Util::getIcon('b_favorite.png') . '</a>';
                 $html .= '<a href="sql.php?server=' . $GLOBALS['server'] . '&db=' . $table['db'] . '&table=' . $table['table'] . '&token=' . $_SESSION[' PMA_token '] . '">`' . $table['db'] . '`.`' . $table['table'] . '`</a>';
                 $html .= '</li>';
             }
         }
     } else {
         $html .= '<li class="warp_link">' . ($this->_tableType == 'recent' ? __('There are no recent tables.') : __('There are no favorite tables.')) . '</li>';
     }
     return $html;
 }
Ejemplo n.º 30
0
    <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;
            ?>
</td>
            </tr>