【php开源代码栏目提醒】:网学会员,鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“tbl_query_box.php”一文,供大家参考学习!
<?php
/* $Id: tbl_query_box.php,v 2.33 2005/08/04 15:06:06 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
// Check parameters
require_once('./libraries/common.lib.php');
require_once('./libraries/bookmark.lib.php');
$upload_dir_error='';
// I don't see the purpose of the first 2 conditions
//if (!($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full'))) {
if (!(isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full'))) {
PMA_checkParameters(array('db','table','url_query'));
}
/**
* Defines the query to be displayed in the query textarea
*/
if (isset($show_query) && $show_query == '1') {
// This script has been called by read_dump.php
if (isset($sql_query_cpy)) {
$query_to_display = $sql_query_cpy;
}
// Other cases
else {
$query_to_display = $sql_query;
}
} else {
$query_to_display = '';
}
unset($sql_query);
/**
* Get the list and number of fields
*/
$fields_cnt = 0;
if (isset($db) && isset($table) && $table != '' && $db != '') {
// 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
$result = PMA_DBI_try_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
if ($result) {
$fields_cnt = PMA_DBI_num_rows($result);
while ($row = PMA_DBI_fetch_assoc($result)) {
$fields_list[] = $row['Field'];
} // end while
PMA_DBI_free_result($result);
} // end if
}
/**
* Work on the table
*/
if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full')) {
$locking = 'onkeypress="document.sqlform.elements[\'LockFromUpdate\'].checked = true;"';
} else {
$locking = '';
}
$auto_sel = ($cfg['TextareaAutoSelect']
// 2003-02-05 rabus: This causes big trouble with Opera 7 for
// Windows, so let's disable it there...
&& !(PMA_USR_OS == 'Win' && PMA_USR_BROWSER_AGENT == 'OPERA' && PMA_USR_BROWSER_VER >= 7))
? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; document.sqlform.elements[\'
sql_query\'].select();}"'
: '';
$auto_sel .= ' ' . $locking;
// garvin: If non-JS query window is embedded, display a list of databases to choose from.
// Apart from that, a non-js query window sucks badly.
/**
* Get the list and number of available databases.
*/
if ($server > 0) {
PMA_availableDatabases(); // this function is defined in "common.lib.php"
} else {
$num_dbs = 0;
}
if ($cfg['QueryFrame'] && (!$cfg['QueryFrameJS'] && !$db || ($cfg['QueryFrameJS'] && !$db))) {
if ($num_dbs > 0) {
$queryframe_db_list = '<select size=1 name="db" style="vertical-align: middle;">';
for ($i = 0; $i < $num_dbs; $i++) {
$t_db = $dblist[$i];
$queryframe_db_list .= '<option value="' . htmlspecialchars($t_db) . '">' . htmlspecialchars($t_db) . '</option>';
}
$queryframe_db_list .= '</select> ';
$queryframe_thcolspan = ' colspan="2"';
$queryframe_tdcolspan = '';
} else {
$queryframe_db_list = '';
$queryframe_thcolspan = ' colspan="3"';
$queryframe_tdcolspan = ' colspan="2"';
}
} else {
$queryframe_db_list = '';
if ($num_dbs > 0) {
$queryframe_thcolspan = ' colspan="3"';
$queryframe_tdcolspan = ' colspan="2"';
} else {
$queryframe_thcolspan = ' colspan="2"';
$queryframe_tdcolspan = '';
}
}
$form_items = 0;
// ($is_upload defined in common.lib.php)
if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && isset($is_inside_querywindow) && $is_inside_querywindow) {
?>
<script type="text/javascript">
<!--
document.writeln('<form method="post" target="phpmain' + <?php echo ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) ? 'opener.' : '');?>parent.frames.queryframe.document.hashform.hash.value + '" action="read_dump.php"<?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?> onsubmit="return checkSqlQuery(this)" name="sqlform">');
//-->
</script>
<?php
echo ' <noscript>' . "\n"
. ' <form method="post" target="phpmain' . md5($cfg['PmaAbsoluteUri']