示例#1
0
文件: recent.php 项目: kelsh/classic
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);
}
示例#2
0
文件: history.php 项目: kelsh/classic
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);
}