function admin_upgrade($name = null)
 {
     if (empty($name)) {
         $this->Session->setFlash(__d('upgrader', 'Missing config name', true));
         $this->redirect('/admin');
     }
     clearCache(null, 'models');
     App::import('Lib', 'Upgrader.Upgrader');
     $upgrader = new Upgrader($name);
     $sErrors = $upgrader->check(true);
     if (!$sErrors) {
         $this->Session->setFlash(__d('upgrader', 'The database is valid', true));
         //$this->redirect(array('plugin'=>'upgrader','controller'=>'upgrader','action'=>'index'));
         $this->redirect('/admin');
     }
     $this->set('name', $name);
     //debug($sErrors);
     if (!empty($this->params['named']['start'])) {
         $error = array();
         $step = empty($this->params['named']['step']) ? 1 : $this->params['named']['step'];
         $res = $upgrader->run($error);
         if ($res === 'break') {
             $this->redirect(array('start' => '1', 'step' => $step++));
         }
         if ($res === true) {
             $this->Session->setFlash(__d('upgrader', 'The database has been fixed', true));
             //$this->redirect(array('plugin'=>'upgrader','controller'=>'upgrader','action'=>'index'));
             $this->redirect('/admin');
         } else {
             $this->Session->setFlash(__d('upgrader', 'An error occurred', true) . ' :<ul><li>' . implode('</li><li>', $error) . '</li></ul>');
         }
     }
 }
Пример #2
0
 public static function requireUpgraded($name, $controller)
 {
     if ($controller->params['plugin'] != 'upgrader') {
         $upgrader = new Upgrader($name);
         if ($upgrader->validable() && $upgrader->check()) {
             $controller->redirect(array('plugin' => 'upgrader', 'controller' => 'upgrader', 'action' => 'upgrade', $name, 'admin' => true));
         }
     }
 }
Пример #3
0
 function constructClasses()
 {
     if (in_array('Upgrader', App::objects('plugin')) && !empty($this->params['admin'])) {
         App::import('Lib', 'Upgrader.Upgrader');
         Upgrader::requireUpgraded('Shop', $this);
     }
     return parent::constructClasses();
 }
