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

📄 setup.php

📁 一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
    return $ret;}/** * Terminates script and ends HTML * * @return nothing */function footer() {    echo '</body>';    echo '</html>';    exit;}/** * Creates string describing server authentication method * * @param   array   server configuration * * @return  string  authentication method description */function get_server_auth($val) {    global $PMA_Config;    if (isset($val['auth_type'])) {        $auth = $val['auth_type'];    } else {        $auth = $PMA_Config->default_server['auth_type'];    }    $ret = $auth;    if ($auth == 'config') {        if (isset($val['user'])) {            $ret .= ':' . $val['user'];        } else {            $ret .= ':' . $PMA_Config->default_server['user'];        }    }    return $ret;}/** * Creates nice string with server name * * @param   array   server configuration * @param   int     optional server id * * @return  string  fancy server name */function get_server_name($val, $id = FALSE, $escape = true) {    if (!empty($val['verbose'])) {        $ret = $val['verbose'];    } else {        $ret = $val['host'];    }    $ret .= ' (' . get_server_auth($val) . ')';    if ($id !== FALSE) {        $ret .= ' [' . ($id + 1) . ']' ;    }    if ($escape) {        return htmlspecialchars($ret);    } else {        return $ret;    }}/** * Exports variable to PHP code, very limited version of var_export * * @param   string  data to export * * @see var_export * * @return  string  PHP code containing variable value */function PMA_var_export($input) {    $output = '';    if (is_null($input)) {        $output .= 'NULL';    } elseif (is_array($input)) {        $output .= "array (\n";        foreach($input as $key => $value) {            $output .= PMA_var_export($key) . ' => ' . PMA_var_export($value);            $output .= ",\n";        }        $output .= ')';    } elseif (is_string($input)) {        $output .= '\'' . addslashes($input) . '\'';    } elseif (is_int($input) || is_double($input)) {        $output .= (string) $input;    } elseif (is_bool($input)) {        $output .= $input ? 'true' : 'false';    } else {        die('Unknown type for PMA_var_export: ' . $input);    }    return $output;}	/** * Creates configuration code for one variable * * @param   string  variable name * @param   mixed   configuration * * @return  string  PHP code containing configuration */function get_cfg_val($name, $val) {    $ret = '';    if (is_array($val)) {        $ret .= "\n";        foreach ($val as $k => $v) {            if (!isset($type)) {                if (is_string($k)) {                    $type = 'string';                } elseif (is_int($k)) {                    $type = 'int';                    $ret .= $name . " = array(\n";                } else {                    // Something unknown...                    $ret .= $name. ' = ' . PMA_var_export($val) . ";\n";                    break;                }            }            if ($type == 'string') {                $ret .= get_cfg_val($name . "['$k']", $v);            } elseif ($type == 'int') {                $ret .= "    " . PMA_var_export($v) . ",\n";            }        }        if (!isset($type)) {            /* Empty array */            $ret .= $name . " = array();\n";        } elseif ($type == 'int') {            $ret .= ");\n";        }        $ret .= "\n";        unset($type);    } else {        $ret .= $name . ' = ' . PMA_var_export($val) . ";\n";    }    return $ret;}/** * Creates configuration PHP code * * @param   array   configuration * * @return  string  PHP code containing configuration */function get_cfg_string($cfg) {    global $script_info, $script_version, $now;    $c = $cfg;    $ret = "<?php\n/*\n * Generated configuration file\n * Generated by: $script_info\n * Version: $script_version\n * Date: " . $now . "\n */\n\n";    if (count($c['Servers']) > 0) {        $ret .= "/* Servers configuration */\n\$i = 0;\n";        foreach ($c['Servers'] as $cnt => $srv) {            $ret .= "\n/* Server " . strtr(get_server_name($srv, $cnt, false), '*', '-') . " */\n\$i++;\n";            foreach ($srv as $key => $val) {                $ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val);            }        }        $ret .= "\n/* End of servers configuration */\n\n";    }    unset($c['Servers']);    foreach ($c as $key => $val) {        $ret .= get_cfg_val("\$cfg['$key']", $val);    }    $ret .= "?>\n";    return $ret;}/** * Compresses server configuration to be indexed from 0 and contain no gaps * * @param   array   configuration * * @return  nothing */function compress_servers(&$cfg) {    $ns = array();    foreach ($cfg['Servers'] as $val) {        if (!empty($val['host'])) {            $ns[] = $val;        }    }    $cfg['Servers'] = $ns;}/** * Grabs values from POST * * @param   string   list of values to grab, values are separated by ";", *                   each can have defined type separated by ":", if no type *                   is defined, string is assumed. Possible types: bool - *                   boolean value, serialized - serialized value, int - *                   integer, tristate - "TRUE"/"FALSE" converted to bool, *                   other strings are kept. * * @return  array   array with grabbed values */function grab_values($list){    $a = split(';', $list);    $res = array();    foreach ($a as $val) {        $v = split(':', $val);        if (!isset($v[1])) {            $v[1] = '';        }        switch($v[1]) {            case 'bool':                $res[$v[0]] = isset($_POST[$v[0]]);                break;            case 'serialized':                if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {                    $res[$v[0]] = unserialize($_POST[$v[0]]);                }                break;            case 'int':                if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {                    $res[$v[0]] = (int)$_POST[$v[0]];                }                break;            case 'tristate':                if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {                    $cur = $_POST[$v[0]];                    if ($cur == 'TRUE') {                        $res[$v[0]] = TRUE;                    } elseif ($cur == 'FALSE') {                        $res[$v[0]] = FALSE;                    } else {                        $res[$v[0]] = $cur;                    }                }                break;            case 'string':            default:                if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {                    $res[$v[0]] = $_POST[$v[0]];                }                break;        }    }    return $res;}/** * Displays overview * * @param   string  title of oveview * @param   array   list of values to display (each element is array of two *                  values - name and value) * @param   string  optional buttons to be displayed * * @return  nothing */function show_overview($title, $list, $buttons = '') {    echo '<fieldset class="overview">' . "\n";    echo '<legend>' . $title . '</legend>' . "\n";    foreach ($list as $val) {        echo '<div class="row">';        echo '<div class="desc">';        echo $val[0];        echo '</div>';        echo '<div class="data">';        echo $val[1];        echo '</div>';        echo '</div>' . "\n";    }    if (!empty($buttons)) {        echo '<div class="buttons">';        echo '<div class="desc">Actions:</div>';        echo $buttons;        echo '</div>' . "\n";    }    echo '</fieldset>' . "\n";    echo "\n";}/** * Displays configuration, fallback defaults are taken from global $PMA_Config * * @param   array   list of values to display (each element is array of two or *                  three values - desription, name and optional type *                  indicator). Type is determined by type of this parameter, *                  array means select and array elements are items, *                  'password' means password input. * @param   string  title of configuration * @param   string  help string for this configuration * @param   array   optional first level defaults * @param   string  optional title for save button * @param   string  optional prefix for documentation links * * @return  nothing */function show_config_form($list, $legend, $help, $defaults = array(), $save = '', $prefix = '') {    global $PMA_Config;    if (empty($save)) {        $save = 'Update';    }    echo '<fieldset class="optbox">' . "\n";    echo '<legend>' . $legend . '</legend>' . "\n";    echo '<p>' . $help . '</p>' . "\n";    foreach ($list as $val) {        echo '<div class="opts">';        $type = 'text';        if (isset($val[3])) {            if (is_array($val[3])) {                $type = 'select';            } elseif (is_bool($val[3])) {                $type = 'check';            } elseif ($val[3] == 'password') {                $type = 'password';            }        }        switch ($type) {            case 'text':            case 'password':                echo '<label for="text_' . $val[1] . '" class="desc" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';                echo '<input type="' . $type . '" name="' . $val[1] . '" id="text_' . $val[1] . '" title="' . $val[2] . '" size="50"';                if (isset($defaults[$val[1]])) {                    echo ' value="' . htmlspecialchars($defaults[$val[1]]) . '"';                } else {                    echo ' value="' . htmlspecialchars($PMA_Config->get($val[1])) . '"';                }                echo ' />';                break;            case 'check':                echo '<input type="checkbox" name="' . $val[1] . '" value="something" id="checkbox_' . $val[1] . '" title="' . $val[2] . '"';                if (isset($defaults[$val[1]])) {                    if ($defaults[$val[1]]) {                        echo ' checked="checked"';                    }                } else {                    if ($PMA_Config->get($val[1])) {                        echo ' checked="checked"';                    }                }                echo ' />';                echo '<label for="checkbox_' . $val[1] . '" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';                break;            case 'select':

⌨️ 快捷键说明

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