本文整理汇总了PHP中PageIndexTerms函数的典型用法代码示例。如果您正苦于以下问题:PHP PageIndexTerms函数的具体用法?PHP PageIndexTerms怎么用?PHP PageIndexTerms使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PageIndexTerms函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PageIndexUpdate
function PageIndexUpdate($pagelist = NULL, $dir = '') {
global $EnableReadOnly, $PageIndexUpdateList, $PageIndexFile,
$PageIndexTime, $Now;
if (IsEnabled($EnableReadOnly, 0)) return;
$abort = ignore_user_abort(true);
if ($dir) { flush(); chdir($dir); }
if (is_null($pagelist))
{ $pagelist = (array)$PageIndexUpdateList; $PageIndexUpdateList = array(); }
if (!$pagelist || !$PageIndexFile) return;
SDV($PageIndexTime, 10);
$c = count($pagelist); $updatecount = 0;
StopWatch("PageIndexUpdate begin ($c pages to update)");
$pagelist = (array)$pagelist;
$timeout = time() + $PageIndexTime;
$cmpfn = create_function('$a,$b', 'return strlen($b)-strlen($a);');
Lock(2);
$ofp = fopen("$PageIndexFile,new", 'w');
foreach($pagelist as $pn) {
if (@$updated[$pn]) continue;
@$updated[$pn]++;
if (time() > $timeout) continue;
$page = ReadPage($pn, READPAGE_CURRENT);
if ($page) {
$targets = str_replace(',', ' ', @$page['targets']);
$terms = PageIndexTerms(array(@$page['text'], $targets, $pn));
usort($terms, $cmpfn);
$x = '';
foreach($terms as $t) { if (strpos($x, $t) === false) $x .= " $t"; }
fputs($ofp, "$pn:$Now: $targets :$x\n");
}
$updatecount++;
}
$ifp = @fopen($PageIndexFile, 'r');
if ($ifp) {
while (!feof($ifp)) {
$line = fgets($ifp, 4096);
while (substr($line, -1, 1) != "\n" && !feof($ifp))
$line .= fgets($ifp, 4096);
$i = strpos($line, ':');
if ($i === false) continue;
$n = substr($line, 0, $i);
if (@$updated[$n]) continue;
fputs($ofp, $line);
}
fclose($ifp);
}
fclose($ofp);
if (file_exists($PageIndexFile)) unlink($PageIndexFile);
rename("$PageIndexFile,new", $PageIndexFile);
fixperms($PageIndexFile);
StopWatch("PageIndexUpdate end ($updatecount updated)");
ignore_user_abort($abort);
}
示例2: PageIndexUpdate
function PageIndexUpdate($pagelist, $dir = '')
{
global $PageIndexFile, $PageIndexTime, $Now;
$abort = ignore_user_abort(true);
if ($dir) {
chdir($dir);
}
SDV($PageIndexTime, 10);
if (!$pagelist || !$PageIndexFile) {
return;
}
$c = count($pagelist);
StopWatch("PageIndexUpdate begin ({$c} pages to update)");
$pagelist = (array) $pagelist;
$timeout = time() + $PageIndexTime;
$cmpfn = create_function('$a,$b', 'return strlen($b)-strlen($a);');
Lock(2);
$ofp = fopen("{$PageIndexFile},new", 'w');
foreach ($pagelist as $pn) {
if (time() > $timeout) {
break;
}
$page = ReadPage($pn, READPAGE_CURRENT);
if ($page) {
$targets = str_replace(',', ' ', @$page['targets']);
$terms = PageIndexTerms(array(@$page['text'], $targets, $pn));
usort($terms, $cmpfn);
$x = '';
foreach ($terms as $t) {
if (strpos($x, $t) === false) {
$x .= " {$t}";
}
}
fputs($ofp, "{$pn}:{$Now}: {$targets} :{$x}\n");
}
$updated[$pn]++;
}
$ifp = @fopen($PageIndexFile, 'r');
if ($ifp) {
while (!feof($ifp)) {
$line = fgets($ifp, 4096);
while (substr($line, -1, 1) != "\n" && !feof($ifp)) {
$line .= fgets($ifp, 4096);
}
$i = strpos($line, ':');
if ($i === false) {
continue;
}
$n = substr($line, 0, $i);
if (@$updated[$n]) {
continue;
}
fputs($ofp, $line);
}
fclose($ifp);
}
fclose($ofp);
if (file_exists($PageIndexFile)) {
unlink($PageIndexFile);
}
rename("{$PageIndexFile},new", $PageIndexFile);
fixperms($PageIndexFile);
$c = count($updated);
StopWatch("PageIndexUpdate end ({$c} updated)");
ignore_user_abort($abort);
}