本文整理汇总了PHP中ReadPage函数的典型用法代码示例。如果您正苦于以下问题:PHP ReadPage函数的具体用法?PHP ReadPage怎么用?PHP ReadPage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadPage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: HandleApprove
function HandleApprove($pagename)
{
global $ApproveUrlPattern, $WhiteUrlPatterns, $ApprovedUrlPagesFmt, $action;
Lock(2);
$page = ReadPage($pagename);
$text = preg_replace('/[()]/', '', $page['text']);
preg_match_all("/{$ApproveUrlPattern}/", $text, $match);
ReadApprovedUrls($pagename);
$addpat = array();
foreach ($match[0] as $a) {
foreach ((array) $WhiteUrlPatterns as $pat) {
if (preg_match("!^{$pat}(/|\$)!", $a)) {
continue 2;
}
}
if ($action == 'approvesites') {
$a = preg_replace("!^([^:]+://[^/]+).*\$!", '$1', $a);
}
$addpat[] = $a;
}
if (count($addpat) > 0) {
$aname = FmtPageName($ApprovedUrlPagesFmt[0], $pagename);
$apage = ReadPage($aname, '');
$new = $apage;
if (substr($new['text'], -1, 1) != "\n") {
$new['text'] .= "\n";
}
foreach ($addpat as $pat) {
$new['text'] .= " {$pat}\n";
}
$_REQUEST['post'] = 'y';
PostPage($aname, $apage, $new);
}
Redirect($pagename);
}
示例2: ReadTrail
function ReadTrail($pagename, $trailname)
{
global $SuffixPattern, $GroupPattern, $WikiWordPattern;
$trailname = MakePageName($pagename, $trailname);
$trailpage = ReadPage($trailname);
if (!$trailpage) {
return false;
}
$t = array();
$n = 0;
foreach (explode("\n", @$trailpage['text']) as $x) {
$x = preg_replace("/^([#*]+)\\s*(({$GroupPattern}([\\.]))?{$WikiWordPattern})/", '$1 [[$2]]', $x);
$x = preg_replace("/\\[\\[([^\\]]*)->([^\\]]*)\\]\\]/", '[[$2|$1]]', $x);
if (!preg_match("/^([#*]+)\\s*(\\[\\[([^|]*?)(\\|.*?)?\\]\\]({$SuffixPattern}))(.*)\$/", $x, $match)) {
continue;
}
$tgt = MakePageName($trailname, $match[3]);
$t[$n]['depth'] = $depth = strlen($match[1]);
$t[$n]['pagename'] = $tgt;
$t[$n]['markup'] = $match[2];
for ($i = $depth; $i < 10; $i++) {
$d[$i] = $n;
}
if ($depth > 1) {
$t[$n]['parent'] = @$d[$depth - 1];
}
$n++;
}
return $t;
}
示例3: VarIndexLoad
function VarIndexLoad($pagename) {
global $VarPagesFmt,$VarIndex,$WikiWordPattern;
static $loaded;
$VarIndex = (array)@$VarIndex;
if ($loaded) return;
foreach($VarPagesFmt as $vf) {
$v = FmtPageName($vf, $pagename);
if (@$loaded[$v]) continue;
$vlist = array($v);
$t = ReadTrail($pagename,$v);
if ($t)
for($i=0;$i<count($t);$i++)
if (@!$loaded[$t[$i]['pagename']]) $vlist[]=$t[$i]['pagename'];
foreach($vlist as $vname) {
$vpage = ReadPage($vname, READPAGE_CURRENT); @$loaded[$vname]++;
if (!$vpage) continue;
if (!preg_match_all("/\n:\\$([[:upper:]]\\w+):/",@$vpage['text'],$match))
continue;
foreach($match[1] as $n) {
$VarIndex[$n]['pagename'] = $vname;
$VarIndex[$n]['url'] = FmtPageName("{\$PageUrl}#$n",$vname);
}
}
}
}
示例4: EditDraft
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;
}
}
示例5: PrintDiff
function PrintDiff($pagename) {
global $DiffHTMLFunction,$DiffShow,$DiffStartFmt,$TimeFmt,
$DiffEndFmt,$DiffRestoreFmt,$FmtV, $LinkFunctions;
$page = ReadPage($pagename);
if (!$page) return;
krsort($page); reset($page);
$lf = $LinkFunctions;
$LinkFunctions['http:'] = 'LinkSuppress';
$LinkFunctions['https:'] = 'LinkSuppress';
SDV($DiffHTMLFunction, 'DiffHTML');
foreach($page as $k=>$v) {
if (!preg_match("/^diff:(\d+):(\d+):?([^:]*)/",$k,$match)) continue;
$diffclass = $match[3];
if ($diffclass=='minor' && $DiffShow['minor']!='y') continue;
$diffgmt = $FmtV['$DiffGMT'] = $match[1];
$FmtV['$DiffTime'] = strftime($TimeFmt,$diffgmt);
$diffauthor = @$page["author:$diffgmt"];
if (!$diffauthor) @$diffauthor=$page["host:$diffgmt"];
if (!$diffauthor) $diffauthor="unknown";
$FmtV['$DiffChangeSum'] = htmlspecialchars(@$page["csum:$diffgmt"]);
$FmtV['$DiffHost'] = @$page["host:$diffgmt"];
$FmtV['$DiffAuthor'] = $diffauthor;
$FmtV['$DiffId'] = $k;
$html = $DiffHTMLFunction($pagename, $v);
if ($html===false) continue;
echo FmtPageName($DiffStartFmt,$pagename);
echo $html;
echo FmtPageName($DiffEndFmt,$pagename);
echo FmtPageName($DiffRestoreFmt,$pagename);
}
$LinkFunctions = $lf;
}
示例6: AuthUserId
function AuthUserId($pagename, $id, $pw = NULL)
{
global $AuthUser, $AuthUserPageFmt, $AuthUserFunctions, $AuthId, $AuthList, $MessagesFmt;
$auth = $AuthUser;
$authid = '';
# load information from Site.AuthUser (or page in $AuthUserPageFmt)
SDV($AuthUserPageFmt, '$SiteGroup.AuthUser');
SDVA($AuthUserFunctions, array('htpasswd' => 'AuthUserHtPasswd', 'ldap' => 'AuthUserLDAP', $id => 'AuthUserConfig'));
$pn = FmtPageName($AuthUserPageFmt, $pagename);
$apage = ReadPage($pn, READPAGE_CURRENT);
if ($apage && preg_match_all("/\n\\s*([@\\w][^\\s:]*):(.*)/", $apage['text'], $matches, PREG_SET_ORDER)) {
foreach ($matches as $m) {
if (!preg_match_all('/\\bldap:\\S+|[^\\s,]+/', $m[2], $v)) {
continue;
}
if ($m[1][0] == '@') {
foreach ($v[0] as $g) {
$auth[$g][] = $m[1];
}
} else {
$auth[$m[1]] = array_merge((array) @$auth[$m[1]], $v[0]);
}
}
}
if (is_null($pw)) {
$authid = $id;
} else {
foreach ($AuthUserFunctions as $k => $fn) {
if ($auth[$k] && $fn($pagename, $id, $pw, $auth[$k])) {
$authid = $id;
break;
}
}
}
if (!$authid) {
$GLOBALS['InvalidLogin'] = 1;
return;
}
if (!isset($AuthId)) {
$AuthId = $authid;
}
@session_start();
$_SESSION['authid'] = $authid;
$_SESSION['authlist']["id:{$authid}"] = 1;
$_SESSION['authlist']["id:-{$authid}"] = -1;
$_SESSION['authlist']["id:*"] = 1;
foreach ((array) @$auth[$authid] as $g) {
if ($g[0] == '@') {
@($_SESSION['authlist'][$g] = 1);
}
}
foreach ((array) @$auth['*'] as $g) {
if ($g[0] == '@') {
@($_SESSION['authlist'][$g] = 1);
}
}
$AuthList = array_merge($AuthList, $_SESSION['authlist']);
}
示例7: HTTPBasicAuth
function HTTPBasicAuth($pagename, $level, $authprompt = true)
{
global $AuthRealmFmt, $AuthDeniedFmt, $DefaultPasswords, $AllowPassword, $GroupAttributesFmt;
SDV($GroupAttributesFmt, '$Group/GroupAttributes');
SDV($AllowPassword, 'nopass');
SDV($AuthRealmFmt, $GLOBALS['WikiTitle']);
SDV($AuthDeniedFmt, 'A valid password is required to access this feature.');
$page = ReadPage($pagename);
if (!$page) {
return false;
}
$passwd = @$page["passwd{$level}"];
if ($passwd == "") {
$grouppg = ReadPage(FmtPageName($GroupAttributesFmt, $pagename));
$passwd = @$grouppg["passwd{$level}"];
if ($passwd == '') {
$passwd = @$DefaultPasswords[$level];
}
if ($passwd == '') {
$passwd = @$page["passwdread"];
}
if ($passwd == '') {
$passwd = @$grouppg["passwdread"];
}
if ($passwd == '') {
$passwd = @$DefaultPasswords['read'];
}
}
if ($passwd == '') {
return $page;
}
if (crypt($AllowPassword, $passwd) == $passwd) {
return $page;
}
@session_start();
if (@$_SERVER['PHP_AUTH_PW']) {
@$_SESSION['authpw'][$_SERVER['PHP_AUTH_PW']]++;
}
$authpw = array_keys((array) @$_SESSION['authpw']);
foreach (array_merge((array) $DefaultPasswords['admin'], (array) $passwd) as $pwchal) {
foreach ($authpw as $pwresp) {
if (@crypt($pwresp, $pwchal) == $pwchal) {
return $page;
}
}
}
if (!$authprompt) {
return false;
}
$realm = FmtPageName($AuthRealmFmt, $pagename);
header("WWW-Authenticate: Basic realm=\"{$realm}\"");
header("Status: 401 Unauthorized");
header("HTTP-Status: 401 Unauthorized");
PrintFmt($pagename, $AuthDeniedFmt);
exit;
}
示例8: ExportActionHandler
function ExportActionHandler($pagename, $auth)
{
// read the page and sort keys chronologically
$page = ReadPage($pagename);
if (!$page || !$page['name']) {
return;
}
krsort($page);
reset($page);
// start with the latest version
$versions = [];
$version['author'] = $page['author'];
$version['timestamp'] = $page['time'];
$version['source'] = utf8_encode($page['text']);
array_push($versions, $version);
// use the page's diff keys to restore markup for older version
foreach ($page as $key => $value) {
if (!preg_match("/^diff:(\\d+):(\\d+):?([^:]*)/", $key, $match)) {
continue;
}
// ignore the original diff tag, which is is not a delta
// ignore blank changes
// ignore some rare dupes
if ($match[1] === $match[2]) {
continue;
}
if (@$page[$match[0]] === '') {
continue;
}
if (array_search($match[2], array_column($versions, 'timestamp'))) {
continue;
}
// metadata
$diffgmt = $match[1];
$diffauthor = @$page["author:{$diffgmt}"];
if (!$diffauthor) {
@($diffauthor = $page["host:{$diffgmt}"]);
}
if (!$diffauthor) {
$diffauthor = "unknown";
}
$diffchangesum = PHSC(@$page["csum:{$diffgmt}"]);
// page version
$version = [];
$version['author'] = $diffauthor;
$version['timestamp'] = $match[2];
$version['commit_message'] = $diffchangesum;
$version['source'] = utf8_encode(RestorePage($pagename, $page, $new, $match[0]));
array_push($versions, $version);
}
// finalize response
$response['page_name'] = $pagename;
$response['versions'] = $versions;
$response = json_encode($response);
echo $response;
}
示例9: AuthUserId
function AuthUserId($pagename, $id, $pw=NULL) {
global $AuthUser, $AuthUserPageFmt, $AuthUserFunctions,
$AuthId, $MessagesFmt, $AuthUserPat;
$auth = array();
foreach((array)$AuthUser as $k=>$v) $auth[$k] = (array)$v;
$authid = '';
# load information from SiteAdmin.AuthUser (or page in $AuthUserPageFmt)
SDV($AuthUserPageFmt, '$SiteAdminGroup.AuthUser');
SDVA($AuthUserFunctions, array(
'htpasswd' => 'AuthUserHtPasswd',
'ldap' => 'AuthUserLDAP',
# 'mysql' => 'AuthUserMySQL',
$id => 'AuthUserConfig'));
SDV($AuthUserPat, "/^\\s*([@\\w][^\\s:]*):(.*)/m");
$pn = FmtPageName($AuthUserPageFmt, $pagename);
$apage = ReadPage($pn, READPAGE_CURRENT);
if ($apage && preg_match_all($AuthUserPat,
$apage['text'], $matches, PREG_SET_ORDER)) {
foreach($matches as $m) {
if (!preg_match_all('/\\bldaps?:\\S+|[^\\s,]+/', $m[2], $v))
continue;
if ($m[1]{0} == '@')
foreach($v[0] as $g) $auth[$g][] = $m[1];
else $auth[$m[1]] = array_merge((array)@$auth[$m[1]], $v[0]);
}
}
if (func_num_args()==2) $authid = $id;
else
foreach($AuthUserFunctions as $k => $fn)
if (@$auth[$k] && $fn($pagename, $id, $pw, $auth[$k], $authlist))
{ $authid = $id; break; }
if (!$authid) { $GLOBALS['InvalidLogin'] = 1; return; }
if (!isset($AuthId)) $AuthId = $authid;
$authlist["id:$authid"] = 1;
$authlist["id:-$authid"] = -1;
foreach(preg_grep('/^@/', (array)@$auth[$authid]) as $g)
$authlist[$g] = 1;
foreach(preg_grep('/^@/', (array)@$auth['*']) as $g)
$authlist[$g] = 1;
foreach(preg_grep('/^@/', array_keys($auth)) as $g) # useless? PITS:01201
if (in_array($authid, $auth[$g])) $authlist[$g] = 1;
if ($auth['htgroup']) {
foreach(AuthUserHtGroup($pagename, $id, $pw, $auth['htgroup']) as $g)
$authlist["@$g"] = 1;
}
foreach(preg_grep('/^@/', (array)@$auth["-$authid"]) as $g)
unset($authlist[$g]);
SessionAuth($pagename, array('authid' => $authid, 'authlist' => $authlist));
}
示例10: EditDraft
function EditDraft(&$pagename, &$page, &$new)
{
global $WikiDir, $DraftSuffix, $DeleteKeyPattern;
SDV($DeleteKeyPattern, "^\\s*delete\\s*\$");
$basename = preg_replace("/{$DraftSuffix}\$/", '', $pagename);
$draftname = $basename . $DraftSuffix;
if ($_POST['postdraft']) {
$pagename = $draftname;
return;
}
if ($_POST['post'] && !preg_match("/{$DeleteKeyPattern}/", $new['text'])) {
$pagename = $basename;
$page = ReadPage($basename);
$WikiDir->delete($draftname);
return;
}
if (PageExists($draftname) && $pagename != $draftname) {
Redirect($draftname, '$PageUrl?action=edit');
exit;
}
}
示例11: ReadTrail
function ReadTrail($pagename, $trailname)
{
global $SuffixPattern, $GroupPattern, $WikiWordPattern, $LinkWikiWords;
if (preg_match('/^\\[\\[(.+?)(->|\\|)(.+?)\\]\\]$/', $trailname, $m)) {
$trailname = $m[2] == '|' ? $m[1] : $m[3];
}
$trailname = MakePageName($pagename, $trailname);
$trailpage = ReadPage($trailname, READPAGE_CURRENT);
if (!$trailpage) {
return false;
}
$t = array();
$n = 0;
foreach (explode("\n", @$trailpage['text']) as $x) {
$x = preg_replace("/\\[\\[([^\\]]*)->([^\\]]*)\\]\\]/", '[[$2|$1]]', $x);
if (!preg_match("/^([#*:]+) \\s* \n (\\[\\[([^:#!|][^|:]*?)(\\|.*?)?\\]\\]({$SuffixPattern})\n | (({$GroupPattern}([\\/.]))?{$WikiWordPattern})) (.*)/x", $x, $match)) {
continue;
}
if (@$match[6]) {
if (!$LinkWikiWords) {
continue;
}
$tgt = MakePageName($trailname, $match[6]);
} else {
$tgt = MakePageName($trailname, preg_replace('/[#?].+/', '', $match[3]));
}
$t[$n]['depth'] = $depth = strlen($match[1]);
$t[$n]['pagename'] = $tgt;
$t[$n]['markup'] = $match[2];
$t[$n]['detail'] = $match[9];
for ($i = $depth; $i < 10; $i++) {
$d[$i] = $n;
}
if ($depth > 1) {
$t[$n]['parent'] = @$d[$depth - 1];
}
$n++;
}
return $t;
}
示例12: VarIndexLoad
function VarIndexLoad($pagename)
{
global $VarPagesFmt, $VarIndex, $WikiWordPattern;
static $loaded;
if ($loaded) {
return;
}
foreach ($VarPagesFmt as $vf) {
$v = FmtPageName($vf, $pagename);
if (@$loaded[$v]) {
continue;
}
$vlist = array($v);
$t = ReadTrail($pagename, $v);
if ($t) {
for ($i = 0; $i < count($t); $i++) {
if (@(!$loaded[$t[$i]['pagename']])) {
$vlist[] = $t[$i]['pagename'];
}
}
}
foreach ($vlist as $vname) {
$vpage = ReadPage($vname);
@$loaded[$vname]++;
if (!$vpage) {
continue;
}
if (!preg_match_all("/\n:\\\$([[:upper:]]\\w+):/", @$vpage['text'], $match)) {
continue;
}
foreach ($match[1] as $n) {
$VarIndex[$n]['pagename'] = $vname;
$VarIndex[$n]['url'] = FmtPageName("\$PageUrl#{$n}", $vname);
}
}
}
}
示例13: EditDraft
function EditDraft(&$pagename, &$page, &$new)
{
global $WikiDir, $DraftSuffix, $DeleteKeyPattern, $DraftRecentChangesFmt, $RecentChangesFmt;
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;
$page = ReadPage($basename);
$WikiDir->delete($draftname);
} else {
if (PageExists($draftname) && $pagename != $draftname) {
Redirect($draftname, '$PageUrl?action=edit');
exit;
}
}
}
if ($pagename == $draftname && isset($DraftRecentChangesFmt)) {
$RecentChangesFmt = $DraftRecentChangesFmt;
}
}
示例14: evaluateTrail
function evaluateTrail () {
$trailpage = ReadPage($this->pagename);
if ($trailpage) {
global $M2MDir, $MarkupTable, $SuffixPattern;
$html = MarkupToHTML($this->pagename, $trailpage['text']);
}
}
示例15: 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);
}