コード例 #1
0
function HandlePostRename($pagename)
{
    global $RedirectToRenameFmt, $GroupPattern, $WikiWordPattern;
    $newpagename = MakePageName($pagename, stripmagic($_POST['group'] . '.' . $_POST['renametext']));
    if (PageExists($newpagename)) {
        Abort("'{$newpagename}' already exists");
    } else {
        Lock(2);
        $page = RetrieveAuthPage($pagename, "edit");
        if ($page) {
            $ntext = $page['text'];
        } else {
            Abort("cannot get '{$pagename}'");
        }
        $ogroup = FmtPageName('$Group', $pagename);
        $ngroup = FmtPageName('$Group', $newpagename);
        #    Abort('stop for testing');
        if ($_POST['addgroup']) {
            if ($_POST['addgroup'] == 'new') {
                $h = $ogroup;
                $ogroup = $ngroup;
                $ngroup = $h;
            }
            if ($ogroup == $ngroup) {
                $ngroup = $ngroup . '1';
            }
            $ntext = preg_replace("/(\\[[=@].*?[=@]\\])|(\\[\\[[^#].*?\\]\\])|([`:\\/])?\\b(({$GroupPattern}([\\/.]))?{$WikiWordPattern})/e", 'QualifyUnqualifiedLinks($ngroup,$ogroup,"$0")', $ntext);
            #        Abort(str_replace("\n",'<br/>',str_replace("\n\n",'</p><p>',$ntext)));
            #        $page = RetrieveAuthPage($newpagename,"edit");
        }
        $page['text'] = $ntext;
        WritePage($newpagename, $page);
        $page['text'] = str_replace('$RenameText', $newpagename, $RedirectToRenameFmt);
        WritePage($pagename, $page);
    }
    Redirect($pagename);
}
コード例 #2
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
function HandlePostAttr($pagename, $auth = 'attr') {
  global $PageAttributes, $EnablePostAttrClearSession;
  Lock(2);
  $page = RetrieveAuthPage($pagename, $auth, true);
  if (!$page) { Abort("?unable to read $pagename"); }
  foreach($PageAttributes as $attr=>$p) {
    $v = stripmagic(@$_POST[$attr]);
    if ($v == '') continue;
    if ($v=='clear') unset($page[$attr]);
    else if (strncmp($attr, 'passwd', 6) != 0) $page[$attr] = $v;
    else {
      $a = array();
      preg_match_all('/"[^"]*"|\'[^\']*\'|\\S+/', $v, $match);
      foreach($match[0] as $pw) 
        $a[] = preg_match('/^(@|\\w+:)/', $pw) ? $pw 
                   : crypt(preg_replace('/^([\'"])(.*)\\1$/', '$2', $pw));
      if ($a) $page[$attr] = implode(' ',$a);
    }
  }
  WritePage($pagename,$page);
  Lock(0);
  if (IsEnabled($EnablePostAttrClearSession, 1)) {
    @session_start();
    unset($_SESSION['authid']);
    unset($_SESSION['authlist']);
    $_SESSION['authpw'] = array();
  }
  Redirect($pagename);
  exit;
} 
コード例 #3
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
function HandlePostAttr($pagename)
{
    global $PageAttributes;
    $page = RetrieveAuthPage($pagename, 'attr');
    if (!$page) {
        Abort("?unable to read {$pagename}");
    }
    foreach ($PageAttributes as $attr => $p) {
        $newpw = @$_POST[$attr];
        if ($newpw == 'clear') {
            unset($page[$attr]);
        } else {
            if ($newpw > '') {
                $page[$attr] = crypt($newpw);
            }
        }
    }
    WritePage($pagename, $page);
    Redirect($pagename);
    exit;
}
コード例 #4
0
ファイル: blocklist.php プロジェクト: BogusCurry/pmwiki
function BlocklistDownload($pagename, $dir = '') {
  global $BlocklistDownloadFmt, $BlocklistDownload, $FmtV;

  if ($dir) { flush(); chdir($dir); }
  SDV($BlocklistDownloadFmt, "
  [@
## blocklist-note:   NOTE: This page is automatically generated by blocklist.php
## blocklist-note:   NOTE: Any edits to this page may be lost!
## blocklist-url:    \$BlocklistDownloadUrl
## blocklist-when:   \$CurrentTimeISO
#  blocklist-format: \$BlocklistFormat
\$BlocklistData
  @]
");

  ##  get the existing blocklist page
  $bd = &$BlocklistDownload[$pagename];
  $page = ReadPage($pagename, READPAGE_CURRENT);

  ##  try to retrieve the remote data
  $blocklistdata = @file($bd['url']);

  ##  if we didn't get it, and we don't already have text, save a
  ##  note in the page so we know what happened
  if (!$blocklistdata && !@$page['text']) {
    $auf = ini_get('allow_url_fopen');
    $blocklistdata = "#### Unable to download blocklist (allow_url_fopen=$auf)";
  }

  ##  if we have some new text to save, let's format it and save it
  if ($blocklistdata) {
    $blocklistdata = implode('', (array)$blocklistdata);
    $blocklistdata = preg_replace('/^##blocklist.*/m', '', $blocklistdata);
    $FmtV['$BlocklistData'] = $blocklistdata;
    $FmtV['$BlocklistDownloadUrl'] = $bd['url'];
    $FmtV['$BlocklistFormat'] = $bd['format'];
    $page['text'] = FmtPageName($BlocklistDownloadFmt, $pagename);
    SDV($page['passwdread'], '@lock');
  }

  ##  save our updated(?) blocklist page
  WritePage($pagename, $page);
}
コード例 #5
0
ファイル: upgrades.php プロジェクト: BogusCurry/pmwiki
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 -&gt; $n1</li>";
  }

  if ($message) {
    $migrateurl = "$ScriptUrl?action=upgrade&amp;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);
}
コード例 #6
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
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;
}
コード例 #7
0
ファイル: pmwiki.php プロジェクト: BogusCurry/pmwiki
function HandlePostAttr($pagename)
{
    global $PageAttributes, $EnablePostAttrClearSession;
    $page = RetrieveAuthPage($pagename, 'attr');
    if (!$page) {
        Abort("?unable to read {$pagename}");
    }
    foreach ($PageAttributes as $attr => $p) {
        $newpw = @$_POST[$attr];
        if ($newpw == 'clear') {
            unset($page[$attr]);
        } else {
            if ($newpw > '') {
                $page[$attr] = crypt($newpw);
            }
        }
    }
    WritePage($pagename, $page);
    if (IsEnabled($EnablePostAttrClearSession, 1)) {
        $_SESSION['authpw'] = array();
    }
    Redirect($pagename);
    exit;
}
コード例 #8
0
ファイル: pmgallery.php プロジェクト: Nepherim/PmGallery
    if ($autogroup || in_array($pmGroup, $pmGallery['virtualgroups'])) {
        // prevent "Page not found..." error message showing up in pmGallery groups
        //PageNotFound file doesn't need to exist!
        SDV($GLOBALS['DefaultPageTextFmt'], '(:include {$Group}.pmPageNotFound:)');
        if ($autogroup) {
            $n = $pmGroup . '.GroupFooter';
            if (!PageExists($n) && $n != $GLOBALS['pagename']) {
                ## Add a custom page storage location
                $GLOBALS['PageStorePath'] = dirname(__FILE__) . "/wikilib.d/{\$FullName}";
                $where = count($GLOBALS['WikiLibDirs']);
                if ($where > 1) {
                    $where--;
                }
                array_splice($GLOBALS['WikiLibDirs'], $where, 0, array(new PageStore($GLOBALS['PageStorePath'])));
                // if there is no footer for this group then copy the default over.
                WritePage($n, ReadPage('PmGallery.GroupFooter'));
            }
        }
    }
    $pmGallery['virtualgroups'][0] = trim($pmGallery['virtualgroups'][0], '+');
}
/**
* Main routine called from markup within wiki pages
*/
function pmGallery($args)
{
    $o = array('album' => '', 'wikitarget' => '', 'startimg' => '', 'tag' => '', 'random' => '', 'width' => '', 'height' => '', 'imageurl' => '', 'query' => '', 'user' => '', 'thumbsize' => '', 'imagesize' => '', 'maxresults' => '', 'wrapper' => 'ul &gt; li', 'mode' => '', 'provider' => 'picasa', 'exif' => false, 'urlbase' => 'com', 'proxy' => '', 'authkey' => '', 'debug' => false, 'cachedir' => '', 'cachelife' => '7200');
    $o = array_merge($o, $GLOBALS['pmGallery']);
    // Allows the markup to be used in an (:include user="******":) where {$$user} might be blank, and thus passed to this routine as {$$user}.
    $o = array_merge($o, preg_grep('/(\\{\\$\\$.*\\}|^$)/', ParseArgs($args), PREG_GREP_INVERT));
    #find all elements NOT like {$$user} or empty
コード例 #9
0
ファイル: compat1x.php プロジェクト: BogusCurry/pmwiki
function ConvertV1WikiD($path) {
  global $WikiDir;
  Lock(2);
  if (!is_dir($path)) {
    Abort("?$path is not an accessible directory");
    exit();
  }
  $WikiV1Dir = new PageStore1x("$path/\$FullName");
  $oldlist = $WikiV1Dir->ls();
  $newlist = ListPages();
  $bothlist = array_intersect($oldlist,$newlist); sort($bothlist);
  $difflist = array_diff($oldlist,$newlist); sort($difflist);
  $bcount = count($bothlist);
  $dcount = count($difflist); 

  echo "
    <html>
    <head>
    <title>Convert v1 pages to v2</title>
    </head>
    <body>
    <h2>Convert and Copy PmWiki v1.x pages into v2.x</h2>
  ";

  $copy = array();
  if (@$_POST['copydiff']) $copy = $difflist;
  if (@$_POST['copyboth']) $copy = array_merge($copy,$bothlist);
  if (@$_POST['copy']) $copy = array_merge($copy,$_POST['copy']);

  if (@$copy) { 
    echo "<p>Okay, I'm now converting the pages you've requested.
       When this is finished, you can see if anything else needs to
       be converted, otherwise you can get rid of the 
       <tt>include_once('scripts/compat1x.php');</tt> and
       <tt>ConvertV1WikiD()</tt> lines that are in your 
       local/config.php file.</p>";
    $copy = array_unique($copy);
    foreach($copy as $p) { 
      echo "<li>Converting $p</li>\n"; 
      $page = $WikiV1Dir->read($p);
      WritePage($p,$page);
    }
    echo "<p>Converted ", count($copy), " pages.</p>\n";
  } else {
    echo "
      <p>This function will migrate pages from a 1.x wiki.d/ directory ($path)
      into your 2.x wiki.d/ directory, converting markups as it proceeds. 
      Note that the files in your 1.x wiki.d/ directory are not affected
      by this script, so if the conversion doesn't work out for any reason
      you still have your original pages lying around.</p>
    ";
  }

  /* now rebuild the lists */
  $oldlist = $WikiV1Dir->ls();
  $newlist = ListPages();
  $bothlist = array_intersect($oldlist,$newlist); sort($bothlist);
  $difflist = array_diff($oldlist,$newlist); sort($difflist);
  $bcount = count($bothlist);
  $dcount = count($difflist); 

 
  echo " <form method='post'> ";

  echo "<h3>Migrate pages from v1 to v2 (don't overwrite existing 
    v2 pages)</h3>";

  if ($difflist) {
    echo "
      <p>The following $dcount pages exist only in the version 1
      wiki.d/ directory.  </p>
      <dd><input type='submit' name='copydiff' value='Copy and convert all
        pages that do not already exist' /></dd>
      <p>or</p><dd><input type='submit' name='copyindv' value='Copy and convert
        pages checked in the list below' /><p></p></dd>
    ";
    foreach($difflist as $p) 
      echo "<dd><input type='checkbox' name='copy[]' value='$p' /> $p</dd>\n";
  } else {
    echo "<p>There aren't any pages in your version 1 wiki.d/ directory that 
      are not already in your version 2 directory.</p>";
  }
  
  echo "<h3>Migrate pages from v1 to v2 (overwrite existing v2 pages)</h3>
    <p>The following $bcount pages exist in <em>both</em> the version 1 and
    version 2 wiki.d/ directories.  If you use one of the buttons below,
    then your converted version 1 pages will <em>overwrite</em> the existing 
    version 2 pages, and you will lose any edits that you might have made
    in the version 2 installation (it's possible that
    this is what you want).</p>
    <dd><input type='submit' name='copyboth' value='Convert and overwrite
      pages that do already exist' /></dd>
    <p>or</p><dd><input type='submit' name='copyindv' value='Convert and
      overwrite pages checked in the list below' /><p></p></dd>
  ";
  foreach($bothlist as $p) 
    echo "<dd><input type='checkbox' name='copy[]' value='$p' /> $p</dd>\n";

  echo "</form></body></html>\n";
  exit();
}
コード例 #10
0
function ConvertXML()
{
    global $WikiDir;
    global $EnablePageStoreXML;
    $pagelist = $WikiDir->ls();
    $pagelist = array_unique($pagelist);
    sort($pagelist);
    $pagecount = count($pagelist);
    echo "\n    <html>\n    <head>\n    <title>Convert pages from/to XML</title>\n    </head>\n    <body>\n    <h2>Convert existing pages</h2>\n    <p>I'm now converting ";
    echo $EnablePageStoreXML ? "<b>to</b> " : "<b>from</b> ";
    echo "XML the files (pages) you have stored in your wiki. When this is finished\n    you can get rid of the <tt>ConvertXML();</tt> line in your\n    local/config.php</p>";
    if ($pagelist) {
        foreach ($pagelist as $p) {
            echo $EnablePageStoreXML ? "<li>Converting to XML: {$p}</li>\n" : "<li>Converting from XML: {$p}</li>\n";
            $page = ReadPage($p);
            WritePage($p, $page);
        }
    }
    echo "<p>Converted {$pagecount} pages.</p>\n";
    echo "<p>Now you can get rid of the <tt>ConvertXML();</tt> line in your local/config.php</p>\n                 </body></html>\n";
    exit(0);
}
コード例 #11
0
ファイル: globals.php プロジェクト: saracarlile/PHP
<?php

