/**
  * @covers Airbrake\Configuration::verify
  */
 public function testVerify()
 {
     $this->object->set('apiKey', null);
     try {
         $this->object->verify();
     } catch (\Exception $e) {
         $this->assertInstanceOf('Airbrake\\Exception', $e);
     }
 }
Example #2
0
 /**
  * Initializes the shared configuration
  *
  * @param string $basePath
  * @return Configuration
  */
 public static function initializeConfiguration($basePath)
 {
     // Read the configurations file
     $configuration = array();
     $configurationFile = $basePath . 'Configurations/Configuration.json';
     if (file_exists($configurationFile) && is_readable($configurationFile)) {
         $configuration = json_decode(file_get_contents($configurationFile), TRUE);
     }
     self::$sharedConfiguration = new Configuration($configuration);
     self::$sharedConfiguration->set('basePath', $basePath);
     return self::$sharedConfiguration;
 }
Example #3
0
 public static function set($key, $values, $id_shop_group = null, $id_shop = null)
 {
     ConfigurationKPI::setKpiDefinition();
     $r = parent::set($key, $values, $id_shop_group, $id_shop);
     ConfigurationKPI::unsetKpiDefinition();
     return $r;
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     if (\Schema::hasTable('config')) {
         if (!\Configuration::has('app_name')) {
             \Configuration::set('app_name', env('APP_NAME'));
         }
     }
 }
Example #5
0
 function getContent()
 {
     global $cookie;
     /* Languages preliminaries */
     $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
     $languages = Language::getLanguages();
     $iso = Language::getIsoById($defaultLanguage);
     $isoUser = Language::getIsoById(intval($cookie->id_lang));
     /* display the module name */
     $this->_html = '<h2>' . $this->displayName . ' ' . $this->version . '</h2>';
     /* update the editorial xml */
     if (isset($_POST['submitUpdate'])) {
         // Generate new XML data
         $newXml = '<?xml version=\'1.0\' encoding=\'utf-8\' ?>' . "\n";
         $newXml .= '<links>' . "\n";
         $i = 0;
         foreach ($_POST['link'] as $link) {
             $newXml .= '	<link>';
             foreach ($link as $key => $field) {
                 if ($line = $this->putContent($newXml, $key, $field)) {
                     $newXml .= $line;
                 }
             }
             /* upload the image */
             if (isset($_FILES['link_' . $i . '_img']) and isset($_FILES['link_' . $i . '_img']['tmp_name']) and !empty($_FILES['link_' . $i . '_img']['tmp_name'])) {
                 Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
                 if ($error = checkImage($_FILES['link_' . $i . '_img'], $this->maxImageSize)) {
                     $this->_html .= $error;
                 } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['link_' . $i . '_img']['tmp_name'], $tmpName)) {
                     return false;
                 } elseif (!imageResize($tmpName, dirname(__FILE__) . '/' . $isoUser . $i . '.jpg')) {
                     $this->_html .= $this->displayError($this->l('An error occurred during the image upload.'));
                 }
                 unlink($tmpName);
             }
             if ($line = $this->putContent($newXml, 'img', $isoUser . $i . '.jpg')) {
                 $newXml .= $line;
             }
             $newXml .= "\n" . '	</link>' . "\n";
             $i++;
         }
         $newXml .= '</links>' . "\n";
         /* write it into the editorial xml file */
         if ($fd = @fopen(dirname(__FILE__) . '/' . $isoUser . 'links.xml', 'w')) {
             if (!@fwrite($fd, $newXml)) {
                 $this->_html .= $this->displayError($this->l('Unable to write to the editor file.'));
             }
             if (!@fclose($fd)) {
                 $this->_html .= $this->displayError($this->l('Can\'t close the editor file.'));
             }
         } else {
             $this->_html .= $this->displayError($this->l('Unable to update the editor file.<br />Please check the editor file\'s writing permissions.'));
         }
     }
     /* display the editorial's form */
     $this->_displayForm();
     return $this->_html;
 }
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     \App::bind('admin', function () {
         // set debug mode!
         if (!\Configuration::has('debug')) {
             \Configuration::set('debug', true);
         }
         return new \App\Classes\Admin();
     });
 }
Example #7
0
 public function addRoute($route = array(), $key = '')
 {
     if (count($route) > 0) {
         $keys = array_keys($route);
         $currentRoutes = \Admin::routes();
         if (!array_key_exists($keys[0], $currentRoutes)) {
             $currentRoutes[$key][] = $route;
             \Configuration::set('admin_routes', $currentRoutes);
             return true;
         }
     }
     return false;
 }
 public function __construct()
 {
     $this->name = 'veritransinstallment';
     $this->tab = 'payments_gateways';
     $this->version = '1.0';
     $this->author = 'Veritrans';
     $this->bootstrap = true;
     $this->currencies = true;
     $this->currencies_mode = 'checkbox';
     $this->veritrans_convenience_fee = 0;
     // key length must be between 0-32 chars to maintain compatibility with <= 1.5
     $this->config_keys = array('VI_CLIENT_KEY', 'VI_SERVER_KEY', 'VI_API_VERSION', 'VI_PAYMENT_TYPE', 'VI_3D_SECURE', 'VI_KURS', 'VI_CONVENIENCE_FEE', 'VI_PAYMENT_SUCCESS_STATUS_MAP', 'VI_PAYMENT_FAILURE_STATUS_MAP', 'VI_PAYMENT_CHALLENGE_STATUS_MAP', 'VI_ENVIRONMENT', 'VI_SANITIZED', 'VI_ENABLE_INSTALLMENT', 'VI_INSTALLMENTS_BNI', 'VI_INSTALLMENTS_TERM', 'VI_BIN_FILTER', 'VI_DISPLAY_NAME', 'VI_AMOUNT_THRESHOLD');
     foreach (array('BNI', 'MANDIRI') as $bank) {
         foreach (array(3, 6, 12) as $months) {
             array_push($this->config_keys, 'VI_INSTALLMENTS_' . $bank . '_' . $months);
         }
     }
     $config = Configuration::getMultiple($this->config_keys);
     foreach ($this->config_keys as $key) {
         if (isset($config[$key])) {
             $this->{strtolower($key)} = $config[$key];
         }
     }
     if (isset($config['VI_KURS'])) {
         $this->veritrans_kurs = $config['VI_KURS'];
     } else {
         Configuration::set('VI_KURS', 10000);
     }
     if (!isset($config['VI_DISPLAY_NAME'])) {
         Configuration::set('VI_DISPLAY_NAME', "Credit Card Installment");
     }
     if (!isset($config['VI_AMOUNT_THRESHOLD']) || strlen($config['VI_AMOUNT_THRESHOLD']) < 1) {
         Configuration::set('VI_AMOUNT_THRESHOLD', "500000");
     }
     Configuration::set('VI_API_VERSION', 2);
     Configuration::set('VI_PAYMENT_TYPE', 'vtweb');
     if (!isset($config['VI_SANITIZED'])) {
         Configuration::set('VI_SANITIZED', 0);
     }
     parent::__construct();
     $this->displayName = $this->l('Veritrans Offline Installment');
     $this->description = $this->l('Accept offline installment payments for your products via Veritrans.');
     $this->confirmUninstall = $this->l('Are you sure about uninstalling Veritrans offline installment?');
     if (!count(Currency::checkPaymentCurrencies($this->id))) {
         $this->warning = $this->l('No currency has been set for this module.');
     }
     // Retrocompatibility
     $this->initContext();
 }
 public function __construct()
 {
     $this->name = 'veritransbni';
     $this->tab = 'payments_gateways';
     $this->version = '1.0';
     $this->author = 'Veritrans';
     $this->bootstrap = true;
     $this->currencies = true;
     $this->currencies_mode = 'checkbox';
     $this->veritrans_convenience_fee = 0;
     // key length must be between 0-32 chars to maintain compatibility with <= 1.5
     $this->config_keys = array('VN_CLIENT_KEY', 'VN_SERVER_KEY', 'VN_API_VERSION', 'VN_PAYMENT_TYPE', 'VN_3D_SECURE', 'VN_KURS', 'VN_CONVENIENCE_FEE', 'VN_PAYMENT_SUCCESS_STATUS_MAP', 'VN_PAYMENT_FAILURE_STATUS_MAP', 'VN_PAYMENT_CHALLENGE_STATUS_MAP', 'VN_ENVIRONMENT', 'VN_SANITIZED', 'VN_ENABLE_INSTALLMENT', 'VN_ENABLED_BNI_INSTALLMENT', 'VN_INSTALLMENTS_BNI', 'VN_INSTALLMENTS_MANDIRI');
     foreach (array('BNI', 'MANDIRI') as $bank) {
         foreach (array(3, 6, 12) as $months) {
             array_push($this->config_keys, 'VN_INSTALLMENTS_' . $bank . '_' . $months);
         }
     }
     $config = Configuration::getMultiple($this->config_keys);
     foreach ($this->config_keys as $key) {
         if (isset($config[$key])) {
             $this->{strtolower($key)} = $config[$key];
         }
     }
     if (isset($config['VN_KURS'])) {
         $this->veritrans_kurs = $config['VN_KURS'];
     } else {
         Configuration::set('VN_KURS', 10000);
     }
     Configuration::set('VN_API_VERSION', 2);
     Configuration::set('VN_PAYMENT_TYPE', 'vtweb');
     if (!isset($config['VN_SANITIZED'])) {
         Configuration::set('VN_SANITIZED', 0);
     }
     parent::__construct();
     $this->displayName = $this->l('Veritrans BNI Installments');
     $this->description = $this->l('Extends Veritrans payment method to accept payment using BNI Installments.');
     $this->confirmUninstall = $this->l('Are you sure about uninstalling Veritrans BNI Installments?');
     if (!count(Currency::checkPaymentCurrencies($this->id))) {
         $this->warning = $this->l('No currency has been set for this module.');
     }
     // Retrocompatibility
     $this->initContext();
 }
 public function postIndex(Request $request)
 {
     $nameVal = \Validator::make($request->all(), ['name' => 'required', 'email' => 'required|unique:users|email|max:255', 'password' => 'required|min:6', 'admin_name' => 'required', 'password_confirm' => 'required_with:password|same:password|min:6']);
     if ($nameVal->fails()) {
         return redirect('install')->withErrors($nameVal)->withInput();
     }
     // save the user
     $user = new User();
     $user->email = $request->input('email');
     $user->name = $request->input('admin_name');
     $user->password = bcrypt($request->input('password'));
     $user->save();
     \Configuration::set('app_name', $request->input('name'));
     \Configuration::set('installed', bcrypt(time()));
     if (\Auth::attempt(['email' => $user->email, 'password' => $request->input('password')])) {
         // Authentication passed...
         return redirect()->intended('admin');
     }
 }
Example #11
0
 /**
  * @param array $arguments
  * @param array $options
  * @return int
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $validModes = array('get', 'set', 'remove');
     switch ($arguments['mode']) {
         case 'get':
             $configValue = Configuration::get($arguments['name']);
             $this->logSection('config', sprintf("Configuration %s value: %s", $arguments['name'], null === $configValue ? 'NULL' : sprintf('"%s"', $configValue)));
             break;
         case 'set':
             $configValue = $arguments['value'];
             Configuration::set($arguments['name'], $arguments['value']);
             $this->logSection('config+', sprintf("Configuration %s set to: %s", $arguments['name'], null === $configValue ? 'NULL' : sprintf('"%s"', $configValue)));
             break;
         case 'remove':
             Configuration::remove($arguments['name']);
             $this->logSection('config-', sprintf("Configuration %s removed", $arguments['name']));
             break;
         default:
             throw new InvalidArgumentException(sprintf("Invalid value for mode argument (%s). One of the following values is accepted: %s", $arguments['mode'], implode(', ', $validModes)));
             break;
     }
     return 0;
 }
Example #12
0
 private static function handleNumAttempts($data)
 {
     $attempts = Configuration::get('attempt_counter_' . $data[0]['user_name']);
     //check if an attempt was made and log the first attempt
     if (Configuration::get('attempt_counter_' . $data[0]['user_name']) == '0') {
         Configuration::set('time_first_try_' . $data[0]['user_name'], time());
     }
     //Increment the attempts if and only if the username exists
     if (!empty($data)) {
         Configuration::set('attempt_counter_' . $data[0]['user_name'], ++$attempts);
     }
     $timeElapsed = self::checkElapsedTime(Configuration::get('time_first_try_' . $data[0]['user_name']), time());
     if (Configuration::get('attempt_counter_' . $data[0]['user_name']) >= '2') {
         if ($timeElapsed->i < 5) {
             self::disableUserAccount($data);
         } else {
             Configuration::set('attempt_counter_' . $data[0]['user_name'], 0);
         }
     }
 }
 protected function uploadImage($image, $image_w = '', $image_h = '')
 {
     $res = false;
     if (is_array($image) && ImageManager::validateUpload($image, $this->max_image_size) === false && ($tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS')) && move_uploaded_file($image['tmp_name'], $tmp_name)) {
         $type = Tools::strtolower(Tools::substr(strrchr($image['name'], '.'), 1));
         $img_name = Tools::encrypt($image['name'] . sha1(microtime())) . '.' . $type;
         Configuration::set('PS_IMAGE_QUALITY', 'png_all');
         if (ImageManager::resize($tmp_name, dirname(__FILE__) . '/img/' . $img_name, $image_w, $image_h)) {
             $res = true;
         }
     }
     if (!$res) {
         $this->context->smarty->assign('error', $this->l('An error occurred during the image upload.'));
         return false;
     }
     return $img_name;
 }
 public function __construct()
 {
     $this->name = 'veritranspay';
     $this->tab = 'payments_gateways';
     $this->version = '1.0';
     $this->author = 'Veritrans';
     $this->bootstrap = true;
     $this->currencies = true;
     $this->currencies_mode = 'checkbox';
     $this->veritrans_convenience_fee = 0;
     // key length must be between 0-32 chars to maintain compatibility with <= 1.5
     $this->config_keys = array('VT_CLIENT_KEY', 'VT_SERVER_KEY', 'VT_API_VERSION', 'VT_PAYMENT_TYPE', 'VT_3D_SECURE', 'VT_KURS', 'VT_CONVENIENCE_FEE', 'VT_PAYMENT_SUCCESS_STATUS_MAP', 'VT_PAYMENT_FAILURE_STATUS_MAP', 'VT_PAYMENT_CHALLENGE_STATUS_MAP', 'VT_ENVIRONMENT', 'ENABLED_CREDIT_CARD', 'ENABLED_CIMB', 'ENABLED_MANDIRI', 'ENABLED_PERMATAVA', 'ENABLED_BRIEPAY', 'ENABLED_TELKOMSEL_CASH', 'ENABLED_XL_TUNAI', 'ENABLED_MANDIRI_BILL', 'ENABLED_BBM_MONEY', 'ENABLED_INDOMARET', 'ENABLED_INDOSAT_DOMPETKU', 'ENABLED_MANDIRI_ECASH', 'VT_SANITIZED', 'VT_ENABLE_INSTALLMENT', 'ENABLED_BNI_INSTALLMENT', 'ENABLED_MANDIRI_INSTALLMENT', 'VT_INSTALLMENTS_BNI', 'VT_INSTALLMENTS_MANDIRI');
     foreach (array('BNI', 'MANDIRI') as $bank) {
         foreach (array(3, 6, 12) as $months) {
             array_push($this->config_keys, 'VT_INSTALLMENTS_' . $bank . '_' . $months);
         }
     }
     $config = Configuration::getMultiple($this->config_keys);
     foreach ($this->config_keys as $key) {
         if (isset($config[$key])) {
             $this->{strtolower($key)} = $config[$key];
         }
     }
     if (isset($config['VT_KURS'])) {
         $this->veritrans_kurs = $config['VT_KURS'];
     } else {
         Configuration::set('VT_KURS', 10000);
     }
     Configuration::set('VT_API_VERSION', 2);
     Configuration::set('VT_PAYMENT_TYPE', 'vtweb');
     if (!isset($config['VT_SANITIZED'])) {
         Configuration::set('VT_SANITIZED', 0);
     }
     if (!isset($config['ENABLED_CREDIT_CARD'])) {
         Configuration::set('ENABLED_CREDIT_CARD', 0);
     }
     if (!isset($config['ENABLED_CIMB'])) {
         Configuration::set('ENABLED_CIMB', 0);
     }
     if (!isset($config['ENABLED_MANDIRI'])) {
         Configuration::set('ENABLED_MANDIRI', 0);
     }
     if (!isset($config['ENABLED_PERMATAVA'])) {
         Configuration::set('ENABLED_PERMATAVA', 0);
     }
     if (!isset($config['ENABLED_BRIEPAY'])) {
         Configuration::set('ENABLED_BRIEPAY', 0);
     }
     if (!isset($config['ENABLED_TELKOMSEL_CASH'])) {
         Configuration::set('ENABLED_TELKOMSEL_CASH', 0);
     }
     if (!isset($config['ENABLED_XL_TUNAI'])) {
         Configuration::set('ENABLED_XL_TUNAI', 0);
     }
     if (!isset($config['ENABLED_MANDIRI_BILL'])) {
         Configuration::set('ENABLED_MANDIRI_BILL', 0);
     }
     if (!isset($config['ENABLED_BBM_MONEY'])) {
         Configuration::set('ENABLED_BBM_MONEY', 0);
     }
     if (!isset($config['ENABLED_INDOMARET'])) {
         Configuration::set('ENABLED_INDOMARET', 0);
     }
     if (!isset($config['ENABLED_INDOSAT_DOMPETKU'])) {
         Configuration::set('ENABLED_INDOSAT_DOMPETKU', 0);
     }
     if (!isset($config['ENABLED_MANDIRI_ECASH'])) {
         Configuration::set('ENABLED_MANDIRI_ECASH', 0);
     }
     parent::__construct();
     $this->displayName = $this->l('Veritrans Pay');
     $this->description = $this->l('Accept payments for your products via Veritrans.');
     $this->confirmUninstall = $this->l('Are you sure about uninstalling Veritrans pay?');
     if (!count(Currency::checkPaymentCurrencies($this->id))) {
         $this->warning = $this->l('No currency has been set for this module.');
     }
     // Retrocompatibility
     $this->initContext();
 }
            }
        }
        $this->{$name} = $value;
    }
}
// end class
$CF = new Configuration();
$mode = getData("mode");
$submode = getData("submode");
// system actions
switch ($mode) {
    case "sessionconfig":
        switch ($submode) {
            case "submit":
                // apply datas to the current settings
                $CF->set("ENABLE_TABLES", getData("FORM_ENABLE_TABLES", "integer"));
                $CF->set("ENABLE_SEQUENCES", getData("FORM_ENABLE_SEQUENCES", "integer"));
                $CF->set("ENABLE_TRIGGERS", getData("FORM_ENABLE_TRIGGERS", "integer"));
                $CF->set("ENABLE_FUNCTIONS", getData("FORM_ENABLE_FUNCTIONS", "integer"));
                $CF->set("ENABLE_INDEXES", getData("FORM_ENABLE_INDEXES", "integer"));
                $CF->set("ENABLE_PACKAGES", getData("FORM_ENABLE_PACKAGES", "integer"));
                $CF->set("ENABLE_PROCEDURES", getData("FORM_ENABLE_PROCEDURES", "integer"));
                $CF->set("ENABLE_TYPES", getData("FORM_ENABLE_TYPES", "integer"));
                $CF->set("ENABLE_VIEWS", getData("FORM_ENABLE_VIEWS", "integer"));
                $CF->set("ENABLE_TABLESPACES", getData("FORM_ENABLE_TABLESPACES", "integer"));
                $CF->set("ENABLE_DATAFILES", getData("FORM_ENABLE_DATAFILES", "integer"));
                $CF->set("USE_ALL_USER_DATA", getData("FORM_USE_ALL_USER_DATA", "integer"));
                $CF->set("ENABLE_VIEW_STATEMENTS", getData("FORM_ENABLE_VIEW_STATEMENTS", "integer"));
                $CF->set("TABLE_ROW_LIMIT", getData("FORM_TABLE_ROW_LIMIT", "integer"));
                $CF->set("TABLE_FIELDLENGTH_LIMIT", getData("FORM_TABLE_FIELDLENGTH_LIMIT", "integer"));
                $CF->set("ENABLE_HTML_OPTIMIZATION", getData("FORM_ENABLE_HTML_OPTIMIZATION", "integer"));
Example #16
0
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/Configuration.php';
$configuration = new Configuration();
switch ($api->method) {
    case 'GET':
        //returns the settings configuration
        $api->output(200, $configuration->query());
        break;
    case 'PUT':
        //update setting
        if (!$api->checkParameterExists('key', $key)) {
            $api->output(400, '`Key` must be provided in path');
            //Key was not provided, return an error
            return;
        }
        if (!$api->checkParameterExists('value', $value)) {
            $api->output(400, '`Value` must be provided in body');
            //Value was not provided, return an error
            return;
        }
        if (!$configuration->set($key, $value)) {
            $api->output(500, 'An error occurred while processing your request');
            //There was an error during update, return an error
            return;
        }
        $setting = new stdClass();
        $setting->key = $key;
        $setting->value = $value;
        $api->output(200, $setting);
        break;
}
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
if (_THEME_NAME_ == 'prestashop_mobile' || isset($_GET['ps_mobile_site']) && $_GET['ps_mobile_site'] == 1) {
    /* Do not allow One-page Checkout and Guest Checkout with Mobile template */
    Configuration::set('PS_ORDER_PROCESS_TYPE', 0);
    Configuration::set('PS_GUEST_CHECKOUT_ENABLED', 0);
    if (version_compare(_PS_VERSION_, '1.4', '<') && !method_exists('Product', 'convertAndFormatPrice')) {
        function convertAndFormatPrice($price, $currency = false)
        {
            if (!$currency) {
                $currency = Currency::getCurrent();
            }
            return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
        }
        $smarty->register_modifier('convertAndFormatPrice', 'smarty_modifier_truncate');
    }
}
Example #18
0
 /**
  * Update configuration key and value into database (automatically insert if key does not exist)
  *
  * Values are inserted/updated directly using SQL, because using (Configuration) ObjectModel
  * may not insert values correctly (for example, HTML is escaped, when it should not be).
  * @TODO Fix saving HTML values in Configuration model
  *
  * @param string $key Key
  * @param mixed $values $values is an array if the configuration is multilingual, a single string else.
  * @param bool $html Specify if html is authorized in value
  * @param int $id_shop_group
  * @param int $id_shop
  * @return bool Update result
  */
 public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null)
 {
     if (!Validate::isConfigName($key)) {
         die(sprintf(Tools::displayError('[%s] is not a valid configuration key'), Tools::htmlentitiesUTF8($key)));
     }
     if ($id_shop === null || !Shop::isFeatureActive()) {
         $id_shop = Shop::getContextShopID(true);
     }
     if ($id_shop_group === null || !Shop::isFeatureActive()) {
         $id_shop_group = Shop::getContextShopGroupID(true);
     }
     if (!is_array($values)) {
         $values = array($values);
     }
     if ($html) {
         foreach ($values as &$value) {
             $value = Tools::purifyHTML($value);
         }
         unset($value);
     }
     $result = true;
     foreach ($values as $lang => $value) {
         $stored_value = Configuration::get($key, $lang, $id_shop_group, $id_shop);
         // if there isn't a $stored_value, we must insert $value
         if (!is_numeric($value) && $value === $stored_value || is_numeric($value) && $value == $stored_value && Configuration::hasKey($key, $lang)) {
             continue;
         }
         // If key already exists, update value
         if (Configuration::hasKey($key, $lang, $id_shop_group, $id_shop)) {
             if (!$lang) {
                 // Update config not linked to lang
                 $result &= Db::getInstance()->update(self::$definition['table'], array('value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')), '`name` = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop), 1, true);
             } else {
                 // Update multi lang
                 $sql = 'UPDATE `' . _DB_PREFIX_ . bqSQL(self::$definition['table']) . '_lang` cl
                         SET cl.value = \'' . pSQL($value, $html) . '\',
                             cl.date_upd = NOW()
                         WHERE cl.id_lang = ' . (int) $lang . '
                             AND cl.`' . bqSQL(self::$definition['primary']) . '` = (
                                 SELECT c.`' . bqSQL(self::$definition['primary']) . '`
                                 FROM `' . _DB_PREFIX_ . bqSQL(self::$definition['table']) . '` c
                                 WHERE c.name = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop) . ')';
                 $result &= Db::getInstance()->execute($sql);
             }
         } else {
             if (!($configID = Configuration::getIdByName($key, $id_shop_group, $id_shop))) {
                 $now = date('Y-m-d H:i:s');
                 $data = array('id_shop_group' => $id_shop_group ? (int) $id_shop_group : null, 'id_shop' => $id_shop ? (int) $id_shop : null, 'name' => pSQL($key), 'value' => $lang ? null : pSQL($value, $html), 'date_add' => $now, 'date_upd' => $now);
                 $result &= Db::getInstance()->insert(self::$definition['table'], $data, true);
                 $configID = Db::getInstance()->Insert_ID();
             }
             if ($lang) {
                 $result &= Db::getInstance()->insert(self::$definition['table'] . '_lang', array(self::$definition['primary'] => $configID, 'id_lang' => (int) $lang, 'value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')));
             }
         }
     }
     Configuration::set($key, $values, $id_shop_group, $id_shop);
     return $result;
 }
Example #19
0
    /**
     * Update configuration key and value into database (automatically insert if key does not exist)
     *
     * @param string $key Key
     * @param mixed $values $values is an array if the configuration is multilingual, a single string else.
     * @param boolean $html Specify if html is authorized in value
     * @param int $id_shop_group
     * @param int $id_shop
     * @return boolean Update result
     */
    public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null)
    {
        if (!Validate::isConfigName($key)) {
            die(Tools::displayError());
        }
        if ($id_shop === null) {
            $id_shop = Shop::getContextShopID(true);
        }
        if ($id_shop_group === null) {
            $id_shop_group = Shop::getContextShopGroupID(true);
        }
        if (!is_array($values)) {
            $is_i18n = false;
            $values = array($values);
        } else {
            $is_i18n = true;
        }
        $result = true;
        foreach ($values as $lang => $value) {
            $stored_value = Configuration::get($key, $lang, $id_shop_group, $id_shop);
            // if there isn't a $stored_value, we must insert $value
            if (!is_numeric($value) && $value === $stored_value || is_numeric($value) && $value == $stored_value && Configuration::hasKey($key, $lang)) {
                continue;
            }
            // If key already exists, update value
            if (Configuration::hasKey($key, $lang, $id_shop_group, $id_shop)) {
                if (!$lang) {
                    // Update config not linked to lang
                    $result &= Db::getInstance()->update(self::$definition['table'], array('value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')), '`name` = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop), 1, true);
                } else {
                    // Update multi lang
                    $sql = 'UPDATE `' . _DB_PREFIX_ . bqSQL(self::$definition['table']) . '_lang` cl
							SET cl.value = \'' . pSQL($value, $html) . '\',
								cl.date_upd = NOW()
							WHERE cl.id_lang = ' . (int) $lang . '
								AND cl.`' . bqSQL(self::$definition['primary']) . '` = (
									SELECT c.`' . bqSQL(self::$definition['primary']) . '`
									FROM `' . _DB_PREFIX_ . bqSQL(self::$definition['table']) . '` c
									WHERE c.name = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop) . ')';
                    $result &= Db::getInstance()->execute($sql);
                }
            } else {
                if (!($configID = Configuration::getIdByName($key, $id_shop_group, $id_shop))) {
                    $newConfig = new Configuration();
                    $newConfig->name = $key;
                    if ($id_shop) {
                        $newConfig->id_shop = (int) $id_shop;
                    }
                    if ($id_shop_group) {
                        $newConfig->id_shop_group = (int) $id_shop_group;
                    }
                    if (!$lang) {
                        $newConfig->value = $value;
                    }
                    $result &= $newConfig->add(true, true);
                    $configID = $newConfig->id;
                }
                if ($lang) {
                    $result &= Db::getInstance()->insert(self::$definition['table'] . '_lang', array(self::$definition['primary'] => $configID, 'id_lang' => $lang, 'value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')));
                }
            }
        }
        Configuration::set($key, $values, $id_shop_group, $id_shop);
        return $result;
    }
Example #20
0
 private function _uploadImage($image, $image_w = '', $image_h = '')
 {
     /* Uploads image */
     $type = @strtolower(substr(strrchr($image['name'], '.'), 1));
     $imagesize = array();
     $imagesize = @getimagesize($image['tmp_name']);
     Configuration::set('PS_IMAGE_QUALITY', 'png_all');
     $salt = sha1(microtime());
     if (isset($image) && isset($image['tmp_name']) && !empty($image['tmp_name']) && !empty($imagesize) && in_array(strtolower(substr(strrchr($imagesize['mime'], '/'), 1)), array('jpg', 'gif', 'jpeg', 'png')) && in_array($type, array('jpg', 'gif', 'jpeg', 'png'))) {
         $temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
         if ($error = ImageManager::validateUpload($image)) {
             $errors[] = $error;
         } elseif (!$temp_name || !move_uploaded_file($image['tmp_name'], $temp_name)) {
             return false;
         } elseif (ImageManager::resize($temp_name, dirname(__FILE__) . '/images/' . Tools::encrypt($image['name'] . $salt) . '.' . $type, $image_w, $image_h)) {
             return Tools::encrypt($image['name'] . $salt) . '.' . $type;
         } else {
             $this->context->smarty->assign('error', $this->l('An error occurred during the image upload.'));
         }
         if (isset($temp_name)) {
             @unlink($temp_name);
         }
     }
 }
Example #21
0
 protected function _uploadImage($image, $image_w = '', $image_h = '')
 {
     $res = false;
     if (is_array($image) && ImageManager::validateUpload($image, $this->max_image_size) === false && ($tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS')) && move_uploaded_file($image['tmp_name'], $tmp_name)) {
         $type = Tools::strtolower(Tools::substr(strrchr($image['name'], '.'), 1));
         $img_name = 'b-' . Tools::strtolower(str_replace('.' . $type, '', $image['name']) . '.' . $type);
         Configuration::set('PS_IMAGE_QUALITY', 'png_all');
         if (ImageManager::resize($tmp_name, _LEOBLOG_BLOG_IMG_DIR_ . 'b/' . $img_name, $image_w, $image_h)) {
             $res = true;
         }
     }
     //		if (isset($temp_name))
     //				@unlink($tmp_name);
     if (!$res) {
         # validate module
         return false;
     }
     return $img_name;
 }
<?php

/* SSL Management */
$useSSL = true;
include dirname(__FILE__) . '/../../../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../../../init.php';
include dirname(__FILE__) . '/adyen.php';
if (!$cookie->isLogged()) {
    die('Error: not logged in');
}
// override the skin, note that this override is temporary without Configuration::update
Configuration::set('ADYEN_SKINCODE', 'mA8bOvvq');
Configuration::set('ADYEN_PAGE_TYPE', 'multiple');
$adyen = new CartAPI_Module_Adyen();
// Create an order before we redirect the shopper
$adyen->validateOrder($cart->id, _PS_OS_ADYEN_REDIRECTED_, $cart->getOrderTotal(true, 3), $adyen->displayName);
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">

// instead of including the entire jquery library we just implement the single required function
function $(formname)
{
	return document.forms[formname.replace('#','')];
}

</script>
</head>
    /**
     * @brief Assign missing smarty templates for Store page
     *
     * @param array $params params array from hookHeader
     *
     */
    protected static function _pageStore($params)
    {
        if (strpos($_SERVER['PHP_SELF'], 'stores.php') !== false) {
            global $smarty;
            Configuration::set('PS_STORES_SIMPLIFIED', 1);
            $stores = Db::getInstance()->ExecuteS('
			SELECT s.*, cl.`name` country, st.`iso_code` state
			FROM `' . _DB_PREFIX_ . 'store` s
			LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = s.`id_country`)
			LEFT JOIN `' . _DB_PREFIX_ . 'state` st ON (st.`id_state` = s.`id_state`)
			WHERE s.`active` = 1 AND cl.`id_lang` = ' . (int) $params['cookie']->id_lang);
            foreach ($stores as &$store) {
                $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_ . (int) $store['id_store'] . '.jpg');
            }
            $smarty->assign('stores', $stores);
        }
    }
