public function renderView() { $this->initPageHeaderToolbar(); $this->tpl_view_vars = 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']); $this->tpl_view_vars = array_merge($this->getTestResult(), $this->tpl_view_vars); return parent::renderView(); }
public function renderView() { $this->initPageHeaderToolbar(); $hosting_vars = array(); if (!defined('_PS_HOST_MODE_')) { $hosting_vars = 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(), 'server' => _DB_SERVER_, 'name' => _DB_NAME_, 'user' => _DB_USER_, 'prefix' => _DB_PREFIX_, 'engine' => _MYSQL_ENGINE_, 'driver' => Db::getClass()), 'uname' => function_exists('php_uname') ? php_uname('s') . ' ' . php_uname('v') . ' ' . php_uname('m') : '', 'apache_instaweb' => Tools::apacheModExists('mod_instaweb')); } $shop_vars = array('shop' => array('ps' => _PS_VERSION_, 'url' => $this->context->shop->getBaseURL(), 'theme' => $this->context->shop->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']); $this->tpl_view_vars = array_merge($this->getTestResult(), array_merge($hosting_vars, $shop_vars)); return parent::renderView(); }
public function __construct() { $this->bootstrap = true; $this->className = 'Configuration'; $this->table = 'configuration'; parent::__construct(); foreach (Contact::getContacts($this->context->language->id) as $contact) { $arr[] = array('email_message' => $contact['id_contact'], 'name' => $contact['name']); } $this->fields_options = array('email' => array('title' => $this->l('Email'), 'icon' => 'icon-envelope', 'fields' => array('PS_MAIL_EMAIL_MESSAGE' => array('title' => $this->l('Send email to'), 'desc' => $this->l('Where customers send messages from the order page.'), 'validation' => 'isUnsignedId', 'type' => 'select', 'cast' => 'intval', 'identifier' => 'email_message', 'list' => $arr), 'PS_MAIL_METHOD' => array('title' => '', 'validation' => 'isGenericName', 'type' => 'radio', 'required' => true, 'choices' => array(3 => $this->l('Never send emails (may be useful for testing purposes)'), 1 => $this->l('Use PHP\'s mail() function (recommended; works in most cases)'), 2 => $this->l('Set my own SMTP parameters (for advanced users ONLY)')), 'js' => array(1 => 'onclick="$(\'#configuration_fieldset_smtp\').slideUp();"', 2 => 'onclick="$(\'#configuration_fieldset_smtp\').slideDown();"', 3 => 'onclick="$(\'#configuration_fieldset_smtp\').slideUp();"'), 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_TYPE' => array('title' => '', 'validation' => 'isGenericName', 'type' => 'radio', 'required' => true, 'choices' => array(Mail::TYPE_HTML => $this->l('Send email in HTML format'), Mail::TYPE_TEXT => $this->l('Send email in text format'), Mail::TYPE_BOTH => $this->l('Both')))), 'submit' => array('title' => $this->l('Save'))), 'smtp' => array('title' => $this->l('Email'), 'fields' => array('PS_MAIL_DOMAIN' => array('title' => $this->l('Mail domain name'), 'hint' => $this->l('Fully qualified domain name (keep this field empty if you don\'t know).'), 'empty' => true, 'validation' => 'isUrl', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_SERVER' => array('title' => $this->l('SMTP server'), 'hint' => $this->l('IP address or server name (e.g. smtp.mydomain.com).'), 'validation' => 'isGenericName', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_USER' => array('title' => $this->l('SMTP user'), 'hint' => $this->l('Leave blank if not applicable.'), 'validation' => 'isGenericName', 'type' => 'text', 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_PASSWD' => array('title' => $this->l('SMTP password'), 'hint' => $this->l('Leave blank if not applicable.'), 'validation' => 'isAnything', 'type' => 'password', 'visibility' => Shop::CONTEXT_ALL, 'autocomplete' => false), 'PS_MAIL_SMTP_ENCRYPTION' => array('title' => $this->l('Encryption'), 'hint' => $this->l('Use an encrypt protocol'), 'desc' => Tools::apacheModExists('mod_ssl') ? '/!\\ ' . $this->l('SSL mod seems to not be installed on your server.') : '', 'type' => 'select', 'cast' => 'strval', 'identifier' => 'mode', 'list' => array(array('mode' => 'off', 'name' => $this->l('None')), array('mode' => 'tls', 'name' => $this->l('TLS')), array('mode' => 'ssl', 'name' => $this->l('SSL'))), 'visibility' => Shop::CONTEXT_ALL), 'PS_MAIL_SMTP_PORT' => array('title' => $this->l('Port'), 'hint' => $this->l('Port number to use.'), 'validation' => 'isInt', 'type' => 'text', 'cast' => 'intval', 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array('title' => $this->l('Save'))), 'test' => array('title' => $this->l('Test your email configuration'), 'hide_multishop_checkbox' => true, 'fields' => array('PS_SHOP_EMAIL' => array('title' => $this->l('Send a test email to'), 'type' => 'text', 'id' => 'testEmail', 'no_multishop_checkbox' => true)), 'bottom' => '<div class="row"><div class="col-lg-9 col-lg-offset-3"> <div class="alert" id="mailResultCheck" style="display:none;"></div> </div></div>', 'buttons' => array(array('title' => $this->l('Send an email test'), 'icon' => 'process-icon-envelope', 'name' => 'btEmailTest', 'js' => 'verifyMail()', 'class' => 'btn btn-default pull-right')))); }
public static function modRewriteActive() { if (Tools::apacheModExists('mod_rewrite')) { return true; } if (isset($_SERVER['HTTP_MOD_REWRITE']) && Tools::strtolower($_SERVER['HTTP_MOD_REWRITE']) == 'on' || Tools::strtolower(getenv('HTTP_MOD_REWRITE')) == 'on') { return true; } return false; }
/** * renderForm contains all necessary initialization needed for all tabs * * @return string|void * @throws PrestaShopException */ public function renderForm() { // This nice code (irony) is here to store the product name, because the row after will erase product name in multishop context $this->product_name = $this->object->name[$this->context->language->id]; if (!method_exists($this, 'initForm' . $this->tab_display)) { return; } $product = $this->object; // Product for multishop $this->context->smarty->assign('bullet_common_field', ''); if (Shop::isFeatureActive() && $this->display == 'edit') { if (Shop::getContext() != Shop::CONTEXT_SHOP) { $this->context->smarty->assign(array('display_multishop_checkboxes' => true, 'multishop_check' => Tools::getValue('multishop_check'))); } if (Shop::getContext() != Shop::CONTEXT_ALL) { $this->context->smarty->assign('bullet_common_field', '<i class="icon-circle text-orange"></i>'); $this->context->smarty->assign('display_common_field', true); } } $this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs; /*---- NOTE FOR WEBKUL ----*/ $this->tpl_form_vars['product_type'] = (int) Tools::getValue('type_product', $product->getType()); // $product->getType() before changes $this->getLanguages(); $this->tpl_form_vars['id_lang_default'] = Configuration::get('PS_LANG_DEFAULT'); $this->tpl_form_vars['currentIndex'] = self::$currentIndex; $this->tpl_form_vars['display_multishop_checkboxes'] = Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP && $this->display == 'edit'; $this->fields_form = array(''); $this->tpl_form_vars['token'] = $this->token; $this->tpl_form_vars['combinationImagesJs'] = $this->getCombinationImagesJs(); $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); $this->tpl_form_vars['post_data'] = Tools::jsonEncode($_POST); $this->tpl_form_vars['save_error'] = !empty($this->errors); $this->tpl_form_vars['mod_evasive'] = Tools::apacheModExists('evasive'); $this->tpl_form_vars['mod_security'] = Tools::apacheModExists('security'); $this->tpl_form_vars['ps_force_friendly_product'] = Configuration::get('PS_FORCE_FRIENDLY_PRODUCT'); // autoload rich text editor (tiny mce) $this->tpl_form_vars['tinymce'] = true; $iso = $this->context->language->iso_code; $this->tpl_form_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'; $this->tpl_form_vars['path_css'] = _THEME_CSS_DIR_; $this->tpl_form_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_); if (Validate::isLoadedObject($this->object)) { $id_product = (int) $this->object->id; } else { $id_product = (int) Tools::getvalue('id_product'); } $page = (int) Tools::getValue('page'); $this->tpl_form_vars['form_action'] = $this->context->link->getAdminLink('AdminProducts') . '&' . ($id_product ? 'id_product=' . (int) $id_product : 'addproduct') . ($page > 1 ? '&page=' . (int) $page : ''); $this->tpl_form_vars['id_product'] = $id_product; // Transform configuration option 'upload_max_filesize' in octets $upload_max_filesize = Tools::getOctets(ini_get('upload_max_filesize')); // Transform configuration option 'upload_max_filesize' in MegaOctets $upload_max_filesize = $upload_max_filesize / 1024 / 1024; $this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize; $this->tpl_form_vars['country_display_tax_label'] = $this->context->country->display_tax_label; $this->tpl_form_vars['has_combinations'] = $this->object->hasAttributes(); $this->product_exists_in_shop = true; if ($this->display == 'edit' && Validate::isLoadedObject($product) && Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP && !$product->isAssociatedToShop($this->context->shop->id)) { $this->product_exists_in_shop = false; if ($this->tab_display == 'Informations') { $this->displayWarning($this->l('Warning: The product does not exist in this shop')); } $default_product = new Product(); $definition = ObjectModel::getDefinition($product); foreach ($definition['fields'] as $field_name => $field) { if (isset($field['shop']) && $field['shop']) { $product->{$field_name} = ObjectModel::formatValue($default_product->{$field_name}, $field['type']); } } } // let's calculate this once for all if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) { $this->errors[] = 'Unable to load object'; } else { $this->_displayDraftWarning($this->object->active); // if there was an error while saving, we don't want to lose posted data if (!empty($this->errors)) { $this->copyFromPost($this->object, $this->table); } $this->initPack($this->object); $this->{'initForm' . $this->tab_display}($this->object); $this->tpl_form_vars['product'] = $this->object; if ($this->ajax) { if (!isset($this->tpl_form_vars['custom_form'])) { throw new PrestaShopException('custom_form empty for action ' . $this->tab_display); } else { return $this->tpl_form_vars['custom_form']; } } } $parent = parent::renderForm(); $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch')); return $parent; }
/** * renderForm contains all necessary initialization needed for all tabs * * @return string|void * @throws PrestaShopException */ public function renderForm() { $data = $this->createTemplate('form.tpl'); // This nice code (irony) is here to store the product name, because the row after will erase product name in multishop context //$this->offer_name = $this->object->name[$this->context->language->id]; if (!method_exists($this, 'initForm' . $this->tab_display)) { return; } $this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs; $this->tpl_form_vars['defaultFormLanguage'] = $this->default_form_language; $this->tpl_form_vars['allowEmployeeFormLang'] = $this->allow_employee_form_lang; $this->tpl_form_vars['vat_number'] = Module::isInstalled('vatnumber') && file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'); $this->getLanguages(); $this->tpl_form_vars['languages'] = $this->_languages; $this->tpl_form_vars['id_lang_default'] = Configuration::get('PS_LANG_DEFAULT'); $this->tpl_form_vars['currentIndex'] = self::$currentIndex; $this->fields_form = array(''); $this->tpl_form_vars['token'] = $this->token; $this->tpl_form_vars['ps_force_friendly_product'] = Configuration::get('PS_FORCE_FRIENDLY_PRODUCT'); $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int) Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); $this->tpl_form_vars['post_data'] = Tools::jsonEncode($_POST); $this->tpl_form_vars['save_error'] = !empty($this->errors); $this->tpl_form_vars['mod_evasive'] = Tools::apacheModExists('evasive'); $this->tpl_form_vars['mod_security'] = Tools::apacheModExists('security'); // autoload rich text editor (tiny mce) $this->tpl_form_vars['tinymce'] = true; $iso = $this->context->language->iso_code; $this->tpl_form_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'; $this->tpl_form_vars['path_css'] = _THEME_CSS_DIR_; $this->tpl_form_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_); $this->tpl_form_vars['firstCall'] = true; if (Validate::isLoadedObject($this->object)) { $id_offer = (int) $this->object->id; } else { $id_offer = (int) Tools::getvalue('id_offer'); } $page = (int) Tools::getValue('page'); $this->tpl_form_vars['form_action'] = $this->context->link->getAdminLink('AdminAphOffers') . '&' . ($id_offer ? 'updateoffer&id_offer=' . (int) $id_offer : 'addoffer') . ($page > 1 ? '&page=' . (int) $page : ''); $this->tpl_form_vars['id_offer'] = $id_offer; // Transform configuration option 'upload_max_filesize' in octets $upload_max_filesize = Tools::getOctets(ini_get('upload_max_filesize')); // Transform configuration option 'upload_max_filesize' in MegaOctets $upload_max_filesize = $upload_max_filesize / 1024 / 1024; $this->tpl_form_vars['upload_max_filesize'] = $upload_max_filesize; $this->offer_exists_in_shop = true; // let's calculate this once for all if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_offer')) { $this->errors[] = 'Impossibile caricare l\'oggetto'; } else { // if there was an error while saving, we don't want to lose posted data if (!empty($this->errors)) { $this->copyFromPost($this->object, $this->table); } $this->{'initForm' . $this->tab_display}($this->object); $this->tpl_form_vars['offer'] = $this->object; if ($this->ajax) { if (!isset($this->tpl_form_vars['custom_form'])) { throw new PrestaShopException('custom_form empty for action ' . $this->tab_display); } else { return $this->tpl_form_vars['custom_form']; } } } $data->assign($this->tpl_form_vars); $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch')); return $data->fetch(); }
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_); // Retro-compatibility include _PS_ADMIN_DIR_ . '/../config/config.inc.php'; include _PS_ADMIN_DIR_ . '/functions.php'; include _PS_ADMIN_DIR_ . '/init.php'; if (empty($tab) and !sizeof($_POST)) { $tab = 'AdminHome'; $_POST['tab'] = 'AdminHome'; $_POST['token'] = Tools::getAdminTokenLite($tab); } if ($id_tab = checkingTab($tab)) { $isoUser = Language::getIsoById(intval($cookie->id_lang)); if (Validate::isLoadedObject($adminObj)) { $adminObj->ajax = true; // If mod_evasive exists, keep it quiet if (!$adminObj->ignore_sleep && Tools::apacheModExists('evasive')) { sleep(1); } if ($adminObj->checkToken()) { // the differences with index.php is here $adminObj->ajaxPreProcess(); $action = Tools::getValue('action'); // no need to use displayConf() here if (!empty($action) and method_exists($adminObj, 'ajaxProcess' . Tools::toCamelCase($action))) { $adminObj->{'ajaxProcess' . Tools::toCamelCase($action)}(); } else { $adminObj->ajaxProcess(); } // @TODO We should use a displayAjaxError $adminObj->displayErrors(); if (!empty($action) and method_exists($adminObj, 'displayAjax' . Tools::toCamelCase($action))) {
/** * This method generate the form for PDF translations */ public function initFormPDF() { $name_var = $this->translations_informations[$this->type_selected]['var']; $GLOBALS[$name_var] = array(); $missing_translations_pdf = array(); $i18n_dir = $this->translations_informations[$this->type_selected]['dir']; $default_i18n_file = $i18n_dir . $this->translations_informations[$this->type_selected]['file']; if (!$this->theme_selected) { $i18n_file = $default_i18n_file; } else { $i18n_dir = $this->translations_informations[$this->type_selected]['override']['dir']; $i18n_file = $i18n_dir . $this->translations_informations[$this->type_selected]['override']['file']; } $this->checkDirAndCreate($i18n_file); if (!file_exists($i18n_file) && !is_writable($i18n_dir) && !is_writable($i18n_file)) { $this->errors[] = sprintf(Tools::displayError('Cannot write into the "%s"'), $i18n_file); } @(include $i18n_file); // if the override's translation file is empty load the default file if (!isset($GLOBALS[$name_var]) || count($GLOBALS[$name_var]) == 0) { @(include $default_i18n_file); } $prefix_key = 'PDF'; $tabs_array = array($prefix_key => array()); $files_by_directory = $this->getFileToParseByTypeTranslation(); foreach ($files_by_directory as $type => $directories) { foreach ($directories as $dir => $files) { foreach ($files as $file) { if (!in_array($file, self::$ignore_folder) && Tools::file_exists_cache($file_path = $dir . $file)) { if ($type == 'tpl') { if (Tools::file_exists_cache($file_path) && is_file($file_path)) { // Get content for this file $content = file_get_contents($file_path); // Parse this content $matches = $this->userParseFile($content, $this->type_selected, 'tpl'); foreach ($matches as $key) { if (isset($GLOBALS[$name_var][$prefix_key . md5($key)])) { $tabs_array[$prefix_key][$key]['trad'] = html_entity_decode($GLOBALS[$name_var][$prefix_key . md5($key)], ENT_COMPAT, 'UTF-8'); } else { if (!isset($tabs_array[$prefix_key][$key]['trad'])) { $tabs_array[$prefix_key][$key]['trad'] = ''; if (!isset($missing_translations_pdf[$prefix_key])) { $missing_translations_pdf[$prefix_key] = 1; } else { $missing_translations_pdf[$prefix_key]++; } } } $tabs_array[$prefix_key][$key]['use_sprintf'] = $this->checkIfKeyUseSprintf($key); } } } else { if (Tools::file_exists_cache($file_path)) { $tabs_array = $this->parsePdfClass($file_path, 'php', $GLOBALS[$name_var], $prefix_key, $tabs_array, $missing_translations_pdf); } } } } } } $this->tpl_view_vars = array_merge($this->tpl_view_vars, array('count' => count($tabs_array['PDF']), 'limit_warning' => $this->displayLimitPostWarning(count($tabs_array['PDF'])), 'mod_security_warning' => Tools::apacheModExists('mod_security'), 'tabsArray' => $tabs_array, 'cancel_url' => $this->context->link->getAdminLink('AdminTranslations'), 'missing_translations' => $missing_translations_pdf)); $this->initToolbar(); $this->base_tpl_view = 'translation_form.tpl'; return parent::renderView(); }
public function ajaxPreProcess() { if (!empty($_POST['responseType']) and $_POST['responseType'] == 'json') { header('Content-Type: application/json'); } if (!empty($_POST['action'])) { $action = $_POST['action']; if (isset(self::$skipAction[strtolower($action)])) { $this->next = self::$skipAction[$action]; $this->nextDesc = sprintf($this->l('action %s skipped'), $action); $this->nextQuickInfo[] = sprintf($this->l('action %s skipped'), $action); unset($_POST['action']); } else { if (!method_exists(get_class($this), 'ajaxProcess' . $action)) { $this->nextDesc = sprintf($this->l('action "%1$s" not found'), $action); $this->next = 'error'; $this->error = '1'; } } } if (!method_exists('Tools', 'apacheModExists') || Tools::apacheModExists('evasive')) { sleep(1); } }
/** * renderForm contains all necessary initialization needed for all tabs * * @return string|void * @throws PrestaShopException */ public function renderForm() { $data = $this->createTemplate('form.tpl'); if (!method_exists($this, 'initForm' . $this->tab_display)) { return; } $this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs; $this->tpl_form_vars['defaultFormLanguage'] = $this->default_form_language; $this->tpl_form_vars['allowEmployeeFormLang'] = $this->allow_employee_form_lang; $this->tpl_form_vars['vat_number'] = false; $this->getLanguages(); $this->tpl_form_vars['languages'] = $this->_languages; $this->tpl_form_vars['id_lang_default'] = Configuration::get('PS_LANG_DEFAULT'); $this->tpl_form_vars['currentIndex'] = self::$currentIndex; $this->fields_form = array(''); $this->tpl_form_vars['token'] = $this->token; $this->tpl_form_vars['post_data'] = Tools::jsonEncode($_POST); $this->tpl_form_vars['save_error'] = !empty($this->errors); $this->tpl_form_vars['mod_evasive'] = Tools::apacheModExists('evasive'); $this->tpl_form_vars['mod_security'] = Tools::apacheModExists('security'); // autoload rich text editor (tiny mce) $iso = $this->context->language->iso_code; $this->tpl_form_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'; $this->tpl_form_vars['path_css'] = _THEME_CSS_DIR_; $this->tpl_form_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_); $this->tpl_form_vars['firstCall'] = true; if (Validate::isLoadedObject($this->object)) { $id_employee = (int) $this->object->id; } else { $id_employee = (int) Tools::getvalue('id_employee'); } $page = (int) Tools::getValue('page'); $this->tpl_form_vars['form_action'] = $this->context->link->getAdminLink(substr(__CLASS__, 0, -10)) . '&' . (!empty($id_employee) ? 'updateemployee&id_employee=' . (int) $id_employee : 'addemployee') . ($page > 1 ? '&page=' . (int) $page : ''); $this->tpl_form_vars['id_employee'] = $id_employee; // let's calculate this once for all if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_employee')) { $this->errors[] = 'Unable to load object'; } else { // if there was an error while saving, we don't want to lose posted data if (!empty($this->errors)) { $this->copyFromPost($this->object, $this->table); } $this->{'initForm' . $this->tab_display}($this->object); $this->tpl_form_vars['dipendente'] = $this->object; if ($this->ajax) { if (!isset($this->tpl_form_vars['custom_form'])) { throw new PrestaShopException('custom_form empty for action ' . $this->tab_display); } else { return $this->tpl_form_vars['custom_form']; } } } $data->assign($this->tpl_form_vars); return $data->fetch(); }
public function ajaxPreProcess() { /* PrestaShop demo mode */ if (defined('_PS_MODE_DEMO_') && _PS_MODE_DEMO_) { return; } /* PrestaShop demo mode*/ if (!empty($_POST['responseType']) && $_POST['responseType'] == 'json') { header('Content-Type: application/json'); } if (!empty($_POST['action'])) { $action = $_POST['action']; if (isset(self::$skipAction[$action])) { $this->next = self::$skipAction[$action]; $this->next_desc = sprintf($this->l('action %s skipped'), $action); $this->nextQuickInfo[] = sprintf($this->l('action %s skipped'), $action); unset($_POST['action']); } else { if (!method_exists(get_class($this), 'ajaxProcess' . $action)) { $this->next_desc = sprintf($this->l('action "%1$s" not found'), $action); $this->next = 'error'; $this->error = '1'; } } } if (!method_exists('Tools', 'apacheModExists') || Tools::apacheModExists('evasive')) { sleep(1); } }
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="#">↦</a></li> <li class="debugtoolbar-tab-right"><a id="debugtoolbar-close" href="#">×</a></li> <li class="debugtoolbar-tab-right"><a id="debugtoolbar-zoom" href="#">⇅</a></li> </ul> <ul id="debugtoolbar-closed-tabs" class="debugtoolbar-tabs"> <li><a id="debugtoolbar-show" href="#">↤</a></li> </ul> </div> '; $output .= '<script type="text/javascript" src="' . Tools::getShopDomain(true) . '/modules/debugtoolbar/views/assets/js/debugtoolbar.js"></script>'; echo $output; }