/* $GLOBALS in php is an associative array that contains references to all variables which are currently defined in the global
scope of the script */
function WritePage($pagetitle, $description, $pageheading, $forwardlink = "", $backlink = "")
{
    /*not all pages need forward and back links, therefore a default value of blank is assigned so the function can be called without these two arguements */
    $GLOBALS["forwardlink"] = "{$forwardlink}";
    /* assigns the global variable forwardlink to the arguement passed into $forwardlink in the function WritePage */
    $GLOBALS["backlink"] = "{$backlink}";
    echo "<br>" . "<br>" . $pagetitle . "<br>" . $description . "<br>" . $pageheading . "<br>" . $GLOBALS["forwardlink"] . "<br>" . $GLOBALS["backlink"];
}
WritePage("Page Title - PHP Globals", "A page description for PHP Globals goes here.", "PHP Globals - Example", "/link/somplace/forward/", "/link/someplace/back/");
function PrevNext($back, $forward)
{
    echo "<a href=" . $back . ">Back</a>";
    echo "<a href=" . $forward . ">Forward</a>";
}
?>




<div id="center">
	<?php 
PrevNext($GLOBALS["backlink"], $GLOBALS["forwardlink"]);
?>
</div>
コード例 #12
0
ファイル: analyze.php プロジェクト: prometheus-ev/promwiki
function HandleAnalyze($pagename, $auth = 'read')
{
    global $AnalyzeKey, $AnalyzeSkip, $EnableAnalyzeSave, $RecipeInfo;
    header('Content-type: text/plain');
    if (!$AnalyzeKey) {
        print "NoKey=1\n";
        exit(0);
    }
    if ($_REQUEST['key'] != $AnalyzeKey) {
        print "InvalidKey=1\n";
        exit(0);
    }
    WritePage('Site.Analyze', array('text' => 'Test Analysis page', 'passwdread' => '@lock'));
    echo 'AnalyzeVersion=', $RecipeInfo['PmWiki:SiteAnalyzer']['Version'], "\n";
    SDV($EnableAnalyzeSave, 0);
    $vars = array('EnableAnalyzeSave', 'VersionNum', 'Version', 'ScriptUrl', 'PubDirUrl', 'FarmD', 'WorkDir', 'EnableDiag');
    foreach ($vars as $k) {
        $v = @$GLOBALS[$k];
        echo "{$k}={$v}\n";
    }
    echo 'AnalyzeSkip=', join(',', (array) $AnalyzeSkip), "\n";
    $conf = array('register_globals', 'post_max_size', 'safe_mode', 'safe_mode_gid', 'upload_max_filesize');
    foreach ($conf as $v) {
        echo "{$v}=", ini_get($v), "\n";
    }
    $fn = array('phpversion', 'session_save_path', 'get_magic_quotes_gpc', 'get_magic_quotes_runtime');
    foreach ($fn as $f) {
        echo "{$f}=" . $f() . "\n";
    }
    $session = array('SERVER_SOFTWARE', 'PHP_SELF', 'REQUEST_URI', 'SCRIPT_NAME');
    foreach ($session as $s) {
        echo "{$s}={$_SERVER[$s]}\n";
    }
    global $FarmD, $LocalDir, $WorkDir, $UploadDir;
    $files = array('farmd' => $FarmD, 'cwd' => getcwd(), 'local' => $LocalDir, 'workdir' => $WorkDir, 'uploads' => $UploadDir, 'cookbook' => 'cookbook', 'scripts' => "{$FarmD}/scripts", 'cookbook_farm' => "{$FarmD}/cookbook");
    foreach ($files as $f => $v) {
        if (!file_exists($v)) {
            continue;
        }
        $owner = @fileowner($v);
        $group = @filegroup($v);
        $perms = sprintf("%o", @fileperms($v));
        echo "{$f}={$owner}:{$group}:{$perms}:{$v}\n";
    }
    $dir = 'cookbook';
    $dfp = @opendir($dir);
    if ($dfp) {
        $cookbookfiles = array();
        while (($name = readdir($dfp)) !== false) {
            if ($name[0] == '.') {
                continue;
            }
            $cookbookfiles[] = $name;
            $text = implode('', @file("{$dir}/{$name}"));
            if (preg_match("/^\\s*\\\$RecipeInfo\\['(.*?)'\\]\\['Version'\\]\\s*=\\s*'(.*?)'\\s*;/m", $text, $match)) {
                SDV($RecipeInfo[$match[1]]['Version'], $match[2]);
            }
            if (preg_match("/^\\s*SDV\\(\\s*\\\$RecipeInfo\\['(.*?)'\\]\\['Version'\\]\\s*,\\s*'(.*?)'\\s*\\)\\s*\\;/m", $text, $match)) {
                SDV($RecipeInfo[$match[1]]['Version'], $match[2]);
            }
        }
        closedir($dfp);
        echo "CookbookFiles=", implode(' ', $cookbookfiles), "\n";
    }
    if (@$RecipeInfo) {
        echo "RecipeInfo=" . count($RecipeInfo) . "\n";
    }
    foreach ((array) $RecipeInfo as $r => $v) {
        if ($v['Version']) {
            echo "RecipeInfo[{$r}]={$v['Version']}\n";
        }
    }
    exit(0);
}