Esempio n. 1
0
 function initialize($loaded_modules)
 {
     global $db, $messageStack, $currencies;
     // load the latest currency exchange rates
     if (web_connected(false) && AUTO_UPDATE_CURRENCY && ENABLE_MULTI_CURRENCY) {
         gen_pull_language('phreedom', 'admin');
         require_once DIR_FS_MODULES . 'phreedom/classes/currency.php';
         $currency = new currency();
         $currency->btn_update();
     }
     // Fix for change to audit log for upgrade to R3.6 causes perpertual crashing when writing audit log
     if (!db_field_exists(TABLE_AUDIT_LOG, 'stats')) {
         $db->Execute("ALTER TABLE " . TABLE_AUDIT_LOG . " ADD stats VARCHAR(32) NOT NULL AFTER ip_address");
     }
     // load installed modules and initialize them
     if (is_array($loaded_modules)) {
         foreach ($loaded_modules as $module) {
             if ($module == 'phreedom') {
                 continue;
             }
             // skip this module
             require_once DIR_FS_MODULES . $module . '/classes/install.php';
             $install_class = $module . '_admin';
             $mod_init = new $install_class();
             if (constant('MODULE_' . strtoupper($module) . '_STATUS') != constant('MODULE_' . strtoupper($module) . '_VERSION')) {
                 // add any new constants
                 if (sizeof($mod_init->keys) > 0) {
                     foreach ($mod_init->keys as $key => $value) {
                         if (!defined($key)) {
                             write_configure($key, $value);
                         }
                     }
                 }
                 admin_install_dirs($mod_init->dirlist, DIR_FS_MY_FILES . $_SESSION['company'] . '/');
                 if (method_exists($mod_init, 'update')) {
                     $mod_init->update($module);
                 }
             }
             if (method_exists($mod_init, 'initialize')) {
                 $mod_init->initialize($module);
             }
         }
     }
     if (web_connected(false) && CFG_AUTO_UPDATE_CHECK && SECURITY_ID_CONFIGURATION > 3) {
         // check for software updates
         $revisions = @file_get_contents(VERSION_CHECK_URL);
         if ($revisions) {
             $versions = xml_to_object($revisions);
             $latest = $versions->Revisions->Phreedom->Current;
             $current = MODULE_PHREEDOM_VERSION;
             if ($latest > $current) {
                 $messageStack->add_session(sprintf(TEXT_VERSION_CHECK_NEW_VER, $current, $latest), 'caution');
             }
             foreach ($loaded_modules as $mod) {
                 // check rest of modules
                 if ($mod == 'phreedom') {
                     continue;
                 }
                 // skip this module
                 $latest = $versions->Revisions->Modules->{$mod}->Current;
                 $current = constant('MODULE_' . strtoupper($mod) . '_VERSION');
                 if ($latest > $current) {
                     $messageStack->add_session(sprintf(TEXT_VERSION_CHECK_NEW_MOD_VER, $mod, $current, $latest), 'caution');
                 }
             }
         }
     }
     // Make sure the install directory has been moved/removed
     if (is_dir(DIR_FS_ADMIN . 'install')) {
         $messageStack->add_session(TEXT_INSTALL_DIR_PRESENT, 'caution');
     }
 }
 // check for software updates
 if (CFG_AUTO_UPDATE_CHECK) {
     if (web_connected($silent = false)) {
         $line = @file(NEW_VERSION_CHECKUP_URL);
         $latest_version = trim($line[0]);
         // Determine the Program patch level
         include DIR_FS_ADMIN . 'includes/version.php';
         $installed_version = PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR;
         if ($latest_version > $installed_version) {
             $messageStack->add_session(sprintf(TEXT_VERSION_CHECK_NEW_VER, $installed_version, $latest_version), 'success');
         }
     }
 }
 // load the latest currency exchange rates
 if (AUTO_UPDATE_CURRENCY && ENABLE_MULTI_CURRENCY) {
     if (web_connected($silent = false)) {
         require DIR_FS_MODULES . 'setup/classes/currency.php';
         require DIR_FS_MODULES . 'setup/language/' . $_SESSION['language'] . '/modules/currency.php';
         $exchange_rates = new currency();
         $exchange_rates->btn_update();
     }
 }
 if (AUTO_UPDATE_PERIOD) {
     gen_auto_update_period();
 }
 gen_add_audit_log(GEN_LOG_LOGIN . $admin_name);
 // check for session timeout to reload to requested page
 $get_params = '';
 if (isset($_SESSION['pb_cat'])) {
     $get_params = 'cat=' . $_SESSION['pb_cat'];
     $get_params .= '&module=' . $_SESSION['pb_module'];