Exemplo n.º 1
0
 public static function updateUaRules()
 {
     $update_needed = false;
     if (!file_exists(TWIGMO_UA_RULES_FILE)) {
         $update_needed = true;
     } else {
         $rules_serialized = fn_get_contents(TWIGMO_UA_RULES_FILE);
         $md5_on_twigmo = Http::get(TWG_CHECK_UA_UPDATES);
         if (md5($rules_serialized) != $md5_on_twigmo) {
             $update_needed = true;
         }
     }
     if (!$update_needed) {
         return;
     }
     $rules_on_twigmo = Http::get(TWG_UA_RULES);
     fn_twg_write_to_file(TWIGMO_UA_RULES_FILE, $rules_on_twigmo, false);
 }
 /**
  * Update UA rules.
  * Info will be downloaded for store with the certain access_id.
  * If access_id is empty, one of the connected access_id will be used.
  * @param string $access_id
  */
 public static function updateUARules($access_id = '')
 {
     if (!$access_id) {
         $stores = fn_twg_get_stores();
         foreach ($stores as $store) {
             if (!$access_id && !empty($store['access_id'])) {
                 $access_id = $store['access_id'];
             }
             if ($store['is_connected']) {
                 break;
             }
         }
     }
     if (!$access_id) {
         return;
     }
     $ua_url_path = self::PROTOCOL . self::TWIGMO_SERVER . self::SERVER_ROOT_PATH . self::USER_PATH;
     $ua_url_path .= self::getAccessIdPath($access_id) . '/' . self::UA_META_DIR;
     $update_needed = false;
     if (!file_exists(TWIGMO_UA_RULES_FILE)) {
         $update_needed = true;
     } else {
         $rules_serialized = fn_get_contents(TWIGMO_UA_RULES_FILE);
         $md5_on_twigmo = self::_httpRequest($ua_url_path . self::UA_RULES_MD5_FILE, array(), 'GET', false);
         if (md5($rules_serialized) != $md5_on_twigmo) {
             $update_needed = true;
         }
     }
     if (!$update_needed) {
         return;
     }
     $rules_on_twigmo = self::_httpRequest($ua_url_path . self::UA_RULES_FILE, array(), 'GET', false);
     fn_twg_write_to_file(TWIGMO_UA_RULES_FILE, $rules_on_twigmo, false);
 }
Exemplo n.º 3
0
function fn_twg_save_version_info($version_info)
{
    fn_twg_write_to_file(TWIGMO_UPGRADE_DIR . TWIGMO_UPGRADE_VERSION_FILE, $version_info);
}
Exemplo n.º 4
0
 public static function backupSettings($upgrade_dirs)
 {
     // Backup addon's settings to the session
     $_SESSION['twigmo_backup_settings'] = TwigmoSettings::get();
     // Backup twigmo blocks
     $old_company_id = Registry::get('runtime.company_id');
     $old_layout_id = Registry::get('runtime.layout.layout_id');
     foreach ($upgrade_dirs['backup_company_settings'] as $company_id => $dir) {
         Registry::set('runtime.company_id', $company_id);
         $default_layout_id = fn_twg_get_default_layout_id();
         Registry::set('runtime.layout.layout_id', $default_layout_id);
         $location = Location::instance($default_layout_id)->get('twigmo.post');
         if ($location) {
             $exim = Exim::instance($company_id, $default_layout_id);
             if (version_compare(PRODUCT_VERSION, '4.1.1', '>=')) {
                 $content = $exim->export($default_layout_id, array($location['location_id']));
             } else {
                 $content = $exim->export(array($location['location_id']));
             }
             if ($content) {
                 fn_twg_write_to_file($dir . '/blocks.xml', $content, false);
             }
         }
     }
     Registry::set('runtime.company_id', $old_company_id);
     Registry::set('runtime.layout.layout_id', $old_layout_id);
     // Backup twigmo langvars
     $languages = Lang::getLanguages();
     foreach ($languages as $language) {
         // Prepare langvars for backup
         $langvars = Lang::getAllLangVars($language['lang_code']);
         $langvars_formated = array();
         foreach ($langvars as $name => $value) {
             $langvars_formated[] = array('name' => $name, 'value' => $value);
         }
         fn_twg_write_to_file($upgrade_dirs['backup_settings'] . '/lang_' . $language['lang_code'] . '.bak', $langvars_formated);
     }
     if (fn_allowed_for('ULTIMATE')) {
         db_export_to_file($upgrade_dirs['backup_settings'] . 'lang_ult.sql', array(db_quote('?:ult_language_values')), 'Y', 'Y', false, false, false);
     }
     return true;
 }