?? setup.php
字號(hào):
return $ret;}/** * Returns needed hidden input for forms. * * @return string HTML with hidden inputs */function get_hidden_inputs() { return '<input type="hidden" name="token" value="' . $_SESSION[' PMA_token '] . '" />';}/** * Creates form for some action * * @param string action name * @param string form title * @param string optional additional inputs * * @return string HTML with form */function get_action($name, $title, $added = '', $enabled = TRUE) { $ret = ''; $ret .= '<form class="action" method="post" action="">'; $ret .= get_hidden_inputs(); $ret .= '<input type="hidden" name="action" value="' . $name . '" />'; $ret .= $added; $ret .= '<input type="submit" value="' . $title . '"'; if (!$enabled) { $ret .= ' disabled="disabled"'; } $ret .= ' />'; $ret .= get_hidden_cfg(); $ret .= '</form>'; $ret .= "\n"; return $ret;}/** * Creates form for going to some url * * @param string URL where to go * @param string form title * @param string optional array of parameters * * @return string HTML with form */function get_url_action($url, $title, $params = array()) { $ret = ''; $ret .= '<form class="action" method="get" action="' . $url . '" target="_blank">'; $ret .= get_hidden_inputs(); foreach ($params as $key => $val) { $ret .= '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; } $ret .= '<input type="submit" value="' . $title . '" />'; $ret .= '</form>'; $ret .= "\n"; 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_Setup; if (isset($val['auth_type'])) { $auth = $val['auth_type']; } else { $auth = $PMA_Config_Setup->default_server['auth_type']; } $ret = $auth; if ($auth == 'config') { if (isset($val['user'])) { $ret .= ':' . $val['user']; } else { $ret .= ':' . $PMA_Config_Setup->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) { global $crlf; $output = ''; if (is_null($input)) { $output .= 'NULL'; } elseif (is_array($input)) { $output .= 'array (' . $crlf; foreach($input as $key => $value) { $output .= PMA_var_export($key) . ' => ' . PMA_var_export($value); $output .= ',' . $crlf; } $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) { global $crlf; $ret = ''; if (is_array($val)) { $ret .= $crlf; foreach ($val as $k => $v) { if (!isset($type)) { if (is_string($k)) { $type = 'string'; } elseif (is_int($k)) { $type = 'int'; $ret .= $name . ' = array(' . $crlf; } else { // Something unknown... $ret .= $name. ' = ' . PMA_var_export($val) . ';' . $crlf; break; } } if ($type == 'string') { $ret .= get_cfg_val($name . "['$k']", $v); } elseif ($type == 'int') { $ret .= ' ' . PMA_var_export($v) . ',' . $crlf; } } if (!isset($type)) { /* Empty array */ $ret .= $name . ' = array();' . $crlf; } elseif ($type == 'int') { $ret .= ');' . $crlf; } $ret .= $crlf; unset($type); } else { $ret .= $name . ' = ' . PMA_var_export($val) . ';' . $crlf; } 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, $crlf; $c = $cfg; $ret = "<?php$crlf/*$crlf * Generated configuration file$crlf * Generated by: $script_info$crlf * Version: $script_version$crlf * Date: " . $now . $crlf . ' */' . $crlf . $crlf; if (count($c['Servers']) > 0) { $ret .= "/* Servers configuration */$crlf\$i = 0;" . $crlf; foreach ($c['Servers'] as $cnt => $srv) { $ret .= $crlf . '/* Server ' . strtr(get_server_name($srv, $cnt, false), '*', '-') . " */$crlf\$i++;" . $crlf; foreach ($srv as $key => $val) { $ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val); } } $ret .= $crlf . '/* End of servers configuration */' . $crlf . $crlf; } unset($c['Servers']); foreach ($c as $key => $val) { $ret .= get_cfg_val("\$cfg['$key']", $val); } $ret .= '?>' . $crlf; 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_Setup * * @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.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -