示例#1
0
/**
 * Executes a query as controluser if possible, otherwise as normal user
 *
 * @param   string   the query to execute
 * @param   boolean  whether to display SQL error messages or not
 *
 * @return  integer  the result id
 *
 * @global  string   the URL of the page to show in case of error
 * @global  string   the name of db to come back to
 * @global  integer  the ressource id of DB connect as controluser
 * @global  array    configuration infos about the relations stuff
 *
 * @access  public
 *
 * @author  Mike Beck <mikebeck@users.sourceforge.net>
 */
function PMA_query_as_cu($sql, $show_error = TRUE)
{
    global $err_url_0, $db, $dbh, $cfgRelation;
    if (isset($dbh)) {
        PMA_mysql_select_db($cfgRelation['db'], $dbh);
        $result = @PMA_mysql_query($sql, $dbh);
        if (!$result && $show_error == TRUE) {
            PMA_mysqlDie(mysql_error($dbh), $sql, '', $err_url_0);
        }
        PMA_mysql_select_db($db, $dbh);
    } else {
        PMA_mysql_select_db($cfgRelation['db']);
        $result = @PMA_mysql_query($sql);
        if ($result && $show_error == TRUE) {
            PMA_mysqlDie('', $sql, '', $err_url_0);
        }
        PMA_mysql_select_db($db);
    }
    // end if... else...
    if ($result) {
        return $result;
    } else {
        return FALSE;
    }
}
示例#2
0
/**
 * Insert data from one table to another one
 *
 * @param   string  the original insert statement
 *
 * @global  string  the database name
 * @global  string  the original table name
 * @global  string  the target database and table names
 * @global  string  the sql query used to copy the data
 */
function PMA_myHandler($sql_insert = '')
{
    global $db, $table, $target;
    global $sql_insert_data;
    $sql_insert = preg_replace('~INSERT INTO (`?)' . $table . '(`?)~i', 'INSERT INTO ' . $target, $sql_insert);
    $result = PMA_mysql_query($sql_insert) or PMA_mysqlDie('', $sql_insert, '', $GLOBALS['err_url']);
    $sql_insert_data .= $sql_insert . ';' . "\n";
}
/**
 * Function to get all index information from a certain table
 *
 * @param   string      Table name
 * @param   string      Error URL
 *
 * @access  public
 * @return  array       Index keys
 */
function PMA_get_indexes($tbl_name, $err_url_0 = '')
{
    $tbl_local_query = 'SHOW KEYS FROM ' . PMA_backquote($tbl_name);
    $tbl_result = PMA_DBI_query($tbl_local_query) or PMA_mysqlDie('', $tbl_local_query, '', $err_url_0);
    $tbl_ret_keys = array();
    while ($tbl_row = PMA_DBI_fetch_assoc($tbl_result)) {
        $tbl_ret_keys[] = $tbl_row;
    }
    PMA_DBI_free_result($tbl_result);
    return $tbl_ret_keys;
}
示例#4
0
 /**
  * Builds the SQL search query
  *
  * @param   string   the table name
  * @param   string   the string to search
  * @param   integer  type of search (1 -> 1 word at least, 2 -> all words,
  *                                   3 -> exact string, 4 -> regexp)
  *
  * @return  array    3 SQL querys (for count, display and delete results)
  *
  * @global  string   the url to retun to in case of errors
  */
 function PMA_getSearchSqls($table, $search_str, $search_option)
 {
     global $err_url;
     // Statement types
     $sqlstr_select = 'SELECT';
     $sqlstr_delete = 'DELETE';
     // Fields to select
     $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']);
     $res = @PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, $err_url);
     $res_cnt = $res ? mysql_num_rows($res) : 0;
     for ($i = 0; $i < $res_cnt; $i++) {
         $tblfields[] = PMA_backquote(PMA_mysql_result($res, $i, 'field'));
     }
     // end if
     $sqlstr_fieldstoselect = ' ' . implode(', ', $tblfields);
     $tblfields_cnt = count($tblfields);
     if ($res) {
         mysql_free_result($res);
     }
     // Table to use
     $sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
     // Beginning of WHERE clause
     $sqlstr_where = ' WHERE';
     $search_words = $search_option > 2 ? array($search_str) : explode(' ', $search_str);
     $search_wds_cnt = count($search_words);
     $like_or_regex = $search_option == 4 ? 'REGEXP' : 'LIKE';
     $automatic_wildcard = $search_option < 3 ? '%' : '';
     for ($i = 0; $i < $search_wds_cnt; $i++) {
         // Elimines empty values
         if (!empty($search_words[$i])) {
             for ($j = 0; $j < $tblfields_cnt; $j++) {
                 $thefieldlikevalue[] = $tblfields[$j] . ' ' . $like_or_regex . ' \'' . $automatic_wildcard . $search_words[$i] . $automatic_wildcard . '\'';
             }
             // end for
             $fieldslikevalues[] = $search_wds_cnt > 1 ? '(' . implode(' OR ', $thefieldlikevalue) . ')' : implode(' OR ', $thefieldlikevalue);
             unset($thefieldlikevalue);
         }
         // end if
     }
     // end for
     $implode_str = $search_option == 1 ? ' OR ' : ' AND ';
     $sqlstr_where .= ' ' . implode($implode_str, $fieldslikevalues);
     unset($fieldslikevalues);
     // Builds complete queries
     $sql['select_fields'] = $sqlstr_select . $sqlstr_fieldstoselect . $sqlstr_from . $sqlstr_where;
     $sql['select_count'] = $sqlstr_select . ' COUNT(*) AS count' . $sqlstr_from . $sqlstr_where;
     $sql['delete'] = $sqlstr_delete . $sqlstr_from . $sqlstr_where;
     return $sql;
 }
示例#5
0
 /**
  * Ensures a database/table/field's name is not a reserved word (for MySQL
  * releases < 3.23.6)
  *
  * @param    string   the name to check
  * @param    string   the url to go back in case of error
  *
  * @return   boolean  true if the name is valid (no return else)
  *
  * @access  public
  *
  * @author   Dell'Aiera Pol; Olivier Blin
  */
 function PMA_checkReservedWords($the_name, $error_url)
 {
     // The name contains caracters <> a-z, A-Z and "_" -> not a reserved
     // word
     if (!ereg('^[a-zA-Z_]+$', $the_name)) {
         return true;
     }
     // Else do the work
     $filename = 'badwords.txt';
     if (file_exists($filename)) {
         // Builds the reserved words array
         $fd = fopen($filename, 'r');
         $contents = fread($fd, filesize($filename) - 1);
         fclose($fd);
         $word_list = explode("\n", $contents);
         // Do the checking
         $word_cnt = count($word_list);
         for ($i = 0; $i < $word_cnt; $i++) {
             if (strtolower($the_name) == $word_list[$i]) {
                 PMA_mysqlDie(sprintf($GLOBALS['strInvalidName'], $the_name), '', FALSE, $error_url);
             }
             // end if
         }
         // end for
     }
     // end if
 }
