本文整理汇总了PHP中StopWatch函数的典型用法代码示例。如果您正苦于以下问题:PHP StopWatch函数的具体用法?PHP StopWatch怎么用?PHP StopWatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StopWatch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DisplayStopWatch
function DisplayStopWatch()
{
global $StopWatch;
StopWatch('now');
$out[] = "<pre>";
foreach ((array) $StopWatch as $k => $x) {
$out[] = "{$x}\n";
}
array_pop($StopWatch);
$out[] = '</pre>';
return implode('', $out);
}
示例2: StopWatchHTML
function StopWatchHTML($pagename, $print = 0) {
global $StopWatch;
StopWatch('now');
$l = strlen(count($StopWatch));
$out = '<pre>';
foreach((array)$StopWatch as $i => $x)
$out .= sprintf("%{$l}d: %s\n", $i, $x);
$out .= '</pre>';
if (is_array($StopWatch)) array_pop($StopWatch);
if ($print) print $out;
return $out;
}
示例3: ReadApprovedUrls
function ReadApprovedUrls($pagename) {
global $ApprovedUrlPagesFmt,$ApproveUrlPattern,$WhiteUrlPatterns;
foreach((array)$ApprovedUrlPagesFmt as $p) {
$pn = FmtPageName($p, $pagename);
StopWatch("ReadApprovedUrls $pn begin");
$apage = ReadPage($pn, READPAGE_CURRENT);
preg_match_all("/$ApproveUrlPattern/",@$apage['text'],$match);
foreach($match[0] as $a)
$WhiteUrlPatterns[] = preg_quote($a,'!');
StopWatch("ReadApprovedUrls $pn end");
}
}
示例4: StopWatchHTML
function StopWatchHTML($pagename, $print = 0)
{
global $StopWatch;
StopWatch('now');
$out = '<pre>' . implode("\n", (array) $StopWatch) . "\n</pre>";
if (is_array($StopWatch)) {
array_pop($StopWatch);
}
if ($print) {
print $out;
}
return $out;
}
示例5: DisplayStopWatch
function DisplayStopWatch()
{
global $StopWatch;
StopWatch('now');
$out = "<pre>";
foreach ((array) $StopWatch as $k => $x) {
$out .= "{$x}\n";
}
if (is_array($StopWatch)) {
array_pop($StopWatch);
}
$out .= '</pre>';
return $out;
}
示例6: DisplayStopWatch
function DisplayStopWatch()
{
global $StopWatch;
StopWatch('now');
$u = $StopWatch[0];
$au = $u;
$out[] = "<table><tr><th>Event</th><th>Time</th><th>Cumulative</th></tr>\n";
for ($i = 0; $i < count($StopWatch); $i++) {
list($bu, $bevent) = explode(' ', $StopWatch[$i], 2);
$t = sprintf('%.02f', $bu - $au);
$c = sprintf('%.02f', $bu - $u);
$out[] = "<tr><td>{$bevent}</td>\n <td align='right'>{$t}</td><td align='right'>{$c}</td></tr>";
$au = $bu;
}
array_pop($StopWatch);
$out[] = '</table>';
return implode('', $out);
}
示例7: Blocklist
function Blocklist($pagename, $text) {
global $BlocklistPages, $BlockedMessagesFmt, $BlocklistDownload,
$BlocklistDownloadRefresh, $Now, $EnablePost, $WhyBlockedFmt,
$MessagesFmt, $BlocklistMessageFmt, $EnableWhyBlocked, $IsBlocked;
StopWatch("Blocklist: begin $pagename");
$BlocklistDownload = (array)@$BlocklistDownload;
SDV($BlocklistPages,
array_merge(array('$SiteAdminGroup.Blocklist',
'$SiteAdminGroup.Blocklist-Farm'),
array_keys($BlocklistDownload)));
SDV($BlocklistMessageFmt, "<h3 class='wikimessage'>$[This post has been blocked by the administrator]</h3>");
SDVA($BlockedMessagesFmt, array(
'ip' => '$[Address blocked from posting]: ',
'text' => '$[Text blocked from posting]: '));
SDV($BlocklistDownloadRefresh, 86400);
## Loop over all blocklist pages
foreach((array)$BlocklistPages as $b) {
## load the current blocklist page
$pn = FmtPageName($b, $pagename);
$page = ReadPage($pn, READPAGE_CURRENT);
if (!$page) continue;
## if the page being checked is a blocklist page, stop blocking
if ($pagename == $pn) return;
## If the blocklist page is managed by automatic download,
## schedule any new downloads here
if (@$BlocklistDownload[$pn]) {
$bd = &$BlocklistDownload[$pn];
SDVA($bd, array(
'refresh' => $BlocklistDownloadRefresh,
'url' => "http://www.pmwiki.org/blocklists/$pn" ));
if (!@$page['text'] || $page['time'] < $Now - $bd['refresh'])
register_shutdown_function('BlocklistDownload', $pn, getcwd());
}
## If the blocklist is simply a list of regexes to be matched, load
## them into $terms['block'] and continue to the next blocklist page.
## Some regexes from remote sites aren't well-formed, so we have
## to escape any slashes that aren't already escaped.
if (strpos(@$page['text'], 'blocklist-format: regex') !==false) {
if (preg_match_all('/^([^\\s#].+)/m', $page['text'], $match))
foreach($match[0] as $m) {
$m = preg_replace('#(?<!\\\\)/#', '\\/', trim($m));
$terms['block'][] = "/$m/";
}
continue;
}
## Treat the page as a pmwiki-format blocklist page, with
## IP addresses and "block:"-style declarations. First, see
## if we need to block the author based on a.b.c.d or a.b.c.*
## IP addresses.
$ip = preg_quote($_SERVER['REMOTE_ADDR']);
$ip = preg_replace('/\\d+$/', '($0\\b|\\*)', $ip);
if (preg_match("/\\b$ip/", @$page['text'], $match)) {
$EnablePost = 0;
$IsBlocked = 1;
$WhyBlockedFmt[] = $BlockedMessagesFmt['ip'] . $match[0];
}
## Now we'll load any "block:" or "unblock:" specifications
## from the page text.
if (preg_match_all('/(un)?(?:block|regex):(.*)/', @$page['text'],
$match, PREG_SET_ORDER))
foreach($match as $m) $terms[$m[1].'block'][] = trim($m[2]);
}
## okay, we've loaded all of the terms, now subtract any 'unblock'
## terms from the block set.
StopWatch("Blocklist: diff unblock");
$blockterms = array_diff((array)@$terms['block'], (array)@$terms['unblock']);
## go through each of the remaining blockterms and see if it matches the
## text -- if so, disable posting and add a message to $WhyBlockedFmt.
StopWatch('Blocklist: blockterms (count='.count($blockterms).')');
$itext = strtolower($text);
foreach($blockterms as $b) {
if ($b{0} == '/') {
if (!preg_match($b, $text)) continue;
} else if (strpos($itext, strtolower($b)) === false) continue;
$EnablePost = 0;
$IsBlocked = 1;
$WhyBlockedFmt[] = $BlockedMessagesFmt['text'] . $b;
}
StopWatch('Blocklist: blockterms done');
## If we came across any reasons to block, let's provide a message
## to the author that it was blocked. If $EnableWhyBlocked is set,
## we'll even tell the author why. :-)
if (@$WhyBlockedFmt) {
$MessagesFmt[] = $BlocklistMessageFmt;
if (IsEnabled($EnableWhyBlocked, 0))
foreach((array)$WhyBlockedFmt as $why)
$MessagesFmt[] = "<pre class='blocklistmessage'>$why</pre>\n";
}
//.........这里部分代码省略.........
示例8: HandleUpgrade
function HandleUpgrade($pagename, $auth = 'ALWAYS') {
global $SiteGroup, $SiteAdminGroup, $StatusPageName, $ScriptUrl,
$AuthUserPageFmt, $VersionNum, $Version;
StopWatch('HandleUpgrade: begin');
$message = '';
$done = '';
## check for Site.* --> SiteAdmin.*
foreach(array('AuthUser', 'NotifyList', 'Blocklist', 'ApprovedUrls') as $n) {
$n0 = "$SiteGroup.$n"; $n1 = "$SiteAdminGroup.$n";
StopWatch("HandleUpgrade: checking $n0 -> $n1");
## checking AuthUser is special, because Site.AuthUser comes with the
## distribution.
if ($n == 'AuthUser') {
## if we already have a user-modified SiteAdmin.AuthUser, we can skip
SDV($AuthUserPageFmt, '$SiteAdminGroup.AuthUser');
$n1 = FmtPageName($AuthUserPageFmt, $pagename);
$page = ReadPage($n1, READPAGE_CURRENT);
if (@$page['time'] > 1000000000) continue;
## if there's not a user-modified Site.AuthUser, we can skip
$page = ReadPage($n0, READPAGE_CURRENT);
if (@$page['time'] == 1000000000) continue;
} else if (!PageExists($n0) || PageExists($n1)) continue;
if (@$_REQUEST['migrate'] == 'yes') {
## if the admin wants PmWiki to migrate, do it.
$page = RetrieveAuthPage($n0, 'admin', true);
StopWatch("HandleUpgrade: copying $n0 -> $n1");
if ($page) {
WritePage($n1, $page);
$done .= "<li>Copied $n0 to $n1</li>";
continue;
}
}
$message .= "<li>$n0 -> $n1</li>";
}
if ($message) {
$migrateurl = "$ScriptUrl?action=upgrade&migrate=yes";
$infourl = 'http://www.pmwiki.org/wiki/PmWiki/UpgradeToSiteAdmin';
$message =
"<h2>Upgrade notice -- SiteAdmin group</h2>
<p>This version of PmWiki expects several administrative pages
from the <em>Site</em> group to be found in a new <em>SiteAdmin</em> group.
On this site, the following pages appear to need to be relocated:</p>
<ul>$message</ul>
<p>For more information about this change, including the various
options for proceeding, see</p>
<blockquote><a target='_blank' href='$infourl'>$infourl</a></blockquote>
<form action='$ScriptUrl' method='post'>
<p>If you would like PmWiki to attempt to automatically copy
these pages into their new <br /> locations for you, try
<input type='hidden' name='action' value='upgrade' />
<input type='hidden' name='migrate' value='yes' />
<input type='submit' value='Relocate pages listed above' />
(admin password required) </p>
</form>
<p>If you want to configure PmWiki so that it continues to
look for the above pages in <em>$SiteGroup</em>, add the
following line near the top of <em>local/config.php</em>:</p>
<blockquote><pre>\$SiteAdminGroup = \$SiteGroup;</pre></blockquote>
$Version
";
print $message;
exit;
}
StopWatch("UpgradeCheck: writing $StatusPageName");
Lock(2);
SDV($StatusPageName, "$SiteAdminGroup.Status");
$page = ReadPage($StatusPageName);
$page['updatedto'] = $VersionNum;
WritePage($StatusPageName, $page);
if ($done) {
$done .= "<li>Updated $StatusPageName</li>";
echo "<h2>Upgrade to $Version ... ok</h2><ul>$done</ul>";
$GLOBALS['EnableRedirect'] = 0;
}
Redirect($pagename);
}
示例9: MarkupToHTML
function MarkupToHTML($pagename, $text, $escape = true)
{
# convert wiki markup text to HTML output
global $MarkupRules, $MarkupFrame, $MarkupFrameBase, $WikiWordCount, $K0, $K1, $RedoMarkupLine;
StopWatch('MarkupToHTML begin');
array_unshift($MarkupFrame, $MarkupFrameBase);
$MarkupFrame[0]['wwcount'] = $WikiWordCount;
$markrules = BuildMarkupRules();
foreach ((array) $text as $l) {
$lines[] = $escape ? PVS(htmlspecialchars($l, ENT_NOQUOTES)) : $l;
}
$lines[] = '(:closeall:)';
$out = '';
while (count($lines) > 0) {
$x = array_shift($lines);
$RedoMarkupLine = 0;
foreach ($markrules as $p => $r) {
if ($p[0] == '/') {
$x = preg_replace($p, $r, $x);
} elseif (strstr($x, $p) !== false) {
$x = eval($r);
}
if (isset($php_errormsg)) {
echo "pat={$p}";
unset($php_errormsg);
}
if ($RedoMarkupLine) {
$lines = array_merge((array) $x, $lines);
continue 2;
}
}
if ($x > '') {
$out .= "{$x}\n";
}
}
foreach ((array) @$MarkupFrame[0]['posteval'] as $v) {
eval($v);
}
array_shift($MarkupFrame);
StopWatch('MarkupToHTML end');
return $out;
}
示例10: MxPageList
function MxPageList($pagename, $args)
{
StopWatch('pagelist start');
$opt = array('o' => $args, 'fmt' => 'csv');
$out = FmtPageList('$MatchList', $pagename, $opt, 0);
$out = preg_replace("/[\n]+/s", "\n", $out);
StopWatch('pagelist end');
return $out;
}
示例11: ls
function ls($pats=NULL) {
global $GroupPattern, $NamePattern;
StopWatch("PageStore::ls begin {$this->dir}");
$pats=(array)$pats;
array_push($pats, "/^$GroupPattern\.$NamePattern$/");
$dir = $this->pagefile('$Group.$Name');
$dirlist = array(preg_replace('!/*[^/]*\\$.*$!','',$dir));
$out = array();
while (count($dirlist)>0) {
$dir = array_shift($dirlist);
$dfp = @opendir($dir); if (!$dfp) { continue; }
$o = array();
while ( ($pagefile = readdir($dfp)) !== false) {
if ($pagefile{0} == '.') continue;
if (is_dir("$dir/$pagefile"))
{ array_push($dirlist,"$dir/$pagefile"); continue; }
$o[] = $pagefile;
}
closedir($dfp);
StopWatch("PageStore::ls merge {$this->dir}");
$out = array_merge($out, MatchPageNames($o, $pats));
}
StopWatch("PageStore::ls end {$this->dir}");
return $out;
}
示例12: PHPDiff
function PHPDiff($old, $new)
{
StopWatch("PHPDiff: begin");
# split the source text into arrays of lines
$t1 = explode("\n", $old);
$x = array_pop($t1);
if ($x > '') {
$t1[] = "{$x}\n\\ No newline at end of file";
}
$t2 = explode("\n", $new);
$x = array_pop($t2);
if ($x > '') {
$t2[] = "{$x}\n\\ No newline at end of file";
}
$t1_start = 0;
$t1_end = count($t1);
$t2_start = 0;
$t2_end = count($t2);
# stop with a common ending
while ($t1_start < $t1_end && $t2_start < $t2_end && $t1[$t1_end - 1] == $t2[$t2_end - 1]) {
$t1_end--;
$t2_end--;
}
# skip over any common beginning
while ($t1_start < $t1_end && $t2_start < $t2_end && $t1[$t1_start] == $t2[$t2_start]) {
$t1_start++;
$t2_start++;
}
# build a reverse-index array using the line as key and line number as value
# don't store blank lines, so they won't be targets of the shortest distance
# search
for ($i = $t1_start; $i < $t1_end; $i++) {
if ($t1[$i] > '') {
$r1[$t1[$i]][] = $i;
}
}
for ($i = $t2_start; $i < $t2_end; $i++) {
if ($t2[$i] > '') {
$r2[$t2[$i]][] = $i;
}
}
$a1 = $t1_start;
$a2 = $t2_start;
# start at beginning of each list
$actions = array();
# walk this loop until we reach the end of one of the lists
while ($a1 < $t1_end && $a2 < $t2_end) {
# if we have a common element, save it and go to the next
if ($t1[$a1] == $t2[$a2]) {
$actions[] = 4;
$a1++;
$a2++;
continue;
}
# otherwise, find the shortest move (Manhattan-distance) from the
# current location
$best1 = $t1_end;
$best2 = $t2_end;
$s1 = $a1;
$s2 = $a2;
while ($s1 + $s2 - $a1 - $a2 < $best1 + $best2 - $a1 - $a2) {
$d = -1;
foreach ((array) @$r1[$t2[$s2]] as $n) {
if ($n >= $s1) {
$d = $n;
break;
}
}
if ($d >= $s1 && $d + $s2 - $a1 - $a2 < $best1 + $best2 - $a1 - $a2) {
$best1 = $d;
$best2 = $s2;
}
$d = -1;
foreach ((array) @$r2[$t1[$s1]] as $n) {
if ($n >= $s2) {
$d = $n;
break;
}
}
if ($d >= $s2 && $s1 + $d - $a1 - $a2 < $best1 + $best2 - $a1 - $a2) {
$best1 = $s1;
$best2 = $d;
}
$s1++;
$s2++;
}
while ($a1 < $best1) {
$actions[] = 1;
$a1++;
}
# deleted elements
while ($a2 < $best2) {
$actions[] = 2;
$a2++;
}
# added elements
}
# we've reached the end of one list, now walk to the end of the other
while ($a1 < $t1_end) {
$actions[] = 1;
//.........这里部分代码省略.........
示例13: ls
function ls($pats = NULL)
{
global $UploadDir, $UploadPrefixFmt;
global $GroupPattern, $NamePattern;
global $ThumbShoeThumbPrefix, $ThumbShoePageSep;
StopWatch("ThumbShoePageStore::ls begin {$this->galleryGroup}");
$pats = (array) $pats;
$topdir = PageVar($this->galleryGroup . '.' . $this->galleryGroup, '$TSAttachTopDir');
StopWatch("ThumbShoePageStore::ls topdir={$topdir}");
$out = array();
$o = array();
$dfp = @opendir($topdir);
if ($dfp) {
while (($file = readdir($dfp)) !== false) {
if ($file[0] == '.') {
continue;
}
if (is_dir("{$topdir}/{$file}")) {
$sub_dfp = @opendir("{$topdir}/{$file}");
while (($subfile = readdir($sub_dfp)) !== false) {
if ($subfile[0] == '.') {
continue;
}
if (is_dir("{$topdir}/{$file}/{$subfile}")) {
continue;
}
if (!preg_match("/{$this->ImgRx}\$/", $subfile)) {
continue;
}
if (preg_match("/^{$ThumbShoeThumbPrefix}/", $subfile)) {
continue;
}
$pn = str_replace('.', '_', $subfile);
$pn = "{$file}{$ThumbShoePageSep}" . $pn;
$pn = MakePageName($this->galleryGroup . '.' . $this->galleryGroup, $pn);
$o[] = $pn;
StopWatch("ThumbShoePageStore::ls pn={$pn}");
}
closedir($sub_dfp);
} else {
if (!preg_match("/{$this->ImgRx}\$/", $file)) {
continue;
}
if (preg_match("/^{$ThumbShoeThumbPrefix}/", $file)) {
continue;
}
$pn = str_replace('.', '_', $file);
$pn = MakePageName($this->galleryGroup . '.' . $this->galleryGroup, $pn);
$o[] = $pn;
StopWatch("ThumbShoePageStore::ls pn={$pn}");
}
}
closedir($dfp);
}
StopWatch("ThumbShoePageStore::ls merge {$this->galleryGroup}");
$out = array_merge($out, MatchPageNames($o, $pats));
StopWatch("ThumbShoePageStore::ls end {$this->galleryGroup}");
return $out;
}
示例14: FPLTextExtract
function FPLTextExtract($pagename, &$matches, $opt)
{
##DEBUG echo "<pre>OPT "; print_r($opt); echo "</pre>";
global $FmtV, $EnableStopWatch, $KeepToken, $KPV;
$EnableStopWatch = 1;
StopWatch('TextExtract pagelist begin');
$opt['stime'] = strtok(microtime(), ' ') + strtok('');
$opt['q'] = ltrim($opt['q']);
foreach ($opt[''] as $k => $v) {
$opt[''][$k] = htmlspecialchars_decode($v);
}
//treat single . search term as request for regex 'all characters'
if ($opt[''][0] == '.' || $opt['pattern'] == '.') {
$opt['regex'] = 1;
}
//MakePageList() does not evaluate terms as regular expressions, so we save them for later
if (@$opt['regex'] == 1) {
$opt['pattern'] = implode(' ', $opt['']);
unset($opt['']);
}
if (@$opt['page']) {
$opt['name'] .= "," . $opt['page'];
}
//allow search of anchor sections
if ($sa = strpos($opt['name'], '#')) {
$opt['section'] = strstr($opt['name'], '#');
$opt['name'] = substr($opt['name'], 0, $sa);
}
$list = MakePageList($pagename, $opt, 0);
//extract page subset according to 'count=' parameter
if (@$opt['count'] && !$opt['section']) {
TESliceList($list, $opt);
}
return TextExtract($pagename, $list, $opt);
}
示例15: MarkupToHTML
function MarkupToHTML($pagename, $text)
{
# convert wiki markup text to HTML output
global $MarkupRules, $MarkupFrame, $MarkupFrameBase, $K0, $K1, $RedoMarkupLine;
StopWatch('MarkupToHTML begin');
array_unshift($MarkupFrame, $MarkupFrameBase);
$markrules = BuildMarkupRules();
foreach ((array) $text as $l) {
$lines[] = htmlspecialchars($l, ENT_NOQUOTES);
}
$out = array();
while (count($lines) > 0) {
$x = array_shift($lines);
$RedoMarkupLine = 0;
foreach ($markrules as $p => $r) {
if (substr($p, 0, 1) == '/') {
$x = preg_replace($p, $r, $x);
} elseif ($p == '' || strstr($x, $p) !== false) {
$x = eval($r);
}
if (isset($php_errormsg)) {
echo "pat={$p}";
unset($php_errormsg);
}
if ($RedoMarkupLine) {
$lines = array_merge((array) $x, $lines);
continue 2;
}
}
if ($x > '') {
$out[] = "{$x}\n";
}
}
foreach ((array) $MarkupFrame[0]['posteval'] as $v) {
$x = eval($v);
if ($x > '') {
$out[] = "{$x}\n";
}
}
array_shift($MarkupFrame);
StopWatch('MarkupToHTML end');
return implode('', (array) $out);
}