Ejemplo n.º 1
0
 public static function handle_error($type, $message, $errfile, $errline, $errcontext)
 {
     if (($type & error_reporting()) > 0) {
         $backtrace = self::debug_backtrace();
         epesi_log(self::error_code_to_string($type) . ' (' . $type . '): ' . $message . "\n" . 'File: ' . $errfile . ' (' . $errline . ")\n\n", 'php_errors.log');
         if (!self::notify_observers($type, $message, $errfile, $errline, $errcontext, $backtrace)) {
             return false;
         }
         while (@ob_end_clean()) {
         }
         echo self::notify_client('Type: ' . self::error_code_to_string($type) . ' (' . $type . ')<br>Message: ' . $message . '<br>File: ' . $errfile . '<br>Line=' . $errline . $backtrace . '<hr>');
         exit;
     }
     return true;
 }
Ejemplo n.º 2
0
 static function log($message)
 {
     epesi_log($message, 'patches.log');
 }
Ejemplo n.º 3
0
 public function update_observer($type, $message, $errfile, $errline, $errcontext, $backtrace)
 {
     global $cron_funcs_prior;
     $backtrace = htmlspecialchars_decode(str_replace(array('<br />', '&nbsp;'), array("\n", ' '), $backtrace));
     $x = $cron_funcs_prior[$this->func_md5] . ":\ntype=" . $type . "\nmessage=" . $message . "\nerror file=" . $errfile . "\nerror line=" . $errline . "\n" . $backtrace;
     epesi_log($x . "\n", 'cron.log');
     DB::IgnoreErrors(array('adodb_error', null));
     //ignore adodb errors
     $query_args = array(time(), $this->func_md5);
     $query = DB::TypeControl('UPDATE cron SET last=%d,running=0 WHERE func=%s', $query_args);
     if (!DB::Execute($query, $query_args)) {
         //if not - probably server gone away - retry every 10 seconds for 1h
         for ($i = 0; $i < 360; $i++) {
             sleep(10);
             $connection = null;
             try {
                 $connection = DB::Connect();
                 //reconnect database as new connection
             } catch (Exception $e) {
                 continue;
                 //no connection - wait
             }
             if ($connection->Execute($query, $query_args)) {
                 //if ok then break and exit
                 $connection->Close();
                 break;
             }
             $connection->Close();
         }
     }
     return true;
 }
Ejemplo n.º 4
0
 public function done($d)
 {
     @set_time_limit(0);
     if (count($this->ini) == 1) {
         $pkgs = reset($this->ini);
         $pkgs = $pkgs['package'];
     } else {
         $pkgs = isset($this->ini[$d[0]['setup_type']]['package']) ? $this->ini[$d[0]['setup_type']]['package'] : array();
     }
     $t = microtime(true);
     epesi_log(date('Y-m-d H:i:s') . ': installing "Base" ...' . "\n", 'firstrun.log');
     if (!ModuleManager::install('Base', null, false)) {
         print 'Unable to install Base module pack.';
         return false;
     }
     epesi_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 'firstrun.log');
     $t = microtime(true);
     epesi_log(date('Y-m-d H:i:s') . ': creating admin user ...' . "\n", 'firstrun.log');
     if (!Base_UserCommon::add_user($d['simple_user']['login'])) {
         print 'Unable to create user';
         return false;
     }
     $user_id = Base_UserCommon::get_user_id($d['simple_user']['login']);
     if ($user_id === false) {
         print 'Unable to get admin user id';
         return false;
     }
     if (!DB::Execute('INSERT INTO user_password(user_login_id,password,mail) VALUES(%d,%s, %s)', array($user_id, md5($d['simple_user']['pass']), $d['simple_user']['mail']))) {
         print 'Unable to set user password';
         return false;
     }
     if (!Base_UserCommon::change_admin($user_id, 2)) {
         print 'Unable to update admin account data (groups).';
         return false;
     }
     Acl::set_user($user_id, true);
     Variable::set('anonymous_setup', false);
     epesi_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 'firstrun.log');
     $t = microtime(true);
     epesi_log(date('Y-m-d H:i:s') . ': setting mail server ...' . "\n", 'firstrun.log');
     $method = $d['simple_mail']['mail_method'];
     Variable::set('mail_method', $method);
     Variable::set('mail_from_addr', $d['simple_user']['mail']);
     Variable::set('mail_from_name', $d['simple_user']['login']);
     if ($method == 'smtp') {
         Variable::set('mail_host', $d['simple_mail_smtp']['mail_host']);
         if ($d['simple_mail_smtp']['mail_user'] !== '' && $d['simple_mail_smtp']['mail_user'] !== '') {
             $auth = true;
         } else {
             $auth = false;
         }
         Variable::set('mail_auth', $auth);
         if ($auth) {
             Variable::set('mail_user', $d['simple_mail_smtp']['mail_user']);
             Variable::set('mail_password', $d['simple_mail_smtp']['mail_password']);
         }
     }
     epesi_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 'firstrun.log');
     $t = microtime(true);
     epesi_log(date('Y-m-d H:i:s') . ': Installing modules ...' . "\n", 'firstrun.log');
     foreach ($pkgs as $p) {
         if (!is_dir('modules/' . $p)) {
             continue;
         }
         $t2 = microtime(true);
         epesi_log(' * ' . date('Y-m-d H:i:s') . ' - ' . $p . ' (', 'firstrun.log');
         if (!ModuleManager::install(str_replace('/', '_', $p), null, false)) {
             print '<b>Unable to install ' . str_replace('_', '/', $p) . ' module.</b>';
         }
         epesi_log(microtime(true) - $t2 . "s)\n", 'firstrun.log');
     }
     epesi_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 'firstrun.log');
     $t = microtime(true);
     epesi_log(date('Y-m-d H:i:s') . ': Refreshing cache of modules ...' . "\n", 'firstrun.log');
     ModuleManager::create_load_priority_array();
     Base_SetupCommon::refresh_available_modules();
     epesi_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 'firstrun.log');
     $t = microtime(true);
     epesi_log(date('Y-m-d H:i:s') . ': Creating cache of template files ...' . "\n", 'firstrun.log');
     Base_ThemeCommon::create_cache();
     epesi_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 'firstrun.log');
     $t = microtime(true);
     epesi_log(date('Y-m-d H:i:s') . ': Updating translation files ...' . "\n", 'firstrun.log');
     Base_LangCommon::update_translations();
     epesi_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 'firstrun.log');
     $processed = ModuleManager::get_processed_modules();
     $_SESSION['first-run_post-install'] = $processed['install'];
     location();
 }