/**
 * Returns config file contents depending on GET type value:
 * o session - uses ConfigFile::getConfigFile()
 * o post - uses POST textconfig value
 *
 * @return string
 */
function get_config()
{
    $type = PMA_ifSetOr($_GET['type'], 'session');
    if ($type == 'session') {
        $config = ConfigFile::getInstance()->getConfigFile();
    } else {
        $config = PMA_ifSetOr($_POST['textconfig'], '');
        // make sure our eol is \n
        $config = str_replace("\r\n", "\n", $config);
        if ($_SESSION['eol'] == 'win') {
            $config = str_replace("\n", "\r\n", $config);
        }
    }
    return $config;
}
Beispiel #2
0
 /**
  * Saves query in history
  *
  * @return void
  */
 private function _setHistory()
 {
     if (!PMA_isValid($_REQUEST['no_history']) && empty($GLOBALS['error_message']) && !empty($GLOBALS['sql_query'])) {
         PMA_setHistory(PMA_ifSetOr($GLOBALS['db'], ''), PMA_ifSetOr($GLOBALS['table'], ''), $GLOBALS['cfg']['Server']['user'], $GLOBALS['sql_query']);
     }
 }
Beispiel #3
0
/**
 * Core libraries.
 */
require_once './libraries/config/FormDisplay.class.php';
require_once './setup/lib/index.lib.php';
require_once './setup/lib/ConfigGenerator.class.php';

$config_readable = false;
$config_writable = false;
$config_exists = false;
check_config_rw($config_readable, $config_writable, $config_exists);
?>
<h2><?php echo __('Configuration file') ?></h2>
<?php display_form_top('config.php'); ?>
<input type="hidden" name="eol" value="<?php echo htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix')) ?>" />
<?php display_fieldset_top('', '', null, array('class' => 'simple')); ?>
<tr>
    <td>
        <textarea cols="50" rows="20" name="textconfig" id="textconfig" spellcheck="false"><?php
            echo htmlspecialchars(ConfigGenerator::getConfigFile())
        ?></textarea>
    </td>
</tr>
<tr>
    <td class="lastrow" style="text-align: left">
        <input type="submit" name="submit_download" value="<?php echo __('Download') ?>" class="green" />
        <input type="submit" name="submit_save" value="<?php echo __('Save') ?>"<?php
if (!$config_writable) {
    echo ' disabled="disabled"';
} ?> />
 /**
  * Sends a JSON response to the browser
  *
  * @return void
  */
 private function _ajaxResponse()
 {
     if (!isset($this->_JSON['message'])) {
         $this->_JSON['message'] = $this->_getDisplay();
     } else {
         if ($this->_JSON['message'] instanceof PMA_Message) {
             $this->_JSON['message'] = $this->_JSON['message']->getDisplay();
         }
     }
     if ($this->_isSuccess) {
         $this->_JSON['success'] = true;
     } else {
         $this->_JSON['success'] = false;
         $this->_JSON['error'] = $this->_JSON['message'];
         unset($this->_JSON['message']);
     }
     if ($this->_isSuccess) {
         // Note: the old judge sentence is:
         // $this->_isAjaxPage && $this->_isSuccess
         // Removal the first, because console need log all queries, if caused any
         // bug, contact Edward Cheng
         $this->addJSON('_title', $this->getHeader()->getTitleTag());
         if (isset($GLOBALS['dbi'])) {
             $menuHash = $this->getHeader()->getMenu()->getHash();
             $this->addJSON('_menuHash', $menuHash);
             $hashes = array();
             if (isset($_REQUEST['menuHashes'])) {
                 $hashes = explode('-', $_REQUEST['menuHashes']);
             }
             if (!in_array($menuHash, $hashes)) {
                 $this->addJSON('_menu', $this->getHeader()->getMenu()->getDisplay());
             }
         }
         $this->addJSON('_scripts', $this->getHeader()->getScripts()->getFiles());
         $this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
         $this->addJSON('_displayMessage', $this->getHeader()->getMessage());
         $debug = $this->_footer->getDebugMessage();
         if (empty($_REQUEST['no_debug']) && mb_strlen($debug)) {
             $this->addJSON('_debug', $debug);
         }
         $errors = $this->_footer->getErrorMessages();
         if (mb_strlen($errors)) {
             $this->addJSON('_errors', $errors);
         }
         $promptPhpErrors = $GLOBALS['error_handler']->hasErrorsForPrompt();
         $this->addJSON('_promptPhpErrors', $promptPhpErrors);
         if (empty($GLOBALS['error_message'])) {
             // set current db, table and sql query in the querywindow
             // (this is for the bottom console)
             $query = '';
             $maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
             if (isset($GLOBALS['sql_query']) && mb_strlen($GLOBALS['sql_query']) < $maxChars) {
                 $query = $GLOBALS['sql_query'];
             }
             $this->addJSON('_reloadQuerywindow', array('db' => PMA_ifSetOr($GLOBALS['db'], ''), 'table' => PMA_ifSetOr($GLOBALS['table'], ''), 'sql_query' => $query));
             if (!empty($GLOBALS['focus_querywindow'])) {
                 $this->addJSON('_focusQuerywindow', $query);
             }
             if (!empty($GLOBALS['reload'])) {
                 $this->addJSON('_reloadNavigation', 1);
             }
             $this->addJSON('_params', $this->getHeader()->getJsParams());
         }
     }
     // Set the Content-Type header to JSON so that jQuery parses the
     // response correctly.
     if (!defined('TESTSUITE')) {
         header('Cache-Control: no-cache');
         header('Content-Type: application/json');
     }
     echo json_encode($this->_JSON);
 }