示例#6
0
</form>
<div id="pdflayout" class="pdflayout" style="visibility: hidden;">
<?php 
            foreach ($array_sh_page as $key => $temp_sh_page) {
                $drag_x = $temp_sh_page['x'];
                $drag_y = $temp_sh_page['y'];
                $draginit .= '    Drag.init(getElement("table_' . $i . '"), null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
                $draginit .= '    getElement("table_' . $i . '").onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
                $draginit .= '    getElement("table_' . $i . '").style.left = "' . $drag_x . 'px";' . "\n";
                $draginit .= '    getElement("table_' . $i . '").style.top  = "' . $drag_y . 'px";' . "\n";
                $reset_draginit .= '    getElement("table_' . $i . '").style.left = "2px";' . "\n";
                $reset_draginit .= '    getElement("table_' . $i . '").style.top  = "' . 15 * $i . 'px";' . "\n";
                $reset_draginit .= '    document.edcoord.elements["c_table_' . $i . '[x]"].value = "2"' . "\n";
                $reset_draginit .= '    document.edcoord.elements["c_table_' . $i . '[y]"].value = "' . 15 * $i . '"' . "\n";
                $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($temp_sh_page['table_name']) . ' FROM ' . PMA_backquote($db);
                $fields_rs = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
                $fields_cnt = mysql_num_rows($fields_rs);
                echo '<div id="table_' . $i . '" class="pdflayout_table"><u>' . $temp_sh_page['table_name'] . '</u>';
                while ($row = PMA_mysql_fetch_array($fields_rs)) {
                    echo "<br>" . htmlspecialchars($row['Field']) . "\n";
                }
                echo '</div>' . "\n";
                mysql_free_result($fields_rs);
                $i++;
            }
            ?>
</div>
<script type="text/javascript">
<!--
function init() {
    refreshLayout();
/* Check parameters */
PMA_checkParameters(array('db', 'table', 'where_clause', 'transform_key'));
/* Select database */
if (!PMA_DBI_select_db($db)) {
    PMA_mysqlDie(sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)), '', '');
}
/* Check if table exists */
if (!PMA_DBI_get_columns($db, $table)) {
    PMA_mysqlDie(__('Invalid table name'));
}
/* Grab data */
$sql = 'SELECT ' . PMA_backquote($transform_key) . ' FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';';
$result = PMA_DBI_fetch_value($sql);
/* Check return code */
if ($result === false) {
    PMA_mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql);
}
/* Avoid corrupting data */
@ini_set('url_rewriter.tags', '');
header('Content-Type: ' . PMA_detectMIME($result));
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
$filename = PMA_sanitize_filename($table . '-' . $transform_key . '.bin');
header('Content-Disposition: attachment; filename="' . $filename . '"');
if (PMA_USR_BROWSER_AGENT == 'IE') {
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
} else {
    header('Pragma: no-cache');
    // test case: exporting a database into a .gz file with Safari
    // would produce files not having the current time
    // (added this header for Safari but should not harm other browsers)
示例#8
0
 */
require_once 'libraries/common.inc.php';
$GLOBALS['js_include'][] = 'db_search.js';
$GLOBALS['js_include'][] = 'sql.js';
$GLOBALS['js_include'][] = 'makegrid.js';
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
/**
 * Gets some core libraries and send headers
 */
require 'libraries/db_common.inc.php';
/**
 * init
 */
// If config variable $GLOBALS['cfg']['Usedbsearch'] is on false : exit.
if (!$GLOBALS['cfg']['UseDbSearch']) {
    PMA_mysqlDie(__('Access denied'), '', false, $err_url);
}
// end if
$url_query .= '&amp;goto=db_search.php';
$url_params['goto'] = 'db_search.php';
/**
 * @global array list of tables from the current database
 * but do not clash with $tables coming from db_info.inc.php
 */
$tables_names_only = PMA_DBI_get_tables($GLOBALS['db']);
$search_options = array('1' => __('at least one of the words'), '2' => __('all words'), '3' => __('the exact phrase'), '4' => __('as regular expression'));
if (empty($_REQUEST['search_option']) || !is_string($_REQUEST['search_option']) || !array_key_exists($_REQUEST['search_option'], $search_options)) {
    $search_option = 1;
    unset($_REQUEST['submit_search']);
} else {
    $search_option = (int) $_REQUEST['search_option'];
    } else {
        PMA_mysqlDie('', '', '', $err_url, false);
        // garvin: An error happened while inserting/updating a table definition.
        // to prevent total loss of that data, we embed the form once again.
        // The variable $regenerate will be used to restore data in libs/tbl_properties.inc.php
        $num_fields = $orig_num_fields;
        $regenerate = true;
    }
}
// end do create table
/**
 * Displays the form used to define the structure of the table
 */
if ($abort == false) {
    if (isset($num_fields)) {
        $num_fields = intval($num_fields);
    }
    // No table name
    if (!isset($table) || trim($table) == '') {
        PMA_mysqlDie($strTableEmpty, '', '', $err_url);
    } elseif (empty($num_fields) || !is_int($num_fields)) {
        PMA_mysqlDie($strFieldsEmpty, '', '', $err_url);
    } elseif (!(PMA_DBI_get_fields($db, $table) === false)) {
        PMA_mysqlDie(sprintf($strTableAlreadyExists, htmlspecialchars($table)), '', '', $err_url);
    } else {
        $action = 'tbl_create.php';
        require './libs/tbl_properties.inc.php';
        // Displays the footer
        require_once './libs/footer.inc.php';
    }
}
示例#10
0
/**
 * User is not allowed to login to MySQL -> authentication failed
 *
 * @global  string    the MySQL error message PHP returns
 * @global  string    the connection type (persistent or not)
 * @global  string    the MySQL server port to use
 * @global  string    the MySQL socket port to use
 * @global  array     the current server settings
 * @global  string    the font face to use in case of failure
 * @global  string    the default font size to use in case of failure
 * @global  string    the big font size to use in case of failure
 * @global  boolean   tell the "PMA_mysqlDie()" function headers have been
 *                    sent
 *
 * @return  boolean   always true (no return indeed)
 *
 * @access  public
 */
function PMA_auth_fails()
{
    global $php_errormsg, $cfg;
    global $right_font_family, $font_size, $font_bigger;
    if (PMA_DBI_getError()) {
        $conn_error = PMA_DBI_getError();
    } else {
        if (isset($php_errormsg)) {
            $conn_error = $php_errormsg;
        } else {
            $conn_error = $GLOBALS['strConnectionError'];
        }
    }
    // Defines the charset to be used
    header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
    // Defines the theme to be used
    require_once './libraries/select_theme.lib.php';
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
    echo $GLOBALS['available_languages'][$GLOBALS['lang']][2];
    ?>
" lang="<?php 
    echo $GLOBALS['available_languages'][$GLOBALS['lang']][2];
    ?>
" dir="<?php 
    echo $GLOBALS['text_dir'];
    ?>
">

<head>
<title><?php 
    echo $GLOBALS['strAccessDenied'];
    ?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php 
    echo $GLOBALS['charset'];
    ?>
" />
<style type="text/css">
<!--
body     {font-family: <?php 
    echo $right_font_family;
    ?>
; font-size: <?php 
    echo $font_size;
    ?>
; color: #000000}
h1       {font-family: <?php 
    echo $right_font_family;
    ?>
; font-size: <?php 
    echo $font_bigger;
    ?>
; font-weight: bold}
//-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
    /* added 2004-06-10 by Michael Keck
     *       we need this for Backwards-Compatibility and resolving problems
     *       with non DOM browsers, which may have problems with css 2 (like NC 4)
    */
    var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
                      && typeof(document.createElement) != 'undefined')
                   ? 1 : 0;
    var isIE4      = (typeof(document.all) != 'undefined'
                      && parseInt(navigator.appVersion) >= 4)
                   ? 1 : 0;
    var isNS4      = (typeof(document.layers) != 'undefined')
                   ? 1 : 0;
    var capable    = (isDOM || isIE4 || isNS4)
                   ? 1 : 0;
    // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
    if (capable) {
        if (typeof(window.opera) != 'undefined') {
            var browserName = ' ' + navigator.userAgent.toLowerCase();
            if ((browserName.indexOf('konqueror 7') == 0)) {
                capable = 0;
            }
        } else if (typeof(navigator.userAgent) != 'undefined') {
            var browserName = ' ' + navigator.userAgent.toLowerCase();
            if ((browserName.indexOf('konqueror') > 0) && (browserName.indexOf('konqueror/3') == 0)) {
                capable = 0;
            }
        } // end if... else if...
    } // end if
    document.writeln('<link rel="stylesheet" type="text/css" href="<?php 
    echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './';
    ?>
css/phpmyadmin.css.php?lang=<?php 
    echo $GLOBALS['available_languages'][$GLOBALS['lang']][2];
    ?>
&amp;js_frame=right&amp;js_isDOM=' + isDOM + '" />');
//-->
</script>
<noscript>
    <link rel="stylesheet" type="text/css" href="<?php 
    echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : './';
    ?>
css/phpmyadmin.css.php?lang=<?php 
    echo $GLOBALS['available_languages'][$GLOBALS['lang']][2];
    ?>
&amp;js_frame=right" />
</noscript>

</head>

<body bgcolor="<?php 
    echo $cfg['RightBgColor'];
    ?>
">
<br /><br />
<center>
    <h1><?php 
    echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION);
    ?>
</h1>
</center>
<br />
<table border="0" cellpadding="0" cellspacing="3" align="center" width="80%">
    <tr>
        <td>
    <?php 
    echo "\n";
    $GLOBALS['is_header_sent'] = TRUE;
    //TODO: I have included this div from header.inc.php to work around
    //      an undefined variable in tooltip.js, when the server
    //      is not responding. Work has to be done to merge all code that
    //      starts the page (DOCTYPE and this div) to one place
    ?>
    <div id="TooltipContainer" name="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div>
    <?php 
    // if we display the "Server not responding" error, do not confuse users
    // by telling them they have a settings problem
    // (note: it's true that they could have a badly typed host name, but
    //  anyway the current $strAccessDeniedExplanation tells that the server
    //  rejected the connection, which is not really what happened)
    // 2002 is the error given by mysqli
    // 2003 is the error given by mysql
    if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
        echo '<p>' . $GLOBALS['strAccessDenied'] . '</p>' . "\n";
    } else {
        if (!isset($GLOBALS['errno']) || isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002 && $GLOBALS['errno'] != 2003) {
            echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
        }
        PMA_mysqlDie($conn_error, '');
    }
    ?>
        </td>
    </tr>
