Documentation TYPO3 par Ameos

bookmark.lib.php

00001 <?php
00002 /* $Id: bookmark.lib.php,v 2.2 2003/11/26 22:52:23 rabus Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00019 function PMA_getBookmarksParam()
00020 {
00021     global $server;
00022 
00023     $cfgBookmark = '';
00024 
00025     // No server selected -> no bookmark table
00026     if ($server == 0) {
00027         return '';
00028     }
00029 
00030     $cfgBookmark['user']  = $GLOBALS['cfg']['Server']['user'];
00031     $cfgBookmark['db']    = $GLOBALS['cfg']['Server']['pmadb'];
00032     $cfgBookmark['table'] = $GLOBALS['cfg']['Server']['bookmarktable'];
00033 
00034     return $cfgBookmark;
00035 } // end of the 'PMA_getBookmarksParam()' function
00036 
00037 
00048 function PMA_listBookmarks($db, $cfgBookmark)
00049 {
00050     $query  = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00051             . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
00052             . ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
00053             . '      OR user = \'\')';
00054     if (isset($GLOBALS['dbh'])) {
00055         $result = PMA_mysql_query($query, $GLOBALS['dbh']);
00056     } else {
00057         $result = PMA_mysql_query($query);
00058     }
00059 
00060     // There is some bookmarks -> store them
00061     if ($result > 0 && mysql_num_rows($result) > 0) {
00062         $flag = 1;
00063         while ($row = PMA_mysql_fetch_row($result)) {
00064             $bookmark_list[$flag . ' - ' . $row[0]] = $row[1];
00065             $flag++;
00066         } // end while
00067         return $bookmark_list;
00068     }
00069     // No bookmarks for the current database
00070     else {
00071         return FALSE;
00072     }
00073 } // end of the 'PMA_listBookmarks()' function
00074 
00075 
00088 function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
00089 {
00090 
00091     if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
00092         return '';
00093     }
00094 
00095     $query          = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00096                     . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
00097                     . ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
00098                     . '      OR user = \'\')'
00099                     . ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
00100     if (isset($GLOBALS['dbh'])) {
00101         $result = PMA_mysql_query($query, $GLOBALS['dbh']);
00102     } else {
00103         $result = PMA_mysql_query($query);
00104     }
00105     $bookmark_query = @PMA_mysql_result($result, 0, 'query') OR FALSE;
00106 
00107     return $bookmark_query;
00108 } // end of the 'PMA_queryBookmarks()' function
00109 
00110 
00122 function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
00123 {
00124     $query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00125            . ' (id, dbase, user, query, label) VALUES (\'\', \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
00126     if (isset($GLOBALS['dbh'])) {
00127         $result   = PMA_mysql_query($query, $GLOBALS['dbh']);
00128         if (PMA_mysql_error($GLOBALS['dbh'])) {
00129            $error = PMA_mysql_error($GLOBALS['dbh']);
00130            require_once('./header.inc.php');
00131            PMA_mysqlDie($error);
00132         }
00133     } else {
00134         $result   = PMA_mysql_query($query);
00135         if (PMA_mysql_error()) {
00136            $error = PMA_mysql_error();
00137            require_once('./header.inc.php');
00138            PMA_mysqlDie($error);
00139         }
00140     }
00141 
00142     return TRUE;
00143 } // end of the 'PMA_addBookmarks()' function
00144 
00145 
00155 function PMA_deleteBookmarks($db, $cfgBookmark, $id)
00156 {
00157     $query  = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
00158             . ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
00159             . '        OR user = \'\')'
00160             . ' AND id = ' . $id;
00161     if (isset($GLOBALS['dbh'])) {
00162         $result = PMA_mysql_query($query, $GLOBALS['dbh']);
00163     } else {
00164         $result = PMA_mysql_query($query);
00165     }
00166 } // end of the 'PMA_deleteBookmarks()' function
00167 
00168 
00172 $cfg['Bookmark'] = PMA_getBookmarksParam();
00173 
00174 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6