Beispiel #5
0
    $GLOBALS['table'] = $recent_table['table'];
    $GLOBALS['url_params']['table'] = $GLOBALS['table'];
}
/**
 * SQL query to be executed
 * @global string $GLOBALS['sql_query']
 */
$GLOBALS['sql_query'] = '';
if (PMA_isValid($_REQUEST['sql_query'])) {
    $GLOBALS['sql_query'] = $_REQUEST['sql_query'];
}
/**
 * avoid problems in phpmyadmin.css.php in some cases
 * @global string $js_frame
 */
$_REQUEST['js_frame'] = PMA_ifSetOr($_REQUEST['js_frame'], '');
//$_REQUEST['set_theme'] // checked later in this file LABEL_theme_setup
//$_REQUEST['server']; // checked later in this file
//$_REQUEST['lang'];   // checked by LABEL_loading_language_file
/**
 * holds name of JavaScript files to be included in HTML header
 * @global array $js_include
 */
$GLOBALS['js_include'] = array();
$GLOBALS['js_include'][] = 'jquery/jquery-1.6.2+fix-9521.js';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.16.custom.js';
$GLOBALS['js_include'][] = 'update-location.js';
/**
 * holds an array of javascript code snippets to be included in the HTML header
 * Can be used with PMA_AddJSCode() to pass on js variables to the browser.
 * @global array $js_script
        echo '<form name="usersForm" id="addUsersForm_' . $random_n . '" action="server_privileges.php" method="post">' . "\n";
        $_params = array(
            'username' => $username,
            'hostname' => $hostname,
        );
        if (isset($dbname)) {
            $_params['dbname'] = $dbname;
            if (isset($tablename)) {
                $_params['tablename'] = $tablename;
            }
        }
        echo PMA_generate_common_hidden_inputs($_params);

        PMA_displayPrivTable(
            PMA_ifSetOr($dbname, '*', 'length'),
            PMA_ifSetOr($tablename, '*', 'length')
        );

        echo '</form>' . "\n";

        if (! isset($tablename) && empty($dbname_is_wildcard)) {

            // no table name was given, display all table specific rights
            // but only if $dbname contains no wildcards

            // table header
            echo '<form action="server_privileges.php" id="db_or_table_specific_priv" method="post">' . "\n"
               . PMA_generate_common_hidden_inputs('', '')
               . '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n"
               . '<input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"
               . '<fieldset>' . "\n"
/**
 * Get HTML snippet for display user properties
 *
 * @param boolean $dbname_is_wildcard whether database name is wildcard or not
 * @param string  $url_dbname         url database name that urlencode() string
 * @param string  $username           username
 * @param string  $hostname           host name
 * @param string  $dbname             database name
 * @param string  $tablename          table name
 *
 * @return string $html_output
 */
