/**
  * Test for PMA_selectServer
  *
  * @return void
  */
 public function testPMASelectServer()
 {
     $not_only_options = false;
     $omit_fieldset = false;
     $GLOBALS['cfg']['DefaultTabServer'] = "welcome";
     $GLOBALS['cfg']['Servers'] = array('0' => array('host' => 'host0', 'port' => 'port0', 'only_db' => 'only_db0', 'user' => 'user0', 'auth_type' => 'config'), '1' => array('host' => 'host1', 'port' => 'port1', 'only_db' => 'only_db1', 'user' => 'user1', 'auth_type' => 'config'));
     //$not_only_options=false & $omit_fieldset=false
     $html = PMA_selectServer($not_only_options, $omit_fieldset);
     $server = $GLOBALS['cfg']['Servers']['0'];
     //server items
     $this->assertContains($server['host'], $html);
     $this->assertContains($server['port'], $html);
     $this->assertContains($server['only_db'], $html);
     $this->assertContains($server['user'], $html);
     $not_only_options = true;
     $omit_fieldset = true;
     $GLOBALS['cfg']['DisplayServersList'] = null;
     //$not_only_options=true & $omit_fieldset=true
     $html = PMA_selectServer($not_only_options, $omit_fieldset);
     //$GLOBALS['cfg']['DefaultTabServer']
     $this->assertContains(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server'), $html);
     //labels
     $this->assertContains(__('Current Server:'), $html);
     $this->assertContains('(' . __('Servers') . ')', $html);
     //server items
     $server = $GLOBALS['cfg']['Servers']['0'];
     $this->assertContains($server['host'], $html);
     $this->assertContains($server['port'], $html);
     $this->assertContains($server['only_db'], $html);
     $this->assertContains($server['user'], $html);
 }
 function testNotSupportedDataTypes()
 {
     $no_support_types = array();
     $this->assertEquals(
         $no_support_types, PMA_Util::unsupportedDatatypes()
     );
 }
    /**
     * @dataProvider dataProvider
     */
    function testConvert_bit_default_value_test($bit, $val)
    {
        $this->assertEquals(
            $val, PMA_Util::convertBitDefaultValue($bit)
        );

    }
 function testExtractValueFromFormattedSizeK()
 {
     $this->assertEquals(
         262144,
         PMA_Util::extractValueFromFormattedSize("256K")
     );
 }
Exemplo n.º 5
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;
}
/**
 * Saves user preferences
 *
 * @param array $config_array configuration array
 *
 * @return true|PMA_Message
 */
function PMA_saveUserprefs(array $config_array)
{
    $cfgRelation = PMA_getRelationsParam();
    $server = isset($GLOBALS['server']) ? $GLOBALS['server'] : $GLOBALS['cfg']['ServerDefault'];
    $cache_key = 'server_' . $server;
    if (!$cfgRelation['userconfigwork']) {
        // no pmadb table, use session storage
        $_SESSION['userconfig'] = array('db' => $config_array, 'ts' => time());
        if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
            unset($_SESSION['cache'][$cache_key]['userprefs']);
        }
        return true;
    }
    // save configuration to pmadb
    $query_table = PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['userconfig']);
    $query = 'SELECT `username` FROM ' . $query_table . ' WHERE `username` = \'' . PMA_Util::sqlAddSlashes($cfgRelation['user']) . '\'';
    $has_config = $GLOBALS['dbi']->fetchValue($query, 0, 0, $GLOBALS['controllink']);
    $config_data = json_encode($config_array);
    if ($has_config) {
        $query = 'UPDATE ' . $query_table . ' SET `timevalue` = NOW(), `config_data` = \'' . PMA_Util::sqlAddSlashes($config_data) . '\'' . ' WHERE `username` = \'' . PMA_Util::sqlAddSlashes($cfgRelation['user']) . '\'';
    } else {
        $query = 'INSERT INTO ' . $query_table . ' (`username`, `timevalue`,`config_data`) ' . 'VALUES (\'' . PMA_Util::sqlAddSlashes($cfgRelation['user']) . '\', NOW(), ' . '\'' . PMA_Util::sqlAddSlashes($config_data) . '\')';
    }
    if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
        unset($_SESSION['cache'][$cache_key]['userprefs']);
    }
    if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
        $message = PMA_Message::error(__('Could not save configuration'));
        $message->addMessage('<br /><br />');
        $message->addMessage(PMA_Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink'])));
        return $message;
    }
    return true;
}
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
    if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
        $response = PMA_Response::getInstance();
        $response->isSuccess(false);
        return;
    }
    // load revision data from repo
    $GLOBALS['PMA_Config']->checkGitRevision();
    // if using a remote commit fast-forwarded, link to GitHub
    $commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7);
    $commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>';
    if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
        $commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>';
    }
    $branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
    if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
        $branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>';
    }
    if ($branch !== false) {
        $branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
    } else {
        $branch = $commit_hash . ' (' . __('no branch') . ')';
    }
    $committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
    $author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
    PMA_printListItem(__('Git revision:') . ' ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null);
}
/**
 * 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;
}
Exemplo n.º 9
0
 /**
  * Test for PMA_getHtmlForActionLinks
  *
  * @return void
  */
 public function testPMAGetHtmlForActionLinks()
 {
     $current_table = array('TABLE_ROWS' => 3, 'TABLE_NAME' => 'name1', 'TABLE_COMMENT' => 'This is a test comment');
     $table_is_view = false;
     $tbl_url_query = 'tbl_url_query';
     $titles = array('Browse' => 'Browse1', 'NoBrowse' => 'NoBrowse1', 'Search' => 'Search1', 'NoSearch' => 'NoSearch1', 'Empty' => 'Empty1', 'NoEmpty' => 'NoEmpty1');
     $truename = 'truename';
     $db_is_system_schema = null;
     $url_query = 'url_query';
     //$table_is_view = true;
     list($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon) = PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_system_schema, $url_query);
     //$browse_table
     $this->assertContains($titles['Browse'], $browse_table);
     //$search_table
     $this->assertContains($titles['Search'], $search_table);
     $this->assertContains($tbl_url_query, $search_table);
     //$browse_table_label
     $this->assertContains($tbl_url_query, $browse_table_label);
     //$empty_table
     $this->assertContains($tbl_url_query, $empty_table);
     $this->assertContains(urlencode('TRUNCATE ' . PMA_Util::backquote($current_table['TABLE_NAME'])), $empty_table);
     $this->assertContains($titles['Empty'], $empty_table);
     //$table_is_view = false;
     $current_table = array('TABLE_ROWS' => 0, 'TABLE_NAME' => 'name1', 'TABLE_COMMENT' => 'This is a test comment');
     $table_is_view = false;
     list($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon) = PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_system_schema, $url_query);
     //$browse_table
     $this->assertContains($titles['NoBrowse'], $browse_table);
     //$search_table
     $this->assertContains($titles['NoSearch'], $search_table);
     //$browse_table_label
     $this->assertContains($tbl_url_query, $browse_table_label);
     $this->assertContains($titles['NoEmpty'], $empty_table);
 }
Exemplo n.º 10
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  *
  * @return Node_Function
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA_Util::getImage('b_routines.png', __('Function'));
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=FUNCTION' . '&amp;edit_item=1&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=FUNCTION' . '&amp;export_item=1&amp;token=' . $_SESSION[' PMA_token ']);
     $this->classes = 'function';
 }
Exemplo n.º 11
0
/**
 * This function utilizes the Mimer SQL Validator service
 * to validate an SQL query
 *
 * <http://developer.mimer.com/validator/index.htm>
 *
 * @param string $sql SQL query to validate
 *
 * @return string Validator result string
 *
 * @global array The PMA configuration array
 */
