diff --git a/include/upgrader/upgrade.inc.php b/include/upgrader/upgrade.inc.php index fae6947d94849c6cfbd4a7df849df708e470f1de..b157b6a030e4e0e23165a4a5720e31fe114ea133 100644 --- a/include/upgrader/upgrade.inc.php +++ b/include/upgrader/upgrade.inc.php @@ -1,5 +1,16 @@ <?php if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied'); + +//See if we need to switch the mode of upgrade...e.g from ajax (default) to manual +if(($mode = $ost->get_var('m', $_GET)) && $mode!=$upgrader->getMode()) { + //Set Persistent mode/ + $upgrader->setMode($mode); + //Log warning about ajax calls - most likely culprit is AcceptPathInfo directive. + if($mode=='manual') + $ost->logWarning('Ajax calls are failing', + 'Make sure your server has AcceptPathInfo directive set to "ON" or get technical help'); +} + $action=$upgrader->getNextAction(); ?> <h2>osTicket Upgrade</h2> @@ -9,7 +20,7 @@ $action=$upgrader->getNextAction(); <p>Thank you for taking the time to upgrade your osTicket intallation!</p> <p>Please don't cancel or close the browser, any errors at this stage will be fatal.</p> </div> - <h2><?php echo $action ?></h2> + <h2 id="task"><?php echo $action ?></h2> <p>The upgrade wizard will now attempt to upgrade your database and core settings!</p> <ul> <li>Database enhancements</li> @@ -20,8 +31,9 @@ $action=$upgrader->getNextAction(); <form method="post" action="upgrade.php" id="upgrade"> <?php csrf_token(); ?> <input type="hidden" name="s" value="upgrade"> + <input type="hidden" id="mode" name="m" value="<?php echo $upgrader->getMode(); ?>"> <input type="hidden" name="sh" value="<?php echo $upgrader->getSchemaSignature(); ?>"> - <input class="btn" type="submit" name="submit" value="Do It Now!"> + <input class="btn" type="submit" name="submit" value="Upgrade Now!"> </form> </div> </div> @@ -33,9 +45,11 @@ $action=$upgrader->getNextAction(); </div> <div class="clear"></div> <div id="upgrading"> - <h4><?php echo $action; ?></h4> + <h4 id="action"><?php echo $action; ?></h4> Please wait... while we upgrade your osTicket installation! - <div id="msg" style="font-weight: bold;padding-top:10px;">Smile!</div> + <div id="msg" style="font-weight: bold;padding-top:10px;"> + <?php echo sprintf("%s - Relax!", $thisstaff->getFirstName()); ?> + </div> </div> </div> -<div class="clear"></div>` +<div class="clear"></div> diff --git a/scp/js/upgrader.js b/scp/js/upgrader.js index 1631ac5cd5a7a156498f44e6f13020dae875dde2..2ac77d99f86c5db1b2a54d36f4afc709e2b9bad5 100644 --- a/scp/js/upgrader.js +++ b/scp/js/upgrader.js @@ -1,5 +1,5 @@ jQuery(function($) { - + $("#overlay").css({ opacity : 0.3, top : 0, @@ -12,18 +12,21 @@ jQuery(function($) { top : ($(window).height() / 3), left : ($(window).width() / 2 - 160) }); - + $('form#upgrade').submit(function(e) { - e.preventDefault(); var form = $(this); $('input[type=submit]', this).attr('disabled', 'disabled'); $('#overlay, #upgrading').show(); - doTasks('upgrade.php',form.serialize()); - - return false; - }); + if($('input#mode', form).val() == 'manual') { + return true; + } else { + e.preventDefault(); + autoUpgrade('upgrade.php',form.serialize()); + return false; + } + }); - function doTasks(url, data) { + function autoUpgrade(url, data) { function _lp(count) { $.ajax({ type: 'POST', @@ -33,26 +36,34 @@ jQuery(function($) { data: data, dataType: 'text', success: function(res) { - if (res) { - $('#loading #msg').html(res); - } + $('#main #task').html(res); + $('#upgrading #action').html(res); + $('#upgrading #msg').html('Still busy... smile #'+count); }, statusCode: { 200: function() { - setTimeout(function() { _lp(count+1); }, 2); + setTimeout(function() { _lp(count+1); }, 200); }, 201: function() { - $('#loading #msg').html("We're done... cleaning up!"); + $('#upgrading #msg').html("Cleaning up!..."); setTimeout(function() { location.href =url+'?c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 3000); } }, - error: function() { - $('#loading #msg').html("Something went wrong"); - setTimeout(function() { location.href =url+'?c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 1000); + error: function(jqXHR, textStatus, errorThrown) { + $('#upgrading #action').html('Error occurred. Aborting...'); + switch(jqXHR.status) { + case 404: + $('#upgrading #msg').html("Manual upgrade required (ajax failed)"); + setTimeout(function() { location.href =url+'?m=manual&c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 2000); + break; + default: + $('#upgrading #msg').html("Something went wrong"); + setTimeout(function() { location.href =url+'?c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 2000); + } } }); }; - _lp(0); + _lp(1); } });