Bookmark Support

This commit is contained in:
Armel Fauveau
2001-05-07 03:59:13 +00:00
parent 8649b504a2
commit 0a35c11957
8 changed files with 135 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ CREDITS, in chronological order
[lc] - Lo<4C>c Chapeaux <lolo@phpHeaven.net>
[mg] - Mirko Giese <mgiese@users.sourceforge.net>
[rj] - Robin Johnson <robbat2@users.sourceforge.net>
[af] - Armel Fauveau <webmaster@phpindex.com>
[xx] - ... (to be completed)

View File

@@ -6,17 +6,32 @@
* All directives are explained in Documentation.html
*/
/*
* Bookmark Table Structure
*
* CREATE TABLE bookmark (
* id int(11) DEFAULT '0' NOT NULL auto_increment,
* dbase varchar(255) NOT NULL,
* label varchar(255) NOT NULL,
* query text NOT NULL,
* PRIMARY KEY (id)
* );
*
*/
// The $cfgServers array starts with $cfgServers[1]. Do not use $cfgServers[0].
// You can disable a server config entry by setting host to ''.
$cfgServers[1]['host'] = 'localhost'; // MySQL hostname
$cfgServers[1]['port'] = ''; // MySQL port - leave blank for default port
$cfgServers[1]['adv_auth'] = false; // Use advanced authentication?
$cfgServers[1]['stduser'] = ''; // MySQL standard user (only needed with advanced auth)
$cfgServers[1]['stduser'] = ''; // MySQL standard user (only needed with advanced auth)
$cfgServers[1]['stdpass'] = ''; // MySQL standard password (only needed with advanced auth)
$cfgServers[1]['user'] = 'phpMyAdmin'; // MySQL user (only needed with basic auth)
$cfgServers[1]['password'] = 'test99'; // MySQL password (only needed with basic auth)
$cfgServers[1]['only_db'] = 'phpMyAdmin'; // If set to a db-name, only this db is accessible
$cfgServers[1]['user'] = 'phpMyAdmin'; // MySQL user (only needed with basic auth)
$cfgServers[1]['password'] = 'test99'; // MySQL password (only needed with basic auth)
$cfgServers[1]['only_db'] = 'phpMyAdmin'; // If set to a db-name, only this db is accessible
$cfgServers[1]['verbose'] = ''; // Verbose name for this host - leave blank to show the hostname
$cfgServers[1]['bookmarkdb'] = ''; // Bookmark db - leave blank for no bookmark support
$cfgServers[1]['bookmarktable'] = ''; // Bookmark table - leave blank for no bookmark support
$cfgServers[2]['host'] = '';
$cfgServers[2]['port'] = '';
@@ -27,6 +42,8 @@ $cfgServers[2]['user'] = 'root';
$cfgServers[2]['password'] = '';
$cfgServers[2]['only_db'] = '';
$cfgServers[2]['verbose'] = '';
$cfgServers[2]['bookmarkdb'] = ''; // Bookmark db - leave blank for no bookmark support
$cfgServers[2]['bookmarktable'] = ''; // Bookmark table - leave blank for no bookmark support
$cfgServers[3]['host'] = '';
$cfgServers[3]['port'] = '';
@@ -37,6 +54,8 @@ $cfgServers[3]['user'] = 'root';
$cfgServers[3]['password'] = '';
$cfgServers[3]['only_db'] = '';
$cfgServers[3]['verbose'] = '';
$cfgServers[3]['bookmarkdb'] = ''; // Bookmark db - leave blank for no bookmark support
$cfgServers[3]['bookmarktable'] = ''; // Bookmark table - leave blank for no bookmark support
// If you have more than one server configured, you can set $cfgServerDefault
// to any one of them to autoconnect to that server when phpMyAdmin is started,
@@ -63,11 +82,9 @@ $cfgOrder = "ASC";
$cfgShowBlob = true;
$cfgShowSQL = true;
$cfgModifyDeleteAtLeft = true;
$cfgModifyDeleteAtRight = false;
$cfgDefaultLang = "en"; // default language to use, if not browser-defined or user-defined
// $cfgLang = "en"; // force: always use this language - must be defined in select_lang.inc.php3
require("select_lang.inc.php3"); // load language file

View File

