install/includes/payload.php
changeset 626 be0e904eec17
parent 616 e311f5e6f904
child 627 460e483987ab
equal deleted inserted replaced
625:0122f538c242 626:be0e904eec17
   420     @unlink(ENANO_ROOT . '/.htaccess.new');
   420     @unlink(ENANO_ROOT . '/.htaccess.new');
   421   }
   421   }
   422   return true;
   422   return true;
   423 }
   423 }
   424 
   424 
       
   425 /**
       
   426  * UPGRADE STAGES
       
   427  */
       
   428 
       
   429 function stg_lang_import()
       
   430 {
       
   431   global $db, $languages;
       
   432   
       
   433   define('IN_ENANO_UPGRADE_POST', 1);
       
   434   
       
   435   //
       
   436   // IMPORT NEW STRINGS
       
   437   //
       
   438   
       
   439   // for each installed language, look for the json files in the filesystem and if they're ok, import new strings from them
       
   440   $q = $db->sql_query('SELECT lang_id, lang_code FROM ' . table_prefix . "language;");
       
   441   if ( !$q )
       
   442     $db->_die();
       
   443   
       
   444   while ( $row = $db->fetchrow($q) )
       
   445   {
       
   446     if ( isset($languages[$row['lang_code']]) )
       
   447     {
       
   448       // found a language and it's good on the filesystem; load it and call a reimport
       
   449       $lang_local = new Language($row['lang_id']);
       
   450       // call fetch to make sure we're up to date
       
   451       $lang_local->fetch();
       
   452       // import
       
   453       foreach ( array('core', 'admin', 'user', 'tools') as $language_file )
       
   454       {
       
   455         // generate full path
       
   456         $language_file = ENANO_ROOT . "/language/{$languages[$row['lang_code']]['dir']}/$language_file.json";
       
   457         // setting the second parameter to bool(true) causes it to skip existing strings
       
   458         if ( !$lang_local->import($language_file, true) )
       
   459           // on failure, report failure to libenanoinstall
       
   460           return false;
       
   461       }
       
   462       // unload this lang_local object to save memory
       
   463       unset($lang_local);
       
   464     }
       
   465   }
       
   466   
       
   467   return true;
       
   468 }
       
   469 
       
   470 function stg_flush_cache()
       
   471 {
       
   472   return purge_all_caches();
       
   473 }
       
   474 
       
   475 function stg_set_version()
       
   476 {
       
   477   global $db;
       
   478   // log the upgrade
       
   479   $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,page_text,edit_summary) VALUES'
       
   480          . '(\'security\', \'upgrade_enano\', ' . time() . ', \'[DEPRECATED]\', \'' . $db->escape($session->username) . '\', \'' . $db->escape($this_version) . '\', \'' . $db->escape($_SERVER['REMOTE_ADDR']) . '\');');
       
   481   if ( !$q )
       
   482   {
       
   483     $db->_die();
       
   484     return false;
       
   485   }
       
   486   setConfig('enano_version', installer_enano_version());
       
   487   return true;
       
   488 }