Example #1
0
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} &ensp;&mdash;&ensp; Last modified <b>{$PageEditTime}</b>.";
    }
    return array($title, $content);
}
Example #2
0
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> &emsp; You are browsing <b><a href='/?tag/{$tag}'>{$cleanTag}</a></b>, this tag appears on <b>{$tagTotal}</b> page{$footerPlural}. &emsp; <a href='{$next['Path']}' title='Next - {$next['Title']}'>Next</a>";
    return array($title, $content);
}
Example #3
0
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']}'>&#8668;</a> " . FishFormat($PageTitle) . " <a href='{$next['Path']}' title='Next - {$next['Title']}'>&#8669;</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} &ensp;&mdash;&ensp; 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);
}
Example #4
0
                } else {
                    $UserEdits[] = $EditID;
                }
                $UserEdits = implode(",", $UserEdits);
                mysql_query("UPDATE `Wiki_Pages` SET `Edits`='{$PageEdits}',`EditTime`='{$Time}' WHERE `ID`='{$PageID}'");
                $SQLError .= mysql_error();
                mysql_query("UPDATE `Wiki_Accounts` SET `EditTime`='{$Time}' WHERE `ID`='{$_SESSION['ID']}'");
                $SQLError .= mysql_error();
                if ($SQLError) {
                    $Content['Body'] .= "Holy SHIT there was a MySQL error.";
                } else {
                    $Content['Body'] .= "Page updated... <meta http-equiv='refresh' content='2;url=/{$Path}'>";
                }
            }
        }
        $PageTitle = PageTitler($PageTitle);
        $Content['Title'] .= 'Editing: ' . FishFormat($PageTitle);
        if (!empty($Form['_Errors']) || empty($_POST) || $Action[0] == "preview") {
            $Content['Body'] .= <<<SuperNav
<script>
\t\$(document).ready(function ()
\t{
\t\t
\t\tWindow(\t"<span class='medium'>Super Edit 3.2 !!!</span><hr />"+
\t\t\t\t"<table><tr><td>"+
\t\t\t\t"<a href='javascript:Wiki(\\"Bold\\")'>Bold</a> &emsp; <a href='javascript:Wiki(\\"Italics\\")'>Italics</a> &emsp; <a href='javascript:Wiki(\\"Underline\\")'>Underline</a> &emsp; <a href='javascript:Wiki(\\"Strike\\")'>Strike</a><br />"+
\t\t\t\t"<a href='javascript:Wiki(\\"Big\\")'>Big</a> &emsp; <a href='javascript:Wiki(\\"Medium\\")'>Medium</a> &emsp; <a href='javascript:Wiki(\\"Small\\")'>Small</a> &emsp; <a href='javascript:Wiki(\\"Rainbow\\")'>Rainbow</a>"+
\t\t\t\t"</td><td>&emsp;</td><td>"+
\t\t\t\t"<a href='javascript:Wiki(\\"Internal\\")'>Internal Link</a> &emsp; <a href='javascript:Wiki(\\"External\\")'>External Link</a><br />"+
\t\t\t\t"<a href='javascript:Wiki(\\"Image\\")'>Image</a> &emsp; <a href='javascript:Wiki(\\"Video\\")'>Video</a> &emsp; <a href='javascript:Wiki(\\"Music\\")'>Music</a>"+
\t\t\t\t"</td></tr></table>");