php IsEnabled类(方法)实例源码

下面列出了php IsEnabled 类(方法)源码代码实例,从而了解它的用法。

作者:BogusCurr    项目:pmwik   
function Merge($newtext,$oldtext,$pagetext) {
  global $WorkDir,$SysMergeCmd, $SysMergePassthru;
  SDV($SysMergeCmd,"/usr/bin/diff3 -L '' -L '' -L '' -m -E");
  if (substr($newtext,-1,1)!="\n") $newtext.="\n";
  if (substr($oldtext,-1,1)!="\n") $oldtext.="\n";
  if (substr($pagetext,-1,1)!="\n") $pagetext.="\n";
  $tempnew = tempnam($WorkDir,"new");
  $tempold = tempnam($WorkDir,"old");
  $temppag = tempnam($WorkDir,"page");
  if ($newfp=fopen($tempnew,'w')) { fputs($newfp,$newtext); fclose($newfp); }
  if ($oldfp=fopen($tempold,'w')) { fputs($oldfp,$oldtext); fclose($oldfp); }
  if ($pagfp=fopen($temppag,'w')) { fputs($pagfp,$pagetext); fclose($pagfp); }
  $mergetext = '';
  if (IsEnabled($SysMergePassthru, 0)) {
    ob_start();
    passthru("$SysMergeCmd $tempnew $tempold $temppag");
    $mergetext = ob_get_clean();
  }
  else {
    $merge_handle = popen("$SysMergeCmd $tempnew $tempold $temppag",'r');
    if ($merge_handle) {
      while (!feof($merge_handle)) $mergetext .= fread($merge_handle,4096);
      pclose($merge_handle);
    }
  }
  @unlink($tempnew); @unlink($tempold); @unlink($temppag);
  return $mergetext;
}

作者:jefmu    项目:pmwiki-kit-bootstrap-compas   
function FastCacheUpdate($pagename, &$page, &$new)
{
    global $IsPagePosted;
    global $FastCacheDir, $FastCacheInvalidateAllOnUpdate;
    if (!$IsPagePosted || !$FastCacheDir) {
        return;
    }
    if (IsEnabled($FastCacheInvalidateAllOnUpdate, TRUE)) {
        if (is_dir($FastCacheDir) && ($fd = opendir($FastCacheDir))) {
            while (($fh = readdir($fd)) !== FALSE) {
                if ($fh[0] == '.') {
                    continue;
                }
                if (!unlink("{$FastCacheDir}/{$fh}")) {
                    StopWatch("FastCacheUpdate: error unlinking file {$FastCacheDir}/{$fh} > stopping");
                    return;
                }
            }
        } else {
            StopWatch("FastCacheUpdate: error opening directory {$FastCacheDir}");
            return;
        }
    } else {
        SDV($FastCacheSuffix, '.html');
        $fcfile = "{$FastCacheDir}/{$pagename}{$FastCacheSuffix}";
        if (is_file($fcfile)) {
            if (!unlink($fcfile)) {
                StopWatch("FastCacheUpdate: error unlinking file {$fcfile}");
            }
        }
    }
}

作者:BogusCurr    项目:pmwik   
function EditDraft(&$pagename, &$page, &$new)
{
    global $WikiDir, $DraftSuffix, $DeleteKeyPattern, $EnableDraftAtomicDiff, $DraftRecentChangesFmt, $RecentChangesFmt, $Now;
    SDV($DeleteKeyPattern, "^\\s*delete\\s*\$");
    $basename = preg_replace("/{$DraftSuffix}\$/", '', $pagename);
    $draftname = $basename . $DraftSuffix;
    if ($_POST['postdraft'] || $_POST['postedit']) {
        $pagename = $draftname;
    } else {
        if ($_POST['post'] && !preg_match("/{$DeleteKeyPattern}/", $new['text'])) {
            $pagename = $basename;
            if (IsEnabled($EnableDraftAtomicDiff, 0)) {
                $page = ReadPage($basename);
                foreach ($new as $k => $v) {
                    # delete draft history
                    if (preg_match('/:\\d+(:\\d+:)?$/', $k) && !preg_match("/:{$Now}(:\\d+:)?\$/", $k)) {
                        unset($new[$k]);
                    }
                }
                unset($new['rev']);
                SDVA($new, $page);
            }
            $WikiDir->delete($draftname);
        } else {
            if (PageExists($draftname) && $pagename != $draftname) {
                Redirect($draftname, '$PageUrl?action=edit');
                exit;
            }
        }
    }
    if ($pagename == $draftname && isset($DraftRecentChangesFmt)) {
        $RecentChangesFmt = $DraftRecentChangesFmt;
    }
}

作者:anomen-    项目:pmwiki-recipe   
function FmtUploadList2($pagename, $args)
{
    global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $EnableUploadOverwrite, $FileListTimeFmt, $EnableDirectDownload, $HTMLStylesFmt, $FarmPubDirUrl;
    $HTMLStylesFmt['filelist'] = "\r\n   table.filelist { padding:0; margin:0; border-spacing:0; }\r\n   table.filelist td { padding:3px 0 0 0; margin:0; }\r\n   .filelist a { text-decoration:underline; }\r\n   .dotted  { background:url({$FarmPubDirUrl}/images/dot3.png) repeat-x bottom; }\r\n   .nodots { background:#feffff; }\r\n   ";
    $opt = ParseArgs($args);
    if (@$opt[''][0]) {
        $pagename = MakePageName($pagename, $opt[''][0]);
    }
    if (@$opt['re']) {
        $matchre = '/^(' . $opt['re'] . ')$/i';
    }
    if (@$opt['ext']) {
        $matchext = '/\\.(' . implode('|', preg_split('/\\W+/', $opt['ext'], -1, PREG_SPLIT_NO_EMPTY)) . ')$/i';
    }
    $uploaddir = FmtPageName("{$UploadDir}{$UploadPrefixFmt}", $pagename);
    $uploadurl = FmtPageName(IsEnabled($EnableDirectDownload, 1) ? "{$UploadUrlFmt}{$UploadPrefixFmt}/" : "\$PageUrl?action=download&upname=", $pagename);
    $dirp = @opendir($uploaddir);
    if (!$dirp) {
        return '';
    }
    $filelist = array();
    while (($file = readdir($dirp)) !== false) {
        if ($file[0] == '.') {
            continue;
        }
        if (@$matchext && !preg_match(@$matchext, $file)) {
            continue;
        }
        if (@$matchre && !preg_match(@$matchre, $file)) {
            continue;
        }
        $filelist[$file] = $file;
    }
    closedir($dirp);
    $out = array();
    #asort($filelist);
    $overwrite = '';
    foreach ($filelist as $file => $x) {
        $name = PUE("{$uploadurl}{$file}");
        $stat = stat("{$uploaddir}/{$file}");
        if ($EnableUploadOverwrite) {
            $overwrite = FmtPageName("<a class='createlink'\r\n        href='\$PageUrl?action=upload&amp;upname={$file}'>&nbsp;&Delta;</a>", $pagename);
        }
        $out[] = "<tr><td class='dotted'> <a href='{$name}'>{$file}</a>{$overwrite} &nbsp;&nbsp;</td>" . "<td class='dotted' align=right><span class='nodots'>" . number_format($stat['size'] / 1024) . "Kb</span></td>" . "<td>&nbsp;&nbsp;&nbsp;" . strftime($FileListTimeFmt, $stat['mtime']) . "</td>" . "<tr>";
    }
    return implode("\n", $out);
}

作者:BogusCurr    项目:pmwik   
function LinkHTTP($pagename, $imap, $path, $title, $txt, $fmt = NULL)
{
    global $EnableUrlApprovalRequired, $IMap, $WhiteUrlPatterns, $FmtV, $UnapprovedLinkFmt;
    if (!IsEnabled($EnableUrlApprovalRequired, 1)) {
        return LinkIMap($pagename, $imap, $path, $title, $txt, $fmt);
    }
    static $havereadpages;
    if (!$havereadpages) {
        ReadApprovedUrls($pagename);
        $havereadpages = true;
    }
    $p = str_replace(' ', '%20', $path);
    $url = str_replace('$1', $p, $IMap[$imap]);
    foreach ((array) $WhiteUrlPatterns as $pat) {
        if (preg_match("!^{$pat}(/|\$)!", $url)) {
            return LinkIMap($pagename, $imap, $path, $title, $txt, $fmt);
        }
    }
    $FmtV['$LinkText'] = $txt;
    return FmtPageName($UnapprovedLinkFmt, $pagename);
}

作者:BogusCurr    项目:pmwik   
Markup('[[', 'links', "/(?>\\[\\[\\s*(.*?)\\]\\])({$SuffixPattern})/e", "Keep(MakeLink(\$pagename,PSS('\$1'),NULL,'\$2'),'L')");
## [[!Category]]
SDV($CategoryGroup, 'Category');
SDV($LinkCategoryFmt, "<a class='categorylink' href='\$LinkUrl'>\$LinkText</a>");
Markup('[[!', '<[[', '/\\[\\[!(.*?)\\]\\]/e', "Keep(MakeLink(\$pagename,PSS('{$CategoryGroup}/\$1'),NULL,'',\$GLOBALS['LinkCategoryFmt']),'L')");
# This is a temporary workaround for blank category pages.
# It may be removed in a future release (Pm, 2006-01-24)
if (preg_match("/^{$CategoryGroup}\\./", $pagename)) {
    SDV($DefaultPageTextFmt, '');
    SDV($PageNotFoundHeaderFmt, 'HTTP/1.1 200 Ok');
}
## [[target | text]]
Markup('[[|', '<[[', "/(?>\\[\\[([^|\\]]*)\\|\\s*)(.*?)\\s*\\]\\]({$SuffixPattern})/e", "Keep(MakeLink(\$pagename,PSS('\$1'),PSS('\$2'),'\$3'),'L')");
## [[text -> target ]]
Markup('[[->', '>[[|', "/(?>\\[\\[([^\\]]+?)\\s*-+&gt;\\s*)(.*?)\\]\\]({$SuffixPattern})/e", "Keep(MakeLink(\$pagename,PSS('\$2'),PSS('\$1'),'\$3'),'L')");
if (IsEnabled($EnableRelativePageLinks, 1)) {
    SDV($QualifyPatterns['/(\\[\\[(?>[^\\]]+?->)?\\s*)([-\\w\\s\']+([|#?].*?)?\\]\\])/e'], "PSS('\$1').\$group.PSS('/\$2')");
}
## [[#anchor]]
Markup('[[#', '<[[', '/(?>\\[\\[#([A-Za-z][-.:\\w]*))\\]\\]/e', "Keep(TrackAnchors('\$1') ? '' : \"<a name='\$1' id='\$1'></a>\", 'L')");
function TrackAnchors($x)
{
    global $SeenAnchor;
    return @$SeenAnchor[$x]++;
}
## [[target |#]] reference links
Markup('[[|#', '<[[|', "/(?>\\[\\[([^|\\]]+))\\|\\s*#\\s*\\]\\]/e", "Keep(MakeLink(\$pagename,PSS('\$1'),'['.++\$MarkupFrame[0]['ref'].']'),'L')");
## [[target |+]] title links
Markup('[[|+', '<[[|', "/(?>\\[\\[([^|\\]]+))\\|\\s*\\+\\s*]]/e", "Keep(MakeLink(\$pagename, PSS('\$1'),\n                 PageVar(MakePageName(\$pagename,PSS('\$1')), '\$Title')\n                ),'L')");
## bare urllinks
Markup('urllink', '>[[', "/\\b(?>(\\L))[^\\s{$UrlExcludeChars}]*[^\\s.,?!{$UrlExcludeChars}]/e", "Keep(MakeLink(\$pagename,'\$0','\$0'),'L')");

作者:libcrac    项目:pmwik   
function BlockUnapprovedPosts($pagename, &$page, &$new)
{
    global $EnableUrlApprovalRequired, $UnapprovedLinkCount, $UnapprovedLinkCountMax, $EnablePost, $MessagesFmt, $BlockMessageFmt;
    if (!IsEnabled($EnableUrlApprovalRequired, 1)) {
        return;
    }
    if ($UnapprovedLinkCount <= $UnapprovedLinkCountMax) {
        return;
    }
    if ($page['=auth']['admin']) {
        return;
    }
    $EnablePost = 0;
    $MessagesFmt[] = $BlockMessageFmt;
}

作者:BogusCurr    项目:pmwik   
function MakePageList($pagename, $opt)
{
    global $MakePageListOpt, $SearchPatterns, $EnablePageListProtect, $PCache, $FmtV;
    StopWatch('MakePageList begin');
    SDVA($MakePageListOpt, array('list' => 'default'));
    $opt = array_merge((array) $MakePageListOpt, $opt);
    $readf = $opt['readf'];
    # we have to read the page if order= is anything but name
    $order = $opt['order'];
    $readf |= $order && $order != 'name' && $order != '-name';
    $pats = @(array) $SearchPatterns[$opt['list']];
    if (@$opt['group']) {
        array_unshift($pats, "/^({$opt['group']})\\./i");
    }
    # inclp/exclp contain words to be included/excluded.
    $inclp = array();
    $exclp = array();
    foreach ((array) @$opt[''] as $i) {
        $inclp[] = '/' . preg_quote($i, '/') . '/i';
    }
    foreach ((array) @$opt['+'] as $i) {
        $inclp[] = '/' . preg_quote($i, '/') . '/i';
    }
    foreach ((array) @$opt['-'] as $i) {
        $exclp[] = '/' . preg_quote($i, '/') . '/i';
    }
    $searchterms = count($inclp) + count($exclp);
    $readf += $searchterms;
    # forced read if incl/excl
    if (@$opt['trail']) {
        $trail = ReadTrail($pagename, $opt['trail']);
        foreach ($trail as $tstop) {
            $pn = $tstop['pagename'];
            $list[] = $pn;
            $tstop['parentnames'] = array();
            PCache($pn, $tstop);
        }
        foreach ($trail as $tstop) {
            $PCache[$tstop['pagename']]['parentnames'][] = $trail[$tstop['parent']]['pagename'];
        }
    } else {
        $list = ListPages($pats);
    }
    if (IsEnabled($EnablePageListProtect, 0)) {
        $readf = 1000;
    }
    $matches = array();
    $FmtV['$MatchSearched'] = count($list);
    # link= (backlinks)
    if (@$opt['link']) {
        $link = MakePageName($pagename, $opt['link']);
        $linkpat = "/(^|,){$link}(,|\$)/i";
        $readf++;
        $xlist = BacklinksTo($link, false);
        $list = array_diff($list, $xlist);
    }
    $xlist = array();
    StopWatch('MakePageList scan');
    foreach ((array) $list as $pn) {
        if ($readf) {
            $page = $readf >= 1000 ? RetrieveAuthPage($pn, 'read', false, READPAGE_CURRENT) : ReadPage($pn, READPAGE_CURRENT);
            if (!$page) {
                continue;
            }
            if (@$linkpat && !preg_match($linkpat, @$page['targets'])) {
                $PCache[$pn]['targets'] = @$page['targets'];
                $xlist[] = $pn;
                continue;
            }
            if ($searchterms) {
                $text = $pn . "\n" . @$page['targets'] . "\n" . @$page['text'];
                foreach ($inclp as $i) {
                    if (!preg_match($i, $text)) {
                        continue 2;
                    }
                }
                foreach ($exclp as $i) {
                    if (preg_match($i, $text)) {
                        continue 2;
                    }
                }
            }
            $page['size'] = strlen(@$page['text']);
        } else {
            $page = array();
        }
        $page['pagename'] = $page['name'] = $pn;
        PCache($pn, $page);
        $matches[] =& $PCache[$pn];
    }
    StopWatch('MakePageList sort');
    SortPageList($matches, $order);
    StopWatch('MakePageList update');
    if ($xlist) {
        LinkIndexUpdate($xlist);
    }
    StopWatch('MakePageList end');
    return $matches;
}

作者:BogusCurr    项目:pmwik   
function recode($pagename, $a) {
   if(!$a) return false;
   global $Charset, $PageRecodeFunction, $DefaultPageCharset, $EnableOldCharset;
   if (function_exists($PageRecodeFunction)) return $PageRecodeFunction($a);
   if (IsEnabled($EnableOldCharset)) $a['=oldcharset'] = @$a['charset'];
   SDVA($DefaultPageCharset, array(''=>@$Charset)); # pre-2.2.31 RecentChanges
   if (@$DefaultPageCharset[$a['charset']]>'')  # wrong pre-2.2.30 encs. *-2, *-9, *-13
     $a['charset'] = $DefaultPageCharset[@$a['charset']];
   if (!$a['charset'] || $Charset==$a['charset']) return $a;
   $from = ($a['charset']=='ISO-8859-1') ? 'WINDOWS-1252' : $a['charset'];
   $to = ($Charset=='ISO-8859-1') ? 'WINDOWS-1252' : $Charset;
   if ($this->recodefn) $F = $this->recodefn;
   elseif ($to=='UTF-8' && $from=='WINDOWS-1252') # utf8 wiki & pre-2.2.30 doc
     $F = create_function('$s,$from,$to', 'return utf8_encode($s);');
   elseif ($to=='WINDOWS-1252' && $from=='UTF-8') # 2.2.31+ documentation
     $F = create_function('$s,$from,$to', 'return utf8_decode($s);');
   else return $a;
   foreach($a as $k=>$v) $a[$k] = $F($v,$from,$to);
   $a['charset'] = $Charset;
   return $a;
 }

作者:BogusCurr    项目:pmwik   
function HandlePostAttr($pagename)
{
    global $PageAttributes, $EnablePostAttrClearSession;
    Lock(2);
    $page = RetrieveAuthPage($pagename, 'attr', true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?unable to read {$pagename}");
    }
    foreach ($PageAttributes as $attr => $p) {
        $v = @$_POST[$attr];
        if ($v == '') {
            continue;
        }
        if ($v == 'clear') {
            unset($page[$attr]);
        } else {
            if (strncmp($attr, 'passwd', 6) != 0) {
                $page[$attr] = $v;
            } else {
                $a = array();
                foreach (preg_split('/\\s+/', $v, -1, PREG_SPLIT_NO_EMPTY) as $pw) {
                    $a[] = preg_match('/^\\w+:/', $pw) ? $pw : crypt($pw);
                }
                if ($a) {
                    $page[$attr] = implode(' ', $a);
                }
            }
        }
    }
    WritePage($pagename, $page);
    Lock(0);
    if (IsEnabled($EnablePostAttrClearSession, 1)) {
        @session_start();
        unset($_SESSION['authid']);
        $_SESSION['authpw'] = array();
    }
    Redirect($pagename);
    exit;
}

作者:BML    项目:memoryhole-ansibl   
function NotifyUpdate($pagename, $dir = '')
{
    global $NotifyList, $NotifyListPageFmt, $NotifyFile, $IsPagePosted, $IsUploadPosted, $FmtV, $NotifyTimeFmt, $NotifyItemFmt, $SearchPatterns, $NotifySquelch, $NotifyDelay, $Now, $Charset, $EnableNotifySubjectEncode, $NotifySubjectFmt, $NotifyBodyFmt, $NotifyHeaders, $NotifyParameters;
    $abort = ignore_user_abort(true);
    if ($dir) {
        flush();
        chdir($dir);
    }
    $GLOBALS['EnableRedirect'] = 0;
    ##   Read in the current notify configuration
    $pn = FmtPageName($NotifyListPageFmt, $pagename);
    $npage = ReadPage($pn, READPAGE_CURRENT);
    preg_match_all('/^[\\s*:#->]*(notify[:=].*)/m', $npage['text'], $nlist);
    $nlist = array_merge((array) @$NotifyList, (array) @$nlist[1]);
    if (!$nlist) {
        return;
    }
    ##   make sure other processes are locked out
    Lock(2);
    ##   let's load the current .notifylist table
    $nfile = FmtPageName($NotifyFile, $pagename);
    $nfp = @fopen($nfile, 'r');
    if ($nfp) {
        ##   get our current squelch and delay timestamps
        clearstatcache();
        $sz = filesize($nfile);
        list($nextevent, $firstpost) = explode(' ', rtrim(fgets($nfp, $sz)));
        ##   restore our notify array
        $notify = unserialize(fgets($nfp, $sz));
        fclose($nfp);
    }
    if (!is_array($notify)) {
        $notify = array();
    }
    ##   if this is for a newly posted page, get its information
    if ($IsPagePosted || $IsUploadPosted) {
        $page = ReadPage($pagename, READPAGE_CURRENT);
        $FmtV['$PostTime'] = strftime($NotifyTimeFmt, $Now);
        $item = urlencode(FmtPageName($NotifyItemFmt, $pagename));
        if ($firstpost < 1) {
            $firstpost = $Now;
        }
    }
    foreach ($nlist as $n) {
        $opt = ParseArgs($n);
        $mailto = preg_split('/[\\s,]+/', $opt['notify']);
        if (!$mailto) {
            continue;
        }
        if ($opt['squelch']) {
            foreach ($mailto as $m) {
                $squelch[$m] = $opt['squelch'];
            }
        }
        if (!$IsPagePosted) {
            continue;
        }
        if ($opt['link']) {
            $link = MakePageName($pagename, $opt['link']);
            if (!preg_match("/(^|,){$link}(,|\$)/i", $page['targets'])) {
                continue;
            }
        }
        $pats = @(array) $SearchPatterns[$opt['list']];
        if ($opt['group']) {
            $pats[] = FixGlob($opt['group'], '$1$2.*');
        }
        if ($opt['name']) {
            $pats[] = FixGlob($opt['name'], '$1*.$2');
        }
        if ($pats && !MatchPageNames($pagename, $pats)) {
            continue;
        }
        if ($opt['trail']) {
            $trail = ReadTrail($pagename, $opt['trail']);
            for ($i = 0; $i < count($trail); $i++) {
                if ($trail[$i]['pagename'] == $pagename) {
                    break;
                }
            }
            if ($i >= count($trail)) {
                continue;
            }
        }
        foreach ($mailto as $m) {
            $notify[$m][] = $item;
        }
    }
    $nnow = time();
    if ($nnow < $firstpost + $NotifyDelay) {
        $nextevent = $firstpost + $NotifyDelay;
    } else {
        $firstpost = 0;
        $nextevent = $nnow + 86400;
        $mailto = array_keys($notify);
        $subject = FmtPageName($NotifySubjectFmt, $pagename);
        if (IsEnabled($EnableNotifySubjectEncode, 0) && preg_match("/[^ -~]/", $subject)) {
            $subject = strtoupper("=?{$Charset}?B?") . base64_encode($subject) . "?=";
        }
        $body = FmtPageName($NotifyBodyFmt, $pagename);
//.........这里部分代码省略.........

作者:BogusCurr    项目:pmwik   
function MakePageList($pagename, $opt, $retpages = 1)
{
    global $MakePageListOpt, $SearchPatterns, $EnablePageListProtect, $PCache, $FmtV;
    StopWatch('MakePageList begin');
    SDVA($MakePageListOpt, array('list' => 'default'));
    $opt = array_merge((array) $MakePageListOpt, $opt);
    $readf = @$opt['readf'];
    # we have to read the page if order= is anything but name
    $order = @$opt['order'];
    $readf |= $order && $order != 'name' && $order != '-name';
    $pats = @(array) $SearchPatterns[$opt['list']];
    if (@$opt['group']) {
        $pats[] = FixGlob($opt['group'], '$1$2.*');
    }
    if (@$opt['name']) {
        $pats[] = FixGlob($opt['name'], '$1*.$2');
    }
    # inclp/exclp contain words to be included/excluded.
    $incl = array();
    $inclp = array();
    $inclx = false;
    $excl = array();
    $exclp = '';
    foreach ((array) @$opt[''] as $i) {
        $incl[] = $i;
    }
    foreach ((array) @$opt['+'] as $i) {
        $incl[] = $i;
    }
    foreach ((array) @$opt['-'] as $i) {
        $excl[] = $i;
    }
    foreach ($incl as $i) {
        $inclp[] = '$' . preg_quote($i) . '$i';
        $inclx |= preg_match('[^\\w\\x80-\\xff]', $i);
    }
    if ($excl) {
        $exclp = '$' . implode('|', array_map('preg_quote', $excl)) . '$i';
    }
    $searchterms = count($incl) + count($excl);
    $readf += $searchterms;
    # forced read if incl/excl
    if (@$opt['trail']) {
        $trail = ReadTrail($pagename, $opt['trail']);
        $list = array();
        foreach ($trail as $tstop) {
            $pn = $tstop['pagename'];
            $list[] = $pn;
            $tstop['parentnames'] = array();
            PCache($pn, $tstop);
        }
        foreach ($trail as $tstop) {
            $PCache[$tstop['pagename']]['parentnames'][] = @$trail[$tstop['parent']]['pagename'];
        }
    } else {
        $list = ListPages($pats);
    }
    if (IsEnabled($EnablePageListProtect, 1)) {
        $readf = 1000;
    }
    $matches = array();
    $FmtV['$MatchSearched'] = count($list);
    $terms = $incl ? PageIndexTerms($incl) : array();
    if (@$opt['link']) {
        $link = MakePageName($pagename, $opt['link']);
        $linkp = "/(^|,){$link}(,|\$)/i";
        $terms[] = " {$link} ";
        $readf++;
    }
    if ($terms) {
        $xlist = PageIndexGrep($terms, true);
        $a = count($list);
        $list = array_diff($list, $xlist);
        $a -= count($list);
        StopWatch("MakePageList: PageIndex filtered {$a} pages");
    }
    $xlist = array();
    StopWatch('MakePageList scanning ' . count($list) . " pages, readf={$readf}");
    foreach ((array) $list as $pn) {
        if ($readf) {
            $page = $readf >= 1000 ? RetrieveAuthPage($pn, 'read', false, READPAGE_CURRENT) : ReadPage($pn, READPAGE_CURRENT);
            if (!$page) {
                continue;
            }
            if (@$linkp && !preg_match($linkp, @$page['targets'])) {
                $xlist[] = $pn;
                continue;
            }
            if ($searchterms) {
                $text = $pn . "\n" . @$page['targets'] . "\n" . @$page['text'];
                if ($exclp && preg_match($exclp, $text)) {
                    continue;
                }
                foreach ($inclp as $i) {
                    if (!preg_match($i, $text)) {
                        if (!$inclx) {
                            $xlist[] = $pn;
                        }
                        continue 2;
                    }
//.........这里部分代码省略.........

作者:BogusCurr    项目:pmwik   
function PageListProtect(&$list, &$opt, $pn, &$page)
{
    global $EnablePageListProtect;
    switch ($opt['=phase']) {
        case PAGELIST_PRE:
            if (!IsEnabled($EnablePageListProtect, 1) && @$opt['readf'] < 1000) {
                return 0;
            }
            StopWatch("PageListProtect enabled");
            $opt['=protectexclude'] = array();
            $opt['=protectsafe'] = (array) @$opt['=protectsafe'];
            return PAGELIST_ITEM | PAGELIST_POST;
        case PAGELIST_ITEM:
            if (@$opt['=protectsafe'][$pn]) {
                return 1;
            }
            $page = RetrieveAuthPage($pn, 'ALWAYS', false, READPAGE_CURRENT);
            $opt['=readc']++;
            if (!$page['=auth']['read']) {
                $opt['=protectexclude'][$pn] = 1;
            }
            if (!$page['=passwd']['read']) {
                $opt['=protectsafe'][$pn] = 1;
            }
            return 1;
        case PAGELIST_POST:
            $excl = array_keys($opt['=protectexclude']);
            $safe = array_keys($opt['=protectsafe']);
            StopWatch("PageListProtect excluded=" . count($excl) . ", safe=" . count($safe));
            $list = array_diff($list, $excl);
            return 1;
    }
}

作者:BogusCurr    项目:pmwik   
$FmtP to hide any "?action=" url parameters in page urls
    generated by PmWiki for actions that robots aren't allowed to
    access.  This can greatly reduce the load on the server by 
    not providing the robot with links to pages that it will be 
    forbidden to index anyway.  
*/
## $MetaRobots provides the value for the <meta name='robots' ...> tag.
SDV($MetaRobots, $action != 'browse' || preg_match('#^PmWiki[./](?!PmWiki$)|^Site[./]#', $pagename) ? 'noindex,nofollow' : 'index,follow');
if ($MetaRobots) {
    $HTMLHeaderFmt['robots'] = "  <meta name='robots' content='\$MetaRobots' />\n";
}
## $RobotPattern is used to identify robots.
SDV($RobotPattern, 'Googlebot|Slurp|msnbot|Teoma|ia_archiver|BecomeBot|HTTrack|MJ12bot');
SDV($IsRobotAgent, $RobotPattern && preg_match("!{$RobotPattern}!", @$_SERVER['HTTP_USER_AGENT']));
if (!$IsRobotAgent) {
    return;
}
## $RobotActions indicates which actions a robot is allowed to perform.
SDVA($RobotActions, array('browse' => 1, 'rss' => 1, 'dc' => 1));
if (!@$RobotActions[$action]) {
    header("HTTP/1.1 403 Forbidden");
    print "<h1>Forbidden</h1>";
    exit;
}
## The following removes any ?action= parameters that robots aren't
## allowed to access.
if (IsEnabled($EnableRobotCloakActions, 0)) {
    $p = create_function('$a', 'return (boolean)$a;');
    $p = join('|', array_keys(array_filter($RobotActions, $p)));
    $FmtP["/(\\\$ScriptUrl[^#\"'\\s<>]+)\\?action=(?!{$p})\\w+/"] = '$1';
}

作者:BML    项目:memoryhole-ansibl   
For example, to create customizations for the 'Demo' group, place 
    them in a file called local/Demo.php.  To customize a single page, 
    use the full page name (e.g., local/Demo.MyPage.php).  
    Per-page/per-group customizations can be handled at any time by adding
	include_once("scripts/pgcust.php");
    to config.php.  It is automatically included by scripts/stdconfig.php
    unless $EnablePGCust is set to zero in config.php.

    A page's customization is loaded first, followed by any group
    customization.  If no page or group customizations are loaded,
    then 'local/default.php' is loaded.  

    A per-page configuration file can prevent its group's config from 
    loading by setting $EnablePGCust=0;.  A per-page configuration file 
    can force group customizations to be loaded first by using include_once
    on the group customization file.
    
*/
$f = 1;
for ($p = $pagename; $p; $p = preg_replace('/\\.*[^.]*$/', '', $p)) {
    if (!IsEnabled($EnablePGCust, 1)) {
        return;
    }
    if (file_exists("{$LocalDir}/{$p}.php")) {
        include_once "{$LocalDir}/{$p}.php";
        $f = 0;
    }
}
if ($f && IsEnabled($EnablePGCust, 1) && file_exists("{$LocalDir}/default.php")) {
    include_once "{$LocalDir}/default.php";
}

作者:BogusCurr    项目:pmwik   
function InputDefault($pagename, $type, $args) {
  global $InputValues, $PageTextVarPatterns, $PCache;
  $args = ParseArgs($args);
  $args[''] = (array)@$args[''];
  $name = (isset($args['name'])) ? $args['name'] : array_shift($args['']);
  $name = preg_replace('/^\\$:/', 'ptv_', $name);
  $value = (isset($args['value'])) ? $args['value'] : array_shift($args['']);
  if (!isset($InputValues[$name])) $InputValues[$name] = $value;
  if (@$args['request']) {
    $req = array_merge($_GET, $_POST);
    foreach($req as $k => $v) 
      if (!isset($InputValues[$k])) 
        $InputValues[$k] = htmlspecialchars(stripmagic($v), ENT_NOQUOTES);
  }
  $source = @$args['source'];
  if ($source) {
    $source = MakePageName($pagename, $source);
    $page = RetrieveAuthPage($source, 'read', false, READPAGE_CURRENT);
    if ($page) {
      foreach((array)$PageTextVarPatterns as $pat)
        if (preg_match_all($pat, IsEnabled($PCache[$source]['=preview'], $page['text']), 
          $match, PREG_SET_ORDER))
          foreach($match as $m)
            if (!isset($InputValues['ptv_'.$m[2]]))
              $InputValues['ptv_'.$m[2]] = 
                htmlspecialchars(Qualify($source, $m[3]), ENT_NOQUOTES);
    }
  }
  return '';
}

作者:BogusCurr    项目:pmwik   
SDV($AuthorRequiredFmt, "<h3 class='wikimessage'>\$[An author name is required.]</h3>");
Markup('[[~', '<[[', '/\\[\\[~(.*?)\\]\\]/', "[[{$AuthorGroup}/\$1]]");
"[[{$AuthorGroup}/\$1]]";
if (!isset($Author)) {
    if (isset($_POST['author'])) {
        $Author = htmlspecialchars(stripmagic($_POST['author']), ENT_QUOTES);
        setcookie('author', $Author, $AuthorCookieExpires, $AuthorCookieDir);
    } else {
        $Author = htmlspecialchars(stripmagic(@$_COOKIE['author']), ENT_QUOTES);
    }
    $Author = preg_replace('/(^[^[:alpha:]]+)|[^\\w- ]/', '', $Author);
}
$k = MakePageName($pagename, $Author);
SDV($AuthorPage, "{$AuthorGroup}/{$k}");
SDV($AuthorLink, "[[~{$Author}]]");
if (IsEnabled($EnableAuthorSignature, 1)) {
    $ROSPatterns['/~~~~/'] = '[[~$Author]] $CurrentTime';
    $ROSPatterns['/~~~/'] = '[[~$Author]]';
}
if (IsEnabled($EnableAuthorRequired, 0)) {
    array_unshift($EditFunctions, 'RequireAuthor');
}
## RequireAuthor forces an author to enter a name before posting.
function RequireAuthor($pagename, &$page, &$new)
{
    global $Author, $EditMessageFmt, $AuthorRequiredFmt;
    if (!$Author) {
        $EditMessageFmt .= $AuthorRequiredFmt;
        $_REQUEST['post'] = '';
    }
}

作者:BogusCurr    项目:pmwik   
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);
}

作者:BogusCurr    项目:pmwik   
<?php

if (!defined('PmWiki')) {
    exit;
}
/*  Copyright 2004 Patrick R. Michaud (pmichaud@pobox.com)
    This file is part of PmWiki; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.  See pmwiki.php for full details.
*/
## %% markup
Markup('%%', 'style', '%', 'return ApplyStyles($x);');
## restore links before applying styles
Markup('restorelinks', '<%%', "/{$KeepToken}(\\d+L){$KeepToken}/e", '$GLOBALS[\'KPV\'][\'$1\']');
if (IsEnabled($EnableStdWikiStyles, 1)) {
    ## standard colors
    foreach (array('black', 'white', 'red', 'yellow', 'blue', 'gray', 'silver', 'maroon', 'green', 'navy', 'purple') as $c) {
        SDV($WikiStyle[$c]['color'], $c);
    }
    ## %newwin% style opens links in a new window
    SDV($WikiStyle['newwin']['target'], '_blank');
    ## %comment% style turns markup into a comment via display:none css
    SDV($WikiStyle['comment']['display'], 'none');
    ## display, margin, padding, and border css properties
    $WikiStyleCSS[] = 'display|(margin|padding|border)(-(left|right|top|bottom))?';
    ## list-styles
    $WikiStyleCSS[] = 'list-style';
    foreach (array('decimal' => 'decimal', 'roman' => 'lower-roman', 'ROMAN' => 'upper-roman', 'alpha' => 'lower-alpha', 'ALPHA' => 'upper-alpha') as $k => $v) {
        SDV($WikiStyle[$k], array('apply' => 'list', 'list-style' => $v));
    }

作者:BogusCurr    项目:pmwik   
if ($action == 'diff' && @(!$HandleActions['diff'])) {
    include_once "{$FarmD}/scripts/pagerev.php";
}
if (IsEnabled($EnableWikiTrails, 1)) {
    include_once "{$FarmD}/scripts/trails.php";
}
if (IsEnabled($EnableStdWikiStyles, 1)) {
    include_once "{$FarmD}/scripts/wikistyles.php";
}
if (IsEnabled($EnableMailPosts, 0)) {
    include_once "{$FarmD}/scripts/mailposts.php";
}
if (IsEnabled($EnableUpload, 0)) {
    include_once "{$FarmD}/scripts/upload.php";
}
if (IsEnabled($EnablePageList, 1)) {
    include_once "{$FarmD}/scripts/pagelist.php";
}
if (IsEnabled($EnableDiag, 0)) {
    include_once "{$FarmD}/scripts/diag.php";
}
if (IsEnabled($EnableVarMarkup, 1)) {
    include_once "{$FarmD}/scripts/vardoc.php";
}
if ($action == 'crypt') {
    include_once "{$FarmD}/scripts/crypt.php";
}
SDV($MetaRobots, $action != 'browse' || preg_match('#^PmWiki[./](?!PmWiki$)#', $pagename) ? 'noindex,nofollow' : 'index,follow');
if ($MetaRobots) {
    $HTMLHeaderFmt[] = "  <meta name='robots' content='{$MetaRobots}' />\n";
}


问题


面经


文章

微信
公众号

扫码关注公众号