</table>
<?php 
    require_once './footer.inc.php';
    return TRUE;
}
示例#11
0
// if there is any message, copy it into $_SESSION as well, so we can obtain it by AJAX call
if (isset($message)) {
    $_SESSION['Import_message']['message'] = $message->getDisplay();
    //  $_SESSION['Import_message']['go_back_url'] = $goto.'?'.  PMA_generate_common_url();
}
// Parse and analyze the query, for correct db and table name
// in case of a query typed in the query window
// (but if the query is too large, in case of an imported file, the parser
//  can choke on it so avoid parsing)
if (strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
    require_once './libraries/parse_analyze.lib.php';
}
// There was an error?
if (isset($my_die)) {
    foreach ($my_die as $key => $die) {
        PMA_mysqlDie($die['error'], $die['sql'], '', $err_url, $error);
    }
}
// we want to see the results of the last query that returned at least a row
if (!empty($last_query_with_results)) {
    // but we want to show intermediate results too
    $disp_query = $sql_query;
    $disp_message = __('Your SQL query has been executed successfully');
    $sql_query = $last_query_with_results;
    $go_sql = true;
}
if ($go_sql) {
    require './sql.php';
} else {
    $active_page = $goto;
    require './' . $goto;
        PMA_DBI_query($sql_query);
        $message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\'');
    } else {
        if (empty($pma_pw) || empty($pma_pw2)) {
            $message = $GLOBALS['strPasswordEmpty'];
        } else {
            if ($pma_pw != $pma_pw2) {
                $message = $GLOBALS['strPasswordNotSame'];
            } else {
                $hidden_pw = '';
                for ($i = 0; $i < strlen($pma_pw); $i++) {
                    $hidden_pw .= '*';
                }
                $local_query = 'SET PASSWORD FOR \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\' = PASSWORD(\'' . PMA_sqlAddslashes($pma_pw) . '\')';
                $sql_query = 'SET PASSWORD FOR \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\' = PASSWORD(\'' . $hidden_pw . '\')';
                PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query);
                $message = sprintf($GLOBALS['strPasswordChanged'], '\'' . $username . '\'@\'' . $hostname . '\'');
            }
        }
    }
}
/**
 * Deletes users
 *   (Changes / copies a user, part IV)
 */
$user_host_separator = chr(27);
if (!empty($delete) || !empty($change_copy) && $mode < 4) {
    if (!empty($change_copy)) {
        $selected_usr = array($old_username . $user_host_separator . $old_hostname);
    } else {
        $queries = array();
示例#13
0
 /**
  * Outputs the content of a table in CSV format
  *
  * Last revision 14 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the database name
  * @param   string   the table name
  * @param   integer  the offset on this table
  * @param   integer  the last row to get
  * @param   string   the field separator character
  * @param   string   the optionnal "enclosed by" character
  * @param   string   the handler (function) to call. It must accept one
  *                   parameter ($sql_insert)
  * @param   string   the url to go back in case of error
  *
  * @global  string   whether to obtain an excel compatible csv format or a
  *                   simple csv one
  *
  * @return  boolean always true
  *
  * @access  public
  */
 function PMA_getTableCsv($db, $table, $limit_from = 0, $limit_to = 0, $sep, $enc_by, $esc_by, $handler, $error_url)
 {
     global $what;
     // Handles the "separator" and the optionnal "enclosed by" characters
     if ($what == 'excel') {
         $sep = ',';
     } else {
         if (!isset($sep)) {
             $sep = '';
         } else {
             if (get_magic_quotes_gpc()) {
                 $sep = stripslashes($sep);
             }
             $sep = str_replace('\\t', "\t", $sep);
         }
     }
     if ($what == 'excel') {
         $enc_by = '"';
     } else {
         if (!isset($enc_by)) {
             $enc_by = '';
         } else {
             if (get_magic_quotes_gpc()) {
                 $enc_by = stripslashes($enc_by);
             }
         }
     }
     if ($what == 'excel' || empty($esc_by) && $enc_by != '') {
         // double the "enclosed by" character
         $esc_by = $enc_by;
     } else {
         if (!isset($esc_by)) {
             $esc_by = '';
         } else {
             if (get_magic_quotes_gpc()) {
                 $esc_by = stripslashes($esc_by);
             }
         }
     }
     // Defines the offsets to use
     if ($limit_from > 0) {
         $limit_from--;
     } else {
         $limit_from = 0;
     }
     if ($limit_to > 0 && $limit_from >= 0) {
         $add_query = " LIMIT {$limit_from}, {$limit_to}";
     } else {
         $add_query = '';
     }
     // Gets the data from the database
     $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
     $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url);
     $fields_cnt = mysql_num_fields($result);
     @set_time_limit($GLOBALS['cfgExecTimeLimit']);
     // Format the data
     $i = 0;
     while ($row = mysql_fetch_row($result)) {
         $schema_insert = '';
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j])) {
                 $schema_insert .= 'NULL';
             } else {
                 if ($row[$j] == '0' || $row[$j] != '') {
                     // loic1 : always enclose fields
                     if ($what == 'excel') {
                         $row[$j] = ereg_replace("\r(\n)?", "\n", $row[$j]);
                     }
                     if ($enc_by == '') {
                         $schema_insert .= $row[$j];
                     } else {
                         $schema_insert .= $enc_by . str_replace($enc_by, $esc_by . $enc_by, $row[$j]) . $enc_by;
                     }
                 } else {
                     $schema_insert .= '';
                 }
             }
             if ($j < $fields_cnt - 1) {
                 $schema_insert .= $sep;
             }
         }
         // end for
         $handler(trim($schema_insert));
         ++$i;
         // loic1: send a fake header to bypass browser timeout if data are
         //        bufferized
         if (!empty($GLOBALS['ob_mode']) && (isset($GLOBALS['zip']) || isset($GLOBALS['bzip']) || isset($GLOBALS['gzip']))) {
             header('Expires: 0');
         }
     }
     // end while
     mysql_free_result($result);
     return TRUE;
 }
示例#14
0
                            $sts_tmp = mysql_fetch_array($sts_result);
                            $tables[] = $sts_tmp;
                        } else {
                            // table in use
                            $tables[] = array('Name' => $tmp[0]);
                        }
                    }
                    mysql_free_result($result);
                    $sot_ready = TRUE;
                }
            }
        }
    }
    if (!isset($sot_ready)) {
        $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
        $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
        if ($result != FALSE && mysql_num_rows($result) > 0) {
            while ($sts_tmp = mysql_fetch_array($result)) {
                $tables[] = $sts_tmp;
            }
            mysql_free_result($result);
        }
    }
    $num_tables = isset($tables) ? count($tables) : 0;
} else {
    $result = mysql_list_tables($db);
    $num_tables = @mysql_numrows($result);
    for ($i = 0; $i < $num_tables; $i++) {
        $tables[] = mysql_tablename($result, $i);
    }
    mysql_free_result($result);
/**
 * User is not allowed to login to MySQL -> authentication failed
 *
 * @global  string    the MySQL error message PHP returns
 * @global  string    the connection type (persistent or not)
 * @global  string    the MySQL server port to use
 * @global  string    the MySQL socket port to use
 * @global  array     the current server settings
 * @global  string    the font face to use in case of failure
 * @global  string    the default font size to use in case of failure
 * @global  string    the big font size to use in case of failure
 * @global  boolean   tell the "PMA_mysqlDie()" function headers have been
 *                    sent
 *
 * @return  boolean   always true (no return indeed)
 *
 * @access  public
 */
function PMA_auth_fails()
{
    global $php_errormsg, $cfg;
    global $right_font_family, $font_size, $font_bigger;
    if (PMA_DBI_getError()) {
        $conn_error = PMA_DBI_getError();
    } else {
        if (isset($php_errormsg)) {
            $conn_error = $php_errormsg;
        } else {
            $conn_error = $GLOBALS['strConnectionError'];
        }
    }
    // Defines the charset to be used
    header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
    // Defines the theme to be used
    require_once './libraries/select_theme.lib.php';
    /* HTML header */
    $page_title = $GLOBALS['strAccessDenied'];
    require './libraries/header_meta_style.inc.php';
    ?>
</head>

<body bgcolor="<?php 
    echo $cfg['RightBgColor'];
    ?>
">
<br /><br />
<center>
    <h1><?php 
    echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION);
    ?>
</h1>
</center>
<br />
<table border="0" cellpadding="0" cellspacing="3" align="center" width="80%">
    <tr>
        <td>
    <?php 
    echo "\n";
    $GLOBALS['is_header_sent'] = TRUE;
    //TODO: I have included this div from header.inc.php to work around
    //      an undefined variable in tooltip.js, when the server
    //      is not responding. Work has to be done to merge all code that
    //      starts the page (DOCTYPE and this div) to one place
    ?>
    <div id="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div>
    <?php 
    // if we display the "Server not responding" error, do not confuse users
    // by telling them they have a settings problem
    // (note: it's true that they could have a badly typed host name, but
    //  anyway the current $strAccessDeniedExplanation tells that the server
    //  rejected the connection, which is not really what happened)
    // 2002 is the error given by mysqli
    // 2003 is the error given by mysql
    if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
        echo '<p>' . $GLOBALS['strAccessDenied'] . '</p>' . "\n";
    } else {
        if (!isset($GLOBALS['errno']) || isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002 && $GLOBALS['errno'] != 2003) {
            echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
        }
        PMA_mysqlDie($conn_error, '');
    }
    ?>
        </td>
    </tr>
</table>
<?php 
    require_once './footer.inc.php';
    return TRUE;
}
         }
         // end if... else....
     } elseif (isset($existrel_foreign[$master_field])) {
         $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP FOREIGN KEY ' . PMA_backquote($existrel_foreign[$master_field]['constraint']);
         $sql_query .= ';';
         $display_query .= $sql_query . "\n";
     }
     // end if... else....
     if (!empty($sql_query)) {
         PMA_DBI_try_query($sql_query);
         $tmp_error = PMA_DBI_getError();
         if (!empty($tmp_error)) {
             $seen_error = true;
         }
         if (substr($tmp_error, 1, 4) == '1216' || substr($tmp_error, 1, 4) == '1452') {
             PMA_mysqlDie($tmp_error, $sql_query, FALSE, '', FALSE);
             echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
         }
         if (substr($tmp_error, 1, 4) == '1005') {
             $message = PMA_Message::warning('strForeignKeyError');
             $message->addParam($master_field);
             $message->display();
             echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
         }
         unset($tmp_error);
         $sql_query = '';
     }
 }
 // end foreach
 if (!empty($display_query)) {
     if ($seen_error) {
示例#17
0
        // read table info on this newly created table, in case
        // the next page is Structure
        $reread_info = true;
        require './libraries/tbl_info.inc.php';
        // do not switch to sql.php - as there is no row to be displayed on a new table
        if ($cfg['DefaultTabTable'] === 'sql.php') {
            require './tbl_structure.php';
        } else {
            require './' . $cfg['DefaultTabTable'];
        }
        exit;
    } else {
        if ($GLOBALS['is_ajax_request'] == true) {
            PMA_ajaxResponse(PMA_DBI_getError(), false);
        } else {
            PMA_mysqlDie('', '', '', $err_url, false);
            // An error happened while inserting/updating a table definition.
            // to prevent total loss of that data, we embed the form once again.
            // The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php
            $num_fields = $_REQUEST['orig_num_fields'];
            $regenerate = true;
        }
    }
}
// end do create table
/**
 * Displays the form used to define the structure of the table
 */