function PMA_validateSQL($sql)
{
    global $cfg;
    $str = '';
    if ($cfg['SQLValidator']['use']) {
        if (isset($GLOBALS['sqlvalidator_error']) && $GLOBALS['sqlvalidator_error']) {
            $str = sprintf(__('The SQL validator could not be initialized. Please check if you have installed the necessary PHP extensions as described in the %sdocumentation%s.'), '<a href="' . PMA_Util::getDocuLink('faq', 'faqsqlvalidator') . '" target="documentation">', '</a>');
        } else {
            // create new class instance
            $srv = new PMA_SQLValidator();
            // Checks for username settings
            // The class defaults to anonymous with an empty password
            // automatically
            if ($cfg['SQLValidator']['username'] != '') {
                $srv->setCredentials($cfg['SQLValidator']['username'], $cfg['SQLValidator']['password']);
            }
            // Identify ourselves to the server properly...
            $srv->appendCallingProgram('phpMyAdmin', PMA_VERSION);
            // ... and specify what database system we are using
            $srv->setTargetDbms('MySQL', PMA_MYSQL_STR_VERSION);
            // Log on to service
            $srv->start();
            // Do service validation
            $str = $srv->validationString($sql);
        }
    }
    // end if
    // Gives string back to caller
    return $str;
}
Exemplo n.º 12
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  *
  * @return Node_Procedure
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA_Util::getImage('b_routines.png', __('Procedure'));
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=PROCEDURE' . '&amp;execute_dialog=1&amp;token=' . $GLOBALS['token'], 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;item_name=%1$s&amp;item_type=PROCEDURE' . '&amp;edit_item=1&amp;token=' . $GLOBALS['token']);
     $this->classes = 'procedure';
 }
 /**
  * @dataProvider dataProvider
  * @return void
  */
 function test_generateHiddenMaxFileSize($size)
 {
     $this->assertEquals(
         PMA_Util::generateHiddenMaxFileSize($size),
         '<input type="hidden" name="MAX_FILE_SIZE" value="' . $size . '" />'
     );
 }
Exemplo n.º 14
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  *
  * @return Node_Index
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA_Util::getImage('b_index.png', __('Index'));
     $this->links = array('text' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;table=%2$s&amp;index=%1$s' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;table=%2$s&amp;index=%1$s' . '&amp;token=' . $_SESSION[' PMA_token ']);
     $this->classes = 'index';
 }
/**
 * This function is called from one of the other functions in this file
 * and it completes the handling of the export functionality.
 *
 * @param string $item_name   The name of the item that we are exporting
 * @param string $export_data The SQL query to create the requested item
 *
 * @return void
 */
function PMA_RTE_handleExport($item_name, $export_data)
{
    global $db;
    $item_name = htmlspecialchars(PMA_Util::backquote($_GET['item_name']));
    if ($export_data !== false) {
        $export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars(trim($export_data)) . '</textarea>';
        $title = sprintf(PMA_RTE_getWord('export'), $item_name);
        if ($GLOBALS['is_ajax_request'] == true) {
            $response = PMA_Response::getInstance();
            $response->addJSON('message', $export_data);
            $response->addJSON('title', $title);
            exit;
        } else {
            echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
        }
    } else {
        $_db = htmlspecialchars(PMA_Util::backquote($db));
        $message = __('Error in processing request:') . ' ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
        $response = PMA_message::error($message);
        if ($GLOBALS['is_ajax_request'] == true) {
            $response = PMA_Response::getInstance();
            $response->isSuccess(false);
            $response->addJSON('message', $message);
            exit;
        } else {
            $response->display();
        }
    }
}
/**
 * Returns the html for create table.
 *
 * @param string $db database name
 *
 * @return string
 */
function PMA_getHtmlForCreateTable($db)
{
    $html = '<form id="create_table_form_minimal" method="post" ' . 'action="tbl_create.php">';
    $html .= '<fieldset>';
    $html .= '<legend>';
    if (PMA_Util::showIcons('ActionLinksMode')) {
        $html .= PMA_Util::getImage('b_newtbl.png');
    }
    $html .= __('Create table');
    $html .= ' </legend>';
    $html .= PMA_URL_getHiddenInputs($db);
    $html .= '<div class="formelement">';
    $html .= __('Name') . ":";
    $html .= '  <input type="text" name="table" maxlength="64" ' . 'size="30" required="required" />';
    $html .= ' </div>';
    $html .= '  <div class="formelement">';
    $html .= __('Number of columns') . ":";
    $html .= '  <input type="number" min="1" name="num_fields" value="4" required="required" />';
    $html .= ' </div>';
    $html .= '  <div class="clearfloat"></div>';
    $html .= '</fieldset>';
    $html .= '<fieldset class="tblFooters">';
    $html .= '   <input type="submit" value="' . __('Go') . '" />';
    $html .= '</fieldset>';
    $html .= '</form>';
    return $html;
}
Exemplo n.º 17
0
/**
 * Get SQL query for store new transformation details of a VIEW
 *
 * @param mysqli_result $pma_transformation_data Result set of SQL execution
 * @param array         $column_map              Details of VIEW columns
 * @param string        $view_name               Name of the VIEW
 * @param string        $db                      Database name of the VIEW
 *
 * @return string $new_transformations_sql SQL query for new transformations
 */
function PMA_getNewTransformationDataSql($pma_transformation_data, $column_map, $view_name, $db)
{
    $cfgRelation = PMA_getRelationsParam();
    // Need to store new transformation details for VIEW
    $new_transformations_sql = 'INSERT INTO ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['column_info']) . ' (`db_name`, `table_name`, `column_name`, `comment`, ' . '`mimetype`, `transformation`, `transformation_options`)' . ' VALUES ';
    $column_count = 0;
    $add_comma = false;
    while ($data_row = $GLOBALS['dbi']->fetchAssoc($pma_transformation_data)) {
        foreach ($column_map as $column) {
            if ($data_row['table_name'] == $column['table_name'] && $data_row['column_name'] == $column['refering_column']) {
                $new_transformations_sql .= $add_comma ? ', ' : '';
                $new_transformations_sql .= '(' . '\'' . $db . '\', ' . '\'' . $view_name . '\', ' . '\'';
                $new_transformations_sql .= isset($column['real_column']) ? $column['real_column'] : $column['refering_column'];
                $new_transformations_sql .= '\', ' . '\'' . $data_row['comment'] . '\', ' . '\'' . $data_row['mimetype'] . '\', ' . '\'' . $data_row['transformation'] . '\', ' . '\'' . PMA_Util::sqlAddSlashes($data_row['transformation_options']) . '\')';
                $add_comma = true;
                $column_count++;
                break;
            }
        }
        if ($column_count == count($column_map)) {
            break;
        }
    }
    return $column_count > 0 ? $new_transformations_sql : '';
}
Exemplo n.º 18
0
/**
 * Send TRI or EVN editor via ajax or by echoing.
 *
 * @param string $type      TRI or EVN
 * @param string $mode      Editor mode 'add' or 'edit'
 * @param array  $item      Data necessary to create the editor
 * @param string $title     Title of the editor
 * @param string $db        Database
 * @param string $operation Operation 'change' or ''
 *
 * @return void
 */
function PMA_RTE_sendEditor($type, $mode, $item, $title, $db, $operation = null)
{
    if ($item !== false) {
        // Show form
        if ($type == 'TRI') {
            $editor = PMA_TRI_getEditorForm($mode, $item);
        } else {
            // EVN
            $editor = PMA_EVN_getEditorForm($mode, $operation, $item);
        }
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA_Response::getInstance();
            $response->addJSON('message', $editor);
            $response->addJSON('title', $title);
        } else {
            echo "\n\n<h2>{$title}</h2>\n\n{$editor}";
            unset($_POST);
        }
        exit;
    } else {
        $message = __('Error in processing request:') . ' ';
        $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db)));
        $message = PMA_message::error($message);
        if ($GLOBALS['is_ajax_request']) {
            $response = PMA_Response::getInstance();
            $response->isSuccess(false);
            $response->addJSON('message', $message);
            exit;
        } else {
            $message->display();
        }
    }
}
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA_Util::getImage('b_props.png', __('View'));
     $this->links = array('text' => 'sql.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s&amp;pos=0' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $_SESSION[' PMA_token ']);
     $this->classes = 'view';
 }
Exemplo n.º 20
0
 /**
  * Returns the singleton instance of geometric class of the given type.
  *
  * @param string $type type of the geometric object
  *
  * @return PMA_GIS_Geometry the singleton instance of geometric class
  *                          of the given type
  *
  * @access public
  * @static
  */
 public static function factory($type)
 {
     include_once './libraries/gis/GIS_Geometry.class.php';
     $type_lower = strtolower($type);
     $file = './libraries/gis/GIS_' . ucfirst($type_lower) . '.class.php';
     if (!PMA_isValid($type_lower, PMA_Util::getGISDatatypes()) || !file_exists($file)) {
         return false;
     }
     if (include_once $file) {
         switch (strtoupper($type)) {
             case 'MULTIPOLYGON':
                 return PMA_GIS_Multipolygon::singleton();
             case 'POLYGON':
                 return PMA_GIS_Polygon::singleton();
             case 'MULTIPOINT':
                 return PMA_GIS_Multipoint::singleton();
             case 'POINT':
                 return PMA_GIS_Point::singleton();
             case 'MULTILINESTRING':
                 return PMA_GIS_Multilinestring::singleton();
             case 'LINESTRING':
                 return PMA_GIS_Linestring::singleton();
             case 'GEOMETRYCOLLECTION':
                 return PMA_GIS_Geometrycollection::singleton();
             default:
                 return false;
         }
     } else {
         return false;
     }
 }
