当前位置: 首页>>代码示例>>PHP>>正文


PHP PageIndexTerms函数代码示例

本文整理汇总了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);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:53,代码来源:pagelist.php

示例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);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:66,代码来源:pagelist.php


注:本文中的PageIndexTerms函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。