コード例 #1
0
ファイル: draft.php プロジェクト: BogusCurry/pmwiki
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;
    }
}
コード例 #2
0
ファイル: transition.php プロジェクト: BogusCurry/pmwiki
 function FPLByGroup($pagename, &$matches, $opt)
 {
     global $FPLByGroupStartFmt, $FPLByGroupEndFmt, $FPLByGroupGFmt, $FPLByGroupIFmt, $FPLByGroupOpt;
     SDV($FPLByGroupStartFmt, "<dl class='fplbygroup'>");
     SDV($FPLByGroupEndFmt, '</dl>');
     SDV($FPLByGroupGFmt, "<dt><a href='\$ScriptUrl/\$Group'>\$Group</a> /</dt>\n");
     SDV($FPLByGroupIFmt, "<dd><a href='\$PageUrl'>\$Name</a></dd>\n");
     SDVA($FPLByGroupOpt, array('readf' => 0, 'order' => 'name'));
     $matches = MakePageList($pagename, array_merge((array) $FPLByGroupOpt, $opt), 0);
     if (@$opt['count']) {
         array_splice($matches, $opt['count']);
     }
     if (count($matches) < 1) {
         return '';
     }
     $out = '';
     foreach ($matches as $pn) {
         $pgroup = FmtPageName($FPLByGroupGFmt, $pn);
         if ($pgroup != @$lgroup) {
             $out .= $pgroup;
             $lgroup = $pgroup;
         }
         $out .= FmtPageName($FPLByGroupIFmt, $pn);
     }
     return FmtPageName($FPLByGroupStartFmt, $pagename) . $out . FmtPageName($FPLByGroupEndFmt, $pagename);
 }
コード例 #3
0
ファイル: authuser.php プロジェクト: BogusCurry/pmwiki
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']);
}
コード例 #4
0
ファイル: authuser.php プロジェクト: BogusCurry/pmwiki
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));
}
コード例 #5
0
ファイル: pagelist.php プロジェクト: BogusCurry/pmwiki
function FPLGroup($pagename, &$matches, $opt)
{
    global $FPLGroupStartFmt, $FPLGroupIFmt, $FPLGroupEndFmt, $FPLGroupOpt;
    SDV($FPLGroupStartFmt, "<ul class='fplgroup'>");
    SDV($FPLGroupEndFmt, "</ul>");
    SDV($FPLGroupIFmt, "<li><a href='\$ScriptUrl/\$Group'>\$Group</a></li>");
    SDVA($FPLGroupOpt, array('readf' => 0, 'order' => 'name'));
    $matches = MakePageList($pagename, array_merge((array) $FPLGroupOpt, $opt));
    $out = array();
    foreach ($matches as $pc) {
        $group = preg_replace('/\\.[^.]+$/', '', $pc['pagename']);
        if (@(!$seen[$group]++)) {
            $out[] = FmtPageName($FPLGroupIFmt, $pc['pagename']);
            if ($opt['count'] && count($out) >= $opt['count']) {
                break;
            }
        }
    }
    return FmtPageName($FPLGroupStartFmt, $pagename) . implode('', $out) . FmtPageName($FPLGroupEndFmt, $pagename);
}
コード例 #6
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
function IncludeText($pagename, $inclspec) {
  global $MaxIncludes, $IncludeOpt, $InclCount;
  SDV($MaxIncludes,50);
  SDVA($IncludeOpt, array('self'=>1));
  $npat = '[[:alpha:]][-\\w]*';
  if ($InclCount++>=$MaxIncludes) return Keep($inclspec);
  $args = array_merge($IncludeOpt, ParseArgs($inclspec));
  while (count($args['#'])>0) {
    $k = array_shift($args['#']); $v = array_shift($args['#']);
    if ($k=='') {
      preg_match('/^([^#\\s]*)(.*)$/', $v, $match);
      if ($match[1]) {                                 # include a page
        if (isset($itext)) continue;
        $iname = MakePageName($pagename, $match[1]);
        if (!$args['self'] && $iname == $pagename) continue;
        if (!PageExists($iname)) continue;
        $ipage = RetrieveAuthPage($iname, 'read', false, READPAGE_CURRENT);
        $itext = @$ipage['text'];
      }
      if (preg_match("/^#($npat)?(\\.\\.)?(#($npat)?)?$/", $match[2], $m)) {
        @list($x, $aa, $dots, $b, $bb) = $m;
        if (!$dots && !$b) $bb = $npat;
        if ($aa)
          $itext=preg_replace("/^.*?\n([^\n]*\\[\\[#$aa\\]\\])/s",
                              '$1', $itext, 1);
        if ($bb)
          $itext=preg_replace("/(\n)[^\n]*\\[\\[#$bb\\]\\].*$/s",
                              '$1', $itext, 1);
      }
      continue;
    }
    if (in_array($k, array('line', 'lines', 'para', 'paras'))) {
      preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $v, $match);
      @list($x, $a, $dots, $b) = $match;
      $upat = ($k{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*(?:\n|$)";
      if (!$dots) { $b=$a; $a=0; }
      if ($a>0) $a--;
      $itext=preg_replace("/^(($upat){0,$b}).*$/s",'$1',$itext,1);
      $itext=preg_replace("/^($upat){0,$a}/s",'',$itext,1);
      continue;
    }
  }
  $basepage = isset($args['basepage']) 
              ? MakePageName($pagename, $args['basepage'])
              : $iname;
  if ($basepage) $itext = Qualify(@$basepage, @$itext);
  return PVS(htmlspecialchars($itext, ENT_NOQUOTES));
}
コード例 #7
0
ファイル: blocklist.php プロジェクト: BogusCurry/pmwiki
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";
  }
  StopWatch("Blocklist: end $pagename");
}
コード例 #8
0
ファイル: feeds.php プロジェクト: BogusCurry/pmwiki
function HandleFeed($pagename, $auth = 'read')
{
    global $FeedFmt, $action, $PCache, $FmtV, $ISOTimeFmt, $RSSTimeFmt, $FeedOpt, $FeedDescPatterns, $CategoryGroup, $EntitiesTable;
    SDV($ISOTimeFmt, '%Y-%m-%dT%H:%M:%SZ');
    SDV($RSSTimeFmt, 'D, d M Y H:i:s \\G\\M\\T');
    SDV($FeedDescPatterns, array('/<[^>]*$/' => ' ', '/\\w+$/' => '', '/<[^>]+>/' => ''));
    SDVA($FeedCategoryOpt, array('link' => $pagename, 'readf' => 1));
    SDVA($FeedTrailOpt, array('trail' => $pagename, 'count' => 10, 'readf' => 1));
    $f = $FeedFmt[$action];
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?cannot generate feed");
    }
    $feedtime = $page['time'];
    # determine list of pages to display
    if (@($_REQUEST['trail'] || $_REQUEST['group'] || $_REQUEST['link'])) {
        $opt['readf'] = 1;
    } else {
        if ($action == 'dc') {
            $opt = array();
        } else {
            if (preg_match("/^{$CategoryGroup}\\./", $pagename)) {
                $opt = $FeedCategoryOpt;
            } else {
                $opt = $FeedTrailOpt;
            }
        }
    }
    if (!$opt) {
        PCache($pagename, $page);
        $pagelist = array(&$PCache[$pagename]);
    } else {
        $opt = array_merge($opt, @$_REQUEST);
        $pagelist = MakePageList($pagename, $opt);
    }
    # process list of pages in feed
    $rdfseq = '';
    foreach ($pagelist as $page) {
        $pn = $page['name'];
        if (!PageExists($pn)) {
            continue;
        }
        $pl[] = $pn;
        if (@$opt['count'] && count($pl) >= $opt['count']) {
            break;
        }
        $rdfseq .= FmtPageName("<rdf:li resource=\"\$PageUrl\" />\n", $pn);
        if ($page['time'] > $feedtime) {
            $feedtime = $page['time'];
        }
    }
    $pagelist = $pl;
    $FmtV['$FeedRDFSeq'] = $rdfseq;
    $FmtV['$FeedISOTime'] = gmstrftime($ISOTimeFmt, $feedtime);
    $FmtV['$FeedRSSTime'] = gmdate($RSSTimeFmt, $feedtime);
    # format start of feed
    $out = FmtPageName($f['feed']['_start'], $pagename);
    # format feed elements
    foreach ($f['feed'] as $k => $v) {
        if ($k[0] == '_' || !$v) {
            continue;
        }
        $x = FmtPageName($v, $pagename);
        if (!$x) {
            continue;
        }
        $out .= $v[0] == '<' ? $x : "<{$k}>{$x}</{$k}>\n";
    }
    # format items in feed
    if (@$f['feed']['_items']) {
        $out .= FmtPageName($f['feed']['_items'], $pagename);
    }
    foreach ($pagelist as $pn) {
        $page =& $PCache[$pn];
        $FmtV['$ItemDesc'] = @$page['description'] ? $page['description'] : trim(preg_replace(array_keys($FeedDescPatterns), array_values($FeedDescPatterns), @$page['excerpt']));
        $FmtV['$ItemISOTime'] = gmstrftime($ISOTimeFmt, $page['time']);
        $out .= FmtPageName($f['item']['_start'], $pn);
        foreach ((array) @$f['item'] as $k => $v) {
            if ($k[0] == '_' || !$v) {
                continue;
            }
            if (is_callable($v)) {
                $out .= $v($pn, $page, $k);
                continue;
            }
            if (strpos($v, '$LastModifiedBy') !== false && !@$page['author']) {
                continue;
            }
            if (strpos($v, '$Category') !== false) {
                if (preg_match_all("/(?<=^|,){$CategoryGroup}\\.([^,]+)/", @$page['targets'], $match)) {
                    foreach ($match[1] as $c) {
                        $FmtV['$Category'] = $c;
                        $out .= FmtPageName($v, $pn);
                    }
                }
                continue;
            }
            $x = FmtPageName($v, $pn);
            if (!$x) {
                continue;
            }
            $out .= $v[0] == '<' ? $x : "<{$k}>{$x}</{$k}>\n";
        }
        $out .= FmtPageName($f['item']['_end'], $pn);
    }
    $out .= FmtPageName($f['feed']['_end'], $pagename);
    foreach ((array) @$f['feed']['_header'] as $fmt) {
        header(FmtPageName($fmt, $pagename));
    }
    print str_replace(array_keys($EntitiesTable), array_values($EntitiesTable), $out);
}
コード例 #9
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
 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;
 }
コード例 #10
0
ファイル: trails.php プロジェクト: BogusCurry/pmwiki
    the ancestry of the TrailPage to the current one.  The <|TrailPage|> 
    markup is like <<|TrailPage|>> except that "< PrevPage |" and 
    "| NextPage >" are omitted if at the beginning or end of the 
    trail respectively.  Thanks to John Rankin for contributing these
    markups and the original suggestion for WikiTrails.
*/

Markup('<<|','<links','/&lt;&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;&gt;/e',
  "MakeTrailStop(\$pagename,'$1')");
Markup('<|','><<|','/&lt;\\|([^|]+|\\[\\[(.+?)\\]\\])\\|&gt;/e',
  "MakeTrailStopB(\$pagename,'$1')");
Markup('^|','<links','/\\^\\|([^|]+|\\[\\[(.+?)\\]\\])\\|\\^/e',
  "MakeTrailPath(\$pagename,'$1')");

SDVA($SaveAttrPatterns, array(
   '/<<\\|([^|]+|\\[\\[(.+?)\\]\\])\\|>>/' => '$1',
   '/<\\|([^|]+|\\[\\[(.+?)\\]\\])\\|>/' => '$1',
   '/\\^\\|([^|]+|\\[\\[(.+?)\\]\\])\\|\\^/' => '$1'));

$Conditions['ontrail'] = 'CondOnTrail($pagename, $condparm)';

function CondOnTrail($pagename, $condparm) {
  @list($trailname, $pn) = preg_split('/\\s+/', $condparm, 2);
  $trail = ReadTrail($pagename, $trailname);
  if (!$trail) return false;
  $pn = ($pn > '') ? MakePageName($pagename, $pn) : $pagename;
  foreach($trail as $t)
    if ($t['pagename'] == $pn) return true;
  return false;
}

