📄 phpdig_functions.php
字号:
<?php/*----------------------------------------------------------------------------------PhpDig Version 1.8.x - See the config file for the full version number.This program is provided WITHOUT warranty under the GNU/GPL license.See the LICENSE file for more information about the GNU/GPL license.Contributors are listed in the CREDITS and CHANGELOG files in this package.Developer from inception to and including PhpDig v.1.6.2: Antoine BajoletDeveloper from PhpDig v.1.6.3 to and including current version: CharterCopyright (C) 2001 - 2003, Antoine Bajolet, http://www.toiletoine.net/Copyright (C) 2003 - current, Charter, http://www.phpdig.net/Contributors hold Copyright (C) to their code submissions.Do NOT edit or remove this copyright or licence information upon redistribution.If you modify code and redistribute, you may ADD your copyright to this notice.----------------------------------------------------------------------------------*/define('CONFIG_CHECK','check'); // do not edit this line//-------------UTILS FUNCTIONS//=================================================// extract _POST or _GET variables from a list varname => vartype// Useful for error_reporting E_ALL too, init variables// usage in script : extract(phpdigHttpVars(array('foobar'=>'string')));function phpdigHttpVars($varray=array()) {$parse_orders = array('_POST','_GET','HTTP_POST_VARS','HTTP_GET_VARS');$httpvars = array();// extract the right arrayif (is_array($varray)) { foreach($parse_orders as $globname) { global $$globname; if (!count($httpvars) && isset($$globname) && is_array($$globname)) { $httpvars = $$globname; } } // extract or create requested vars foreach($varray as $varname => $vartype) { if (in_array($vartype,array('integer','bool','double','float','string','array')) ) { if (!isset($httpvars[$varname])) { if (!isset($GLOBALS[$varname])) { $httpvars[$varname] = false; } else { $httpvars[$varname] = $GLOBALS[$varname]; } } settype($httpvars[$varname],$vartype); } }return $httpvars;}}//=================================================// timer for profilingclass phpdigTimer { var $time = 0; var $mode = ''; var $marks = array(); var $template = ''; function phpdigTimer($mode='html') { $this->time = $this->getTime(); if ($mode == 'cli') { $this->template = "%s:\t%0.9f s. \n"; } else { $this->template = "<tr><td class=\"greyForm\">%s</td><td class=\"greyForm\">%0.9f s. </td></tr>\n"; } } function start($name) { if (!isset($this->marks[$name])) { $this->marks[$name]['time'] = $this->getTime(); $this->marks[$name]['stat'] = 'r'; } else if ($this->marks[$name]['stat'] == 's') { $this->marks[$name]['time'] = $this->getTime()-$this->marks[$name]['time']; $this->marks[$name]['stat'] = 'r'; } } function stop($name) { if (isset($this->marks[$name]) && $this->marks[$name]['stat'] == 'r') { $this->marks[$name]['time'] = $this->getTime()-$this->marks[$name]['time']; } else { $this->marks[$name]['time'] = 0; } $this->marks[$name]['stat'] = 's'; } function display() { if ($this->mode != 'cli') { print "<table class=\"borderCollapse\"><tr><td class=\"blueForm\">Mark</td><td class=\"blueForm\">Value</td></tr>\n"; } foreach($this->marks as $name => $value) { printf($this->template,ucwords($name),$value['time']); } if ($this->mode != 'cli') { print "</table>\n"; } } // increase precision with deltime function getTime() { return array_sum(explode(' ',microtime()))-$this->time; }}//-------------STRING FUNCTIONS//=================================================//returns a localized stringfunction phpdigMsg($string='') {global $phpdig_mess;if (isset($phpdig_mess[$string])) { return nl2br($phpdig_mess[$string]);}else { return ucfirst($string);}}//=================================================//print a localized stringfunction phpdigPrnMsg($string='') {global $phpdig_mess;if (isset($phpdig_mess[$string])) { print nl2br($phpdig_mess[$string]);}else { print ucfirst($string);}}//=================================================//load the common words in an arrayfunction phpdigComWords($file=''){$lines = @file($file);if (is_array($lines)) { while (list($id,$word) = each($lines)) $common[trim($word)] = 1; }else $common['aaaa'] = 1;return $common;}//=================================================//highlight a string partfunction phpdigHighlight($ereg='',$string=''){if ($ereg) { $string = @eregi_replace($ereg,"\\1<^#_>\\2</_#^>\\3",@eregi_replace($ereg,"\\1<^#_>\\2</_#^>\\3",$string)); $string = str_replace("^#_","span class=\"phpdigHighlight\"",str_replace("_#^","span",$string)); return $string;}else { return $result;}}//=================================================//replace all characters with an accentfunction phpdigStripAccents($chaine,$encoding=PHPDIG_ENCODING) {global $phpdigEncode;if (!isset($phpdigEncode[$encoding])) { $encoding = PHPDIG_ENCODING;}// exceptionsif ($encoding == 'iso-8859-1') { $chaine = str_replace('
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -