示例#1
0
function PurgePage(&$request)
{
    global $WikiTheme;
    $page = $request->getPage();
    $pagelink = WikiLink($page);
    if ($request->getArg('cancel')) {
        $request->redirect(WikiURL($page));
        // noreturn
    }
    $current = $page->getCurrentRevision();
    if (!$current or !($version = $current->getVersion())) {
        $html = HTML::p(array('class' => 'error'), _("Sorry, this page does not exist."));
    } elseif (!$request->isPost() || !$request->getArg('verify')) {
        $purgeB = Button('submit:verify', _("Purge Page"), 'wikiadmin');
        $cancelB = Button('submit:cancel', _("Cancel"), 'button');
        // use generic wiki button look
        $fieldset = HTML::fieldset(HTML::p(fmt("You are about to purge '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'purge')), HTML::div(array('class' => 'toolbar'), $purgeB, $WikiTheme->getButtonSeparator(), $cancelB)));
        $sample = HTML::div(array('class' => 'transclusion'));
        // simple and fast preview expanding only newlines
        foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
            $sample->pushContent($s, HTML::br());
        }
        $html = HTML($fieldset, HTML::div(array('class' => 'wikitext'), $sample));
    } elseif ($request->getArg('currentversion') != $version) {
        $html = HTML(HTML::p(array('class' => 'error'), _("Someone has edited the page!")), HTML::p(fmt("Since you started the purge process, someone has saved a new version of %s.  Please check to make sure you still want to permanently purge the page from the database.", $pagelink)));
    } else {
        // Real purge.
        $pagename = $page->getName();
        $dbi = $request->getDbh();
        $dbi->purgePage($pagename);
        $dbi->touch();
        $html = HTML::div(array('class' => 'feedback'), fmt("Purged page '%s' successfully.", $pagename));
    }
    GeneratePage($html, _("Purge Page"));
}
示例#2
0
function actionPage(&$request, $action)
{
    global $WikiTheme;
    $pagename = $request->getArg('pagename');
    $version = $request->getArg('version');
    $page = $request->getPage();
    $revision = $page->getCurrentRevision();
    $dbi = $request->getDbh();
    $actionpage = $dbi->getPage($action);
    $actionrev = $actionpage->getCurrentRevision();
    $pagetitle = HTML(fmt("%s: %s", $actionpage->getName(), $WikiTheme->linkExistingWikiWord($pagename, false, $version)));
    $validators = new HTTP_ValidatorSet(array('pageversion' => $revision->getVersion(), '%mtime' => $revision->get('mtime')));
    $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime')));
    $request->appendValidators(array('actionpagerev' => $actionrev->getVersion(), '%mtime' => $actionrev->get('mtime')));
    $transformedContent = $actionrev->getTransformedContent();
    $template = Template('browse', array('CONTENT' => $transformedContent));
    /*
        if (!headers_sent()) {
            //FIXME: does not work yet. document.write not supported (signout button)
            // http://www.w3.org/People/mimasa/test/xhtml/media-types/results
            if (ENABLE_XHTML_XML 
                and (!isBrowserIE() and
                     strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml')))
                header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']);
            else
                header("Content-Type: text/html; charset=" . $GLOBALS['charset']);
        }
    */
    GeneratePage($template, $pagetitle, $revision);
    $request->checkValidators();
    flush();
}
示例#3
0
function RemovePage(&$request)
{
    global $WikiTheme;
    $page = $request->getPage();
    $pagelink = WikiLink($page);
    if ($request->getArg('cancel')) {
        $request->redirect(WikiURL($page));
        // noreturn
    }
    $current = $page->getCurrentRevision();
    if (!$current or !($version = $current->getVersion())) {
        $html = HTML(HTML::h2(_("Already deleted")), HTML::p(_("Sorry, this page is not in the database.")));
    } elseif (!$request->isPost() || !$request->getArg('verify')) {
        $removeB = Button('submit:verify', _("Remove Page"), 'wikiadmin');
        $cancelB = Button('submit:cancel', _("Cancel"), 'button');
        // use generic wiki button look
        $html = HTML(HTML::h2(fmt("You are about to remove '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'remove')), HTML::div(array('class' => 'toolbar'), $removeB, $WikiTheme->getButtonSeparator(), $cancelB)), HTML::hr());
        $sample = HTML::div(array('class' => 'transclusion'));
        // simple and fast preview expanding only newlines
        foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
            $sample->pushContent($s, HTML::br());
        }
        $html->pushContent(HTML::div(array('class' => 'wikitext'), $sample));
    } elseif ($request->getArg('currentversion') != $version) {
        $html = HTML(HTML::h2(_("Someone has edited the page!")), HTML::p(fmt("Since you started the deletion process, someone has saved a new version of %s.  Please check to make sure you still want to permanently remove the page from the database.", $pagelink)));
    } else {
        // Codendi specific: remove the deleted wiki page from ProjectWantedPages
        $projectPageName = 'ProjectWantedPages';
        $pagename = $page->getName();
        $dbi = $request->getDbh();
        require_once PHPWIKI_DIR . "/lib/loadsave.php";
        $pagehandle = $dbi->getPage($projectPageName);
        if ($pagehandle->exists()) {
            // don't replace default contents
            $current = $pagehandle->getCurrentRevision();
            $version = $current->getVersion();
            $text = $current->getPackedContent();
            $meta = $current->_data;
        }
        $text = str_replace("* [{$pagename}]", "", $text);
        $meta['summary'] = $GLOBALS['Language']->getText('wiki_lib_wikipagewrap', 'page_added', array($pagename));
        $meta['author'] = user_getname();
        $pagehandle->save($text, $version + 1, $meta);
        //Codendi specific: remove permissions for this page @codenditodo: may be transferable otherwhere.
        require_once 'common/wiki/lib/WikiPage.class.php';
        $wiki_page = new WikiPage(GROUP_ID, $_REQUEST['pagename']);
        $wiki_page->resetPermissions();
        // Real delete.
        //$pagename = $page->getName();
        $dbi = $request->getDbh();
        $dbi->deletePage($pagename);
        $dbi->touch();
        $link = HTML::a(array('href' => 'javascript:history.go(-2)'), _("Back to the previous page."));
        $html = HTML(HTML::h2(fmt("Removed page '%s' successfully.", $pagename)), HTML::div($link), HTML::hr());
    }
    GeneratePage($html, _("Remove Page"));
}
示例#4
0
 function savePage()
 {
     $request =& $this->request;
     if ($this->isUnchanged()) {
         // Allow admin lock/unlock even if
         // no text changes were made.
         if ($this->updateLock()) {
             $dbi = $request->getDbh();
             $dbi->touch();
         }
         // Save failed. No changes made.
         $this->_redirectToBrowsePage();
         // user will probably not see the rest of this...
         include_once 'lib/display.php';
         // force browse of current version:
         $request->setArg('version', false);
         displayPage($request, 'nochanges');
         return true;
     }
     if (!$this->user->isAdmin() and $this->isSpam()) {
         $this->_isSpam = true;
         return false;
         /*
         // Save failed. No changes made.
         $this->_redirectToBrowsePage();
         // user will probably not see the rest of this...
         include_once('lib/display.php');
         // force browse of current version:
         $request->setArg('version', false);
         displayPage($request, 'nochanges');
         return true;
         */
     }
     $page =& $this->page;
     // Include any meta-data from original page version which
     // has not been explicitly updated.
     // (Except don't propagate pgsrc_version --- moot for now,
     //  because at present it never gets into the db...)
     $meta = $this->selected->getMetaData();
     unset($meta['pgsrc_version']);
     $meta = array_merge($meta, $this->meta);
     // Save new revision
     $this->_content = $this->getContent();
     $newrevision = $page->save($this->_content, $this->version == -1 ? -1 : $this->_currentVersion + 1, $meta);
     if (!isa($newrevision, 'WikiDB_PageRevision')) {
         // Save failed.  (Concurrent updates).
         return false;
     } else {
         // Save succeded. We store cross references (if there are).
         $reference_manager =& ReferenceManager::instance();
         $reference_manager->extractCrossRef($this->_content, $page->getName(), ReferenceManager::REFERENCE_NATURE_WIKIPAGE, GROUP_ID);
         // Save succeded. We raise an event.
         $new = $this->version + 1;
         $difflink = WikiURL($page->getName(), array('action' => 'diff'), true);
         $difflink .= "&versions%5b%5d=" . $this->version . "&versions%5b%5d=" . $new;
         $eM =& EventManager::instance();
         $uM =& UserManager::instance();
         $user =& $uM->getCurrentUser();
         $eM->processEvent("wiki_page_updated", array('group_id' => GROUP_ID, 'wiki_page' => $page->getName(), 'diff_link' => $difflink, 'user' => $user, 'version' => $this->version));
     }
     // New contents successfully saved...
     $this->updateLock();
     // Clean out archived versions of this page.
     include_once 'lib/ArchiveCleaner.php';
     $cleaner = new ArchiveCleaner($GLOBALS['ExpireParams']);
     $cleaner->cleanPageRevisions($page);
     /* generate notification emails done in WikiDB::save to catch 
        all direct calls (admin plugins) */
     // look at the errorstack
     $errors = $GLOBALS['ErrorManager']->_postponed_errors;
     $warnings = $GLOBALS['ErrorManager']->getPostponedErrorsAsHTML();
     $GLOBALS['ErrorManager']->_postponed_errors = $errors;
     $dbi = $request->getDbh();
     $dbi->touch();
     global $WikiTheme;
     if (empty($warnings->_content) && !$WikiTheme->getImageURL('signature')) {
         // Do redirect to browse page if no signature has
         // been defined.  In this case, the user will most
         // likely not see the rest of the HTML we generate
         // (below).
         $this->_redirectToBrowsePage();
     }
     // Force browse of current page version.
     $request->setArg('version', false);
     //$request->setArg('action', false);
     $template = Template('savepage', $this->tokens);
     $template->replace('CONTENT', $newrevision->getTransformedContent());
     if (!empty($warnings->_content)) {
         $template->replace('WARNINGS', $warnings);
     }
     $pagelink = WikiLink($page);
     GeneratePage($template, fmt("Saved: %s", $pagelink), $newrevision);
     return true;
 }
示例#5
0
}
$full = trim($full);
$html = "<P><B>" . sprintf(gettext("Searching for \"%s\" ....."), htmlspecialchars($full)) . "</B></P>\n<DL>\n";
$found = 0;
$count = 0;
if (strlen($full)) {
    // search matching pages
    $query = InitFullSearch($dbi, $full);
    // quote regexp chars (space are treated as "or" operator)
    $full = preg_replace("/\\s+/", "|", preg_quote($full));
    while ($pagehash = FullSearchNextMatch($dbi, $query)) {
        $html .= "<DT><B>" . LinkExistingWikiWord($pagehash["pagename"]) . "</B>\n";
        $count++;
        // print out all matching lines, highlighting the match
        for ($j = 0; $j < count($pagehash["content"]); $j++) {
            if ($hits = preg_match_all(":{$full}:i", $pagehash["content"][$j], $dummy)) {
                $matched = preg_replace(":{$full}:i", "{$FieldSeparator}OT\\0{$FieldSeparator}CT", $pagehash["content"][$j]);
                $matched = htmlspecialchars($matched);
                $matched = str_replace("{$FieldSeparator}OT", '<b>', $matched);
                $matched = str_replace("{$FieldSeparator}CT", '</b>', $matched);
                $html .= "<dd><small>{$matched}</small></dd>\n";
                $found += $hits;
            }
        }
    }
} else {
    $html .= "<dd>" . gettext("(You entered an empty search string)") . "</dd>\n";
}
$html .= "</dl>\n<hr noshade>" . sprintf(gettext("%d matches found in %d pages."), $found, $count) . "\n";
GeneratePage('MESSAGE', $html, gettext("Full Text Search Results"), 0);
示例#6
0
function showDiff(&$request)
{
    $pagename = $request->getArg('pagename');
    if (is_array($versions = $request->getArg('versions'))) {
        // Version selection from pageinfo.php display:
        rsort($versions);
        list($version, $previous) = $versions;
    } else {
        $version = $request->getArg('version');
        $previous = $request->getArg('previous');
    }
    // abort if page doesn't exist
    $dbi = $request->getDbh();
    $page = $request->getPage();
    $current = $page->getCurrentRevision();
    if ($current->getVersion() < 1) {
        $html = HTML::div(array('id' => 'content'), HTML::p(fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown'))));
        include_once 'lib/Template.php';
        GeneratePage($html, sprintf(_("Diff: %s"), $pagename), false);
        return;
        //early return
    }
    if ($version) {
        if (!($new = $page->getRevision($version))) {
            NoSuchRevision($request, $page, $version);
        }
        $new_version = fmt("version %d", $version);
    } else {
        $new = $current;
        $new_version = _("current version");
    }
    if (preg_match('/^\\d+$/', $previous)) {
        if (!($old = $page->getRevision($previous))) {
            NoSuchRevision($request, $page, $previous);
        }
        $old_version = fmt("version %d", $previous);
        $others = array('major', 'minor', 'author');
    } else {
        switch ($previous) {
            case 'author':
                $old = $new;
                while ($old = $page->getRevisionBefore($old)) {
                    if ($old->get('author') != $new->get('author')) {
                        break;
                    }
                }
                $old_version = _("revision by previous author");
                $others = array('major', 'minor');
                break;
            case 'minor':
                $previous = 'minor';
                $old = $page->getRevisionBefore($new);
                $old_version = _("previous revision");
                $others = array('major', 'author');
                break;
            case 'major':
            default:
                $old = $new;
                while ($old && $old->get('is_minor_edit')) {
                    $old = $page->getRevisionBefore($old);
                }
                if ($old) {
                    $old = $page->getRevisionBefore($old);
                }
                $old_version = _("predecessor to the previous major change");
                $others = array('minor', 'author');
                break;
        }
    }
    $new_link = WikiLink($new, '', $new_version);
    $old_link = $old ? WikiLink($old, '', $old_version) : $old_version;
    $page_link = WikiLink($page);
    $html = HTML::div(array('id' => 'content'), HTML::p(fmt("Differences between %s and %s of %s.", $new_link, $old_link, $page_link)));
    $otherdiffs = HTML::p(_("Other diffs:"));
    $label = array('major' => _("Previous Major Revision"), 'minor' => _("Previous Revision"), 'author' => _("Previous Author"));
    foreach ($others as $other) {
        $args = array('action' => 'diff', 'previous' => $other);
        if ($version) {
            $args['version'] = $version;
        }
        if (count($otherdiffs->getContent()) > 1) {
            $otherdiffs->pushContent(", ");
        } else {
            $otherdiffs->pushContent(" ");
        }
        $otherdiffs->pushContent(Button($args, $label[$other]));
    }
    $html->pushContent($otherdiffs);
    if ($old and $old->getVersion() == 0) {
        $old = false;
    }
    $html->pushContent(HTML::Table(PageInfoRow(_("Newer page:"), $new, $request, empty($version)), PageInfoRow(_("Older page:"), $old, $request, false)));
    if ($new && $old) {
        $diff = new Diff($old->getContent(), $new->getContent());
        if ($diff->isEmpty()) {
            $html->pushContent(HTML::hr(), HTML::p('[', _("Versions are identical"), ']'));
        } else {
            // New CSS formatted unified diffs (ugly in NS4).
            $fmt = new HtmlUnifiedDiffFormatter();
            // Use this for old table-formatted diffs.
            //$fmt = new TableUnifiedDiffFormatter;
            $html->pushContent($fmt->format($diff));
        }
    }
    include_once 'lib/Template.php';
    GeneratePage($html, sprintf(_("Diff: %s"), $pagename), $new);
}
示例#7
0
    $aText = $aLang == "en" ? "Archived page:" : "Page archivée :";
    $html .= "<dl><dt>{$aText}</dt>";
    if (is_array($archive)) {
        $html .= "\n<dd>";
        $html .= sprintf(gettext("Version %s"), $archive['version']);
        $html .= "\n</dd><dd>";
        $aText = $aLang == "en" ? "Last modified on %s" : "Dernière modification : %s";
        $html .= sprintf($aText, date($datetimeformat, $archive['lastmodified']));
        $html .= "\n</dd><dd>";
        $aText = $aLang == "en" ? "By %s" : "Par %s";
        $html .= sprintf($aText, $archive['author']);
        $html .= "</dd>";
    } else {
        $html .= "<dd><em>";
        $html .= $aLang == "en" ? "None" : "Aucune";
        $html .= "</em></dd>";
    }
    $html .= "</dl></div>\n";
    if (is_array($wiki) && is_array($archive)) {
        $diff = new WikiDiff($archive['content'], $wiki['content']);
        if ($diff->isEmpty()) {
            $aText = $aLang == "en" ? "Versions are identical" : "Les versions sont identiques";
            $html .= '<hr>[' . $aText . ']';
        } else {
            //$fmt = new WikiDiffFormatter;
            $fmt = new WikiUnifiedDiffFormatter();
            $html .= $fmt->format($diff, $archive['content']);
        }
    }
    GeneratePage('MESSAGE2', $html, sprintf("Diff %s", htmlspecialchars($pagename)), 0);
}
示例#8
0
$directory = $dumpserial;
$pages = GetAllWikiPagenames($dbi);
// see if we can access the directory the user wants us to use
if (!file_exists($directory)) {
    if (!mkdir($directory, 0755)) {
        ExitWiki("Cannot create directory '{$directory}'<br>\n");
    } else {
        $html = "Created directory '{$directory}' for the page dump...<br>\n";
    }
} else {
    $html = "Using directory '{$directory}'<br>\n";
}
$numpages = count($pages);
for ($x = 0; $x < $numpages; $x++) {
    $pagename = htmlspecialchars($pages[$x]);
    $filename = preg_replace('/^\\./', '%2e', rawurlencode($pages[$x]));
    $html .= "<br>{$pagename} ... ";
    if ($pagename != $filename) {
        $html .= "<small>saved as {$filename}</small> ... ";
    }
    $data = serialize(RetrievePage($dbi, $pages[$x], $WikiPageStore));
    if ($fd = fopen("{$directory}/{$filename}", "w")) {
        $num = fwrite($fd, $data, strlen($data));
        $html .= "<small>{$num} bytes written</small>\n";
    } else {
        ExitWiki("<b>couldn't open file '{$directory}/{$filename}' for writing</b>\n");
    }
}
$html .= "<p><b>Dump complete.</b>";
GeneratePage('MESSAGE', $html, 'Dump serialized pages', 0);
ExitWiki('');
示例#9
0
文件: stdlib.php 项目: hugcoday/wiki
function NoSuchRevision(&$request, $page, $version)
{
    $html = HTML(HTML::h2(_("Revision Not Found")), HTML::p(fmt("I'm sorry.  Version %d of %s is not in the database.", $version, WikiLink($page, 'auto'))));
    include_once 'lib/Template.php';
    GeneratePage($html, _("Bad Version"), $page->getCurrentRevision());
    $request->finish();
}
示例#10
0
<?php

// Backlinks: returns pages which link to a given page.
rcs_id('$Id: backlinks.php,v 1.1 2004/09/28 21:48:44 gcasse Exp $');
if (get_magic_quotes_gpc()) {
    $refs = stripslashes($refs);
}
$pagename = $refs;
// No HTML markup allowed in $title.
$title = sprintf(gettext("Pages which link to %s"), htmlspecialchars($pagename));
if (IsWikiPage($dbi, $pagename)) {
    $pagelink = LinkExistingWikiWord($pagename);
} else {
    $pagelink = LinkUnknownWikiWord($pagename);
}
$html = "<p><b>" . sprintf(gettext("Pages which link to %s") . " .....", $pagelink) . "</b></p>\n<ul>\n";
// search matching pages
$query = InitBackLinkSearch($dbi, $pagename);
$found = 0;
while ($page = BackLinkSearchNextMatch($dbi, $query)) {
    $found++;
    $html .= "<li>" . LinkExistingWikiWord($page) . "<br>\n";
}
$html .= "</ul>\n<hr noshade>\n" . sprintf(gettext("%d pages link to %s."), $found, $pagelink) . "\n";
GeneratePage('MESSAGE', $html, $title, 0);
示例#11
0
<?php

// Title search: returns pages having a name matching the search term
rcs_id('$Id: search.php,v 1.1 2004/09/28 21:48:48 gcasse Exp $');
if (get_magic_quotes_gpc()) {
    $search = stripslashes($search);
}
$html = "<P><B>" . sprintf(gettext("Searching for \"%s\" ....."), htmlspecialchars($search)) . "</B></P>\n";
// quote regexp chars (backends should do this...)
//$search = preg_quote($search);
// search matching pages
$found = 0;
if (strlen($search)) {
    $query = InitTitleSearch($dbi, $search);
    while ($page = TitleSearchNextMatch($dbi, $query)) {
        $found++;
        $html .= LinkExistingWikiWord($page) . "<br>\n";
    }
} else {
    $html .= gettext("(You entered an empty search string)") . "<br>\n";
}
$html .= "<hr noshade>\n" . sprintf(gettext("%d pages match your query."), $found) . "\n";
GeneratePage('MESSAGE', $html, gettext("Title Search Results"), 0);
示例#12
0
function RevertPage(&$request)
{
    $mesg = HTML::dd();
    $pagename = $request->getArg('pagename');
    $version = $request->getArg('version');
    if (!$version) {
        PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), HTML::dd(_("missing required version argument")));
        return;
    }
    $dbi =& $request->_dbi;
    $page = $dbi->getPage($pagename);
    $current = $page->getCurrentRevision();
    $currversion = $current->getVersion();
    if ($currversion == 0) {
        $mesg->pushContent(' ', _("no page content"));
        PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), $mesg);
        flush();
        return;
    }
    if ($currversion == $version) {
        $mesg->pushContent(' ', _("same version page"));
        PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), $mesg);
        flush();
        return;
    }
    if ($request->getArg('cancel')) {
        $mesg->pushContent(' ', _("Cancelled"));
        PrintXML(HTML::dt(fmt("Revert"), " ", WikiLink($pagename)), $mesg);
        flush();
        return;
    }
    if (!$request->getArg('verify')) {
        $mesg->pushContent(HTML::br(), _("Are you sure?"), HTML::br(), HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs($request->getArgs(), false, array('verify')), HiddenInputs(array('verify' => 1)), Button('submit:verify', _("Yes"), 'button'), HTML::Raw('&nbsp;'), Button('submit:cancel', _("Cancel"), 'button')));
        $rev = $page->getRevision($version);
        $html = HTML(HTML::dt(fmt("Revert %s to version {$version}", WikiLink($pagename))), $mesg, $rev->getTransformedContent());
        $template = Template('browse', array('CONTENT' => $html));
        GeneratePage($template, $pagename, $rev);
        $request->checkValidators();
        flush();
        return;
    }
    $rev = $page->getRevision($version);
    $content = $rev->getPackedContent();
    $versiondata = $rev->_data;
    $versiondata['summary'] = sprintf(_("revert to version %d"), $version);
    $new = $page->save($content, $currversion + 1, $versiondata);
    $dbi->touch();
    $pagelink = WikiLink($pagename);
    $mesg->pushContent(fmt("Revert: %s", $pagelink), fmt("- version %d saved to database as version %d", $version, $new->getVersion()));
    // Force browse of current page version.
    $request->setArg('version', false);
    $template = Template('savepage', array());
    $template->replace('CONTENT', $new->getTransformedContent());
    GeneratePage($template, $mesg, $new);
    flush();
}
示例#13
0
文件: main.php 项目: hugcoday/wiki
 function handleAction()
 {
     // Check illegal characters in page names: <>[]{}|"
     require_once "lib/Template.php";
     $page = $this->getPage();
     $pagename = $page->getName();
     if (preg_match("/[<\\[\\{\\|\"\\}\\]>]/", $pagename, $matches) > 0) {
         $CONTENT = HTML::div(array('class' => 'error'), _("Illegal character '") . $matches[0] . _("' in page name."));
         GeneratePage($CONTENT, $pagename);
         $this->finish();
     }
     $action = $this->getArg('action');
     if ($this->isPost() and !$this->_user->isAdmin() and $action != 'browse' and $action != 'wikitohtml') {
         if ($page->get('moderation')) {
             require_once "lib/WikiPlugin.php";
             $loader = new WikiPluginLoader();
             $plugin = $loader->getPlugin("ModeratedPage");
             if ($plugin->handler($this, $page)) {
                 $CONTENT = HTML::div(array('class' => 'wiki-edithelp'), fmt("%s: action forwarded to a moderator.", $action), HTML::br(), _("This action requires moderator approval. Please be patient."));
                 if (!empty($plugin->_tokens['CONTENT'])) {
                     $plugin->_tokens['CONTENT']->pushContent(HTML::br(), _("You must wait for moderator approval."));
                 } else {
                     $plugin->_tokens['CONTENT'] = $CONTENT;
                 }
                 $title = WikiLink($page->getName());
                 $title->pushContent(' : ', WikiLink(_("ModeratedPage")));
                 GeneratePage(Template('browse', $plugin->_tokens), $title, $page->getCurrentRevision());
                 $this->finish();
             }
         }
     }
     $method = "action_{$action}";
     if (method_exists($this, $method)) {
         $this->{$method}();
     } elseif ($page = $this->findActionPage($action)) {
         $this->actionpage($page);
     } else {
         $this->finish(fmt("%s: Bad action", $action));
     }
 }