function PMA_getHtmlForUserProperties($dbname_is_wildcard, $url_dbname, $username, $hostname, $dbname, $tablename)
{
    $html_output = '<div id="edit_user_dialog">';
    $html_output .= PMA_getHtmlHeaderForUserProperties($dbname_is_wildcard, $url_dbname, $dbname, $username, $hostname, $tablename);
    $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';";
    $user_does_not_exists = (bool) (!$GLOBALS['dbi']->fetchValue($sql));
    if ($user_does_not_exists) {
        $html_output .= PMA_Message::error(__('The selected user was not found in the privilege table.'))->getDisplay();
        $html_output .= PMA_getHtmlForLoginInformationFields();
        //exit;
    }
    $_params = array('username' => $username, 'hostname' => $hostname);
    if (!is_array($dbname) && mb_strlen($dbname)) {
        $_params['dbname'] = $dbname;
        if (mb_strlen($tablename)) {
            $_params['tablename'] = $tablename;
        }
    } else {
        $_params['dbname'] = $dbname;
    }
    $html_output .= '<form class="submenu-item" name="usersForm" ' . 'id="addUsersForm" action="server_privileges.php" method="post">' . "\n";
    $html_output .= PMA_URL_getHiddenInputs($_params);
    $html_output .= PMA_getHtmlToDisplayPrivilegesTable(PMA_ifSetOr($dbname, is_array($dbname) ? $dbname[0] : '*', 'length'), PMA_ifSetOr($tablename, '*', 'length'));
    $html_output .= '</form>' . "\n";
    if (!is_array($dbname) && !mb_strlen($tablename) && empty($dbname_is_wildcard)) {
        // no table name was given, display all table specific rights
        // but only if $dbname contains no wildcards
        $html_output .= '<form class="submenu-item" action="server_privileges.php" ' . 'id="db_or_table_specific_priv" method="post">' . "\n";
        // unescape wildcards in dbname at table level
        $unescaped_db = PMA_Util::unescapeMysqlWildcards($dbname);
        list($html_rightsTable, $found_rows) = PMA_getHtmlForAllTableSpecificRights($username, $hostname, $unescaped_db);
        $html_output .= $html_rightsTable;
        if (!mb_strlen($dbname)) {
            // no database name was given, display select db
            $html_output .= PMA_getHtmlForSelectDbInEditPrivs($found_rows);
        } else {
            $html_output .= PMA_displayTablesInEditPrivs($dbname, $found_rows);
        }
        $html_output .= '</fieldset>' . "\n";
        $html_output .= '<fieldset class="tblFooters">' . "\n" . '    <input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . "\n" . '</form>' . "\n";
    }
    // Provide a line with links to the relevant database and table
    if (!is_array($dbname) && mb_strlen($dbname) && empty($dbname_is_wildcard)) {
        $html_output .= PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename);
    }
    if (!is_array($dbname) && !mb_strlen($dbname) && !$user_does_not_exists) {
        //change login information
        $html_output .= PMA_getHtmlForChangePassword($username, $hostname);
        $html_output .= PMA_getChangeLoginInformationHtmlForm($username, $hostname);
    }
    $html_output .= '</div>';
    return $html_output;
}
if (isset($_REQUEST['submit_sql'])
 && ! preg_match('@^SELECT@i', $sql_query)) {
    PMA_Message::warning('strHaveToShow')->display();
}


/**
 * Initialize some variables
 */
$col_cnt = PMA_ifSetOr($_REQUEST['col_cnt'], 3, 'numeric');
$add_col = PMA_ifSetOr($_REQUEST['add_col'], 0, 'numeric');
$add_row = PMA_ifSetOr($_REQUEST['add_row'], 0, 'numeric');

$rows    = PMA_ifSetOr($_REQUEST['rows'],    0, 'numeric');
$ins_col = PMA_ifSetOr($_REQUEST['ins_col'], null, 'array');
$del_col = PMA_ifSetOr($_REQUEST['del_col'], null, 'array');

$prev_criteria = isset($_REQUEST['prev_criteria'])
    ? $_REQUEST['prev_criteria']
    : array();
$criteria = isset($_REQUEST['criteria'])
    ? $_REQUEST['criteria']
    : array_fill(0, $col_cnt, '');

$ins_row = isset($_REQUEST['ins_row'])
    ? $_REQUEST['ins_row']
    : array_fill(0, $col_cnt, '');
$del_row = isset($_REQUEST['del_row'])
    ? $_REQUEST['del_row']
    : array_fill(0, $col_cnt, '');
$and_or_row = isset($_REQUEST['and_or_row'])
 unset($sql);
 if ($user_does_not_exists) {
     PMA_Message::error(__('The selected user was not found in the privilege table.'))->display();
     PMA_displayLoginInformationFields();
     //require './libraries/footer.inc.php';
 }
 echo '<form name="usersForm" id="addUsersForm_' . $random_n . '" action="server_privileges.php" method="post">' . "\n";
 $_params = array('username' => $username, 'hostname' => $hostname);
 if (isset($dbname)) {
     $_params['dbname'] = $dbname;
     if (isset($tablename)) {
         $_params['tablename'] = $tablename;
     }
 }
 echo PMA_generate_common_hidden_inputs($_params);
 PMA_displayPrivTable(PMA_ifSetOr($dbname, '*', 'length'), PMA_ifSetOr($tablename, '*', 'length'));
 echo '</form>' . "\n";
 if (!isset($tablename) && empty($dbname_is_wildcard)) {
     // no table name was given, display all table specific rights
     // but only if $dbname contains no wildcards
     // table header
     echo '<form action="server_privileges.php" id="db_or_table_specific_priv" method="post">' . "\n" . PMA_generate_common_hidden_inputs('', '') . '<input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n" . '<fieldset>' . "\n" . '<legend>' . (!isset($dbname) ? __('Database-specific privileges') : __('Table-specific privileges')) . '</legend>' . "\n" . '<table class="data">' . "\n" . '<thead>' . "\n" . '<tr><th>' . (!isset($dbname) ? __('Database') : __('Table')) . '</th>' . "\n" . '    <th>' . __('Privileges') . '</th>' . "\n" . '    <th>' . __('Grant') . '</th>' . "\n" . '    <th>' . (!isset($dbname) ? __('Table-specific privileges') : __('Column-specific privileges')) . '</th>' . "\n" . '    <th colspan="2">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n" . '<tbody>' . "\n";
     $user_host_condition = ' WHERE `User`' . ' = \'' . PMA_sqlAddSlashes($username) . "'" . ' AND `Host`' . ' = \'' . PMA_sqlAddSlashes($hostname) . "'";
     // table body
     // get data
     // we also want privielgs for this user not in table `db` but in other table
     $tables = PMA_DBI_fetch_result('SHOW TABLES FROM `mysql`;');
     if (!isset($dbname)) {
         // no db name given, so we want all privs for the given user
         $tables_to_search_for_users = array('tables_priv', 'columns_priv');
         $db_rights_sqls = array();
Beispiel #10
0
        if (window.parent && window.parent.frame_navigation) {
            window.parent.frame_navigation.location.reload();
        }
        <?php 
            }
        }
        ?>
