Esempio n. 1
0
 public function submit_admin($data)
 {
     Variable::set('default_theme', $data['theme']);
     Base_ThemeCommon::create_cache();
     Base_StatusBarCommon::message('Theme changed - reloading page');
     eval_js('setTimeout(\'document.location=\\\'index.php\\\'\',\'3000\')');
     return true;
 }
Esempio n. 2
0
 public function install()
 {
     Base_ThemeCommon::install_default_theme('FirstRun');
     Base_ThemeCommon::create_cache();
     return true;
 }
Esempio n. 3
0
        if (!Base_AclCommon::i_am_sa()) {
            die('Only super admin can access this page');
        }
    } else {
        $auth = SimpleLogin::form();
        if ($auth) {
            print $auth;
            die;
        }
    }
}
if (class_exists('Base_LangCommon')) {
    Base_LangCommon::update_translations();
}
if (class_exists('Base_ThemeCommon')) {
    Base_ThemeCommon::create_cache();
}
if (class_exists('ModuleManager')) {
    ModuleManager::create_load_priority_array();
}
$html = '';
$checks = array();
// checking:
// DB - creating tables, selects, locking tables
// Strict Standards
// error display
// file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration
// memory check
// max_execution_time setting (safe mode)
// upload_max_filesize
// Libs: ZIP, curl
Esempio n. 4
0
 public function validate($data)
 {
     if (DEMO_MODE) {
         print 'You cannot modify installed modules in demo';
         return false;
     }
     @set_time_limit(0);
     $installed = array();
     $install = array();
     $uninstall = array();
     $anonymous_setup = false;
     foreach ($data as $k => $v) {
         ${$k} = $v;
     }
     foreach ($installed as $name => $new_version) {
         $old_version = ModuleManager::is_installed($name);
         if ($old_version == $new_version) {
             continue;
         }
         if ($old_version == -1 && $new_version >= 0) {
             $install[$name] = $new_version;
             continue;
         }
         if ($new_version == -2) {
             $uninstall[$name] = 1;
             $install[$name] = $old_version;
             continue;
         }
         if ($old_version >= 0 && $new_version == -1) {
             $uninstall[$name] = 1;
             continue;
         }
         if ($old_version < $new_version) {
             if (!ModuleManager::upgrade($name, $new_version)) {
                 return false;
             }
             continue;
         }
         if ($old_version > $new_version) {
             if (!ModuleManager::downgrade($name, $new_version)) {
                 return false;
             }
             continue;
         }
     }
     //uninstall
     $modules_prio_rev = array();
     foreach (ModuleManager::$modules as $k => $v) {
         $modules_prio_rev[] = $k;
     }
     $modules_prio_rev = array_reverse($modules_prio_rev);
     foreach ($modules_prio_rev as $k) {
         if (array_key_exists($k, $uninstall)) {
             if (!ModuleManager::uninstall($k)) {
                 return false;
             }
             if (count(ModuleManager::$modules) == 0) {
                 print 'No modules installed';
             }
         }
     }
     //install
     foreach ($install as $i => $v) {
         $post_install[$i] = $v;
         if (isset($uninstall[$i])) {
             if (!ModuleManager::install($i, $v, true, false)) {
                 return false;
             }
         } else {
             if (!ModuleManager::install($i, $v)) {
                 return false;
             }
         }
     }
     $processed = ModuleManager::get_processed_modules();
     $this->set_module_variable('post-install', $processed['install']);
     Base_ThemeCommon::create_cache();
     if (empty($post_install)) {
         Epesi::redirect();
     }
     return true;
 }
Esempio n. 5
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);
     error_log(date('Y-m-d H:i:s') . ': installing "Base" ...' . "\n", 3, DATA_DIR . '/firstrun.log');
     if (!ModuleManager::install('Base', null, false)) {
         print 'Unable to install Base module pack.';
         return false;
     }
     error_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 3, DATA_DIR . '/firstrun.log');
     $t = microtime(true);
     error_log(date('Y-m-d H:i:s') . ': creating admin user ...' . "\n", 3, DATA_DIR . '/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);
     error_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 3, DATA_DIR . '/firstrun.log');
     $t = microtime(true);
     error_log(date('Y-m-d H:i:s') . ': setting mail server ...' . "\n", 3, DATA_DIR . '/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']);
         }
     }
     error_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 3, DATA_DIR . '/firstrun.log');
     $t = microtime(true);
     error_log(date('Y-m-d H:i:s') . ': Installing modules ...' . "\n", 3, DATA_DIR . '/firstrun.log');
     foreach ($pkgs as $p) {
         if (!is_dir('modules/' . $p)) {
             continue;
         }
         $t2 = microtime(true);
         error_log(' * ' . date('Y-m-d H:i:s') . ' - ' . $p . ' (', 3, DATA_DIR . '/firstrun.log');
         if (!ModuleManager::install(str_replace('/', '_', $p), null, false)) {
             print '<b>Unable to install ' . str_replace('_', '/', $p) . ' module.</b>';
         }
         error_log(microtime(true) - $t2 . "s)\n", 3, DATA_DIR . '/firstrun.log');
     }
     error_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 3, DATA_DIR . '/firstrun.log');
     $t = microtime(true);
     error_log(date('Y-m-d H:i:s') . ': Refreshing cache of modules ...' . "\n", 3, DATA_DIR . '/firstrun.log');
     ModuleManager::create_load_priority_array();
     Base_SetupCommon::refresh_available_modules();
     error_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 3, DATA_DIR . '/firstrun.log');
     $t = microtime(true);
     error_log(date('Y-m-d H:i:s') . ': Creating cache of template files ...' . "\n", 3, DATA_DIR . '/firstrun.log');
     Base_ThemeCommon::create_cache();
     error_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 3, DATA_DIR . '/firstrun.log');
     $t = microtime(true);
     error_log(date('Y-m-d H:i:s') . ': Updating translation files ...' . "\n", 3, DATA_DIR . '/firstrun.log');
     Base_LangCommon::update_translations();
     error_log(date('Y-m-d H:i:s') . ': done (' . (microtime(true) - $t) . "s).\n", 3, DATA_DIR . '/firstrun.log');
     $processed = ModuleManager::get_processed_modules();
     $_SESSION['first-run_post-install'] = $processed['install'];
     location();
 }