コード例 #1
0
 public function run()
 {
     global $debug;
     // Connect to the database
     $this->debug($this::name_space . ': Connecting to database...');
     if ($this->_dbConnect() === false) {
         $this->debug($this::name_space . ': Connection failed!');
         if (is_CLI()) {
             return false;
         }
     } else {
         $this->debug($this::name_space . ': Connection successful!');
         $this->config->__init($this);
         $this->config->loadOptions();
     }
     $this->debug($this::name_space . ': Creating user controller...');
     $this->user = new UserController($this);
     $this->debug($this::name_space . ': Creating event logger...');
     $this->logger = new Logger($this);
     if (is_CLI()) {
         $this->debug($this::name_space . ': Setting up CLI...');
         $this->CLI();
     } else {
         $this->Web();
     }
 }
コード例 #2
0
ファイル: debugger.php プロジェクト: huwcbjones/WebFramework
 /**
  * Debugger::debug()
  * 
  * @param mixed $text
  * @return
  */
 public function debug($text, $shift = 0, $cli_print = false)
 {
     $space = '';
     $spaces = 80 - strlen($text);
     for ($s = 1; $s <= $spaces; $s++) {
         $space .= ' ';
     }
     if (version_compare(PHP_VERSION, '5.3.6', '>=')) {
         $bt = debug_backtrace(~DEBUG_BACKTRACE_PROVIDE_OBJECT & DEBUG_BACKTRACE_IGNORE_ARGS);
     } else {
         $bt = debug_backtrace(false);
     }
     $caller = array_shift($bt);
     if (strpos($caller['file'], 'autoload.php') === false) {
         $caller = array_shift($bt);
     }
     if ($shift != 0 && count($bt) > 1) {
         for ($i = 0; $i < abs($shift); $i++) {
             if (count($bt) <= abs($shift)) {
                 break;
             }
             $caller = array_shift($bt);
         }
     }
     $file = '';
     if (array_key_exists('file', $caller)) {
         $file = str_replace(__EXECDIR__, '', $caller['file']);
     } else {
         $caller['file'] = 'Unknown';
         $caller['line'] = '-';
     }
     $file = str_replace(DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'modules', '_MODULE_', $file);
     $file = str_replace(DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'plugins', '_PLUGIN_', $file);
     $file = str_replace(DIRECTORY_SEPARATOR . 'lib', '_LIB_', $file);
     $file = str_replace(DIRECTORY_SEPARATOR . 'class.', DIRECTORY_SEPARATOR, $file);
     if ($spaces < 16 || strlen($file) > 30) {
         $file = explode(DIRECTORY_SEPARATOR, $caller['file']);
         $file = $file[count($file) - 1];
     }
     $msg = $text . $space . '(' . $file . ', ' . $caller['line'] . ')';
     $this->debugLog[ranString(2, 2) . microtime(false)] = $msg;
     if (is_CLI() && $cli_print) {
         echo ' # ' . $msg . PHP_EOL;
     }
 }