function action_find() { global $pagestore, $find, $branch_search; $doFindOne = 1; // avoid findOne search if empty string, full text search, or branch search if (trim($find) == '' || $find[0] == '!' || $branch_search) { $doFindOne = 0; } // remove leading ! if full text search if ($find[0] == '!') { $find = substr($find, 1); } // try to find one page by its name if ($doFindOne && ($findOne = $pagestore->findOne(trim($find)))) { header('Location: ' . viewURL($findOne)); } else { $list = $pagestore->find($find); if ($branch_search) { $branch_nodes = $pagestore->getTree($branch_search, '', 'FLAT'); $list = array_intersect($list, $branch_nodes); } $text = ''; foreach ($list as $page) { if ($page != $find) { $text .= html_ref($page, $page) . html_newline(); } } template_find(array('find' => $find, 'pages' => $text, 'branch_search' => $branch_search)); } }
function template_save($args) { // You might use this to put up some sort of "thank-you" page like Ward // does in WikiWiki, or to display a list of words that fail spell-check. // For now, we simply redirect to the view action for this page. $newLocation = viewURL($args['page']) . '&no_redirect=1'; if (isset($args['anchor'])) { $newLocation .= "#" . $args['anchor']; } header('Location: ' . $newLocation); }
function template_subscriptions($args) { template_common_prologue(array('norobots' => 1, 'title' => 'Page Subscriptions', 'heading' => 'Page Subscriptions', 'headlink' => '', 'headsufx' => '', 'toolbar' => 0, 'button_selected' => '', 'button_view' => 0, 'button_backlinks' => 0)); ?> <form name="subscriptionsForm" action="<?php print $SubscriptionsScript; ?> " method="POST"> <input type="hidden" name="subscribed_pages[]" value=""> <?php if ($args['subscriptions']) { ?> <p> Uncheck any pages you want to remove from your subscriptions. <p> <?php foreach ($args['subscriptions'] as $page) { print '<input type="checkbox" name="subscribed_pages[]" value="' . urlencode($page) . '" checked>'; print ' <a href="' . viewURL($page) . '">' . $page . "</a><br>\n"; } ?> <p> <input type="submit" value="Save"> <?php } else { ?> <p> You have no page subscriptions. <?php } ?> </form> <?php template_common_epilogue(array('nosearch' => 1, 'headlink' => '', 'button_selected' => '', 'button_view' => 0, 'button_backlinks' => 0)); }
function action_rss() { global $pagestore, $min, $days; $itemseq = ''; $itemdesc = ''; if ($min == 0) { $min = 10; } if ($days == 0) { $days = 2; } $pages = $pagestore->allpages(); usort($pages, 'catSort'); $now = time(); for ($i = 0; $i < count($pages); $i++) { $editTime = mktime(substr($pages[$i][0], 8, 2), substr($pages[$i][0], 10, 2), substr($pages[$i][0], 12, 2), substr($pages[$i][0], 4, 2), substr($pages[$i][0], 6, 2), substr($pages[$i][0], 0, 4)); if ($days >= 0 && $now - $editTime > $days * 24 * 60 * 60 && $i >= $min) { break; } $itemseq = $itemseq . ' <rdf:li rdf:resource="' . viewURL($pages[$i][1], $pages[$i][7]) . '" />' . "\n"; $itemdesc = $itemdesc . ' <item rdf:about="' . viewURL($pages[$i][1], $pages[$i][7]) . '">' . "\n" . ' <title>' . $pages[$i][1] . '</title>' . "\n" . ' <link>' . viewURL($pages[$i][1]) . '</link>' . "\n" . ' <description>' . $pages[$i][5] . '</description>' . "\n" . ' <dc:date>' . html_gmtime($pages[$i][0]) . '</dc:date>' . "\n" . ' <dc:contributor>' . "\n" . ' <rdf:Description wiki:host="' . $pages[$i][2] . '"' . ($pages[$i][3] == '' ? '' : ' link="' . viewURL($pages[$i][3]) . '"') . '>' . "\n" . ($pages[$i][3] == '' ? '' : ' <rdf:value>' . $pages[$i][3] . '</rdf:value>' . "\n") . ' </rdf:Description>' . "\n" . ' </dc:contributor>' . "\n" . ' <wiki:status>updated</wiki:status>' . "\n" . ' <wiki:importance>major</wiki:importance>' . "\n" . ' <wiki:diff>' . historyURL($pages[$i][1]) . '</wiki:diff>' . "\n" . ' <wiki:version>' . $pages[$i][7] . '</wiki:version>' . "\n" . ' <wiki:history>' . historyURL($pages[$i][1]) . '</wiki:history>' . "\n" . ' </item>' . "\n"; } template_rss(array('itemseq' => $itemseq, 'itemdesc' => $itemdesc)); }
function template_subscribe($args) { $newLocation = viewURL($args['page']); header('Location: ' . $newLocation); }
function custom_display_html_ref($page, $appearance, $hover = '', $anchor = '', $anchor_appearance = '') { global $SeparateLinkWords, $TDPageQueue, $Messages; if ($hover != '') { $hover = ' title="' . $hover . '"'; } if (query_page_exists($page)) { $found = FALSE; foreach ($TDPageQueue as $t) { if ($t == $page) { $found = TRUE; } } if (!$found) { $TDPageQueue[] = $page; } if ($SeparateLinkWords && $page == $appearance) { $appearance = html_split_name($page); } return '<a href="' . viewURL($page) . $anchor . '"' . $hover . '>' . $appearance . $anchor_appearance . '</a>'; } else { $Messages[] = 'Page <a href="index.php?action=edit&page=' . $page . '">' . $page . '</a> missing from Wiki.'; return $appearance; } }
function template_common_epilogue($args) { global $AdditionalFooter, $AllowAnonymousPosts, $EmailSuffix; global $EnableSubscriptions, $EnableCaptcha, $HomePage, $NickName, $page; global $pagestore, $PageTooLongLen, $PrefsScript, $UserName; $pg = $pagestore->page($page); $pagetext = $pg->text; if (isset($args["toolbar"])) { ?> <div class="toolbar" id="toolbar-bottom"><?php toolbar($page, $args); ?> </div> <?php } ?> </div> <NOINDEX> <div id="footer" class="printhide"> <div id="logininfo"> <?php if ($UserName) { print "Logged in as " . html_ref($UserName, $UserName); } else { print "Not <a href=\"login/?{$page}\">logged in</a>"; } if ($EnableSubscriptions && isset($EmailSuffix) && $UserName != '' && isset($args['subscribe']) && !empty($args['subscribe'])) { if ($pg->isSubscribed($UserName)) { $caption = 'Unsubscribe'; } else { $caption = 'Subscribe'; } print ' | <a href="' . pageSubscribeURL($args['subscribe']) . '">' . $caption . '</a>'; } if (!$UserName) { print ' | <a href="' . viewURL($page) . '&view_source=1">View source</a>'; } print "<br>"; print html_ref('RecentChanges', 'RecentChanges') . ', ' . '<a href="' . $PrefsScript . '">UserOptions</a>'; $help_page = $pagestore->page('HelpPage'); if ($help_page->exists()) { print ', ' . html_ref('HelpPage', 'HelpPage'); } ?> </div> <div id="comment"> <?php if (!in_array($page, array($HomePage, 'RecentChanges')) && ($UserName || $AllowAnonymousPosts)) { ?> <script language="javascript"> <!-- function epilogue_quickadd_validate(form) { if (form.quickadd.value == '') { alert('Please provide content for the text field.'); return false; } else if (form.validationcode && form.validationcode.value == '') { alert('The validation code is required.'); return false; } else { return true; } } //--> </script> <?php if ($args['edit']) { if ($args['page_length'] > $PageTooLongLen) { print '<div style="color:red;font-weight:bold">' . 'This page is too long. Comments are disabled.</div>'; } else { global $document; $document = $pg->read(); $document = str_replace('"', "\\\\'", $document); ?> <form method="post" action="<?php print saveURL($page); ?> "> <div class="form"> <input type="hidden" name="Save" value="1"> <input type="hidden" name="appending" value="1"> <?php if (!strcasecmp($page, 'annoyingquote') || !strcasecmp($page, 'accumulatedwisdom')) { // Tweaked "Add a Comment" for AnnoyingQuote page ?> <input type="hidden" name="comment" value="Add a Quote"> <input type="hidden" name="appendingQuote" value="1"> <table width="100%"> <tr valign="bottom"> <td align="right">Quote: </td> <td nowrap><textarea name="quickadd" rows="2" wrap="virtual"></textarea></td> </tr> <tr valign="bottom"> <td width="1%" align="right">Author: </td> <td width="99%" nowrap><input class="fullWidth" type="text" name="quoteAuthor" size="20" value=""></td> </tr> </table> <?php if (!$UserName && $EnableCaptcha) { print_captcha_box(); } ?> <input type="submit" name="append" value="Add a Quote" onClick="return epilogue_quickadd_validate(this.form)"> <?php } else { // Standard Add a Comment print '<input type="hidden" name="comment" value="Comment">'; print '<textarea name="quickadd" rows="4" cols="20">'; print "----\n'''"; if ($UserName) { print "[{$UserName}]"; } else { if ($NickName) { print htmlspecialchars($NickName); } else { print "Anonymous@" . $_SERVER["REMOTE_ADDR"]; } } print " (" . date('Y/m/d') . ")''': "; print "</textarea>\n"; if (!$UserName) { if ($EnableCaptcha) { print_captcha_box(); } if (!$NickName) { print '(Anonymous users, see <a href="' . $PrefsScript . '">UserOptions</a> to set a nickname.) '; } } print '<input type="submit" name="append" value="Add a Comment" onClick="return epilogue_quickadd_validate(this.form)">'; } ?> </div> </form> <?php } } ?> <?php } ?> </div> <div id="timestamp"> <?php if (isset($args['timestamp'])) { print '<i>Last edited ' . html_time($args['timestamp']); if ($args['timestamp'] != '') { if (isset($args['euser']) && $args['euser']) { print ' by ' . $args['euser']; } else { print ' anonymously'; } } } if (isset($args['twin']) && $args['twin'] != '') { if (count($twin = $pagestore->twinpages($args['twin']))) { print '<br>See twins of this page: '; for ($i = 0; $i < count($twin); $i++) { print html_twin($twin[$i][0], $twin[$i][1]) . ' '; } } } ?> </div> <?php if ($AdditionalFooter) { include $AdditionalFooter; } ?> </div> </NOINDEX> </body> </html> <?php }
function latex_history_entry($page, $version, $time, $host, $user, $c1, $c2, $comment) { return "<tr><td>" . "<input type=\"radio\" name=\"ver1\" value=\"{$version}\"" . ($c1 ? ' checked="checked"' : '') . " /></td>\n" . " <td>" . "<input type=\"radio\" name=\"ver2\" value=\"{$version}\"" . ($c2 ? ' checked="checked"' : '') . " /></td>\n" . "<td><a href=\"" . viewURL($page, $version) . "\">" . latex_time($time) . "</a> . . . . " . ($user == '' ? $host : latex_ref($user, $user, $host)) . ($comment == '' ? '' : ' ' . latex_bold_start() . '[' . str_replace('<', '<', str_replace('&', '&', $comment)) . ']' . latex_bold_end()) . "</td></tr>\n"; }
function parse($args, $page) { global $HTTP_COOKIE_VARS, $pagestore, $UserName; $poll_user = addslashes($UserName); // is a ballot being cast? if ($_POST['poll_vote']) { if ($poll_user && $_POST['poll_choice']) { $vote_title = $this->quote($_POST['poll_title']); // check if they have already voted. $q1 = $pagestore->dbh->query("SELECT id " . "FROM " . $this->tblname . " " . "WHERE title='{$vote_title}' " . "AND author='{$poll_user}'"); $results = $pagestore->dbh->result($q1); if (!$results) { foreach ($_POST['poll_choice'] as $vote_choice) { $vote_choice = $this->quote($vote_choice); $query = "INSERT INTO " . $this->tblname . " " . "(title, author, choice) " . "VALUES ('{$vote_title}', '{$poll_user}', " . "'{$vote_choice}')"; $pagestore->dbh->query($query); } } } header('Location: ' . viewURL($page)); exit; } else { if ($_GET['vote_cancel']) { if ($poll_user && $_GET['poll_title']) { $vote_title = $this->quote($_GET['poll_title']); $query = "DELETE FROM " . $this->tblname . " " . "WHERE title='{$vote_title}' " . "AND author='{$poll_user}'"; $pagestore->dbh->query($query); } header('Location: ' . viewURL($page)); exit; } else { if (isset($_GET['poll_show_results'])) { $poll_show_results = $_GET['poll_show_results'] ? 1 : 0; setcookie('pollshowresults', $poll_show_results, time() + 157680000, "/", false); header('Location: ' . viewURL($page)); exit; } } } // poll type preg_match('/^((single|multiple) )?(.*)/i', $args, $matches); $poll_type = strtolower($matches[2]) == 'multiple' ? POLL_MULTIPLE : POLL_SINGLE; $args = $matches[3]; // poll title and members $ob = strpos($args, '('); if ($ob === FALSE) { $poll_title = $args; $poll_members = array(); } else { $poll_title = trim(substr($args, 0, $ob)); $poll_members = substr($args, $ob + 1); $poll_members = rtrim($poll_members, ')'); $poll_members = explode('|', $poll_members); for ($i = 0; $i < count($poll_members); $i++) { $poll_members[$i] = trim($poll_members[$i]); } } if ($poll_user) { // check if they have already voted. $query_title = addslashes($poll_title); $q1 = $pagestore->dbh->query("SELECT id " . "FROM " . $this->tblname . " " . "WHERE title='{$query_title}' " . "AND author='{$poll_user}'"); $results = $pagestore->dbh->result($q1); } else { // show results if not logged in $results = true; } if ($results) { $show_results = 1; $show_vote_widgets = 0; } else { $show_results = isset($HTTP_COOKIE_VARS['pollshowresults']) && $HTTP_COOKIE_VARS['pollshowresults'] ? 1 : 0; $show_vote_widgets = 1; } return $this->draw_poll($poll_user, $poll_type, $poll_title, $poll_members, $show_results, $show_vote_widgets); }
function template_reparent($args) { $newLocation = viewURL($args['page']); header('Location: ' . $newLocation); }
function template_common_prologue($args) { global $WikiName, $HomePage, $WikiLogo, $MetaKeywords, $MetaDescription; global $StyleScript, $SeparateTitleWords, $SeparateHeaderWords; $keywords = ' ' . html_split_name($args['headlink']); $keywords = str_replace('"', '"', $keywords); preg_match("/^(.*)\\//", $args['headlink'], $path); // Find startpath of page ob_start(); // Start buffering output. if ($SeparateTitleWords) { $args['title'] = html_split_name($args['title']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta name="KEYWORDS" content="<?php print $MetaKeywords . $keywords; ?> " /> <meta name="DESCRIPTION" content="<?php print $MetaDescription; ?> " /> <?php if ($args['norobots']) { ?> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> <?php } ?> <link rel="STYLESHEET" href="<?php print $StyleScript; ?> " type="text/css" /> <title><?php print $args['title'] . ' - ' . $WikiName; ?> </title> </head> <body> <div id="header"> <div class="logo"> <a href="<?php print viewURL($HomePage); ?> "><img src="<?php print $WikiLogo; ?> " alt="[Home]" /></a> </div> <h1> <?php print $args['heading']; if ($args['headlink'] != '') { ?> <a class="title" href="<?php print findURL($args['headlink']); ?> "> <?php if ($SeparateHeaderWords) { print html_split_name($args['headlink']); } else { print $args['headlink']; } ?> </a> <?php } print $args['headsufx']; ?> </h1> <div id="toolbar-top"> <?php if ($args['toolbar']) { if (isset($path[1])) { print html_toolbar_top($path[1]); } else { print html_toolbar_top(""); } } ?> </div> <hr /> </div> <?php }