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

📄 common.lib.php

📁 一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
/** * Converts numbers like 10M into bytes * * @param   string  $size * @return  integer $size */function get_real_size($size = 0){    if (!$size) {        return 0;    }    $scan['MB'] = 1048576;    $scan['Mb'] = 1048576;    $scan['M']  = 1048576;    $scan['m']  = 1048576;    $scan['KB'] =    1024;    $scan['Kb'] =    1024;    $scan['K']  =    1024;    $scan['k']  =    1024;    while (list($key) = each($scan)) {        if ((strlen($size) > strlen($key))          && (substr($size, strlen($size) - strlen($key)) == $key)) {            $size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key];            break;        }    }    return $size;} // end function get_real_size()/** * loads php module * * @uses    PHP_OS * @uses    extension_loaded() * @uses    ini_get() * @uses    function_exists() * @uses    ob_start() * @uses    phpinfo() * @uses    strip_tags() * @uses    ob_get_contents() * @uses    ob_end_clean() * @uses    preg_match() * @uses    strtoupper() * @uses    substr() * @uses    dl() * @param   string  $module name if module to load * @return  boolean success loading module */function PMA_dl($module){    static $dl_allowed = null;    if (extension_loaded($module)) {        return true;    }    if (null === $dl_allowed) {        if (!@ini_get('safe_mode')          && @ini_get('enable_dl')          && @function_exists('dl')) {            ob_start();            phpinfo(INFO_GENERAL); /* Only general info */            $a = strip_tags(ob_get_contents());            ob_end_clean();            if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {                if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {                    $dl_allowed = true;                } else {                    $dl_allowed = false;                }            } else {                $dl_allowed = true;            }        } else {            $dl_allowed = false;        }    }    if (!$dl_allowed) {        return false;    }    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {        $module_file = 'php_' . $module . '.dll';    } else {        $module_file = $module . '.so';    }    return @dl($module_file);}/** * merges array recursive like array_merge_recursive() but keyed-values are * always overwritten. * * array PMA_array_merge_recursive(array $array1[, array $array2[, array ...]]) * * @see     http://php.net/array_merge * @see     http://php.net/array_merge_recursive * @uses    func_num_args() * @uses    func_get_arg() * @uses    is_array() * @uses    call_user_func_array() * @param   array   array to merge * @param   array   array to merge * @param   array   ... * @return  array   merged array */function PMA_array_merge_recursive(){    switch(func_num_args()) {        case 0 :            return false;            break;        case 1 :            // when does that happen?            return func_get_arg(0);            break;        case 2 :            $args = func_get_args();            if (!is_array($args[0]) || !is_array($args[1])) {                return $args[1];            }            foreach ($args[1] AS $key2 => $value2) {                if (isset($args[0][$key2]) && !is_int($key2)) {                    $args[0][$key2] = PMA_array_merge_recursive($args[0][$key2],                        $value2);                } else {                    // we erase the parent array, otherwise we cannot override a directive that                    // contains array elements, like this:                    // (in config.default.php) $cfg['ForeignKeyDropdownOrder'] = array('id-content','content-id');                    // (in config.inc.php) $cfg['ForeignKeyDropdownOrder'] = array('content-id');                    if (is_int($key2) && $key2 == 0) {                        unset($args[0]);                    }                    $args[0][$key2] = $value2;                }            }            return $args[0];            break;        default :            $args = func_get_args();            $args[1] = PMA_array_merge_recursive($args[0], $args[1]);            array_shift($args);            return call_user_func_array('PMA_array_merge_recursive', $args);            break;    }}/** * calls $function vor every element in $array recursively * * @param   array   $array      array to walk * @param   string  $function   function to call for every array element */function PMA_arrayWalkRecursive(&$array, $function, $apply_to_keys_also = false){    foreach ($array as $key => $value) {        if (is_array($value)) {            PMA_arrayWalkRecursive($array[$key], $function, $apply_to_keys_also);        } else {            $array[$key] = $function($value);        }        if ($apply_to_keys_also && is_string($key)) {            $new_key = $function($key);            if ($new_key != $key) {                $array[$new_key] = $array[$key];                unset($array[$key]);            }        }    }}/** * boolean phpMyAdmin.PMA_checkPageValidity(string &$page, array $whitelist) * * checks given given $page against given $whitelist and returns true if valid * it ignores optionaly query paramters in $page (script.php?ignored) * * @uses    in_array() * @uses    urldecode() * @uses    substr() * @uses    strpos() * @param   string  &$page      page to check * @param   array   $whitelist  whitelist to check page against * @return  boolean whether $page is valid or not (in $whitelist or not) */function PMA_checkPageValidity(&$page, $whitelist){    if (! isset($page)) {        return false;    }    if (in_array($page, $whitelist)) {        return true;    } elseif (in_array(substr($page, 0, strpos($page . '?', '?')), $whitelist)) {        return true;    } else {        $_page = urldecode($page);        if (in_array(substr($_page, 0, strpos($_page . '?', '?')), $whitelist)) {            return true;        }    }    return false;}/** * trys to find the value for the given environment vriable name * * searchs in $_SERVER, $_ENV than trys getenv() and apache_getenv() * in this order * * @param   string  $var_name   variable name * @return  string  value of $var or empty string */function PMA_getenv($var_name) {    if (isset($_SERVER[$var_name])) {        return $_SERVER[$var_name];    } elseif (isset($_ENV[$var_name])) {        return $_ENV[$var_name];    } elseif (getenv($var_name)) {        return getenv($var_name);    } elseif (function_exists('apache_getenv')     && apache_getenv($var_name, true)) {        return apache_getenv($var_name, true);    }    return '';}/** * include here only libraries which contain only function definitions * no code im main()! *//* Input sanitizing */require_once './libraries/sanitizing.lib.php';require_once './libraries/Theme.class.php';require_once './libraries/Theme_Manager.class.php';require_once './libraries/Config.class.php';if (!defined('PMA_MINIMUM_COMMON')) {    /**     * Displays the maximum size for an upload     *     * @param   integer  the size     *     * @return  string   the message     *     * @access  public     */     function PMA_displayMaximumUploadSize($max_upload_size)     {         list($max_size, $max_unit) = PMA_formatByteDown($max_upload_size);         return '(' . sprintf($GLOBALS['strMaximumSize'], $max_size, $max_unit) . ')';     }    /**     * Generates a hidden field which should indicate to the browser     * the maximum size for upload     *     * @param   integer  the size     *     * @return  string   the INPUT field     *     * @access  public     */     function PMA_generateHiddenMaxFileSize($max_size)     {         return '<input type="hidden" name="MAX_FILE_SIZE" value="' .$max_size . '" />';     }    /**     * Add slashes before "'" and "\" characters so a value containing them can     * be used in a sql comparison.     *     * @param   string   the string to slash     * @param   boolean  whether the string will be used in a 'LIKE' clause     *                   (it then requires two more escaped sequences) or not     * @param   boolean  whether to treat cr/lfs as escape-worthy entities     *                   (converts \n to \\n, \r to \\r)     *     * @param   boolean  whether this function is used as part of the     *                   "Create PHP code" dialog     *     * @return  string   the slashed string     *     * @access  public     */    function PMA_sqlAddslashes($a_string = '', $is_like = false, $crlf = false, $php_code = false)    {        if ($is_like) {            $a_string = str_replace('\\', '\\\\\\\\', $a_string);        } else {            $a_string = str_replace('\\', '\\\\', $a_string);        }        if ($crlf) {            $a_string = str_replace("\n", '\n', $a_string);            $a_string = str_replace("\r", '\r', $a_string);            $a_string = str_replace("\t", '\t', $a_string);        }        if ($php_code) {            $a_string = str_replace('\'', '\\\'', $a_string);        } else {            $a_string = str_replace('\'', '\'\'', $a_string);        }        return $a_string;    } // end of the 'PMA_sqlAddslashes()' function    /**     * Add slashes before "_" and "%" characters for using them in MySQL     * database, table and field names.     * Note: This function does not escape backslashes!     *     * @param   string   the string to escape     *     * @return  string   the escaped string     *     * @access  public     */    function PMA_escape_mysql_wildcards($name)    {        $name = str_replace('_', '\\_', $name);        $name = str_replace('%', '\\%', $name);        return $name;    } // end of the 'PMA_escape_mysql_wildcards()' function    /**     * removes slashes before "_" and "%" characters     * Note: This function does not unescape backslashes!     *     * @param   string   $name  the string to escape     * @return  string   the escaped string     * @access  public     */    function PMA_unescape_mysql_wildcards($name)    {        $name = str_replace('\\_', '_', $name);        $name = str_replace('\\%', '%', $name);

⌨️ 快捷键说明

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