// set current db, table and sql query in the querywindow
if (window.parent.reload_querywindow) {
    window.parent.reload_querywindow(
        '<?php 
        echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], ''));
        ?>
',
        '<?php 
        echo PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], ''));
        ?>
',
        '<?php 
        echo strlen($GLOBALS['sql_query']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] ? PMA_escapeJsString($GLOBALS['sql_query']) : '';
        ?>
');
}
    <?php 
    }
    if (!empty($GLOBALS['focus_querywindow'])) {
        ?>
// set focus to the querywindow
if (parent.querywindow && !parent.querywindow.closed && parent.querywindow.location) {
    self.focus();
}
Beispiel #11
0
if (!defined('PHPMYADMIN')) {
    exit;
}
/**
 * Core libraries.
 */
require_once './libraries/config/FormDisplay.class.php';
require_once './setup/lib/index.lib.php';
require_once './setup/lib/ConfigGenerator.class.php';
$config_readable = false;
$config_writable = false;
$config_exists = false;
PMA_checkConfigRw($config_readable, $config_writable, $config_exists);
echo '<h2>' . __('Configuration file') . '</h2>';
PMA_displayFormTop('config.php');
echo '<input type="hidden" name="eol" value="' . htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix')) . '" />';
PMA_displayFieldsetTop('config.inc.php', '', null, array('class' => 'simple'));
echo '<tr>';
echo '<td>';
echo '<textarea cols="50" rows="20" name="textconfig" ' . 'id="textconfig" spellcheck="false">';
echo htmlspecialchars(ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']));
echo '</textarea>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="lastrow" style="text-align: left">';
echo '<input type="submit" name="submit_download" value="' . __('Download') . '" class="green" />';
echo '<input type="submit" name="submit_save" value="' . __('Save') . '"';
if (!$config_writable) {
    echo ' disabled="disabled"';
}
/**
 * Get HTML snippet for display user properties
 *
 * @param boolean $dbname_is_wildcard whether database name is wildcard or not
 * @param string  $url_dbname         url database name that urlencode() string
 * @param string  $username           username
 * @param string  $hostname           host name
 * @param string  $dbname             database name
 * @param string  $tablename          table name
 *
 * @return string $html_output
 */
function PMA_getHtmlForUserProperties($dbname_is_wildcard, $url_dbname, $username, $hostname, $dbname, $tablename)
{
    $html_output = '<div id="edit_user_dialog">';
    $html_output .= PMA_getHtmlHeaderForUserProperties($dbname_is_wildcard, $url_dbname, $dbname, $username, $hostname, $tablename, 'table');
    $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'" . " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
    $user_does_not_exists = (bool) (!$GLOBALS['dbi']->fetchValue($sql));
    if ($user_does_not_exists) {
        $html_output .= Message::error(__('The selected user was not found in the privilege table.'))->getDisplay();
        $html_output .= PMA_getHtmlForLoginInformationFields();
    }
    $_params = array('username' => $username, 'hostname' => $hostname);
    if (!is_array($dbname) && strlen($dbname) > 0) {
        $_params['dbname'] = $dbname;
        if (strlen($tablename) > 0) {
            $_params['tablename'] = $tablename;
        }
    } else {
        $_params['dbname'] = $dbname;
    }
    $html_output .= '<form class="submenu-item" name="usersForm" ' . 'id="addUsersForm" action="server_privileges.php" method="post">' . "\n";
    $html_output .= URL::getHiddenInputs($_params);
    $html_output .= PMA_getHtmlToDisplayPrivilegesTable(PMA_ifSetOr($dbname, is_array($dbname) ? $dbname[0] : '*', 'length'), PMA_ifSetOr($tablename, '*', 'length'));
    $html_output .= '</form>' . "\n";
    if (!is_array($dbname) && strlen($tablename) === 0 && empty($dbname_is_wildcard)) {
        // no table name was given, display all table specific rights
        // but only if $dbname contains no wildcards
        if (strlen($dbname) === 0) {
            $html_output .= PMA_getHtmlForAllTableSpecificRights($username, $hostname, 'database');
        } else {
            // unescape wildcards in dbname at table level
            $unescaped_db = Util::unescapeMysqlWildcards($dbname);
            $html_output .= PMA_getHtmlForAllTableSpecificRights($username, $hostname, 'table', $unescaped_db);
            $html_output .= PMA_getHtmlForAllTableSpecificRights($username, $hostname, 'routine', $unescaped_db);
        }
    }
    // Provide a line with links to the relevant database and table
    if (!is_array($dbname) && strlen($dbname) > 0 && empty($dbname_is_wildcard)) {
        $html_output .= PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename);
    }
    if (!is_array($dbname) && strlen($dbname) === 0 && !$user_does_not_exists) {
        //change login information
        $html_output .= PMA_getHtmlForChangePassword('edit_other', $username, $hostname);
        $html_output .= PMA_getChangeLoginInformationHtmlForm($username, $hostname);
    }
    $html_output .= '</div>';
    return $html_output;
}
Beispiel #13
0
 /**
  * Sets search parameters
  *
  */
 private function _setSearchParams()
 {
     // sets column count
     $criteriaColumnCount = PMA_ifSetOr($_REQUEST['criteriaColumnCount'], 3, 'numeric');
     $criteriaColumnAdd = PMA_ifSetOr($_REQUEST['criteriaColumnAdd'], 0, 'numeric');
     $this->_criteria_column_count = max($criteriaColumnCount + $criteriaColumnAdd, 0);
     // sets row count
     $rows = PMA_ifSetOr($_REQUEST['rows'], 0, 'numeric');
     $criteriaRowAdd = PMA_ifSetOr($_REQUEST['criteriaRowAdd'], 0, 'numeric');
     $this->_criteria_row_count = max($rows + $criteriaRowAdd, 0);
     $this->_criteriaColumnInsert = PMA_ifSetOr($_REQUEST['criteriaColumnInsert'], null, 'array');
     $this->_criteriaColumnDelete = PMA_ifSetOr($_REQUEST['criteriaColumnDelete'], null, 'array');
     $this->_prev_criteria = isset($_REQUEST['prev_criteria']) ? $_REQUEST['prev_criteria'] : array();
     $this->_criteria = isset($_REQUEST['criteria']) ? $_REQUEST['criteria'] : array_fill(0, $criteriaColumnCount, '');
     $this->_criteriaRowInsert = isset($_REQUEST['criteriaRowInsert']) ? $_REQUEST['criteriaRowInsert'] : array_fill(0, $criteriaColumnCount, '');
     $this->_criteriaRowDelete = isset($_REQUEST['criteriaRowDelete']) ? $_REQUEST['criteriaRowDelete'] : array_fill(0, $criteriaColumnCount, '');
     $this->_criteriaAndOrRow = isset($_REQUEST['criteriaAndOrRow']) ? $_REQUEST['criteriaAndOrRow'] : array_fill(0, $criteriaColumnCount, '');
     $this->_criteriaAndOrColumn = isset($_REQUEST['criteriaAndOrColumn']) ? $_REQUEST['criteriaAndOrColumn'] : array_fill(0, $criteriaColumnCount, '');
     // sets minimum width
     $this->_form_column_width = 12;
     $this->_curField = array();
     $this->_curSort = array();
     $this->_curShow = array();
     $this->_curCriteria = array();
     $this->_curAndOrRow = array();
     $this->_curAndOrCol = array();
 }
Beispiel #14
0
 public function testVarNotSetNoDefault()
 {
     // $in is not set!
     $out = PMA_ifSetOr($in);
     $this->assertEquals($out, null);
 }
Beispiel #15
0
 /**
  * Initialize _criteria_column_count
  *
  * @return int Previous number of columns
  */
 private function _initializeCriteriasCount()
 {
     // sets column count
     $criteriaColumnCount = PMA_ifSetOr($_REQUEST['criteriaColumnCount'], 3, 'numeric');
     $criteriaColumnAdd = PMA_ifSetOr($_REQUEST['criteriaColumnAdd'], 0, 'numeric');
     $this->_criteria_column_count = max($criteriaColumnCount + $criteriaColumnAdd, 0);
     // sets row count
     $rows = PMA_ifSetOr($_REQUEST['rows'], 0, 'numeric');
     $criteriaRowAdd = PMA_ifSetOr($_REQUEST['criteriaRowAdd'], 0, 'numeric');
     $this->_criteria_row_count = max($rows + $criteriaRowAdd, 0);
     return $criteriaColumnCount;
 }
Beispiel #16
0
$cfgRelation = PMA_getRelationsParam();
/**
 * load bookmark support
 */
require_once 'libraries/bookmark.lib.php';
$querydisplay_tabs = array('sql', 'files', 'history', 'full');
if (isset($_REQUEST['querydisplay_tab']) && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)) {
    $querydisplay_tab = $_REQUEST['querydisplay_tab'];
} else {
    $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
}
/**
 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
 * so this page is loaded in main frame
 */
$no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
if ($no_js) {
    $querydisplay_tab = 'full';
    $tabs = false;
} else {
    $tabs = array();
    $tabs['sql']['icon'] = 'b_sql.png';
    $tabs['sql']['text'] = __('SQL');
    $tabs['sql']['fragment'] = '#';
    $tabs['sql']['attr'] = 'onclick="PMA_querywindowCommit(\'sql\');return false;"';
    $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
    $tabs['import']['icon'] = 'b_import.png';
    $tabs['import']['text'] = __('Import files');
    $tabs['import']['fragment'] = '#';
    $tabs['import']['attr'] = 'onclick="PMA_querywindowCommit(\'files\');return false;"';
    $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
Beispiel #17
0
        $opts['values'][(string)$id] = $cf->getServerName($id) . " [$id]";
    }
} else {
    $opts['values']['1'] = __('- none -');
    $opts['values_escaped'] = true;
}
display_input('ServerDefault', __('Default server'), '', 'select',
    $cf->getValue('ServerDefault'), true, $opts);

// Display EOL list
$opts = array(
    'values' => array(
        'unix' => 'UNIX / Linux (\n)',
        'win' => 'Windows (\r\n)'),
    'values_escaped' => true);
$eol = PMA_ifSetOr($_SESSION['eol'], (PMA_IS_WINDOWS ? 'win' : 'unix'));
display_input('eol', __('End of line'), '', 'select',
    $eol, true, $opts);
?>
<tr>
    <td colspan="2" class="lastrow" style="text-align: left">
        <input type="submit" name="submit_display" value="<?php echo __('Display') ?>" />
        <input type="submit" name="submit_download" value="<?php echo __('Download') ?>" />
        &nbsp; &nbsp;
        <input type="submit" name="submit_save" value="<?php echo __('Save') ?>"<?php if (!$config_writable) echo ' disabled="disabled"' ?> />
        <input type="submit" name="submit_load" value="<?php echo __('Load') ?>"<?php if (!$config_exists) echo ' disabled="disabled"' ?> />
        <input type="submit" name="submit_delete" value="<?php echo __('Delete') ?>"<?php if (!$config_exists || !$config_writable) echo ' disabled="disabled"' ?> />
        &nbsp; &nbsp;
        <input type="submit" name="submit_clear" value="<?php echo __('Clear') ?>" class="red" />
    </td>
</tr>
 /**
  * Sends a JSON response to the browser
  *
  * @return void
  */
 private function _ajaxResponse()
 {
     /* Avoid wrapping in case we're disabled */
     if ($this->_isDisabled) {
         echo $this->_getDisplay();
         return;
     }
     if (!isset($this->_JSON['message'])) {
         $this->_JSON['message'] = $this->_getDisplay();
     } else {
         if ($this->_JSON['message'] instanceof Message) {
             $this->_JSON['message'] = $this->_JSON['message']->getDisplay();
         }
     }
     if ($this->_isSuccess) {
         $this->_JSON['success'] = true;
     } else {
         $this->_JSON['success'] = false;
         $this->_JSON['error'] = $this->_JSON['message'];
         unset($this->_JSON['message']);
     }
     if ($this->_isSuccess) {
         // Note: the old judge sentence is:
         // $this->_isAjaxPage && $this->_isSuccess
         // Removal the first, because console need log all queries
         $this->addJSON('_title', $this->getHeader()->getTitleTag());
         if (isset($GLOBALS['dbi'])) {
             $menuHash = $this->getHeader()->getMenu()->getHash();
             $this->addJSON('_menuHash', $menuHash);
             $hashes = array();
             if (isset($_REQUEST['menuHashes'])) {
                 $hashes = explode('-', $_REQUEST['menuHashes']);
             }
             if (!in_array($menuHash, $hashes)) {
                 $this->addJSON('_menu', $this->getHeader()->getMenu()->getDisplay());
             }
         }
         $this->addJSON('_scripts', $this->getHeader()->getScripts()->getFiles());
         $this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
         $this->addJSON('_displayMessage', $this->getHeader()->getMessage());
         $debug = $this->_footer->getDebugMessage();
         if (empty($_REQUEST['no_debug']) && mb_strlen($debug)) {
             $this->addJSON('_debug', $debug);
         }
         $errors = $this->_footer->getErrorMessages();
         if (mb_strlen($errors)) {
             $this->addJSON('_errors', $errors);
         }
         $promptPhpErrors = $GLOBALS['error_handler']->hasErrorsForPrompt();
         $this->addJSON('_promptPhpErrors', $promptPhpErrors);
         if (empty($GLOBALS['error_message'])) {
             // set current db, table and sql query in the querywindow
             // (this is for the bottom console)
             $query = '';
             $maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
             if (isset($GLOBALS['sql_query']) && mb_strlen($GLOBALS['sql_query']) < $maxChars) {
                 $query = $GLOBALS['sql_query'];
             }
             $this->addJSON('_reloadQuerywindow', array('db' => PMA_ifSetOr($GLOBALS['db'], ''), 'table' => PMA_ifSetOr($GLOBALS['table'], ''), 'sql_query' => $query));
             if (!empty($GLOBALS['focus_querywindow'])) {
                 $this->addJSON('_focusQuerywindow', $query);
             }
             if (!empty($GLOBALS['reload'])) {
                 $this->addJSON('_reloadNavigation', 1);
             }
             $this->addJSON('_params', $this->getHeader()->getJsParams());
         }
     }
     // Set the Content-Type header to JSON so that jQuery parses the
     // response correctly.
     PMA_headerJSON();
     $result = json_encode($this->_JSON);
     if ($result === false) {
         switch (json_last_error()) {
             case JSON_ERROR_NONE:
                 $error = 'No errors';
                 break;
             case JSON_ERROR_DEPTH:
                 $error = 'Maximum stack depth exceeded';
                 break;
             case JSON_ERROR_STATE_MISMATCH:
                 $error = 'Underflow or the modes mismatch';
                 break;
             case JSON_ERROR_CTRL_CHAR:
                 $error = 'Unexpected control character found';
                 break;
             case JSON_ERROR_SYNTAX:
                 $error = 'Syntax error, malformed JSON';
                 break;
             case JSON_ERROR_UTF8:
                 $error = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                 break;
             case JSON_ERROR_RECURSION:
                 $error = 'One or more recursive references in the value to be encoded';
                 break;
             case JSON_ERROR_INF_OR_NAN:
                 $error = 'One or more NAN or INF values in the value to be encoded';
                 break;
             case JSON_ERROR_UNSUPPORTED_TYPE:
                 $error = 'A value of a type that cannot be encoded was given';
             default:
                 $error = 'Unknown error';
                 break;
         }
         echo json_encode(array('success' => false, 'error' => 'JSON encoding failed: ' . $error));
     } else {
         echo $result;
     }
 }