Exemplo n.º 21
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  *
  * @return Node_Event
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA_Util::getImage('b_events.png');
     $this->links = array('text' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;item_name=%1$s&amp;edit_item=1' . '&amp;token=' . $GLOBALS['token'], 'icon' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;item_name=%1$s&amp;export_item=1' . '&amp;token=' . $GLOBALS['token']);
     $this->classes = 'event';
 }
Exemplo n.º 22
0
 /**
  * Test for showPHPDocu
  *
  * @return void
  */
 function testShowPHPDocu()
 {
     $target = "docu";
     $lang = _pgettext('PHP documentation language', 'en');
     $expected = '<a href="./url.php?url=http%3A%2F%2Fphp.net%2Fmanual%2F' . $lang . '%2F' . $target . '" target="documentation">' . '<img src="themes/dot.gif" title="' . __('Documentation') . '" alt="' . __('Documentation') . '" class="icon ic_b_help" /></a>';
     $this->assertEquals($expected, PMA_Util::showPHPDocu($target));
 }
 /**
  * Does the actual work of each specific transformations plugin.
  *
  * @param string $buffer  text to be transformed
  * @param array  $options transformation options
  * @param string $meta    meta information
  *
  * @return string
  */
 public function applyTransformation($buffer, $options = array(), $meta = '')
 {
     // see PMA_highlightSQL()
     $result = PMA_Util::formatSql($buffer);
     // Need to clear error state not to break subsequent queries display.
     PMA_SQP_resetError();
     return $result;
 }
Exemplo n.º 24
0
 /**
  * Test for getDivForSliderEffect
  *
  * @return void
  */
 function testGetDivForSliderEffectTestDisabled()
 {
     global $cfg;
     $cfg['InitialSlidersState'] = 'disabled';
     $id = "test_id";
     $message = "test_message";
     $this->assertEquals(PMA_Util::getDivForSliderEffect($id, $message), '<div id="' . $id . '">');
 }
    /**
     * @dataProvider dataProvider
     * @return void
     */
    function testMaximumUploadSize($size, $unit, $res)
    {
        $this->assertEquals(
            "(" . __('Max: '). $res . $unit .")",
            PMA_Util::getFormattedMaximumUploadSize($size)
        );

    }
Exemplo n.º 26
0
 /**
  * returns array of partition names for a specific db/table
  *
  * @param string $db    database name
  * @param string $table table name
  *
  * @access  public
  * @return array   of partition names
  */
 public static function getPartitionNames($db, $table)
 {
     if (PMA_Partition::havePartitioning()) {
         return $GLOBALS['dbi']->fetchResult("SELECT `PARTITION_NAME` FROM `information_schema`.`PARTITIONS`" . " WHERE `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($db) . "' AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($table) . "'");
     } else {
         return array();
     }
 }
Exemplo n.º 27
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));
 }
Exemplo n.º 28
0
 /**
  * returns the pbxt engine specific handling for
  * PMA_ENGINE_DETAILS_TYPE_SIZE variables.
  *
  * @param string $formatted_size the size expression (for example 8MB)
  *
  * @return string the formatted value and its unit
  */
 public function resolveTypeSize($formatted_size)
 {
     if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) {
         $value = PMA_Util::extractValueFromFormattedSize($formatted_size);
     } else {
         $value = $formatted_size;
     }
     return PMA_Util::formatByteDown($value);
 }
Exemplo n.º 29
0
/**
 * returns collation of given db
 *
 * @param string $db name of db
 *
 * @return string  collation of $db
 */
function PMA_getDbCollation($db)
{
    if ($GLOBALS['dbi']->isSystemSchema($db)) {
        // We don't have to check the collation of the virtual
        // information_schema database: We know it!
        return 'utf8_general_ci';
    }
    $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 $GLOBALS['dbi']->fetchValue($sql);
}
Exemplo n.º 30
0
    function testGetCheckboxCheckedOnclick()
    {
        $name = "test_display_html_checkbox";
        $label = "text_label_for_checkbox";

        $this->assertEquals(
            PMA_Util::getCheckbox($name, $label, true, true),
            '<input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" class="autosubmit" /><label for="' . $name . '">' . $label . '</label>'
        );
    }