function ReadTrail($pagename, $trailname) {
コード例 #11
0
ファイル: wikistyles.php プロジェクト: BogusCurry/pmwiki
    foreach (array('left', 'right', 'center', 'justify') as $c) {
        SDV($WikiStyle[$c], array('apply' => 'block', 'text-align' => $c));
    }
    ## frames, floating frames, and floats
    SDV($HTMLStylesFmt['wikistyles'], " \n    .frame \n      { border:1px solid #cccccc; padding:4px; background-color:#f9f9f9; }\n    .lfloat { float:left; margin-right:0.5em; }\n    .rfloat { float:right; margin-left:0.5em; }\n");
    SDV($WikiStyle['thumb'], array('width' => '100px'));
    SDV($WikiStyle['frame'], array('class' => 'frame'));
    SDV($WikiStyle['lframe'], array('class' => 'frame lfloat'));
    SDV($WikiStyle['rframe'], array('class' => 'frame rfloat'));
    SDV($WikiStyle['cframe'], array('class' => 'frame', 'margin-left' => 'auto', 'margin-right' => 'auto', 'width' => '200px', 'apply' => 'block', 'text-align' => 'center'));
    ##  preformatted text sections
    SDV($WikiStyle['pre'], array('apply' => 'block', 'white-space' => 'pre'));
    SDV($WikiStyle['sidehead'], array('apply' => 'block', 'class' => 'sidehead'));
}
SDVA($WikiStyleAttr, array('vspace' => 'img', 'hspace' => 'img', 'align' => 'img', 'value' => 'li', 'target' => 'a', 'accesskey' => 'a', 'rel' => 'a'));
SDVA($WikiStyleRepl, array('/^%(.*)%$/' => '$1', '/\\bbgcolor([:=])/' => 'background-color$1', '/\\b(\\d+)pct\\b/' => '$1%'));
$WikiStyleCSS[] = 'color|background-color';
$WikiStyleCSS[] = 'text-align|text-decoration';
$WikiStyleCSS[] = 'font-size|font-family|font-weight|font-style';
SDV($imgTag, '(?:img|object|embed)');
SDV($aTag, 'a');
SDV($spanTag, 'span');
function ApplyStyles($x)
{
    global $UrlExcludeChars, $WikiStylePattern, $WikiStyleRepl, $WikiStyle, $WikiStyleAttr, $WikiStyleCSS, $WikiStyleApply, $BlockPattern, $WikiStyleTag, $imgTag, $aTag, $spanTag, $WikiStyleAttrPrefix;
    $wt = @$WikiStyleTag;
    $ns = $WikiStyleAttrPrefix;
    $ws = '';
    $x = PPRE("/\\b(href|src)=(['\"]?)[^{$UrlExcludeChars}]+\\2/", "Keep(\$m[0])", $x);
    $x = PPRE("/\\bhttps?:[^{$UrlExcludeChars}]+/", "Keep(\$m[0])", $x);
    $parts = preg_split("/({$WikiStylePattern})/", $x, -1, PREG_SPLIT_DELIM_CAPTURE);
コード例 #12
0
ファイル: skin.php プロジェクト: pmskin/pmwiki-bootstrap-skin
                $out .= "</ul></li>";
            }
            $group = $matches[1];
            $out .= "<li class='nav nav-list'>{$group}<b class='caret'></b>";
            $out .= "<ul class='dropdown-menu'>";
        }
        $out .= '<li>';
        $out .= MakeLink($pagename, $page);
        $out .= '</li>';
    }
    $out .= "</ul></li>";
    return $out;
}
include_once "{$SkinDir}/dropdown.php";
global $BootButtons;
SDVA($BootButtons, array('em' => array(100, "''", "''", '$[Emphasized]', 'icon-italic', '$[ak_em]'), 'strong' => array(110, "'''", "'''", '$[Strong]', 'icon-bold', '$[ak_strong]'), 'big' => array(300, "'+", "+'", '$[Big text]', 'icon-fullscreen'), 'sup' => array(320, "'^", "^'", '$[Superscript]', 'icon-arrow-up'), 'sub' => array(330, "'_", "_'", '$[Subscript]', 'icon-arrow-down'), 'center' => array(410, '%center%', '', '', 'icon-align-center')));
/* sms($BootButtons); */
#sms('after the echo');
Markup('e_bootbuttons', 'directives', '/\\(:e_bootbuttons:\\)/', "Keep(FmtPageName(BootButtonCode(\$pagename), \$pagename))");
function BootButtonCode($pagename)
{
    global $BootButtons;
    $cmpfn = create_function('$a,$b', 'return $a[0]-$b[0];');
    /* sms('inside of BootButtonCode'); */
    /* sms('Buttons: '.$BootButtons); */
    usort($BootButtons, $cmpfn);
    $out = "<script type='text/javascript'><!--\n";
    foreach ($BootButtons as $k => $g) {
        if (!$g) {
            continue;
        }
コード例 #13
0
ファイル: upload.php プロジェクト: BogusCurry/pmwiki
    This script adds upload capabilities to PmWiki.  Uploads can be
    enabled by setting
        $EnableUpload = 1;
    in config.php.  In addition, an upload password must be set, as
    the default is to lock uploads.  In some configurations it may also
    be necessary to set values for $UploadDir and $UploadUrlFmt,
    especially if any form of URL rewriting is being performed.
    See the PmWiki.UploadsAdmin page for more information.
*/
## $EnableUploadOverwrite determines if we allow previously uploaded
## files to be overwritten.
SDV($EnableUploadOverwrite, 1);
## $UploadExts contains the list of file extensions we're willing to
## accept, along with the Content-Type: value appropriate for each.
SDVA($UploadExts, array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'bmp' => 'image/bmp', 'ico' => 'image/x-icon', 'wbmp' => 'image/vnd.wap.wbmp', 'mp3' => 'audio/mpeg', 'au' => 'audio/basic', 'wav' => 'audio/x-wav', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'wmf' => 'text/plain', 'avi' => 'video/x-msvideo', 'zip' => 'application/zip', 'gz' => 'application/x-gzip', 'tgz' => 'application/x-gzip', 'rpm' => 'application/x-rpm', 'hqx' => 'application/mac-binhex40', 'sit' => 'application/x-stuffit', 'doc' => 'application/msword', 'ppt' => 'application/vnd.ms-powerpoint', 'xls' => 'application/vnd.ms-excel', 'mdb' => 'text/plain', 'exe' => 'application/octet-stream', 'pdf' => 'application/pdf', 'psd' => 'text/plain', 'ps' => 'application/postscript', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'htm' => 'text/html', 'html' => 'text/html', 'css' => 'text/css', 'fla' => 'application/x-shockwave-flash', 'swf' => 'application/x-shockwave-flash', 'txt' => 'text/plain', 'rtf' => 'application/rtf', 'tex' => 'application/x-tex', 'dvi' => 'application/x-dvi', '' => 'text/plain'));
SDV($UploadMaxSize, 50000);
SDV($UploadPrefixQuota, 0);
SDV($UploadDirQuota, 0);
foreach ($UploadExts as $k => $v) {
    if (!isset($UploadExtSize[$k])) {
        $UploadExtSize[$k] = $UploadMaxSize;
    }
}
SDV($UploadDir, 'uploads');
SDV($UploadPrefixFmt, '/$Group');
SDV($UploadFileFmt, "{$UploadDir}{$UploadPrefixFmt}");
SDV($UploadUrlFmt, preg_replace('#/[^/]*$#', "/{$UploadDir}", $ScriptUrl, 1));
SDV($LinkUploadCreateFmt, "<a class='createlinktext' href='\$LinkUrl'>\$LinkText</a><a class='createlink' href='\$LinkUrl'>&nbsp;&#8657;</a>");
SDV($PageUploadFmt, array("\n  <h2 class='wikiaction'>\$[Attachments for] \$PageName</h2>\n  <h3>\$UploadResult</h3>\n  <form enctype='multipart/form-data' action='\$ScriptUrl' method='post'>\n  <input type='hidden' name='pagename' value='\$PageName' />\n  <input type='hidden' name='action' value='postupload' />\n  <table border='0'>\n    <tr><td align='right'>\$[File to upload:]</td><td><input\n      name='uploadfile' type='file' /></td></tr>\n    <tr><td align='right'>\$[Name attachment as:]</td>\n      <td><input type='text' name='upname' value='\$UploadName' />\n        <input type='submit' value=' \$[Upload] ' /><br />\n        </td></tr></table></form>", 'wiki:$[PmWiki.UploadQuickReference]'));
XLSDV('en', array('ULsuccess' => 'successfully uploaded', 'ULbadname' => 'invalid attachment name', 'ULbadtype' => '\'$upext\' is not an allowed file extension', 'ULtoobig' => 'file is larger than maximum allowed by webserver', 'ULtoobigext' => 'file is larger than allowed maximum of $upmax
コード例 #14
0
<?php

if (!defined('PmWiki')) {
    exit;
}
/*  Copyright 2005-2011 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.
*/
global $HTTPHeaders, $Charset, $DefaultPageCharset;
$HTTPHeaders[] = "Content-type: text/html; charset=iso-8859-13;";
$Charset = "ISO-8859-13";
SDVA($DefaultPageCharset, array('ISO-8859-1' => $Charset));
コード例 #15
0
ファイル: pagelist.php プロジェクト: BogusCurry/pmwiki
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;
                    }
                }
            }
            $page['size'] = strlen(@$page['text']);
        } else {
            $page = array();
        }
        $page['pagename'] = $page['name'] = $pn;
        PCache($pn, $page);
        $matches[] = $pn;
    }
    StopWatch('MakePageList sort');
    if ($order) {
        SortPageList($matches, $order);
    }
    if ($xlist) {
        register_shutdown_function('flush');
        register_shutdown_function('PageIndexUpdate', $xlist, getcwd());
    }
    StopWatch('MakePageList end');
    if ($retpages) {
        for ($i = 0; $i < count($matches); $i++) {
            $matches[$i] =& $PCache[$matches[$i]];
        }
    }
    return $matches;
}
コード例 #16
0
ファイル: wikistyles.php プロジェクト: BogusCurry/pmwiki
    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));
    }
    ## apply ranges
    SDVA($WikiStyleApply, array('item' => 'li|dt', 'list' => 'ul|ol|dl', 'block' => 'p(?!\\sclass=)|div|ul|ol|dl|li|dt|pre', 'p' => 'p(?!\\sclass=)'));
    foreach (array('item', 'list', 'block', 'p') as $c) {
        SDV($WikiStyle[$c], array('apply' => $c));
    }
    ## block justifications
    foreach (array('left', 'right', 'center') as $c) {
        SDV($WikiStyle[$c], array('apply' => 'block', 'text-align' => $c));
    }
}
SDV($WikiStylePattern, '%%|%[A-Za-z][-,=:#\\w\\s\'"]*%');
SDVA($WikiStyleAttr, array('height' => 'img', 'width' => 'img', 'vspace' => 'img', 'hspace' => 'img', 'target' => 'a', 'rel' => 'a'));
SDVA($WikiStyleRepl, array('/\\bbgcolor([:=])/' => 'background-color$1'));
$WikiStyleCSS[] = 'color|background-color';
$WikiStyleCSS[] = 'text-align|text-decoration';
$WikiStyleCSS[] = 'font-size|font-family|font-weight|font-style';
function ApplyStyles($x)
{
    global $WikiStylePattern, $WikiStyleRepl, $WikiStyle, $WikiStyleAttr, $WikiStyleCSS, $WikiStyleApply;
    $parts = preg_split("/({$WikiStylePattern})/", $x, -1, PREG_SPLIT_DELIM_CAPTURE);
    $parts[] = NULL;
    $out = array();
    $style = array();
    $wikicsspat = '/^(' . implode('|', (array) $WikiStyleCSS) . ')$/';
    while ($parts) {
        $p = array_shift($parts);
        if (preg_match("/^{$WikiStylePattern}\$/", $p)) {
            $WikiStyle['curr'] = $style;
コード例 #17
0
ファイル: forms.php プロジェクト: BogusCurry/pmwiki
if ($action != 'edit') {
    return;
}
SDV($PageEditForm, '$SiteGroup.EditForm');
SDV($PageEditFmt, '$EditForm');
if (@$_REQUEST['editform']) {
    $PageEditForm = $_REQUEST['editform'];
    $PageEditFmt = '$EditForm';
}
$Conditions['e_preview'] = '(boolean)$_POST["preview"]';
XLSDV('en', array('ak_save' => 's', 'ak_saveedit' => 'u', 'ak_preview' => 'p', 'ak_textedit' => ',', 'e_rows' => '25', 'e_cols' => '60'));
# (:e_preview:) displays the preview of formatted text.
Markup('e_preview', 'directives', '/^\\(:e_preview:\\)/e', "Keep(\$GLOBALS['FmtV']['\$PreviewText'])");
# If we didn't load guiedit.php, then set (:e_guibuttons:) to
# simply be empty.
Markup('e_guibuttons', 'directives', '/\\(:e_guibuttons:\\)/', '');
SDVA($InputTags['e_form'], array(':html' => "<form action='{\$PageUrl}?action=edit' method='post'><input \n    type='hidden' name='action' value='edit' /><input \n    type='hidden' name='n' value='{\$FullName}' /><input \n    type='hidden' name='basetime' value='\$EditBaseTime' />"));
SDVA($InputTags['e_textarea'], array(':html' => "<textarea \$InputFormArgs \n    onkeydown='if (event.keyCode==27) event.returnValue=false;' \n    >\$EditText</textarea>", 'name' => 'text', 'id' => 'text', 'accesskey' => XL('ak_textedit'), 'rows' => XL('e_rows'), 'cols' => XL('e_cols')));
SDVA($InputTags['e_author'], array(':html' => "<input type='text' \$InputFormArgs />", 'name' => 'author', 'value' => $Author));
SDVA($InputTags['e_changesummary'], array(':html' => "<input type='text' \$InputFormArgs />", 'name' => 'csum', 'size' => '60', 'maxlength' => '100', 'value' => htmlspecialchars(stripmagic(@$_POST['csum']), ENT_QUOTES)));
SDVA($InputTags['e_minorcheckbox'], array(':html' => "<input type='checkbox' \$InputFormArgs />", 'name' => 'diffclass', 'value' => 'minor'));
if (@$_POST['diffclass'] == 'minor') {
    SDV($InputTags['e_minorcheckbox']['checked'], 'checked');
}
SDVA($InputTags['e_savebutton'], array(':html' => "<input type='submit' \$InputFormArgs />", 'name' => 'post', 'value' => ' ' . XL('Save') . ' ', 'accesskey' => XL('ak_save')));
SDVA($InputTags['e_saveeditbutton'], array(':html' => "<input type='submit' \$InputFormArgs />", 'name' => 'postedit', 'value' => ' ' . XL('Save and edit') . ' ', 'accesskey' => XL('ak_saveedit')));
SDVA($InputTags['e_savedraftbutton'], array(':html' => ''));
SDVA($InputTags['e_previewbutton'], array(':html' => "<input type='submit' \$InputFormArgs />", 'name' => 'preview', 'value' => ' ' . XL('Preview') . ' ', 'accesskey' => XL('ak_preview')));
SDVA($InputTags['e_cancelbutton'], array(':html' => "<input type='submit' \$InputFormArgs />", 'name' => 'cancel', 'value' => ' ' . XL('Cancel') . ' '));
SDVA($InputTags['e_resetbutton'], array(':html' => "<input type='reset' \$InputFormArgs />", 'value' => ' ' . XL('Reset') . ' '));
コード例 #18
0
<?php

SDVA($LinkCleanser, array('/`\\..*?$/' => '...', "/\\[\\[([^|\\]]+)\\|\\s*(.*?)\\]\\]({$SuffixPattern})/e" => "MakeLink(\$pagename,PSS('\$1'),PSS('\$2'),'\$3','\$LinkText')", "/\\[\\[([^\\]]+?)\\s*-+&gt;\\s*(.*?)\\]\\]({$SuffixPattern})/e" => "MakeLink(\$pagename,PSS('\$2'),PSS('\$1'),'\$3','\$LinkText')", '/\\[\\[#([A-Za-z][-.:\\w]*)\\]\\]/' => "", "/\\[\\[(.*?)\\]\\]({$SuffixPattern})/e" => "MakeLink(\$pagename,PSS('\$1'),NULL,'\$2','\$LinkText')", '/[\\[\\{](.*?)\\|(.*?)[\\]\\}]/' => '$1', "/`(({$GroupPattern}([\\/.]))?({$WikiWordPattern}))/" => '$1', "/{$GroupPattern}\\/({$WikiWordPattern})/" => '$1'));
function QualifyWLink($pgroup, $group, $esc, $link)
{
    global $WikiWordCount, $WikiWordCountMax;
    if ($esc) {
        return "{$esc}{$link}";
    }
    if ($pgroup == $group) {
        return $link;
    }
    $wwcount = isset($WikiWordCount[$link]) ? $WikiWordCount[$link] : $WikiWordCountMax;
    if ($wwcount == 0) {
        return $link;
    }
    return preg_match("/[.\\/]/", $link) ? $link : QualifiedLink($group, $link);
}
function QualifyFLink($pgroup, $group, $link)
{
    if ($pgroup == $group) {
        return $link;
    }
    $l = FLRef($link);
    return preg_match("/[~!:.\\/]/", $l) ? $link : str_replace("{$l}", QualifiedLink($group, $l), $link);
}
function QualifiedLink($grp, $ref)
{
    return $grp . '1' == FmtPageName('$Group', MakePageName($grp . '1.' . $grp, $ref)) ? "{$grp}/{$ref}" : $ref;
}
function FLRef($linkword)
コード例 #19
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
function IncludeText($pagename, $inclspec) {
  global $MaxIncludes, $IncludeOpt, $InclCount;
  SDV($MaxIncludes,50);
  SDVA($IncludeOpt, array('self'=>1));
  $npat = '[[:alpha:]][-\\w]*';
  if ($InclCount++>=$MaxIncludes) return Keep($inclspec);
  $args = array_merge($IncludeOpt, ParseArgs($inclspec));
  while (count($args['#'])>0) {
    $k = array_shift($args['#']); $v = array_shift($args['#']);
    if ($k=='') {
      if ($v{0} != '#') {
        if (isset($itext)) continue;
        $iname = MakePageName($pagename, $v);
        if (!$args['self'] && $iname == $pagename) continue;
        $ipage = RetrieveAuthPage($iname, 'read', false, READPAGE_CURRENT);
        $itext = @$ipage['text'];
      }
      $itext = TextSection($itext, $v, array('anchors' => 1));
      continue;
    }
    if (preg_match('/^(?:line|para)s?$/', $k)) {
      preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $v, $match);
      @list($x, $a, $dots, $b) = $match;
      $upat = ($k{0} == 'p') ? ".*?(\n\\s*\n|$)" : "[^\n]*(?:\n|$)";
      if (!$dots) { $b=$a; $a=0; }
      if ($a>0) $a--;
      $itext=preg_replace("/^(($upat){0,$b}).*$/s",'$1',$itext,1);
      $itext=preg_replace("/^($upat){0,$a}/s",'',$itext,1);
      continue;
    }
  }
  $basepage = isset($args['basepage']) 
              ? MakePageName($pagename, $args['basepage'])
              : $iname;
  if ($basepage) $itext = Qualify(@$basepage, @$itext);
  return FmtTemplateVars(PVSE($itext), $args);
}
コード例 #20
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
 function recode($pagename, $a) {
   if(!$a) return false;
   global $Charset, $PageRecodeFunction, $DefaultPageCharset;
   if (function_exists($PageRecodeFunction)) return $PageRecodeFunction($a);
   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;
   if ($Charset=='ISO-8859-1' && $a['charset']=='UTF-8') $F = 'utf8_decode'; # 2.2.31+ documentation
   elseif ($Charset=='UTF-8' && $a['charset']=='ISO-8859-1') $F = 'utf8_encode'; # utf8 wiki & pre-2.2.30 doc
   elseif (function_exists('iconv'))
     $F = create_function('$s', "return iconv('{$a['charset']}', '$Charset//IGNORE', \$s);");
   elseif (function_exists('mb_convert_encoding'))
     $F = create_function('$s', "return mb_convert_encoding(\$s, '$Charset', '{$a['charset']}');");
   else return $a;
   foreach($a as $k=>$v) $a[$k] = $F($v);
   $a['charset'] = $Charset;
   return $a;
 }
コード例 #21
0
ファイル: authuser.php プロジェクト: BogusCurry/pmwiki
function AuthUserId($pagename, $id, $pw = NULL)
{
    global $AuthUser, $AuthUserPageFmt, $AuthUserFunctions, $AuthId, $MessagesFmt;
    foreach ((array) $AuthUser as $k => $v) {
        $auth[$k] = (array) $v;
    }
    $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("/^\\s*([@\\w][^\\s:]*):(.*)/m", $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 (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;
    }
    $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) {
        if (in_array($authid, $auth[$g])) {
            $authlist[$g] = 1;
        }
    }
    if ($auth['htgroup']) {
        foreach (AuthUserHtGroup($pagename, $id, $pw, $auth['htgroup']) as $g) {
            $authlist["@{$g}"] = 1;
        }
    }
    SessionAuth($pagename, array('authid' => $authid, 'authlist' => $authlist));
}
コード例 #22
0
ファイル: pagelist.php プロジェクト: BogusCurry/pmwiki
function FPLTemplate($pagename, &$matches, $opt)
{
    global $Cursor, $FPLTemplatePageFmt, $RASPageName, $PageListArgPattern;
    SDV($FPLTemplatePageFmt, array('{$FullName}', '{$SiteGroup}.LocalTemplates', '{$SiteGroup}.PageListTemplates'));
    StopWatch("FPLTemplate begin");
    $template = @$opt['template'];
    if (!$template) {
        $template = @$opt['fmt'];
    }
    $ttext = RetrieveAuthSection($pagename, $template, $FPLTemplatePageFmt);
    $ttext = PVSE(Qualify($RASPageName, $ttext));
    ##  save any escapes
    $ttext = MarkupEscape($ttext);
    ##  remove any anchor markups to avoid duplications
    $ttext = preg_replace('/\\[\\[#[A-Za-z][-.:\\w]*\\]\\]/', '', $ttext);
    ##  extract portions of template
    $tparts = preg_split('/\\(:(template)\\s+(\\w+)\\s*(.*?):\\)/i', $ttext, -1, PREG_SPLIT_DELIM_CAPTURE);
    ##  handle (:template defaults:)
    $i = 0;
    while ($i < count($tparts)) {
        if ($tparts[$i] != 'template') {
            $i++;
            continue;
        }
        if ($tparts[$i + 1] != 'defaults' && $tparts[$i + 1] != 'default') {
            $i += 4;
            continue;
        }
        $opt = array_merge(ParseArgs($tparts[$i + 2], $PageListArgPattern), $opt);
        array_splice($tparts, $i, 3);
    }
    SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
    ##  get the list of pages
    $matches = array_values(MakePageList($pagename, $opt, 0));
    ##  extract page subset according to 'count=' parameter
    if (@$opt['count']) {
        list($r0, $r1) = CalcRange($opt['count'], count($matches));
        if ($r1 < $r0) {
            $matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
        } else {
            $matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
        }
    }
    $savecursor = $Cursor;
    $pagecount = 0;
    $groupcount = 0;
    $grouppagecount = 0;
    $pseudovars = array('{$$PageCount}' => &$pagecount, '{$$GroupCount}' => &$groupcount, '{$$GroupPageCount}' => &$grouppagecount);
    foreach (preg_grep('/^[\\w$]/', array_keys($opt)) as $k) {
        if (!is_array($opt[$k])) {
            $pseudovars["{\$\${$k}}"] = htmlspecialchars($opt[$k], ENT_NOQUOTES);
        }
    }
    $vk = array_keys($pseudovars);
    $vv = array_values($pseudovars);
    $lgroup = '';
    $out = '';
    foreach ($matches as $i => $pn) {
        $group = PageVar($pn, '$Group');
        if ($group != $lgroup) {
            $groupcount++;
            $grouppagecount = 0;
            $lgroup = $group;
        }
        $grouppagecount++;
        $pagecount++;
        $t = 0;
        while ($t < count($tparts)) {
            if ($tparts[$t] != 'template') {
                $item = $tparts[$t];
                $t++;
            } else {
                list($when, $control, $item) = array_slice($tparts, $t + 1, 3);
                $t += 4;
                if (!$control) {
                    if ($when == 'first' && $i != 0) {
                        continue;
                    }
                    if ($when == 'last' && $i != count($matches) - 1) {
                        continue;
                    }
                } else {
                    if ($when == 'first' || !isset($last[$t])) {
                        $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
                        $Cursor['='] = $pn;
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
                        $curr = str_replace($vk, $vv, $control);
                        $curr = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $curr);
                        if ($when == 'first' && $i > 0 && $last[$t] == $curr) {
                            continue;
                        }
                        $last[$t] = $curr;
                    }
                    if ($when == 'last') {
                        $Cursor['<'] = $Cursor['&lt;'] = $pn;
                        $Cursor['='] = (string) @$matches[$i + 1];
                        $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 2];
                        $next = str_replace($vk, $vv, $control);
                        $next = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $next);
                        if ($next == $last[$t] && $i != count($matches) - 1) {
                            continue;
                        }
                        $last[$t] = $next;
                    }
                }
            }
            $Cursor['<'] = $Cursor['&lt;'] = (string) @$matches[$i - 1];
            $Cursor['='] = $pn;
            $Cursor['>'] = $Cursor['&gt;'] = (string) @$matches[$i + 1];
            $item = str_replace($vk, $vv, $item);
            $item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PVSE(PageVar(\$pn, '\$2', '\$1'))", $item);
            $out .= MarkupRestore($item);
        }
    }
    $class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
    if ($class) {
        $class = " class='{$class}'";
    }
    $wrap = @$opt['wrap'];
    if ($wrap != 'inline') {
        $out = MarkupToHTML($pagename, $out, array('escape' => 0, 'redirect' => 1));
        if ($wrap != 'none') {
            $out = "<div{$class}>{$out}</div>";
        }
    }
    $Cursor = $savecursor;
    StopWatch("FPLTemplate end");
    return $out;
}
コード例 #23
0
ファイル: creole.php プロジェクト: BogusCurry/pmwiki
/*  Copyright 2007 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.

    This script adds Creole v0.4 markup (http://www.wikicreole.org/)
    to PmWiki.  To activate this script, simply add the following into
    a local customization file:

        include_once('scripts/creole.php');

*/
## **strong**
Markup('**', 'inline', '/^\\*\\*(?>(.+?)\\*\\*)(?!\\S)|(?<!^)\\*\\*(.+?)\\*\\*/', '<strong>$1$2</strong>');
## //emphasized//
Markup('//', 'inline', '/(?<!http:|ftp:)\\/\\/(.*?)\\/\\//', '<em>$1</em>');
## == Headings ==
Markup('^=', 'block', '/^(={1,6})\\s?(.*?)(\\s*=*\\s*)$/e', "'<:block,1><h'.strlen('\$1').PSS('>\$2</h').strlen('\$1').'>'");
## Line breaks
Markup('\\\\', 'inline', '/\\\\\\\\/', '<br />');
## Preformatted
Markup('^{{{', '[=', "/^\\{\\{\\{\n(.*?\n)\\}\\}\\}[^\\S\n]*\n/sme", "Keep(PSS('<pre class=\"escaped\">\$1</pre>'))");
Markup('{{{', '>{{{', '/\\{\\{\\{(.*?)\\}\\}\\}/se', "Keep(PSS('<code class=\"escaped\">\$1</code>'))");
## Tables
Markup('|-table', '>^||', '/^\\|(.*)$/e', "FormatTableRow(PSS('\$0'), '\\|')");
## Images
Markup('{{', 'inline', '/\\{\\{(?>(\\L))([^|\\]]*)(?:\\|\\s*(.*?)\\s*)?\\}\\}/e', "Keep(\$GLOBALS['LinkFunctions']['\$1'](\$pagename, '\$1', '\$2', '\$3',\n     '\$1\$2', \$GLOBALS['ImgTagFmt']),'L')");
## GUIButtons
SDVA($GUIButtons, array('em' => array(100, "//", "//", '$[Emphasized]', '$GUIButtonDirUrlFmt/em.gif"$[Emphasized (italic)]"', '$[ak_em]'), 'strong' => array(110, "**", "**", '$[Strong]', '$GUIButtonDirUrlFmt/strong.gif"$[Strong (bold)]"', '$[ak_strong]'), 'h2' => array(400, '\\n== ', ' ==\\n', '$[Heading]', '$GUIButtonDirUrlFmt/h.gif"$[Heading]"')));
コード例 #24
0
ファイル: markupexpr.php プロジェクト: BogusCurry/pmwiki
    The expression arguments are parsed using ParseArgs(), and the
    result of this parsing is available through the $argp array:

        ##  expressions like {(myfunc fmt=foo output=bar)}
        $MarkupExpr['myfunc'] = 'myfunc($argp["fmt"], $argp["output"])';
   
    Finally, if the code in $MarkupExpr contains '$params', then
    it is executed directly without any preprocessing into arguments,
    and $params contains the entire argument string.  Note that $params
    may contain escaped values representing quoted arguments and
    results of other expressions; these values may be un-escaped
    by using "preg_replace($rpat, $rrep, $params)".