// This div is used to show the content(eg: create table form with more columns) fetched with AJAX subsequently.
if ($GLOBALS['is_ajax_request'] != true) {
    echo '<div id="create_table_div">';
/**
 * returns array with databases containing extended infos about them
 *
 * @todo    move into PMA_List_Database?
 * @param   string      $databases      database
 * @param   boolean     $force_stats    retrieve stats also for MySQL < 5
 * @param   resource    $link           mysql link
 * @param   string      $sort_by        column to order by
 * @param   string      $sort_order     ASC or DESC
 * @param   integer     $limit_offset   starting offset for LIMIT
 * @param   bool|int    $limit_count    row count for LIMIT or true for $GLOBALS['cfg']['MaxDbList']
 * @return  array       $databases
 */
function PMA_DBI_get_databases_full($database = null, $force_stats = false, $link = null, $sort_by = 'SCHEMA_NAME', $sort_order = 'ASC', $limit_offset = 0, $limit_count = false)
{
    $sort_order = strtoupper($sort_order);
    if (true === $limit_count) {
        $limit_count = $GLOBALS['cfg']['MaxDbList'];
    }
    // initialize to avoid errors when there are no databases
    $databases = array();
    $apply_limit_and_order_manual = true;
    if (!$GLOBALS['cfg']['Server']['DisableIS']) {
        /**
         * if $GLOBALS['cfg']['NaturalOrder'] is enabled, we cannot use LIMIT
         * cause MySQL does not support natural ordering, we have to do it afterward
         */
        if ($GLOBALS['cfg']['NaturalOrder']) {
            $limit = '';
        } else {
            if ($limit_count) {
                $limit = ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
            }
            $apply_limit_and_order_manual = false;
        }
        // get table information from information_schema
        if ($database) {
            $sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \'' . addslashes($database) . '\'';
        } else {
            $sql_where_schema = '';
        }
        // for PMA bc:
        // `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
        $sql = '
             SELECT `information_schema`.`SCHEMATA`.*';
        if ($force_stats) {
            $sql .= ',
                    COUNT(`information_schema`.`TABLES`.`TABLE_SCHEMA`)
                        AS `SCHEMA_TABLES`,
                    SUM(`information_schema`.`TABLES`.`TABLE_ROWS`)
                        AS `SCHEMA_TABLE_ROWS`,
                    SUM(`information_schema`.`TABLES`.`DATA_LENGTH`)
                        AS `SCHEMA_DATA_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`MAX_DATA_LENGTH`)
                        AS `SCHEMA_MAX_DATA_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`INDEX_LENGTH`)
                        AS `SCHEMA_INDEX_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`DATA_LENGTH`
                      + `information_schema`.`TABLES`.`INDEX_LENGTH`)
                        AS `SCHEMA_LENGTH`,
                    SUM(`information_schema`.`TABLES`.`DATA_FREE`)
                        AS `SCHEMA_DATA_FREE`';
        }
        $sql .= '
               FROM `information_schema`.`SCHEMATA`';
        if ($force_stats) {
            $sql .= '
          LEFT JOIN `information_schema`.`TABLES`
                 ON BINARY `information_schema`.`TABLES`.`TABLE_SCHEMA`
                  = BINARY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`';
        }
        $sql .= '
              ' . $sql_where_schema . '
           GROUP BY BINARY `information_schema`.`SCHEMATA`.`SCHEMA_NAME`
           ORDER BY BINARY ' . PMA_backquote($sort_by) . ' ' . $sort_order . $limit;
        $databases = PMA_DBI_fetch_result($sql, 'SCHEMA_NAME', null, $link);
        $mysql_error = PMA_DBI_getError($link);
        if (!count($databases) && $GLOBALS['errno']) {
            PMA_mysqlDie($mysql_error, $sql);
        }
        // display only databases also in official database list
        // f.e. to apply hide_db and only_db
        $drops = array_diff(array_keys($databases), (array) $GLOBALS['pma']->databases);
        if (count($drops)) {
            foreach ($drops as $drop) {
                unset($databases[$drop]);
            }
            unset($drop);
        }
        unset($sql_where_schema, $sql, $drops);
    } else {
        foreach ($GLOBALS['pma']->databases as $database_name) {
            // MySQL forward compatibility
            // so pma could use this array as if every server is of version >5.0
            $databases[$database_name]['SCHEMA_NAME'] = $database_name;
            if ($force_stats) {
                require_once './libraries/mysql_charsets.lib.php';
                $databases[$database_name]['DEFAULT_COLLATION_NAME'] = PMA_getDbCollation($database_name);
                // get additional info about tables
                $databases[$database_name]['SCHEMA_TABLES'] = 0;
                $databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
                $databases[$database_name]['SCHEMA_DATA_LENGTH'] = 0;
                $databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 0;
                $databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
                $databases[$database_name]['SCHEMA_LENGTH'] = 0;
                $databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
                $res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($database_name) . ';');
                while ($row = PMA_DBI_fetch_assoc($res)) {
                    $databases[$database_name]['SCHEMA_TABLES']++;
                    $databases[$database_name]['SCHEMA_TABLE_ROWS'] += $row['Rows'];
                    $databases[$database_name]['SCHEMA_DATA_LENGTH'] += $row['Data_length'];
                    $databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] += $row['Max_data_length'];
                    $databases[$database_name]['SCHEMA_INDEX_LENGTH'] += $row['Index_length'];
                    // for InnoDB, this does not contain the number of
                    // overhead bytes but the total free space
                    if ('InnoDB' != $row['Engine']) {
                        $databases[$database_name]['SCHEMA_DATA_FREE'] += $row['Data_free'];
                    }
                    $databases[$database_name]['SCHEMA_LENGTH'] += $row['Data_length'] + $row['Index_length'];
                }
                PMA_DBI_free_result($res);
                unset($res);
            }
        }
    }
    /**
     * apply limit and order manually now
     * (caused by older MySQL < 5 or $GLOBALS['cfg']['NaturalOrder'])
     */
    if ($apply_limit_and_order_manual) {
        $GLOBALS['callback_sort_order'] = $sort_order;
        $GLOBALS['callback_sort_by'] = $sort_by;
        usort($databases, 'PMA_usort_comparison_callback');
        unset($GLOBALS['callback_sort_order'], $GLOBALS['callback_sort_by']);
        /**
         * now apply limit
         */
        if ($limit_count) {
            $databases = array_slice($databases, $limit_offset, $limit_count);
        }
    }
    return $databases;
}
示例#19
0
         case 'unique_fld':
             $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE( ' : ', ') . PMA_backquote(urldecode($selected[$i])) . ($i == $selected_cnt - 1 ? ');' : '');
             break;
         case 'fulltext_fld':
             $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT( ' : ', ') . PMA_backquote(urldecode($selected[$i])) . ($i == $selected_cnt - 1 ? ');' : '');
             break;
     }
     // end switch
     // All "DROP TABLE", "DROP FIELD", "OPTIMIZE TABLE" and "REPAIR TABLE"
     // statements will be run at once below
     if ($run_parts) {
         $sql_query .= $a_query . ';' . "\n";
         if ($query_type != 'drop_db') {
             PMA_DBI_select_db($db);
         }
         $result = @PMA_DBI_query($a_query) or PMA_mysqlDie('', $a_query, FALSE, $err_url);
     }
     // end if
 }
 // end for
 if ($query_type == 'drop_tbl') {
     if (!empty($sql_query)) {
         $sql_query .= ';';
     } elseif (!empty($sql_query_views)) {
         $sql_query = $sql_query_views . ';';
         unset($sql_query_views);
     }
 }
 if ($use_sql) {
     require './sql.php';
 } elseif (!$run_parts) {
示例#20
0
        PMA_mysqlDie('', '', '', $err_url, FALSE);
        // garvin: An error happened while inserting/updating a table definition.
        // to prevent total loss of that data, we embed the form once again.
        // The variable $regenerate will be used to restore data in tbl_properties.inc.php
        $num_fields = $orig_num_fields;
        $regenerate = true;
    }
}
// end do create table
/**
 * Displays the form used to define the structure of the table
 */