Пример #4
0
function checkPSVersion()
{
    $upgrader = new Upgrader();
    return $upgrader->checkPSVersion();
}
Пример #5
0
    public function display()
    {
        global $cookie;
        $this->warnDomainName();
        $tab = get_class();
        $protocol = Tools::usingSecureMode() ? 'https' : 'http';
        $isoDefault = Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT')));
        $isoUser = Language::getIsoById(intval($cookie->id_lang));
        $isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
        $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
        $employee = new Employee($cookie->id_employee);
        echo '<div>
		<h1>' . $this->l('Dashboard') . '</h1>
		<hr style="background-color: #812143;color: #812143;" />
		<br />';
        if (@ini_get('allow_url_fopen')) {
            $upgrade = new Upgrader();
            if ($update = $upgrade->checkPSVersion()) {
                echo '<div class="warning warn" style="margin-bottom:30px;"><h3>' . $this->l('New PrestaShop version available') . ' : <a style="text-decoration: underline;" href="' . $update['link'] . '" target="_blank">' . $this->l('Download') . '&nbsp;' . $update['name'] . '</a> !</h3></div>';
            }
        } else {
            echo '<p>' . $this->l('Update notification unavailable') . '</p>';
            echo '<p>&nbsp;</p>';
            echo '<p>' . $this->l('To receive PrestaShop update warnings, you need to activate the <b>allow_url_fopen</b> command in your <b>php.ini</b> config file.') . ' [<a href="http://www.php.net/manual/' . $isoUser . '/ref.filesystem.php">' . $this->l('more info') . '</a>]</p>';
            echo '<p>' . $this->l('If you don\'t know how to do that, please contact your host administrator !') . '</p><br>';
        }
        echo '</div>';
        if ($employee->bo_show_screencast) {
            echo '
			<div id="adminpresentation">
				<iframe src="' . $protocol . '://screencasts.prestashop.com/screencast.php?iso_lang=' . Tools::strtolower($isoUser) . '" style="border:none;width:100%;height:420px;" scrolling="no"></iframe>
				<div id="footer_iframe_home">
					<!--<a href="#">' . $this->l('View more video tutorials') . '</a>-->
					<input type="checkbox" id="screencast_dont_show_again"><label for="screencast_dont_show_again">' . $this->l('don\'t show again') . '</label>
				</div>
			</div>
			<script type="text/javascript">
			$(document).ready(function() {
				$(\'#screencast_dont_show_again\').click(function() {
					if ($(this).is(\':checked\'))
					{
						$.ajax({
							type: \'POST\',
							async: true,
							url: \'ajax.php?toggleScreencast\',
							success: function(data) {
								$(\'#adminpresentation\').slideUp(\'slow\');
							}
						});
					}
				});
			});
			</script>
			<div class="clear"></div><br />';
        }
        echo '
		<div id="column_left">
			<ul class="F_list clearfix">
				<li id="first_block">
					<h4><a href="index.php?tab=AdminCatalog&addcategory&token=' . Tools::getAdminTokenLite('AdminCatalog') . '">' . $this->l('New category') . '</a></h4>
					<p>' . $this->l('Create a new category and organize your products.') . '</p>
				</li>
				<li id="second_block">
					<h4><a href="index.php?tab=AdminCatalog&id_category=1&addproduct&token=' . Tools::getAdminTokenLite('AdminCatalog') . '">' . $this->l('New product') . '</a></h4>
					<p>' . $this->l('Fill up your catalog with new articles and attributes.') . '</p>
				</li>
				<li id="third_block">
					<h4><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('Statistics') . '</a></h4>
					<p>' . $this->l('Manage your activity with a thorough analysis of your e-shop.') . '</p>
				</li>
				<li id="fourth_block">
					<h4><a href="index.php?tab=AdminEmployees&addemployee&token=' . Tools::getAdminTokenLite('AdminEmployees') . '">' . $this->l('New employee') . '</a></h4>
					<p>' . $this->l('Add a new employee account and discharge a part of your duties of shop owner.') . '</p>
				</li>
			</ul>
			';
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT SUM(o.`total_paid_real` / o.conversion_rate) as total_sales, COUNT(*) as total_orders
			FROM `' . _DB_PREFIX_ . 'orders` o
			WHERE o.valid = 1
			AND o.`invoice_date` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\' ');
        $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT COUNT(`id_customer`) AS total_registrations
			FROM `' . _DB_PREFIX_ . 'customer` c
			WHERE c.`date_add` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'');
        $result3 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT SUM(pv.`counter`) AS total_viewed
			FROM `' . _DB_PREFIX_ . 'page_viewed` pv
			LEFT JOIN `' . _DB_PREFIX_ . 'date_range` dr ON pv.`id_date_range` = dr.`id_date_range`
			LEFT JOIN `' . _DB_PREFIX_ . 'page` p ON pv.`id_page` = p.`id_page`
			LEFT JOIN `' . _DB_PREFIX_ . 'page_type` pt ON pt.`id_page_type` = p.`id_page_type`
			WHERE pt.`name` = \'product.php\'
			AND dr.`time_start` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'
			AND dr.`time_end` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'');
        $results = array_merge($result, array_merge($result2, $result3));
        echo '
			<div class="table_info">
				<h5><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('View more') . '</a> ' . $this->l('Monthly Statistics') . ' </h5>
				<table class="table_info_details">
					<tr class="tr_odd">
						<td class="td_align_left">
						' . $this->l('Sales') . '
						</td>
						<td>
							' . Tools::displayPrice($results['total_sales'], $currency) . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Total registrations') . '
						</td>
						<td>
							' . (int) $results['total_registrations'] . '
						</td>
					</tr>
					<tr class="tr_odd">
						<td class="td_align_left">
							' . $this->l('Total orders') . '
						</td>
						<td>
							' . (int) $results['total_orders'] . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Product pages viewed') . '
						</td>
						<td>
							' . (int) $results['total_viewed'] . '
						</td>
					</tr>
				</table>
			</div>
			';
        $all = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'customer_thread');
        $unread = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'customer_thread` WHERE `status` = "open"');
        $pending = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'customer_thread` WHERE `status` LIKE "%pending%"');
        $close = $all - ($unread + $pending);
        echo '
			<div class="table_info" id="table_info_last">
				<h5><a href="index.php?tab=AdminCustomerThreads&token=' . Tools::getAdminTokenLite('AdminCustomerThreads') . '">' . $this->l('View more') . '</a> ' . $this->l('Customers service') . '</h5>
				<table class="table_info_details">
					<tr class="tr_odd">
						<td class="td_align_left">
						' . $this->l('Thread unread') . '
						</td>
						<td>
							' . $unread . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Thread pending') . '
						</td>
						<td>
							' . $pending . '
						</td>
					</tr>
					<tr class="tr_odd">
						<td class="td_align_left">
							' . $this->l('Thread closed') . '
						</td>
						<td>
							' . $close . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Total thread') . '
						</td>
						<td>
							' . $all . '
						</td>
					</tr>
				</table>
			</div>

			<div id="table_info_large">
				<h5><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('View more') . '</a> <strong>' . $this->l('Statistics') . '</strong> / ' . $this->l('Sales of the week') . '</h5>
				<div id="stat_google">';
        define('PS_BASE_URI', __PS_BASE_URI__);
        $chart = new Chart();
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
			SELECT total_paid / conversion_rate as total_converted, invoice_date
			FROM ' . _DB_PREFIX_ . 'orders o
			WHERE valid = 1
			AND invoice_date BETWEEN \'' . date('Y-m-d', strtotime('-7 DAYS', time())) . ' 00:00:00\' AND \'' . date('Y-m-d H:i:s') . '\'');
        foreach ($result as $row) {
            $chart->getCurve(1)->setPoint(strtotime($row['invoice_date']), $row['total_converted']);
        }
        $chart->setSize(580, 170);
        $chart->setTimeMode(strtotime('-7 DAYS', time()), time(), 'd');
        $chart->getCurve(1)->setLabel($this->l('Sales +Tx') . ' (' . strtoupper($currency->iso_code) . ')');
        $chart->display();
        echo '	</div>
			</div>
			<table cellpadding="0" cellspacing="0" id="table_customer">
				<thead>
					<tr>
						<th class="order_id"><span class="first">' . $this->l('ID') . '</span></th>
						<th class="order_customer"><span>' . $this->l('Customer Name') . '</span></th>
						<th class="order_status"><span>' . $this->l('Status') . '</span></th>
						<th class="order_total"><span>' . $this->l('Total') . '</span></th>
						<th class="order_action"><span class="last">' . $this->l('Action') . '</span></th>
					<tr>
				</thead>
				<tbody>';
        $orders = Order::getOrdersWithInformations(10);
        $i = 0;
        foreach ($orders as $order) {
            $currency = Currency::getCurrency((int) $order['id_currency']);
            echo '
					<tr' . ($i % 2 ? ' id="order_line1"' : '') . '>
						<td class="order_td_first order_id">' . (int) $order['id_order'] . '</td>
						<td class="order_customer">' . Tools::htmlentitiesUTF8($order['firstname']) . ' ' . Tools::htmlentitiesUTF8($order['lastname']) . '</td>
						<td class="order_status">' . Tools::htmlentitiesUTF8($order['state_name']) . '</td>
						<td class="order_total">' . Tools::displayPrice((double) $order['total_paid'], $currency) . '</td>
						<td class="order_action">
							<a href="index.php?tab=AdminOrders&id_order=' . (int) $order['id_order'] . '&vieworder&token=' . Tools::getAdminTokenLite('AdminOrders') . '" title="' . $this->l('Details') . '"><img src="../img/admin/details.gif" alt="' . $this->l('See') . '" /></a>
						</td>
					</tr>
				';
            $i++;
        }
        echo '
				</tbody>
			</table>
		</div>
		<div id="column_right">
			<script type="text/javascript">
				$(document).ready(function() {
					$.ajax({
						url: "ajax.php",
						dataType: "json",
						data: "getAdminHomeElement",
						success: function(json) {
							if (json.screencast != \'NOK\')
								$(\'#adminpresentation\').fadeIn(\'slow\');
							else
								$(\'#adminpresentation\').fadeOut(\'slow\');

							$(\'#partner_preactivation\').fadeOut(\'slow\', function() {
								if (json.partner_preactivation != \'NOK\')
									$(\'#partner_preactivation\').html(json.partner_preactivation);
								else
									$(\'#partner_preactivation\').html(\'\');
								$(\'#partner_preactivation\').fadeIn(\'slow\');
							});

							$(\'#discover_prestashop\').fadeOut(\'slow\', function() {
								if (json.discover_prestashop != \'NOK\')
									$(\'#discover_prestashop\').html(json.discover_prestashop);
								else
									$(\'#discover_prestashop\').html(\'\');
								$(\'#discover_prestashop\').fadeIn(\'slow\');
							});
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							$(\'#adminpresentation\').fadeOut(\'slow\');
							$(\'#partner_preactivation\').fadeOut(\'slow\');
							$(\'#discover_prestashop\').fadeOut(\'slow\');
						}
					});
				});
			</script>
			<div id="partner_preactivation">
				<p class="center"><img src="../img/loader.gif" alt="" /> ' . translate('Loading...') . '</p>
			</div>
		';
        if (Tools::isSubmit('hideOptimizationTips')) {
            Configuration::updateValue('PS_HIDE_OPTIMIZATION_TIPS', 1);
        }
        $this->_displayOptimizationTips();
        echo '
			<div id="discover_prestashop">
				<p class="center"><img src="../img/loader.gif" alt="" /> ' . translate('Loading...') . '</p>
			</div>
		</div>
		<div class="clear"></div>';
        echo Module::hookExec('backOfficeHome');
    }
Пример #6
0
    osTicket Upgrade Wizard

    Peter Rotich <*****@*****.**>
    Copyright (c)  2006-2013 osTicket
    http://www.osticket.com

    Released under the GNU General Public License WITHOUT ANY WARRANTY.
    See LICENSE.TXT for details.

    vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require_once 'admin.inc.php';
require_once INCLUDE_DIR . 'class.upgrader.php';
//$_SESSION['ost_upgrader']=null;
$upgrader = new Upgrader(TABLE_PREFIX, UPGRADE_DIR . 'streams/');
$errors = array();
if ($_POST && $_POST['s'] && !$upgrader->isAborted()) {
    switch (strtolower($_POST['s'])) {
        case 'prereq':
            if (!$ost->isUpgradePending()) {
                $errors['err'] = __('Nothing to do! System already upgraded to the current version');
            } elseif (!$upgrader->isUpgradable()) {
                $errors['err'] = __('The upgrader does NOT support upgrading from the current vesion!');
            } 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');
            }
Пример #7
0
$schema->setPrefix($g_db_prefix);
$sql = $schema->ParseSchema('upgrade.xml');
$result = $schema->ExecuteSchema($sql);
$error = $db->ErrorMsg();
if ($result != true) {
    die('The following error was encountered while creating the database tables:<br/> ' . $error);
} else {
    echo 'No error were encountered.';
}
?>
 
    
    <h2>Step 5 - Updating Records</h2>

    <?php 
$upgrader = new Upgrader();
$upgrader->upgrade_languages();
$upgrader->upgrade_options();
?>
    
    <h2>Step 6 - Verifying Data</h2>

    <?php 
# Verifying tables
$tables_in_db = $db->MetaTables('TABLES');
$tables = array('language' => 10, 'options' => 14);
foreach ($tables as $table => $records) {
    $sql = 'SELECT COUNT(*) FROM ' . $g_db_prefix . $table;
    $count = $db->GetOne($sql);
    if ($count != $records) {
        die('The ' . $g_db_prefix . $table . ' table does not contain the correct number of records. Found ' . $count . ', but there should be ' . $records . '.');
Пример #8
0
 function upgrade()
 {
     global $thisstaff, $ost;
     if (!$thisstaff or !$thisstaff->isAdmin() or !$ost) {
         Http::response(403, 'Access Denied');
     }
     $upgrader = new Upgrader(TABLE_PREFIX, UPGRADE_DIR . 'streams/');
     if ($upgrader->isAborted()) {
         Http::response(416, __("We have a problem ... wait a sec."));
         exit;
     }
     if ($upgrader->getTask() && $upgrader->doTask()) {
         //More pending tasks - doTasks returns the number of pending tasks
         Http::response(200, $upgrader->getNextAction());
         exit;
     } elseif ($ost->isUpgradePending()) {
         if ($upgrader->isUpgradable()) {
             $version = $upgrader->getNextVersion();
             if ($upgrader->upgrade()) {
                 //We're simply reporting progress here - call back will report next action'
                 Http::response(200, sprintf(__("Upgraded to %s ... post-upgrade checks!"), $version));
                 exit;
             }
         } else {
             //Abort: Upgrade pending but NOT upgradable - invalid or wrong hash.
             $upgrader->abort(sprintf(__('Upgrade Failed: Invalid or wrong hash [%s]'), $ost->getDBSignature()));
         }
     } elseif (!$ost->isUpgradePending()) {
         $upgrader->setState('done');
         session_write_close();
         Http::response(201, __("We're done!"));
         exit;
     }
     if ($upgrader->isAborted() || $upgrader->getErrors()) {
         Http::response(416, __("We have a problem ... wait a sec."));
         exit;
     }
     Http::response(200, $upgrader->getNextAction());
 }
Пример #9
0
    public function display()
    {
        $this->_html .= '<script type="text/javascript">var jQueryVersionPS = parseInt($().jquery.replace(/\\./g, ""));</script>
		<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/js/jquery-1.6.2.min.js"></script>
		<script type="text/javascript">if (jQueryVersionPS >= 162) jq162 = jQuery.noConflict(true);</script>';
        /* PrestaShop demo mode */
        if (defined('_PS_MODE_DEMO_') && _PS_MODE_DEMO_) {
            echo '<div class="error">' . $this->l('This functionality has been disabled.') . '</div>';
            return;
        }
        if (!file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . 'ajax-upgradetab.php')) {
            echo '<div class="error">' . '<img src="../img/admin/warning.gif" /> ' . $this->l('[TECHNICAL ERROR] ajax-upgradetab.php is missing. Please reinstall or reset the module.') . '</div>';
            return false;
        }
        /* PrestaShop demo mode*/
        // in order to not use Tools class
        $upgrader = new Upgrader();
        preg_match('#([0-9]+\\.[0-9]+)(?:\\.[0-9]+){1,2}#', _PS_VERSION_, $matches);
        $upgrader->branch = $matches[1];
        $channel = $this->getConfig('channel');
        switch ($channel) {
            case 'archive':
                $upgrader->channel = 'archive';
                $upgrader->version_num = $this->getConfig('archive.version_num');
                break;
            case 'directory':
                $upgrader->channel = 'directory';
                $upgrader->version_num = $this->getConfig('directory.version_num');
                break;
            default:
                $upgrader->channel = $channel;
                if (isset($_GET['refreshCurrentVersion'])) {
                    // delete the potential xml files we saved in config/xml (from last release and from current)
                    $upgrader->clearXmlMd5File(_PS_VERSION_);
                    $upgrader->clearXmlMd5File($upgrader->version_num);
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(true, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(true, array('minor'));
                    }
                    Tools14::redirectAdmin($this->currentIndex . '&conf=5&token=' . Tools14::getValue('token'));
                } else {
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(false, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(false, array('minor'));
                    }
                }
        }
        $this->upgrader = $upgrader;
        $this->_html .= '<link type="text/css" rel="stylesheet" href="' . __PS_BASE_URI__ . 'modules/autoupgrade/css/styles.css" />';
        $this->_html .= '<div class="bootstrap" id="informationBlock">
            <div class="panel">
                <div class="panel-heading">
                  ' . $this->l('Welcome!') . '
                </div>
                <p>
                    ' . $this->l('With the PrestaShop 1-Click Upgrade module, upgrading your store to the latest version available has never been easier!') . '<br /><br />
                    <span style="color:#CC0000;font-weight:bold">' . $this->l('Please always perform a full manual backup of your files and database before starting any upgrade.') . '</span><br />
                    ' . $this->l('Double-check the integrity of your backup and that you can easily manually roll-back if necessary.') . '<br />
                    ' . $this->l('If you do not know how to proceed, ask your hosting provider.') . '
                </p>
            </div>
            </div>';
        /* Make sure the user has configured the upgrade options, or set default values */
        $configuration_keys = array('PS_AUTOUP_UPDATE_DEFAULT_THEME' => 1, 'PS_AUTOUP_CHANGE_DEFAULT_THEME' => 0, 'PS_AUTOUP_KEEP_MAILS' => 0, 'PS_AUTOUP_CUSTOM_MOD_DESACT' => 1, 'PS_AUTOUP_MANUAL_MODE' => 0, 'PS_AUTOUP_PERFORMANCE' => 1, 'PS_DISPLAY_ERRORS' => 0);
        foreach ($configuration_keys as $k => $default_value) {
            if (Configuration::get($k) == '') {
                Configuration::updateValue($k, $default_value);
            }
        }
        /* Checks/requirements and "Upgrade PrestaShop now" blocks */
        $this->_displayCurrentConfiguration();
        $this->_displayBlockUpgradeButton();
        $this->_displayComparisonBlock();
        $this->_displayBlockActivityLog();
        $this->_displayRollbackForm();
        $this->_html .= '<br/>';
        $this->_html .= '<form action="' . $this->currentIndex . '&amp;customSubmitAutoUpgrade=1&amp;token=' . $this->token . '" method="post" class="form-horizontal" enctype="multipart/form-data">';
        $this->_displayForm('backupOptions', $this->_fieldsBackupOptions, '<a href="#" name="backup-options" id="backup-options">' . $this->l('Backup Options') . '</a>', '', 'database_gear');
        $this->_displayForm('upgradeOptions', $this->_fieldsUpgradeOptions, '<a href="#" name="upgrade-options" id="upgrade-options">' . $this->l('Upgrade Options') . '</a>', '', 'prefs');
        $this->_html .= '</form>';
        $this->_html .= '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/js/jquery.xml2json.js"></script>';
        $this->_html .= '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
        echo $this->_html;
    }
    public function display()
    {
        if (isset($_GET['refreshCurrentVersion'])) {
            $upgrader = new Upgrader();
            $upgrader->checkPSVersion(true);
            $this->upgrader = $upgrader;
        }
        echo '<style>
.autoupgradeSteps div {  line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {border:2px outset grey;margin-top:1px;overflow: auto;}
#dbResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
.changedFileList {margin-left:20px; padding-left:5px;}
.changedNotice li{color:grey;}
.changedImportant li{color:red;font-weight:bold}
</style>';
        $this->displayWarning($this->l('This function is experimental. It\'s highly recommended to make a backup of your files and database before starting the upgrade process.'));
        global $currentIndex;
        // update['name'] = version name
        // update['num'] = only the version
        // update['link'] = download link
        // @TODO
        $this->createCustomToken();
        if ($this->useSvn) {
            echo '<div class="error"><h1>' . $this->l('Unstable upgrade') . '</h1>
				<p class="warning">' . $this->l('Your current configuration indicate you want to upgrade your system from the unstable development branch, with no version number. If you upgrade, you will not be able to follow the official release process anymore') . '.</p>
				</div>';
        }
        $this->_displayUpgraderForm();
        echo '<br/>';
        $this->_displayRollbackForm();
        echo '<br/>';
        $this->_displayForm('autoUpgradeOptions', $this->_fieldsAutoUpgrade, '<a href="" name="options" id="options">' . $this->l('Options') . '</a>', '', 'prefs');
        // @todo manual upload with a form
        // We need jquery 1.6 for json
        echo '<script type="text/javascript">
			jq13 = jQuery.noConflict(true);
			</script>
			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery-1.6.2.min.js"></script>';
        echo '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery.xml2json.js"></script>';
        echo '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
    }
Пример #11
0
 /**
  * Display the wizard
  *
  * @author KnowledgeTree Team
  * @access private
  * @param string
  * @return void
  */
 public function displayUpgrader($response = null)
 {
     if ($response) {
         $ins = new Upgrader();
         // Instantiate the upgrader
         $ins->resolveErrors($response);
         // Run step
     } else {
         $ins = new Upgrader(new session());
         // Instantiate the upgrader and pass the session class
         $ins->step();
         // Run step
     }
 }
Пример #12
0
    public function display()
    {
        // We need jquery 1.6 for json
        // do we ?
        echo '<script type="text/javascript">
		if (jQuery == "undefined")
			jq13 = jQuery.noConflict(true);
			</script>
		<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery-1.6.2.min.js"></script>';
        $this->createCustomToken();
        /* PrestaShop demo mode */
        if (defined('_PS_MODE_DEMO_') && _PS_MODE_DEMO_) {
            echo '<div class="error">' . $this->l('This functionnality has been disabled.') . '</div>';
            return;
        }
        if (!file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . 'ajax-upgradetab.php')) {
            echo '<div class="error">' . '<img src="../img/admin/warning.gif" /> [TECHNICAL ERROR] ' . $this->l('ajax-upgradetab.php is missing. please reinstall or reset the module') . '</div>';
            return false;
        }
        /* PrestaShop demo mode*/
        // in order to not use Tools class
        if (isset($_GET['refreshCurrentVersion'])) {
            $upgrader = new Upgrader();
            $upgrader->checkPSVersion(true);
            // delete the potential xml files we saved in config/xml (from last release and from current)
            $upgrader->clearXmlMd5File(_PS_VERSION_);
            $upgrader->clearXmlMd5File($upgrader->version_num);
            $this->upgrader = $upgrader;
        }
        echo '<style>
.autoupgradeSteps div {  line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {border:2px outset grey;margin-top:1px;overflow: auto;}
#dbResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion, #checkPrestaShopModifiedFiles{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
.changedFileList {margin-left:20px; padding-left:5px;}
.changedNotice li{color:grey;}
.changedImportant li{color:red;font-weight:bold}
.upgradeDbError{background-color:red}
.upgradeDbOk{background-color:green}
.small_label{font-weight:normal;width:300px;float:none;text-align:left;padding:0}
</style>';
        $this->displayWarning($this->l('This function is experimental. It\'s highly recommended to make a backup of your files and database before starting the upgrade process.'));
        global $currentIndex;
        // update['name'] = version name
        // update['num'] = only the version
        // update['link'] = download link
        // @TODO
        if ($this->useSvn) {
            echo '<div class="error"><h1>' . $this->l('Unstable upgrade') . '</h1>
				<p class="warning">' . $this->l('Your current configuration indicate you want to upgrade your system from the unstable development branch, with no version number. If you upgrade, you will not be able to follow the official release process anymore') . '.</p>
				</div>';
        }
        $this->_displayUpgraderForm();
        echo '<br/>';
        $this->_displayRollbackForm();
        echo '<br/>';
        $this->_displayForm('autoUpgradeOptions', $this->_fieldsAutoUpgrade, '<a href="" name="options" id="options">' . $this->l('Options') . '</a>', '', 'prefs');
        // @todo manual upload with a form
        echo '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery.xml2json.js"></script>';
        echo '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
    }
    public function display()
    {
        global $currentIndex;
        // We need jquery 1.6 for json
        // do we ?
        $this->_html .= '<script type="text/javascript">
		if (jQuery == "undefined")
			jq13 = jQuery.noConflict(true);
			</script>
		<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery-1.6.2.min.js"></script>';
        /* PrestaShop demo mode */
        if (defined('_PS_MODE_DEMO_') && _PS_MODE_DEMO_) {
            echo '<div class="error">' . $this->l('This functionnality has been disabled.') . '</div>';
            return;
        }
        if (!file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . 'ajax-upgradetab.php')) {
            echo '<div class="error">' . '<img src="../img/admin/warning.gif" /> [TECHNICAL ERROR] ' . $this->l('ajax-upgradetab.php is missing. please reinstall or reset the module') . '</div>';
            return false;
        }
        /* PrestaShop demo mode*/
        // in order to not use Tools class
        $upgrader = new Upgrader();
        preg_match('#([0-9]+\\.[0-9]+)(?:\\.[0-9]+){1,2}#', _PS_VERSION_, $matches);
        $upgrader->branch = $matches[1];
        $channel = $this->getConfig('channel');
        switch ($channel) {
            case 'archive':
                $upgrader->channel = 'archive';
                $upgrader->version_num = $this->getConfig('archive.version_num');
                break;
            case 'directory':
                $upgrader->channel = 'directory';
                $upgrader->version_num = $this->getConfig('directory.version_num');
                break;
            default:
                $upgrader->channel = $channel;
                if (isset($_GET['refreshCurrentVersion'])) {
                    // delete the potential xml files we saved in config/xml (from last release and from current)
                    $upgrader->clearXmlMd5File(_PS_VERSION_);
                    $upgrader->clearXmlMd5File($upgrader->version_num);
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(true, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(true, array('minor'));
                    }
                    Tools::redirectAdmin($currentIndex . '&conf=5&token=' . Tools::getValue('token'));
                } else {
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(false, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(false, array('minor'));
                    }
                }
        }
        $this->upgrader = $upgrader;
        $this->_html .= '<style type="text/css">
fieldset{margin-top:10px}
.autoupgradeSteps div {  line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;display:inline-block;font-size: medium;margin:10px 0;padding: 5px;}
.processing {border:2px outset grey;margin-top:1px;overflow: auto;}
#infoStep {height:100px;width:300px}
#infoError {height:100px;width:550px}
#quickInfo {height:200px}
#upgradeResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion, #checkPrestaShopModifiedFiles{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
.changedFileList {margin-left:20px; padding-left:5px;}
.changedNotice li{color:grey;}
.changedImportant li{color:red;font-weight:bold}
.upgradeDbError{background-color:#FEEFB3}
.upgradeDbOk{background-color:#DFF2BF}
.small_label{font-weight:normal;width:300px;float:none;text-align:left;padding:0}
.blocOneClickUpgrade{width:530px;float:left}
.ocu-feature-list{margin:0;padding:0;list-style:none}
.ocu-feature-list li{background:url(../img/admin/enabled.gif) no-repeat; padding-left:20px;margin:0;}
</style>';
        $this->_html .= '
		<h1>' . $this->l('1-click Upgrade') . '</h1>
		<fieldset id="informationBlock" class="information" style="float: left; width: 30%;">
			<legend>' . $this->l('Welcome!') . '</legend>
			<p>' . $this->l('With the PrestaShop 1-click upgrade module, upgrading your store to the latest version available has never been easier!') . '<br /><br />
			<img src="../img/admin/warning.gif" alt=""/><strong>' . $this->l('This module is still in a "beta" version.') . '</strong><br /><br /><span style="color: #CC0000; font-weight: bold;">' . $this->l('Please always perform a full manual backup of your files and database before starting any upgrade.') . '</span><br />' . $this->l('Double-check the integrity of your backup and that you can easily manually roll-back if necessary.') . '<br />' . $this->l('If you don\'t know how to proceed, ask your hosting provider.') . '</p>			
		</fieldset>';
        /* Make sure the user has configured the upgrade options, or set default values */
        $configuration_keys = array('PS_AUTOUP_KEEP_DEFAULT_THEME' => 0, 'PS_AUTOUP_KEEP_MAILS' => 0, 'PS_AUTOUP_CUSTOM_MOD_DESACT' => 1, 'PS_AUTOUP_MANUAL_MODE' => 0, 'PS_AUTOUP_PERFORMANCE' => 1, 'PS_DISPLAY_ERRORS' => 0);
        foreach ($configuration_keys as $k => $default_value) {
            if (Configuration::get($k) == '') {
                Configuration::updateValue($k, $default_value);
            }
        }
        /* Checks/requirements and "Upgrade PrestaShop now" blocks */
        $this->_displayCurrentConfiguration();
        $this->_html .= '<div class="clear"></div>';
        $this->_displayBlockUpgradeButton();
        $this->_displayComparisonBlock();
        $this->_displayBlockActivityLog();
        $this->_displayRollbackForm();
        $this->_html .= '<br/>';
        $this->_html .= '<form action="' . $currentIndex . '&customSubmitAutoUpgrade=1&token=' . $this->token . '"
			method="post" enctype="multipart/form-data">';
        $this->_displayForm('backupOptions', $this->_fieldsBackupOptions, '<a href="#" name="backup-options" id="backup-options">' . $this->l('Backup Options') . '</a>', '', 'database_gear');
        $this->_displayForm('upgradeOptions', $this->_fieldsUpgradeOptions, '<a href="#" name="upgrade-options" id="upgrade-options">' . $this->l('Upgrade Options') . '</a>', '', 'prefs');
        $this->_html .= '</form>';
        $this->_html .= '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery.xml2json.js"></script>';
        $this->_html .= '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
        echo $this->_html;
    }
Пример #14
0
 function upgrade()
 {
     global $thisstaff, $ost;
     if (!$thisstaff or !$thisstaff->isAdmin() or !$ost) {
         Http::response(403, 'Access Denied');
     }
     $upgrader = new Upgrader($ost->getDBSignature(), TABLE_PREFIX, SQL_DIR);
     //Just report the next action on the first call.
     if (!$_SESSION['ost_upgrader'] || !$_SESSION['ost_upgrader'][$upgrader->getShash()]['progress']) {
         $_SESSION['ost_upgrader'][$upgrader->getShash()]['progress'] = $upgrader->getNextAction();
         Http::response(200, $upgrader->getNextAction());
         exit;
     }
     if ($upgrader->isAborted()) {
         Http::response(416, "We have a problem ... wait a sec.");
         exit;
     }
     if ($upgrader->getNumPendingTasks() && $upgrader->doTasks()) {
         //More pending tasks - doTasks returns the number of pending tasks
         Http::response(200, $upgrader->getNextAction());
         exit;
     } elseif ($ost->isUpgradePending()) {
         if ($upgrader->isUpgradable()) {
             $version = $upgrader->getNextVersion();
             if ($upgrader->upgrade()) {
                 //We're simply reporting progress here - call back will report next action'
                 Http::response(200, "Upgraded to {$version} ... post-upgrade checks!");
                 exit;
             }
         } else {
             //Abort: Upgrade pending but NOT upgradable - invalid or wrong hash.
             $upgrader->abort(sprintf('Upgrade Failed: Invalid or wrong hash [%s]', $ost->getDBSignature()));
         }
     } elseif (!$ost->isUpgradePending()) {
         $upgrader->setState('done');
         session_write_close();
         Http::response(201, "We're done!");
         exit;
     }
     if ($upgrader->isAborted() || $upgrader->getErrors()) {
         Http::response(416, "We have a problem ... wait a sec.");
         exit;
     }
     Http::response(200, $upgrader->getNextAction());
 }