示例#14
0
 function output($template, $title_fs)
 {
     global $WikiTheme;
     $selected =& $this->selected;
     $current =& $this->current;
     if ($selected && $selected->getVersion() != $current->getVersion()) {
         $rev = $selected;
         $pagelink = WikiLink($selected);
     } else {
         $rev = $current;
         $pagelink = WikiLink($this->page);
     }
     $title = new FormattedText($title_fs, $pagelink);
     if (USE_HTMLAREA and $template == 'editpage') {
         $WikiTheme->addMoreHeaders(Edit_HtmlArea_Head());
         //$tokens['PAGE_SOURCE'] = Edit_HtmlArea_ConvertBefore($this->_content);
     }
     $template = Template($template, $this->tokens);
     GeneratePage($template, $title, $rev);
     return true;
 }
示例#15
0
文件: display.php 项目: hugcoday/wiki
function actionPage(&$request, $action)
{
    global $WikiTheme;
    global $robots;
    $pagename = $request->getArg('pagename');
    $version = $request->getArg('version');
    $page = $request->getPage();
    $revision = $page->getCurrentRevision();
    $dbi = $request->getDbh();
    $actionpage = $dbi->getPage($action);
    $actionrev = $actionpage->getCurrentRevision();
    $pagetitle = HTML(fmt("%s: %s", $actionpage->getName(), $WikiTheme->linkExistingWikiWord($pagename, false, $version)));
    $request->setValidators(array('pageversion' => $revision->getVersion(), '%mtime' => $revision->get('mtime')));
    $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime')));
    $request->appendValidators(array('actionpagerev' => $actionrev->getVersion(), '%mtime' => $actionrev->get('mtime')));
    $transformedContent = $actionrev->getTransformedContent();
    /* Optionally tell google (and others) not to take notice of action pages.
          RecentChanges or AllPages might be an exception.
       */
    $args = array();
    if (GOOGLE_LINKS_NOFOLLOW) {
        $robots = "noindex,nofollow";
        $args = array('ROBOTS_META' => $robots);
    }
    /* Handle other formats: So far we had html only.
          xml is requested by loaddump, rss is handled by recentchanges,
          pdf is a special action, but should be a format to dump multiple pages
          if the actionpage plugin returns a pagelist.
          rdf and owl are handled by SemanticWeb.
       */
    $format = $request->getArg('format');
    /* At first the single page formats: html, xml */
    if ($pagename == _("LinkDatabase")) {
        $template = Template('browse', array('CONTENT' => $transformedContent));
        GeneratePage($template, $pagetitle, $revision, $args);
    } elseif (!$format or $format == 'html' or $format == 'sidebar' or $format == 'contribs') {
        $template = Template('browse', array('CONTENT' => $transformedContent));
        GeneratePage($template, $pagetitle, $revision, $args);
    } elseif ($format == 'xml') {
        $request->setArg('format', '');
        $template = new Template('browse', $request, array('revision' => $revision, 'CONTENT' => $transformedContent));
        $html = GeneratePageAsXML($template, $pagename, $revision);
        header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']);
        echo $html;
    } else {
        $pagelist = null;
        require_once 'lib/WikiPlugin.php';
        // Then the multi-page formats
        // rss (if not already handled by RecentChanges)
        // Need the pagelist from the first plugin
        foreach ($transformedContent->_content as $cached_element) {
            if (is_a($cached_element, "Cached_PluginInvocation")) {
                $loader = new WikiPluginLoader();
                $markup = null;
                // return the first found pagelist
                $pagelist = $loader->expandPI($cached_element->_pi, $request, $markup, $pagename);
                if (is_a($pagelist, 'PageList')) {
                    break;
                }
            }
        }
        if (!$pagelist or !is_a($pagelist, 'PageList')) {
            if (!in_array($format, array("rss91", "rss2", "rss", "atom", "rdf"))) {
                trigger_error(sprintf("Format %s requires an actionpage returning a pagelist.", $format) . "\n" . "Fall back to single page mode", E_USER_WARNING);
            }
            require_once 'lib/PageList.php';
            $pagelist = new PageList();
            if ($format == 'pdf') {
                $pagelist->addPage($page);
            }
        } else {
            foreach ($pagelist->_pages as $page) {
                $name = $page->getName();
                if ($name != $pagename and $page->exists()) {
                    $args['VALID_LINKS'][] = $name;
                }
            }
        }
        if ($format == 'pdf') {
            require_once "lib/pdf.php";
            array_unshift($args['VALID_LINKS'], $pagename);
            ConvertAndDisplayPdfPageList($request, $pagelist, $args);
        } elseif ($format == 'ziphtml') {
            // need to fix links
            require_once 'lib/loadsave.php';
            array_unshift($args['VALID_LINKS'], $pagename);
            $request->setArg('zipname', FilenameForPage($pagename) . ".zip");
            $request->setArg('pages', $args['VALID_LINKS']);
            $request->setArg('format', '');
            MakeWikiZipHtml($request);
        } elseif (in_array($format, array("rss91", "rss2", "rss", "atom"))) {
            $args = $request->getArgs();
            //$request->setArg('format','');
            if ($pagename == _("RecentChanges")) {
                $template->printExpansion($args);
            } else {
                require_once "lib/plugin/RecentChanges.php";
                $plugin = new WikiPlugin_RecentChanges();
                return $plugin->format($plugin->getChanges($request->_dbi, $args), $args);
            }
        } elseif ($format == 'json') {
            // for faster autocompletion on searches
            $req_args =& $request->args;
            unset($req_args['format']);
            $json = array('count' => count($pagelist->_pages), 'list' => $args['VALID_LINKS'], 'args' => $req_args, 'phpwiki-version' => PHPWIKI_VERSION);
            if (loadPhpExtension('json')) {
                $json_enc = json_encode($json);
            } else {
                require_once "lib/pear/JSON.php";
                $j = new Services_JSON();
                $json_enc = $j->encode($json);
            }
            header("Content-Type: application/json");
            die($json_enc);
        } elseif ($format == 'rdf') {
            // all semantic relations and attributes
            require_once "lib/SemanticWeb.php";
            $rdf = new RdfWriter($request, $pagelist);
            $rdf->format();
        } elseif ($format == 'rdfs') {
            require_once "lib/SemanticWeb.php";
            $rdf = new RdfsWriter($request, $pagelist);
            $rdf->format();
        } elseif ($format == 'owl') {
            // or daml?
            require_once "lib/SemanticWeb.php";
            $rdf = new OwlWriter($request, $pagelist);
            $rdf->format();
        } else {
            if (!in_array($pagename, array(_("LinkDatabase")))) {
                trigger_error(sprintf(_("Unsupported argument: %s=%s"), "format", $format), E_USER_WARNING);
            }
            $template = Template('browse', array('CONTENT' => $transformedContent));
            GeneratePage($template, $pagetitle, $revision, $args);
        }
    }
    $request->checkValidators();
    flush();
    return '';
}
示例#16
0
            if ($key > 0 || !$key) {
                #key is an array index
                continue;
            }
            if (gettype($val) == "array" && $showpagesource == "on") {
                $val = implode($val, "{$FieldSeparator}#BR#{$FieldSeparator}\n");
                $val = htmlspecialchars($val);
                $val = str_replace("{$FieldSeparator}#BR#{$FieldSeparator}", "<br>", $val);
            } elseif ($key == 'lastmodified' || $key == 'created') {
                $val = date($datetimeformat, $val);
            } else {
                $val = htmlspecialchars($val);
            }
            $table .= "<tr><td>{$key}</td><td>{$val}</td></tr>\n";
        }
        $table .= "</table>";
    }
    return $table;
}
$html .= "<P><B>";
$html .= gettext("Current version");
$html .= "</B></p>";
// $dbi = OpenDataBase($WikiPageStore);   --- done by w_index.php
$html .= ViewPageProps($info, $WikiPageStore);
$html .= "<P><B>";
$html .= gettext("Archived version");
$html .= "</B></p>";
// $dbi = OpenDataBase($ArchivePageStore);
$html .= ViewPageProps($info, $ArchivePageStore);
GeneratePage('MESSAGE', $html, gettext("PageInfo") . ": '{$info}'", 0);
示例#17
0
 function savePage()
 {
     $request =& $this->request;
     if ($this->isUnchanged()) {
         // Allow admin lock/unlock even if
         // no text changes were made.
         if ($this->updateLock()) {
             $dbi = $request->getDbh();
             $dbi->touch();
         }
         // Save failed. No changes made.
         $this->_redirectToBrowsePage();
         // user will probably not see the rest of this...
         require_once 'lib/display.php';
         // force browse of current version:
         $request->setArg('action', false);
         $request->setArg('version', false);
         displayPage($request, 'nochanges');
         return true;
     }
     if (!$this->user->isAdmin() and $this->isSpam()) {
         $this->_isSpam = true;
         return false;
         /*
         // Save failed. No changes made.
         $this->_redirectToBrowsePage();
         // user will probably not see the rest of this...
         require_once('lib/display.php');
         // force browse of current version:
         $request->setArg('version', false);
         displayPage($request, 'nochanges');
         return true;
         */
     }
     $page =& $this->page;
     // Include any meta-data from original page version which
     // has not been explicitly updated.
     // (Except don't propagate pgsrc_version --- moot for now,
     //  because at present it never gets into the db...)
     $meta = $this->selected->getMetaData();
     unset($meta['pgsrc_version']);
     $meta = array_merge($meta, $this->meta);
     // Save new revision
     $this->_content = $this->getContent();
     $newrevision = $page->save($this->_content, $this->version == -1 ? -1 : $this->_currentVersion + 1, $meta);
     if (!isa($newrevision, 'WikiDB_PageRevision')) {
         // Save failed.  (Concurrent updates).
         return false;
     }
     // New contents successfully saved...
     $this->updateLock();
     // Clean out archived versions of this page.
     require_once 'lib/ArchiveCleaner.php';
     $cleaner = new ArchiveCleaner($GLOBALS['ExpireParams']);
     $cleaner->cleanPageRevisions($page);
     /* generate notification emails done in WikiDB::save to catch 
        all direct calls (admin plugins) */
     // look at the errorstack
     $errors = $GLOBALS['ErrorManager']->_postponed_errors;
     $warnings = $GLOBALS['ErrorManager']->getPostponedErrorsAsHTML();
     $GLOBALS['ErrorManager']->_postponed_errors = $errors;
     $dbi = $request->getDbh();
     $dbi->touch();
     global $WikiTheme;
     if (empty($warnings->_content) && !$WikiTheme->getImageURL('signature')) {
         // Do redirect to browse page if no signature has
         // been defined.  In this case, the user will most
         // likely not see the rest of the HTML we generate
         // (below).
         $request->setArg('action', false);
         $this->_redirectToBrowsePage();
     }
     // Force browse of current page version.
     $request->setArg('version', false);
     // testme: does preview and more need action=edit?
     $request->setArg('action', false);
     $template = Template('savepage', $this->tokens);
     $template->replace('CONTENT', $newrevision->getTransformedContent());
     if (!empty($warnings->_content)) {
         $template->replace('WARNINGS', $warnings);
         unset($GLOBALS['ErrorManager']->_postponed_errors);
     }
     $pagelink = WikiLink($page);
     GeneratePage($template, fmt("Saved: %s", $pagelink), $newrevision);
     return true;
 }
示例#18
0
    ExitWiki('');
} elseif (isset($dumpserial)) {
    include 'w_admin/dumpserial.php';
} elseif (isset($loadserial)) {
    include 'w_admin/loadserial.php';
} elseif (isset($remove)) {
    if (get_magic_quotes_gpc()) {
        $remove = stripslashes($remove);
    }
    if (function_exists('RemovePage')) {
        $html .= sprintf(gettext("You are about to remove '%s' permanently!"), htmlspecialchars($remove));
        $html .= "\n<P>";
        $url = rawurlencode($remove);
        $html .= sprintf(gettext("Click %shere%s to remove the page now."), "<A HREF=\"{$ScriptUrl}?removeok={$url}\">", "</A>");
        $html .= "\n<P>";
        $html .= gettext("Otherwise press the \"Back\" button of your browser.");
    } else {
        $html = gettext("Function not yet implemented.");
    }
    GeneratePage('MESSAGE', $html, gettext("Remove page"), 0);
    ExitWiki('');
} elseif (isset($removeok)) {
    if (get_magic_quotes_gpc()) {
        $removeok = stripslashes($removeok);
    }
    RemovePage($dbi, $removeok);
    $html = sprintf(gettext("Removed page '%s' succesfully."), htmlspecialchars($removeok));
    GeneratePage('MESSAGE', $html, gettext("Remove page"), 0);
    ExitWiki('');
}
include 'wiki.php';
示例#19
0
 function handleAction()
 {
     $action = $this->getArg('action');
     if ($this->isPost() and !$this->_user->isAdmin() and $action != 'browse') {
         $page = $this->getPage();
         if ($page->get('moderation')) {
             require_once "lib/WikiPlugin.php";
             $loader = new WikiPluginLoader();
             $plugin = $loader->getPlugin("ModeratedPage");
             if ($plugin->handler($this, $page)) {
                 $CONTENT = HTML::div(array('class' => 'wiki-edithelp'), fmt("%s: action forwarded to a moderator.", $action), HTML::br(), _("This action requires moderator approval. Please be patient."));
                 if (!empty($plugin->_tokens['CONTENT'])) {
                     $plugin->_tokens['CONTENT']->pushContent(HTML::br(), _("You must wait for moderator approval."));
                 } else {
                     $plugin->_tokens['CONTENT'] = $CONTENT;
                 }
                 require_once "lib/Template.php";
                 $title = WikiLink($page->getName());
                 $title->pushContent(' : ', WikiLink(_("ModeratedPage")));
                 GeneratePage(Template('browse', $plugin->_tokens), $title, $page->getCurrentRevision());
                 $this->finish();
             }
         }
     }
     $method = "action_{$action}";
     if (method_exists($this, $method)) {
         $this->{$method}();
     } elseif ($page = $this->findActionPage($action)) {
         $this->actionpage($page);
     } else {
         $this->finish(fmt("%s: Bad action", $action));
     }
 }
