function diff($path, $action, $title, $content) { $Head = '<meta name="robots" content="noindex, nofollow" />'; $content['PageNav']->Active("Page History"); if (is_numeric($action[1])) { $pageQuery = mysql_query("SELECT `PageID`,`AccountID`,`EditTime`,`Name`,`Description`,`Title`,`Content` FROM `Wiki_Edits` WHERE `ID`='{$action['1']}' and `Archived` = 0"); list($PageID, $AccountID, $PageEditTime, $PageName, $PageDescription, $PageTitle, $pageContent) = mysql_fetch_array($pageQuery); $previousQuery = mysql_query("Select `ID`, `Content` from `Wiki_Edits` where `ID` < '{$action['1']}' and `PageID`='{$PageID}' and `Archived` = 0 order by `ID` desc limit 1"); list($previousID, $previousContent) = mysql_fetch_array($previousQuery); $nextQuery = mysql_query("Select `ID` from `Wiki_Edits` where `ID` > '{$action['1']}' and `PageID`='{$PageID}' and `Archived` = 0 order by `ID` limit 1"); list($nextID) = mysql_fetch_array($nextQuery); if (!empty($previousID)) { $previousPath = FormatPath("/{$path}/?diff/{$previousID}"); $content['Title'] = "<a href='{$previousPath}' title='Previous Revision'>⟨</a> "; } $content['Title'] .= FishFormat($PageTitle); if (!empty($nextID)) { $nextPath = FormatPath("/{$path}/?diff/{$nextID}"); $content['Title'] .= " <a href='{$nextPath}' title='Next Revision'>⟩</a>"; } $content['Body'] .= <<<JavaScript <script> \$(document).ready(function () { \$('body').on('keydown', function(event) { event.stopImmediatePropagation() if(event.keyCode == 37) // Previous location.href = '{$previousPath}'; else if(event.keyCode == 39) // Next location.href = '{$nextPath}'; }); }); </script> JavaScript; $old = explode("\n", html_entity_decode($previousContent, ENT_QUOTES)); $new = explode("\n", html_entity_decode($pageContent, ENT_QUOTES)); // Initialize the diff class $diff = new Diff($old, $new); require_once dirname(__FILE__) . '/../libraries/Diff/Renderer/Html/SideBySide.php'; $renderer = new Diff_Renderer_Html_SideBySide(); $content['Body'] .= $diff->Render($renderer); date_default_timezone_set('America/New_York'); $PageEditTime = formatTime($PageEditTime); $content['Footer'] = "This page is an old revision made by <b><a href='/names?id={$AccountID}'>{$PageName}</a></b> on {$PageEditTime}."; if ($PageDescription) { $content['Footer'] .= "<br />'{$PageDescription}'"; } } return array($title, $content); }
function view($path, $action, $title, $content) { $content['PageNav']->Active("View Page"); $PageQuery = mysql_query("SELECT `ID`,`Title`,`Content`,`Edits`,`Views`,`EditTime` FROM `Wiki_Pages` WHERE `Path`='{$path}'"); list($PageID, $PageTitle, $PageContent, $PageEdits, $pageViews, $PageEditTime) = mysql_fetch_array($PageQuery); $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n from `Wiki_Tags` as tags,\n `Wiki_Tag_Statistics` as stats\n \n where tags.`pageID` = '{$PageID}'\n and stats.`tag` = tags.`tag`"); while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) { $plural = 's'; if ($tagCount == 1) { $plural = ''; } $tagLink = urlencode($tagName); $tagTitle = str_replace('-', ' ', $tagName); $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>"; } if ($tagLinks) { $tagLinks = implode(" | ", $tagLinks); $tagLinks = "<hr />Tags: {$tagLinks}"; } $PageTitle = PageTitler($PageTitle); if (empty($PageContent)) { $PageContent = array("Hello friend. b{Wetfish regrets to inform you this page does not exist.}", "", "Confused? This is the {{wiki|Wetfish Wiki}}, a place anyone can edit!", "It appears you've stumbled upon a place none have yet traveled.", "Would you like to be the first? {{{$path}/?edit|All it takes is a click.}}", "", "i{But please, don't wallow.}", "i{A new page surely follows.}", "i{You have the power.}"); $PageContent = implode("<br />", $PageContent); } else { mysql_query("Update `Wiki_Pages` set `Views` = `Views` + 1 where `ID`='{$PageID}'"); } if ($_SESSION['admin']) { $content['ExtraNav'] = new Navigation(); $content['ExtraNav']->Add("Archive This Page", FormatPath("/{$path}/") . "?archive"); $content['ExtraNav']->Add("Rename This Page", FormatPath("/{$path}/") . "?rename"); } $title[] = FishFormat($PageTitle, "strip"); $content['Title'] .= FishFormat($PageTitle); $content['Body'] .= FishFormat($PageContent); if ($PageEdits) { $EditCount = count(explode(",", $PageEdits)); date_default_timezone_set('America/New_York'); $PageEditTime = formatTime($PageEditTime); if ($pageViews != 1) { $viewPlural = 's'; } if ($EditCount != 1) { $Plural = "s"; } $content['Tags'] = $tagLinks; $content['Footer'] = "<b>" . number_format($pageViews) . "</b> page view{$viewPlural}. <b>{$EditCount}</b> edit{$Plural}  —  Last modified <b>{$PageEditTime}</b>."; } return array($title, $content); }
public function json($path) { $path = implode('/', $path); $result = $this->model->page->get(array('path' => $path)); $page = $result->fetch_object(); if (empty($page)) { $response = array('status' => 'error', 'code' => 404, 'message' => 'Page does not exist.'); header('Content-Type: application/json'); return json_encode($response); } else { $response = array('status' => 'success', 'code' => 200, 'path' => $page->Path, 'views' => $page->Views, 'edits' => count(explode(',', $page->Edits)), 'modified' => $page->EditTime, 'title' => array('formatted' => FishFormat($page->Title), 'source' => $page->Title), 'content' => array('formatted' => FishFormat($page->Content), 'source' => $page->Content)); header('Content-Type: application/json'); return json_encode($response); } }
function recent($path, $action, $title, $content) { // $Head = '<meta name="robots" content="noindex, nofollow" />'; $content['UserNav']->Active("Recent Activity"); if (empty($_SESSION['Recent'])) { $_SESSION['Recent']['Active'][0] = "All Edits"; $_SESSION['Recent']['Active'][3] = "Descending"; $_SESSION['Recent']['Order'] = "DESC"; } $content['ExtraNav'] = new Navigation(); $content['ExtraNav']->Add("All Edits", "?recent/all"); $content['ExtraNav']->Add("Most Recent Edit", "?recent/unique"); $content['ExtraNav']->Add("Ascending", "?recent/asc"); $content['ExtraNav']->Add("Descending", "?recent/desc"); $content['ExtraNav']->Active($_SESSION['Recent']['Active']); $Template['Title'] = "View:"; $content['ExtraNav']->Template($Template); if (empty($action[1])) { $content['Title'] = "Recent Activity"; $ActivityQuery = "SELECT {$Unique} `ID`,`PageID`,`AccountID`,`EditTime`,`Size`,`Tags`,`Name`,`Description`,`Title` FROM `Wiki_Edits` where `Archived` = 0 ORDER BY `ID` {$_SESSION['Recent']['Order']}"; list($QueryData, $Links) = Paginate($ActivityQuery, 50, $_GET['page'], $_SERVER['QUERY_STRING']); $content['Body'] .= "<center class='page-navigation'>{$Links}</center>"; $content['Body'] .= "<table width='100%' class='history'>"; $content['Body'] .= "<tr><td><b>Revision</b></td><td><b>Size</b></td><td><b>Tags</b></td><td><b>Editor</b></td><td style='min-width:200px;'><b>Title</b></td><td><b>Description</b></td></tr>"; if ($QueryData) { foreach ($QueryData as $Result) { list($EditID, $PageID, $AccountID, $PageTime, $PageSize, $pageTags, $PageName, $PageDescription, $PageTitle) = $Result; if (empty($Data[$PageID])) { $PageQuery = mysql_query("SELECT `Path` FROM `Wiki_Pages` WHERE `ID`='{$PageID}'"); list($PagePath) = mysql_fetch_array($PageQuery); $Data[$PageID] = $PagePath; } else { $PagePath = $Data[$PageID]; } $Toggle++; date_default_timezone_set('America/New_York'); $minWidth = recentTime($PageTime) ? 85 : 175; $PageTime = formatTime($PageTime); if ($Toggle % 2 == 1) { $Class = "class='toggle'"; } else { $Class = ''; } $PageName = FishFormat($PageName, "format"); $PageDescription = FishFormat($PageDescription, "format"); $PageTitle = FishFormat($PageTitle, "format"); $DiffURL = str_replace("//", "/", "/{$PagePath}/?diff/{$EditID}"); $content['Body'] .= "<tr {$Class}><td style='min-width:{$minWidth}px;'>{$PageTime}</td><td>{$PageSize}</td><td>{$pageTags}</td><td><b><a href='/edits?name={$PageName}'>{$PageName}</a></b></td><td style='max-width:400px'><span style='float:right;'><a href='{$DiffURL}' rel='nofollow'>d</a></span><b><a href='/{$PagePath}'>{$PageTitle}</a></b></td><td class='multi-line'>{$PageDescription}</td></tr>"; } } $content['Body'] .= "</table>"; $content['Body'] .= "<center class='page-navigation bottom'>{$Links}</center>"; } elseif ($action[1] == "page") { } else { switch ($action[1]) { case "all": $_SESSION['Recent']['Active'][0] = "All Edits"; $_SESSION['Recent']['Active'][1] = ""; $_SESSION['Recent']['View'] = ""; break; case "unique": $_SESSION['Recent']['Active'][0] = ""; $_SESSION['Recent']['Active'][1] = "Most Recent Edit"; $_SESSION['Recent']['View'] = "DISTINCT"; break; case "asc": $_SESSION['Recent']['Active'][2] = "Ascending"; $_SESSION['Recent']['Active'][3] = ""; $_SESSION['Recent']['Order'] = ""; break; case "desc": $_SESSION['Recent']['Active'][2] = ""; $_SESSION['Recent']['Active'][3] = "Descending"; $_SESSION['Recent']['Order'] = "DESC"; break; } $content['Body'] = "<b>Settings changed...</b> <meta http-equiv='refresh' content='2;url=" . FormatPath("/{$path}/?recent") . "'>"; } return array($title, $content); }
echo "<table width='100%'>"; echo "<tr><td style='min-width:175px;'><b>Revision</b></td><td><b>Size</b></td><td><b>Editor</b></td><td style='min-width:200px;'><b>Title</b></td><td><b>Description</b></td></tr>"; foreach ($QueryData as $Result) { list($EditID, $PageID, $AccountID, $PageTime, $PageSize, $PageName, $PageDescription, $PageTitle) = $Result; if (empty($Data[$PageID])) { $PageQuery = mysql_query("SELECT `Path` FROM `Wiki_Pages` WHERE `ID`='{$PageID}'"); list($PagePath) = mysql_fetch_array($PageQuery); $Data[$PageID] = $PagePath; } else { $PagePath = $Data[$PageID]; } $Toggle++; date_default_timezone_set('America/New_York'); $PageTime = date("F j\\, Y G:i:s", $PageTime) . " EST"; if ($Toggle % 2 == 1) { $Class = "class='toggle'"; } else { $Class = ''; } $PageName = FishFormat($PageName, "format"); $PageDescription = FishFormat($PageDescription, "format"); $PageTitle = FishFormat($PageTitle, "format"); $DiffURL = str_replace("//", "/", "/{$PagePath}/?diff/{$EditID}"); echo "<tr {$Class}><td>{$PageTime}</td><td>{$PageSize}</td><td><b><a href='/names?id={$AccountID}'>{$PageName}</a></b></td><td><b><a href='/{$PagePath}'>{$PageTitle}</a></b><span style='float:right;'><a href='{$DiffURL}'>d</a></span></td><td>{$PageDescription}</td></tr>"; } echo "</table>"; echo "<hr /><center>{$Links}</center>"; } else { echo "<hr /><b>Nothing found, sorry.</b>"; } }
function random($path, $action, $title, $content) { if ($path) { $PageQuery = mysql_query("SELECT `ID`,`Title`,`Content`,`Edits`,`Views`,`EditTime` FROM `Wiki_Pages` WHERE `Path` = '{$path}'"); list($PageID, $PageTitle, $PageContent, $PageEdits, $pageViews, $PageEditTime) = mysql_fetch_array($PageQuery); $pagePrevious = RandomRow('Wiki_Pages', 'ID'); $pageNext = RandomRow('Wiki_Pages', 'ID'); if ($pagePrevious) { $previous = $pagePrevious; } if ($pageNext) { $next = $pageNext; } $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n from `Wiki_Tags` as tags,\n `Wiki_Tag_Statistics` as stats\n \n where tags.`pageID` = '{$PageID}'\n and stats.`tag` = tags.`tag`"); while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) { $plural = 's'; if ($tagCount == 1) { $plural = ''; } $tagLink = urlencode($tagName); $tagTitle = str_replace('-', ' ', $tagName); $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>"; } $tagLinks = implode(" | ", $tagLinks); if ($tagLinks) { $tagLinks = "<hr />Tags: {$tagLinks}"; } $PageTitle = PageTitler($PageTitle); if (empty($PageContent)) { $PageContent = array("Hello friend. b{Wetfish regrets to inform you this page does not exist.}", "", "Confused? This is the {{wiki|Wetfish Wiki}}, a place anyone can edit!", "It appears you've stumbled upon a place none have yet traveled.", "Would you like to be the first? {{{$path}/?edit|All it takes is a click.}}", "", "i{But please, don't wallow.}", "i{A new page surely follows.}", "i{You have the power.}"); $PageContent = implode("<br />", $PageContent); } else { mysql_query("Update `Wiki_Pages` set `Views` = `Views` + 1 where `ID`='{$PageID}'"); } if ($previous['Path']) { $previous['Path'] = "/{$previous['Path']}/?random"; } else { $previous['Path'] = "/?random"; } if ($next['Path']) { $next['Path'] = "/{$next['Path']}/?random"; } else { $next['Path'] = "/?random"; } if ($_SESSION['admin']) { $content['ExtraNav'] = new Navigation(); $content['ExtraNav']->Add("Archive This Page", FormatPath("/{$path}/") . "?archive"); $content['ExtraNav']->Add("Rename This Page", FormatPath("/{$path}/") . "?rename"); } $title[] = FishFormat($PageTitle, "strip"); $content['Title'] .= "<a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>⇜</a> " . FishFormat($PageTitle) . " <a href='{$next['Path']}' title='Next - {$next['Title']}'>⇝</a>"; $content['Body'] .= FishFormat($PageContent); $content['Tags'] = $tagLinks; $content['Body'] .= <<<JavaScript <script> \$(document).ready(function () { \$('body').on('keydown', function(event) { event.stopImmediatePropagation() if(event.keyCode == 37) // Previous history.back(); else if(event.keyCode == 39) // Next location.href = '{$next['Path']}'; //\t\t\tconsole.log(event); }); }); </script> JavaScript; if ($PageEdits) { $EditCount = count(explode(",", $PageEdits)); date_default_timezone_set('America/New_York'); $PageEditTime = formatTime($PageEditTime); if ($pageViews != 1) { $viewPlural = 's'; } if ($EditCount != 1) { $Plural = "s"; } $content['Tags'] = $tagLinks; $content['Footer'] = "<b>" . number_format($pageViews) . "</b> page view{$viewPlural}. <b>{$EditCount}</b> edit{$Plural}  —  Last modified <b>{$PageEditTime}</b>."; // $content['Footer'] = "This page has been edited <b>$EditCount</b> time{$Plural}, and was last edited on $PageEditTime."; } } else { $Head = '<meta name="robots" content="noindex, nofollow" />'; $Random = RandomRow('Wiki_Pages', 'ID'); $ID = uuid(); $randomTitles = array('Wormhole open: ', 'An adventure!', 'Welcome to', 'Internet Space Award', 'Friendship served', 'WOW!'); $randomPhrases = array('Hold on to your hat!', 'Hold on to your butt!!', 'I love butts', 'Wet, fish', 'I LOVE ANIME!!!!!!!!', 'COOL!'); shuffle($randomTitles); shuffle($randomPhrases); header("Location: /{$Random['Path']}/?random"); exit; } return array($title, $content); }
function tag($path, $action, $title, $content) { $action = implode('/', $action); $action = explode('/', $action, 3); $tag = Clean($action[1]); $cleanTag = ucwords(str_replace('-', ' ', $tag)); if (isset($action[2])) { $path = $action[2]; } $totalQuery = mysql_query("Select stats.`count`\n\t\t\t\t\t\t\t\tfrom `Wiki_Tag_Statistics` as stats\n\t\t\t\t\t\t\t\twhere stats.`tag` = '{$tag}'"); $nextQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID`\n\t\t\t\t\t\t\t\t\torder by tag.`tagID` desc limit 1"); $previousQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID`\n\t\t\t\t\t\t\t\t\torder by tag.`tagID` limit 1"); list($tagTotal) = mysql_fetch_array($totalQuery); $next = mysql_fetch_array($nextQuery); $previous = mysql_fetch_array($previousQuery); if ($path or isset($action[2])) { $PageQuery = mysql_query("SELECT `ID`,`Title`,`Content`,`Edits`,`Views`,`EditTime`,tag.`tagID` FROM `Wiki_Pages`, `Wiki_Tags` as tag WHERE `Path` like '{$path}' and tag.`tag` = '{$tag}' and tag.`pageID` = `ID`"); list($PageID, $PageTitle, $PageContent, $PageEdits, $pageViews, $PageEditTime, $tagID) = mysql_fetch_array($PageQuery); $previousQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID` and tag.`tagID` >'{$tagID}'\n\t\t\t\t\t\t\t\t\t\t\torder by tag.`tagID` limit 1"); $nextQuery = mysql_query("Select `Path`, `Title`\n\t\t\t\t\t\t\t\t\tfrom `Wiki_Pages`,\n\t\t\t\t\t\t\t\t\t\t`Wiki_Tags` as tag\n\t\t\t\t\t\t\t\t\twhere tag.`tag` = '{$tag}' and tag.`pageID` = `ID` and tag.`tagID` < '{$tagID}'\n\t\t\t\t\t\t\t\t\t\torder by tag.`tagID` desc limit 1"); $pagePrevious = mysql_fetch_array($previousQuery); $pageNext = mysql_fetch_array($nextQuery); if ($pagePrevious) { $previous = $pagePrevious; } if ($pageNext) { $next = $pageNext; } $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n\t\t\t\t\t\t\t\t\tfrom `Wiki_Tags` as tags,\n\t\t\t\t\t\t\t\t\t\t `Wiki_Tag_Statistics` as stats\n\t\t\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\twhere tags.`pageID` = '{$PageID}'\n\t\t\t\t\t\t\t\t\t\tand stats.`tag` = tags.`tag`"); while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) { $plural = 's'; if ($tagCount == 1) { $plural = ''; } $tagLink = urlencode($tagName); $tagTitle = str_replace('-', ' ', $tagName); $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>"; } $tagLinks = implode(" | ", $tagLinks); if ($tagLinks) { $tagLinks = "<hr />Tags: {$tagLinks}"; } $PageTitle = PageTitler($PageTitle); if (empty($PageContent)) { $PageContent = array("Hello friend. b{Wetfish regrets to inform you this page does not exist.}", "", "Confused? This is the {{wiki|Wetfish Wiki}}, a place anyone can edit!", "It appears you've stumbled upon a place none have yet traveled.", "Would you like to be the first? {{{$path}/?edit|All it takes is a click.}}", "", "i{But please, don't wallow.}", "i{A new page surely follows.}", "i{You have the power.}"); $PageContent = implode("<br />", $PageContent); } else { mysql_query("Update `Wiki_Pages` set `Views` = `Views` + 1 where `ID`='{$PageID}'"); } if ($_SESSION['admin']) { $content['ExtraNav'] = new Navigation(); $content['ExtraNav']->Add("Archive This Page", FormatPath("/{$path}/") . "?archive"); $content['ExtraNav']->Add("Rename This Page", FormatPath("/{$path}/") . "?rename"); } if ($previous['Path']) { $previous['Path'] = "/{$previous['Path']}/?tag/{$tag}"; } else { $previous['Path'] = "/?tag/{$tag}/"; } if ($next['Path']) { $next['Path'] = "/{$next['Path']}/?tag/{$tag}"; } else { $next['Path'] = "/?tag/{$tag}/"; } $title[] = FishFormat($PageTitle, "strip"); $content['Title'] .= "<a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>⟨</a> " . FishFormat($PageTitle) . " <a href='{$next['Path']}' title='Next - {$next['Title']}'>⟩</a>"; $content['Body'] .= FishFormat($PageContent); $content['Tags'] = $tagLinks; } else { mysql_query("Update `Wiki_Tag_Statistics` set `views` = `views` + 1\n\t\t\t\t\t\twhere `tag` = '{$tag}'"); if ($previous['Path']) { $previous['Path'] = "/{$previous['Path']}/?tag/{$tag}"; } else { $previous['Path'] = "/?tag/{$tag}/"; } if ($next['Path']) { $next['Path'] = "/{$next['Path']}/?tag/{$tag}"; } else { $next['Path'] = "/?tag/{$tag}/"; } $content['Title'] = "Pages tagged: <a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>⟨</a> {$cleanTag} <a href='{$next['Path']}' title='Next - {$next['Title']}'>⟩</a>"; $pageQuery = "SELECT `ID`,`Path`,`Title`,`Content`,`Edits`, `EditTime`\n\t\t\t\t\t\tFROM `Wiki_Pages`,\n\t\t\t\t\t\t\t `Wiki_Tags` as tag\n\t\t\t\t\t\tWHERE tag.`tag` = '{$tag}' and tag.`pageID` = `ID`\n\t\t\t\t\t\torder by tag.`tagID` desc"; list($Data, $Links) = Paginate($pageQuery, 50, $_GET['page'], $_SERVER['QUERY_STRING']); if ($Data) { $content['Body'] .= "<center class='page-navigation'>{$Links}</center>"; foreach ($Data as $Result) { list($pageID, $pagePath, $pageTitle, $pageContent) = $Result; $tagQuery = mysql_query("Select tags.`tag`, stats.`count`\n\t\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Tags` as tags,\n\t\t\t\t\t\t\t\t\t\t\t\t `Wiki_Tag_Statistics` as stats\n\t\t\t\t\t\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t\t\t\t\twhere tags.`pageID` = '{$pageID}'\n\t\t\t\t\t\t\t\t\t\t\t\tand stats.`tag` = tags.`tag`"); $tagLinks = array(); while (list($tagName, $tagCount) = mysql_fetch_array($tagQuery)) { $plural = 's'; if ($tagCount == 1) { $plural = ''; } $tagLink = urlencode($tagName); $tagTitle = str_replace('-', ' ', $tagName); $tagLinks[] = "<a href='/?tag/{$tagLink}' title='{$tagCount} tagged page{$plural}'>{$tagTitle}</a>"; } $tagLinks = implode(" | ", $tagLinks); if ($Count % 4 == 1 or $Count % 4 == 2) { $class = 'toggle'; } else { $class = ''; } if ($Count % 2 == 0) { $content['Body'] .= "<div class='clear'></div>"; } $content['Body'] .= "<div class='{$class}' style='float:left; width:50%'><div style='padding:16px'>"; $content['Body'] .= "<a href='/{$pagePath}/?tag/{$tag}' style='font-weight:bold'>{$pageTitle}</a><br />"; $content['Body'] .= "Tags: {$tagLinks}"; $content['Body'] .= "</div></div>"; $Count++; } $content['Body'] .= "<div class='clear'></div>"; $content['Body'] .= "<center class='page-navigation bottom'>{$Links}</center>"; } if (empty($Count)) { $content['Body'] .= "<br /><b>Sorry friend, it appears the tag you're looking for doesn't exist.</b>"; } } if ($tagTotal == 1) { $footerPlural = ''; } else { $footerPlural = 's'; } /* if($previous['Path']) $previous['Path'] = "/{$previous['Path']}/?tag/$tag"; else $previous['Path'] = "/?tag/$tag/"; if($next['Path']) $next['Path'] = "/{$next['Path']}/?tag/$tag"; else $next['Path'] = "/?tag/$tag/"; */ $content['Body'] .= <<<JavaScript \t \t<script> \t\t\$(document).ready(function () \t\t{ \t\t\t\$('body').on('keydown', function(event) \t\t\t{ \t\t\t\t// what? \t\t\t\tevent.stopImmediatePropagation() \t\t\t\t \t\t\t\tif(event.keyCode == 37) // Previous \t\t\t\t\tlocation.href = '{$previous['Path']}'; \t\t\t\telse if(event.keyCode == 39) // Next \t\t\t\t\tlocation.href = '{$next['Path']}'; \t\t\t\t\t \t//\t\t\tconsole.log(event); \t\t\t}); \t\t}); \t</script> \t JavaScript; $content['Footer'] = " <a href='{$previous['Path']}' title='Previous - {$previous['Title']}'>Previous</a>   You are browsing <b><a href='/?tag/{$tag}'>{$cleanTag}</a></b>, this tag appears on <b>{$tagTotal}</b> page{$footerPlural}.   <a href='{$next['Path']}' title='Next - {$next['Title']}'>Next</a>"; return array($title, $content); }
function history($path, $action, $title, $content) { $Head = '<meta name="robots" content="noindex, nofollow" />'; $content['PageNav']->Active("Page History"); $pageQuery = mysql_query("Select `ID` from `Wiki_Pages` where `Path`='{$path}'"); list($pageID) = mysql_fetch_array($pageQuery); $totalQuery = mysql_query("Select `ID`\n\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `Archived` = 0"); $nextQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `Archived` = 0\n\t\t\t\t\t\t\t\torder by `ID` desc limit 1"); $previousQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `Archived` = 0\n\t\t\t\t\t\t\t\torder by `ID` limit 1"); $totalEdits = mysql_num_rows($totalQuery); $next = mysql_fetch_array($nextQuery); $previous = mysql_fetch_array($previousQuery); if (is_numeric($action[1])) { $PreviousQuery = mysql_query("Select `Content` from `Wiki_Edits` where `ID` < '{$action['1']}' and `Archived` = 0 order by `ID` desc limit 1"); list($PreviousContent) = mysql_fetch_array($PreviousQuery); $PageQuery = mysql_query("SELECT `AccountID`,`EditTime`,`Name`,`Description`,`Title`,`Content` FROM `Wiki_Edits` WHERE `ID`='{$action['1']}' and `Archived` = 0"); list($AccountID, $PageEditTime, $PageName, $PageDescription, $PageTitle, $PageContent) = mysql_fetch_array($PageQuery); $previousQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `ID` > '{$action['1']}' and `Archived` = 0\n\t\t\t\t\t\t\t\t\t\t\torder by `ID` limit 1"); $nextQuery = mysql_query("Select `ID`, `Title`\n\t\t\t\t\t\t\t\t\t\tfrom `Wiki_Edits`\n\t\t\t\t\t\t\t\t\t\twhere `PageID` = '{$pageID}' and `ID` < '{$action['1']}' and `Archived` = 0\n\t\t\t\t\t\t\t\t\t\t\torder by `ID` desc limit 1"); $pagePrevious = mysql_fetch_array($previousQuery); $pageNext = mysql_fetch_array($nextQuery); if ($pagePrevious) { $previous = $pagePrevious; } if ($pageNext) { $next = $pageNext; } $content['ExtraNav'] = new Navigation(); $content['ExtraNav']->Add("View Source", FormatPath("/{$path}/") . "?source/{$action['1']}"); $content['ExtraNav']->Add("View Difference", FormatPath("/{$path}/") . "?diff/{$action['1']}"); if ($_SESSION['Verified'] == 1) { $content['ExtraNav']->Add("Revert Page", FormatPath("/{$path}/") . "?revert/{$action['1']}"); } if ($_SESSION['admin']) { $content['ExtraNav']->Add("Archive This Edit", FormatPath("/{$path}/") . "?archive/{$action['1']}"); } $title[] = FishFormat($PageTitle, "strip"); $PageContent = FishFormat($PageContent); $previousPath = FormatPath("/{$path}/?history/{$previous['ID']}"); $nextPath = FormatPath("/{$path}/?history/{$next['ID']}"); $content['Title'] .= "<a href='{$previousPath}' title='Previous - {$previous['Title']}'>⟨</a> " . FishFormat($PageTitle) . " <a href='{$nextPath}' title='Next - {$next['Title']}'>⟩</a>"; $content['Body'] .= $PageContent; date_default_timezone_set('America/New_York'); // $PageEditTime = date("F j\, Y G:i:s", $PageEditTime)." EST"; $PageEditTime = formatTime($PageEditTime); $content['Footer'] = "This page is an old revision made by <b><a href='/names?id={$AccountID}'>{$PageName}</a></b> on {$PageEditTime}."; if ($PageDescription) { $content['Footer'] .= "<br />'{$PageDescription}'"; } } else { $previousPath = FormatPath("/{$path}/?history/{$previous['ID']}"); $nextPath = FormatPath("/{$path}/?history/{$next['ID']}"); $content['Title'] = "<a href='{$previousPath}' title='Previous - {$previous['Title']}'>⟨</a> Page History <a href='{$nextPath}' title='Next - {$next['Title']}'>⟩</a>"; $PageQuery = mysql_query("SELECT `ID` FROM `Wiki_Pages` WHERE `Path`='{$path}'"); list($PageID) = mysql_fetch_array($PageQuery); $HistoryQuery = "SELECT `ID`,`AccountID`,`EditTime`,`Size`,`Tags`,`Name`,`Description`,`Title` FROM `Wiki_Edits` WHERE `PageID`='{$PageID}' and `Archived` = 0 ORDER BY `ID` DESC"; $request = parse_url($_SERVER['REQUEST_URI']); list($Data, $Links) = Paginate($HistoryQuery, 50, $_GET['page'], $request['query']); if ($_SESSION['admin']) { $content['ExtraNav'] = new Navigation(); $content['ExtraNav']->Add("Archive All Edits", FormatPath("/{$path}/") . "?archive"); } $content['Body'] .= "<hr /><center>{$Links}</center><hr />"; $content['Body'] .= "<table width='100%' class='history'>"; $content['Body'] .= "<tr><td><b>Revision</b></td><td><b>Size</b></td><td><b>Tags</b></td><td><b>Editor</b></td><td><b>Title</b></td><td><b>Description</b></td></tr>"; foreach ($Data as $Result) { list($HistoryID, $AccountID, $HistoryTime, $HistorySize, $historyTags, $HistoryName, $HistoryDescription, $HistoryTitle) = $Result; $Toggle++; date_default_timezone_set('America/New_York'); $minWidth = recentTime($HistoryTime) ? 85 : 175; $HistoryTime = formatTime($HistoryTime); if ($Toggle % 2 == 1) { $Class = "class='toggle'"; } else { $Class = ''; } $HistoryName = FishFormat($HistoryName, "format"); $HistoryDescription = FishFormat($HistoryDescription, "format"); $HistoryTitle = FishFormat($HistoryTitle, "format"); $HistoryURL = str_replace("//", "/", "/{$path}/?history/{$HistoryID}"); $DiffURL = str_replace("//", "/", "/{$path}/?diff/{$HistoryID}"); $content['Body'] .= "<tr {$Class}><td style='min-width:{$minWidth};'>{$HistoryTime}</td><td>{$HistorySize}</td><td>{$historyTags}</td><td><b><a href='/edits?name={$HistoryName}'>{$HistoryName}</a></b></td><td style='max-width:400px;'><span style='float:right;'><a href='{$DiffURL}' rel='nofollow'>d</a></span><b><a href='{$HistoryURL}' rel='nofollow'>{$HistoryTitle}</a></b></td><td>{$HistoryDescription}</td></tr>"; } $content['Body'] .= "</table>"; $content['Body'] .= "<hr /><center>{$Links}</center>"; } $content['Body'] .= <<<JavaScript \t \t<script> \t\t\$(document).ready(function () \t\t{ \t\t\t\$('body').on('keydown', function(event) \t\t\t{ \t\t\t\tevent.stopImmediatePropagation() \t\t\t\t \t\t\t\tif(event.keyCode == 37) // Previous \t\t\t\t\tlocation.href = '{$previousPath}'; \t\t\t\telse if(event.keyCode == 39) // Next \t\t\t\t\tlocation.href = '{$nextPath}'; \t\t\t\t\t \t//\t\t\tconsole.log(event); \t\t\t}); \t\t}); \t</script> \t JavaScript; return array($title, $content); }
$Form['Content']['Text'] = "Content:"; $Form['Content']['Form'] = "id:Editbox; name:Content; value:x{" . $PageContent . "}x; type:textarea;"; $Form['Content']['Style'] = "width:100%; height:400px"; $Form['Description']['Text'] = "Description:"; $Form['Description']['Form'] = "name:Description; value:x{" . $Description . "}x; size: 80; maxlength:255;"; $Form['Description']['SubText'] = "Optional; to let other editors know why you made this edit."; $Form['tags']['Text'] = "Tags:"; $Form['tags']['Form'] = "name:tags; value:x{" . $tagText . "}x; size: 80; maxlength:255;"; $Form['tags']['SubText'] = "Optional; used for grouping similar pages. Separate tags by commas."; if (!$_SESSION['bypass']) { $Form['Captcha']['Form'] = "type:plaintext; value:" . recaptcha_get_html(RECAPTCHA_PUBLIC, null, 1); } $Form['Submit']['Form'] = "type:plaintext; value:{<input type='submit' value='Submit' /> <input type='button' value='Preview' onClick='SelectAction(\"preview\")' />};"; if ($Action[0] == "preview") { $Content['Title'] = 'Preview: ' . FishFormat($PageTitle); $Content['Body'] .= FishFormat($PageContent) . "<div style='clear:both'></div><hr />"; } $Content['Body'] .= Format($Form, Form); } if ($PageEdits) { $EditCount = count(explode(",", $PageEdits)); date_default_timezone_set('America/New_York'); $PageEditTime = formatTime($PageEditTime); if ($pageViews != 1) { $viewPlural = 's'; } if ($EditCount != 1) { $Plural = "s"; } $Content['Footer'] = "<b>" . number_format($pageViews) . "</b> page view{$viewPlural}. <b>{$EditCount}</b> edit{$Plural}. — Last modified <b>{$PageEditTime}</b>."; }
</td> <td><?php echo $result['editCount']; ?> </td> <td><?php echo $result['Views']; ?> </td> <td><?php echo $result['tagCount']; ?> </td> <td style='max-width:400px;'><b><a href='/<?php echo $result['Path']; ?> ' rel='nofollow'><?php echo FishFormat($result['Title'], "strip"); ?> </a></b></td> </tr> <?php } ?> </table> <?php echo "<center class='page-navigation bottom'>{$navigation}</center>"; } else { echo "<b>Oops!!</b>"; }