@@ -1,10 +1,7 @@
<?php
/* $Id$ */
require("grab_globals.inc.php3");
if(!isset($message))
{
@@ -73,6 +70,24 @@ $query = "?server=$server&lang=$lang&db=$db&goto=db_details.php3";
echo $cfgMaxInputsize;?>"></textarea><br>
<?php echo "<i>$strOr</i> $strLocationTextfile";?>:<br>
<input type="file" name="sql_file"><br>
<?php
// Bookmark Support
if($cfgBookmark['db'] && $cfgBookmark['table'])
{
if(($bookmark_list=list_bookmarks($db, $cfgBookmark)) && count($bookmark_list)>0)
{
echo "<i>$strOr</i> $strBookmarkQuery:<br>\n";
echo "<select name=\"sql_bookmark\">\n";
echo "<option value=\"\"></option>\n";
while(list($key,$value)=each($bookmark_list)) {
echo "<option value=\"".htmlentities($value)."\">".htmlentities($key)."</option>\n";
}
echo "</select>\n";
echo "<br>\n";
}
}
?>
<input type="submit" name="SQL" value="<?php echo $strGo; ?>">
</form>
<li><a href="tbl_qbe.php3<?php echo $query;?>"><?php echo $strQBE;?></a>

View File

@@ -9,6 +9,13 @@ require("grab_globals.inc.php3");
include("lib.inc.php3");
// Bookmark Support
if($sql_bookmark != "")
$sql_query = $sql_bookmark;
//
if(!empty($sql_file) && $sql_file != "none" && ereg("^php[0-9A-Za-z_.-]+$", basename($sql_file))) {
$sql_query = fread(fopen($sql_file, "r"), filesize($sql_file));
}

View File

@@ -149,4 +149,8 @@ $strCheckTable = "Check table";
$strAnalyzeTable = "Analyze table";
$strRepairTable = "Repair table";
$strOptimizeTable = "Optimize table";
$strBookmarkQuery = "Bookmarked SQL-query";
$strBookmarkThis = "Bookmark this SQL-query";
$strBookmarkLabel = "Label";
?>

View File

@@ -168,4 +168,8 @@ $strAnalyzeTable = "Analyze table"; //to translate
$strRepairTable = "Repair table"; //to translate
$strOptimizeTable = "Optimize table"; //to translate
$strTableType = "Table type"; //to translate
$strBookmarkQuery = "Requ<EFBFBD>tes bookmark<72>es";
$strBookmarkThis = "Bookmarker cette requ<71>te";
$strBookmarkLabel = "Label";
?>

View File

@@ -682,6 +682,56 @@ function split_string($sql, $delimiter) {
return($ret);
}
// Bookmark Support
function get_bookmarks_param() {
global $cfgServers;
global $cfgServer;
global $server;
$i=1;
while($i<=sizeof($cfgServers)) {
if($cfgServer['adv_auth']) {
if(($cfgServers[$i]['host']==$cfgServer['host'] || $cfgServers[$i]['host']=='') && $cfgServers[$i]['adv_auth']==true && $cfgServers[$i]['stduser']==$cfgServer['user'] && $cfgServers[$i]['stdpass']==$cfgServer['password']) {
$cfgBookmark['db']=$cfgServers[$i]['bookmarkdb'];
$cfgBookmark['table']=$cfgServers[$i]['bookmarktable'];
break;
}
}
else {
if(($cfgServers[$i]['host']==$cfgServer['host'] || $cfgServers[$i]['host']=='') && $cfgServers[$i]['adv_auth']==false && $cfgServers[$i]['user']==$cfgServer['user'] && $cfgServers[$i]['password']==$cfgServer['password']) {
$cfgBookmark['db']=$cfgServers[$i]['bookmarkdb'];
$cfgBookmark['table']=$cfgServers[$i]['bookmarktable'];
break;
}
}
$i++;
}
return $cfgBookmark;
}
function list_bookmarks($db, $cfgBookmark) {
$query="SELECT label, query FROM ".$cfgBookmark['db'].".".$cfgBookmark['table']." WHERE dbase='$db'";
$result=mysql_db_query($cfgBookmark['db'], $query);
if($result>0 && mysql_num_rows($result)>0)
{
$flag = 1;
while($row = mysql_fetch_row($result))
{
$bookmark_list["$flag - ".$row[0]] = $row[1];
$flag++;
}
return $bookmark_list;
}
else
return false;
}
$cfgBookmark=get_bookmarks_param();
} // $__LIB_INC__
// -----------------------------------------------------------------
?>

View File

@@ -104,8 +104,35 @@ else {
include("header.inc.php3");
display_table($result);
if(!eregi("SHOW VARIABLES|SHOW PROCESSLIST|SHOW STATUS", $sql_query))
{
echo "<p><a href=\"tbl_change.php3?server=$server&lang=$lang&db=$db&table=$table&pos=$pos&goto=$goto&sql_query=".urlencode($sql_query)."\"> $strInsertNewRow</a></p>";
// Bookmark Support
if($cfgBookmark['db'] && $cfgBookmark['table'] && $db!=$cfgBookmark['db'] && !$sql_bookmark)
{
echo "<form method=\"post\" action=\"tbl_replace.php3\">\n";
echo "<i>$strOr</i><br><br>\n";
echo $strBookmarkLabel.":\n";
$goto="sql.php3?server=$server&lang=$lang&db=$db&table=$table&pos=$pos&sql_bookmark=1&sql_query=".urlencode($sql_query);
?>
<input type="hidden" name="server" value="<?php echo $server;?>">
<input type="hidden" name="lang" value="<?php echo $lang;?>">
<input type="hidden" name="db" value="<?php echo $cfgBookmark['db'];?>">
<input type="hidden" name="table" value="<?php echo $cfgBookmark['table'] ;?>">
<input type="hidden" name="goto" value="<?php echo $goto;?>">
<input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0;?>">
<input type="hidden" name="funcs[id]" value="NULL"?>
<input type="hidden" name="fields[dbase]" value="<?php echo $db;?>">
<input type="hidden" name="fields[query]" value="<?php echo isset($sql_query) ? $sql_query : "";?>">
<input type="text" name="fields[label]" value="">
<input type="submit" value="<?php echo $strBookmarkThis; ?>">
</form>
<?php
}
echo "</p>";
}
}
} //ne drop query
require ("footer.inc.php3");
?>
?>