示例#20
0
文件: diff.php 项目: hugcoday/wiki
function showDiff(&$request)
{
    $pagename = $request->getArg('pagename');
    if (is_array($versions = $request->getArg('versions'))) {
        // Version selection from pageinfo.php display:
        rsort($versions);
        list($version, $previous) = $versions;
    } else {
        $version = $request->getArg('version');
        $previous = $request->getArg('previous');
    }
    // abort if page doesn't exist
    $dbi = $request->getDbh();
    $page = $request->getPage();
    $current = $page->getCurrentRevision(false);
    if ($current->getVersion() < 1) {
        $html = HTML::div(array('class' => 'wikitext', 'id' => 'difftext'), HTML::p(fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown'))));
        require_once 'lib/Template.php';
        GeneratePage($html, sprintf(_("Diff: %s"), $pagename), false);
        return;
        //early return
    }
    if ($version) {
        if (!($new = $page->getRevision($version))) {
            NoSuchRevision($request, $page, $version);
        }
        $new_version = fmt("version %d", $version);
    } else {
        $new = $current;
        $new_version = _("current version");
    }
    if (preg_match('/^\\d+$/', $previous)) {
        if (!($old = $page->getRevision($previous))) {
            NoSuchRevision($request, $page, $previous);
        }
        $old_version = fmt("version %d", $previous);
        $others = array('major', 'minor', 'author');
    } else {
        switch ($previous) {
            case 'author':
                $old = $new;
                while ($old = $page->getRevisionBefore($old)) {
                    if ($old->get('author') != $new->get('author')) {
                        break;
                    }
                }
                $old_version = _("revision by previous author");
                $others = array('major', 'minor');
                break;
            case 'minor':
                $previous = 'minor';
                $old = $page->getRevisionBefore($new);
                $old_version = _("previous revision");
                $others = array('major', 'author');
                break;
            case 'major':
            default:
                $old = $new;
                while ($old && $old->get('is_minor_edit')) {
                    $old = $page->getRevisionBefore($old);
                }
                if ($old) {
                    $old = $page->getRevisionBefore($old);
                }
                $old_version = _("predecessor to the previous major change");
                $others = array('minor', 'author');
                break;
        }
    }
    $new_link = WikiLink($new, '', $new_version);
    $old_link = $old ? WikiLink($old, '', $old_version) : $old_version;
    $page_link = WikiLink($page);
    $html = HTML::div(array('class' => 'wikitext', 'id' => 'difftext'), HTML::p(fmt("Differences between %s and %s of %s.", $new_link, $old_link, $page_link)));
    $otherdiffs = HTML::p(_("Other diffs:"));
    $label = array('major' => _("Previous Major Revision"), 'minor' => _("Previous Revision"), 'author' => _("Previous Author"));
    foreach ($others as $other) {
        $args = array('action' => 'diff', 'previous' => $other);
        if ($version) {
            $args['version'] = $version;
        }
        if (count($otherdiffs->getContent()) > 1) {
            $otherdiffs->pushContent(", ");
        } else {
            $otherdiffs->pushContent(" ");
        }
        $otherdiffs->pushContent(Button($args, $label[$other]));
    }
    $html->pushContent($otherdiffs);
    if ($old and $old->getVersion() == 0) {
        $old = false;
    }
    $html->pushContent(HTML::Table(PageInfoRow(_("Newer page:"), $new, $request, empty($version)), PageInfoRow(_("Older page:"), $old, $request, false)));
    if ($new && $old) {
        $diff = new Diff($old->getContent(), $new->getContent());
        if ($diff->isEmpty()) {
            $html->pushContent(HTML::hr(), HTML::p(_("Content of versions "), $old->getVersion(), _(" and "), $new->getVersion(), _(" is identical.")));
            // If two consecutive versions have the same content, it is because the page was
            // renamed, or metadata changed: ACL, owner, markup.
            // We give the reason by printing the summary.
            if ($new->getVersion() - $old->getVersion() == 1) {
                $html->pushContent(HTML::p(_("Version "), $new->getVersion(), _(" was created because: "), $new->get('summary')));
            }
        } else {
            $fmt = new HtmlUnifiedDiffFormatter();
            $html->pushContent($fmt->format($diff));
        }
        $html->pushContent(HTML::hr(), HTML::h2($new_version));
        require_once "lib/BlockParser.php";
        $html->pushContent(TransformText($new, $new->get('markup'), $pagename));
    }
    require_once 'lib/Template.php';
    GeneratePage($html, sprintf(_("Diff: %s"), $pagename), $new);
}
示例#21
0
function ConcurrentUpdates($pagename)
{
    if ("en" == getLang()) {
        //     exit;
        /* xgettext only knows about c/c++ line-continuation strings
             is does not know about php's dot operator.
             We want to translate this entire paragraph as one string, of course.
           */
        $html = "<p>";
        $html .= "PhpWiki is unable to save your changes, because another user edited and saved the page while you were editing the page too. If saving proceeded now changes from the previous author would be lost.";
        $html .= "</p>\n<p>";
        $html .= "In order to recover from this situation follow these steps:</p>";
        $html .= "\n<ol><li>";
        $html .= "Use your browser's <em>Back</em> button to go back to the edit page.";
        $html .= "\n</li><li>";
        $html .= "Copy your changes to the clipboard or to another temporary place (e.g. text editor).";
        $html .= "\n</li><li>";
        $html .= "<em>Reload</em> the page. You should now see the most current version of the page. Your changes are no longer there.";
        $html .= "\n</li><li>";
        $html .= "Make changes to the file again. Paste your additions from the clipboard (or text editor).";
        $html .= "\n</li><li>";
        $html .= "Press <em>Save</em> again.";
        $html .= "\n</li></ol>\n<p>";
        $html .= "Sorry for the inconvenience.";
        $html .= "</p>";
        GeneratePage('MESSAGE', $html, sprintf(gettext("Problem while updating %s"), $pagename), 0);
    } else {
        $html = "<p>";
        $html .= "PhpWiki ne peut pas sauvegarder vos modifications, car un autre utilisateur modifia et sauvegarda cette même page pendant que vous étiez en train de la modifier. Si vos modification étaient acceptées, celles du précédant utilisateur seraient perdues.";
        $html .= "</p>\n<p>";
        $html .= "A fin de remédier à cette situation suivez les étapes suivantes :</p>";
        $html .= "\n<ol><li>";
        $html .= "Appuyer sur le bouton <em>Retour</em> de votre navigateur pour revenir à la page en cours de modification.";
        $html .= "\n</li><li>";
        $html .= "Recopier vos modifications à un autre endroit (par exemple via un éditeur de texte).";
        $html .= "\n</li><li>";
        $html .= "<em>Recharger</em> la page. Vous devriez maintenant voir apparaitre la version la plus récente de cette page. Vos modifications n'y figurent pas.";
        $html .= "\n</li><li>";
        $html .= "Modifier à nouveau la page en récupérant vos modifications (de l'éditeur de texte par exemple).";
        $html .= "\n</li><li>";
        $html .= "Appuyer sur <em>Save</em> à nouveau.";
        $html .= "\n</li></ol>\n<p>";
        $html .= "Désolé pour le dérangement.";
        $html .= "</p>";
        GeneratePage('MESSAGE', $html, sprintf(gettext("Problème pendant la mise à jour de %s"), $pagename), 0);
    }
    exit;
}
示例#22
0
        $html .= gettext("This page has been locked by the administrator and cannot be edited.");
        $html .= "\n<p>";
        $html .= gettext("Sorry for the inconvenience.");
        $html .= "\n";
        GeneratePage('MESSAGE', $html, sprintf(gettext("Problem while editing %s"), $pagename), 0);
        ExitWiki("");
    }
    $textarea = htmlspecialchars(implode("\n", $pagehash["content"]));
    if (isset($copy)) {
        // $cdbi = OpenDataBase($WikiPageStore);
        $currentpage = RetrievePage($dbi, $pagename, $WikiPageStore);
        $pagehash["version"] = $currentpage["version"];
    } elseif ($pagehash["version"] > 1) {
        if (IsInArchive($dbi, $pagename)) {
            $pagehash["copy"] = 1;
        }
    }
} else {
    if (preg_match("/^{$WikiNameRegexp}\$/", $pagename)) {
        $newpage = $pagename;
    } else {
        $newpage = "[{$pagename}]";
    }
    $textarea = htmlspecialchars(sprintf(gettext("Describe %s here."), $newpage));
    unset($pagehash);
    $pagehash["version"] = 0;
    $pagehash["lastmodified"] = time();
    $pagehash["author"] = '';
}
GeneratePage('EDITPAGE', $textarea, $pagename, $pagehash);
示例#23
0
/*
   Load a set of pages that have been serialized with 
   wiki_dumpserial.php.
*/
if (!defined('WIKI_ADMIN')) {
    die("You must be logged in as the administrator to load serialized pages.");
}
$directory = $loadserial;
$html = "Loading serialized pages from '{$directory}'.<p>\n";
if (!file_exists($directory)) {
    echo "No such directory '{$directory}'.<br>\n";
    exit;
}
$handle = opendir($directory);
while ($file = readdir($handle)) {
    if ($file[0] == ".") {
        continue;
    }
    $html .= "Reading '{$file}'...<br>\n";
    $data = implode("", file("{$directory}/{$file}"));
    $pagehash = unserialize($data);
    // at this point there needs to be some form of verification
    // that we are about to insert a page.
    $pagename = rawurldecode($file);
    $html .= "inserting file '" . htmlspecialchars($pagename) . "' into the database...<br>\n";
    InsertPage($dbi, $pagename, $pagehash);
}
closedir($handle);
$html .= "<p><b>Load complete.</b>";
GeneratePage('MESSAGE', $html, 'Load serialized pages', 0);
ExitWiki('');
示例#24
0
<!-- $Id: editlinks.php,v 1.1 2004/09/28 21:48:46 gcasse Exp $ -->
<?php 
// Thanks to Alister <*****@*****.**> for this code.
// This allows an arbitrary number of reference links.
$pagename = rawurldecode($links);
if (get_magic_quotes_gpc()) {
    $pagename = stripslashes($pagename);
}
$pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
settype($pagehash, 'array');
GeneratePage('EDITLINKS', "", $pagename, $pagehash);
示例#25
0
 function PrintLoginForm(&$request, $args, $fail_message = false, $seperate_page = true)
 {
     include_once 'lib/Template.php';
     // Call update_locale in case the system's default language is not 'en'.
     // (We have no user pref for lang at this point yet, no one is logged in.)
     update_locale(DEFAULT_LANGUAGE);
     $userid = '';
     $require_level = 0;
     extract($args);
     // fixme
     $require_level = max(0, min(WIKIAUTH_ADMIN, (int) $require_level));
     $pagename = $request->getArg('pagename');
     $login = new Template('login', $request, compact('pagename', 'userid', 'require_level', 'fail_message', 'pass_required'));
     if ($seperate_page) {
         $request->discardOutput();
         $page = $request->getPage($pagename);
         $revision = $page->getCurrentRevision();
         return GeneratePage($login, _("Sign In"), $revision);
     } else {
         return $login;
     }
 }
