⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sql_query_form.lib.php

📁 架設ROSE私服必備之物 ROSE數據庫
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/* $Id: sql_query_form.lib.php 9156 2006-07-03 15:01:45Z cybot_tm $ */// vim: expandtab sw=4 ts=4 sts=4:/** * functions for displaying the sql query form * * @usedby  server_sql.php * @usedby  db_details.php * @usedby  tbl_properties.php * @usedby  tbl_properties_structure.php * @usedby  querywindow.php */require_once './libraries/file_listing.php'; // used for file listingrequire_once './libraries/bookmark.lib.php'; // used for file listing/** * prints the sql query boxes * * @usedby  server_sql.php * @usedby  db_details.php * @usedby  tbl_properties.php * @usedby  tbl_properties_structure.php * @usedby  querywindow.php * @uses    $GLOBALS['table'] * @uses    $GLOBALS['db'] * @uses    $GLOBALS['server'] * @uses    $GLOBALS['goto'] * @uses    $GLOBALS['is_upload']           from common.lib.php * @uses    $GLOBALS['sql_query']           from grab_globals.lib.php * @uses    $GLOBALS['cfg']['DefaultQueryTable'] * @uses    $GLOBALS['cfg']['DefaultQueryDatabase'] * @uses    $GLOBALS['cfg']['Servers'] * @uses    $GLOBALS['cfg']['DefaultTabDatabase'] * @uses    $GLOBALS['cfg']['DefaultQueryDatabase'] * @uses    $GLOBALS['cfg']['DefaultQueryTable'] * @uses    $GLOBALS['cfg']['Bookmark']['db'] * @uses    $GLOBALS['cfg']['Bookmark']['table'] * @uses    $GLOBALS['strSuccess'] * @uses    PMA_generate_common_url() * @uses    PMA_backquote() * @uses    PMA_DBI_fetch_result() * @uses    PMA_showMySQLDocu() * @uses    PMA_generate_common_hidden_inputs() * @uses    PMA_sqlQueryFormBookmark() * @uses    PMA_sqlQueryFormInsert() * @uses    PMA_sqlQueryFormUpload() * @uses    PMA_DBI_QUERY_STORE * @uses    PMA_set_enc_form() * @uses    sprintf() * @uses    htmlspecialchars() * @uses    str_replace() * @uses    md5() * @uses    function_exists() * @param   boolean|string  $query          query to display in the textarea *                                          or true to display last executed * @param   boolean|string  $display_tab    sql|files|history|full|FALSE *                                          what part to display *                                          false if not inside querywindow */function PMA_sqlQueryForm($query = true, $display_tab = false){    // check tab to display if inside querywindow    if (! $display_tab) {        $display_tab = 'full';        $is_querywindow = false;    } else {        $is_querywindow = true;    }    // query to show    if (true === $query) {        $query = empty($GLOBALS['sql_query']) ? '' : $GLOBALS['sql_query'];    }    // set enctype to multipart for file uploads    if ($GLOBALS['is_upload']) {        $enctype = ' enctype="multipart/form-data"';    } else {        $enctype = '';    }    $table  = '';    $db     = '';    if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) {        // prepare for server related        $goto   = empty($GLOBALS['goto']) ?                    'server_sql.php' : $GLOBALS['goto'];    } elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) {        // prepare for db related        $db     = $GLOBALS['db'];        $goto   = empty($GLOBALS['goto']) ?                    'db_details.php' : $GLOBALS['goto'];    } else {        $table  = $GLOBALS['table'];        $db     = $GLOBALS['db'];        $goto   = empty($GLOBALS['goto']) ?                    'tbl_properties.php' : $GLOBALS['goto'];    }    // start output    if ($is_querywindow) {        ?>        <form method="post" id="sqlqueryform" target="frame_content"              action="import.php"<?php echo $enctype; ?> name="sqlform"              onsubmit="var save_name = window.opener.parent.frame_content.name;                        window.opener.parent.frame_content.name = save_name + '<?php echo time(); ?>';                        this.target = window.opener.parent.frame_content.name;                        return checkSqlQuery( this );" >        <?php    } else {        echo '<form method="post" action="import.php" ' . $enctype . ' id="sqlqueryform"'            .' onsubmit="return checkSqlQuery(this)" name="sqlform">' . "\n";    }    if ($is_querywindow) {        echo '<input type="hidden" name="focus_querywindow" value="true" />'            ."\n";        if ($display_tab != 'sql' && $display_tab != 'full') {            echo '<input type="hidden" name="sql_query" value="" />' . "\n";            echo '<input type="hidden" name="show_query" value="1" />' . "\n";        }    }    echo '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n"        .PMA_generate_common_hidden_inputs($db, $table) . "\n"        .'<input type="hidden" name="pos" value="0" />' . "\n"        .'<input type="hidden" name="goto" value="'        .htmlspecialchars($goto) . '" />' . "\n"        .'<input type="hidden" name="zero_rows" value="'        . htmlspecialchars($GLOBALS['strSuccess']) . '" />' . "\n"        .'<input type="hidden" name="prev_sql_query" value="'        . htmlspecialchars($query) . '" />' . "\n";    // display querybox    if ($display_tab === 'full' || $display_tab === 'sql') {        PMA_sqlQueryFormInsert($query, $is_querywindow);    }    // display uploads    if ($display_tab === 'files' && $GLOBALS['is_upload']) {        PMA_sqlQueryFormUpload();    }    // Bookmark Support    if ($display_tab === 'full' || $display_tab === 'history') {        if (! empty( $GLOBALS['cfg']['Bookmark'])          && $GLOBALS['cfg']['Bookmark']['db']          && $GLOBALS['cfg']['Bookmark']['table']) {            PMA_sqlQueryFormBookmark();        }    }    // Encoding setting form appended by Y.Kawada    if (function_exists('PMA_set_enc_form')) {        echo PMA_set_enc_form('    ');    }    echo '</form>' . "\n";    if ($is_querywindow) {        ?>        <script type="text/javascript" language="javascript">        //<![CDATA[            if (window.opener) {                window.opener.parent.insertQuery();            }        //]]>        </script>        <?php    }}/** * prints querybox fieldset * * @usedby  PMA_sqlQueryForm() * @uses    $GLOBALS['text_dir'] * @uses    $GLOBALS['cfg']['TextareaAutoSelect'] * @uses    $GLOBALS['cfg']['TextareaCols'] * @uses    $GLOBALS['cfg']['TextareaRows'] * @uses    $GLOBALS['strShowThisQuery'] * @uses    $GLOBALS['strGo'] * @uses    PMA_availableDatabases() * @uses    PMA_USR_OS * @uses    PMA_USR_BROWSER_AGENT * @uses    PMA_USR_BROWSER_VER * @uses    PMA_availableDatabases() * @uses    htmlspecialchars() * @param   string      $query          query to display in the textarea * @param   boolean     $is_querywindow if inside querywindow or not */function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false){    // enable auto select text in textarea    if ($GLOBALS['cfg']['TextareaAutoSelect']) {        $auto_sel = ' onfocus="selectContent( this, sql_box_locked, true )"';    } else {        $auto_sel = '';    }    // enable locking if inside query window    if ($is_querywindow) {        $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].'            .'checked = true;"';    } else {        $locking = '';    }    $table          = '';    $db             = '';    $fields_list    = array();    if (! isset($GLOBALS['db']) || ! strlen($GLOBALS['db'])) {        // prepare for server related        $legend = sprintf($GLOBALS['strRunSQLQueryOnServer'],            htmlspecialchars(                $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']));    } elseif (! isset($GLOBALS['table']) || ! strlen($GLOBALS['table'])) {        // prepare for db related        $db     = $GLOBALS['db'];        // if you want navigation:        $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']            . '?' . PMA_generate_common_url($db) . '"';        if ($is_querywindow) {            $strDBLink .= ' target="_self"'                . ' onclick="this.target=window.opener.frame_content.name"';        }        $strDBLink .= '>'            . htmlspecialchars($db) . '</a>';        // else use        // $strDBLink = htmlspecialchars($db);        $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);        if (empty($query)) {            $query = str_replace('%d',                PMA_backquote($db), $GLOBALS['cfg']['DefaultQueryDatabase']);        }    } else {        $table  = $GLOBALS['table'];        $db     = $GLOBALS['db'];        // Get the list and number of fields        // we do a try_query here, because we could be in the query window,        // trying to synchonize and the table has not yet been created        $fields_list = PMA_DBI_fetch_result(            'SHOW FULL COLUMNS FROM ' . PMA_backquote($db)            . '.' . PMA_backquote($GLOBALS['table']));        $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']            . '?' . PMA_generate_common_url($db) . '"';        if ($is_querywindow) {            $strDBLink .= ' target="_self"'                . ' onclick="this.target=window.opener.frame_content.name"';        }        $strDBLink .= '>'            . htmlspecialchars($db) . '</a>';        // else use        // $strDBLink = htmlspecialchars($db);        $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);        if (empty($query) && count($fields_list)) {            $field_names = array();            foreach ($fields_list as $field) {                $field_names[] = PMA_backquote($field['Field']);            }            $query =                str_replace('%d', PMA_backquote($db),                    str_replace('%t', PMA_backquote($table),                        str_replace('%f',                            implode(', ', $field_names ),                            $GLOBALS['cfg']['DefaultQueryTable'])));            unset($field_names);        }    }    $legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');    if (count($fields_list)) {        $sqlquerycontainer_id = 'sqlquerycontainer';    } else {        $sqlquerycontainer_id = 'sqlquerycontainerfull';    }    echo '<a name="querybox"></a>' . "\n"        .'<div id="queryboxcontainer">' . "\n"        .'<fieldset id="querybox">' . "\n";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -