Example #1
0
 function __construct()
 {
     parent::__construct(Config::getCfg('site')['pagetitle'], "", 0);
     $boards = Model::get()->getBoards();
     $archiveBoards = array_filter($boards, function ($b) {
         return $b->isArchive();
     });
     $plainBoards = array_filter($boards, function ($b) {
         return !$b->isArchive();
     });
     $html = "<div class='boardlist_big'><h1>Archived Boards</h1><hr style='width:64px;'>";
     foreach ($archiveBoards as $b) {
         $html .= Site::parseHtmlFragment("indexArchiveBoard.html", ["%ago%", "%crawltime%", "%shortname%", "%longname%", "%posts%", "%threads%", "%firstcrawl%"], [ago(time() - $b->getLastCrawl()), $b->getLastCrawl(), $b->getName(), $b->getLongName(), $b->getNoPosts(), $b->getNoThreads(), date("j F Y", $b->getFirstCrawl())]);
     }
     $html .= "</div>";
     $html .= "<script type='text/javascript' src='/script/boardUpdate.js'></script>";
     if (count($plainBoards) > 0) {
         $html .= "<div class='boardlist_big'><h1>Boards</h1><hr style='width:64px;'>";
         foreach ($plainBoards as $b) {
             $html .= Site::parseHtmlFragment("indexBoard.html", ["%ago%", "%crawltime%", "%shortname%", "%longname%", "%posts%", "%threads%", "%firstcrawl%"], [ago(time() - $b->getLastCrawl()), $b->getLastCrawl(), $b->getName(), $b->getLongName(), $b->getNoPosts(), $b->getNoThreads(), date("j F Y", $b->getFirstCrawl())]);
         }
         $html .= "</div>";
     }
     $this->setBody($html);
 }
Example #2
0
 function __construct($message = "")
 {
     parent::__construct("404 ;_;", "", 0);
     $this->setBody("<h1>404 ;_;</h1><div class='centertext' style='font-size:1.5em;'>{$message}</div><br><br>");
     $this->appendToBody("<p style='text-align:center;'><img src='/image/404.png' alt='file not found' /></p>");
     header("HTTP/1.0 404 Not Found");
 }
Example #3
0
 public function __construct()
 {
     parent::__construct("Report Queue", el('h2', "Reports"), Config::getCfg('permissions')['delete']);
     $reports = Model::get()->getReports();
     $html = "<table class='reportTable'><tr><th colspan='3'>Report Queue</th></tr><tr><th style='width:3em;'>Times</th><th>Post</th><th style='width:20em;'>Options</th></tr>";
     foreach ($reports as $report) {
         $hash = bin2hex($report['md5']);
         $html .= "<tr id='report{$report['no']}'>";
         $html .= "<td>" . $report['count'] . "</td>";
         $html .= "<td><a href='{$report['threadid']}#p{$report['no']}' data-board='{$report['board']}' data-thread='{$report['threadid']}' data-post='{$report['no']}' class='quotelink noEmbed'>&gt;&gt;{$report['no']}</a></td>";
         $html .= "<td><a class='button' href='javascript:deletePost({$report['no']},\"{$report['board']}\");' >Delete&nbsp;Post</a>&nbsp;";
         $html .= "<a class='button' href='javascript:banImage(\"{$hash}\");' id='ban{$hash}'>Ban&nbsp;Image</a>&nbsp;";
         $html .= "<a class='button' href='javascript:deleteReport({$report['no']},\"{$report['board']}\");'>Delete&nbsp;Report</a>&nbsp;";
         $html .= "<a class='button' href='javascript:banReporter({$report['no']},\"{$report['board']}\");'>Ban&nbsp;Reporter</a></td>";
         $html .= "</tr>";
     }
     $html .= "</table>";
     if (Site::getUser()->getPrivilege() >= Config::getCfg('permissions')['owner']) {
         $html .= "<br><table class='reportTable'><tr><th colspan='3'>Last Few Deleted Posts</th></tr><tr><th style='width:3em;'>Board</th><th>Post</th><th style='width:7em;'>Options</th></tr>";
         foreach (Model::get()->getBoards() as $board) {
             $lastFew = OldModel::getLastNDeletedPosts($board->getName(), 5);
             foreach ($lastFew as $report) {
                 $html .= "<tr id='report{$report['no']}'>";
                 $html .= "<td>" . $board->getName() . "</td>";
                 $html .= "<td>&gt;&gt;{$report['no']} ({$report['name']}{$report['trip']})</td>";
                 $html .= "<td><a class='button' href='javascript:restorePost({$report['no']},\"{$board->getName()}\");' >Restore&nbsp;Post</a></td>";
                 $html .= "</tr>";
             }
         }
         $html .= "</table>";
     }
     $this->appendToBody($html);
 }
Example #4
0
 public function __construct(Board $board)
 {
     parent::__construct("/{$board->getName()}/ - {$board->getLongName()}", "", $board->getPrivilege());
     $boardBanner = div("", "boardBanner centertext")->append(div("/{$board->getName()}/ - {$board->getLongName()}", "boardTitle"));
     if ($board->isArchive()) {
         $boardBanner->append(a("View this board on 4chan", '//boards.4chan.org/' . $board->getName()));
     }
     $this->appendToBody("<hr>" . $boardBanner . "<hr>");
     $this->board = $board;
 }
Example #5
0
 function __construct()
 {
     parent::__construct("b-stats news", "", 0);
     $this->appendToBody("<h2>News</h2>");
     $articles = Model::get()->getAllNewsArticles();
     foreach ($articles as $article) {
         $date = date("Y-m-d g:i a", $article['time']);
         $content = nl2br($article['content']);
         $this->appendToBody(Site::parseHtmlFragment("article.html", ['_author_', '_id_', '_title_', '_content_', '_date_'], [$article['username'], $article['article_id'], $article['title'], $content, $date]));
     }
 }
Example #6
0
 public function __construct()
 {
     parent::__construct("Dashboard", "", 1);
     if (isset($_GET['success'])) {
         $error = "<br>Successfully changed.";
     } else {
         if (isset($_GET['failure'])) {
             $error = "<br>Password change unsuccessful.";
         } else {
             $error = "";
         }
     }
     $user = Site::getUser();
     $this->appendToBody(Site::parseHtmlFragment("dashboard.html", ['<!-- username -->', '<!-- privilege -->', '<!-- theme -->', '<!-- error -->'], [$user->getUsername(), $user->getPrivilege(), $user->getTheme(), $error]));
 }
Example #7
0
 public function __construct()
 {
     parent::__construct("Apply for Access", "", 0);
     $db = Config::getMysqliConnectionRW();
     $err = '';
     if (isset($_POST['username'])) {
         if (post('captcha') == $_SESSION['captcha']) {
             $username = $db->real_escape_string(post('username'));
             $password = md5(post('password'));
             $email = $db->real_escape_string(post('email'));
             $reason = $db->real_escape_string(post('why'));
             $ip = Site::ip();
             $db->query("INSERT INTO `request` (`ip`,`username`,`password`,`email`,`reason`,`time`) VALUES ('{$ip}','{$username}',UNHEX('{$password}'),'{$email}','{$reason}',UNIX_TIMESTAMP())");
             header('Location: /');
             exit;
         } else {
             $err = 'Invalid captcha.';
         }
     }
     $q = $db->query("SELECT * FROM `request` WHERE `ip`='" . Site::ip() . "'");
     if ($q->num_rows === 0) {
         $_SESSION['captcha'] = rand(100000, 999999);
         if ($err != '') {
             $this->appendToBody("<p class='center'>{$err}</p>");
         }
         $this->appendToBody(Site::parseHtmlFragment('reqForm.html', ['__captcha__'], ['<img src="/captcha" alt="captcha">']));
     } else {
         $r = $q->fetch_assoc();
         if ($r['accepted'] == 0) {
             $this->appendToBody("<h2>Hold Your Horses</h2><p class='center'>You have successfully applied. Check this page or your email for your status.</p>");
         } else {
             if ($r['accepted'] == -1) {
                 $this->appendToBody("<h2>Oh noes ;_;</h2><p class='center'>Sorry, your application has been reviewed and denied. Now that you have seen this message, you may submit a new application.</p>");
                 $db->query("DELETE FROM `request` WHERE `ip`='" . Site::ip() . "'");
             } else {
                 if ($r['accepted'] == 1) {
                     $this->appendToBody("<h2>Congratulations</h2><p class='center'>Your application was reviewed and accepted.<br>You may now log in with the username and password that you chose.</p>");
                 }
             }
         }
     }
 }
Example #8
0
 function __construct()
 {
     parent::__construct("Server Control Panel", "", Site::LEVEL_TERRANCE);
     $this->appendToBody(Site::parseHtmlFragment("scp.html", ['<!-- uptime -->'], [`uptime` . '<br>' . human_filesize(disk_free_space(__DIR__), 2) . " free"]));
 }
Example #9
0
 function __construct()
 {
     parent::__construct("FAQ", "", 0);
     $this->setBody(Site::parseHtmlFragment("faq.html"));
 }
Example #10
0
use View\Pages\FourOhFour;
define("START_TIME", microtime(true));
require_once 'inc/config.php';
require_once 'inc/globals.php';
try {
    // Page router
    try {
        if (Site::backupInProgress() && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
            die((new Page("Backup in Progress", "<h2>Backing Up</h2><div class='centertext'>Please come back later.</div>"))->display());
        }
        if (Site::isBanned()) {
            die((new Banned())->display());
        }
        Router::route(strtok($_SERVER["REQUEST_URI"], '?'));
    } catch (NotFoundException $ex) {
        echo (new FourOhFour($ex->getMessage()))->display();
    } catch (PermissionException $ex) {
        die((new FancyPage("/b/ stats: ACCESS DENIED", Site::parseHtmlFragment('accessDenied.html', ['__privilege__', '__required__'], [$ex->has, $ex->required]), 0))->display());
    } catch (PDOException $ex) {
        $page = new Page("Database Error", "");
        $page->appendToBody(div('There was an error with the database.<br>' . 'It may be misconfigured.', 'centertext') . div($ex->getMessage() . nl2br($ex->getTraceAsString()), 'centertext'));
        header("HTTP/1.0 500 Internal Server Error");
        echo $page->display();
    } catch (Exception $ex) {
        $page = new FancyPage("Error", "", 0);
        $page->setBody("<h1>Error</h1>" . "<div class='centertext'>" . "Your request could not be processed. The following error was encountered: " . "<br>" . $ex->getMessage() . " at " . $ex->getFile() . ":" . $ex->getLine() . "</div>");
        echo $page->display();
    }
} catch (Throwable $err) {
    echo "There was a serious error encountered. The server admin likely broke a configuration file, or something." . "<br><br>" . $err->getMessage() . " in " . $err->getFile() . " at line " . $err->getLine();
}