예제 #1
0
파일: system.php 프로젝트: M03G/PrestaShop
 public function checkTests($list, $type)
 {
     $tests = ConfigurationTest::check($list);
     $success = true;
     foreach ($tests as $result) {
         $success &= $result == 'ok' ? true : false;
     }
     return array('checks' => $tests, 'success' => $success);
 }
 /**
  * get all tests
  *
  * @return array of test results
  */
 public function getTestResult()
 {
     // Functions list to test with 'test_system'
     // Test to execute (function/args) : lets uses the default test
     $tests = ConfigurationTest::getDefaultTests();
     $tests_op = ConfigurationTest::getDefaultTestsOp();
     $tests_errors = array('phpversion' => $this->l('Update your PHP version'), 'upload' => $this->l('Configure your server to allow file uploads'), 'system' => $this->l('Configure your server to allow the creation of directories and files with write permissions'), 'gd' => $this->l('Enable the GD library on your server'), 'mysql_support' => $this->l('Enable the MySQL support on your server'), 'config_dir' => $this->l('Set write permissions for "config" folder'), 'cache_dir' => $this->l('Set write permissions for "cache" folder'), 'sitemap' => $this->l('Set write permissions for "sitemap.xml" file'), 'img_dir' => $this->l('Set write permissions for "img" folder and subfolders, recursively'), 'log_dir' => $this->l('Set write permissions for "log" folder and subfolders, recursively'), 'mails_dir' => $this->l('Set write permissions for "mails" folder and subfolders, recursively'), 'module_dir' => $this->l('Set write permissions for "modules" folder and subfolders, recursively'), 'theme_lang_dir' => $this->l('Set write permissions for "themes/') . _THEME_NAME_ . $this->l('/lang/" folder and subfolders, recursively'), 'translations_dir' => $this->l('Set write permissions for "translations" folder and subfolders, recursively'), 'customizable_products_dir' => $this->l('Set write permissions for "upload" folder and subfolders, recursively'), 'virtual_products_dir' => $this->l('Set write permissions for "download" folder and subfolders, recursively'), 'fopen' => $this->l('Allow the PHP fopen() function on your server'), 'register_globals' => $this->l('Set PHP "register_global" option to "Off"'), 'gz' => $this->l('Enable GZIP compression on your server'));
     $params_required_results = ConfigurationTest::check($tests);
     $params_optional_results = ConfigurationTest::check($tests_op);
     return array('failRequired' => in_array('fail', $params_required_results), 'failOptional' => in_array('fail', $params_optional_results), 'testsErrors' => $tests_errors, 'testsRequired' => $params_required_results, 'testsOptional' => $params_optional_results);
 }
 /**
  * get all tests
  *
  * @return array of test results
  */
 public function getTestResult()
 {
     $tests_errors = array('phpversion' => $this->l('Update your PHP version.'), 'upload' => $this->l('Configure your server to allow file uploads.'), 'system' => $this->l('Configure your server to allow the creation of directories and files with write permissions.'), 'gd' => $this->l('Enable the GD library on your server.'), 'mysql_support' => $this->l('Enable the MySQL support on your server.'), 'config_dir' => $this->l('Set write permissions for the "config" folder.'), 'cache_dir' => $this->l('Set write permissions for the "cache" folder.'), 'sitemap' => $this->l('Set write permissions for the "sitemap.xml" file.'), 'img_dir' => $this->l('Set write permissions for the "img" folder and subfolders.'), 'log_dir' => $this->l('Set write permissions for the "log" folder and subfolders.'), 'mails_dir' => $this->l('Set write permissions for the "mails" folder and subfolders.'), 'module_dir' => $this->l('Set write permissions for the "modules" folder and subfolders.'), 'theme_lang_dir' => sprintf($this->l('Set the write permissions for the "themes%s/lang/" folder and subfolders, recursively.'), _THEME_NAME_), 'translations_dir' => $this->l('Set write permissions for the "translations" folder and subfolders.'), 'customizable_products_dir' => $this->l('Set write permissions for the "upload" folder and subfolders.'), 'virtual_products_dir' => $this->l('Set write permissions for the "download" folder and subfolders.'), 'fopen' => $this->l('Allow the PHP fopen() function on your server.'), 'register_globals' => $this->l('Set PHP "register_globals" option to "Off".'), 'gz' => $this->l('Enable GZIP compression on your server.'));
     // Functions list to test with 'test_system'
     // Test to execute (function/args): lets uses the default test
     $params_required_results = ConfigurationTest::check(ConfigurationTest::getDefaultTests());
     if (!defined('_PS_HOST_MODE_')) {
         $params_optional_results = ConfigurationTest::check(ConfigurationTest::getDefaultTestsOp());
     }
     $results = array('failRequired' => in_array('fail', $params_required_results), 'testsErrors' => $tests_errors, 'testsRequired' => $params_required_results);
     if (!defined('_PS_HOST_MODE_')) {
         $results = array_merge($results, array('failOptional' => in_array('fail', $params_optional_results), 'testsOptional' => $params_optional_results));
     }
     return $results;
 }
 /**
  * get all tests
  *
  * @return array of test results
  */
 public function getTestResult()
 {
     $tests_errors = array('phpversion' => $this->l('Update your PHP version.'), 'upload' => $this->l('Configure your server to allow file uploads.'), 'system' => $this->l('Configure your server to allow the creation of directories and files with write permissions.'), 'gd' => $this->l('Enable the GD library on your server.'), 'mysql_support' => $this->l('Enable the MySQL support on your server.'), 'config_dir' => $this->l('Set write permissions for the "config" folder.'), 'cache_dir' => $this->l('Set write permissions for the "cache" folder.'), 'sitemap' => $this->l('Set write permissions for the "sitemap.xml" file.'), 'img_dir' => $this->l('Set write permissions for the "img" folder and subfolders.'), 'log_dir' => $this->l('Set write permissions for the "log" folder and subfolders.'), 'mails_dir' => $this->l('Set write permissions for the "mails" folder and subfolders.'), 'module_dir' => $this->l('Set write permissions for the "modules" folder and subfolders.'), 'theme_lang_dir' => sprintf($this->l('Set the write permissions for the "themes%s/lang/" folder and subfolders, recursively.'), _THEME_NAME_), 'translations_dir' => $this->l('Set write permissions for the "translations" folder and subfolders.'), 'customizable_products_dir' => $this->l('Set write permissions for the "upload" folder and subfolders.'), 'virtual_products_dir' => $this->l('Set write permissions for the "download" folder and subfolders.'), 'fopen' => $this->l('Allow the PHP fopen() function on your server.'), 'register_globals' => $this->l('Set PHP "register_globals" option to "Off".'), 'gz' => $this->l('Enable GZIP compression on your server.'), 'files' => $this->l('Some PrestaShop files are missing from your server.'), 'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by PrestaShop will be PHP 5.4. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.4 now!'), phpversion()));
     // Functions list to test with 'test_system'
     // Test to execute (function/args): lets uses the default test
     $params_required_results = ConfigurationTest::check(ConfigurationTest::getDefaultTests());
     if (!defined('_PS_HOST_MODE_')) {
         $params_optional_results = ConfigurationTest::check(ConfigurationTest::getDefaultTestsOp());
     }
     $fail_required = in_array('fail', $params_required_results);
     if ($fail_required && $params_required_results['files'] != 'ok') {
         $tmp = ConfigurationTest::test_files(true);
         if (is_array($tmp) && count($tmp)) {
             $tests_errors['files'] = $tests_errors['files'] . '<br/>(' . implode(', ', $tmp) . ')';
         }
     }
     $results = array('failRequired' => $fail_required, 'testsErrors' => $tests_errors, 'testsRequired' => $params_required_results);
     if (!defined('_PS_HOST_MODE_')) {
         $results = array_merge($results, array('failOptional' => in_array('fail', $params_optional_results), 'testsOptional' => $params_optional_results));
     }
     return $results;
 }
예제 #5
0
파일: checkConfig.php 프로젝트: 7s4r/eBidix
<?php

header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date dans le passé
include_once INSTALL_PATH . '/classes/ConfigurationTest.php';
// Functions list to test with 'test_system'
$funcs = array('fopen', 'fclose', 'fread', 'fwrite', 'rename', 'file_exists', 'unlink', 'rmdir', 'mkdir', 'getcwd', 'chdir', 'chmod');
// Test list to execute (function/args)
$tests = array('phpversion' => false, 'upload' => false, 'system' => $funcs, 'mysql_support' => false, 'cache_dir' => INSTALL_PATH . '/../data/');
$tests_op = array('fopen' => false, 'register_globals' => false, 'gz' => false, 'mcrypt' => false, 'magicquotes' => false, 'dom' => false);
// Execute tests
$res = ConfigurationTest::check($tests);
$res_op = ConfigurationTest::check($tests_op);
$has_error = false;
// Building XML Tree...
echo '<config>' . "\n";
echo '<firsttime value="' . ((isset($_GET['firsttime']) and $_GET['firsttime'] == 1) ? 1 : 0) . '" />' . "\n";
echo '<testList id="required">' . "\n";
foreach ($res as $key => $line) {
    if ($line == 'fail') {
        $has_error = true;
    }
    echo '<test id="' . $key . '" result="' . $line . '"/>' . "\n";
}
echo '</testList>' . "\n";
echo '<testList id="optional">' . "\n";
foreach ($res_op as $key => $line) {
    if ($line == 'fail') {
        $has_error = true;
예제 #6
0
 /**
  * init to build informations we need
  *
  * @return void
  */
 public function init()
 {
     // For later use, let's set up prodRootDir and adminDir
     // This way it will be easier to upgrade a different path if needed
     $this->prodRootDir = _PS_ROOT_DIR_;
     $this->adminDir = _PS_ADMIN_DIR_;
     // test writable recursively
     if (ConfigurationTest::test_dir($this->prodRootDir, true)) {
         $this->rootWritable = true;
     }
     // checkPSVersion will be not
     $this->upgrader = new Upgrader(true);
     $this->upgrader->checkPSVersion();
     // If you have defined this somewhere, you know what you do
     if (defined('_PS_ALLOW_UPGRADE_UNSTABLE_') and _PS_ALLOW_UPGRADE_UNSTABLE_ and function_exists('svn_checkout')) {
         $this->useSvn = Configuration::get('PS_AUTOUP_USE_SVN');
     } else {
         $this->useSvn = false;
     }
     // from $_POST or $_GET
     $this->action = Tools::getValue('action');
     $this->currentParams = Tools::getValue('params');
     // If not exists in this sessions, "create"
     // session handling : from current to next params
     if (isset($this->currentParams['removeList'])) {
         $this->nextParams['removeList'] = $this->currentParams['removeList'];
     }
     if (isset($this->currentParams['filesToUpgrade'])) {
         $this->nextParams['filesToUpgrade'] = $this->currentParams['filesToUpgrade'];
     }
     $this->backupDbFilename = Configuration::get('UPGRADER_BACKUPDB_FILENAME');
     if (!file_exists($this->backupDbFilename)) {
         $this->backupDbFilename = '';
         Configuration::updateValue('UPGRADER_BACKUPDB_FILENAME', '');
     }
     $this->backupFilesFilename = Configuration::get('UPGRADER_BACKUPFILES_FILENAME');
     if (!file_exists($this->backupFilesFilename)) {
         $this->backupFilesFilename = '';
         Configuration::updateValue('UPGRADER_BACKUPFILES_FILENAME', '');
     }
     $this->autoupgradePath = $this->adminDir . DIRECTORY_SEPARATOR . $this->autoupgradeDir;
     if (!file_exists($this->autoupgradePath)) {
         if (!@mkdir($this->autoupgradePath, 0777)) {
             $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'), $this->autoupgradePath));
         }
     }
     $latest = $this->autoupgradePath . DIRECTORY_SEPARATOR . 'latest';
     if (!file_exists($latest)) {
         if (!@mkdir($latest, 0777)) {
             $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'), $latest));
         }
     }
     $this->latestRootDir = $latest . DIRECTORY_SEPARATOR . 'prestashop';
     $this->adminDir = str_replace($this->prodRootDir, '', $this->adminDir);
     // @TODO future option
     //	$this->testRootDir = $this->autoupgradePath.DIRECTORY_SEPARATOR.'test';
     /* optional skips */
     $this->dontBackupImages = Configuration::get('PS_AUTOUP_DONT_SAVE_IMAGES');
     $this->keepDefaultTheme = Configuration::get('PS_AUTOUP_KEEP_DEFAULT_THEME');
     $this->keepTrad = Configuration::get('PS_AUTOUP_KEEP_TRAD');
     $this->manualMode = Configuration::get('PS_AUTOUP_MANUAL_MODE');
     // We can add any file or directory in the exclude dir : theses files will be not removed or overwritten
     // @TODO cache should be ignored recursively, but we have to reconstruct it after upgrade
     // - compiled from smarty
     // - .svn
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty_v2/compile";
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty_v2/cache";
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty/compile";
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty/cache";
     $this->excludeFilesFromUpgrade[] = '.';
     $this->excludeFilesFromUpgrade[] = '..';
     $this->excludeFilesFromUpgrade[] = '.svn';
     $this->excludeFilesFromUpgrade[] = 'install';
     $this->excludeFilesFromUpgrade[] = 'settings.inc.php';
     $this->excludeFilesFromUpgrade[] = 'autoupgrade';
     $this->backupIgnoreFiles[] = '.';
     $this->backupIgnoreFiles[] = '..';
     $this->backupIgnoreFiles[] = '.svn';
     $this->backupIgnoreFiles[] = 'autoupgrade';
     if ($this->dontBackupImages) {
         $this->backupIgnoreAbsoluteFiles[] = "/img";
     }
     if ($this->keepDefaultTheme) {
         $this->excludeAbsoluteFilesFromUpgrade[] = "/themes/prestashop";
     }
     if ($this->keepTrad) {
         $this->excludeFilesFromUpgrade[] = "translations";
     }
 }
 /**
  * download PrestaShop archive according to the chosen channel
  *
  * @access public
  */
 public function ajaxProcessDownload()
 {
     if (@ini_get('allow_url_fopen')) {
         if (!is_object($this->upgrader)) {
             $this->upgrader = new Upgrader();
         }
         // regex optimization
         preg_match('#([0-9]+\\.[0-9]+)(?:\\.[0-9]+){1,2}#', _PS_VERSION_, $matches);
         $this->upgrader->channel = $this->getConfig('channel');
         $this->upgrader->branch = $matches[1];
         if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
             $this->upgrader->checkPSVersion(false, array('private', 'minor'));
         } else {
             $this->upgrader->checkPSVersion(false, array('minor'));
         }
         if ($this->upgrader->channel == 'private') {
             $this->upgrader->link = $this->getConfig('private_release_link');
             $this->upgrader->md5 = $this->getConfig('private_release_md5');
         }
         $this->nextQuickInfo[] = sprintf('downloading from %s', $this->upgrader->link);
         $this->nextQuickInfo[] = sprintf('file will be saved in %s', $this->downloadPath . DIRECTORY_SEPARATOR . $this->destDownloadFilename);
         $report = '';
         $relative_download_path = str_replace(_PS_ROOT_DIR_, '', $this->downloadPath);
         if (ConfigurationTest::test_dir($relative_download_path, false, $report)) {
             $res = $this->upgrader->downloadLast($this->downloadPath, $this->destDownloadFilename);
             if ($res) {
                 $md5file = md5_file(realpath($this->downloadPath) . DIRECTORY_SEPARATOR . $this->destDownloadFilename);
                 if ($md5file == $this->upgrader->md5) {
                     $this->nextQuickInfo[] = 'Download complete.';
                     $this->next = 'unzip';
                     $this->next_desc = $this->l('Download complete. Now extracting');
                 } else {
                     $this->nextQuickInfo[] = sprintf('Download complete but md5sum does not match (%s)', $md5file);
                     $this->nextErrors[] = sprintf('Download complete but md5sum does not match (%s)', $md5file);
                     $this->next = 'error';
                     $this->next_desc = $this->l('Download complete but md5sum does not match. Operation aborted.');
                 }
             } else {
                 if ($this->upgrader->channel == 'private') {
                     $this->next_desc = $this->l('Error during download. The private key may be incorrect.');
                     $this->nextQuickInfo[] = 'Error during download. The private key may be incorrect.';
                     $this->nextErrors[] = 'Error during download. The private key may be incorrect.';
                 } else {
                     $this->next_desc = $this->l('Error during download');
                     $this->nextQuickInfo[] = 'Error during download';
                     $this->nextErrors[] = 'Error during download';
                 }
                 $this->next = 'error';
             }
         } else {
             $this->next_desc = $this->l('Download directory is not writeable ');
             $this->nextQuickInfo[] = 'Download directory is not writeable ';
             $this->nextErrors[] = 'Download directory is not writeable "' . $this->downloadPath . '"';
             $this->next = 'error';
         }
     } else {
         $this->nextQuickInfo[] = $this->l('you need allow_url_fopen for automatic download.');
         $this->nextErrors[] = $this->l('you need allow_url_fopen for automatic download.');
         $this->next = 'error';
         $this->next_desc = sprintf($this->l('you need allow_url_fopen for automatic download. You can also manually upload it in %s'), $this->downloadPath . $this->destDownloadFilename);
     }
 }
    /** this returns fieldset containing the configuration points you need to use autoupgrade
     * @return string
     */
    private function _displayCurrentConfiguration()
    {
        $current_ps_config = $this->getcheckCurrentPsConfig();
        $this->_html .= '
		<fieldset id="currentConfigurationBlock" class="width autoupgrade" style="float: left; width: 60%; margin-left: 30px;">
			<legend>' . $this->l('The pre-Upgrade checklist') . '</legend>';
        if (!$this->configOk()) {
            $this->_html .= '<div class="clear"><br></div><p class="warn">' . $this->l('The checklist is not ok. You can not upgrade your shop until every indicator will not be green.') . '</p>';
        }
        $this->_html .= '<div id="currentConfiguration">
							<p>' . $this->l('Before starting the upgrade process, please make sure this checklist is all green.') . '</p>
				<table class="table" cellpadding="0" cellspacing="0">';
        $pic_ok = '<img src="../img/admin/enabled.gif" alt="ok"/>';
        $pic_nok = '<img src="../img/admin/disabled.gif" alt="nok"/>';
        $pic_warn = '<img src="../img/admin/warning.gif" alt="warn"/>';
        // module version : checkAutoupgradeLastVersion
        $this->_html .= '
				<tr>
					<td>' . sprintf($this->l('The 1-click upgrade module is up-to-date (your current version is v%s)'), $this->getModuleVersion()) . '
					' . ($current_ps_config['module_version_ok'] ? '' : '&nbsp;&nbsp;' . (version_compare(_PS_VERSION_, '1.5.3.0', '>') ? '<strong><a href="index.php?controller=AdminModules&amp;token=' . Tools14::getAdminTokenLite('AdminModules') . '&update=autoupgrade">' . $this->l('Update') . '</a></strong> - ' : '') . '<strong><a class="_blank" href="http://addons.prestashop.com/en/administration-tools-prestashop-modules/5496-1-click-upgrade-autoupgrade.html">' . $this->l('Download') . '</a><strong> ') . '
					</td>
					<td>' . ($current_ps_config['module_version_ok'] ? $pic_ok : $pic_nok) . '</td>
				</tr>';
        // root : getRootWritable()
        $this->_html .= '
			<tr>
				<td>' . $this->l('Your store root directory must be writeable (appropriate CHMOD permissions)') . '</td>
				<td>' . ($current_ps_config['root_writable'] ? $pic_ok : $pic_nok . ' ' . $this->root_writable_report) . '</td>
			</tr>';
        //check safe_mod
        if (!($safe_mode = @ini_get('safe_mode'))) {
            $safe_mode = '';
        }
        $safe_mode = in_array(Tools14::strtolower($safe_mode), array(1, 'on'));
        $this->_html .= '
			<tr><td>' . $this->l('The PHP "Safe mode" option must be turned off') . '</td>
			<td>' . (!$safe_mode ? $pic_ok : $pic_warn) . '</td></tr>';
        $this->_html .= '
			<tr><td>' . $this->l('The PHP "allow_url_fopen" option must be turned on or CURL must be installed') . '</td>
			<td>' . (ConfigurationTest::test_fopen() || ConfigurationTest::test_curl() ? $pic_ok : $pic_nok) . '</td></tr>';
        // shop enabled
        $this->_html .= '
			<tr><td>' . $this->l('You must put your store under maintenance') . ' ' . (!$current_ps_config['shop_deactivated'] ? '<br><form method="post" action="' . $this->currentIndex . '&token=' . $this->token . '"><input type="submit" class="button" name="putUnderMaintenance" value="' . $this->l('Click here to put your shop under maintenance') . '"></form>' : '') . '</td>
			<td>' . ($current_ps_config['shop_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>';
        $this->_html .= '
			<tr><td>' . $this->l('You must disable the Caching features of PrestaShop') . '</td>
			<td>' . ($current_ps_config['cache_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>';
        // for informaiton, display time limit
        $max_exec_time = ini_get('max_execution_time');
        $this->_html .= '
			<tr><td>' . sprintf($this->l('The PHP time limit must be either high or disabled (Current value: %s)'), $max_exec_time == 0 ? $this->l('unlimited') : $max_exec_time . ' ' . $this->l('seconds')) . '</td>
			<td>' . ($max_exec_time == 0 ? $pic_ok : $pic_warn) . '</td></tr>
				</table>
				<p>' . $this->l('Please also make sure you proceeded to a full manual backup of your files and database.') . '</p>
			</div>
		</fieldset>';
    }
예제 #9
0
    /** this returns fieldset containing the configuration points you need to use autoupgrade
     * @return string
     */
    private function _displayCurrentConfiguration()
    {
        global $currentIndex;
        $current_ps_config = $this->getcheckCurrentPsConfig();
        $this->_html .= '
		<fieldset id="currentConfigurationBlock" class="width autoupgrade" style="float: left; width: 60%; margin-left: 30px;">
			<legend>' . $this->l('The pre-Upgrade checklist') . '</legend>';
        if (!$this->configOk()) {
            $this->_html .= '<div class="clear"><br></div><p class="warn">' . $this->l('The checklist is not ok. You can not upgrade your shop until every indicator will not be green.') . '</p>';
        }
        $this->_html .= '<div id="currentConfiguration">
				<table class="table" cellpadding="0" cellspacing="0">
				<p>' . $this->l('Before starting the upgrade process, please make sure this checklist is all green.') . '</p>';
        $pic_ok = '<img src="../img/admin/enabled.gif" alt="ok"/>';
        $pic_nok = '<img src="../img/admin/disabled.gif" alt="nok"/>';
        $pic_warn = '<img src="../img/admin/warning.gif" alt="warn"/>';
        // module version : checkAutoupgradeLastVersion
        $this->_html .= '
				<tr>
					<th>' . sprintf($this->l('The 1-click upgrade module is up-to-date (your current version is v%s)'), $this->getModuleVersion()) . '</th>
					<td>' . ($current_ps_config['module_version_ok'] ? $pic_ok : $pic_nok) . '</td>
				</tr>';
        // root : getRootWritable()
        $this->_html .= '<th>' . $this->l('Your store root directory must be writeable (appropriate CHMOD permissions)') . '</th>
			<td>' . ($current_ps_config['root_writable'] ? $pic_ok : $pic_nok . ' ' . $this->root_writable_report) . '</td></tr>';
        //check safe_mod
        $this->_html .= '<th>' . $this->l('The PHP "Safe mode" option must be turned off') . '</th>
			<td>' . (!ini_get('safe_mode') ? $pic_ok : $pic_warn) . '</td></tr>';
        $this->_html .= '<th>' . $this->l('The PHP "allow_url_fopen" option must be turned on or CURL must be installed') . '</th>
			<td>' . (ConfigurationTest::test_fopen() || ConfigurationTest::test_curl() ? $pic_ok : $pic_nok) . '</td></tr>';
        // shop enabled
        $this->_html .= '<th>' . $this->l('You must put your store under maintenance') . ' ' . (!$current_ps_config['shop_deactivated'] ? '<br><form method="post" action="' . $currentIndex . '&token=' . $this->token . '"><input type="submit" class="button" name="putUnderMaintenance" value="' . $this->l('Click here to put your shop under maintenance') . '"></form>' : '') . '</th>
			<td>' . ($current_ps_config['shop_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>';
        $this->_html .= '<th>' . $this->l('You must disable the Caching features of PrestaShop') . '</th>
			<td>' . ($current_ps_config['cache_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>';
        // for informaiton, display time limit
        $max_exec_time = ini_get('max_execution_time');
        $this->_html .= '<th>' . sprintf($this->l('The PHP time limit must be either high or disabled (Current value: %s)'), $max_exec_time == 0 ? $this->l('unlimited') : $max_exec_time . ' ' . $this->l('seconds')) . '</th>
			<td>' . ($max_exec_time == 0 ? $pic_ok : $pic_warn) . '</td></tr>
				</table>
				<p>' . $this->l('Please also make sure you proceeded to a full manual backup of your files and database.') . '</p>
			</div>
		</fieldset>';
    }
 /**
  * init to build informations we need
  *
  * @return void
  */
 public function init()
 {
     // For later use, let's set up prodRootDir and adminDir
     // This way it will be easier to upgrade a different path if needed
     $this->prodRootDir = _PS_ROOT_DIR_;
     $this->adminDir = _PS_ADMIN_DIR_;
     // from $_POST or $_GET
     $this->action = empty($_REQUEST['action']) ? null : $_REQUEST['action'];
     $this->currentParams = empty($_REQUEST['params']) ? null : $_REQUEST['params'];
     // test writable recursively
     if (version_compare(_PS_VERSION_, '1.4.5.0', '<')) {
         require_once 'ConfigurationTest.php';
         if (!class_exists('ConfigurationTest', false) and class_exists('ConfigurationTestCore')) {
             eval('class ConfigurationTest extends ConfigurationTestCore{}');
         }
     }
     if (ConfigurationTest::test_dir($this->prodRootDir, true)) {
         $this->rootWritable = true;
     }
     if (!in_array($this->action, array('upgradeFile', 'upgradeDb', 'upgradeComplete', 'rollback', 'restoreFiles', 'restoreDb'))) {
         // checkPSVersion will be not
         $this->upgrader = new Upgrader();
         $this->upgrader->checkPSVersion();
         $this->nextParams['install_version'] = $this->upgrader->version_num;
         if ($this->upgrader->autoupgrade_module) {
             $this->standalone = true;
         } else {
             $this->standalone = false;
         }
         $this->standalone = true;
     }
     // If you have defined this somewhere, you know what you do
     if (defined('_PS_ALLOW_UPGRADE_UNSTABLE_') and _PS_ALLOW_UPGRADE_UNSTABLE_ and function_exists('svn_checkout')) {
         if (version_compare(_PS_VERSION_, '1.4.5.0', '<') or class_exists('Configuration', false)) {
             $this->useSvn = Configuration::get('PS_AUTOUP_USE_SVN');
         }
     } else {
         $this->useSvn = false;
     }
     // If not exists in this sessions, "create"
     // session handling : from current to next params
     if (isset($this->currentParams['removeList'])) {
         $this->nextParams['removeList'] = $this->currentParams['removeList'];
     }
     if (isset($this->currentParams['filesToUpgrade'])) {
         $this->nextParams['filesToUpgrade'] = $this->currentParams['filesToUpgrade'];
     }
     // set autoupgradePath, to be used in backupFiles and backupDb config values
     $this->autoupgradePath = $this->adminDir . DIRECTORY_SEPARATOR . $this->autoupgradeDir;
     if (!file_exists($this->autoupgradePath)) {
         if (!@mkdir($this->autoupgradePath, 0777)) {
             $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'), $this->autoupgradePath));
         }
     }
     $latest = $this->autoupgradePath . DIRECTORY_SEPARATOR . 'latest';
     if (!file_exists($latest)) {
         if (!@mkdir($latest, 0777)) {
             $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'), $latest));
         }
     }
     if (class_exists('Configuration', false)) {
         $time = time();
         $this->backupDbFilename = Configuration::get('UPGRADER_BACKUPDB_FILENAME');
         if (!file_exists($this->backupDbFilename)) {
             // If not exists, the filename is generated by Backup.php
             $this->backupDbFilename = '';
             Configuration::updateValue('UPGRADER_BACKUPDB_FILENAME', $this->backupDbFilename);
         }
         $this->backupFilesFilename = Configuration::get('UPGRADER_BACKUPFILES_FILENAME');
         if (!file_exists($this->backupFilesFilename)) {
             $this->backupFilesFilename = $this->autoupgradePath . DIRECTORY_SEPARATOR . 'backupfile-' . date('Y-m-d') . '-' . $time . '.zip';
             Configuration::updateValue('UPGRADER_BACKUPFILES_FILENAME', $this->backupFilesFilename);
         }
     } else {
         // backupDbFilename should never be empty
         $this->backupDbFilename = $this->currentParams['backupDbFilename'];
         // backupFilesFilename should never etc.
         $this->backupFilesFilename = $this->currentParams['backupFilesFilename'];
     }
     $this->latestRootDir = $latest . DIRECTORY_SEPARATOR . 'prestashop';
     $this->adminDir = str_replace($this->prodRootDir, '', $this->adminDir);
     // @TODO future option "install in test dir"
     //	$this->testRootDir = $this->autoupgradePath.DIRECTORY_SEPARATOR.'test';
     /* option */
     if (class_exists('Configuration', false)) {
         $this->dontBackupImages = !Configuration::get('PS_AUTOUP_DONT_SAVE_IMAGES');
         $this->keepDefaultTheme = Configuration::get('PS_AUTOUP_KEEP_DEFAULT_THEME');
         $this->keepTrad = Configuration::get('PS_AUTOUP_KEEP_TRAD');
         $this->manualMode = Configuration::get('PS_AUTOUP_MANUAL_MODE');
         $this->desactivateCustomModule = Configuration::get('PS_AUTOUP_CUSTOM_MOD_DESACT');
     } else {
         $this->dontBackupImages = $this->currentParams['dontBackupImages'];
         $this->keepDefaultTheme = $this->currentParams['keepDefaultTheme'];
         $this->keepTrad = $this->currentParams['keepTrad'];
         $this->manualMode = $this->currentParams['manualMode'];
         $this->desactivateCustomModule = $this->currentParams['desactivateCustomModule'];
     }
     // We can add any file or directory in the exclude dir : theses files will be not removed or overwritten
     // @TODO cache should be ignored recursively, but we have to reconstruct it after upgrade
     // - compiled from smarty
     // - .svn
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty_v2/compile";
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty_v2/cache";
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty/compile";
     $this->backupIgnoreAbsoluteFiles[] = "/tools/smarty/cache";
     $this->excludeFilesFromUpgrade[] = '.';
     $this->excludeFilesFromUpgrade[] = '..';
     $this->excludeFilesFromUpgrade[] = '.svn';
     $this->excludeFilesFromUpgrade[] = 'install';
     $this->excludeFilesFromUpgrade[] = 'settings.inc.php';
     // this will exclude autoupgrade dir from admin, and autoupgrade from modules
     $this->excludeFilesFromUpgrade[] = 'autoupgrade';
     $this->backupIgnoreFiles[] = '.';
     $this->backupIgnoreFiles[] = '..';
     $this->backupIgnoreFiles[] = '.svn';
     $this->backupIgnoreFiles[] = 'autoupgrade';
     if ($this->dontBackupImages) {
         $this->backupIgnoreAbsoluteFiles[] = "/img";
     }
     if ($this->keepDefaultTheme) {
         $this->excludeAbsoluteFilesFromUpgrade[] = "/themes/prestashop";
     }
     if ($this->keepTrad) {
         $this->excludeFilesFromUpgrade[] = "translations";
     }
 }
    }
    function LoadConfiguration($data, $fields)
    {
        try {
            $Configuration = new Configuration();
            $result = $Configuration->load($fields['CFG_UID'], $fields['OBJ_UID'], $fields['PRO_UID'], $fields['USR_UID'], $fields['APP_UID']);
            return $result;
        } catch (Exception $e) {
            return array('Exception!! ' => $e->getMessage());
        }
    }
    function RemoveConfiguration($data, $fields)
    {
        try {
            $Configuration = new Configuration();
            $result = $Configuration->remove($fields['CFG_UID'], $fields['OBJ_UID'], $fields['PRO_UID'], $fields['USR_UID'], $fields['APP_UID']);
            return $result;
        } catch (Exception $e) {
            return array('Exception!! ' => $e->getMessage());
        }
    }
}
$test = new ConfigurationTest('configuration.yml', $t);
$test->domain->addDomain('CREATED_UID');
$test->domain->addDomain('CREATED_OBJ');
$test->domain->addDomain('CREATED_PRO');
$test->domain->addDomain('CREATED_USR');
$test->load('CreateTestConfigurations');
$test->runAll();
$test->load('ConfigurationUnitTest');
$test->runAll();
예제 #12
0
 public function getRootWritable()
 {
     // test if prodRootDir is writable recursively
     if (ConfigurationTest::test_dir($this->prodRootDir, true)) {
         $this->root_writable = true;
     }
     return $this->root_writable;
 }
예제 #13
0
파일: core.php 프로젝트: rodrisan/ps-cli
 public static function print_server_info()
 {
     $context = Context::getContext();
     $params_optional_results = ConfigurationTest::check(ConfigurationTest::getDefaultTestsOp());
     $table = new Cli\Table();
     $table->addRow(array('MySQL version', Db::getInstance()->getVersion()));
     $table->addRow(array('MySQL server', _DB_SERVER_));
     $table->addRow(array('Database name', _DB_NAME_));
     $table->addRow(array('User', _DB_USER_));
     $table->addRow(array('Prefix', _DB_PREFIX_));
     $table->addRow(array('Engine', _MYSQL_ENGINE_));
     $table->addRow(array('PrestaShop version', _PS_VERSION_));
     $table->addRow(array('Shop base URL', $context->shop->getBaseURL()));
     foreach ($params_optional_results as $key => $value) {
         $table->addRow(array($key, $value));
     }
     $table->display();
 }
 public static function test_dir($relative_dir, $recursive = false, &$full_report = null)
 {
     $dir = rtrim(_PS_ROOT_DIR_, '\\/') . DIRECTORY_SEPARATOR . trim($relative_dir, '\\/');
     if (!file_exists($dir) || !($dh = opendir($dir))) {
         $full_report = sprintf('Directory %s does not exists or is not writable', $dir);
         // sprintf for future translation
         return false;
     }
     $dummy = rtrim($dir, '\\/') . DIRECTORY_SEPARATOR . uniqid();
     if (false && @file_put_contents($dummy, 'test')) {
         @unlink($dummy);
         if (!$recursive) {
             closedir($dh);
             return true;
         }
     } elseif (!is_writable($dir)) {
         $full_report = sprintf('Directory %s is not writable', $dir);
         // sprintf for future translation
         return false;
     }
     if ($recursive) {
         while (($file = readdir($dh)) !== false) {
             if (is_dir($dir . DIRECTORY_SEPARATOR . $file) && $file != '.' && $file != '..' && $file != '.svn') {
                 if (!ConfigurationTest::test_dir($relative_dir . DIRECTORY_SEPARATOR . $file, $recursive, $full_report)) {
                     return false;
                 }
             }
         }
     }
     closedir($dh);
     return true;
 }
예제 #15
0
    /** this returns fieldset containing the configuration points you need to use autoupgrade
     * @return string
     */
    private function _displayCurrentConfiguration()
    {
        $current_ps_config = $this->getcheckCurrentPsConfig();
        $this->_html .= '<div class="bootstrap" id="currentConfigurationBlock">
            <div class="panel">
                <div class="panel-heading">
                  ' . $this->l('The pre-Upgrade checklist') . '
                </div>';
        if (!$this->configOk()) {
            $this->_html .= '<p class="alert alert-warning">' . $this->l('The checklist is not OK. You can only upgrade your shop once all indicators are green.') . '</p>';
        }
        $this->_html .= '<div id="currentConfiguration">
							<p class="alert alert-info">' . $this->l('Before starting the upgrade process, please make sure this checklist is all green.') . '</p>';
        $pic_ok = '<img src="../img/admin/enabled.gif" alt="ok"/>';
        $pic_nok = '<img src="../img/admin/disabled.gif" alt="nok"/>';
        $pic_warn = '<img src="../img/admin/warning.gif" alt="warn"/>';
        // module version : checkAutoupgradeLastVersion
        $this->_html .= '<table class="table" cellpadding="0" cellspacing="0">
				<tr>
					<td>' . sprintf($this->l('The 1-click upgrade module is up-to-date (your current version is v%s)'), $this->getModuleVersion()) . '
					' . ($current_ps_config['module_version_ok'] ? '' : '&nbsp;&nbsp;' . (version_compare(_PS_VERSION_, '1.5.3.0', '>') ? '<strong><a href="index.php?controller=AdminModules&amp;token=' . Tools14::getAdminTokenLite('AdminModules') . '&update=autoupgrade">' . $this->l('Update') . '</a></strong> - ' : '') . '<strong><a class="_blank" href="http://addons.prestashop.com/en/administration-tools-prestashop-modules/5496-1-click-upgrade-autoupgrade.html">' . $this->l('Download') . '</a><strong> ') . '
					</td>
					<td>' . ($current_ps_config['module_version_ok'] ? $pic_ok : $pic_nok) . '</td>
				</tr>';
        // root : getRootWritable()
        $this->_html .= '
			<tr>
				<td>' . $this->l('Your store\'s root directory is writable (with appropriate CHMOD permissions)') . '</td>
				<td>' . ($current_ps_config['root_writable'] ? $pic_ok : $pic_nok . ' ' . $this->root_writable_report) . '</td>
			</tr>';
        $admin_dir = trim(str_replace($this->prodRootDir, '', $this->adminDir), DIRECTORY_SEPARATOR);
        $report = '';
        ConfigurationTest::test_dir($admin_dir . DIRECTORY_SEPARATOR . $this->autoupgradeDir, true, $report);
        if ($report) {
            $this->_html .= '
				<tr>
					<td>' . $this->l('The "/admin/autoupgrade" directory is writable (appropriate CHMOD permissions)') . '</td>
					<td>' . ($current_ps_config['admin_au_writable'] ? $pic_ok : $pic_nok . ' ' . $report) . '</td>
				</tr>';
        }
        //check safe_mod
        if (!($safe_mode = @ini_get('safe_mode'))) {
            $safe_mode = '';
        }
        $safe_mode = in_array(Tools14::strtolower($safe_mode), array(1, 'on'));
        $this->_html .= '
			<tr><td>' . $this->l('PHP\'s "Safe mode" option is turned off') . '</td>
			<td>' . (!$safe_mode ? $pic_ok : $pic_warn) . '</td></tr>';
        $this->_html .= '
			<tr><td>' . $this->l('PHP\'s "allow_url_fopen" option is turned on, or cURL is installed') . '</td>
			<td>' . (ConfigurationTest::test_fopen() || ConfigurationTest::test_curl() ? $pic_ok : $pic_nok) . '</td></tr>';
        // shop enabled
        $this->_html .= '
			<tr><td>' . $this->l('Your store is in maintenance mode') . ' ' . (!$current_ps_config['shop_deactivated'] ? '<br><form method="post" action="' . $this->currentIndex . '&token=' . $this->token . '"><input type="submit" class="button" name="putUnderMaintenance" value="' . $this->l('Click here to put your shop under maintenance') . '"></form>' : '') . '</td>
			<td>' . ($current_ps_config['shop_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>';
        $this->_html .= '
			<tr><td>' . $this->l('PrestaShop\'s caching features are disabled') . '</td>
			<td>' . ($current_ps_config['cache_deactivated'] ? $pic_ok : $pic_nok) . '</td></tr>';
        // for informaiton, display time limit
        $max_exec_time = ini_get('max_execution_time');
        $this->_html .= '
			<tr><td>' . sprintf($this->l('PHP\'s max_execution_time setting has a high value or is disabled entirely (current value: %s)'), $max_exec_time == 0 ? $this->l('unlimited') : sprintf($this->l('%s seconds'), $max_exec_time)) . '</td>
			<td>' . ($max_exec_time == 0 ? $pic_ok : $pic_warn) . '</td></tr>
        </table>
        <br/>
        <p class="alert alert-info">' . $this->l('Please also make sure you make a full manual backup of your files and database.') . '</p>
        </div>
        </div>
		</div>';
    }
예제 #16
0
    public function postProcessCallback()
    {
        $return = false;
        $installed_modules = array();
        foreach ($this->map as $key => $method) {
            $modules = Tools::getValue($key);
            if (strpos($modules, '|')) {
                $modules_list_save = $modules;
                $modules = explode('|', $modules);
            } else {
                $modules = empty($modules) ? false : array($modules);
            }
            $module_errors = array();
            if ($modules) {
                foreach ($modules as $name) {
                    $full_report = null;
                    if ($key == 'update') {
                        if (ConfigurationTest::test_dir('modules/' . $name, true, $full_report)) {
                            Tools::deleteDirectory('../modules/' . $name . '/');
                        } else {
                            $module = Module::getInstanceByName(urldecode($name));
                            $this->errors[] = $this->l(sprintf("Module %s can't be upgraded : ", $module->displayName)) . $full_report;
                            continue;
                        }
                    }
                    // If Addons module, download and unzip it before installing it
                    if (!file_exists('../modules/' . $name . '/' . $name . '.php')) {
                        $filesList = array(array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0), array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1));
                        foreach ($filesList as $f) {
                            if (file_exists(_PS_ROOT_DIR_ . $f['file'])) {
                                $file = $f['file'];
                                $content = Tools::file_get_contents(_PS_ROOT_DIR_ . $file);
                                $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
                                foreach ($xml->module as $modaddons) {
                                    if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0)) {
                                        if ($f['loggedOnAddons'] == 0) {
                                            if (file_put_contents('../modules/' . $modaddons->name . '.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id))))) {
                                                $this->extractArchive('../modules/' . $modaddons->name . '.zip', false);
                                            }
                                        }
                                        if ($f['loggedOnAddons'] == 1 && $this->logged_on_addons) {
                                            if (file_put_contents('../modules/' . $modaddons->name . '.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons)))))) {
                                                $this->extractArchive('../modules/' . $modaddons->name . '.zip', false);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // Check potential error
                    if (!($module = Module::getInstanceByName(urldecode($name)))) {
                        $this->errors[] = $this->l('Module not found');
                    } elseif ($key == 'install' && $this->tabAccess['add'] !== '1') {
                        $this->errors[] = Tools::displayError('You do not have permission to install this module.');
                    } elseif ($key == 'uninstall' && ($this->tabAccess['delete'] !== '1' || !$module->getPermission('configure'))) {
                        $this->errors[] = Tools::displayError('You do not have permission to delete this module.');
                    } elseif ($key == 'configure' && ($this->tabAccess['edit'] !== '1' || !$module->getPermission('configure') || !Module::isInstalled(urldecode($name)))) {
                        $this->errors[] = Tools::displayError('You do not have permission to configure this module.');
                    } elseif ($key == 'install' && Module::isInstalled($module->name)) {
                        $this->errors[] = Tools::displayError('This module is already installed:') . ' ' . $module->name;
                    } elseif ($key == 'uninstall' && !Module::isInstalled($module->name)) {
                        $this->errors[] = Tools::displayError('This module has already been uninstalled:') . ' ' . $module->name;
                    } else {
                        if ($key == 'update' && !Module::isInstalled($module->name)) {
                            $this->errors[] = Tools::displayError('This module need to be installed in order to be updated:') . ' ' . $module->name;
                        } else {
                            // If we install a module, force temporary global context for multishop
                            if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $method != 'getContent') {
                                Context::getContext()->tmpOldShop = clone Context::getContext()->shop;
                                Context::getContext()->shop = new Shop();
                            }
                            //retrocompatibility
                            if (Tools::getValue('controller') != '') {
                                $_POST['tab'] = Tools::safeOutput(Tools::getValue('controller'));
                            }
                            $echo = '';
                            if ($key != 'update') {
                                // We check if method of module exists
                                if (!method_exists($module, $method)) {
                                    throw new PrestaShopException('Method of module can\'t be found');
                                }
                                // Get the return value of current method
                                $echo = $module->{$method}();
                            }
                            // If the method called is "configure" (getContent method), we show the html code of configure page
                            if ($key == 'configure' && Module::isInstalled($module->name)) {
                                if (isset($module->multishop_context)) {
                                    $this->multishop_context = $module->multishop_context;
                                }
                                $backlink = self::$currentIndex . '&token=' . $this->token . '&tab_module=' . $module->tab . '&module_name=' . $module->name;
                                $hooklink = 'index.php?tab=AdminModulesPositions&token=' . Tools::getAdminTokenLite('AdminModulesPositions') . '&show_modules=' . (int) $module->id;
                                $tradlink = 'index.php?tab=AdminTranslations&token=' . Tools::getAdminTokenLite('AdminTranslations') . '&type=modules&lang=';
                                $toolbar = '<table class="table" cellpadding="0" cellspacing="0" style="margin:auto;text-align:center"><tr>
									<th>' . $this->l('Module') . ' <span style="color: green;">' . $module->name . '</span></th>
									<th><a href="' . $backlink . '" style="padding:5px 10px">' . $this->l('Back') . '</a></th>
									<th><a href="' . $hooklink . '" style="padding:5px 10px">' . $this->l('Manage hooks') . '</a></th>
									<th style="padding:5px 10px">' . $this->l('Manage translations') . ' ';
                                foreach (Language::getLanguages(false) as $language) {
                                    $toolbar .= '<a href="' . $tradlink . $language['iso_code'] . '#' . $module->name . '" style="margin-left:5px"><img src="' . _THEME_LANG_DIR_ . $language['id_lang'] . '.jpg" alt="' . $language['iso_code'] . '" title="' . $language['iso_code'] . '" /></a>';
                                }
                                $toolbar .= '</th></tr>';
                                // Display checkbox in toolbar if multishop
                                if (Shop::isFeatureActive()) {
                                    $activateOnclick = 'onclick="location.href = \'' . $this->getCurrentUrl('enable') . '&enable=\'+(($(this).attr(\'checked\')) ? 1 : 0)"';
                                    $toolbar .= '<tr>
										<th colspan="4">
											<input type="checkbox" name="activateModule" value="1" ' . ($module->active ? 'checked="checked"' : '') . ' ' . $activateOnclick . ' /> ' . $this->l('Activate module for') . ' ';
                                    if (Shop::getContext() == Shop::CONTEXT_SHOP) {
                                        $toolbar .= 'shop <b>' . $this->context->shop->name . '</b>';
                                    } elseif (Shop::getContext() == Shop::CONTEXT_GROUP) {
                                        $shop_group = new ShopGroup((int) Shop::getContextShopGroupID());
                                        $toolbar .= 'all shops of group shop <b>' . $shop_group->name . '</b>';
                                    } else {
                                        $toolbar .= 'all shops';
                                    }
                                    $toolbar .= '</th>
								</tr>';
                                }
                                $toolbar .= '</table>';
                                if (Shop::isFeatureActive() && isset(Context::getContext()->tmpOldShop)) {
                                    Context::getContext()->shop = clone Context::getContext()->tmpOldShop;
                                    unset(Context::getContext()->tmpOldShop);
                                }
                                // Display module configuration
                                $this->context->smarty->assign('module_content', $toolbar . '<div class="clear">&nbsp;</div>' . $echo . '<div class="clear">&nbsp;</div>' . $toolbar);
                            } elseif ($echo === true) {
                                $return = 13;
                                if ($method == 'install') {
                                    $return = 12;
                                    $installed_modules[] = $module->id;
                                }
                            } elseif ($echo === false) {
                                $module_errors[] = array('name' => $name, 'message' => $module->getErrors());
                            }
                            if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && isset(Context::getContext()->tmpOldShop)) {
                                Context::getContext()->shop = clone Context::getContext()->tmpOldShop;
                                unset(Context::getContext()->tmpOldShop);
                            }
                        }
                    }
                    if ($key != 'configure' && isset($_GET['bpay'])) {
                        Tools::redirectAdmin('index.php?tab=AdminPayment&token=' . Tools::getAdminToken('AdminPayment' . (int) Tab::getIdFromClassName('AdminPayment') . (int) $this->id_employee));
                    }
                }
            }
            if (count($module_errors)) {
                // If error during module installation, no redirection
                $html_error = $this->generateHtmlMessage($module_errors);
                $this->errors[] = sprintf(Tools::displayError('The following module(s) were not installed properly: %s'), $html_error);
                $this->context->smarty->assign('error_module', 'true');
            }
        }
        if ($return) {
            $params = count($installed_modules) ? '&installed_modules=' . implode('|', $installed_modules) : '';
            // If redirect parameter is present and module installed with success, we redirect on configuration module page
            if (Tools::getValue('redirect') == 'config' && Tools::getValue('module_name') != '' && $return == '12' && Module::isInstalled(pSQL(Tools::getValue('module_name')))) {
                Tools::redirectAdmin('index.php?controller=adminmodules&configure=' . Tools::getValue('module_name') . '&token=' . Tools::getValue('token') . '&module_name=' . Tools::getValue('module_name') . $params);
            }
            Tools::redirectAdmin(self::$currentIndex . '&conf=' . $return . '&token=' . $this->token . '&tab_module=' . $module->tab . '&module_name=' . $module->name . '&anchor=anchor' . ucfirst($module->name) . (isset($modules_list_save) ? '&modules_list=' . $modules_list_save : '') . $params);
        }
    }
예제 #17
0
 public static function test_files()
 {
     $return = ConfigurationTest::test_files_();
     return empty($return);
 }
예제 #18
0
 public static function test_virtual_products_dir($dir)
 {
     return ConfigurationTest::test_dir($dir);
 }
예제 #19
0
    public function displayDebug()
    {
        global $start_time;
        $this->display();
        $this->_memory['display'] = memory_get_usage();
        $this->_mempeak['display'] = memory_get_peak_usage();
        $this->_time['display'] = microtime(true);
        if (!$this->ini_get_display_errors()) {
            return;
        }
        $memory_peak_usage = memory_get_peak_usage();
        $hr = '<hr style="color:#F5F5F5;margin:2px" />';
        $totalSize = 0;
        foreach (get_included_files() as $file) {
            $totalSize += filesize($file);
        }
        $totalQueryTime = 0;
        foreach (Db::getInstance()->queries as $data) {
            $totalQueryTime += $data['time'];
        }
        $hooktime = Hook::getHookTime();
        arsort($hooktime);
        $totalHookTime = 0;
        foreach ($hooktime as $time) {
            $totalHookTime += $time;
        }
        $hookMemoryUsage = Hook::getHookMemoryUsage();
        arsort($hookMemoryUsage);
        $totalHookMemoryUsage = 0;
        foreach ($hookMemoryUsage as $usage) {
            $totalHookMemoryUsage += $usage;
        }
        $globalSize = array();
        $totalGlobalSize = 0;
        foreach ($GLOBALS as $key => $value) {
            if ($key != 'GLOBALS') {
                $totalGlobalSize += $size = $this->sizeofvar($value);
                if ($size > 1024) {
                    $globalSize[$key] = round($size / 1024, 1);
                }
            }
        }
        arsort($globalSize);
        $cache = Cache::retrieveAll();
        $totalCacheSize = $this->sizeofvar($cache);
        $output = '';
        $output .= '<link href="' . Tools::getShopDomain(true) . '/modules/debugtoolbar/views/assets/css/debugtoolbar.css" rel="stylesheet" type="text/css" media="all">';
        $output .= '	<div class="debugtoolbar">

							<div class="debugtoolbar-window">
								<div class="debugtoolbar-content-area">
		';
        /* LOAD TIME */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-load-times">';
        $output .= '					<table>
											<tr>
												<th>Name</th>
												<th>Running Time (ms)</th>
											</tr>
											<tr>
												<td class="debugtoolbar-table-first">Global Application</td>
												<td>' . $this->displayLoadTimeColor($this->_time['display'] - $start_time, true) . '</td>
											</tr>
		';
        $last_time = $start_time;
        foreach ($this->_time as $k => $time) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . ucfirst($k) . '</td>
												<td>' . $this->displayLoadTimeColor($time - $last_time, true) . '</td>
											</tr>
			';
            $last_time = $time;
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /LOAD TIME */
        /* HOOK PROCESSING */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-hook-processing">';
        $output .= '					<table>
											<tr>
												<th>Name</th>
												<th>Running Time (ms) / Memory Usage</th>
											</tr>
											<tr>
												<td class="debugtoolbar-table-first">Global Hook</td>
												<td><pre>' . $this->displayLoadTimeColor($totalHookTime) . ' / ' . $this->displayMemoryColor($totalHookMemoryUsage) . '</pre></td>
											</tr>
		';
        foreach ($hooktime as $hook => $time) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . ucfirst($hook) . '</td>
												<td><pre>' . $this->displayLoadTimeColor($time) . ' / ' . $this->displayMemoryColor($hookMemoryUsage[$hook]) . '</pre></td>
											</tr>
			';
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /HOOK PROCESSING */
        /* MEMORY PEAK USAGE */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-memory-peak-usage">';
        $output .= '					<table>
											<tr>
												<th>Name</th>
												<th>Memory Usage (Global)</th>
											</tr>
											<tr>
												<td class="debugtoolbar-table-first">Global Memory</td>
												<td><pre>' . $this->displayPeakMemoryColor($memory_peak_usage) . '</pre></td>
											</tr>
		';
        foreach ($this->_memory as $k => $memory) {
            $last_memory = 0;
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . ucfirst($k) . '</td>
												<td><pre>' . $this->displayMemoryColor($memory - $last_memory) . ' (' . $this->displayPeakMemoryColor($this->_mempeak[$k]) . ')</pre></td>
											</tr>
			';
            $last_memory = $memory;
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /MEMORY PEAK USAGE */
        /* INCLUDED FILES */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-included-files">';
        $output .= '					<table>
											<tr>
												<th>#</th>
												<th>File</th>
												<th>Size</th>
											</tr>
											<tr>
												<td class="debugtoolbar-table-first">Size global files</td>
												<td><pre>' . $this->displayMemoryColor($totalSize) . '</pre></td>
												<td>-</td>
											</tr>
		';
        $i = 1;
        foreach (get_included_files() as $file) {
            $f = ltrim(str_replace('\\', '/', str_replace(_PS_ROOT_DIR_, '', $file)), '/');
            $f = dirname($file) . '/<span style="color: #0080b0">' . basename($file) . '</span>';
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . $i . '</td>
												<td><pre>' . $f . '</pre></td>
												<td>' . FileSizeConvert(@filesize($file)) . '</td>
											</tr>
			';
            $i++;
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /INCLUDED FILES */
        /* SQL QUERIES */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-sql-queries">';
        $output .= '					<table>
											<tr>
												<th>Time</th>
												<th>Query</th>
											</tr>
		';
        $array_queries = array();
        $queries = Db::getInstance()->queries;
        uasort($queries, 'prestashop_querytime_sort');
        foreach ($queries as $data) {
            $query_row = array('time' => $data['time'], 'query' => $data['query'], 'location' => $data['file'] . ':<span style="color:#0080b0">' . $data['line'] . '</span>', 'filesort' => false, 'rows' => 1, 'group_by' => false);
            if (preg_match('/^\\s*select\\s+/i', $data['query'])) {
                $explain = Db::getInstance()->executeS('explain ' . $data['query']);
                if (stristr($explain[0]['Extra'], 'filesort')) {
                    $query_row['filesort'] = true;
                }
                foreach ($explain as $row) {
                    $query_row['rows'] *= $row['rows'];
                }
                if (stristr($data['query'], 'group by') && !preg_match('/(avg|count|min|max|group_concat|sum)\\s*\\(/i', $data['query'])) {
                    $query_row['group_by'] = true;
                }
            }
            $array_queries[] = $query_row;
        }
        foreach ($array_queries as $data) {
            $filestortGroup = '';
            if (preg_match('/^\\s*select\\s+/i', $data['query'])) {
                if ($data['filesort']) {
                    $filestortGroup .= '<b ' . $this->getTimeColor($data['time'] * 1000) . '>USING FILESORT</b> - ';
                }
                $filestortGroup .= $this->displayRowsBrowsed($data['rows']);
                if ($data['group_by']) {
                    $filestortGroup .= ' - <b>Useless GROUP BY need to be removed</b>';
                }
            }
            $output .= '
											<tr>
												<td class="debugtoolbar-table-title" colspan="2"><strong>Query in : </strong>' . $data['location'] . ' - ' . $filestortGroup . '</td>
											</tr>
											<tr>
												<td class="debugtoolbar-table-first"><span ' . $this->getTimeColor($data['time'] * 1000) . '>' . round($data['time'] * 1000, 3) . ' ms</span></td>
												<td><pre>' . htmlspecialchars($data['query'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
											</tr>
			';
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /SQL QUERIES */
        /* TABLES */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-sql-table">';
        $output .= '					<table>
											<tr>
												<th>Nb call</th>
												<th>Table</th>
											</tr>
		';
        $tables = Db::getInstance()->tables;
        arsort($tables);
        foreach ($tables as $table => $nb) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first"><b ' . $this->getTableColor($nb) . '>' . $nb . '</b></td>
												<td><pre>' . $table . '</pre></td>
											</tr>
			';
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /TABLES */
        /* OBJECTMODEL */
        if (isset(ObjectModel::$debug_list)) {
            $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-objectmodel-instance">';
            $output .= '					<table>
												<tr>
													<th>Nb call</th>
													<th>ObjectModel Instance</th>
												</tr>
			';
            $list = ObjectModel::$debug_list;
            uasort($list, create_function('$a,$b', 'return (count($a) < count($b)) ? 1 : -1;'));
            $i = 0;
            foreach ($list as $class => $info) {
                echo '';
                echo '';
                $i++;
                $output .= '
												<tr>
													<td class="debugtoolbar-table-first"><b ' . $this->getObjectModelColor(count($info)) . '>' . count($info) . '</b></td>
													<td><a href="#" onclick="$(\'#object_model_' . $i . '\').css(\'display\', $(\'#object_model_' . $i . '\').css(\'display\') == \'none\' ? \'block\' : \'none\'); return false" style="color:#0080b0">' . $class . '</a>
														<pre id="object_model_' . $i . '" style="display: none">';
                foreach ($info as $trace) {
                    $output .= ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') . ' [' . $trace['line'] . ']<br />';
                }
                $output .= '</pre></td>
												</tr>
				';
            }
            $output .= '
											</table>
			';
            $output .= '				</div>';
        }
        /* /OBJECTMODEL */
        /* GETALLHEADERS */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-getallheader">';
        $output .= '					<table>
											<tr>
												<th>Name</th>
												<th>Value</th>
											</tr>
		';
        $getallheaders = getallheaders();
        foreach ($getallheaders as $name => $value) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . $name . '</td>
												<td><pre>' . $value . '</pre></td>
											</tr>
			';
        }
        stream_context_set_default(array('http' => array('method' => 'HEAD')));
        $url = getUrl();
        if ($get_headers = get_headers($url, 1)) {
            foreach ($get_headers as $name => $value) {
                $output .= '
												<tr>
													<td class="debugtoolbar-table-first">' . $name . '</td>
													<td><pre>' . (is_array($value) ? $value[0] : $value) . '</pre></td>
												</tr>
				';
            }
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /GETALLHEADERS */
        /* DATA */
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-getpost-data">';
        $output .= '					<table>
											<tr>
												<th>Name</th>
												<th>Value</th>
											</tr>
											<tr>
												<td class="debugtoolbar-table-title" colspan="2">Post Data</td>
											</tr>
		';
        $post = isset($_POST) ? $_POST : array();
        if (!count($post)) {
            $output .= '<tr><td colspan="2">No POST Data Found</td></tr>';
        } else {
            foreach ($post as $name => $value) {
                if (!is_array($value)) {
                    $output .= '
													<tr>
														<td class="debugtoolbar-table-first">' . $name . '</td>
														<td><pre>' . $value . '</pre></td>
													</tr>
					';
                } else {
                    $output .= '
													<tr>
														<td class="debugtoolbar-table-first">' . $name . '</td>
														<td>
					';
                    foreach ($value as $k => $v) {
                        $output .= '
															<pre>' . $k . ' : ' . $v . '</pre>
						';
                    }
                    $output .= '
														</td>
													</tr>
					';
                }
            }
        }
        $output .= '						<tr>
												<td class="debugtoolbar-table-title" colspan="2">Get Data</td>
											</tr>
		';
        $get = isset($_GET) ? $_GET : array();
        if (!count($get)) {
            $output .= '<tr><td colspan="2">No GET Data Found</td></tr>';
        } else {
            foreach ($get as $name => $value) {
                $output .= '
												<tr>
													<td class="debugtoolbar-table-first">' . $name . '</td>
													<td><pre>' . $value . '</pre></td>
												</tr>
				';
            }
        }
        $output .= '						<tr>
												<td class="debugtoolbar-table-title" colspan="2">Server Data</td>
											</tr>
		';
        $server = isset($_SERVER) ? $_SERVER : array();
        if (!count($server)) {
            $output .= '<tr><td colspan="2">No SERVER Data Found</td></tr>';
        } else {
            foreach ($server as $name => $value) {
                $output .= '
												<tr>
													<td class="debugtoolbar-table-first">' . $name . '</td>
													<td><pre>' . $value . '</pre></td>
												</tr>
				';
            }
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* /DATA */
        /* DEBUG */
        if (count($GLOBALS['debugtoolbar'])) {
            $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-debug">';
            $output .= '					<table>
												<tr>
													<th>Debug</th>
												</tr>
			';
            $output .= '
												<tr>
													<td colspan="2">' . $GLOBALS['debugtoolbar'] . '</td>
												</tr>
			';
            $output .= '
											</table>
			';
            $output .= '				</div>';
        }
        /* /DEBUG */
        /* PS INFOS */
        if (isset($this->context->employee->id)) {
            $ps_infos = array('version' => array('php' => phpversion(), 'server' => $_SERVER['SERVER_SOFTWARE'], 'memory_limit' => ini_get('memory_limit'), 'max_execution_time' => ini_get('max_execution_time')), 'database' => array('version' => Db::getInstance()->getVersion(), 'prefix' => _DB_PREFIX_, 'engine' => _MYSQL_ENGINE_), 'uname' => function_exists('php_uname') ? php_uname('s') . ' ' . php_uname('v') . ' ' . php_uname('m') : '', 'apache_instaweb' => Tools::apacheModExists('mod_instaweb'), 'shop' => array('ps' => _PS_VERSION_, 'url' => Tools::getHttpHost(true) . __PS_BASE_URI__, 'theme' => _THEME_NAME_), 'mail' => Configuration::get('PS_MAIL_METHOD') == 1, 'smtp' => array('server' => Configuration::get('PS_MAIL_SERVER'), 'user' => Configuration::get('PS_MAIL_USER'), 'password' => Configuration::get('PS_MAIL_PASSWD'), 'encryption' => Configuration::get('PS_MAIL_SMTP_ENCRYPTION'), 'port' => Configuration::get('PS_MAIL_SMTP_PORT')), 'user_agent' => $_SERVER['HTTP_USER_AGENT']);
            $tests = ConfigurationTest::getDefaultTests();
            $tests_op = ConfigurationTest::getDefaultTestsOp();
            $params_required_results = ConfigurationTest::check($tests);
            $params_optional_results = ConfigurationTest::check($tests_op);
            $tests_errors = array('phpversion' => 'Update your PHP version', 'upload' => 'Configure your server to allow file uploads', 'system' => 'Configure your server to allow the creation of directories and files with write permissions.', 'gd' => 'Enable the GD library on your server.', 'mysql_support' => 'Enable the MySQL support on your server.', 'config_dir' => 'Set write permissions for the "config" folder.', 'cache_dir' => 'Set write permissions for the "cache" folder.', 'sitemap' => 'Set write permissions for the "sitemap.xml" file.', 'img_dir' => 'Set write permissions for the "img" folder and subfolders.', 'log_dir' => 'Set write permissions for the "log" folder and subfolders.', 'mails_dir' => 'Set write permissions for the "mails" folder and subfolders.', 'module_dir' => 'Set write permissions for the "modules" folder and subfolders.', 'theme_lang_dir' => 'Set the write permissions for the "themes' . _THEME_NAME_ . '/lang/" folder and subfolders, recursively.', 'translations_dir' => 'Set write permissions for the "translations" folder and subfolders.', 'customizable_products_dir' => 'Set write permissions for the "upload" folder and subfolders.', 'virtual_products_dir' => 'Set write permissions for the "download" folder and subfolders.', 'fopen' => 'Allow the PHP fopen() function on your server', 'register_globals' => 'Set PHP "register_global" option to "Off"', 'gz' => 'Enable GZIP compression on your server.');
            $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-ps-info">';
            $output .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\$(document).ready(function()\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\$.ajax({\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: 'GET',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\turl: '" . $this->context->link->getAdminLink('AdminInformation') . "',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdata: {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'action': 'checkFiles',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'ajax': 1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdataType: 'json',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsuccess: function(json)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar tab = {\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'missing': 'Missing files',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'updated': 'Updated files'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (json.missing.length || json.updated.length)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('#changedFilesDebugtoolbar').html('<div style=\"color:#ef8400;\">Changed/missing files have been detected.</div>');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('#changedFilesDebugtoolbar').html('<div style=\"color:#0080b0;\">No change has been detected in your files</div>');\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$.each(tab, function(key, lang)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (json[key].length)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar html = \$('<ul>').attr('id', key+'_files');\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$(json[key]).each(function(key, file)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\thtml.append(\$('<li>').html(file))\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\$('#changedFilesDebugtoolbar')\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.append(\$('<h3>').html(lang+' ('+json[key].length+')'))\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.append(html);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\t</script>\r\n\t\t\t";
            $output .= '					<table>
												<tr>
													<th>Name</th>
													<th>Value</th>
												</tr>
			';
            $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>Server Informations</strong></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Server</td>
													<td><pre>' . htmlspecialchars($ps_infos['uname'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Logiciel Serveur</td>
													<td><pre>' . htmlspecialchars($ps_infos['version']['server'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">PHP Version</td>
													<td><pre>' . htmlspecialchars($ps_infos['version']['php'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Memory Limit</td>
													<td><pre>' . htmlspecialchars($ps_infos['version']['memory_limit'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Max Execution Time</td>
													<td><pre>' . htmlspecialchars($ps_infos['version']['max_execution_time'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
			';
            $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>Database Informations</strong></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">MySQL Version</td>
													<td><pre>' . htmlspecialchars($ps_infos['database']['version'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">MySQL Engine</td>
													<td><pre>' . htmlspecialchars($ps_infos['database']['engine'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">MySQL Prefix</td>
													<td><pre>' . htmlspecialchars($ps_infos['database']['prefix'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
			';
            $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>Store Informations</strong></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">PrestaShop Version</td>
													<td><pre>' . htmlspecialchars($ps_infos['shop']['ps'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Store Url</td>
													<td><pre>' . htmlspecialchars($ps_infos['shop']['url'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Themes Use</td>
													<td><pre>' . htmlspecialchars($ps_infos['shop']['theme'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
			';
            if (!empty($ps_infos['mail'])) {
                $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>Email Setting</strong></td>
												</tr>
												<tr>
													<td colspan="2"><pre>You are using the PHP mail function.</pre></td>
												</tr>
				';
            } else {
                $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>Email Setting</strong></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">SMTP Server</td>
													<td><pre>' . htmlspecialchars($ps_infos['smtp']['server'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Cryptage</td>
													<td><pre>' . htmlspecialchars($ps_infos['smtp']['encryption'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Port</td>
													<td><pre>' . htmlspecialchars($ps_infos['smtp']['port'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Login</td>
													<td><pre>' . (!empty($ps_infos['smtp']['user']) ? '<span style="color:#90bd00;font-weight:bold;">OK</span>' : '<span style="color:#ff4141;font-weight:bold;">Not defined</span>') . '</pre></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Password</td>
													<td><pre>' . (!empty($ps_infos['smtp']['password']) ? '<span style="color:#90bd00;font-weight:bold;">OK</span>' : '<span style="color:#ff4141;font-weight:bold;">Not defined</span>') . '</pre></td>
												</tr>
				';
            }
            $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>Your information</strong></td>
												</tr>
												<tr>
													<td class="debugtoolbar-table-first">Your web browser</td>
													<td><pre>' . htmlspecialchars($ps_infos['user_agent'], ENT_NOQUOTES, 'utf-8', false) . '</pre></td>
												</tr>
			';
            $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>Check your configuration</strong></td>
												</tr>
			';
            $output .= '
												<tr>
													<td class="debugtoolbar-table-first">Required parameters</td>
			';
            if (!in_array('fail', $params_required_results)) {
                $output .= '
													<td><pre><span style="color:#90bd00;font-weight:bold;">OK</span></pre></td>
				';
            } else {
                $output .= '
													<td>
														<pre><span style="color:#ff4141;font-weight:bold;">Please fix the following error(s)</span></pre>
														<ul>
				';
                foreach ($params_required_results as $key => $value) {
                    if ($value == 'fail') {
                        $output .= '						<li>' . $tests_errors[$key] . '</li>';
                    }
                }
                $output .= '
														</ul>
													</td>
				';
            }
            $output .= '
												</tr>
			';
            $output .= '
												<tr>
													<td class="debugtoolbar-table-first">Optional parameters</td>
			';
            if (!in_array('fail', $params_optional_results)) {
                $output .= '
													<td><pre><span style="color:#90bd00;font-weight:bold;">OK</span></pre></td>
				';
            } else {
                $output .= '
													<td>
														<pre><span style="color:#ff4141;font-weight:bold;">Please fix the following error(s)</span></pre>
														<ul>
				';
                foreach ($params_optional_results as $key => $value) {
                    if ($value == 'fail') {
                        $output .= '						<li>' . $key . '</li>';
                    }
                }
                $output .= '
														</ul>
													</td>
				';
            }
            $output .= '
												</tr>
			';
            $output .= '
												<tr>
													<td class="debugtoolbar-table-title" colspan="2"><strong>List of changed files</strong></td>
												</tr>
			';
            $output .= '
												<tr>
													<td colspan="2"><div id="changedFilesDebugtoolbar"><img src="../img/admin/ajax-loader.gif" /> Checking files...</div></td>
												</tr>
			';
            $output .= '
											</table>
			';
            $output .= '				</div>';
        } else {
            $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-ps-info">';
            $output .= '					<table>
												<tr>
													<td><pre><span style="color:#ff4141;font-weight:bold;">Not display in Front office</span></pre></td>
												</tr>
											</table>
										</div>
			';
        }
        /* /PS INFOS */
        /* SMARTY DEBUG */
        $this->context->smarty->loadPlugin('Smarty_Internal_Debug');
        // Smarty_Internal_Debug::display_debug($this->context->smarty);
        $SID = new Smarty_Internal_Debug();
        $obj = $this->context->smarty;
        $ptr = $SID::get_debug_vars($obj);
        if ($obj instanceof Smarty) {
            $smarty = clone $obj;
        } else {
            $smarty = clone $obj->smarty;
        }
        $_assigned_vars = $ptr->tpl_vars;
        ksort($_assigned_vars);
        $_config_vars = $ptr->config_vars;
        ksort($_config_vars);
        $smarty->registered_filters = array();
        $smarty->autoload_filters = array();
        $smarty->default_modifiers = array();
        $smarty->force_compile = false;
        $smarty->left_delimiter = '{';
        $smarty->right_delimiter = '}';
        $smarty->debugging = false;
        $smarty->force_compile = false;
        if ($obj instanceof Smarty_Internal_Template) {
            $template_name = $obj->source->type . ':' . $obj->source->name;
        }
        if ($obj instanceof Smarty) {
            $template_name = $SID::$template_data;
        } else {
            $template_name = null;
        }
        $execution_time = microtime(true) - $smarty->start_time;
        $assigned_vars = $_assigned_vars;
        $config_vars = $_config_vars;
        // echo 'assigned_vars<pre>'.print_r($assigned_vars['SCRIPT_NAME'], true).'</pre>';die;
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-smarty-debug">';
        $output .= '					<table>
											<tr>
												<th colspan="2">Smarty Debug Console  -  ' . (isset($template_name) && count($template_name) ? $template_name : 'Total Time ' . number_format($execution_time, 5, '.', '')) . '</th>
											</tr>
		';
        if (isset($template_name) && count($template_name)) {
            foreach ($template_name as $template) {
                $output .= '
											<tr>
												<td class="debugtoolbar-table-first"><font color=brown>' . $template['name'] . '</font></td>
												<td>
													<span style="font-size: 0.8em;font-style: italic;">
														' . number_format($template['compile_time'], 5, '.', '') . '
														' . number_format($template['render_time'], 5, '.', '') . '
														' . number_format($template['cache_time'], 5, '.', '') . '
													</span>
												</td>
											</tr>
				';
            }
        }
        $output .= '
											<tr>
												<td class="debugtoolbar-table-title" colspan="2"><strong>Assigned template variables</strong></td>
											</tr>
		';
        foreach ($assigned_vars as $key => $vars) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . $key . '</td>
												<td><pre>' . smarty_modifier_debug_print_var($vars) . '</pre></td>
											</tr>
			';
        }
        $output .= '
											<tr>
												<td class="debugtoolbar-table-title" colspan="2"><trong>Assigned config file variables (outer template scope)</strong></td>
											</tr>
		';
        foreach ($config_vars as $key => $vars) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . $key . '</td>
												<td><pre>' . smarty_modifier_debug_print_var($vars) . '</pre></td>
											</tr>
			';
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* SMARTY DEBUG */
        /* ADMINER */
        if (isset($this->context->employee->id)) {
            $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-adminer">';
            $output .= '					<table>
											<tr>
												<th>Adminer</th>
											</tr>
		';
            $output .= '
											<tr>
												<td colspan="2">
												<iframe src="' . Tools::getShopDomain(true) . '/modules/debugtoolbar/tools/adminer/display.php?server=' . _DB_SERVER_ . '&username='******'&db=' . _DB_NAME_ . '" frameborder="0" height="880" width="100%" id="adminerFrame"></iframe>
													<script type="text/javascript">
														$(\'#adminerFrame\').load(function(){
															$self = $(this).contents();
															$self.find("input[name=\'auth[server]\']").val("' . _DB_SERVER_ . '");
															$self.find("input[name=\'auth[username]\']").val("' . _DB_USER_ . '");
															$self.find("input[name=\'auth[password]\']").val("' . _DB_PASSWD_ . '");
															$self.find("input[name=\'auth[db]\']").val("' . _DB_NAME_ . '");
														});
													</script>
												</td>
											</tr>
		';
            $output .= '
										</table>
		';
            $output .= '				</div>';
        } else {
            $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-adminer">';
            $output .= '					<table>
												<tr>
													<td><pre><span style="color:#ff4141;font-weight:bold;">Not display in Front office</span></pre></td>
												</tr>
											</table>
										</div>
			';
        }
        /* /ADMINER */
        $output .= '			</div>
							</div>

							<ul id="debugtoolbar-open-tabs" class="debugtoolbar-tabs">

								<!-- LOAD TIME -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-load-times">Time <span class="debugtoolbar-count">' . $this->displayLoadTimeColor($this->_time['display'] - $start_time) . '</span></a></li>
								<!-- /LOAD TIME -->

								<!-- HOOK PROCESSING -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-hook-processing">Hook <span class="debugtoolbar-count">' . $this->displayLoadTimeColor($totalHookTime) . ' / ' . $this->displayMemoryColor($totalHookMemoryUsage) . '</span></a></li>
								<!-- /HOOK PROCESSING -->

								<!-- MEMORY PEAK USAGE -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-memory-peak-usage">Memory <span class="debugtoolbar-count">' . $this->displayPeakMemoryColor($memory_peak_usage) . '</span></a></li>
								<!-- /MEMORY PEAK USAGE -->

								<!-- INCLUDED FILES -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-included-files">Files <span class="debugtoolbar-count">' . sizeof(get_included_files()) . '</span></a></li>
								<!-- /INCLUDED FILES -->

								<!-- SQL QUERIES -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-sql-queries">Sql <span class="debugtoolbar-count">' . $this->displaySQLQueries(count(Db::getInstance()->queries)) . '</span><span class="debugtoolbar-count">' . $this->displayLoadTimeColor($totalQueryTime) . '</span></a></li>
								<!-- /SQL QUERIES -->

								<!-- TABLE -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-sql-table">Table</a></li>
								<!-- /TABLE -->

								<!-- OBJECTMODEL -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-objectmodel-instance">ObjectModel</a></li>
								<!-- /OBJECTMODEL -->

								<!-- GETALLHEADERS -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-getallheader">Header</a></li>
								<!-- /GETALLHEADERS -->

								<!-- DATA -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-getpost-data">Data</a></li>
								<!-- /DATA -->

								<!-- PS INFOS -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-ps-info">Infos</a></li>
								<!-- /PS INFOS -->

								<!-- SMARTY DEBUG -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-smarty-debug">Smarty</a></li>
								<!-- /SMARTY DEBUG -->

								<!-- ADMINER -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-adminer">Adminer</a></li>
								<!-- /ADMINER -->
		';
        if (count($GLOBALS['debugtoolbar'])) {
            $output .= '
								<!-- DEBUG -->
								<li><a class="debugtoolbar-tab" data-debugtoolbar-tab="debugtoolbar-debug">Debug</a></li>
								<!-- /DEBUG -->
			';
        }
        $output .= '			<li class="debugtoolbar-tab-right"><a id="debugtoolbar-hide" href="#">&#8614;</a></li>
								<li class="debugtoolbar-tab-right"><a id="debugtoolbar-close" href="#">&times;</a></li>
								<li class="debugtoolbar-tab-right"><a id="debugtoolbar-zoom" href="#">&#8645;</a></li>
							</ul>

							<ul id="debugtoolbar-closed-tabs" class="debugtoolbar-tabs">
								<li><a id="debugtoolbar-show" href="#">&#8612;</a></li>
							</ul>

						</div>
		';
        $output .= '<script type="text/javascript" src="' . Tools::getShopDomain(true) . '/modules/debugtoolbar/views/assets/js/debugtoolbar.js"></script>';
        echo $output;
    }