示例#26
0
 function PrintLoginForm(&$request, $args, $fail_message = false, $seperate_page = false)
 {
     include_once 'lib/Template.php';
     // Call update_locale in case the system's default language is not 'en'.
     // (We have no user pref for lang at this point yet, no one is logged in.)
     if ($GLOBALS['LANG'] != DEFAULT_LANGUAGE) {
         update_locale(DEFAULT_LANGUAGE);
     }
     $userid = $this->_userid;
     $require_level = 0;
     extract($args);
     // fixme
     $require_level = max(0, min(WIKIAUTH_ADMIN, (int) $require_level));
     $pagename = $request->getArg('pagename');
     $nocache = 1;
     $login = Template('login', compact('pagename', 'userid', 'require_level', 'fail_message', 'pass_required', 'nocache'));
     // check if the html template was already processed
     $seperate_page = $seperate_page ? true : !alreadyTemplateProcessed('html');
     if ($seperate_page) {
         $page = $request->getPage($pagename);
         $revision = $page->getCurrentRevision();
         return GeneratePage($login, _("Sign In"), $revision);
     } else {
         return $login->printExpansion();
     }
 }
示例#27
0
} else {
    // Gilles Casse (2003-01-21) for the Oralux website.
    $pagename = $FrontPage;
    //       $pagename = gettext("FrontPage");
    //       // if there is no FrontPage, create a basic set of Wiki pages
    //       if (! IsWikiPage($dbi, $pagename)) {
    //          include "w_lib/setupwiki.php";
    //       }
}
$html = "";
$enc_name = rawurlencode($pagename);
$pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
// Gilles Casse (2003-01-21) for the Oralux website.
// Sorry, no new page at the moment (translations).
if (!is_array($pagehash)) {
    echo "Error...";
    return;
}
// transform.php returns $html containing all the HTML markup
include "w_lib/transform.php";
// we render the page if it exists, else ask the user to write one.
//    if (is_array($pagehash)) {
//       // transform.php returns $html containing all the HTML markup
//       include("w_lib/transform.php");
//    } else {
//       $html .= sprintf(gettext("Describe %s here."),
// 		       "$pagename<a href='$ScriptUrl?edit=$enc_name'>?</a>");
//    }
GeneratePage('BROWSE', $html, $pagename, $pagehash);
flush();
IncreaseHitCount($dbi, $pagename);