Esempio n. 1
0
 function __construct(Thread $thread)
 {
     parent::__construct($thread->getBoard());
     $topLinks = div('', 'topLinks navLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
     if (!$thread->getBoard()->isSwfBoard()) {
         $topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
     }
     if (!$thread->getBoard()->isArchive() && $thread->isActive()) {
         if ($thread->isClosed()) {
             $this->appendToBody(el('h2', 'Thread is closed.'));
         } else {
             if (!isset($_SESSION['captcha'])) {
                 $_SESSION['captcha'] = rand(100000, 999999);
             }
             $this->appendToBody(Site::parseHtmlFragment('postForm.html', ['_board_', '_resto_', '_password_'], [$thread->getBoard()->getName(), $thread->getThreadId(), 'password']));
         }
     }
     $this->appendToBody($topLinks);
     $thread->loadAll();
     $dur = secsToDHMS($thread->getPost($thread->getPosts() - 1)->getTime() - $thread->getPost(0)->getTime());
     $board = div('', 'board');
     if ($thread->getBoard()->isArchive()) {
         $threadStats = Site::parseHtmlFragment("threadStats.html", ["__threadid__", "__posts__", "__posts_actual__", "__images__", "__images_actual__", "__lifetime__", "__deleted__", "<!--4chanLink-->", "<!--tag-->"], [$thread->getThreadId(), $thread->getChanPosts(), $thread->getPosts() - 1, $thread->getChanImages(), $thread->getImages() - 1, "{$dur[0]}d {$dur[1]}h {$dur[2]}m {$dur[3]}s", $thread->getDeleted(), $thread->isActive() ? "<a target='_blank' href='//boards.4chan.org/{$this->board->getName()}/thread/{$thread->getThreadId()}'>View on 4chan</a>" : "Thread is dead.", $thread->getTag() != null ? "<br>Tagged as: " . $thread->getTag() : ""]);
         $board->append($threadStats);
     } else {
         $board->append('<hr>');
     }
     $this->appendToBody($board->append(div($thread->displayThread(), 'thread')));
     $bottomLinks = $topLinks;
     $this->appendToBody("<hr>" . $bottomLinks);
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 public function __construct()
 {
     parent::__construct("Banned", "You're banned.");
     $banInfo = OldModel::getBanInfo($_SERVER['REMOTE_ADDR']);
     $expires = $banInfo['expires'] == 0 ? "Never" : date("Y-m-d h:i:s T", $banInfo['expires']);
     $this->body = Site::parseHtmlFragment('banned.html', ['__ip__', '__reason__', '__expires__'], [$_SERVER['REMOTE_ADDR'], $banInfo['reason'], $expires]);
     $this->title = "/b/ stats: ACCESS DENIED";
 }
Esempio n. 4
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]));
     }
 }
Esempio n. 5
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]));
 }
Esempio n. 6
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>");
                 }
             }
         }
     }
 }
Esempio n. 7
0
 private function renderPageNumbers(int $page, bool $catalog = true) : string
 {
     $catalogLink = $catalog ? '<div class="pages cataloglink"><a href="./catalog">Catalog</a></div>' : '';
     if ($page == 1) {
         $linkList = Site::parseHtmlFragment("pagelist/pagelist_first.html", '<!-- catalog -->', $catalogLink);
     } elseif (1 < $page && $page < $this->board->getArchivePages() - 1) {
         $linkList = Site::parseHtmlFragment("pagelist/pagelist_middle.html", '<!-- catalog -->', $catalogLink);
     } else {
         $linkList = Site::parseHtmlFragment("pagelist/pagelist_last.html", '<!-- catalog -->', $catalogLink);
     }
     $pages = "";
     for ($p = 2; $p <= min($this->board->getArchivePages(), $this->board->getPages()); $p++) {
         if ($p == $page) {
             $pages .= "[<strong><a href='{$p}'>{$p}</a></strong>] ";
         } else {
             $pages .= "[<a href='{$p}'>{$p}</a>] ";
         }
     }
     $start = max([$page - 7, $this->board->getPages() + 1]);
     $end = min([$page + 8, $this->board->getArchivePages() + 1]);
     if ($end > $this->board->getPages()) {
         if ($start > $this->board->getPages() + 1) {
             $pages .= "[...] ";
         }
         for ($i = $start; $i < $end; $i++) {
             if ($i == $page) {
                 $pages .= "[<strong><a href='{$i}'>{$i}</a></strong>] ";
             } else {
                 $pages .= "[<a href='{$i}'>{$i}</a>] ";
             }
         }
     }
     if ($end < $this->board->getArchivePages()) {
         $pages .= "[...] ";
         $pages .= "[<a href='{$this->board->getArchivePages()}'>{$this->board->getArchivePages()}</a>] ";
     }
     return str_replace(["_prev_", "_next_", "_pages_"], [$page - 1, $page + 1, $pages], $linkList);
 }
Esempio n. 8
0
 private static function makeImageBlock(Post $post, $display)
 {
     /**
      * The following block is only for posts with an image attached.
      */
     if ($post->hasImage() && !$post->imgbanned) {
         $md5Filename = str_replace('/', '-', $post->md5);
         $humanFilesize = $post->fsize > 0 ? human_filesize($post->fsize) . ", " : "";
         list($thumbW, $thumbH) = tn_Size($post->w, $post->h);
         if ($display == self::DISPLAY_OP && ($post->w > 125 || $post->h > 125)) {
             //OP thumbs are 250x250 rather than 125x125
             $thumbW *= 2;
             $thumbH *= 2;
         }
         $thumb = "<a class='fileThumb' href='{$post->getImgUrl()}' target='_blank'>" . "<img src='{$post->getThumbUrl()}' alt='' data-md5='{$post->md5}' data-md5-filename='{$md5Filename}' data-ext='{$post->ext}' data-full-img='{$post->getImgUrl()}' width='{$thumbW}' height='{$thumbH}' data-width='{$post->w}' data-height='{$post->h}' />" . "</a>";
         $chanMedia = $post->board == 'f' ? '//i.4cdn.org/f/src/' . $post->filename . $post->ext : '//i.4cdn.org/' . $post->board . '/src/' . $post->tim . $post->ext;
         $fullImgLink = $post->getExtension() == '.swf' ? $post->getSwfUrl() : $post->getImgUrl();
         $fileDiv = div('', 'file')->set('id', 'f' . $post->no);
         $fileInfo = div('', 'fileInfo');
         $fileText = span('', 'fileText')->set('id', 'fT' . $post->no)->set('data-filename', $post->filename . $post->ext);
         $fileText->append(a($post->filename . $post->ext, $chanMedia)->set("target", "_blank")->set("title", $post->filename . $post->ext)->set("class", 'imageLink')->set('rel', 'noreferrer'))->append('&nbsp;')->append("({$humanFilesize}{$post->w}x{$post->h}, " . ($post->board == 'f' ? $post->tag . ")" : "<span title='{$post->filename}{$post->ext}'>{$post->tim}{$post->ext}</span>)&nbsp;"));
         if ($post->getExtension() != '.swf') {
             $fileText->append(a('iqdb', "http://iqdb.org/?url={$post->getThumbUrl()}")->set("target", "_blank") . '&nbsp;' . a('google', "http://www.google.com/searchbyimage?image_url={$post->getThumbUrl()}")->set("target", "_blank"));
         }
         $fileText->append('&nbsp;' . a('reposts', "/{$post->board}/search/md5/{$post->getMD5Hex()}")->set("target", "_blank") . '&nbsp;' . a('full', $fullImgLink)->set("target", '_blank'));
         $fileInfo->append($fileText);
         $fileDiv->append($fileInfo);
         $fileDiv->append($thumb);
         return $fileDiv;
     } else {
         if ($post->imgbanned) {
             return Site::parseHtmlFragment("post/banned_image.html");
         } else {
             return "";
         }
     }
 }
Esempio n. 9
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"]));
 }
Esempio n. 10
0
 function __construct()
 {
     parent::__construct("FAQ", "", 0);
     $this->setBody(Site::parseHtmlFragment("faq.html"));
 }
Esempio n. 11
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();
}
Esempio n. 12
0
 protected function renderFooter()
 {
     if (!$this->clearFooter) {
         $this->footer = Site::parseHtmlFragment("pagefoot.html", ["<!--copyright-->"], [file_get_contents("htmls/copyright.html")]);
     } else {
         $this->footer = file_get_contents("htmls/pagefoot.html");
     }
     return $this->footer;
 }
Esempio n. 13
0
 /**
  * Default constructor
  * @param string $title Text in the <code>&lt;title&gt;</code> tags.
  * @param string $body Initial body text.
  * @param int $privelege The minimum access level to see the page.
  */
 function __construct($title, $body = "", $privilege = 1, $board = null)
 {
     parent::__construct($title, $body);
     $this->requiredLevel = $privilege;
     $this->board = $board;
     if ($this->user->getPrivilege() >= Site::LEVEL_SEARCH) {
         $this->addToHead("<script type='text/javascript'>\$(document).ready(function(){ImageHover.init('');});</script>");
     }
     if ($this->user->getPrivilege() >= Site::LEVEL_ADMIN) {
         $this->addToHead("<script type='text/javascript' src='/script/bstats-admin.js'></script>");
     }
     if ($this->user->getPrivilege() < $this->requiredLevel) {
         throw new PermissionException($this->user->getPrivilege(), $this->requiredLevel);
     }
     $navBarExtra = "";
     if ($this->user->getPrivilege() == 0) {
         //If not logged in, show login form.
         $navBarExtra .= Site::parseHtmlFragment("loginform.html");
     }
     if ($this->user->getPrivilege() > 0) {
         $navBarExtra .= Site::parseHtmlFragment('loginticker.html', ['%username%', '%privilege%', '<!-- more buttons -->'], [$this->user->getUsername(), $this->user->getPrivilege(), $this->renderExtraButtons()]);
     }
     $this->navbar->append($navBarExtra);
 }