if ($abort == FALSE) {
    if (isset($num_fields)) {
        $num_fields = intval($num_fields);
    }
    // No table name
    if (!isset($table) || trim($table) == '') {
        PMA_mysqlDie($strTableEmpty, '', '', $err_url);
    } else {
        if (empty($num_fields) || !is_int($num_fields)) {
            PMA_mysqlDie($strFieldsEmpty, '', '', $err_url);
        } else {
            $action = 'tbl_create.php';
            require './tbl_properties.inc.php';
            // Diplays the footer
            echo "\n";
            require_once './footer.inc.php';
        }
    }
}
示例#21
0
function PMA_RT_DOC($alltables)
{
    global $db, $pdf, $orientation;
    //TOC
    $pdf->addpage("P");
    $pdf->Cell(0, 9, $GLOBALS['strTableOfContents'], 1, 0, 'C');
    $pdf->Ln(15);
    $i = 1;
    foreach ($alltables as $table) {
        $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink();
        $pdf->SetX(10);
        //$pdf->Ln(1);
        $pdf->Cell(0, 6, $GLOBALS['strPageNumber'] . ' {' . sprintf("%02d", $i) . '}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$table]['-']);
        $pdf->SetX(10);
        $pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', 0, $pdf->PMA_links['doc'][$table]['-']);
        //$pdf->Ln(1);
        $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table);
        $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
        while ($row = PMA_mysql_fetch_array($result)) {
            $pdf->SetX(20);
            $field_name = $row['Field'];
            $pdf->PMA_links['doc'][$table][$field_name] = $pdf->AddLink();
            //$pdf->Cell(0,6,$field_name,0,1,'L',0,$pdf->PMA_links['doc'][$table][$field_name]);
        }
        $lasttable = $table;
        $i++;
    }
    $pdf->PMA_links['RT']['-'] = $pdf->AddLink();
    $pdf->SetX(10);
    $pdf->Cell(0, 6, $GLOBALS['strPageNumber'] . ' {00}', 0, 0, 'R', 0, $pdf->PMA_links['doc'][$lasttable]['-']);
    $pdf->SetX(10);
    $pdf->Cell(0, 6, $i . ' ' . $GLOBALS['strRelationalSchema'], 0, 1, 'L', 0, $pdf->PMA_links['RT']['-']);
    $z = 0;
    foreach ($alltables as $table) {
        $z++;
        $pdf->addpage($GLOBALS['orientation']);
        $pdf->Bookmark($table);
        $pdf->SetAlias('{' . sprintf("%02d", $z) . '}', $pdf->PageNo());
        $pdf->PMA_links['RT'][$table]['-'] = $pdf->AddLink();
        $pdf->SetLink($pdf->PMA_links['doc'][$table]['-'], -1);
        $pdf->SetFont('', 'B', 18);
        $pdf->Cell(0, 8, $z . ' ' . $table, 1, 1, 'C', 0, $pdf->PMA_links['RT'][$table]['-']);
        $pdf->SetFont('', '', 8);
        $pdf->ln();
        $cfgRelation = PMA_getRelationsParam();
        if ($cfgRelation['commwork']) {
            $comments = PMA_getComments($db, $table);
        }
        if ($cfgRelation['mimework']) {
            $mime_map = PMA_getMIME($db, $table, true);
        }
        /**
         * Gets table informations
         */
        $local_query = "SHOW TABLE STATUS LIKE '" . PMA_sqlAddslashes($table, TRUE) . "'";
        $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
        $showtable = PMA_mysql_fetch_array($result);
        $num_rows = isset($showtable['Rows']) ? $showtable['Rows'] : 0;
        $show_comment = isset($showtable['Comment']) ? $showtable['Comment'] : '';
        $create_time = isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '';
        $update_time = isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '';
        $check_time = isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '';
        if ($result) {
            mysql_free_result($result);
        }
        /**
         * Gets table keys and retains them
         */
        $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table);
        $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
        $primary = '';
        $indexes = array();
        $lastIndex = '';
        $indexes_info = array();
        $indexes_data = array();
        $pk_array = array();
        // will be use to emphasis prim. keys in the table
        // view
        while ($row = PMA_mysql_fetch_array($result)) {
            // Backups the list of primary keys
            if ($row['Key_name'] == 'PRIMARY') {
                $primary .= $row['Column_name'] . ', ';
                $pk_array[$row['Column_name']] = 1;
            }
            // Retains keys informations
            if ($row['Key_name'] != $lastIndex) {
                $indexes[] = $row['Key_name'];
                $lastIndex = $row['Key_name'];
            }
            $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
            $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
            if (isset($row['Cardinality'])) {
                $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
            }
            // I don't know what does following column mean....
            // $indexes_info[$row['Key_name']]['Packed']          = $row['Packed'];
            $indexes_info[$row['Key_name']]['Comment'] = $row['Comment'];
            $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
            if (isset($row['Sub_part'])) {
                $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
            }
        }
        // end while
        if ($result) {
            mysql_free_result($result);
        }
        /**
         * Gets fields properties
         */
        $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table);
        $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
        $fields_cnt = mysql_num_rows($result);
        // Check if we can use Relations (Mike Beck)
        if (!empty($cfgRelation['relation'])) {
            // Find which tables are related with the current one and write it in
            // an array
            $res_rel = PMA_getForeigners($db, $table);
            if (count($res_rel) > 0) {
                $have_rel = TRUE;
            } else {
                $have_rel = FALSE;
            }
        } else {
            $have_rel = FALSE;
        }
        // end if
        /**
         * Displays the comments of the table if MySQL >= 3.23
         */
        $break = false;
        if (!empty($show_comment)) {
            $pdf->Cell(0, 3, $GLOBALS['strTableComments'] . ' : ' . $show_comment, 0, 1);
            $break = true;
        }
        if (!empty($create_time)) {
            $pdf->Cell(0, 3, $GLOBALS['strStatCreateTime'] . ': ' . $create_time, 0, 1);
            $break = true;
        }
        if (!empty($update_time)) {
            $pdf->Cell(0, 3, $GLOBALS['strStatUpdateTime'] . ': ' . $update_time, 0, 1);
            $break = true;
        }
        if (!empty($check_time)) {
            $pdf->Cell(0, 3, $GLOBALS['strStatCheckTime'] . ': ' . $check_time, 0, 1);
            $break = true;
        }
        if ($break == true) {
            $pdf->Cell(0, 3, '', 0, 1);
            $pdf->Ln();
        }
        $i = 0;
        $pdf->SetFont('', 'B');
        if (isset($orientation) && $orientation == 'L') {
            $pdf->Cell(25, 8, ucfirst($GLOBALS['strField']), 1, 0, 'C');
            $pdf->Cell(20, 8, ucfirst($GLOBALS['strType']), 1, 0, 'C');
            $pdf->Cell(20, 8, ucfirst($GLOBALS['strAttr']), 1, 0, 'C');
            $pdf->Cell(10, 8, ucfirst($GLOBALS['strNull']), 1, 0, 'C');
            $pdf->Cell(20, 8, ucfirst($GLOBALS['strDefault']), 1, 0, 'C');
            $pdf->Cell(25, 8, ucfirst($GLOBALS['strExtra']), 1, 0, 'C');
            $pdf->Cell(45, 8, ucfirst($GLOBALS['strLinksTo']), 1, 0, 'C');
            $pdf->Cell(67, 8, ucfirst($GLOBALS['strComments']), 1, 0, 'C');
            $pdf->Cell(45, 8, 'MIME', 1, 1, 'C');
            $pdf->SetWidths(array(25, 20, 20, 10, 20, 25, 45, 67, 45));
        } else {
            $pdf->Cell(20, 8, ucfirst($GLOBALS['strField']), 1, 0, 'C');
            $pdf->Cell(20, 8, ucfirst($GLOBALS['strType']), 1, 0, 'C');
            $pdf->Cell(20, 8, ucfirst($GLOBALS['strAttr']), 1, 0, 'C');
            $pdf->Cell(10, 8, ucfirst($GLOBALS['strNull']), 1, 0, 'C');
            $pdf->Cell(15, 8, ucfirst($GLOBALS['strDefault']), 1, 0, 'C');
            $pdf->Cell(15, 8, ucfirst($GLOBALS['strExtra']), 1, 0, 'C');
            $pdf->Cell(30, 8, ucfirst($GLOBALS['strLinksTo']), 1, 0, 'C');
            $pdf->Cell(30, 8, ucfirst($GLOBALS['strComments']), 1, 0, 'C');
            $pdf->Cell(30, 8, 'MIME', 1, 1, 'C');
            $pdf->SetWidths(array(20, 20, 20, 10, 15, 15, 30, 30, 30));
        }
        $pdf->SetFont('', '');
        while ($row = PMA_mysql_fetch_array($result)) {
            $bgcolor = $i % 2 ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
            $i++;
            $type = $row['Type'];
            // reformat mysql query output - staybyte - 9. June 2001
            // loic1: set or enum types: slashes single quotes inside options
            if (preg_match('@^(set|enum)\\((.+)\\)$@i', $type, $tmp)) {
                $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);
                $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
                $type_nowrap = '';
                $binary = 0;
                $unsigned = 0;
                $zerofill = 0;
            } else {
                $type_nowrap = ' nowrap="nowrap"';
                $type = preg_replace('@BINARY@i', '', $type);
                $type = preg_replace('@ZEROFILL@i', '', $type);
                $type = preg_replace('@UNSIGNED@i', '', $type);
                if (empty($type)) {
                    $type = '&nbsp;';
                }
                $binary = stristr($row['Type'], 'BINARY');
                $unsigned = stristr($row['Type'], 'UNSIGNED');
                $zerofill = stristr($row['Type'], 'ZEROFILL');
            }
            $strAttribute = ' ';
            if ($binary) {
                $strAttribute = 'BINARY';
            }
            if ($unsigned) {
                $strAttribute = 'UNSIGNED';
            }
            if ($zerofill) {
                $strAttribute = 'UNSIGNED ZEROFILL';
            }
            if (!isset($row['Default'])) {
                if ($row['Null'] != '') {
                    $row['Default'] = 'NULL';
                }
            }
            $field_name = $row['Field'];
            //$pdf->Ln();
            $pdf->PMA_links['RT'][$table][$field_name] = $pdf->AddLink();
            $pdf->Bookmark($field_name, 1, -1);
            $pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name], -1);
            $pdf_row = array($field_name, $type, $strAttribute, $row['Null'] == '' ? $GLOBALS['strNo'] : $GLOBALS['strYes'], isset($row['Default']) ? $row['Default'] : '', $row['Extra'], isset($res_rel[$field_name]) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : '', isset($comments[$field_name]) ? $comments[$field_name] : '', isset($mime_map) && isset($mime_map[$field_name]) ? str_replace('_', '/', $mime_map[$field_name]['mimetype']) : '');
            $links[0] = $pdf->PMA_links['RT'][$table][$field_name];
            if (isset($res_rel[$field_name]['foreign_table']) and isset($res_rel[$field_name]['foreign_field']) and isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])) {
                $links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']];
            } else {
                unset($links[6]);
            }
            $pdf->Row($pdf_row, $links);
            /*$pdf->Cell(20,8,$field_name,1,0,'L',0,$pdf->PMA_links['RT'][$table][$field_name]);
                      //echo '    ' . $field_name . '&nbsp;' . "\n";
                  }
              $pdf->Cell(20,8,$type,1,0,'L');
              $pdf->Cell(20,8,$strAttribute,1,0,'L');
              $pdf->Cell(15,8,,1,0,'L');
              $pdf->Cell(15,8,((isset($row['Default'])) ?  $row['Default'] : ''),1,0,'L');
              $pdf->Cell(15,8,$row['Extra'],1,0,'L');
                 if ($have_rel) {
                      if (isset($res_rel[$field_name])) {
                          $pdf->Cell(30,8,$res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'],1,0,'L');
                      }
                  }
                  if ($cfgRelation['commwork']) {
                      if (isset($comments[$field_name])) {
                          $pdf->Cell(0,8,$comments[$field_name],1,0,'L');
                      }
                  } */
        }
        // end while
        $pdf->SetFont('', '', 14);
        mysql_free_result($result);
    }
    //end each
}
示例#22
0
    $message = '';
    if ($nopass == 0 && isset($pma_pw) && isset($pma_pw2)) {
        if ($pma_pw != $pma_pw2) {
            $message = PMA_Message::error(__('The passwords aren\'t the same!'));
        } elseif (empty($pma_pw) || empty($pma_pw2)) {
            $message = PMA_Message::error(__('The password is empty!'));
        }
    }
    // end if
    // here $nopass could be == 1
    if (empty($message)) {
        $hashing_function = (!empty($pw_hash) && $pw_hash == 'old' ? 'OLD_' : '') . 'PASSWORD';
        // in $sql_query which will be displayed, hide the password
        $sql_query = 'SET PASSWORD FOR \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\' = ' . ($pma_pw == '' ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
        $local_query = 'SET PASSWORD FOR \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\' = ' . ($pma_pw == '' ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddSlashes($pma_pw) . '\')');
        PMA_DBI_try_query($local_query) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
        $message = PMA_Message::success(__('The password for %s was changed successfully.'));
        $message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
    }
}
/**
 * Deletes users
 *   (Changes / copies a user, part IV)
 */