Beispiel #19
0
    //
    file_put_contents($config_file_path, ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']));
    header('HTTP/1.1 303 See Other');
    header('Location: index.php' . PMA_URL_getCommon() . '&action_done=config_saved');
    exit;
} elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
    //
    // Load config file from the server
    //
    $cfg = array();
    include_once $config_file_path;
    $GLOBALS['ConfigFile']->setConfigData($cfg);
    header('HTTP/1.1 303 See Other');
    header('Location: index.php');
    exit;
} elseif (PMA_ifSetOr($_POST['submit_delete'], '')) {
    //
    // Delete config file on the server
    //
    @unlink($config_file_path);
    header('HTTP/1.1 303 See Other');
    header('Location: index.php');
    exit;
} else {
    //
    // Show generated config file in a <textarea>
    //
    header('HTTP/1.1 303 See Other');
    header('Location: index.php' . PMA_URL_getCommon() . '&page=config');
    exit;
}
/**
 * Get HTML snippet for display user properties
 *
 * @param boolean $dbname_is_wildcard whether database name is wildcard or not
 * @param type    $url_dbname         url database name that urlencode() string
 * @param string  $username           username
 * @param string  $hostname           host name
 * @param string  $link_edit          standard link to edit privileges
 * @param string  $link_revoke        standard link to revoke
 * @param string  $dbname             database name
 * @param string  $tablename          table name
 *
 * @return string $html_output
 */
function PMA_getHtmlForDisplayUserProperties($dbname_is_wildcard, $url_dbname, $username, $hostname, $link_edit, $link_revoke, $dbname, $tablename)
{
    $html_output = PMA_getHtmlHeaderForDisplayUserProperties($dbname_is_wildcard, $url_dbname, $dbname, $username, $hostname, $tablename);
    $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" . " AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';";
    $user_does_not_exists = (bool) (!PMA_DBI_fetch_value($sql));
    if ($user_does_not_exists) {
        $html_output .= PMA_Message::error(__('The selected user was not found in the privilege table.'))->getDisplay();
        $html_output .= PMA_getHtmlForDisplayLoginInformationFields();
        //exit;
    }
    $class = ' class="ajax"';
    $html_output .= '<form' . $class . ' name="usersForm" id="addUsersForm"' . ' action="server_privileges.php" method="post">' . "\n";
    $_params = array('username' => $username, 'hostname' => $hostname);
    if (strlen($dbname)) {
        $_params['dbname'] = $dbname;
        if (strlen($tablename)) {
            $_params['tablename'] = $tablename;
        }
    }
    $html_output .= PMA_generate_common_hidden_inputs($_params);
    $html_output .= PMA_getHtmlToDisplayPrivilegesTable(PMA_ifSetOr($dbname, '*', 'length'), PMA_ifSetOr($tablename, '*', 'length'));
    $html_output .= '</form>' . "\n";
    if (!strlen($tablename) && empty($dbname_is_wildcard)) {
        // no table name was given, display all table specific rights
        // but only if $dbname contains no wildcards
        $html_output .= '<form action="server_privileges.php" ' . 'id="db_or_table_specific_priv" method="post">' . "\n";
        list($html_rightsTable, $found_rows) = PMA_getTableForDisplayAllTableSpecificRights($username, $hostname, $link_edit, $link_revoke, $dbname);
        $html_output .= $html_rightsTable;
        if (!strlen($dbname)) {
            // no database name was given, display select db
            $html_output .= PMA_getHtmlForDisplaySelectDbInEditPrivs($found_rows);
        } else {
            $html_output .= PMA_displayTablesInEditPrivs($dbname, $found_rows);
        }
        $html_output .= '</fieldset>' . "\n";
        $html_output .= '<fieldset class="tblFooters">' . "\n" . '    <input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . "\n" . '</form>' . "\n";
    }
    // Provide a line with links to the relevant database and table
    if (strlen($dbname) && empty($dbname_is_wildcard)) {
        $html_output .= PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename);
    }
    if (!strlen($dbname) && !$user_does_not_exists) {
        //change login information
        $html_output .= PMA_getHtmlForChangePassword($username, $hostname);
        $html_output .= PMA_getChangeLoginInformationHtmlForm($username, $hostname);
    }
    return $html_output;
}
Beispiel #21
0
require_once './setup/lib/index.lib.php';
require_once './setup/lib/ConfigGenerator.class.php';
$config_readable = false;
$config_writable = false;
$config_exists = false;
check_config_rw($config_readable, $config_writable, $config_exists);
?>
<h2><?php 
echo __('Configuration file');
?>
</h2>
<?php 
display_form_top('config.php');
?>
<input type="hidden" name="eol" value="<?php 
echo htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix'));
?>
" />
<?php 
display_fieldset_top('', '', null, array('class' => 'simple'));
?>
<tr>
    <td>
        <textarea cols="50" rows="20" name="textconfig" id="textconfig" spellcheck="false"><?php 
echo htmlspecialchars(ConfigGenerator::getConfigFile());
?>
</textarea>
    </td>
</tr>
<tr>
    <td class="lastrow" style="text-align: left">
Beispiel #22
0
 /**
  * Sends a JSON response to the browser
  *
  * @return void
  */
 private function _ajaxResponse()
 {
     if (!isset($this->_JSON['message'])) {
         $this->_JSON['message'] = $this->_getDisplay();
     } else {
         if ($this->_JSON['message'] instanceof PMA_Message) {
             $this->_JSON['message'] = $this->_JSON['message']->getDisplay();
         }
     }
     if ($this->_isSuccess) {
         $this->_JSON['success'] = true;
     } else {
         $this->_JSON['success'] = false;
         $this->_JSON['error'] = $this->_JSON['message'];
         unset($this->_JSON['message']);
     }
     if ($this->_isAjaxPage && $this->_isSuccess) {
         $this->addJSON('_title', $this->getHeader()->getTitleTag());
         $menuHash = $this->getHeader()->getMenu()->getHash();
         $this->addJSON('_menuHash', $menuHash);
         $hashes = array();
         if (isset($_REQUEST['menuHashes'])) {
             $hashes = explode('-', $_REQUEST['menuHashes']);
         }
         if (!in_array($menuHash, $hashes)) {
             $this->addJSON('_menu', $this->getHeader()->getMenu()->getDisplay());
         }
         $this->addJSON('_scripts', $this->getHeader()->getScripts()->getFiles());
         $this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
         $this->addJSON('_displayMessage', $this->getHeader()->getMessage());
         $errors = $this->_footer->getErrorMessages();
         if (strlen($errors)) {
             $this->addJSON('_errors', $errors);
         }
         if (empty($GLOBALS['error_message'])) {
             // set current db, table and sql query in the querywindow
             $query = '';
             $maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
             if (isset($GLOBALS['sql_query']) && strlen($GLOBALS['sql_query']) < $maxChars) {
                 $query = PMA_escapeJsString($GLOBALS['sql_query']);
             }
             $this->addJSON('_reloadQuerywindow', array('db' => PMA_ifSetOr($GLOBALS['db'], ''), 'table' => PMA_ifSetOr($GLOBALS['table'], ''), 'sql_query' => $query));
             if (!empty($GLOBALS['focus_querywindow'])) {
                 $this->addJSON('_focusQuerywindow', $query);
             }
             if (!empty($GLOBALS['reload'])) {
                 $this->addJSON('_reloadNavigation', 1);
             }
             $this->addJSON('_params', $this->getHeader()->getJsParams());
         }
     }
     // Set the Content-Type header to JSON so that jQuery parses the
     // response correctly.
     if (!defined('TESTSUITE')) {
         header('Cache-Control: no-cache');
         header('Content-Type: application/json');
     }
     echo json_encode($this->_JSON);
 }