From edbf467232f03fb3f0d4f9ab7db517932fae33be Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Thu, 5 Jul 2012 11:01:56 -0400 Subject: [PATCH] Require config file rename when upgrading from v1.6 RC5 based installations --- include/upgrader/rename.inc.php | 33 +++++++++++++++++++++++++++++++++ main.inc.php | 7 +++++-- scp/admin.inc.php | 11 +++++++++-- scp/staff.inc.php | 2 +- scp/upgrade.php | 16 ++++++++++------ 5 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 include/upgrader/rename.inc.php diff --git a/include/upgrader/rename.inc.php b/include/upgrader/rename.inc.php new file mode 100644 index 000000000..6d449567f --- /dev/null +++ b/include/upgrader/rename.inc.php @@ -0,0 +1,33 @@ +<?php +if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied'); +?> +<div id="upgrader"> + <br> + <h2 style="color:#FF7700;">Configuration file rename required!</h2> + <div id="main"> + <div id="intro"> + <p>To avoid possible conflicts, please take a minute to rename configuration file as shown below.</p> + </div> + <h3>Solution:</h3> + Rename file <b>include/settings.php</b> to <b>include/ost-config.php</b> and click continue below. + <ul> + <li><b>CLI:</b><br><i>mv include/settings.php include/ost-config.php</i></li> + <li><b>FTP:</b><br> </li> + <li><b>Cpanel:</b><br> </li> + </ul> + <p>Please refer to the <a target="_blank" href="http://osticket.com/wiki/Upgrade_and_Migration">Upgrade Guide</a> for more information.</p> + <div id="bar"> + <form method="post" action="upgrade.php"> + <input type="hidden" name="s" value="prereq"> + <input class="btn" type="submit" name="submit" value="Continue »"> + </form> + </div> + </div> + <div id="sidebar"> + <h3>Need Help?</h3> + <p> + If you are looking for a greater level of support, we provide <u>professional upgrade</u> and commercial support with guaranteed response times, and access to the core development team. We can also help customize osTicket or even add new features to the system to meet your unique needs. <a target="_blank" href="http://osticket.com/support/professional_services.php">Learn More!</a> + </p> + </div> + <div class="clear"></div> +</div> diff --git a/main.inc.php b/main.inc.php index 31b044f4b..b27bea15d 100644 --- a/main.inc.php +++ b/main.inc.php @@ -70,9 +70,12 @@ $configfile=''; if(file_exists(ROOT_DIR.'ostconfig.php')) //Old installs prior to v 1.6 RC5 $configfile=ROOT_DIR.'ostconfig.php'; - elseif(file_exists(INCLUDE_DIR.'settings.php')) //OLD config file.. v 1.6 RC5 + elseif(file_exists(INCLUDE_DIR.'settings.php')) { //OLD config file.. v 1.6 RC5 $configfile=INCLUDE_DIR.'settings.php'; - elseif(file_exists(INCLUDE_DIR.'ost-config.php')) //NEW config file v 1.6 stable ++ + //Die gracefully on upgraded v1.6 RC5 installation - otherwise script dies with confusing message. + if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']), 'settings.php')) + die('Please rename config file include/settings.php to include/ost-config.php to continue!'); + } elseif(file_exists(INCLUDE_DIR.'ost-config.php')) //NEW config file v 1.6 stable ++ $configfile=INCLUDE_DIR.'ost-config.php'; elseif(file_exists(ROOT_DIR.'setup/')) header('Location: '.ROOT_PATH.'setup/'); diff --git a/scp/admin.inc.php b/scp/admin.inc.php index acd63ed41..28db6fab7 100644 --- a/scp/admin.inc.php +++ b/scp/admin.inc.php @@ -34,13 +34,20 @@ if($ost->isUpgradePending()) { } } else { - if(file_exists('../setup/')) { + if(!strcasecmp(basename(CONFIG_FILE), 'settings.php')) { + $sysnotice=sprintf('Please rename config file include/%s to include/ost-config.php to avoid possible conflicts', + basename(CONFIG_FILE)); + //Die gracefully - otherwise upgraded RC5 installations will die with confusing message. + if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']), 'settings.php')) + die($sysnotice); + + } elseif(file_exists('../setup/')) { $sysnotice='Please take a minute to delete <strong>setup/install</strong> directory (../setup/) for security reasons.'; } elseif(CONFIG_FILE && file_exists(CONFIG_FILE) && is_writable(CONFIG_FILE)) { //Confirm for real that the file is writable by group or world. clearstatcache(); //clear the cache! $perms = @fileperms(CONFIG_FILE); - if(($perms & 0x0002) || ($perms & 0x0010)) { + if(($perms & 0x0002) || ($perms & 0x0010)) { $sysnotice=sprintf('Please change permission of config file (%s) to remove write access. e.g <i>chmod 644 %s</i>', basename(CONFIG_FILE), basename(CONFIG_FILE)); } diff --git a/scp/staff.inc.php b/scp/staff.inc.php index 93b290a7b..a7d4b5db2 100644 --- a/scp/staff.inc.php +++ b/scp/staff.inc.php @@ -92,7 +92,7 @@ $errors=array(); $msg=$warn=$sysnotice=''; $tabs=array(); $submenu=array(); -$exempt = in_array(basename($_SERVER['SCRIPT_NAME']), array('logout.php', 'ajax.php', 'logs.php')); +$exempt = in_array(basename($_SERVER['SCRIPT_NAME']), array('logout.php', 'ajax.php', 'logs.php', 'upgrade.php')); if($ost->isUpgradePending() && !$exempt) { $errors['err']=$sysnotice='System upgrade is pending <a href="upgrade.php">Upgrade Now</a>'; diff --git a/scp/upgrade.php b/scp/upgrade.php index 19c9b27c2..c424f425c 100644 --- a/scp/upgrade.php +++ b/scp/upgrade.php @@ -22,15 +22,17 @@ $errors=array(); if($_POST && $_POST['s'] && !$upgrader->isAborted()) { switch(strtolower($_POST['s'])) { case 'prereq': - //XXX: check if it's upgradable version?? - if(!$ost->isUpgradePending()) + if(!$ost->isUpgradePending()) { $errors['err']=' Nothing to do! System already upgraded to the current version'; - elseif(!$upgrader->isUpgradable()) + } elseif(!$upgrader->isUpgradable()) { $errors['err']='The upgrader does NOT support upgrading from the current vesion!'; - elseif($upgrader->check_prereq()) { + } elseif(!$upgrader->check_prereq()) { + $errors['prereq']='Minimum requirements not met! Refer to Release Notes for more information'; + } elseif(!strcasecmp(basename(CONFIG_FILE), 'settings.php')) { + $errors['err']='Config file rename required to continue!'; + } else { $upgrader->setState('upgrade'); - } else - $errors['prereq']='Minimum requirements not met!'; + } break; case 'upgrade': //Manual upgrade.... when JS (ajax) is not supported. if($upgrader->getNumPendingTasks()) { @@ -64,6 +66,8 @@ switch(strtolower($upgrader->getState())) { $inc='prereq.inc.php'; if($upgrader->isAborted()) $inc='aborted.inc.php'; + elseif(!strcasecmp(basename(CONFIG_FILE), 'settings.php')) + $inc='rename.inc.php'; elseif(!$ost->isUpgradePending()) $errors['err']='Nothing to do! System already upgraded to <b>'.$ost->getVersion().'</b> with no pending patches to apply.'; elseif(!$upgrader->isUpgradable()) -- GitLab