Example #24
0
    public function getContent()
    {
        $this->context->controller->addJqueryPlugin('colorpicker');
        $this->context->controller->addCSS($this->_path . 'css/admin/admin.css');
        $this->context->controller->addJS($this->_path . 'js/admin/script.js');
        $this->context->controller->addJS($this->_path . 'js/admin/shBrushJScript.js');
        $errors = '';
        $id_shop = (int) $this->context->shop->id;
        if (Tools::isSubmit('save_editor')) {
            $this->registerHook('calculateGrid');
            foreach ($this->defaults as $default => $value) {
                if ($default == 'custom_css') {
                    if (isset($_POST[$default])) {
                        Configuration::updateValue($this->configName . '_' . $default, $_POST[$default]);
                    }
                } elseif (array_key_exists($default, $this->defaultsBorders)) {
                    Configuration::updateValue($this->configName . '_' . $default, Tools::getValue($default . '_width') . ';' . Tools::getValue($default . '_type') . ';' . Tools::getValue($default . '_color'));
                } elseif ($default == 'copyright_text') {
                    $message_trads = array();
                    foreach ($_POST as $key => $value) {
                        if (preg_match('/copyright_text_/i', $key)) {
                            $id_lang = preg_split('/copyright_text_/i', $key);
                            $message_trads[(int) $id_lang[1]] = $value;
                        }
                    }
                    Configuration::updateValue($this->configName . '_' . $default, $message_trads, true);
                } elseif ($default == 'footer_img_disable') {
                    if ($default == 'footer_img_disable' && isset($_FILES['footer_img_src']) && isset($_FILES['footer_img_src']['tmp_name']) && !empty($_FILES['footer_img_src']['tmp_name'])) {
                        Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
                        if (file_exists(dirname(__FILE__) . '/img/footer_logo_' . (int) $id_shop . '.jpg')) {
                            unlink(dirname(__FILE__) . '/img/footer_logo_' . (int) $id_shop . '.jpg');
                        }
                        if ($error = ImageManager::validateUpload($_FILES['footer_img_src'])) {
                            $errors .= $error;
                        } elseif (!($tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['footer_img_src']['tmp_name'], $tmp_name)) {
                            return false;
                        } elseif (!ImageManager::resize($tmp_name, dirname(__FILE__) . '/img/footer_logo_' . (int) $id_shop . '.jpg')) {
                            $errors .= $this->displayError($this->l('An error occurred while attempting to upload the image.'));
                        }
                        if (isset($tmp_name)) {
                            unlink($tmp_name);
                        }
                    }
                    if (file_exists(dirname(__FILE__) . '/img/footer_logo_' . (int) $id_shop . '.jpg')) {
                        Configuration::updateValue($this->configName . '_' . $default, 0);
                    }
                } else {
                    Configuration::updateValue($this->configName . '_' . $default, Tools::getValue($default));
                }
            }
            Configuration::updateValue('PS_QUICK_VIEW', (int) Tools::getValue('PS_QUICK_VIEW'));
            $this->generateCss();
            if (isset($errors) and $errors != '') {
                $this->_html .= $this->displayError($errors);
            } else {
                $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
            }
        } elseif (Tools::isSubmit('reset_editor')) {
            $this->setDefaults();
            $this->generateCss();
            $this->_html .= $this->displayConfirmation($this->l('Settings reset'));
        } elseif (Tools::isSubmit('deleteFooterImage')) {
            if (!file_exists(dirname(__FILE__) . '/img/footer_logo_' . (int) $id_shop . '.jpg')) {
                $errors .= $this->displayError($this->l('This action cannot be made.'));
            } else {
                unlink(dirname(__FILE__) . '/img/footer_logo_' . (int) $id_shop . '.jpg');
                Configuration::updateValue('footer_img_disable', 1);
                Tools::redirectAdmin('index.php?tab=AdminModules&configure=' . $this->name . '&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id));
            }
            $this->_html .= $errors;
        } elseif (Tools::isSubmit('exportConfiguration')) {
            $var = array();
            foreach ($this->defaults as $default => $value) {
                if ($default == 'copyright_text') {
                    foreach (Language::getLanguages(false) as $lang) {
                        $var[$default][(int) $lang['id_lang']] = Tools::getValue($default . '_' . (int) $lang['id_lang'], Configuration::get($default, (int) $lang['id_lang']));
                    }
                } else {
                    $var[$default] = Configuration::get($this->configName . '_' . $default);
                }
            }
            $var['PS_QUICK_VIEW'] = (int) Tools::getValue('PS_QUICK_VIEW', Configuration::get('PS_QUICK_VIEW'));
            $file_name = time() . '.csv';
            $fd = fopen($this->getLocalPath() . $file_name, 'w+');
            file_put_contents($this->getLocalPath() . 'export/' . $file_name, print_r(serialize($var), true));
            fclose($fd);
            Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/export/' . $file_name);
        } elseif (Tools::isSubmit('importConfiguration')) {
            if (isset($_FILES['uploadConfig']) && isset($_FILES['uploadConfig']['tmp_name'])) {
                $str = file_get_contents($_FILES['uploadConfig']['tmp_name']);
                $arr = unserialize($str);
                foreach ($arr as $default => $value) {
                    if ($default == 'copyright_text') {
                        $message_trads = array();
                        foreach ($_POST as $key => $value) {
                            if (preg_match('/copyright_text_/i', $key)) {
                                $id_lang = preg_split('/copyright_text_/i', $key);
                                $message_trads[(int) $id_lang[1]] = $value;
                            }
                        }
                        Configuration::updateValue($this->configName . '_' . $default, $message_trads, true);
                    } elseif ($default == 'PS_QUICK_VIEW') {
                        Configuration::updateValue('PS_QUICK_VIEW', $value);
                    } elseif ($default != 'footer_img_disable') {
                        Configuration::updateValue($this->configName . '_' . $default, $value);
                    }
                }
                $this->generateCss();
                if (isset($errors) and $errors != '') {
                    $this->_html .= $this->displayError($errors);
                } else {
                    $this->_html .= $this->displayConfirmation($this->l('Configuration imported'));
                }
            } else {
                $this->_html .= $this->displayError($this->l('No config file'));
            }
        }
        $this->_html .= '<div class="panel clearfix">
		<form class="pull-left" id="importForm" method="post" enctype="multipart/form-data" action="' . $this->context->link->getAdminLink('AdminModules', false) . '&importConfiguration&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '">
		<div style="display:inline-block;"><input type="file" id="uploadConfig" name="uploadConfig" /></div>
	
		<button type="submit" class="btn btn-default btn-lg"><span class="icon icon-upload"></span> ' . $this->l('Import configuration') . '</button>
		
		</form>

		


		<a href="' . $this->context->link->getAdminLink('AdminModules', false) . '&exportConfiguration&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '">
		<button class="btn btn-default btn-lg pull-right"><span class="icon icon-share"></span> ' . $this->l('Export configuration(Export only saved settigns, save before export)') . '</button>
		</a></div>';
        $this->_html .= $this->renderForm();
        return $this->_html;
    }
Example #25
0
    /**
     * Update configuration key and value into database (automatically insert if key does not exist)
     *
     * @param string $key Key
     * @param mixed $values $values is an array if the configuration is multilingual, a single string else.
     * @param boolean $html Specify if html is authorized in value
     * @param int $id_shop_group
     * @param int $id_shop
     * @return boolean Update result
     */
    public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null)
    {
        if (!Validate::isConfigName($key)) {
            die(Tools::displayError());
        }
        if ($id_shop === null) {
            $id_shop = Shop::getContextShopID(true);
        }
        if ($id_shop_group === null) {
            $id_shop_group = Shop::getContextShopGroupID(true);
        }
        if (!is_array($values)) {
            $is_i18n = false;
            $values = array($values);
        } else {
            $is_i18n = true;
        }
        $result = true;
        foreach ($values as $lang => $value) {
            if ($value === Configuration::get($key, $lang, $id_shop_group, $id_shop)) {
                continue;
            }
            // If key already exists, update value
            if (Configuration::hasKey($key, $lang, $id_shop_group, $id_shop)) {
                if (!$lang) {
                    // Update config not linked to lang
                    $result &= Db::getInstance()->update('configuration', array('value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')), '`name` = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop), true, true);
                } else {
                    // Update multi lang
                    $sql = 'UPDATE ' . _DB_PREFIX_ . 'configuration_lang cl
							SET cl.value = \'' . pSQL($value, $html) . '\',
								cl.date_upd = NOW()
							WHERE cl.id_lang = ' . (int) $lang . '
								AND cl.id_configuration = (
									SELECT c.id_configuration
									FROM ' . _DB_PREFIX_ . 'configuration c
									WHERE c.name = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop) . ')';
                    $result &= Db::getInstance()->execute($sql);
                }
            } else {
                if (!($configID = Configuration::getIdByName($key, $id_shop_group, $id_shop))) {
                    $newConfig = new Configuration();
                    $newConfig->name = $key;
                    if ($id_shop) {
                        $newConfig->id_shop = (int) $id_shop;
                    }
                    if ($id_shop_group) {
                        $newConfig->id_shop_group = (int) $id_shop_group;
                    }
                    if (!$lang) {
                        $newConfig->value = $value;
                    }
                    $result &= $newConfig->add(true, true);
                    $configID = $newConfig->id;
                }
                if ($lang) {
                    $result &= Db::getInstance()->insert('configuration_lang', array('id_configuration' => $configID, 'id_lang' => $lang, 'value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')));
                }
            }
            if (!$is_i18n) {
                Configuration::set($key, $value, $id_shop_group, $id_shop);
            }
        }
        if ($is_i18n) {
            Configuration::set($key, $values, $id_shop_group, $id_shop);
        }
        return $result;
    }
Example #26
0
 public function getContent()
 {
     global $cookie;
     /* display the module name */
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     $errors = '';
     // Delete logo image
     if (Tools::isSubmit('deleteImage')) {
         if (!file_exists(dirname(__FILE__) . '/homepage_logo.jpg')) {
             $errors .= $this->displayError($this->l('This action cannot be taken.'));
         } else {
             unlink(dirname(__FILE__) . '/homepage_logo.jpg');
             Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 1);
             Tools::redirectAdmin('index.php?tab=AdminModules&configure=' . $this->name . '&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $cookie->id_employee));
         }
         $this->_html .= $errors;
     }
     /* update the editorial xml */
     if (Tools::isSubmit('submitUpdate')) {
         // Forbidden key
         $forbidden = array('submitUpdate');
         $editorial = new EditorialClass(1);
         $editorial->copyFromPost();
         $editorial->update();
         /* upload the image */
         if (isset($_FILES['body_homepage_logo']) and isset($_FILES['body_homepage_logo']['tmp_name']) and !empty($_FILES['body_homepage_logo']['tmp_name'])) {
             Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
             if (file_exists(dirname(__FILE__) . '/homepage_logo.jpg')) {
                 unlink(dirname(__FILE__) . '/homepage_logo.jpg');
             }
             if ($error = checkImage($_FILES['body_homepage_logo'], $this->maxImageSize)) {
                 $errors .= $error;
             } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) {
                 return false;
             } elseif (!imageResize($tmpName, dirname(__FILE__) . '/homepage_logo.jpg')) {
                 $errors .= $this->displayError($this->l('An error occurred during the image upload.'));
             }
             if (isset($tmpName)) {
                 unlink($tmpName);
             }
         }
         $this->_html .= $errors == '' ? $this->displayConfirmation($this->l('Settings updated successfully')) : $errors;
         if (file_exists(dirname(__FILE__) . '/homepage_logo.jpg')) {
             list($width, $height, $type, $attr) = getimagesize(dirname(__FILE__) . '/homepage_logo.jpg');
             Configuration::updateValue('EDITORIAL_IMAGE_WIDTH', (int) round($width));
             Configuration::updateValue('EDITORIAL_IMAGE_HEIGHT', (int) round($height));
             Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 0);
         }
     }
     /* display the editorial's form */
     $this->_displayForm();
     return $this->_html;
 }
Example #27
0
 public function postProcess()
 {
     $errors = '';
     $id_shop = (int) $this->context->shop->id;
     // Delete logo image
     if (Tools::isSubmit('deleteImage')) {
         if (!file_exists(dirname(__FILE__) . '/homepage_logo_' . (int) $id_shop . '.jpg')) {
             $errors .= $this->displayError($this->l('This action cannot be made.'));
         } else {
             unlink(dirname(__FILE__) . '/homepage_logo_' . (int) $id_shop . '.jpg');
             Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 1);
             $this->_clearCache('editorial.tpl');
             Tools::redirectAdmin('index.php?tab=AdminModules&configure=' . $this->name . '&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id));
         }
         $this->_html .= $errors;
     }
     if (Tools::isSubmit('submitUpdateEditorial')) {
         $id_shop = (int) $this->context->shop->id;
         $editorial = EditorialClass::getByIdShop($id_shop);
         $editorial->copyFromPost();
         $editorial->update();
         /* upload the image */
         if (isset($_FILES['body_homepage_logo']) && isset($_FILES['body_homepage_logo']['tmp_name']) && !empty($_FILES['body_homepage_logo']['tmp_name'])) {
             Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
             if (file_exists(dirname(__FILE__) . '/homepage_logo_' . (int) $id_shop . '.jpg')) {
                 unlink(dirname(__FILE__) . '/homepage_logo_' . (int) $id_shop . '.jpg');
             }
             if ($error = ImageManager::validateUpload($_FILES['body_homepage_logo'])) {
                 $errors .= $error;
             } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) {
                 return false;
             } elseif (!ImageManager::resize($tmpName, dirname(__FILE__) . '/homepage_logo_' . (int) $id_shop . '.jpg')) {
                 $errors .= $this->displayError($this->l('An error occurred while attempting to upload the image.'));
             }
             if (isset($tmpName)) {
                 unlink($tmpName);
             }
         }
         $this->_html .= $errors == '' ? $this->displayConfirmation($this->l('Settings updated successfully.')) : $errors;
         if (file_exists(dirname(__FILE__) . '/homepage_logo_' . (int) $id_shop . '.jpg')) {
             list($width, $height, $type, $attr) = getimagesize(dirname(__FILE__) . '/homepage_logo_' . (int) $id_shop . '.jpg');
             Configuration::updateValue('EDITORIAL_IMAGE_WIDTH', (int) round($width));
             Configuration::updateValue('EDITORIAL_IMAGE_HEIGHT', (int) round($height));
             Configuration::updateValue('EDITORIAL_IMAGE_DISABLE', 0);
         }
         $this->_clearCache('editorial.tpl');
     }
 }
 public static function preInit(&$metadata = array())
 {
     Configuration::set('PS_CANONICAL_REDIRECT', 0);
     // language
     if (isset($metadata['X-LANGUAGE'])) {
         $_GET['isolang'] = $metadata['X-LANGUAGE'];
     }
     // currency
     if (isset($metadata['X-CURRENCY'])) {
         $_POST['SubmitCurrency'] = 1;
         $_POST['id_currency'] = Currency::getIdByIsoCode($metadata['X-CURRENCY']);
     }
     // register a new translation smarty function
     global $smarty;
     if (function_exists('smartyRegisterFunction')) {
         smartyRegisterFunction($smarty, 'function', 'l2', 'smartyTranslate2');
     } else {
         $smarty->register_function('l2', 'smartyTranslate2');
     }
     // call the override function if found
     if (method_exists('CartAPI_Handlers_Override_Helpers', 'preInit')) {
         CartAPI_Handlers_Override_Helpers::preInit($metadata);
     }
 }
Example #29
0
 function getContent()
 {
     /* display the module name */
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     $errors = '';
     /* update the editorial xml */
     if (isset($_POST['submitUpdate'])) {
         // Forbidden key
         $forbidden = array('submitUpdate');
         foreach ($_POST as $key => $value) {
             if (!Validate::isString($_POST[$key])) {
                 $this->_html .= $this->displayError($this->l('Invalid html field, javascript is forbidden'));
                 $this->_displayForm();
                 return $this->_html;
             }
         }
         // Generate new XML data
         $newXml = '<?xml version=\'1.0\' encoding=\'utf-8\' ?>' . "\n";
         $newXml .= '<editorial>' . "\n";
         $newXml .= '	<header>';
         // Making header data
         foreach ($_POST as $key => $field) {
             if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'header')) {
                 $newXml .= $line;
             }
         }
         $newXml .= "\n" . '	</header>' . "\n";
         $newXml .= '	<body>';
         // Making body data
         foreach ($_POST as $key => $field) {
             if ($line = $this->putContent($newXml, $key, $field, $forbidden, 'body')) {
                 $newXml .= $line;
             }
         }
         $newXml .= "\n" . '	</body>' . "\n";
         $newXml .= '</editorial>' . "\n";
         /* write it into the editorial xml file */
         if ($fd = @fopen(dirname(__FILE__) . '/editorial.xml', 'w')) {
             if (!@fwrite($fd, $newXml)) {
                 $errors .= $this->displayError($this->l('Unable to write to the editor file.'));
             }
             if (!@fclose($fd)) {
                 $errors .= $this->displayError($this->l('Can\'t close the editor file.'));
             }
         } else {
             $errors .= $this->displayError($this->l('Unable to update the editor file.<br />Please check the editor file\'s writing permissions.'));
         }
         /* upload the image */
         if (isset($_FILES['body_homepage_logo']) and isset($_FILES['body_homepage_logo']['tmp_name']) and !empty($_FILES['body_homepage_logo']['tmp_name'])) {
             Configuration::set('PS_IMAGE_GENERATION_METHOD', 1);
             if ($error = checkImage($_FILES['body_homepage_logo'], $this->maxImageSize)) {
                 $errors .= $error;
             } elseif (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['body_homepage_logo']['tmp_name'], $tmpName)) {
                 return false;
             } elseif (!imageResize($tmpName, dirname(__FILE__) . '/homepage_logo.jpg')) {
                 $errors .= $this->displayError($this->l('An error occurred during the image upload.'));
             }
             unlink($tmpName);
         }
         $this->_html .= $errors == '' ? $this->displayConfirmation('Settings updated successfully') : $errors;
     }
     /* display the editorial's form */
     $this->_displayForm();
     return $this->_html;
 }
 public function postHomepageList(Request $request)
 {
     \Configuration::set('default_list', $request->input('homepage_list'));
     return \Redirect::to('admin');
 }