*/
$RecipeInfo['MarkupExpressions']['Version'] = '2007-04-11';
Markup('{(', '>{$var}', '/\\{(\\(\\w+\\b.*?\\))\\}/e', "MarkupExpression(\$pagename, PSS('\$1'))");
SDVA($MarkupExpr, array('substr' => 'call_user_func_array("substr", $args)', 'strlen' => 'strlen($args[0])', 'ftime' => 'ME_ftime($args[0], $args[1], $argp)', 'rand' => '($args) ? rand($args[0], $args[1]) : rand()', 'ucfirst' => 'ucfirst($args[0])', 'ucwords' => 'ucwords($args[0])', 'tolower' => 'strtolower($args[0])', 'toupper' => 'strtoupper($args[0])', 'asspaced' => '$GLOBALS["AsSpacedFunction"]($args[0])', 'pagename' => 'MakePageName($pagename, preg_replace($rpat, $rrep, $params))'));
function MarkupExpression($pagename, $expr)
{
    global $KeepToken, $KPV, $MarkupExpr;
    $rpat = "/{$KeepToken}(\\d+P){$KeepToken}/e";
    $rrep = '$KPV[\'$1\']';
    $expr = preg_replace('/([\'"])(.*?)\\1/e', "Keep(PSS('\$2'),'P')", $expr);
    $expr = preg_replace('/\\(\\W/e', "Keep(PSS('\$2'),'P')", $expr);
    while (preg_match('/\\((\\w+)(\\s[^()]*)?\\)/', $expr, $match)) {
        list($repl, $func, $params) = $match;
        $code = @$MarkupExpr[$func];
        ##  if not a valid function, save this string as-is and exit
        if (!$code) {
            break;
        }
        ##  if the code uses '$params', we just evaluate directly
コード例 #25
0
ファイル: rss.php プロジェクト: BogusCurry/pmwiki
        $text = entityencode(preg_replace("/<.*?>/s", "", $text));
        preg_match("/^(.{0,{$RssDescSize}}\\s)/s", $text, $match);
        $r[] = array('name' => $t[$i]['pagename'], 'time' => $page['time'], 'desc' => $match[1] . " ...", 'author' => $page['author']);
        if ($page['time'] > $cbgmt) {
            $cbgmt = $page['time'];
        }
    }
    SDV($RssChannelBuildDate, entityencode(gmdate('D, d M Y H:i:s \\G\\M\\T', $cbgmt)));
    SDV($RssChannelDesc, entityencode(FmtPageName('$Group.$Title', $pagename)));
    foreach ($r as $page) {
        $FmtV['$RssItemPubDate'] = gmstrftime($RssTimeFmt, $page['time']);
        $FmtV['$RssItemDesc'] = $page['desc'];
        $FmtV['$RssItemAuthor'] = $page['author'];
        $RssItemsRDFList[] = entityencode(FmtPageName($RssItemsRDFListFmt, $page['name']));
        $RssItems[] = entityencode(FmtPageName($RssItemFmt, $page['name']));
    }
    header("Content-type: text/xml");
    PrintFmt($pagename, $HandleRssFmt);
    exit;
}
# entityencode() and $EntitiesTable are used to convert non-ASCII characters
# and named entities into numeric entities, since the RSS and RDF
# specifications don't have a good way of incorporating them by default.
function entityencode($s)
{
    global $EntitiesTable;
    $s = str_replace(array_keys($EntitiesTable), array_values($EntitiesTable), $s);
    return preg_replace('/([\\x80-\\xff])/e', "'&#'.ord('\$1').';'", $s);
}
SDVA($EntitiesTable, array('&nbsp;' => '&#160;', '&iexcl;' => '&#161;', '&cent;' => '&#162;', '&pound;' => '&#163;', '&curren;' => '&#164;', '&yen;' => '&#165;', '&brvbar;' => '&#166;', '&sect;' => '&#167;', '&uml;' => '&#168;', '&copy;' => '&#169;', '&ordf;' => '&#170;', '&laquo;' => '&#171;', '&not;' => '&#172;', '&shy;' => '&#173;', '&reg;' => '&#174;', '&macr;' => '&#175;', '&deg;' => '&#176;', '&plusmn;' => '&#177;', '&sup2;' => '&#178;', '&sup3;' => '&#179;', '&acute;' => '&#180;', '&micro;' => '&#181;', '&para;' => '&#182;', '&middot;' => '&#183;', '&cedil;' => '&#184;', '&sup1;' => '&#185;', '&ordm;' => '&#186;', '&raquo;' => '&#187;', '&frac14;' => '&#188;', '&frac12;' => '&#189;', '&frac34;' => '&#190;', '&iquest;' => '&#191;', '&Agrave;' => '&#192;', '&Aacute;' => '&#193;', '&Acirc;' => '&#194;', '&Atilde;' => '&#195;', '&Auml;' => '&#196;', '&Aring;' => '&#197;', '&AElig;' => '&#198;', '&Ccedil;' => '&#199;', '&Egrave;' => '&#200;', '&Eacute;' => '&#201;', '&Ecirc;' => '&#202;', '&Euml;' => '&#203;', '&Igrave;' => '&#204;', '&Iacute;' => '&#205;', '&Icirc;' => '&#206;', '&Iuml;' => '&#207;', '&ETH;' => '&#208;', '&Ntilde;' => '&#209;', '&Ograve;' => '&#210;', '&Oacute;' => '&#211;', '&Ocirc;' => '&#212;', '&Otilde;' => '&#213;', '&Ouml;' => '&#214;', '&times;' => '&#215;', '&Oslash;' => '&#216;', '&Ugrave;' => '&#217;', '&Uacute;' => '&#218;', '&Ucirc;' => '&#219;', '&Uuml;' => '&#220;', '&Yacute;' => '&#221;', '&THORN;' => '&#222;', '&szlig;' => '&#223;', '&agrave;' => '&#224;', '&aacute;' => '&#225;', '&acirc;' => '&#226;', '&atilde;' => '&#227;', '&auml;' => '&#228;', '&aring;' => '&#229;', '&aelig;' => '&#230;', '&ccedil;' => '&#231;', '&egrave;' => '&#232;', '&eacute;' => '&#233;', '&ecirc;' => '&#234;', '&euml;' => '&#235;', '&igrave;' => '&#236;', '&iacute;' => '&#237;', '&icirc;' => '&#238;', '&iuml;' => '&#239;', '&eth;' => '&#240;', '&ntilde;' => '&#241;', '&ograve;' => '&#242;', '&oacute;' => '&#243;', '&ocirc;' => '&#244;', '&otilde;' => '&#245;', '&ouml;' => '&#246;', '&divide;' => '&#247;', '&oslash;' => '&#248;', '&ugrave;' => '&#249;', '&uacute;' => '&#250;', '&ucirc;' => '&#251;', '&uuml;' => '&#252;', '&yacute;' => '&#253;', '&thorn;' => '&#254;', '&yuml;' => '&#255;', '&quot;' => '&#34;', '&apos;' => '&#39;', '&OElig;' => '&#338;', '&oelig;' => '&#339;', '&Scaron;' => '&#352;', '&scaron;' => '&#353;', '&Yuml;' => '&#376;', '&circ;' => '&#710;', '&tilde;' => '&#732;', '&ensp;' => '&#8194;', '&emsp;' => '&#8195;', '&thinsp;' => '&#8201;', '&zwnj;' => '&#8204;', '&zwj;' => '&#8205;', '&lrm;' => '&#8206;', '&rlm;' => '&#8207;', '&ndash;' => '&#8211;', '&mdash;' => '&#8212;', '&lsquo;' => '&#8216;', '&rsquo;' => '&#8217;', '&sbquo;' => '&#8218;', '&ldquo;' => '&#8220;', '&rdquo;' => '&#8221;', '&bdquo;' => '&#8222;', '&dagger;' => '&#8224;', '&Dagger;' => '&#8225;', '&permil;' => '&#8240;', '&lsaquo;' => '&#8249;', '&rsaquo;' => '&#8250;', '&euro;' => '&#8364;', '&fnof;' => '&#402;', '&Alpha;' => '&#913;', '&Beta;' => '&#914;', '&Gamma;' => '&#915;', '&Delta;' => '&#916;', '&Epsilon;' => '&#917;', '&Zeta;' => '&#918;', '&Eta;' => '&#919;', '&Theta;' => '&#920;', '&Iota;' => '&#921;', '&Kappa;' => '&#922;', '&Lambda;' => '&#923;', '&Mu;' => '&#924;', '&Nu;' => '&#925;', '&Xi;' => '&#926;', '&Omicron;' => '&#927;', '&Pi;' => '&#928;', '&Rho;' => '&#929;', '&Sigma;' => '&#931;', '&Tau;' => '&#932;', '&Upsilon;' => '&#933;', '&Phi;' => '&#934;', '&Chi;' => '&#935;', '&Psi;' => '&#936;', '&Omega;' => '&#937;', '&alpha;' => '&#945;', '&beta;' => '&#946;', '&gamma;' => '&#947;', '&delta;' => '&#948;', '&epsilon;' => '&#949;', '&zeta;' => '&#950;', '&eta;' => '&#951;', '&theta;' => '&#952;', '&iota;' => '&#953;', '&kappa;' => '&#954;', '&lambda;' => '&#955;', '&mu;' => '&#956;', '&nu;' => '&#957;', '&xi;' => '&#958;', '&omicron;' => '&#959;', '&pi;' => '&#960;', '&rho;' => '&#961;', '&sigmaf;' => '&#962;', '&sigma;' => '&#963;', '&tau;' => '&#964;', '&upsilon;' => '&#965;', '&phi;' => '&#966;', '&chi;' => '&#967;', '&psi;' => '&#968;', '&omega;' => '&#969;', '&thetasym;' => '&#977;', '&upsih;' => '&#978;', '&piv;' => '&#982;', '&bull;' => '&#8226;', '&hellip;' => '&#8230;', '&prime;' => '&#8242;', '&Prime;' => '&#8243;', '&oline;' => '&#8254;', '&frasl;' => '&#8260;', '&weierp;' => '&#8472;', '&image;' => '&#8465;', '&real;' => '&#8476;', '&trade;' => '&#8482;', '&alefsym;' => '&#8501;', '&larr;' => '&#8592;', '&uarr;' => '&#8593;', '&rarr;' => '&#8594;', '&darr;' => '&#8595;', '&harr;' => '&#8596;', '&crarr;' => '&#8629;', '&lArr;' => '&#8656;', '&uArr;' => '&#8657;', '&rArr;' => '&#8658;', '&dArr;' => '&#8659;', '&hArr;' => '&#8660;', '&forall;' => '&#8704;', '&part;' => '&#8706;', '&exist;' => '&#8707;', '&empty;' => '&#8709;', '&nabla;' => '&#8711;', '&isin;' => '&#8712;', '&notin;' => '&#8713;', '&ni;' => '&#8715;', '&prod;' => '&#8719;', '&sum;' => '&#8721;', '&minus;' => '&#8722;', '&lowast;' => '&#8727;', '&radic;' => '&#8730;', '&prop;' => '&#8733;', '&infin;' => '&#8734;', '&ang;' => '&#8736;', '&and;' => '&#8743;', '&or;' => '&#8744;', '&cap;' => '&#8745;', '&cup;' => '&#8746;', '&int;' => '&#8747;', '&there4;' => '&#8756;', '&sim;' => '&#8764;', '&cong;' => '&#8773;', '&asymp;' => '&#8776;', '&ne;' => '&#8800;', '&equiv;' => '&#8801;', '&le;' => '&#8804;', '&ge;' => '&#8805;', '&sub;' => '&#8834;', '&sup;' => '&#8835;', '&nsub;' => '&#8836;', '&sube;' => '&#8838;', '&supe;' => '&#8839;', '&oplus;' => '&#8853;', '&otimes;' => '&#8855;', '&perp;' => '&#8869;', '&sdot;' => '&#8901;', '&lceil;' => '&#8968;', '&rceil;' => '&#8969;', '&lfloor;' => '&#8970;', '&rfloor;' => '&#8971;', '&lang;' => '&#9001;', '&rang;' => '&#9002;', '&loz;' => '&#9674;', '&spades;' => '&#9824;', '&clubs;' => '&#9827;', '&hearts;' => '&#9829;', '&diams;' => '&#9830;'));
コード例 #26
0
ファイル: stdmarkup.php プロジェクト: BogusCurry/pmwiki
}
Markup('[=', '_begin', "/(\n[^\\S\n]*)?\\[([=@])(.*?)\\2\\]/se", "PreserveText('\$2', PSS('\$3'), '\$1')");
Markup('restore', '<_end', "/{$KeepToken}(\\d.*?){$KeepToken}/e", '$GLOBALS[\'KPV\'][\'$1\']');
Markup('<:', '>restore', '/<:[^>]*>/', '');
Markup('<vspace>', '<restore', '/<vspace>/', "<div class='vspace'></div>");
Markup('<vspace><p>', '<<vspace>', "/<vspace><p\\b(([^>]*)(\\s)class=(['\"])([^>]*?)\\4)?/", "<p\$2 class='vspace\$3\$5'");
## remove carriage returns before preserving text
Markup('\\r', '<[=', '/\\r/', '');
# $[phrase] substitutions
Markup('$[phrase]', '>[=', '/\\$\\[(?>([^\\]]+))\\]/e', "NoCache(XL(PSS('\$1')))");
# {$var} substitutions
Markup('{$var}', '>$[phrase]', '/\\{(\\*|!?[-\\w.\\/\\x80-\\xff]*)(\\$:?\\w+)\\}/e', "PVSE(PageVar(\$pagename, '\$2', '\$1'), ENT_NOQUOTES)");
# invisible (:textvar:...:) definition
Markup('textvar:', '<split', '/\\(:\\w[-\\w]*:(?!\\)).*?:\\)/s', '');
## patterns recognized as text vars
SDVA($PageTextVarPatterns, array('var:' => '/^:*(\\w[-\\w]*):[ \\t]?(.*)$/m', '(:var:...:)' => '/\\(:(\\w[-\\w]*):(?!\\))\\s?(.*?):\\)/s'));
## handle relative text vars in includes
if (IsEnabled($EnableRelativePageVars, 0)) {
    SDV($QualifyPatterns["/\\{([-\\w\\x80-\\xfe]*)(\\\$:?\\w+\\})/e"], "'{' . ('\$1' ? MakePageName(\$pagename, '\$1') : \$pagename) . '\$2'");
}
## (:if:)/(:elseif:)/(:else:)
Markup('if', 'fulltext', "/ \\(:if (?:end)? \\b[^\n]*?:\\)\n     .*?\n     (?: \\(: (?:if|ifend) \\s* :\\)\n     |   (?=\\(:(?:if|ifend)\\b[^\n]*?:\\) | \$)\n     )\n   /seix", "CondText2(\$pagename, PSS('\$0'))");
function CondText2($pagename, $text)
{
    global $Conditions;
    $parts = preg_split('/\\(:(ifend|if|else *if|else)\\b\\s*(!?)\\s*(\\S+)?\\s*(.*?)\\s*:\\)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    $x = array_shift($parts);
    while ($parts) {
        list($condstr, $not, $condname, $condparm, $condtext) = array_splice($parts, 0, 5);
        if (!isset($Conditions[$condname])) {
            return $condtext;
コード例 #27
0
ファイル: compat1x.php プロジェクト: BogusCurry/pmwiki
    to PmWiki 2.  This is definitely a preliminary implementation and
    still probably needs some work.

    The major component is the PageStore1x, which allows pages
    to be read from an existing PmWiki 1.x wiki.d/ directory, 
    converting PmWiki 1 markup into PmWiki 2 markup as the page is read.  
    Pages are then saved in the PmWiki 2 installation's wiki.d/
    directory, which should be separate from the original wiki.d/.

    The intent is that a wiki administrator can install, configure, and
    test a PmWiki 2 installation on an existing set of PmWiki 1.x pages 
    without losing or modifying the 1.x page files.

    Details on this are being maintained at the UpgradingFromPmWiki1 page 
    http://www.pmwiki.org/pmwiki2/pmwiki.php/PmWiki/UpgradingFromPmWiki1 .
*/
SDVA($Compat1x, array("/\\[\\[(noheader|nofooter|nogroupheader|nogroupfooter|notitle|spacewikiwords)\\]\\]/" => '(:$1:)', "/\\[\\[(include|redirect):(.*?)\\]\\]/" => '(:$1 $2:)', "/\\[\\[(table|cell|cellnr|tableend)(\\s.*?)?\\]\\]\n?/" => "(:\$1\$2:)\n", "/\\[\\[\\\$Title\\]\\]/" => '{$Name}', "/\\[\\[\\\$pagecount\\]\\]/" => '{$PageCount}', "/\\[\\[\\\$(Group|Version|Author|LastModified|LastModifiedBy|LastModifiedHost)\\]\\]/" => '{$$1}', "/\\[\\[\\\$Edit\\s(.*?)\\]\\]/" => '[[{$Name}?action=edit |$1]]', "/\\[\\[\\\$Diff\\s(.*?)\\]\\]/" => '[[{$Name}?action=diff |$1]]', "/\\[\\[\\\$Search\\]\\]/" => '(:searchbox:)', "/\\[\\[\\\$Searchresults\\]\\]/" => '(:searchresults:)', "/\\[\\[\\\$Attachlist(\\s.*?)?\\]\\]/" => '(:attachlist$1:)', "/\\[\\[((\\w|\\#)[^{$UrlExcludeChars}\\s]*)\\s(.*?)\\]\\]/" => '[[$1 |$3]]', "/\\[\\[(\\w[^{$UrlExcludeChars}\\s]*)\\]\\]/" => '[[$1 |<#>]]', "/\\[\\[({$GroupPattern}([\\/.]))?\\{\\{(~?\\w[-\\w\\s.\\/]*)\\}\\}([-#\\w]*)\\s(.*?)\\]\\]/" => '[[$1$3$4 |$5]]', "/\\[\\[({$GroupPattern}([\\/.]))?\\{\\{(~?\\w[-\\w\\s.\\/]*)\\|([-\\w\\s]*)\\}\\}([-#\\w]*)\\s(.*?)\\]\\]/" => '[[$1$3$4$5 |$6]]', "/({$GroupPattern}([\\/.]))?\\{\\{(~?\\w[-\\w\\s.\\/]*)\\}\\}([-\\w]*)/" => '[[$1$3]]$4', "/({$GroupPattern}([\\/.]))?\\{\\{(~?\\w[-\\w\\s.\\/]*)\\|([-\\w\\s]*)\\}\\}([-\\w]*)/" => '[[$1$3($4)]]$5', "/^(:+)(:[^:\n]*)\$/m" => '$1 $2'));
class PageStore1x extends PageStore
{
    function read($pagename)
    {
        global $Compat1x, $KeepToken;
        $page = parent::read($pagename);
        if ($page) {
            $page['text'] = preg_replace('/(\\[([=@]).*?\\2\\])/se', "Keep(PSS('\$1'))", @$page['text']);
            $page['text'] = preg_replace(array_keys($Compat1x), array_values($Compat1x), $page['text']);
            $page['text'] = preg_replace("/{$KeepToken}(\\d.*?){$KeepToken}/e", '$GLOBALS[\'KPV\'][\'$1\']', $page['text']);
        }
        return $page;
    }
}
コード例 #28
0
ファイル: pagelist.php プロジェクト: BogusCurry/pmwiki
/*  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.

*/
SDV($SearchResultsFmt, "\$[SearchFor]\n  {$HTMLVSpace}\$MatchList\n  {$HTMLVSpace}\$[SearchFound]{$HTMLVSpace}");
SDVA($SearchPatterns['all'], array());
$SearchPatterns['normal'][] = '!\\.(All)?Recent(Changes|Uploads)$!';
$SearchPatterns['normal'][] = '!\\.Group(Print)?(Header|Footer)$!';
XLSDV('en', array('SearchFor' => 'Results of search for <em>$Needle</em>:', 'SearchFound' => '$MatchCount pages found out of $MatchSearched pages searched.'));
Markup('searchbox', '>links', '/\\(:searchbox:\\)/', FmtPageName("<form class='wikisearch' action='\$ScriptUrl' \n    method='get'><input type='hidden' name='pagename' \n    value='\$[Main/SearchWiki]' /><input class='wikisearchbox' \n    type='text' name='q' value='' size='40' /><input \n    class='wikisearchbutton' type='submit' value='\$[Search]' /></form>", $pagename));
Markup('searchresults', 'directives', '/\\(:searchresults\\s*(.*?):\\)/e', "Keep(FmtPageList(\$GLOBALS['SearchResultsFmt'],\$pagename,\n    array('q'=>PSS('\$1'))))");
Markup('pagelist', 'directives', '/\\(:pagelist\\s*(.*):\\)/e', "Keep(FmtPageList('\$MatchList',\$pagename,array('q'=>PSS('\$1 '))))");
SDVA($FPLFunctions, array('bygroup' => 'FPLByGroup', 'simple' => 'FPLSimple'));
function FmtPageList($fmt, $pagename, $opt)
{
    global $GroupPattern, $SearchPatterns, $FmtV, $FPLFunctions;
    $opt = array_merge(@$_REQUEST, $opt);
    if (!$opt['q']) {
        $opt['q'] = stripmagic(@$_REQUEST['q']);
    }
    if (!$opt['q']) {
        return;
    }
    $terms = preg_split('/((?<!\\S)[-+]?[\'"].*?[\'"](?!\\S)|\\S+)/', $opt['q'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
    if (preg_match("!^({$GroupPattern}(\\|{$GroupPattern})*)?/!i", @$terms[0], $match)) {
        $opt['group'] = @$match[1];
        $terms[0] = str_replace(@$match[1] . '/', '', $terms[0]);
    }
コード例 #29
0
ファイル: upload.php プロジェクト: BogusCurry/pmwiki
SDV($PageAttributes['passwdupload'],'$[Set new upload password:]');
SDV($DefaultPasswords['upload'],'*');
SDV($AuthCascade['upload'], 'read');
SDV($FmtPV['$PasswdUpload'], 'PasswdVar($pn, "upload")');

Markup('attachlist', 'directives', 
  '/\\(:attachlist\\s*(.*?):\\)/ei',
  "Keep('<ul>'.FmtUploadList('$pagename',PSS('$1')).'</ul>')");
SDV($GUIButtons['attach'], array(220, 'Attach:', '', '$[file.ext]',
  '$GUIButtonDirUrlFmt/attach.gif"$[Attach file]"'));
SDV($LinkFunctions['Attach:'], 'LinkUpload');
SDV($IMap['Attach:'], '$1');
SDVA($HandleActions, array('upload' => 'HandleUpload',
  'postupload' => 'HandlePostUpload',
  'download' => 'HandleDownload'));
SDVA($HandleAuth, array('upload' => 'upload',
  'download' => 'read'));
SDV($HandleAuth['postupload'], $HandleAuth['upload']);
SDV($UploadVerifyFunction, 'UploadVerifyBasic');

function MakeUploadName($pagename,$x) {
  global $UploadNameChars;
  SDV($UploadNameChars, "-\\w. ");
  $x = preg_replace("/[^$UploadNameChars]/", '', $x);
  $x = preg_replace('/\\.[^.]*$/e', "strtolower('$0')", $x);
  $x = preg_replace('/^[^[:alnum:]_]+/', '', $x);
  return preg_replace('/[^[:alnum:]_]+$/', '', $x);
}

function LinkUpload($pagename, $imap, $path, $alt, $txt, $fmt=NULL) {
  global $FmtV, $UploadFileFmt, $LinkUploadCreateFmt, $UploadUrlFmt,
    $UploadPrefixFmt, $EnableDirectDownload;
コード例 #30
0
ファイル: pagelist.php プロジェクト: BogusCurry/pmwiki
function FPLTemplateDefaults($pagename, $matches, &$opt, &$tparts){
  global $PageListArgPattern;
  $i = 0;
  while ($i < count($tparts)) {
    if ($tparts[$i] != 'template') { $i++; continue; }
    if ($tparts[$i+2] != 'defaults' && $tparts[$i+2] != 'default') { $i+=5; continue; }
    $opt = array_merge(ParseArgs($tparts[$i+3], $PageListArgPattern), $opt);
    array_splice($tparts, $i, 4);
  }
  SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
}