Esempio n. 1
0
 public function tagWork($tpl)
 {
     $expression = "/{(BLOCK|PAGE|LINK):([a-z][\\w]*)([\\.\\w]*)}/is";
     if (preg_match($expression, $tpl, $match)) {
         // Array (     [0] => {BLOCK:menu.main}     [1] => BLOCK    [2] => menu    [3] => .main )
         if ($match[1] == "BLOCK" and isset($this->modules[$match[2]])) {
             $call = $this->modules[$match[2]][0];
             //'\\'.$m[0].'\Block';
             // call or recall block module
             $qq = $this->modules[$match[2]][1];
             if (isset($this->modules[$match[2]][2])) {
                 $tpl = str_replace($match[0], $call::{$this->modules[$match[2]][1]}($match[3]), $tpl);
             } else {
                 $tpl = str_replace($match[0], $call::instance()->{$this->modules[$match[2]][1]}($match[3]), $tpl);
             }
         } elseif ($match[1] == "PAGE") {
             $page = \View\Page::load($match[2]);
             $tpl = str_replace($match[0], $page, $tpl);
         } else {
             $tpl = str_replace($match[0], "*{$match[2]}*", $tpl);
         }
         return $this->tagWork($tpl);
     } else {
         return $tpl;
     }
 }
Esempio n. 2
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. 3
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);
 }
Esempio n. 4
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();
}