📄 common.lib.php
字号:
$tab['link'] .= $tab['fragment']; } // display icon, even if iconic is disabled but the link-text is missing if (($GLOBALS['cfg']['MainPageIconic'] || empty($tab['text'])) && isset($tab['icon'])) { // avoid generating an alt tag, because it only illustrates // the text that follows and if browser does not display // images, the text is duplicated $image = '<img class="icon" src="' . htmlentities($GLOBALS['pmaThemeImage']) .'%1$s" width="16" height="16" alt="" />%2$s'; $tab['text'] = sprintf($image, htmlentities($tab['icon']), $tab['text']); } // check to not display an empty link-text elseif (empty($tab['text'])) { $tab['text'] = '?'; trigger_error('empty linktext in function ' . __FUNCTION__ . '()', E_USER_NOTICE); } $out = '<li' . ($tab['class'] == 'active' ? ' class="active"' : '') . '>'; if (!empty($tab['link'])) { $out .= '<a class="tab' . htmlentities($tab['class']) . '"' .' href="' . $tab['link'] . '" ' . $tab['attr'] . '>' . $tab['text'] . '</a>'; } else { $out .= '<span class="tab' . htmlentities($tab['class']) . '">' . $tab['text'] . '</span>'; } $out .= '</li>'; return $out;} // end of the 'PMA_getTab()' function/** * returns html-code for a tab navigation * * @uses PMA_getTab() * @uses htmlentities() * @param array $tabs one element per tab * @param array $url_params * @return string html-code for tab-navigation */function PMA_getTabs($tabs, $url_params){ $tag_id = 'topmenu'; $tab_navigation = '<div id="' . htmlentities($tag_id) . 'container">' . "\n" .'<ul id="' . htmlentities($tag_id) . '">' . "\n"; foreach ($tabs as $tab) { $tab_navigation .= PMA_getTab($tab, $url_params) . "\n"; } $tab_navigation .= '</ul>' . "\n" .'<div class="clearfloat"></div>' .'</div>' . "\n"; return $tab_navigation;}/** * Displays a link, or a button if the link's URL is too large, to * accommodate some browsers' limitations * * @param string the URL * @param string the link message * @param mixed $tag_params string: js confirmation * array: additional tag params (f.e. style="") * @param boolean $new_form we set this to false when we are already in * a form, to avoid generating nested forms * * @return string the results to be echoed or saved in an array */function PMA_linkOrButton($url, $message, $tag_params = array(), $new_form = true, $strip_img = false, $target = ''){ if (! is_array($tag_params)) { $tmp = $tag_params; $tag_params = array(); if (!empty($tmp)) { $tag_params['onclick'] = 'return confirmLink(this, \'' . $tmp . '\')'; } unset($tmp); } if (! empty($target)) { $tag_params['target'] = htmlentities($target); } $tag_params_strings = array(); foreach ($tag_params as $par_name => $par_value) { // htmlspecialchars() only on non javascript $par_value = substr($par_name, 0, 2) == 'on' ? $par_value : htmlspecialchars($par_value); $tag_params_strings[] = $par_name . '="' . $par_value . '"'; } // previously the limit was set to 2047, it seems 1000 is better if (strlen($url) <= 1000) { // no whitespace within an <a> else Safari will make it part of the link $ret = "\n" . '<a href="' . $url . '" ' . implode(' ', $tag_params_strings) . '>' . $message . '</a>' . "\n"; } else { // no spaces (linebreaks) at all // or after the hidden fields // IE will display them all // add class=link to submit button if (empty($tag_params['class'])) { $tag_params['class'] = 'link'; } // decode encoded url separators $separator = PMA_get_arg_separator(); // on most places separator is still hard coded ... if ($separator !== '&') { // ... so always replace & with $separator $url = str_replace(htmlentities('&'), $separator, $url); $url = str_replace('&', $separator, $url); } $url = str_replace(htmlentities($separator), $separator, $url); // end decode $url_parts = parse_url($url); $query_parts = explode($separator, $url_parts['query']); if ($new_form) { $ret = '<form action="' . $url_parts['path'] . '" class="link"' . ' method="post"' . $target . ' style="display: inline;">'; $subname_open = ''; $subname_close = ''; $submit_name = ''; } else { $query_parts[] = 'redirect=' . $url_parts['path']; if (empty($GLOBALS['subform_counter'])) { $GLOBALS['subform_counter'] = 0; } $GLOBALS['subform_counter']++; $ret = ''; $subname_open = 'subform[' . $GLOBALS['subform_counter'] . ']['; $subname_close = ']'; $submit_name = ' name="usesubform[' . $GLOBALS['subform_counter'] . ']"'; } foreach ($query_parts as $query_pair) { list($eachvar, $eachval) = explode('=', $query_pair); $ret .= '<input type="hidden" name="' . $subname_open . $eachvar . $subname_close . '" value="' . htmlspecialchars(urldecode($eachval)) . '" />'; } // end while if (stristr($message, '<img')) { if ($strip_img) { $message = trim(strip_tags($message)); $ret .= '<input type="submit"' . $submit_name . ' ' . implode(' ', $tag_params_strings) . ' value="' . htmlspecialchars($message) . '" />'; } else { $ret .= '<input type="image"' . $submit_name . ' ' . implode(' ', $tag_params_strings) . ' src="' . preg_replace( '/^.*\ssrc="([^"]*)".*$/si', '\1', $message) . '"' . ' value="' . htmlspecialchars( preg_replace('/^.*\salt="([^"]*)".*$/si', '\1', $message)) . '" />'; } } else { $message = trim(strip_tags($message)); $ret .= '<input type="submit"' . $submit_name . ' ' . implode(' ', $tag_params_strings) . ' value="' . htmlspecialchars($message) . '" />'; } if ($new_form) { $ret .= '</form>'; } } // end if... else... return $ret;} // end of the 'PMA_linkOrButton()' function/** * Returns a given timespan value in a readable format. * * @uses $GLOBALS['timespanfmt'] * @uses sprintf() * @uses floor() * @param int the timespan * * @return string the formatted value */function PMA_timespanFormat($seconds){ $return_string = ''; $days = floor($seconds / 86400); if ($days > 0) { $seconds -= $days * 86400; } $hours = floor($seconds / 3600); if ($days > 0 || $hours > 0) { $seconds -= $hours * 3600; } $minutes = floor($seconds / 60); if ($days > 0 || $hours > 0 || $minutes > 0) { $seconds -= $minutes * 60; } return sprintf($GLOBALS['timespanfmt'], (string)$days, (string)$hours, (string)$minutes, (string)$seconds);}/** * Takes a string and outputs each character on a line for itself. Used * mainly for horizontalflipped display mode. * Takes care of special html-characters. * Fulfills todo-item * http://sf.net/tracker/?func=detail&aid=544361&group_id=23067&atid=377411 * * @todo add a multibyte safe function PMA_STR_split() * @uses strlen * @param string The string * @param string The Separator (defaults to "<br />\n") * * @access public * @author Garvin Hicking <me@supergarv.de> * @return string The flipped string */function PMA_flipstring($string, $Separator = "<br />\n"){ $format_string = ''; $charbuff = false; for ($i = 0; $i < strlen($string); $i++) { $char = $string{$i}; $append = false; if ($char == '&') { $format_string .= $charbuff; $charbuff = $char; } elseif ($char == ';' && !empty($charbuff)) { $format_string .= $charbuff . $char; $charbuff = false; $append = true; } elseif (! empty($charbuff)) { $charbuff .= $char; } else { $format_string .= $char; $append = true; } // do not add separator after the last character if ($append && ($i != strlen($string)-1)) { $format_string .= $Separator; } } return $format_string;}/** * Function added to avoid path disclosures. * Called by each script that needs parameters, it displays * an error message and, by default, stops the execution. * * Not sure we could use a strMissingParameter message here, * would have to check if the error message file is always available * * @todo localize error message * @todo use PMA_fatalError() if $die === true? * @uses PMA_getenv() * @uses header_meta_style.inc.php * @uses $GLOBALS['PMA_PHP_SELF'] * basename * @param array The names of the parameters needed by the calling * script. * @param boolean Stop the execution? * (Set this manually to false in the calling script * until you know all needed parameters to check). * @param boolean Whether to include this list in checking for special params. * @global string path to current script * @global boolean flag whether any special variable was required * * @access public * @author Marc Delisle (lem9@users.sourceforge.net) */function PMA_checkParameters($params, $die = true, $request = true){ global $checked_special; if (!isset($checked_special)) { $checked_special = false; } $reported_script_name = basename($GLOBALS['PMA_PHP_SELF']); $found_error = false; $error_message = ''; foreach ($params as $param) { if ($request && $param != 'db' && $param != 'table') { $checked_special = true; } if (!isset($GLOBALS[$param])) { $error_message .= $reported_script_name . ': Missing parameter: ' . $param . ' <a href="./Documentation.html#faqmissingparameters"' . ' target="documentation"> (FAQ 2.8)</a><br />'; $found_error = true; } } if ($found_error) { /** * display html meta tags */ require_once './libraries/header_meta_style.inc.php'; echo '</head><body><p>' . $error_message . '</p></body></html>'; if ($die) { exit(); } }} // end function/** * Function to generate unique condition for specified row. * * @uses $GLOBALS['analyzed_sql'][0] * @uses PMA_DBI_field_flags() * @uses PMA_backquote() * @uses PMA_sqlAddslashes() * @uses stristr() * @uses bin2hex() * @uses preg_replace() * @param resource $handle current query result * @param integer $fields_cnt number of fields * @param array $fields_meta meta information about fields * @param array $row current row * @param boolean $force_unique generate condition only on pk or unique * * @access public * @author Michal Cihar (michal@cihar.com) and others... * @return string calculated condition */function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force_unique=false){ $primary_key = ''; $unique_key = ''; $nonprimary_condition = ''; $preferred_condition = ''; for ($i = 0; $i < $fields_cnt; ++$i) { $condition = ''; $field_flags = PMA_DBI_field_flags($handle, $i); $meta = $fields_meta[$i]; // do not use a column alias in a condition if (! isset($meta->orgname) || ! strlen($meta->orgname)) { $meta->orgname = $meta->name; if (isset($GLOBALS['analyzed_sql'][0]['select_expr']) && is_array($GLOBALS['analyzed_sql'][0]['select_expr'])) { foreach ($GLOBALS['analyzed_sql'][0]['select_expr'] as $select_expr) { // need (string) === (string) // '' !== 0 but '' == 0 if ((string) $select_expr['alias'] === (string) $meta->name) { $meta->orgname = $select_expr['column']; break; } // end if } // end foreach } } // Do not use a table alias in a condition. // Test case is: // select * from galerie x WHERE //(select count(*) from galerie y where y.datum=x.datum)>1 // // But orgtable is present only with mysqli extension so the // fix is only for mysqli. // Also, do not use the original table name if we are dealing with // a view because this view might be updatable. // (The isView() verification should not be costly in most cases // because there is some caching in the function). if (isset($meta->orgtable) && $meta->table != $meta->orgtable && ! PMA_Table::isVie
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -