Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.82 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @copyright   ProFusion
  4.  * @author      ProFusion
  5.  */
  6.  
  7. if (!defined('NO_IMPORTS')) {
  8.     require_once(PBB_DIR.'functions.php');
  9. }
  10.  
  11. class PBB {
  12.    
  13.     /**
  14.      * MySQLDatabase object
  15.      * @name    dbObj
  16.      * @access  static private
  17.      *
  18.      * @var     object
  19.      */
  20.     static private $dbObj = null;
  21.    
  22.     /**
  23.      * Cache object
  24.      * @name    dbObj
  25.      * @access  static private
  26.      *
  27.      * @var     object
  28.      */
  29.     static private $cacheObj = null;
  30.        
  31.     /**
  32.      * Template class object
  33.      * @name    tplObj
  34.      * @access  static private
  35.      *
  36.      * @var     object
  37.      */
  38.     static private $tplObj = null;
  39.    
  40.     /**
  41.      * Starts up PBB
  42.      * @name    __construct
  43.      * @access  public
  44.      *
  45.      * @return  void
  46.      */
  47.     public function __construct() {
  48.         $this->initDB();
  49.         $this->initCache();
  50.         $this->initTPL();
  51.     }
  52.    
  53.     /**
  54.      * Inits MySQLDatabase
  55.      * @name    initDB
  56.      * @access  private
  57.      *
  58.      * @return  void
  59.      */
  60.     private function initDB() {
  61.         require_once(PBB_DIR.'lib/system/database/MySQLDatabase.class.php');
  62.         $dbHost = $dbUser = $dbPass = $dbName = '';
  63.         require_once(PBB_DIR.'config.inc.php');
  64.         self::$dbObj = new MySQLDatabase($dbHost, $dbUser, $dbPass, $dbName, false);
  65.     }
  66.    
  67.     /**
  68.      * Gets MySQLDatabase object
  69.      * @name    getDB
  70.      * @access  static public
  71.      *
  72.      * @return  object
  73.      */
  74.     static public function getDB() {
  75.         return self::$dbObj;
  76.     }
  77.    
  78.     /**
  79.      * Inits Cache
  80.      * @name    initCache
  81.      * @access  private
  82.      *
  83.      * @return  void
  84.      */
  85.     private function initCache() {
  86.         require_once(PBB_DIR.'lib/system/cache/Cache.class.php');
  87.         self::$cacheObj = new Cache();
  88.     }
  89.    
  90.     /**
  91.      * Gets Cache object
  92.      * @name    getCache
  93.      * @access  static public
  94.      *
  95.      * @return  object
  96.      */
  97.     static public function getCache() {
  98.         return self::$cacheObj;
  99.     }
  100.    
  101.     /**
  102.      * Inits Template class
  103.      * @name    initTPL
  104.      * @access  private
  105.      *
  106.      * @return  void
  107.      */
  108.     private function initTPL() {
  109.         require_once(PBB_DIR.'lib/system/template/Template.class.php');
  110.         #$styleID = (!empty(PBB::getStyle()->currentStyleID)) ? PBB::getStyle()->currentStyleID : 1;
  111.        self::$tplObj = new Template(1);
  112.         PBB::getTPL()->addFile('core/style/'.PBB::getTPL()->styleLocation.'/'.PBB::getTPL()->styleLocation, 'stylesheet');
  113.     }
  114.    
  115.     /**
  116.      * Gets TemplateParser object
  117.      * @name    getTPL
  118.      * @access  static public
  119.      *
  120.      * @return  object
  121.      */
  122.     static public function getTPL() {
  123.         return self::$tplObj;
  124.     }
  125.    
  126.     /**
  127.      * Handles an exception
  128.      * @name    handleException
  129.      * @access  static public
  130.      *
  131.      * @param   exception   $e  exception object
  132.      *
  133.      * @return  void
  134.      */
  135.     static public function handleException(exception $e) {
  136.         if ($e instanceof PrintableException) {
  137.             $e->show();
  138.             exit;
  139.         }
  140.     }
  141.    
  142.     /**
  143.      * Handles an error
  144.      * @name    handleError
  145.      * @access  static public
  146.      *
  147.      * @param   int     $errno      error code
  148.      * @param   string  $errstr     error as string
  149.      * @param   string  $errfile    errorfile
  150.      * @param   string  $errline    errorline
  151.      *
  152.      * @return  void
  153.      */
  154.     static public function handleError($errno = 0, $errstr, $errfile, $errline) {
  155.         if ($errno != E_NOTICE) {
  156.             $error = new ErrorHandler($errno, $errstr, $errfile, $errline);
  157.             throw new SystemException($error->errorAsString(), $errno, $this);
  158.         } else {
  159.             //ignore
  160.         }
  161.     }
  162. }
  163. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement