Ejemplo n.º 1
0
 TBGContext::addClasspath(THEBUGGENIE_CORE_PATH . 'classes' . DS);
 TBGLogging::log(TBGCache::isEnabled() ? 'APC cache is enabled' : 'APC cache is not enabled');
 TBGLogging::log('Loading B2DB');
 try {
     TBGLogging::log('Adding B2DB classes to autoload path');
     define('B2DB_BASEPATH', THEBUGGENIE_CORE_PATH . 'B2DB' . DS);
     define('B2DB_CACHEPATH', THEBUGGENIE_CORE_PATH . 'cache' . DS . 'B2DB' . DS);
     TBGContext::addClasspath(THEBUGGENIE_CORE_PATH . 'B2DB' . DS . 'classes' . DS);
     TBGLogging::log('...done (Adding B2DB classes to autoload path)');
     TBGLogging::log('Initializing B2DB');
     if (!isset($argc)) {
         B2DB::setHTMLException(true);
     }
     B2DB::initialize(THEBUGGENIE_CORE_PATH . 'b2db_bootstrap.inc.php');
     TBGLogging::log('...done (Initializing B2DB)');
     if (B2DB::isInitialized()) {
         TBGLogging::log('Database connection details found, connecting');
         B2DB::doConnect();
         TBGLogging::log('...done (Database connection details found, connecting)');
         TBGLogging::log('Adding core table classpath to autoload path');
         TBGContext::addClasspath(THEBUGGENIE_CORE_PATH . 'classes' . DS . 'B2DB' . DS);
     }
 } catch (Exception $e) {
     tbg_exception('Could not load and initiate the B2DB subsystem', $e);
 }
 TBGLogging::log('...done');
 TBGLogging::log('Initializing context');
 TBGContext::initialize();
 TBGLogging::log('...done');
 //require THEBUGGENIE_CORE_PATH . 'common_functions.inc.php';
 require THEBUGGENIE_CORE_PATH . 'geshi/geshi.php';
Ejemplo n.º 2
0
 /**
  * Runs the action for the second step of the installation
  * where you enter database information
  * 
  * @param TBGRequest $request The request object
  * 
  * @return null
  */
 public function runInstallStep2(TBGRequest $request)
 {
     $this->preloaded = false;
     $this->selected_connection_detail = 'custom';
     if (!$this->error) {
         try {
             B2DB::initialize(THEBUGGENIE_CORE_PATH . 'b2db_bootstrap.inc.php');
         } catch (Exception $e) {
         }
         if (B2DB::isInitialized()) {
             $this->preloaded = true;
             $this->username = B2DB::getUname();
             $this->password = B2DB::getPasswd();
             $this->dsn = B2DB::getDSN();
             $this->hostname = B2DB::getHost();
             $this->port = B2DB::getPort();
             $this->b2db_dbtype = B2DB::getDBtype();
             $this->db_name = B2DB::getDBname();
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Launches the MVC framework
  */
 public static function go()
 {
     TBGLogging::log('Dispatching');
     try {
         if (($route = self::getRouting()->getRouteFromUrl(self::getRequest()->getParameter('url', null, false))) || self::isInstallmode()) {
             if (self::isUpgrademode()) {
                 $route = array('module' => 'installation', 'action' => 'upgrade');
             } elseif (self::isInstallmode()) {
                 $route = array('module' => 'installation', 'action' => 'installIntro');
             }
             if (self::$_redirect_login) {
                 TBGLogging::log('An error occurred setting up the user object, redirecting to login', 'main', TBGLogging::LEVEL_NOTICE);
                 self::getResponse()->headerRedirect(self::getRouting()->generate('login_redirect'), 403);
             }
             if (is_dir(THEBUGGENIE_MODULES_PATH . $route['module'])) {
                 if (!file_exists(THEBUGGENIE_MODULES_PATH . $route['module'] . DS . 'classes' . DS . 'actions.class.php')) {
                     throw new TBGActionNotFoundException('The ' . $route['module'] . ' module is missing the classes/actions.class.php file, containing all the module actions');
                 }
                 if (!class_exists($route['module'] . 'Actions') && !class_exists($route['module'] . 'ActionComponents')) {
                     self::addClasspath(THEBUGGENIE_MODULES_PATH . $route['module'] . DS . 'classes' . DS);
                 }
                 if (self::performAction($route['module'], $route['action'])) {
                     if (B2DB::isInitialized()) {
                         B2DB::closeDBLink();
                     }
                     return true;
                 }
             } else {
                 throw new Exception('Cannot load the ' . $route['module'] . ' module');
                 return;
             }
         } else {
             require THEBUGGENIE_MODULES_PATH . 'main' . DS . 'classes' . DS . 'actions.class.php';
             self::performAction('main', 'notFound');
         }
     } catch (TBGTemplateNotFoundException $e) {
         B2DB::closeDBLink();
         TBGContext::setLoadedAt();
         header("HTTP/1.0 404 Not Found", true, 404);
         tbg_exception($e->getMessage(), $e);
     } catch (TBGActionNotFoundException $e) {
         B2DB::closeDBLink();
         TBGContext::setLoadedAt();
         header("HTTP/1.0 404 Not Found", true, 404);
         tbg_exception('Module action "' . $route['action'] . '" does not exist for module "' . $route['module'] . '"', $e);
     } catch (TBGCSRFFailureException $e) {
         B2DB::closeDBLink();
         TBGContext::setLoadedAt();
         self::$_response->setHttpStatus(301);
         $message = $e->getMessage();
         if (self::getRequest()->getRequestedFormat() == 'json') {
             self::$_response->setContentType('application/json');
             $message = json_encode(array('message' => $message));
         }
         self::$_response->renderHeaders();
         echo $message;
     } catch (Exception $e) {
         B2DB::closeDBLink();
         TBGContext::setLoadedAt();
         header("HTTP/1.0 404 Not Found", true, 404);
         tbg_exception('An error occured', $e);
     }
 }