if (isset($_REQUEST['delete']) || isset($_REQUEST['change_copy']) && $_REQUEST['mode'] < 4) {
    if (isset($_REQUEST['change_copy'])) {
        $selected_usr = array($old_username . '&amp;#27;' . $old_hostname);
    } else {
        $selected_usr = $_REQUEST['selected_usr'];
        $queries = array();
    }
        $message = isset($submit_move) ? $strMoveTableSameNames : $strCopyTableSameNames;
    } else {
        PMA_Table::moveCopy($db, $table, $target_db, $new_name, $what, isset($submit_move), 'one_table');
        $js_to_run = 'functions.js';
        $message = isset($submit_move) ? $strMoveTableOK : $strCopyTableOK;
        $message = sprintf($message, htmlspecialchars($table), htmlspecialchars($new_name));
        $reload = 1;
        /* Check: Work on new table or on old table? */
        if (isset($submit_move)) {
            $db = $target_db;
            $table = $new_name;
        } else {
            $pma_uri_parts = parse_url($cfg['PmaAbsoluteUri']);
            if (isset($switch_to_new) && $switch_to_new == 'true') {
                PMA_setCookie('pma_switch_to_new', 'true');
                $db = $target_db;
                $table = $new_name;
            } else {
                PMA_removeCookie('pma_switch_to_new');
            }
        }
    }
    require_once './libs/header.inc.php';
} else {
    require_once './libs/header.inc.php';
    PMA_mysqlDie($strTableEmpty, '', '', $err_url);
}
/**
 * Back to the calling script
 */
require './tbl_sql.php';
示例#24
0
/**
 * Sends the queries and buffers the results
 */
if (PMA_MYSQL_INT_VERSION >= 40003) {
    $res = @PMA_mysql_query('SHOW SESSION VARIABLES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW SESSION VARIABLES;');
    while ($row = PMA_mysql_fetch_row($res)) {
        $serverVars[$row[0]] = $row[1];
    }
    @mysql_free_result($res);
    $res = @PMA_mysql_query('SHOW GLOBAL VARIABLES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW GLOBAL VARIABLES;');
    while ($row = PMA_mysql_fetch_row($res)) {
        $serverVarsGlobal[$row[0]] = $row[1];
    }
    @mysql_free_result($res);
} else {
    $res = @PMA_mysql_query('SHOW VARIABLES;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW VARIABLES;');
    while ($row = PMA_mysql_fetch_row($res)) {
        $serverVars[$row[0]] = $row[1];
    }
    @mysql_free_result($res);
}
unset($res);
unset($row);
/**
 * Displays the page
 */
?>
<table border="0">
    <tr>
        <th>&nbsp;<?php 
echo $strVar;
示例#25
0
    unset($pieces);
}
// end if
/**
 * MySQL error
 */
if (isset($my_die)) {
    $js_to_run = 'functions.js';
    require_once './header.inc.php';
    if (is_array($my_die)) {
        foreach ($my_die as $key => $die_string) {
            PMA_mysqlDie('', $die_string, '', $err_url, FALSE);
            echo '<hr />';
        }
    } else {
        PMA_mysqlDie('', $my_die, '', $err_url, TRUE);
    }
}
/**
 * Go back to the calling script
 */
// Checks for a valid target script
if (isset($table) && $table == '') {
    unset($table);
}
if (isset($db) && $db == '') {
    unset($db);
}
$is_db = $is_table = FALSE;
if ($goto == 'tbl_properties.php') {
    if (!isset($table)) {
示例#26
0
/**
 * User is not allowed to login to MySQL -> authentication failed
 *
 * @global  string    the MySQL error message PHP returns
 * @global  string    the connection type (persistent or not)
 * @global  string    the MySQL server port to use
 * @global  string    the MySQL socket port to use
 * @global  array     the current server settings
 * @global  string    the font face to use in case of failure
 * @global  string    the default font size to use in case of failure
 * @global  string    the big font size to use in case of failure
 * @global  boolean   tell the "PMA_mysqlDie()" function headers have been
 *                    sent
 *
 * @return  boolean   always true (no return indeed)
 *
 * @access  public
 */
function PMA_auth_fails()
{
    global $php_errormsg, $cfg;
    $conn_error = PMA_DBI_getError();
    if (!$conn_error) {
        if (isset($php_errormsg)) {
            $conn_error = $php_errormsg;
        } else {
            $conn_error = $GLOBALS['strConnectionError'];
        }
    }
    // Defines the charset to be used
    header('Content-Type: text/html; charset=' . $GLOBALS['charset']);
    /* HTML header */
    $page_title = $GLOBALS['strAccessDenied'];
    require './libraries/header_meta_style.inc.php';
    ?>
</head>

<body>
<br /><br />
<center>
    <h1><?php 
    echo sprintf($GLOBALS['strWelcome'], ' phpMyAdmin ' . PMA_VERSION);
    ?>
</h1>
</center>
<br />
<table border="0" cellpadding="0" cellspacing="3" align="center" width="80%">
    <tr>
        <td>
    <?php 
    echo "\n";
    $GLOBALS['is_header_sent'] = TRUE;
    //TODO: I have included this div from libraries/header.inc.php to work around
    //      an undefined variable in tooltip.js, when the server
    //      is not responding. Work has to be done to merge all code that
    //      starts the page (DOCTYPE and this div) to one place
    ?>
    <div id="TooltipContainer" onmouseover="holdTooltip();" onmouseout="swapTooltip('default');"></div>
    <?php 
    if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
        echo '<p>' . $GLOBALS['strAccessDenied'] . '</p>' . "\n";
    } else {
        // Check whether user has configured something
        if ($_SESSION['PMA_Config']->source_mtime == 0) {
            echo '<p>' . sprintf($GLOBALS['strAccessDeniedCreateConfig'], '<a href="scripts/setup.php">', '</a>') . '</p>' . "\n";
        } elseif (!isset($GLOBALS['errno']) || isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002 && $GLOBALS['errno'] != 2003) {
            // if we display the "Server not responding" error, do not confuse users
            // by telling them they have a settings problem
            // (note: it's true that they could have a badly typed host name, but
            //  anyway the current $strAccessDeniedExplanation tells that the server
            //  rejected the connection, which is not really what happened)
            // 2002 is the error given by mysqli
            // 2003 is the error given by mysql
            echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
        }
        PMA_mysqlDie($conn_error, '', true, '', false);
    }
    if (!empty($GLOBALS['PMA_errors']) && is_array($GLOBALS['PMA_errors'])) {
        foreach ($GLOBALS['PMA_errors'] as $error) {
            echo '<div class="error">' . $error . '</div>' . "\n";
        }
    }
    ?>
        </td>
    </tr>
<?php 
    if (count($GLOBALS['cfg']['Servers']) > 1) {
        // offer a chance to login to other servers if the current one failed
        require_once './libraries/select_server.lib.php';
        echo '<tr>' . "\n";
        echo ' <td>' . "\n";
        PMA_select_server(TRUE, TRUE);
        echo ' </td>' . "\n";
        echo '</tr>' . "\n";
    }
    echo '</table>' . "\n";
    require_once './libraries/footer.inc.php';
    return TRUE;
}
示例#27
0
            $active_page = $goto;
            $message = PMA_Message::rawError($error);

            if ($GLOBALS['is_ajax_request'] == true) {
                PMA_ajaxResponse($message, false);
            }

            /**
             * Go to target path.
             */
            include '' . PMA_securePath($goto);
        } else {
            $full_err_url = (preg_match('@^(db|tbl)_@', $err_url))
                          ? $err_url . '&amp;show_query=1&amp;sql_query=' . urlencode($sql_query)
                          : $err_url;
            PMA_mysqlDie($error, $full_sql_query, '', $full_err_url);
        }
        exit;
    }
    unset($error);

    // Gets the number of rows affected/returned
    // (This must be done immediately after the query because
    // mysql_affected_rows() reports about the last query done)

    if (! $is_affected) {
        $num_rows = ($result) ? @PMA_DBI_num_rows($result) : 0;
    } elseif (! isset($num_rows)) {
        $num_rows = @PMA_DBI_affected_rows();
    }
示例#28
0
            $sql_query .= ' ADD UNIQUE ' . (empty($index) ? '' : PMA_backquote($index)) . ' (';
            break;
        case 'INDEX':
            $sql_query .= ' ADD INDEX ' . (empty($index) ? '' : PMA_backquote($index)) . ' (';
            break;
    }
    // end switch
    $index_fields = '';
    foreach ($column as $i => $name) {
        if ($name != '--ignore--') {
            $index_fields .= (empty($index_fields) ? '' : ',') . PMA_backquote($name) . (empty($sub_part[$i]) ? '' : '(' . $sub_part[$i] . ')');
        }
    }
    // end while
    if (empty($index_fields)) {
        PMA_mysqlDie($strNoIndexPartsDefined, '', FALSE, $err_url);
    } else {
        $sql_query .= $index_fields . ')';
    }
    $result = PMA_DBI_query($sql_query);
    $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
    $active_page = 'tbl_properties_structure.php';
    require './tbl_properties_structure.php';
} else {
    if (!defined('PMA_IDX_INCLUDED') && (isset($index) || isset($create_index))) {
        // Prepares the form values
        if (!isset($index)) {
            $index = '';
        }
        if (!isset($old_index)) {
            $old_index = $index;
示例#29
0
        } elseif (empty($pma_pw) || empty($pma_pw2)) {
            $message = PMA_Message::error(__('The password is empty!'));
        }
    } // end if

    // here $nopass could be == 1
    if (empty($message)) {

        $hashing_function = (! empty($pw_hash) && $pw_hash == 'old' ? 'OLD_' : '')
                      . 'PASSWORD';

        // in $sql_query which will be displayed, hide the password
        $sql_query        = 'SET PASSWORD FOR \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\' = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
        $local_query      = 'SET PASSWORD FOR \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\' = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddSlashes($pma_pw) . '\')');
        PMA_DBI_try_query($local_query)
            or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
        $message = PMA_Message::success(__('The password for %s was changed successfully.'));
        $message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
    }
}


/**
 * Deletes users
 *   (Changes / copies a user, part IV)
 */

if (isset($_REQUEST['delete']) || (isset($_REQUEST['change_copy']) && $_REQUEST['mode'] < 4)) {
    if (isset($_REQUEST['change_copy'])) {
        $selected_usr = array($old_username . '&amp;#27;' . $old_hostname);
    } else {
示例#30
0
        // garvin: Update comment table for mime types [MIME]
        if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
            foreach ($field_mimetype as $fieldindex => $mimetype) {
                if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
                    PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
                }
            }
        }
        // Go back to the structure sub-page
        $sql_query = $sql_query_cpy;
        unset($sql_query_cpy);
        $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
        $active_page = 'tbl_properties_structure.php';
        require './tbl_properties_structure.php';
    } else {
        PMA_mysqlDie('', '', '', $err_url, FALSE);
        // garvin: An error happened while inserting/updating a table definition.
        // to prevent total loss of that data, we embed the form once again.
        // The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php
        $num_fields = $orig_num_fields;
        if (isset($orig_after_field)) {
            $after_field = $orig_after_field;
        }
        if (isset($orig_field_where)) {
            $field_where = $orig_field_where;
        }
        $regenerate = true;
    }
}
// end do alter table
/**