common.lib.php
来自「php绿色服务器,让大家试用greenamp」· PHP 代码 · 共 1,687 行 · 第 1/5 页
PHP
1,687 行
* @param string string to search for * @param mixed array to search into * * @return integer the rank of the $toFind string in the array or '-1' if * it hasn't been found * * @access public */ function PMA_isInto($toFind = '', &$in) { $max = count($in); for ($i = 0; $i < $max && ($toFind != $in[$i]); $i++) { // void(); } return ($i < $max) ? $i : -1; } // end of the 'PMA_isInto()' function /** * Returns a string formatted with CONVERT ... USING * if MySQL supports it * * @param string the string itself * @param string the mode: quoted or unquoted (this one by default) * * @return the formatted string * * @access private */ function PMA_convert_using($string, $mode='unquoted') { if ($mode == 'quoted') { $possible_quote = "'"; } else { $possible_quote = ""; } if (PMA_MYSQL_INT_VERSION >= 40100) { list($conn_charset) = explode('_', $GLOBALS['collation_connection']); $converted_string = "CONVERT(" . $possible_quote . $string . $possible_quote . " USING " . $conn_charset . ")"; } else { $converted_string = $possible_quote . $string . $possible_quote; } return $converted_string; } // end function}/** * Get the complete list of Databases a user can access * * @param boolean whether to include check on failed 'only_db' operations * @param resource database handle (superuser) * @param integer amount of databases inside the 'only_db' container * @param resource possible resource from a failed previous query * @param resource database handle (user) * @param array configuration * @param array previous list of databases * * @return array all databases a user has access to * * @access private */function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cfg, $dblist) { if ($only_db_check == FALSE) { // try to get the available dbs list // use userlink by default $dblist = PMA_DBI_get_dblist(); $dblist_cnt = count($dblist); // did not work so check for available databases in the "mysql" db; // I don't think we can fall here now... if (!$dblist_cnt) { $auth_query = 'SELECT User, Select_priv ' . 'FROM mysql.user ' . 'WHERE User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\''; $rs = PMA_DBI_try_query($auth_query, $dbh); } // end } // Access to "mysql" db allowed and dblist still empty -> gets the // usable db list if (!$dblist_cnt && ($rs && @PMA_DBI_num_rows($rs))) { $row = PMA_DBI_fetch_assoc($rs); PMA_DBI_free_result($rs); // Correction uva 19991215 // Previous code assumed database "mysql" admin table "db" column // "db" contains literal name of user database, and works if so. // Mysql usage generally (and uva usage specifically) allows this // column to contain regular expressions (we have all databases // owned by a given student/faculty/staff beginning with user i.d. // and governed by default by a single set of privileges with // regular expression as key). This breaks previous code. // This maintenance is to fix code to work correctly for regular // expressions. if ($row['Select_priv'] != 'Y') { // 1. get allowed dbs from the "mysql.db" table // lem9: User can be blank (anonymous user) $local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND (User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\' OR User = \'\')'; $rs = PMA_DBI_try_query($local_query, $dbh); if ($rs && @PMA_DBI_num_rows($rs)) { // Will use as associative array of the following 2 code // lines: // the 1st is the only line intact from before // correction, // the 2nd replaces $dblist[] = $row['Db']; $uva_mydbs = array(); // Code following those 2 lines in correction continues // populating $dblist[], as previous code did. But it is // now populated with actual database names instead of // with regular expressions. while ($row = PMA_DBI_fetch_assoc($rs)) { // loic1: all databases cases - part 1 if (empty($row['Db']) || $row['Db'] == '%') { $uva_mydbs['%'] = 1; break; } // loic1: avoid multiple entries for dbs if (!isset($uva_mydbs[$row['Db']])) { $uva_mydbs[$row['Db']] = 1; } } // end while PMA_DBI_free_result($rs); $uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['dbh']); // loic1: all databases cases - part 2 if (isset($uva_mydbs['%'])) { while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) { $dblist[] = $uva_row[0]; } // end while } // end if else { while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) { $uva_db = $uva_row[0]; if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) { $dblist[] = $uva_db; $uva_mydbs[$uva_db] = 0; } else if (!isset($dblist[$uva_db])) { foreach ($uva_mydbs AS $uva_matchpattern => $uva_value) { // loic1: fixed bad regexp // TODO: db names may contain characters // that are regexp instructions $re = '(^|(\\\\\\\\)+|[^\])'; $uva_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $uva_matchpattern)); // Fixed db name matching // 2000-08-28 -- Benjamin Gandon if (ereg('^' . $uva_regex . '$', $uva_db)) { $dblist[] = $uva_db; break; } } // end while } // end if ... else if.... } // end while } // end else PMA_DBI_free_result($uva_alldbs); unset($uva_mydbs); } // end if // 2. get allowed dbs from the "mysql.tables_priv" table $local_query = 'SELECT DISTINCT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\''; $rs = PMA_DBI_try_query($local_query, $dbh); if ($rs && @PMA_DBI_num_rows($rs)) { while ($row = PMA_DBI_fetch_assoc($rs)) { if (PMA_isInto($row['Db'], $dblist) == -1) { $dblist[] = $row['Db']; } } // end while PMA_DBI_free_result($rs); } // end if } // end if } // end building available dbs from the "mysql" db return $dblist;}/** * Determines the font sizes to use depending on the os and browser of the * user. * * This function is based on an article from phpBuilder (see * http://www.phpbuilder.net/columns/tim20000821.php). * * @return boolean always true * * @global string the standard font size * @global string the font size for titles * @global string the small font size * @global string the smallest font size * * @access public * * @version 1.1 */function PMA_setFontSizes(){ global $font_size, $font_biggest, $font_bigger, $font_smaller, $font_smallest; // IE (<7)/Opera (<7) for win case: needs smaller fonts than anyone else if (PMA_USR_OS == 'Win' && ((PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 7) || (PMA_USR_BROWSER_AGENT == 'OPERA' && PMA_USR_BROWSER_VER < 7))) { $font_size = 'x-small'; $font_biggest = 'large'; $font_bigger = 'medium'; $font_smaller = '90%'; $font_smallest = '7pt'; } // IE6 and other browsers for win case else if (PMA_USR_OS == 'Win') { $font_size = 'small'; $font_biggest = 'large'; $font_bigger = 'medium'; $font_smaller = (PMA_USR_BROWSER_AGENT == 'IE') ? '90%' : 'x-small'; $font_smallest = 'x-small'; } // Some mac browsers need also smaller default fonts size (OmniWeb & // Opera)... // and a beta version of Safari did also, but not the final 1.0 version // so I remove || PMA_USR_BROWSER_AGENT == 'SAFARI' // but we got a report that Safari 1.0 build 85.5 needs it! else if (PMA_USR_OS == 'Mac' && (PMA_USR_BROWSER_AGENT == 'OMNIWEB' || PMA_USR_BROWSER_AGENT == 'OPERA' || PMA_USR_BROWSER_AGENT == 'SAFARI')) { $font_size = 'x-small'; $font_biggest = 'large'; $font_bigger = 'medium'; $font_smaller = '90%'; $font_smallest = '7pt'; } // ... but most of them (except IE 5+ & NS 6+) need bigger fonts else if ((PMA_USR_OS == 'Mac' && ((PMA_USR_BROWSER_AGENT != 'IE' && PMA_USR_BROWSER_AGENT != 'MOZILLA') || PMA_USR_BROWSER_VER < 5)) || PMA_USR_BROWSER_AGENT == 'KONQUEROR') { $font_size = 'medium'; $font_biggest = 'x-large'; $font_bigger = 'large'; $font_smaller = 'small'; $font_smallest = 'x-small'; } // OS/2 browser else if (PMA_USR_OS == 'OS/2' && PMA_USR_BROWSER_AGENT == 'OPERA') { $font_size = 'small'; $font_biggest = 'medium'; $font_bigger = 'medium'; $font_smaller = 'x-small'; $font_smallest = 'x-small'; } else { $font_size = 'small'; $font_biggest = 'large'; $font_bigger = 'medium'; $font_smaller = 'x-small'; $font_smallest = 'x-small'; } return TRUE;} // end of the 'PMA_setFontSizes()' functionif ($is_minimum_common == FALSE) { /** * $cfg['PmaAbsoluteUri'] is a required directive else cookies won't be * set properly and, depending on browsers, inserting or updating a * record might fail */ $display_pmaAbsoluteUri_warning = 0; // Setup a default value to let the people and lazy syadmins work anyway, // but display a big warning on the main.php page. if (empty($cfg['PmaAbsoluteUri'])) { $url = array(); // At first we try to parse REQUEST_URI, it might contain full URI if (!empty($_SERVER['REQUEST_URI'])) { $url = parse_url($_SERVER['REQUEST_URI']); } // If we don't have scheme, we didn't have full URL so we need to dig deeper if (empty($url['scheme'])) { // Scheme if (!empty($_SERVER['HTTP_SCHEME'])) { $url['scheme'] = $_SERVER['HTTP_SCHEME']; } else { $url['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'; } // Host and port if (!empty($_SERVER['HTTP_HOST'])) { if (strpos($_SERVER['HTTP_HOST'], ':') > 0) { list($url['host'], $url['port']) = explode(':', $_SERVER['HTTP_HOST']); } else { $url['host'] = $_SERVER['HTTP_HOST']; } } else if (!empty($_SERVER['SERVER_NAME'])) { $url['host'] = $_SERVER['SERVER_NAME']; } else { header('Content-Type: text/html; charset=' . $charset); // Displays the error message ?><!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 $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>"><head><title>phpMyAdmin</title><meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" /><style type="text/css"><!--body {font-family: sans-serif; font-size: small; color: #000000; background-color: #F5F5F5}h1 {font-family: sans-serif; font-size: large; font-weight: bold}//--></style></head><body bgcolor="#ffffff"><h1>phpMyAdmin - <?php echo $strError; ?></h1><p><?php echo $strPmaUriError; ?><br /><br /></p></body></html> <?php exit(); } // If we didn't set port yet... if (empty($url['port']) && !empty($_SERVER['SERVER_PORT'])) { $url['port'] = $_SERVER['SERVER_PORT'];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?