Now regenerate template.sql, using something like '.escape_html($cmd).' > ~/public_html/uploads/website_specific/ocportal.com/myocp/template.sql
'; up_do_footer(); return; } } $show_more_link=true; switch ($type) { case 'misc': clear_caches_1(); $l_choices=do_lang('FU_CHOICES'); $oc=(get_option('site_closed')=='0')?do_lang('SITE_OPEN'):do_lang('SITE_CLOSED'); $a=float_to_raw_string(ocp_version_number(),10,true); $b=get_value('version'); $b=float_to_raw_string(floatval($b),10,true); // Normalise decimal places $l_up_info=do_lang('FU_UP_INFO'.(($a==$b)?'_1':'_2'),$a,$b); $l_fu_closedness=do_lang('FU_CLOSENESS',$oc); $l_maintenance=do_lang('FU_MAINTENANCE'); $l_upgrading=do_lang('FU_UPGRADING'); $l_take_backup=do_lang('FU_TAKE_BACKUP'); $l_clear_caches=fu_link('upgrader.php?type=decache',do_lang('FU_CLEAR_CACHES')); $l_check_permissions=fu_link('upgrader.php?type=check_perms',do_lang('FU_CHECK_PERMISSIONS')); $l_fix_permissions=fu_link('upgrader.php?type=fix_perms',do_lang('FU_FIX_PERMISSIONS')); $l_close_site=fu_link('upgrader.php?type=close_site',do_lang('FU_CLOSE_SITE'),get_option('site_closed')=='1'); $l_integrity_scan=fu_link('upgrader.php?type=integrity_scan&allow_merging=1',do_lang('FU_INTEGRITY_SCAN'),false,do_lang('FU_WILL_MERGE')); $l_integrity_scan_no_merging=fu_link('upgrader.php?type=integrity_scan',do_lang('FU_INTEGRITY_SCAN_NO_CSS_MERGE')); $l_database_upgrade=fu_link('upgrader.php?type=db_upgrade',do_lang('FU_DATABASE_UPGRADE')); $l_theme_upgrade=fu_link('upgrader.php?type=theme_upgrade',do_lang('FU_THEME_UPGRADE')); $l_open_site=fu_link('upgrader.php?type=open_site',do_lang('FU_OPEN_SITE'),get_option('site_closed')=='0'); $l_error_correction=do_lang('FU_ERROR_CORRECTION'); $l_not_for_patch=do_lang('FU_NOT_FOR_PATCH'); $l_tutorial=fu_link('http://ocportal.com/docs/tut_upgrade.htm',do_lang('FU_TUTORIAL')); $l_release_notes=do_lang('FU_RELEASE_NOTES'); $l_refer_release_notes=do_lang('FU_REFER_RELEASE_NOTES'); $news_id=post_param_integer('news_id',NULL); $tar_url=''; if (!is_null($news_id)) { require_code('files'); $fetch_url='http://ocportal.com/uploads/website_specific/ocportal.com/scripts/fetch_release_details.php?news_id='.strval($news_id).'&from_version='.urlencode(strval(ocp_version()).'.'.ocp_version_minor()); $news=http_download_file($fetch_url,NULL,true,false,'ocPortal',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,30.0); $details=unserialize($news); if ($details[0]!='') $l_refer_release_notes=$details[0].'{$l_choices}
{$l_bugs}
{$l_refer_release_notes}
{$l_step} | {$l_action} | {$l_estimated_time} |
---|---|---|
X | {$l_not_for_patch} {$l_tutorial} | ".escape_html(display_time_period(60*120))." |
1 | {$l_take_backup} | ".escape_html(display_time_period(60*120))." |
2 | {$l_close_site} {$l_fu_closedness}".$closed->evaluate()."[evaluate())."\" title=\"(this link will open in a new window)\" target=\"_blank\">".do_lang('CHANGE')."] | ".escape_html(display_time_period(60))." |
3 | {$l_download} | ".escape_html(display_time_period(60*5))." |
4 | {$l_not_for_patch} {$l_integrity_scan_no_merging} | ".str_replace(' ',' ',escape_html(display_time_period(60*10)))." † |
5 | {$l_not_for_patch} {$l_database_upgrade} {$l_up_info} | ".escape_html(display_time_period(60*5))." |
6 | {$l_not_for_patch} {$l_theme_upgrade} | ".escape_html(display_time_period(60*5))." |
7 | {$l_clear_caches} | 1 minute |
8 | {$l_open_site} {$l_fu_closedness} | 1 minute |
† {$l_customisations}
'.do_lang('SUCCESS').'
'; break; case 'check_perms': echo check_perms(); break; case 'fix_perms': echo fix_perms(); break; case 'open_site': set_option('site_closed','0'); echo ''.do_lang('SUCCESS').'
'; break; case 'close_site': set_option('closed',do_lang('FU_CLOSED_FOR_UPGRADES',get_site_name())); set_option('site_closed','1'); echo ''.do_lang('SUCCESS').'
'; break; case 'file_upgrade': require_code('version2'); $personal_upgrader_url='http://compo.sr/uploads/website_specific/compo.sr/scripts/build_personal_upgrader.php?from='.urlencode(get_version_dotted()); $hooks=find_all_hooks('systems','addon_registry'); foreach (array_keys($hooks) as $hook) { if (is_file(get_file_base().'/sources/hooks/systems/addon_registry/'.$hook.'.php')) { $personal_upgrader_url.='&addon_'.$hook.'=1'; } } if (get_param('tar_url','')=='') echo do_lang('FU_FILE_UPGRADE_INFO'); echo do_lang('FU_FILE_UPGRADE_INFO_MANUAL',escape_html($personal_upgrader_url)); echo ''; $show_more_link=false; break; case '_file_upgrade': require_code('tar'); if (function_exists('set_time_limit')) @set_time_limit(0); if ((post_param('url','')=='') && ((ocp_srv('HTTP_HOST')=='ocportal.com') || ($GLOBALS['DEV_MODE']))) { $temp_path=$_FILES['upload']['tmp_name']; } else { if (post_param('url','')=='') warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); $temp_path=ocp_tempnam('ocpfu'); $url=post_param('url'); if (substr($url,0,strlen(get_base_url().'/'))==get_base_url().'/') { unlink($temp_path); copy(get_custom_file_base().'/'.rawurldecode(substr($url,strlen(get_base_url().'/'))),$temp_path); } else { $myfile=fopen($temp_path,'wb'); http_download_file($url,NULL,true,false,'ocPortal',NULL,NULL,NULL,NULL,NULL,$myfile); fclose($myfile); } } $upgrade_resource=tar_open($temp_path,'rb'); //tar_extract_to_folder($upgrade_resource,'',true); disable_php_memory_limit(); $directory=tar_get_directory($upgrade_resource); // Uses up to around 5MB $data=array('todo'=>array()); $popup_simple_extract=(_ftp_info()===false); if (!$popup_simple_extract) echo ''.do_lang('EXTRACTING_MESSAGE').'
'; $addon_contents=array(); // Find addons foreach ($directory as $upgrade_file2) { // See if we can find an addon registry file in our upgrade TAR if ((strpos($upgrade_file2['path'],'/addon_registry/')!==false) && (substr($upgrade_file2['path'],-4)=='.php')) { $file_data=tar_get_file($upgrade_resource,$upgrade_file2['path']); $addon_contents[basename($upgrade_file2['path'],'.php')]=$file_data['data']; } } // Process files foreach ($directory as $offset=>$upgrade_file) { // skip over these, from manually installer package (which may be used for an upgrade) if ($upgrade_file['path']=='info.php') continue; if ($upgrade_file['path']=='install.php') continue; if ($upgrade_file['path']=='install.sql') continue; if ($upgrade_file['path']=='info.php.template') continue; if (!$popup_simple_extract) { // See if we can skip the file, if the on-disk version is identical? if ((file_exists(get_file_base().'/'.$upgrade_file['path'])) && (filesize(get_file_base().'/'.$upgrade_file['path'])==$upgrade_file['size'])) { $tar_data=tar_get_file($upgrade_resource,$upgrade_file['path']); if (file_get_contents(get_file_base().'/'.$upgrade_file['path'])==$tar_data['data']) { echo do_lang('U_SKIPPING_MESSAGE',escape_html($upgrade_file['path'])).''.do_lang('FU_EXTRACTING_WINDOW',integer_format(count($data['todo']))).'
'; echo ''; } else { echo ''.do_lang('SUCCESS').'
'; @unlink($temp_path); } unset($_POST['news_id']); break; case 'integrity_scan': $allow_merging=either_param_integer('allow_merging',0); echo run_integrity_check(false,$allow_merging==1); break; case '_integrity_scan': _integrity_scan(); echo ''.do_lang('SUCCESS').'
'; break; case 'db_upgrade': $something_done=false; clear_caches_2(); if (version_specific()) { echo do_lang('FU_UPGRADED_CORE_TABLES'); $something_done=true; } $done=upgrade_modules(); if ($done!='') { echo do_lang('FU_UPGRADE_MODULES',$done); $something_done=true; } if (!$something_done) echo do_lang('NO_UPGRADE_DONE'); $version_files=ocp_version_number(); $_version_database=get_value('ocf_version'); $version_database=floatval($_version_database); if (is_null($_version_database)) $version_database=2.1; // Either 2.0 or 2.1, and they are equivalent in terms of what we need to do if ($version_database<$version_files) echo do_lang('FU_MUST_UPGRADE_OCF',fu_link('upgrader.php?type=ocf',do_lang('FU_UPGRADE_OCF'))); break; case 'theme_upgrade': echo upgrade_themes(); break; case 'ocf': // Only to be launched as a consequent of db_upgrade if (ocf_upgrade()) echo ''.do_lang('SUCCESS').'
'; else echo do_lang('FU_NO_OCF_UPGRADE'); break; } if ($show_more_link) { echo ''.$message.'
'; $news_id=get_param_integer('news_id',NULL); $url="upgrader.php?type=".escape_html($type); if (get_param_integer('keep_safe_mode',0)==1) $url.='&keep_safe_mode=1'; if (get_param_integer('keep_show_loading',0)==1) $url.='&keep_show_loading=1'; echo "{$l_login_info}
"; echo "{$l_login_info_pass_forget}
{$upgrader_intro}
'.$error.'
'; } $super_out.=''.do_lang('SUCCESS').'
'; $GLOBALS['SUPPRESS_ERROR_DEATH']=false; return $super_out; } /** * Tell the user about any modules that need moving again (because the ocp ones haven't moved). * * @return array Pair: HTML list of moved files, raw list */ function move_modules() { $out=''; $outr=array(); $zones=find_all_zones(); foreach ($zones as $zone) { $pages=find_all_pages($zone,'modules'); foreach (array_keys($pages) as $page) { // See if this isn't the true home of the module foreach ($zones as $zone2) { $_path_a=$zone2.'/pages/modules/'.$page.'.php'; // potential true home $_path_b=$zone.'/pages/modules/'.$page.'.php'; // where it is now $path_a=zone_black_magic_filterer(get_file_base().'/'.$_path_a); $path_b=zone_black_magic_filterer(get_file_base().'/'.$_path_b); if (($zone2!=$zone) && (file_exists($path_a)) && (filemtime($path_a)>=filemtime($path_b))) { if (($page=='filedump') && ($zone2=='cms')) continue; // This has moved between versions $out.='✗ '.$error->evaluate().'
'; $has_errors=true; } foreach ($successes as $success) { $str.='✓ '.$success->evaluate().'
'; } } if ($test_run) { if ($has_errors) { $str.=''.do_lang('FU_THEME_ERRORS').'
'; } $l_theme_upgrade=fu_link('upgrader.php?type=theme_upgrade&live_run=1',do_lang('FU_THEME_UPGRADE_FINAL')); $str.=$l_theme_upgrade; } return $str; } /** * Upgrade a theme automatically, using hand-coded migration arrays. * * @param ID_TEXT Theme to be upgraded * @param float From version * @param float Target version * @param boolean Whether executing a test run (i.e. not do anything) * @return array A pair: List of errors, List of successes */ function upgrade_theme($theme,$from_version,$to_version,$test_run=true) { $errors=array(); $successes=array(); if (!$test_run) { require_code('abstract_file_manager'); force_have_afm_details(); } $css_replace__single_match=array(); $css_prepend__single_match=array(); $css_append__single_match=array(); $css_replace__multi_match=array(); $css_prepend__multi_match=array(); $css_append__multi_match=array(); $css_file_append=array(); $theme_images_new=array(); $theme_images_renames=array(); $templates_replace=array(); $templates_rename=array(); $templates_borked=array(); // TODO: Implement upgrade for next version if (false) { $css_recognition_string='2004-2011'; // Must be defined. Ensures theme is right version. $css_replace__multi_match=array( '*'=>array( ), 'global.css'=>array( ), ); $css_replace__single_match=array( ); $css_prepend__single_match=array( ); $css_append__single_match=array( ); $css_file_append=array( ); // NB: This UNIX command can work out what theme images are added... // OLD=/Library/WebServer/Documents/test/themes/default/images ; NEW=/Library/WebServer/Documents/git/themes/default/images ; diff -r $OLD $NEW | grep "Only in $NEW" | grep -v .DS_Store | sed "s#Only in "$NEW"##g" | sed "s#: #/#g" | sed "s#^/##g" | sed "s#^EN/##g" | sed "s#\.*$##" // Obviously only theme-wizable images should go here $theme_images_new=array( ); $theme_images_renames=array( ); $templates_replace=array( '*'=>array( ), ); /*Find deleted/renamed templates: OLD=/Library/WebServer/Documents/test/themes/default/templates ; NEW=/Library/WebServer/Documents/git/themes/default/templates ; diff -r $OLD $NEW | grep .tpl$ | grep "Only in "$OLD | sed "s#Only in "$OLD": ##"*/ $templates_rename=array( ); /*Find diff of changes templates OLD=/Library/WebServer/Documents/test/themes/default/templates ; NEW=/Library/WebServer/Documents/git/themes/default/templates ; diff -u $OLD $NEW > ~/Desktop/diff.txt*/ $templates_borked=array( ); } else { $errors[]=do_lang_tempcode('NO_DEFINED_THEME_UPGRADER'); return array($errors,array()); } if (addon_installed('themewizard')) { require_code('themewizard'); $seed=find_theme_seed($theme); $dark=find_theme_dark($theme); list($colours,$landscape)=calculate_theme($seed,'default','equations','colours',$dark); } // CSS $css_dir=get_custom_file_base().'/themes/'.filter_naughty($theme).'/css_custom/'; $dh=@opendir($css_dir); if ($dh!==false) { while (($css_file=readdir($dh))!==false) { if (substr($css_file,-4)!='.css') continue; if (substr($css_file,0,1)=='.') continue; $css_file_contents=file_get_contents($css_dir.$css_file); $orig_css_file_contents=$css_file_contents; if (strpos($css_file_contents,$css_recognition_string)===false) { $errors[]=do_lang_tempcode('NON_RECOGNISED_CSS_FILE',escape_html($css_file),escape_html(float_to_raw_string($from_version))); //continue; Actually we'll let it pass } // Apply single match rules. First check single match rules apply exactly once (means rule is bogus if it matches more than once, or unusable if not at all) foreach (array('css_replace'=>$css_replace__single_match,'css_prepend'=>$css_prepend__single_match,'css_append'=>$css_append__single_match) as $rule_set_type=>$rule_set) { foreach ($rule_set as $target_file=>$_rule_set) { // If people have moved CSS into global.css, to optimise page load times if (($target_file!='*') && ($target_file!='global.css') && ($css_file=='global.css')) { if ((file_exists($css_dir.$target_file)) && (strlen(trim(file_get_contents($css_dir.$target_file)))==0)) { $target_file='global.css'; } } if (($target_file=='*') || ($target_file==$css_file)) { foreach ($_rule_set as $from=>$to) { // Apply theme wizard to $to if (addon_installed('themewizard')) $to=theme_wizard_colours_to_css($to,$landscape,'default','equations',$seed); $occurrences=substr_count($css_file_contents,$from); if ($occurrences==0) // Try after applying theme wizard { if (addon_installed('themewizard')) { $from=theme_wizard_colours_to_css($from,$landscape,'default','equations',$seed); $occurrences=substr_count($css_file_contents,$from); } } if ($occurrences==0) { $errors[]=do_lang_tempcode('CSS_RULE_UNMATCHED_'.$rule_set_type,escape_html($from),escape_html($to),escape_html($target_file)); } elseif ($occurrences>1) { $errors[]=do_lang_tempcode('CSS_RULE_OVERMATCHED_'.$rule_set_type,escape_html($from),escape_html($to),escape_html($target_file)); } else { switch ($rule_set_type) { case 'css_replace': $css_file_contents=str_replace($from,$to,$css_file_contents); break; case 'css_prepend': $pos=strpos($css_file_contents,$from); if (substr($css_file_contents,$pos-strlen($to),strlen($to))!=$to) { $css_file_contents=substr($css_file_contents,0,$pos).$to.substr($css_file_contents,$pos); } break; case 'css_append': $pos=strpos($css_file_contents,$from)+strlen($from); if (substr($css_file_contents,$pos,strlen($to))!=$to) { $css_file_contents=substr($css_file_contents,0,$pos).$to.substr($css_file_contents,$pos); } break; } } } } } } // Apply multi-match rules foreach (array('css_replace'=>$css_replace__multi_match,'css_prepend'=>$css_prepend__multi_match,'css_append'=>$css_append__multi_match) as $rule_set_type=>$rule_set) { foreach ($rule_set as $target_file=>$_rule_set) { if (($target_file=='*') || ($target_file==$css_file)) { foreach ($_rule_set as $from_a=>$to) { // Apply theme wizard to $to if (addon_installed('themewizard')) $to=theme_wizard_colours_to_css($to,$landscape,'default','equations',$seed); $froms=array($from_a); if (addon_installed('themewizard')) $froms[]=theme_wizard_colours_to_css($from_a,$landscape,'default','equations',$seed); foreach ($froms as $from) { switch ($rule_set_type) { case 'css_replace': $css_file_contents=str_replace($from,$to,$css_file_contents); break; case 'css_prepend': $pos=0; do { $pos=strpos($css_file_contents,$from,$pos); if ($pos!==false) { if (substr($css_file_contents,$pos,-strlen($to))!=$to) { $css_file_contents=substr($css_file_contents,0,$pos).$to.substr($css_file_contents,$pos); $pos+=strlen($to)+strlen($from); } else { $pos+=strlen($from); } } } while ($pos!==false); break; case 'css_append': $pos=0; do { $pos=strpos($css_file_contents,$from,$pos); if ($pos!==false) { if (substr($css_file_contents,$pos,strlen($to))!=$to) { $pos+=strlen($from); $css_file_contents=substr($css_file_contents,0,$pos).$to.substr($css_file_contents,$pos); $pos+=strlen($to); } else { $pos+=strlen($from); } } } while ($pos!==false); break; } } } } } } // Apply unmatched rules foreach ($css_file_append as $target_file=>$rule_set) { if (($target_file=='*') || ($target_file==$css_file)) { foreach ($rule_set as $to) { $css_file_contents.=$to; } } } if (!$test_run) { // Take revision $revision_file=$css_dir.$css_file.'.'.strval(time()); if (@copy($css_dir.$css_file,$revision_file)!==false) { fix_permissions($revision_file); sync_file($revision_file); } // Save if ($orig_css_file_contents!=$css_file_contents) { $outfile=@fopen($css_dir.$css_file,'wb') OR intelligent_write_error($css_dir.$css_file); fwrite($outfile,$css_file_contents); fclose($outfile); } $successes[]=do_lang_tempcode('CSS_FILE_UPGRADED',escape_html($css_file)); } } closedir($dh); } // Theme images require_code('themes2'); $langs=array('EN'=>'lang');//find_all_langs(); foreach ($theme_images_renames as $old=>$new) { foreach (array_keys($langs) as $lang) { $path=urldecode(find_theme_image($old,true,true,$theme,$lang)); if ($path!='') { $new_path=str_replace('/'.$old,'/'.$new,$path); if (!$test_run) { if (!file_exists(get_custom_file_base().'/'.$new_path)) { if (file_exists($path)) afm_move($path,$new_path); $where_map=array('theme'=>$theme,'id'=>$new); if (($lang!='') && (!is_null($lang))) $where_map['lang']=$lang; $GLOBALS['SITE_DB']->query_delete('theme_images',$where_map); actual_edit_theme_image($old,$theme,$lang,$new,$new_path); $successes[]=do_lang_tempcode('THEME_IMAGE_RENAMED',escape_html($old),escape_html($new)); } } } } } if (addon_installed('themewizard')) { if ($theme!='default') { foreach ($theme_images_new as $new) { foreach (array_keys($langs) as $lang) { $path=urldecode(find_theme_image($new,true,true,'default',$lang)); if ($path!='') { $new_path=str_replace('themes/default/images/','themes/'.$theme.'/images/',$path); if (!file_exists(get_custom_file_base().'/'.$new_path)) { if (!$test_run) { afm_make_directory(dirname($new_path),true,true); } $image=calculate_theme($seed,'default','equations',$new,$dark,$colours,$landscape,$lang); if (!is_null($image)) { if (!$test_run) { @imagepng($image,get_custom_file_base().'/'.$new_path) OR intelligent_write_error(get_custom_file_base().'/'.$new_path); imagedestroy($image); fix_permissions(get_custom_file_base().'/'.$new_path); sync_file(get_custom_file_base().'/'.$new_path); $successes[]=do_lang_tempcode('THEME_IMAGE_NEW',escape_html($new)); } } } } } } } } // Templates $templates_dir=get_custom_file_base().'/themes/'.filter_naughty($theme).'/templates_custom/'; $dh=@opendir($templates_dir); if ($dh!==false) { while (($templates_file=readdir($dh))!==false) { if (substr($templates_file,-4)!='.tpl') continue; $templates_file_contents=file_get_contents($templates_dir.$templates_file); $orig_templates_file_contents=$templates_file_contents; foreach ($templates_replace as $target_file=>$rule_set) { if (($target_file=='*') || ($target_file==$templates_file)) { foreach ($rule_set as $from=>$to) { $templates_file_contents=str_replace($from,$to,$templates_file_contents); } } } if (array_key_exists($templates_file,$templates_rename)) { if (!$test_run) { @rename($templates_dir.$templates_file,$templates_dir.$templates_rename[$templates_file]) OR intelligent_write_error($templates_dir.$templates_rename[$templates_file]); $successes[]=do_lang_tempcode('TEMPLATE_RENAMED',escape_html($templates_file),escape_html($templates_rename[$templates_file])); } $templates_file=$templates_rename[$templates_file]; } if ($templates_file_contents!=$orig_templates_file_contents) { if (!$test_run) { $successes[]=do_lang_tempcode('TEMPLATE_ALTERED',escape_html($templates_file)); // Save $outfile=@fopen($templates_dir.$templates_file,'wb') OR intelligent_write_error($templates_dir.$templates_file); fwrite($outfile,$templates_file_contents); fclose($outfile); } } if (in_array($templates_file,$templates_borked)) { $errors[]=do_lang_tempcode('TEMPLATE_WILL_NEED_RESTORING',escape_html($templates_file)); } } closedir($dh); } return array($errors,$successes); } /** * Upgrade shared installs. * * @param integer Position to proceed from */ function upgrade_sharedinstall_sites($from=0) { global $CURRENT_SHARE_USER,$SITE_INFO,$TABLE_LANG_FIELDS; // Find sites $sites=array(); foreach (array_keys($SITE_INFO) as $key) { $matches=array(); if (preg_match('#^custom_user_(.*)#',$key,$matches)!=0) { $sites[]=$matches[1]; } } disable_php_memory_limit(); $total=count($sites); foreach ($sites as $i=>$site) { if (function_exists('set_time_limit')) @set_time_limit(0); if (($i<$from) && ($site!='shareddemo')) continue; // Change active site $CURRENT_SHARE_USER=$site; $TABLE_LANG_FIELDS=array(); _general_db_init(); // Reset DB $GLOBALS['SITE_DB']=new database_driver(get_db_site(),get_db_site_host(),get_db_site_user(),get_db_site_password(),get_table_prefix()); $GLOBALS['FORUM_DB']=$GLOBALS['SITE_DB']; // NB: File path will be ok // NB: Other internal caching could need changing in the future, but works at time of writing // Go! automate_upgrade(); echo 'Upgraded '.escape_html($site).' ('.escape_html(number_format($i+1).' of '.number_format($total)).')