Merge branch 'develop' into gli-610

This commit is contained in:
Shreesh Arora
2021-10-29 14:41:57 +05:30
committed by GitHub
3236 changed files with 175421 additions and 67623 deletions

13
SECURITY.md Normal file
View File

@@ -0,0 +1,13 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.5.x | :white_check_mark: |
| 1.4.x | :white_check_mark: |
| < 1.4.0 | :x: |
## Reporting a Vulnerability
Please report (suspected) security vulnerabilities to support@qloapps.com. You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity.

View File

@@ -72,12 +72,12 @@ if (Tools::isSubmit('ajaxProductPackItems')) {
if (Tools::isSubmit('getChildrenCategories') && Tools::isSubmit('id_category_parent')) {
$children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat'), Context::getContext()->language->id, null, Tools::getValue('use_shop_context'));
die(Tools::jsonEncode($children_categories));
die(json_encode($children_categories));
}
if (Tools::isSubmit('getNotifications')) {
$notification = new Notification;
die(Tools::jsonEncode($notification->getLastElements()));
die(json_encode($notification->getLastElements()));
}
if (Tools::isSubmit('updateElementEmployee') && Tools::getValue('updateElementEmployeeType')) {
@@ -111,7 +111,7 @@ if (Tools::isSubmit('getParentCategoriesId') && $id_category = Tools::getValue('
$output[] = $result;
}
die(Tools::jsonEncode($output));
die(json_encode($output));
}
if (Tools::isSubmit('getZones')) {
@@ -121,7 +121,7 @@ if (Tools::isSubmit('getZones')) {
}
$html .= '</select>';
$array = array('hasError' => false, 'errors' => '', 'data' => $html);
die(Tools::jsonEncode($array));
die(json_encode($array));
}
if (Tools::isSubmit('getEmailHTML') && $email = Tools::getValue('email')) {

View File

@@ -137,7 +137,7 @@ if ($items && ($excludeIds || strpos($_SERVER['HTTP_REFERER'], 'AdminScenes') !=
}
}
$results = array_values($results);
echo Tools::jsonEncode($results);
echo json_encode($results);
} else {
Tools::jsonEncode(new stdClass);
json_encode(new stdClass);
}

View File

@@ -96,15 +96,11 @@ function rewriteSettingsFile($base_urls = null, $theme = null, $array_db = null)
$defines['_DB_PASSWD_'] = (($array_db && isset($array_db['_DB_PASSWD_'])) ? $array_db['_DB_PASSWD_'] : _DB_PASSWD_);
$defines['_COOKIE_KEY_'] = addslashes(_COOKIE_KEY_);
$defines['_COOKIE_IV_'] = addslashes(_COOKIE_IV_);
$defines['_NEW_COOKIE_KEY_'] = addslashes(_NEW_COOKIE_KEY_);
$defines['_PS_CREATION_DATE_'] = addslashes(_PS_CREATION_DATE_);
if (defined('_RIJNDAEL_KEY_')) {
$defines['_RIJNDAEL_KEY_'] = addslashes(_RIJNDAEL_KEY_);
}
if (defined('_RIJNDAEL_IV_')) {
$defines['_RIJNDAEL_IV_'] = addslashes(_RIJNDAEL_IV_);
}
$defines['_PS_VERSION_'] = addslashes(_PS_VERSION_);
$defines['_QLOAPPS_VERSION_'] = addslashes(_QLOAPPS_VERSION_);
$content = "<?php\n\n";
foreach ($defines as $k => $value) {
if ($k == '_PS_VERSION_') {
@@ -524,8 +520,8 @@ function runAdminTab($tab, $ajax_mode = false)
}
// we can display the correct url
// die(Tools::jsonEncode(array(Translate::getAdminTranslation('Invalid security token'),$url)));
die(Tools::jsonEncode(Translate::getAdminTranslation('Invalid security token')));
// die(json_encode(array(Translate::getAdminTranslation('Invalid security token'),$url)));
die(json_encode(Translate::getAdminTranslation('Invalid security token')));
} else {
// If this is an XSS attempt, then we should only display a simple, secure page
if (ob_get_level() && ob_get_length() > 0) {

View File

@@ -301,11 +301,11 @@
<div class="col-sm-7">
<select name="booking_order_status" class="form-control booking_order_status margin-bottom-5">
{foreach from=$hotel_order_status item=state}
<option value="{$state['id']|intval}" {if isset($data.id_status) && $state.id == $data.id_status} selected="selected" disabled="disabled"{/if}>{$state.status|escape}</option>
<option value="{$state['id_status']|intval}" {if isset($data.id_status) && $state.id_status == $data.id_status} selected="selected" disabled="disabled"{/if}>{$state.name|escape}</option>
{/foreach}
</select>
{if $data['id_status'] == 2}<span class="badge badge-success margin-bottom-5">{l s='checked in on'} {$data['check_in']|date_format:"%d-%m-%Y"}</span>{elseif $data['id_status'] == 3}<span class="badge badge-success margin-bottom-5">{l s='checked out on'} {$data['check_out']|date_format:"%d-%m-%Y"}</span>{/if}
{if $data['id_status'] == $hotel_order_status['STATUS_CHECKED_IN']['id_status']}<span class="badge badge-success margin-bottom-5">{l s='checked in on'} {$data['check_in']|date_format:"%d-%m-%Y"}</span>{elseif $data['id_status'] == $hotel_order_status['STATUS_CHECKED_OUT']['id_status']}<span class="badge badge-success margin-bottom-5">{l s='checked out on'} {$data['check_out']|date_format:"%d-%m-%Y"}</span>{/if}
{* field for the current date *}
<input class="room_status_date wk-input-date" type="text" name="status_date" value="{$data['date_from']|date_format:"%d-%m-%Y"}" readonly/>

View File

@@ -41,10 +41,10 @@
</select>
</td>
<td class="center col-sm-6">
<a class="btn btn-default deactiveDatesModal" data-toggle="modal" data-target="#deactiveDatesModal" {if $info['id_status'] != 3 }style="display: none;"{/if}>{if $info['id_status'] != 3 }{l s='Add Dates'}{else}{l s='View Dates'}{/if}
<a class="btn btn-default deactiveDatesModal" data-toggle="modal" data-target="#deactiveDatesModal" {if $info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }style="display: none;"{/if}>{if $info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }{l s='Add Dates'}{else}{l s='View Dates'}{/if}
</a>
<input type="text" class="form-control room_comment" value="{$info['comment']}" name="room_comment[]" {if $info['id_status'] == 3 }style="display: none;"{/if}>
<input type="hidden" class="form-control disableDatesJSON" name="disableDatesJSON[]" {if $info['id_status'] == 3}value="{$info['disabled_dates_json']|escape:'html':'UTF-8'}"{/if}>
<input type="text" class="form-control room_comment" value="{$info['comment']}" name="room_comment[]" {if $info['id_status'] == $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }style="display: none;"{/if}>
<input type="hidden" class="form-control disableDatesJSON" name="disableDatesJSON[]" {if $info['id_status'] == $rm_status['STATUS_TEMPORARY_INACTIVE']['id']}value="{$info['disabled_dates_json']|escape:'html':'UTF-8'}"{/if}>
</td>
<td class="center col-sm-1">
<a href="#" class="rm_htl_room btn btn-default" data-id-htl-info="{$info['id']}"><i class="icon-trash"></i></a>
@@ -337,7 +337,7 @@
// on changing the room status as disabled for some date range.....
$(document).on("change", ".room_status", function(){
var status_val = $(this).val();
if (status_val == 3) {
if (status_val == rm_status.STATUS_TEMPORARY_INACTIVE.id) {
$(this).closest('.room_data_values').find('.room_comment, .deactiveDatesModal').toggle();
} else {
$(this).closest('.room_data_values').find('.room_comment').show();

View File

@@ -377,7 +377,7 @@ class Crypt_Blowfish
for ($i = 0; $i < 18; $i++) {
$data = 0;
for ($j = 4; $j > 0; $j--) {
$data = $data << 8 | ord($key{$k});
$data = $data << 8 | ord($key[$k]);
$k = ($k + 1) % $len;
}
$this->_P[$i] ^= $data;

View File

@@ -2632,6 +2632,9 @@ class CartCore extends ObjectModel
*/
public static function desintifier($int, $delimiter = ',')
{
if (!$int)
return;
$delimiter_len = $int[0];
$int = strrev(substr($int, 1));
$elm = explode(str_repeat('0', $delimiter_len + 1), $int);
@@ -4317,7 +4320,7 @@ class CartCore extends ObjectModel
$postData = trim(file_get_contents('php://input'));
libxml_use_internal_errors(true);
$xml = simplexml_load_string(utf8_decode($postData));
$cartData = Tools::jsonDecode(Tools::jsonEncode($xml, true));
$cartData = json_decode(json_encode($xml, true));
$this->id_address_delivery = $cartData->cart->id_address;
$this->id_address_invoice = $cartData->cart->id_address;
@@ -4344,7 +4347,7 @@ class CartCore extends ObjectModel
$postData = trim(file_get_contents('php://input'));
libxml_use_internal_errors(true);
$xml = simplexml_load_string(utf8_decode($postData));
$cartData = Tools::jsonDecode(Tools::jsonEncode($xml, true));
$cartData = json_decode(json_encode($xml, true));
$this->id_address_delivery = $cartData->cart->id_address;
$this->id_address_invoice = $cartData->cart->id_address;
@@ -4384,14 +4387,14 @@ class CartCore extends ObjectModel
$extraDemands = null;
foreach ($bookingRows as $booking) {
$booking = Tools::jsonDecode(Tools::jsonEncode($booking, true), true);
$booking = json_decode(json_encode($booking, true), true);
if (isset($booking['extra_demands']['extra_demand'])) {
$extraDemands = $booking['extra_demands']['extra_demand'];
if (isset($extraDemands['id_global_demand'])) {
$extraDemands = array($extraDemands);
}
// $extraDemands = Tools::jsonDecode($extraDemands, true);
$extraDemands = Tools::jsonEncode($extraDemands);
// $extraDemands = json_decode($extraDemands, true);
$extraDemands = json_encode($extraDemands);
}
// get room booking info

View File

@@ -1220,7 +1220,7 @@ class CartRuleCore extends ObjectModel
if ($type == 'shop') {
$shops = Context::getContext()->employee->getAssociatedShops();
if (count($shops)) {
$shop_list = ' AND t.id_shop IN ('.implode(array_map('intval', $shops), ',').') ';
$shop_list = ' AND t.id_shop IN ('.implode(',', array_map('intval', $shops)).') ';
}
}

View File

@@ -31,7 +31,7 @@ class ConfigurationTestCore
'/classes/log/index.php',
'/classes/cache/index.php',
'/config/index.php',
'/tools/tar/Archive_Tar.php',
'/tools/tar/Tar.php',
'/tools/pear/PEAR.php',
'/controllers/admin/AdminLoginController.php',
'/css/index.php',
@@ -83,10 +83,11 @@ class ConfigurationTestCore
),
'phpversion' => false,
'gd' => false,
'mysql_support' => false,
'pdo_mysql' => false,
'config_dir' => 'config',
'files' => false,
'mails_dir' => 'mails',
'openssl' => false,
'curl' => false,
'soap' => false,
'simplexml' => false,
@@ -94,6 +95,7 @@ class ConfigurationTestCore
'upload_max_filesize' => false,
'max_execution_time' => false,
'fopen' => false,
'zip' => false,
));
}
@@ -112,11 +114,9 @@ class ConfigurationTestCore
'new_phpversion' => false,
'register_globals' => false,
'gz' => false,
'mcrypt' => false,
'mbstring' => false,
'magicquotes' => false,
'dom' => false,
'pdo_mysql' => false,
);
}
@@ -145,17 +145,17 @@ class ConfigurationTestCore
public static function test_phpversion()
{
return version_compare(substr(phpversion(), 0, 5), '5.4.0', '>=');
return version_compare(substr(phpversion(), 0, 5), '5.6.0', '>=');
}
public static function test_new_phpversion()
{
return version_compare(substr(phpversion(), 0, 5), '5.4.0', '>=');
return version_compare(substr(phpversion(), 0, 5), '5.6.0', '>=');
}
public static function test_mysql_support()
{
return extension_loaded('mysql') || extension_loaded('mysqli') || extension_loaded('pdo_mysql');
return extension_loaded('mysqli') || extension_loaded('pdo_mysql');
}
public static function test_pdo_mysql()
@@ -180,7 +180,7 @@ class ConfigurationTestCore
public static function test_magicquotes()
{
return !get_magic_quotes_gpc();
return function_exists('get_magic_quotes_gpc') ? !get_magic_quotes_gpc() : true;
}
public static function test_upload()
@@ -215,6 +215,12 @@ class ConfigurationTestCore
return false;
}
public static function test_zip()
{
return extension_loaded('zip');
}
public static function test_fopen()
{
return ini_get('allow_url_fopen');
@@ -394,9 +400,9 @@ class ConfigurationTestCore
return function_exists('mb_strtolower');
}
public static function test_mcrypt()
public static function test_openssl()
{
return function_exists('mcrypt_encrypt');
return function_exists('openssl_encrypt');
}
public static function test_sessions()

View File

@@ -136,7 +136,7 @@ class ConnectionCore extends ObjectModel
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
ORDER BY `date_add` DESC';
$result = Db::getInstance()->getRow($sql, false);
if (!$result['id_guest'] && (int)$cookie->id_guest) {
if (!isset($result['id_guest']) && (int)$cookie->id_guest) {
// The old connections details are removed from the database in order to spare some memory
Connection::cleanConnectionsPages();

View File

@@ -66,7 +66,7 @@ class CookieCore
$this->_standalone = $standalone;
$this->_expire = is_null($expire) ? time() + 1728000 : (int)$expire;
$this->_path = trim(($this->_standalone ? '' : Context::getContext()->shop->physical_uri).$path, '/\\').'/';
if ($this->_path{0} != '/') {
if ($this->_path[0] != '/') {
$this->_path = '/'.$this->_path;
}
$this->_path = rawurlencode($this->_path);
@@ -76,7 +76,7 @@ class CookieCore
$this->_name = 'PrestaShop-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain);
$this->_allow_writing = true;
$this->_salt = $this->_standalone ? str_pad('', 8, md5('ps'.__FILE__)) : _COOKIE_IV_;
$this->_cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
$this->_cipherTool = new PhpEncryption(_NEW_COOKIE_KEY_);
$this->_secure = (bool)$secure;
$this->update();
@@ -324,6 +324,11 @@ class CookieCore
*/
protected function _setcookie($cookie = null)
{
$length = (ini_get('mbstring.func_overload') & 2) ? mb_strlen($cookie, ini_get('default_charset')) : strlen($cookie);
if ($length >= 1048576) {
return false;
}
if ($cookie) {
$content = $this->_cipherTool->encrypt($cookie);
$time = $this->_expire;

View File

@@ -798,7 +798,7 @@ class LanguageCore extends ObjectModel
// If the language pack has not been provided, retrieve it from prestashop.com
if (!$lang_pack) {
$lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
$lang_pack = json_decode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
}
// If a language pack has been found or provided, prefill the language object with the value
@@ -914,7 +914,7 @@ class LanguageCore extends ObjectModel
if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.$version.'&iso_lang='.Tools::strtolower((string)$iso))) {
$errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
} elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link)) {
} elseif (!$lang_pack = json_decode($lang_pack_link)) {
$errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
} elseif (empty($lang_pack->error) && ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.Tools::strtolower($lang_pack->iso_code.'.gzip')))) {
if (!@file_put_contents($file, $content)) {
@@ -930,7 +930,7 @@ class LanguageCore extends ObjectModel
if (!file_exists($file)) {
$errors[] = Tools::displayError('No language pack is available for your version.');
} elseif ($install) {
require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');
require_once(_PS_TOOL_DIR_.'tar/Tar.php');
$gz = new Archive_Tar($file, true);
$files_list = AdminTranslationsController::filterTranslationFiles(Language::getLanguagePackListContent((string)$iso, $gz));
$files_paths = AdminTranslationsController::filesListToPaths($files_list);
@@ -1030,7 +1030,7 @@ class LanguageCore extends ObjectModel
public static function updateModulesTranslations(array $modules_list)
{
require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');
require_once(_PS_TOOL_DIR_.'tar/Tar.php');
$languages = Language::getLanguages(false);
foreach ($languages as $lang) {

122
classes/PhpEncryption.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
/**
* 2007-2018 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* 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 <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
/**
* Class PhpEncryptionCore for openSSL 1.0.1+.
*/
class PhpEncryptionCore
{
const ENGINE = 'PhpEncryptionEngine';
const LEGACY_ENGINE = 'PhpEncryptionLegacyEngine';
private static $engine;
/**
* PhpEncryptionCore constructor.
*
* @param string $hexString A string that only contains hexadecimal characters
* Bother upper and lower case are allowed
*/
public function __construct($hexString)
{
$engineClass = self::resolveEngineToUse();
self::$engine = new $engineClass($hexString);
}
/**
* Encrypt the plaintext.
*
* @param string $plaintext Plaintext
*
* @return string Cipher text
*/
public function encrypt($plaintext)
{
return self::$engine->encrypt($plaintext);
}
/**
* Decrypt the cipher text.
*
* @param string $cipherText Cipher text
*
* @return bool|string Plaintext
* `false` if unable to decrypt
*
* @throws Exception
*/
public function decrypt($cipherText)
{
return self::$engine->decrypt($cipherText);
}
/**
* @param $header
* @param $bytes
*
* @return string
*
* @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException
*/
public static function saveBytesToChecksummedAsciiSafeString($header, $bytes)
{
$engine = self::resolveEngineToUse();
return $engine::saveBytesToChecksummedAsciiSafeString($header, $bytes);
}
/**
* @return string
*
* @throws Exception
*/
public static function createNewRandomKey()
{
$engine = self::resolveEngineToUse();
try {
$randomKey = $engine::createNewRandomKey();
} catch (EnvironmentIsBrokenException $exception) {
$buf = $engine::randomCompat();
$randomKey = $engine::saveToAsciiSafeString($buf);
}
return $randomKey;
}
/**
* Choose which engine use regarding the OpenSSL cipher methods available.
*/
public static function resolveEngineToUse()
{
if (false === in_array(\Defuse\Crypto\Core::CIPHER_METHOD, openssl_get_cipher_methods())) {
return self::LEGACY_ENGINE;
}
return self::ENGINE;
}
}

View File

@@ -0,0 +1,168 @@
<?php
/**
* 2007-2018 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* 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 <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
use Defuse\Crypto\Crypto;
use Defuse\Crypto\Encoding;
use Defuse\Crypto\Key;
/**
* Class PhpEncryption engine for openSSL 1.0.1+.
*/
class PhpEncryptionEngineCore
{
protected $key;
/**
* PhpEncryptionCore constructor.
*
* @param string $hexString A string that only contains hexadecimal characters
* Bother upper and lower case are allowed
*/
public function __construct($hexString)
{
$this->key = self::loadFromAsciiSafeString($hexString);
}
/**
* Encrypt the plaintext.
*
* @param string $plaintext Plaintext
*
* @return string Cipher text
*/
public function encrypt($plaintext)
{
return Crypto::encrypt($plaintext, $this->key);
}
/**
* Decrypt the cipher text.
*
* @param string $cipherText Cipher text
*
* @return bool|string Plaintext
* `false` if unable to decrypt
*
* @throws Exception
*/
public function decrypt($cipherText)
{
try {
$plaintext = Crypto::decrypt($cipherText, $this->key);
} catch (Exception $e) {
if ($e instanceof \Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException) {
return false;
}
throw $e;
}
return $plaintext;
}
/**
* @param $header
* @param $bytes
*
* @return string
*
* @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException
*/
public static function saveBytesToChecksummedAsciiSafeString($header, $bytes)
{
return Encoding::saveBytesToChecksummedAsciiSafeString($header, $bytes);
}
/**
* @return string
*/
public static function createNewRandomKey()
{
$key = Key::createNewRandomKey();
return $key->saveToAsciiSafeString();
}
/**
* @param $hexString
*
* @return Key
*/
public static function loadFromAsciiSafeString($hexString)
{
return Key::loadFromAsciiSafeString($hexString);
}
/**
* @return string
*
* @throws Exception
*
* @see https://github.com/paragonie/random_compat/blob/v1.4.1/lib/random_bytes_openssl.php
* @see https://github.com/paragonie/random_compat/blob/v1.4.1/lib/random_bytes_mcrypt.php
*/
public static function randomCompat()
{
$bytes = Key::KEY_BYTE_SIZE;
$secure = true;
$buf = openssl_random_pseudo_bytes($bytes, $secure);
if (
$buf !== false
&&
$secure
&&
RandomCompat_strlen($buf) === $bytes
) {
return $buf;
}
$buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
if (
$buf !== false
&&
RandomCompat_strlen($buf) === $bytes
) {
return $buf;
}
throw new Exception(
'Could not gather sufficient random data'
);
}
/**
* @param $buf
*
* @return string
*/
public static function saveToAsciiSafeString($buf)
{
return Encoding::saveBytesToChecksummedAsciiSafeString(
Key::KEY_CURRENT_VERSION,
$buf
);
}
}

View File

@@ -0,0 +1,168 @@
<?php
/**
* 2007-2018 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* 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 <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Class PhpEncryption engine for openSSL < 0.9.8.
*
* @doc http://php.net/manual/fr/function.mcrypt-encrypt.php#refsect1-function.mcrypt-encrypt-examples
*
* This class will be deprecated when web hosting providers will update their version of OpenSSL.
*/
class PhpEncryptionLegacyEngineCore extends PhpEncryptionEngine
{
protected $key;
protected $hmacIv;
protected $iv;
protected $ivSize;
protected $mode = MCRYPT_MODE_CBC;
protected $cipher = MCRYPT_RIJNDAEL_128;
/**
* PhpEncryptionCore constructor.
*
* @param string $hexString A string that only contains hexadecimal characters
* Bother upper and lower case are allowed
*/
public function __construct($hexString)
{
$this->key = substr($hexString, 0, 32);
$this->ivSize = mcrypt_get_iv_size($this->cipher, $this->mode);
$this->iv = mcrypt_create_iv($this->ivSize, MCRYPT_RAND);
$this->hmacIv = substr(sha1(_COOKIE_KEY_), 0, $this->ivSize);
}
/**
* Encrypt the plaintext.
*
* @param string $plaintext Plaintext
*
* @return string Cipher text
*/
public function encrypt($plaintext)
{
$blockSize = mcrypt_get_block_size($this->cipher, $this->mode);
$pad = $blockSize - (strlen($plaintext) % $blockSize);
$cipherText = mcrypt_encrypt(
$this->cipher,
$this->key,
$plaintext . str_repeat(chr($pad), $pad),
$this->mode,
$this->iv
);
$cipherText = $this->iv . $cipherText;
return $this->generateHmac($cipherText) . ':' . base64_encode($cipherText);
}
/**
* Decrypt the cipher text.
*
* @param string $cipherText Cipher text
*
* @return bool|string Plaintext
* `false` if unable to decrypt
*
* @throws Exception
*/
public function decrypt($cipherText)
{
$data = explode(':', $cipherText);
if (count($data) != 2) {
return false;
}
list($hmac, $encrypted) = $data;
$encrypted = base64_decode($encrypted);
$newHmac = $this->generateHmac($encrypted);
if ($hmac !== $newHmac) {
return false;
}
$ivDec = substr($encrypted, 0, $this->ivSize);
$cipherText = substr($encrypted, $this->ivSize);
$data = mcrypt_decrypt(
$this->cipher,
$this->key,
$cipherText,
$this->mode,
$ivDec
);
$pad = ord($data[strlen($data) - 1]);
return substr($data, 0, -$pad);
}
/**
* Generate Hmac.
*
* @param string $encrypted
*
* @return string
*/
protected function generateHmac($encrypted)
{
$macKey = $this->generateKeygenS2k('sha256', $this->key, $this->hmacIv, 32);
return hash_hmac(
'sha256',
$this->hmacIv . $this->cipher . $encrypted,
$macKey
);
}
/**
* Alternative to mhash_keygen_s2k for security reason
* and php compatibilities.
*
* @param string $hash
* @param string $password
* @param string $salt
* @param int $bytes
*
* @return string
*/
protected function generateKeygenS2k($hash, $password, $salt, $bytes)
{
$result = '';
foreach (range(0, ceil($bytes / strlen(hash($hash, null, true))) - 1) as $i) {
$result .= hash(
$hash,
str_repeat("\0", $i) . str_pad(substr($salt, 0, 8), 8, "\0", STR_PAD_RIGHT) . $password,
true
);
}
return substr(
$result,
0,
intval($bytes)
);
}
}

View File

@@ -5776,7 +5776,7 @@ class ProductCore extends ObjectModel
libxml_use_internal_errors(true);
$xml = simplexml_load_string(utf8_decode($postData));
$roomtypeData = Tools::jsonDecode(Tools::jsonEncode($xml), true);
$roomtypeData = json_decode(json_encode($xml), true);
// set room map info for the hotel from request
return Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'htl_room_type` (`id_product`, `id_hotel`, `adult`, `children`, `date_add`, `date_upd`) VALUES ('.(int)$this->id.', '.(int) $roomtypeData['room_type']['id_hotel'].', '.(int) $roomtypeData['room_type']['adults'].', '.(int) $roomtypeData['room_type']['children'].', \''.date('Y-m-d h:i:s').'\', \''.date('Y-m-d h:i:s').'\')');

View File

@@ -236,7 +236,7 @@ class ReferrerCore extends ObjectModel
if ($implode) {
$sql = 'SELECT COUNT(id_order) AS orders, SUM(total_paid_real / conversion_rate) AS sales
FROM '._DB_PREFIX_.'orders
WHERE id_order IN ('.implode($implode, ',').')
WHERE id_order IN ('.implode(',', $implode).')
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
AND valid = 1';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
@@ -349,6 +349,6 @@ class ReferrerCore extends ObjectModel
'percent_fee' => Tools::displayPrice($stats_sales['sales'] * $referrer->percent_fee / 100, $currency),
);
die('['.Tools::jsonEncode($json_array).']');
die('['.json_encode($json_array).']');
}
}

View File

@@ -1,157 +0,0 @@
<?php
/*
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class RijndaelCore
{
protected $_key;
protected $_iv;
public function __construct($key, $iv)
{
$this->_key = $key;
$this->_iv = base64_decode($iv);
}
/**
* Base64 is not required, but it is be more compact than urlencode
*
* @param string $plaintext
* @return bool|string
*/
public function encrypt($plaintext)
{
if (strlen($plaintext) >= 1048576) {
return false;
}
$cipherText = null;
if (function_exists('openssl_encrypt') && version_compare(phpversion(), '5.3.3', '>=')) {
$cipherText = openssl_encrypt($plaintext, 'AES-128-CBC', $this->_key, OPENSSL_RAW_DATA, $this->_iv);
} elseif (function_exists('mcrypt_encrypt')) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
$blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$pad = $blockSize - (strlen($plaintext) % $blockSize);
$cipherText = mcrypt_encrypt(
MCRYPT_RIJNDAEL_128,
$this->_key,
$plaintext . str_repeat(chr($pad), $pad),
MCRYPT_MODE_CBC,
$iv
);
$cipherText = $iv.$cipherText;
} else {
throw new RuntimeException('Either Mcrypt or OpenSSL extension is required to run Prestashop');
}
return $this->generateHmac($cipherText) . ':' . base64_encode($cipherText);
}
public function decrypt($cipherText)
{
$data = explode(':', $cipherText);
if (count($data) != 2) {
return false;
}
list($hmac, $encrypted) = $data;
$encrypted = base64_decode($encrypted);
$newHmac = $this->generateHmac($encrypted);
if ($hmac !== $newHmac) {
return false;
}
$output = null;
if (function_exists('openssl_decrypt') && version_compare(phpversion(), '5.3.3', '>=')) {
$output = openssl_decrypt($encrypted, 'AES-128-CBC', $this->_key, OPENSSL_RAW_DATA, $this->_iv);
} elseif (function_exists('mcrypt_decrypt')) {
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$ivDec = substr($encrypted, 0, $ivSize);
$encrypted = substr($encrypted, $ivSize);
$output = mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
$this->_key,
$encrypted,
MCRYPT_MODE_CBC,
$ivDec
);
$pad = ord($output[strlen($output) - 1]);
$output = substr($output, 0, -$pad);
} else {
throw new RuntimeException('Either Mcrypt or OpenSSL extension is required to run Prestashop');
}
return $output;
}
/**
* Generate Hmac
*
* @param string $encrypted
*
* @return string
*/
protected function generateHmac($encrypted)
{
$macKey = $this->generateKeygenS2k('sha256', $this->_key, $this->_iv, 32);
return hash_hmac(
'sha256',
$this->_iv . MCRYPT_RIJNDAEL_128 . $encrypted,
$macKey
);
}
/**
* Alternative to mhash_keygen_s2k for security reason
* and php compatibilities.
*
* @param string $hash
* @param string $password
* @param string $salt
* @param integer $bytes
*
* @return string
*/
protected function generateKeygenS2k($hash, $password, $salt, $bytes)
{
$result = '';
foreach (range(0, ceil($bytes / strlen(hash($hash, null, true))) - 1) as $i) {
$result .= hash(
$hash,
str_repeat("\0", $i) . str_pad(substr($salt, 0, 8), 8, "\0", STR_PAD_RIGHT) . $password,
true
);
}
return substr(
$result,
0,
intval($bytes)
);
}
}

View File

@@ -1,28 +1,28 @@
<?php
/*
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
require_once(_PS_TOOL_DIR_.'smarty/Smarty.class.php');

View File

@@ -1,28 +1,28 @@
<?php
/*
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class SmartyCustomCore extends Smarty
{

View File

@@ -0,0 +1,63 @@
<?php
/**
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class SmartyDev extends Smarty
{
public function __construct()
{
parent::__construct();
$this->template_class = 'Smarty_Dev_Template';
}
/**
* {@inheritDoc}
*/
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
{
return "\n<!-- begin $template -->\n"
.parent::fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter)
."\n<!-- end $template -->\n";
}
}
class Smarty_Dev_Template extends Smarty_Internal_Template
{
/** @var SmartyCustom|null */
public $smarty = null;
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
{
if (!is_null($template)) {
$tpl = $template->template_resource;
} else {
$tpl = $this->template_resource;
}
return "\n<!-- begin $tpl -->\n"
.parent::fetch($template, $cache_id, $compile_id, $parent, $display, $merge_tpl_vars, $no_output_filter)
."\n<!-- end $tpl -->\n";
}
}

View File

@@ -0,0 +1,95 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Used to delay loading of external classes with smarty->register_plugin.
*/
class SmartyLazyRegister
{
protected $registry = array();
protected static $instance;
/**
* Register a function or method to be dynamically called later.
*
* @param string|array $params function name or array(object name, method name)
*/
public function register($params)
{
if (is_array($params)) {
$this->registry[$params[1]] = $params;
} else {
$this->registry[$params] = $params;
}
}
public function isRegistered($params)
{
if (is_array($params)) {
$params = $params[1];
}
return isset($this->registry[$params]);
}
/**
* Dynamically call static function or method.
*
* @param string $name function name
* @param mixed $arguments function argument
*
* @return mixed function return
*/
public function __call($name, $arguments)
{
$item = $this->registry[$name];
// case 1: call to static method - case 2 : call to static function
if (is_array($item[1])) {
return call_user_func_array($item[1].'::'.$item[0], array($arguments[0], &$arguments[1]));
} else {
$args = array();
foreach ($arguments as $a => $argument) {
if ($a == 0) {
$args[] = $arguments[0];
} else {
$args[] = &$arguments[$a];
}
}
return call_user_func_array($item, $args);
}
}
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
}

View File

@@ -0,0 +1,68 @@
<?php
/**
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Override module templates easily
*
* @since 1.7.0.0
*/
class SmartyResourceModuleCore extends Smarty_Resource_Custom
{
private $shop;
public function __construct(array $paths)
{
$this->paths = $paths;
}
/**
* Fetch a template
*
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @return void
*/
protected function fetch($name, &$source, &$mtime)
{
foreach ($this->paths as $path) {
if (Tools::file_exists_cache($file = $path.$name)) {
if (_PS_MODE_DEV_) {
$source = implode('', [
'<!-- begin '.$file.' -->',
file_get_contents($file),
'<!-- end '.$file.' -->'
]);
} else {
$source = file_get_contents($file);
}
$mtime = filemtime($file);
return;
}
}
}
}

View File

@@ -104,65 +104,7 @@ class ToolsCore
}
}
if (function_exists('mcrypt_create_iv')) {
$bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
if ($bytes !== false && strlen($bytes) === $length) {
return $bytes;
}
}
// Else try to get $length bytes of entropy.
// Thanks to Zend
$result = '';
$entropy = '';
$msec_per_round = 400;
$bits_per_round = 2;
$total = $length;
$hash_length = 20;
while (strlen($result) < $length) {
$bytes = ($total > $hash_length) ? $hash_length : $total;
$total -= $bytes;
for ($i=1; $i < 3; $i++) {
$t1 = microtime(true);
$seed = mt_rand();
for ($j=1; $j < 50; $j++) {
$seed = sha1($seed);
}
$t2 = microtime(true);
$entropy .= $t1 . $t2;
}
$div = (int) (($t2 - $t1) * 1000000);
if ($div <= 0) {
$div = 400;
}
$rounds = (int) ($msec_per_round * 50 / $div);
$iter = $bytes * (int) (ceil(8 / $bits_per_round));
for ($i = 0; $i < $iter; $i ++) {
$t1 = microtime();
$seed = sha1(mt_rand());
for ($j = 0; $j < $rounds; $j++) {
$seed = sha1($seed);
}
$t2 = microtime();
$entropy .= $t1 . $t2;
}
$result .= sha1($entropy, true);
}
return substr($result, 0, $length);
return false;
}
public static function strReplaceFirst($search, $replace, $subject, $cur = 0)
@@ -926,6 +868,11 @@ class ToolsCore
return html_entity_decode((string)$string, ENT_QUOTES, 'utf-8');
}
public static function removeHtmlComments($html)
{
return preg_replace('/<!--(.|\s)*?-->/', '', $html);
}
public static function safePostVars()
{
if (!isset($_POST) || !is_array($_POST)) {
@@ -1066,7 +1013,7 @@ class ToolsCore
echo '
<script type="text/javascript">
console.'.$type.'('.Tools::jsonEncode($object).');
console.'.$type.'('.json_encode($object).');
</script>
';
}
@@ -1822,10 +1769,10 @@ class ToolsCore
return Tools::strtoupper(Tools::substr($str, 0, 1)).Tools::substr($str, 1);
}
public static function ucwords($str)
public static function ucwords($str, $encoding = 'utf-8')
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($str, MB_CASE_TITLE);
return mb_convert_case($str, MB_CASE_TITLE, $encoding);
}
return ucwords(Tools::strtolower($str));
}
@@ -2222,8 +2169,8 @@ class ToolsCore
public static function parserSQL($sql)
{
if (strlen($sql) > 0) {
require_once(_PS_TOOL_DIR_.'parser_sql/PHPSQLParser.php');
$parser = new PHPSQLParser($sql);
require_once _PS_TOOL_DIR_.'parser_sql/php_sql_parser_autoload.php';
$parser = new PHPSQLParser\PHPSQLParser($sql);
return $parser->parsed;
}
return false;
@@ -2660,19 +2607,15 @@ exit;
/**
* jsonDecode convert json string to php array / object
*
* @param string $json
* @param string $data
* @param bool $assoc (since 1.4.2.4) if true, convert to associativ array
* @return array
*/
public static function jsonDecode($json, $assoc = false)
public static function jsonDecode($data, $assoc = false, $depth = 512, $options = 0
)
{
if (function_exists('json_decode')) {
return json_decode($json, $assoc);
} else {
include_once(_PS_TOOL_DIR_.'json/json.php');
$pear_json = new Services_JSON(($assoc) ? SERVICES_JSON_LOOSE_TYPE : 0);
return $pear_json->decode($json);
}
Tools::displayAsDeprecated();
return json_decode($data, $assoc, $depth, $options);
}
/**
@@ -2681,15 +2624,15 @@ exit;
* @param array $data
* @return string json
*/
public static function jsonEncode($data)
public static function jsonEncode($data, $options = 0, $depth = 512)
{
if (function_exists('json_encode')) {
return json_encode($data);
} else {
include_once(_PS_TOOL_DIR_.'json/json.php');
$pear_json = new Services_JSON();
return $pear_json->encode($data);
Tools::displayAsDeprecated();
if (PHP_VERSION_ID < 50500) { /* PHP version < 5.5.0 */
return json_encode($data, $options);
}
return json_encode($data, $options, $depth);
}
/**
@@ -2854,14 +2797,9 @@ exit;
*/
public static function ZipTest($from_file)
{
if (class_exists('ZipArchive', false)) {
$zip = new ZipArchive();
return ($zip->open($from_file, ZIPARCHIVE::CHECKCONS) === true);
} else {
require_once(_PS_ROOT_DIR_.'/tools/pclzip/pclzip.lib.php');
$zip = new PclZip($from_file);
return ($zip->privCheckFormat() === true);
}
$zip = new ZipArchive();
return ($zip->open($from_file, ZipArchive::CHECKCONS) === true);
}
public static function getSafeModeStatus()
@@ -2881,23 +2819,12 @@ exit;
if (!file_exists($to_dir)) {
mkdir($to_dir, 0777);
}
if (class_exists('ZipArchive', false)) {
$zip = new ZipArchive();
if ($zip->open($from_file) === true && $zip->extractTo($to_dir) && $zip->close()) {
return true;
}
return false;
} else {
require_once(_PS_ROOT_DIR_.'/tools/pclzip/pclzip.lib.php');
$zip = new PclZip($from_file);
$list = $zip->extract(PCLZIP_OPT_PATH, $to_dir, PCLZIP_OPT_REPLACE_NEWER);
foreach ($list as $file) {
if ($file['status'] != 'ok' && $file['status'] != 'already_a_directory') {
return false;
}
}
$zip = new ZipArchive();
if ($zip->open($from_file) === true && $zip->extractTo($to_dir) && $zip->close()) {
return true;
}
return false;
}
public static function chmodr($path, $filemode)
@@ -3626,8 +3553,6 @@ exit;
public static function purifyHTML($html, $uri_unescape = null, $allow_style = false)
{
require_once(_PS_TOOL_DIR_.'htmlpurifier/HTMLPurifier.standalone.php');
static $use_html_purifier = null;
static $purifier = null;

View File

@@ -1803,14 +1803,14 @@ class AdminControllerCore extends Controller
}
if ($conf = Tools::getValue('conf')) {
$this->context->smarty->assign('conf', $this->json ? Tools::jsonEncode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]);
$this->context->smarty->assign('conf', $this->json ? json_encode($this->_conf[(int)$conf]) : $this->_conf[(int)$conf]);
}
foreach (array('errors', 'warnings', 'informations', 'confirmations') as $type) {
if (!is_array($this->$type)) {
$this->$type = (array)$this->$type;
}
$this->context->smarty->assign($type, $this->json ? Tools::jsonEncode(array_unique($this->$type)) : array_unique($this->$type));
$this->context->smarty->assign($type, $this->json ? json_encode(array_unique($this->$type)) : array_unique($this->$type));
}
if ($this->show_page_header_toolbar && !$this->lite_display) {
@@ -1824,7 +1824,7 @@ class AdminControllerCore extends Controller
$this->context->smarty->assign(
array(
'page' => $this->json ? Tools::jsonEncode($page) : $page,
'page' => $this->json ? json_encode($page) : $page,
'header' => $this->context->smarty->fetch($header_tpl),
'footer' => $this->context->smarty->fetch($footer_tpl),
)

View File

@@ -284,13 +284,17 @@ abstract class DbCore
*/
public static function getClass()
{
$class = 'MySQL';
$class = '';
if (PHP_VERSION_ID >= 50200 && extension_loaded('pdo_mysql')) {
$class = 'DbPDO';
} elseif (extension_loaded('mysqli')) {
$class = 'DbMySQLi';
}
if (empty($class)) {
throw new PrestaShopException('Cannot select any valid SQL engine.');
}
return $class;
}

View File

@@ -1,399 +0,0 @@
<?php
/*
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* 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 <contact@prestashop.com>
* @copyright 2007-2017 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/**
* Class MySQLCore
*/
class MySQLCore extends Db
{
/** @var resource */
protected $link;
/* @var resource */
protected $result;
/**
* Tries to connect to the database
*
* @see DbCore::connect()
* @return resource
* @throws PrestaShopDatabaseException
*/
public function connect()
{
if (!defined('_PS_MYSQL_REAL_ESCAPE_STRING_')) {
define('_PS_MYSQL_REAL_ESCAPE_STRING_', function_exists('mysql_real_escape_string'));
}
if (!$this->link = mysql_connect($this->server, $this->user, $this->password)) {
throw new PrestaShopDatabaseException(Tools::displayError('Link to database cannot be established.'));
}
if (!$this->set_db($this->database)) {
throw new PrestaShopDatabaseException(Tools::displayError('The database selection cannot be made.'));
}
// UTF-8 support
if (!mysql_query('SET NAMES \'utf8\'', $this->link)) {
throw new PrestaShopDatabaseException(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
}
return $this->link;
}
/**
* Tries to connect and create a new database
*
* @param string $host
* @param string $user
* @param string $password
* @param string $dbname
* @param bool $dropit If true, drops the created database.
* @return bool|resource
*/
public static function createDatabase($host, $user, $password, $dbname, $dropit = false)
{
$link = mysql_connect($host, $user, $password);
$success = mysql_query('CREATE DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link);
if ($dropit && (mysql_query('DROP DATABASE `'.str_replace('`', '\\`', $dbname).'`', $link) !== false)) {
return true;
}
return $success;
}
/**
* Destroys the database connection link
*
* @see DbCore::disconnect()
*/
public function disconnect()
{
mysql_close($this->link);
}
/**
* Executes an SQL statement, returning a result set as a result resource object.
*
* @see DbCore::_query()
* @param string $sql
* @return resource
*/
protected function _query($sql)
{
return mysql_query($sql, $this->link);
}
/**
* Returns the next row from the result set.
*
* @see DbCore::nextRow()
* @param bool|resource $result
* @return array|bool
*/
public function nextRow($result = false)
{
$return = false;
if (is_resource($result) && $result) {
$return = mysql_fetch_assoc($result);
} elseif (is_resource($this->_result) && $this->_result) {
$return = mysql_fetch_assoc($this->_result);
}
return $return;
}
/**
* Returns the next row from the result set.
*
* @see DbCore::_numRows()
* @param resource $result
* @return int
*/
protected function _numRows($result)
{
return mysql_num_rows($result);
}
/**
* Returns ID of the last inserted row.
*
* @see DbCore::Insert_ID()
* @return int
*/
public function Insert_ID()
{
return mysql_insert_id($this->link);
}
/**
* Return the number of rows affected by the last SQL query.
*
* @see DbCore::Affected_Rows()
* @return int
*/
public function Affected_Rows()
{
return mysql_affected_rows($this->link);
}
/**
* Returns error message.
*
* @see DbCore::getMsgError()
* @param bool $query
* @return string
*/
public function getMsgError($query = false)
{
return mysql_error($this->link);
}
/**
* Returns error code.
*
* @see DbCore::getNumberError()
* @return int
*/
public function getNumberError()
{
return mysql_errno($this->link);
}
/**
* Returns database server version.
*
* @see DbCore::getVersion()
* @return string
*/
public function getVersion()
{
return mysql_get_server_info($this->link);
}
/**
* Escapes illegal characters in a string.
*
* @see DbCore::_escape()
* @param string $str
* @return string
*/
public function _escape($str)
{
return _PS_MYSQL_REAL_ESCAPE_STRING_ ? mysql_real_escape_string($str, $this->link) : addslashes($str);
}
/**
* Switches to a different database.
*
* @see DbCore::set_db()
* @param string $db_name
* @return bool
*/
public function set_db($db_name)
{
return mysql_select_db($db_name, $this->link);
}
/**
* Returns all rows from the result set.
*
* @see DbCore::getAll()
* @param bool|resource $result
* @return array
*/
protected function getAll($result = false)
{
if (!$result) {
$result = $this->result;
}
$data = array();
while ($row = $this->nextRow($result)) {
$data[] = $row;
}
return $data;
}
/**
* Try a connection to the database and check if at least one table with same prefix exists
*
* @see Db::hasTableWithSamePrefix()
* @param string $server Server address
* @param string $user Login for database connection
* @param string $pwd Password for database connection
* @param string $db Database name
* @param string $prefix Tables prefix
* @return bool
*/
public static function hasTableWithSamePrefix($server, $user, $pwd, $db, $prefix)
{
if (!$link = @mysql_connect($server, $user, $pwd, true)) {
return false;
}
if (!@mysql_select_db($db, $link)) {
return false;
}
$sql = 'SHOW TABLES LIKE \''.$prefix.'%\'';
$result = mysql_query($sql);
return (bool)@mysql_fetch_assoc($result);
}
/**
* Try a connection to the database
*
* @see Db::checkConnection()
* @param string $server Server address
* @param string $user Login for database connection
* @param string $pwd Password for database connection
* @param string $db Database name
* @param bool $newDbLink
* @param string|null $engine
* @param int $timeout
* @return int Error code or 0 if connection was successful
*/
public static function tryToConnect($server, $user, $pwd, $db, $new_db_link = true, $engine = null, $timeout = 5)
{
ini_set('mysql.connect_timeout', $timeout);
if (!$link = @mysql_connect($server, $user, $pwd, $new_db_link)) {
return 1;
}
if (!@mysql_select_db($db, $link)) {
return 2;
}
@mysql_close($link);
return 0;
}
/**
* Selects best table engine.
*
* @return string
*/
public function getBestEngine()
{
$value = 'InnoDB';
$sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
$result = mysql_query($sql);
if (!$result) {
$value = 'MyISAM';
}
$row = mysql_fetch_assoc($result);
if (!$row || strtolower($row['Value']) != 'yes') {
$value = 'MyISAM';
}
/* MySQL >= 5.6 */
$sql = 'SHOW ENGINES';
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
if ($row['Engine'] == 'InnoDB') {
if (in_array($row['Support'], array('DEFAULT', 'YES'))) {
$value = 'InnoDB';
}
break;
}
}
return $value;
}
/**
* Tries to connect to the database and create a table (checking creation privileges)
*
* @param string $server
* @param string $user
* @param string $pwd
* @param string $db
* @param string $prefix
* @param string|null $engine Table engine
* @return bool|string True, false or error
*/
public static function checkCreatePrivilege($server, $user, $pwd, $db, $prefix, $engine = null)
{
ini_set('mysql.connect_timeout', 5);
if (!$link = @mysql_connect($server, $user, $pwd, true)) {
return false;
}
if (!@mysql_select_db($db, $link)) {
return false;
}
if ($engine === null) {
$engine = 'MyISAM';
}
$result = mysql_query('
CREATE TABLE `'.$prefix.'test` (
`test` tinyint(1) unsigned NOT NULL
) ENGINE='.$engine, $link);
if (!$result) {
return mysql_error($link);
}
mysql_query('DROP TABLE `'.$prefix.'test`', $link);
return true;
}
/**
* Try a connection to the database and set names to UTF-8
*
* @see Db::checkEncoding()
* @param string $server Server address
* @param string $user Login for database connection
* @param string $pwd Password for database connection
* @return bool
*/
public static function tryUTF8($server, $user, $pwd)
{
$link = @mysql_connect($server, $user, $pwd);
$ret = mysql_query('SET NAMES \'utf8\'', $link);
@mysql_close($link);
return $ret;
}
/**
* Checks if auto increment value and offset is 1
*
* @param string $server
* @param string $user
* @param string $pwd
* @return bool
*/
public static function checkAutoIncrement($server, $user, $pwd)
{
$link = @mysql_connect($server, $user, $pwd);
$ret = (bool)(($result = mysql_query('SELECT @@auto_increment_increment as aii', $link)) && ($row = mysql_fetch_assoc($result)) && $row['aii'] == 1);
$ret &= (bool)(($result = mysql_query('SELECT @@auto_increment_offset as aio', $link)) && ($row = mysql_fetch_assoc($result)) && $row['aio'] == 1);
@mysql_close($link);
return $ret;
}
}

View File

@@ -435,7 +435,7 @@ class HelperListCore extends Helper
'token' => $token != null ? $token : $this->token,
'action' => self::$cache_lang['Details'],
'params' => $ajax_params,
'json_params' => Tools::jsonEncode($ajax_params)
'json_params' => json_encode($ajax_params)
));
return $tpl->fetch();
}

View File

@@ -142,8 +142,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
*/
public function getContent()
{
$invoiceAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true);
$deliveryAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true);
$invoiceAddressPatternRules = json_decode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true);
$deliveryAddressPatternRules = json_decode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true);
$invoice_address = new Address((int)$this->order->id_address_invoice);
$country = new Country((int)$invoice_address->id_country);
@@ -444,8 +444,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = Tools::displayDate($data_v['date_from']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = Tools::displayDate($data_v['date_to']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;

View File

@@ -24,7 +24,6 @@
* International Registered Trademark & Property of PrestaShop SA
*/
require_once(_PS_TOOL_DIR_.'tcpdf/config/lang/eng.php');
require_once(_PS_TOOL_DIR_.'tcpdf/tcpdf.php');
/**

View File

@@ -76,7 +76,7 @@ class TreeToolbarSearchCore extends TreeToolbarButtonCore implements
$html = '';
foreach ($data as $item) {
$html .= Tools::jsonEncode($item).',';
$html .= json_encode($item).',';
if (array_key_exists('children', $item) && !empty($item['children'])) {
$html .= $this->_renderData($item['children']);
}

View File

@@ -73,7 +73,7 @@ class TreeToolbarSearchCategoriesCore extends TreeToolbarButtonCore implements
$html = '';
foreach ($data as $item) {
$html .= Tools::jsonEncode($item).',';
$html .= json_encode($item).',';
if (array_key_exists('children', $item) && !empty($item['children'])) {
$html .= $this->_renderData($item['children']);
}

View File

@@ -23,6 +23,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
require_once (_PS_TOOL_DIR_.'defuse/php-encryption/defuse-crypto.phar');
// Include some alias functions
require_once(_PS_CONFIG_DIR_.'alias.php');

View File

@@ -132,7 +132,7 @@ define('_PS_PRICE_DISPLAY_PRECISION_', Configuration::get('PS_PRICE_DISPLAY_PREC
define('_PS_PRICE_COMPUTE_PRECISION_', _PS_PRICE_DISPLAY_PRECISION_);
if (Configuration::get('PS_USE_HTMLPURIFIER')) {
require_once(_PS_TOOL_DIR_.'htmlpurifier/HTMLPurifier.standalone.php');
require_once(_PS_TOOL_DIR_.'htmlpurifier/HTMLPurifier.auto.php');
}
/* Load all languages */

View File

@@ -107,7 +107,6 @@ if (!defined('_PS_GEOIP_DIR_')) {
if (!defined('_PS_GEOIP_CITY_FILE_')) {
define('_PS_GEOIP_CITY_FILE_', 'GeoLiteCity.dat');
}
define('_PS_PEAR_XML_PARSER_PATH_', _PS_TOOL_DIR_.'pear_xml_parser/');
define('_PS_SWIFT_DIR_', _PS_TOOL_DIR_.'swift/');
define('_PS_TAASC_PATH_', _PS_TOOL_DIR_.'taasc/');
define('_PS_TCPDF_PATH_', _PS_TOOL_DIR_.'tcpdf/');
@@ -140,7 +139,7 @@ define('_PS_TMP_IMG_DIR_', _PS_IMG_DIR_.'tmp/');
define('_PS_TRANS_PATTERN_', '(.*[^\\\\])');
define('_PS_MIN_TIME_GENERATE_PASSWD_', '360');
if (!defined('_PS_MAGIC_QUOTES_GPC_')) {
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
define('_PS_MAGIC_QUOTES_GPC_', function_exists('get_magic_quotes_gpc')? @get_magic_quotes_gpc() : false);
}
define('_CAN_LOAD_FILES_', 1);

View File

@@ -29,7 +29,14 @@ define('_PS_SMARTY_DIR_', _PS_TOOL_DIR_.'smarty/');
require_once(_PS_SMARTY_DIR_.'Smarty.class.php');
global $smarty;
$smarty = new SmartyCustom();
if (Configuration::get('PS_SMARTY_LOCAL')) {
$smarty = new SmartyCustom();
} elseif (_PS_MODE_DEV_) {
$smarty = new SmartyDev();
} else {
$smarty = new Smarty();
}
$smarty->setCompileDir(_PS_CACHE_DIR_.'smarty/compile');
$smarty->setCacheDir(_PS_CACHE_DIR_.'smarty/cache');
if (!Tools::getSafeModeStatus()) {
@@ -38,7 +45,7 @@ if (!Tools::getSafeModeStatus()) {
$smarty->setConfigDir(_PS_SMARTY_DIR_.'configs');
$smarty->caching = false;
if (Configuration::get('PS_SMARTY_CACHING_TYPE') == 'mysql') {
include(_PS_CLASS_DIR_.'/SmartyCacheResourceMysql.php');
include _PS_CLASS_DIR_.'Smarty/SmartyCacheResourceMysql.php';
$smarty->caching_type = 'mysql';
}
$smarty->force_compile = (Configuration::get('PS_SMARTY_FORCE_COMPILE') == _PS_SMARTY_FORCE_COMPILE_) ? true : false;
@@ -55,7 +62,27 @@ if (defined('_PS_ADMIN_DIR_')) {
} else {
require_once(dirname(__FILE__).'/smartyfront.config.inc.php');
}
require_once SMARTY_PLUGINS_DIR.'modifier.truncate.php';
// This escape modifier is required for invoice PDF generation
function smartyEscape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
{
$escapeModifierFile = implode(
DIRECTORY_SEPARATOR,
array(
SMARTY_PLUGINS_DIR,
'modifier.escape.php',
)
);
require_once $escapeModifierFile;
global $smarty;
if (($esc_type === 'html' || $esc_type === 'htmlall') && $smarty->escape_html) {
return $string;
} else {
return smarty_modifier_escape($string, $esc_type, $char_set, $double_encode);
}
}
smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate');
smartyRegisterFunction($smarty, 'modifier', 'secureReferrer', array('Tools', 'secureReferrer'));
@@ -123,25 +150,6 @@ function smartyTruncate($params, &$smarty)
return (isset($params['encode']) ? Tools::htmlentitiesUTF8($text, ENT_NOQUOTES) : $text);
}
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false, $charset = 'UTF-8')
{
if (!$length) {
return '';
}
$string = trim($string);
if (Tools::strlen($string) > $length) {
$length -= min($length, Tools::strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/u', '', Tools::substr($string, 0, $length+1, $charset));
}
return !$middle ? Tools::substr($string, 0, $length, $charset).$etc : Tools::substr($string, 0, $length/2, $charset).$etc.Tools::substr($string, -$length/2, $length, $charset);
} else {
return $string;
}
}
function smarty_modifier_htmlentitiesUTF8($string)
{
return Tools::htmlentitiesUTF8($string);
@@ -175,6 +183,9 @@ function smartyRegisterFunction($smarty, $type, $function, $params, $lazy = true
// lazy is better if the function is not called on every page
if ($lazy) {
$lazy_register = SmartyLazyRegister::getInstance();
if ($lazy_register->isRegistered($params)) {
return;
}
$lazy_register->register($params);
if (is_array($params)) {
@@ -221,61 +232,3 @@ function toolsConvertPrice($params, &$smarty)
return Tools::convertPrice($params['price'], Context::getContext()->currency);
}
/**
* Used to delay loading of external classes with smarty->register_plugin
*/
class SmartyLazyRegister
{
protected $registry = array();
protected static $instance;
/**
* Register a function or method to be dynamically called later
* @param string|array $params function name or array(object name, method name)
*/
public function register($params)
{
if (is_array($params)) {
$this->registry[$params[1]] = $params;
} else {
$this->registry[$params] = $params;
}
}
/**
* Dynamically call static function or method
*
* @param string $name function name
* @param mixed $arguments function argument
* @return mixed function return
*/
public function __call($name, $arguments)
{
$item = $this->registry[$name];
// case 1: call to static method - case 2 : call to static function
if (is_array($item[1])) {
return call_user_func_array($item[1].'::'.$item[0], array($arguments[0], &$arguments[1]));
} else {
$args = array();
foreach ($arguments as $a => $argument) {
if ($a == 0) {
$args[] = $arguments[0];
} else {
$args[] = &$arguments[$a];
}
}
return call_user_func_array($item, $args);
}
}
public static function getInstance()
{
if (!self::$instance) {
self::$instance = new SmartyLazyRegister();
}
return self::$instance;
}
}

View File

@@ -33,7 +33,7 @@ $smarty->force_compile = (Configuration::get('PS_SMARTY_FORCE_COMPILE') == _PS_S
// But force compile_check since the performance impact is small and it is better for debugging
$smarty->compile_check = true;
function smartyTranslate($params, &$smarty)
function smartyTranslate($params, $smarty)
{
$htmlentities = !isset($params['js']);
$pdf = isset($params['pdf']);

View File

@@ -25,7 +25,7 @@
*/
global $smarty;
$smarty->setTemplateDir(_PS_THEME_DIR_.'tpl');
$smarty->setTemplateDir(_PS_THEME_DIR_);
if (Configuration::get('PS_HTML_THEME_COMPRESSION')) {
$smarty->registerFilter('output', 'smartyMinifyHTML');
@@ -34,7 +34,7 @@ if (Configuration::get('PS_JS_HTML_THEME_COMPRESSION')) {
$smarty->registerFilter('output', 'smartyPackJSinHTML');
}
function smartyTranslate($params, &$smarty)
function smartyTranslate($params, $smarty)
{
global $_LANG;
@@ -48,7 +48,47 @@ function smartyTranslate($params, &$smarty)
$params['mod'] = false;
}
if (!isset($params['sprintf'])) {
$params['sprintf'] = null;
$params['sprintf'] = array();
}
if (!isset($params['d'])) {
$params['d'] = null;
}
if (!is_null($params['d'])) {
if (isset($params['tags'])) {
$backTrace = debug_backtrace();
$errorMessage = sprintf(
'Unable to translate "%s" in %s. tags() is not supported anymore, please use sprintf().',
$params['s'],
$backTrace[0]['args'][1]->template_resource
);
if (_PS_MODE_DEV_) {
throw new Exception($errorMessage);
} else {
PrestaShopLogger::addLog($errorMessage);
}
}
if (!is_array($params['sprintf'])) {
$backTrace = debug_backtrace();
$errorMessage = sprintf(
'Unable to translate "%s" in %s. sprintf() parameter should be an array.',
$params['s'],
$backTrace[0]['args'][1]->template_resource
);
if (_PS_MODE_DEV_) {
throw new Exception($errorMessage);
} else {
PrestaShopLogger::addLog($errorMessage);
return $params['s'];
}
}
}
$string = str_replace('\'', '\\\'', $params['s']);

View File

@@ -495,7 +495,7 @@ class AdminAddressesControllerCore extends AdminController
$customer = Customer::searchByName($email);
if (!empty($customer)) {
$customer = $customer['0'];
echo Tools::jsonEncode(array('infos' => pSQL($customer['firstname']).'_'.pSQL($customer['lastname']).'_'.pSQL($customer['company'])));
echo json_encode(array('infos' => pSQL($customer['firstname']).'_'.pSQL($customer['lastname']).'_'.pSQL($customer['company'])));
}
}
die;

View File

@@ -76,7 +76,7 @@ class AdminAttributeGeneratorControllerCore extends AdminController
protected static function createCombinations($list)
{
if (count($list) <= 1) {
return count($list) ? array_map(create_function('$v', 'return (array($v));'), $list[0]) : $list;
return count($list) ? array_map(function ($v) {return (array($v));}, $list[0]) : $list;
}
$res = array();
$first = array_pop($list);

View File

@@ -297,7 +297,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
$associations = array();
}
$this->fields_form['shop_associations'] = Tools::jsonEncode($associations);
$this->fields_form['shop_associations'] = json_encode($associations);
$this->fields_form['input'][] = array(
'type' => 'color',

View File

@@ -652,7 +652,7 @@ class AdminCarrierWizardControllerCore extends AdminController
$return['errors'] = $this->errors;
}
if (count($this->errors) || $die) {
die(Tools::jsonEncode($return));
die(json_encode($return));
}
}
@@ -870,7 +870,7 @@ class AdminCarrierWizardControllerCore extends AdminController
$return['id_carrier'] = $carrier->id;
}
}
die(Tools::jsonEncode($return));
die(json_encode($return));
}
protected function changeGroups($id_carrier, $delete = true)

View File

@@ -140,7 +140,7 @@ class AdminCartRulesControllerCore extends AdminController
}
}
}
echo Tools::jsonEncode(array('html' => $html, 'next_link' => $next_link));
echo json_encode(array('html' => $html, 'next_link' => $next_link));
}
public function setMedia()
@@ -589,7 +589,7 @@ class AdminCartRulesControllerCore extends AdminController
)
ORDER BY c.`firstname`, c.`lastname` ASC
LIMIT 50');
die(Tools::jsonEncode($customers));
die(json_encode($customers));
}
// Both product filter (free product and product discount) search for products
if (Tools::isSubmit('giftProductFilter') || Tools::isSubmit('reductionProductFilter')) {
@@ -599,7 +599,7 @@ class AdminCartRulesControllerCore extends AdminController
$products,
$this->context->employee->id_profile
);
die(Tools::jsonEncode($products));
die(json_encode($products));
}
}
@@ -642,7 +642,7 @@ class AdminCartRulesControllerCore extends AdminController
public function ajaxProcessSearchProducts()
{
$array = $this->searchProducts(Tools::getValue('product_search'));
$this->content = trim(Tools::jsonEncode($array));
$this->content = trim(json_encode($array));
}
public function renderForm()
@@ -771,6 +771,6 @@ class AdminCartRulesControllerCore extends AdminController
if ($vouchers = CartRule::getCartsRuleByCode(Tools::getValue('q'), (int)$this->context->language->id, true)) {
$found = true;
}
echo Tools::jsonEncode(array('found' => $found, 'vouchers' => $vouchers));
echo json_encode(array('found' => $found, 'vouchers' => $vouchers));
}
}

View File

@@ -403,10 +403,10 @@ class AdminCartsControllerCore extends AdminController
$errors[] = Tools::displayError('Invalid combination');
}
if (count($errors)) {
die(Tools::jsonEncode($errors));
die(json_encode($errors));
}
if ($this->context->cart->deleteProduct($id_product, $id_product_attribute, (int)Tools::getValue('id_customization'))) {
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
}
@@ -520,7 +520,7 @@ class AdminCartsControllerCore extends AdminController
}
}
echo Tools::jsonEncode(array_merge($this->ajaxReturnVars(), array('errors' => $errors)));
echo json_encode(array_merge($this->ajaxReturnVars(), array('errors' => $errors)));
}
}
@@ -541,7 +541,7 @@ class AdminCartsControllerCore extends AdminController
$this->context->cart->gift_message = $gift_message;
}
$this->context->cart->save();
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
@@ -563,7 +563,7 @@ class AdminCartsControllerCore extends AdminController
} elseif (Validate::isLoadedObject($message)) {
$message->delete();
}
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
@@ -593,7 +593,7 @@ class AdminCartsControllerCore extends AdminController
$result = $this->ajaxReturnVars();
$result['cart_detail_html'] = $cart_dtl_tpl;//tpl is added to the returned array
echo Tools::jsonEncode($result);
echo json_encode($result);
}
}
public function ajaxProcessUpdateLang()
@@ -604,7 +604,7 @@ class AdminCartsControllerCore extends AdminController
$this->context->cart->id_lang = (int)$lang->id;
$this->context->cart->save();
}
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
@@ -623,7 +623,7 @@ class AdminCartsControllerCore extends AdminController
$errors[] = Tools::displayError('The order cannot be renewed.');
} else {
$this->context->cart = $new_cart['cart'];
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
}
@@ -632,7 +632,7 @@ class AdminCartsControllerCore extends AdminController
{
if ($this->tabAccess['edit'] === '1') {
if ($this->context->cart->removeCartRule((int)Tools::getValue('id_cart_rule'))) {
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
}
@@ -663,7 +663,7 @@ class AdminCartsControllerCore extends AdminController
$this->context->cart->addCartRule((int)$cart_rule->id);
}
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
@@ -681,14 +681,14 @@ class AdminCartsControllerCore extends AdminController
$errors[] = Tools::displayError('Can\'t add the voucher.');
}
}
echo Tools::jsonEncode(array_merge($this->ajaxReturnVars(), array('errors' => $errors)));
echo json_encode(array_merge($this->ajaxReturnVars(), array('errors' => $errors)));
}
}
public function ajaxProcessUpdateAddress()
{
if ($this->tabAccess['edit'] === '1') {
echo Tools::jsonEncode(array('addresses' => $this->context->customer->getAddresses((int)$this->context->cart->id_lang)));
echo json_encode(array('addresses' => $this->context->customer->getAddresses((int)$this->context->cart->id_lang)));
}
}
@@ -709,7 +709,7 @@ class AdminCartsControllerCore extends AdminController
/*$this->context->cart->id_address_invoice = (int)$address_invoice->id;*/
$this->context->cart->save();
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}
@@ -825,7 +825,7 @@ class AdminCartsControllerCore extends AdminController
$to_return = array_merge($this->ajaxReturnVars(), array('found' => false));
}
echo Tools::jsonEncode($to_return);
echo json_encode($to_return);
}
public function ajaxReturnVars()
@@ -879,7 +879,7 @@ class AdminCartsControllerCore extends AdminController
public function displayAjaxGetSummary()
{
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
public function ajaxProcessUpdateProductPrice()
@@ -903,7 +903,7 @@ class AdminCartsControllerCore extends AdminController
$specific_price->from = '0000-00-00 00:00:00';
$specific_price->to = '0000-00-00 00:00:00';
$specific_price->add();
echo Tools::jsonEncode($this->ajaxReturnVars());
echo json_encode($this->ajaxReturnVars());
}
}

View File

@@ -961,14 +961,14 @@ class AdminCategoriesControllerCore extends AdminController
public function ajaxProcessStatusCategory()
{
if (!$id_category = (int)Tools::getValue('id_category')) {
die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status'))));
die(json_encode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status'))));
} else {
$category = new Category((int)$id_category);
if (Validate::isLoadedObject($category)) {
$category->active = $category->active == 1 ? 0 : 1;
$category->save() ?
die(Tools::jsonEncode(array('success' => true, 'text' => $this->l('The status has been updated successfully')))) :
die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status'))));
die(json_encode(array('success' => true, 'text' => $this->l('The status has been updated successfully')))) :
die(json_encode(array('success' => false, 'error' => true, 'text' => $this->l('Failed to update the status'))));
}
}
}

View File

@@ -896,7 +896,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
}
if (Tools::isSubmit('syncImapMail')) {
die(Tools::jsonEncode($this->syncImap()));
die(json_encode($this->syncImap()));
}
}

View File

@@ -1104,7 +1104,7 @@ class AdminCustomersControllerCore extends AdminController
$to_return = array('found' => false);
}
$this->content = Tools::jsonEncode($to_return);
$this->content = json_encode($to_return);
}
/**

View File

@@ -370,7 +370,7 @@ class AdminDashboardControllerCore extends AdminController
'extra' => (int)Tools::getValue('extra')
);
die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'))));
die(json_encode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'))));
}
public function ajaxProcessSetSimulationMode()
@@ -437,7 +437,7 @@ class AdminDashboardControllerCore extends AdminController
}
}
}
die(Tools::jsonEncode($return));
die(json_encode($return));
}
public function ajaxProcessSaveDashConfig()
@@ -475,6 +475,6 @@ class AdminDashboardControllerCore extends AdminController
$return['widget_html'] = $module_obj->$hook($params);
}
die(Tools::jsonEncode($return));
die(json_encode($return));
}
}

View File

@@ -673,6 +673,6 @@ class AdminEmployeesControllerCore extends AdminController
}
}
}
die(Tools::jsonEncode($this->tabs_list));
die(json_encode($this->tabs_list));
}
}

View File

@@ -451,7 +451,7 @@ class AdminGroupsControllerCore extends AdminController
$result['discount'] = $category_reduction;
$result['hasError'] = false;
}
die(Tools::jsonEncode($result));
die(json_encode($result));
}
/**

View File

@@ -58,9 +58,9 @@ class AdminImagesControllerCore extends AdminController
'height' => array('title' => $this->l('Height'), 'suffix' => ' px'),
'products' => array('title' => $this->l('Products'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
'categories' => array('title' => $this->l('Categories'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
'manufacturers' => array('title' => $this->l('Manufacturers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
'suppliers' => array('title' => $this->l('Suppliers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
'stores' => array('title' => $this->l('Stores'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false)
// 'manufacturers' => array('title' => $this->l('Manufacturers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
// 'suppliers' => array('title' => $this->l('Suppliers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false),
// 'stores' => array('title' => $this->l('Stores'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false)
);
// Scenes tab has been removed by default from the installation, but may still exists in updates
@@ -267,46 +267,46 @@ class AdminImagesControllerCore extends AdminController
),
)
),
array(
'type' => 'switch',
'label' => $this->l('Manufacturers'),
'name' => 'manufacturers',
'required' => false,
'is_bool' => true,
'hint' => $this->l('This type will be used for Manufacturer images.'),
'values' => array(
array(
'id' => 'manufacturers_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'manufacturers_off',
'value' => 0,
'label' => $this->l('Disabled')
),
)
),
array(
'type' => 'switch',
'label' => $this->l('Suppliers'),
'name' => 'suppliers',
'required' => false,
'is_bool' => true,
'hint' => $this->l('This type will be used for Supplier images.'),
'values' => array(
array(
'id' => 'suppliers_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'suppliers_off',
'value' => 0,
'label' => $this->l('Disabled')
),
)
),
// array(
// 'type' => 'switch',
// 'label' => $this->l('Manufacturers'),
// 'name' => 'manufacturers',
// 'required' => false,
// 'is_bool' => true,
// 'hint' => $this->l('This type will be used for Manufacturer images.'),
// 'values' => array(
// array(
// 'id' => 'manufacturers_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'manufacturers_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// ),
// )
// ),
// array(
// 'type' => 'switch',
// 'label' => $this->l('Suppliers'),
// 'name' => 'suppliers',
// 'required' => false,
// 'is_bool' => true,
// 'hint' => $this->l('This type will be used for Supplier images.'),
// 'values' => array(
// array(
// 'id' => 'suppliers_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'suppliers_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// ),
// )
// ),
array(
'type' => 'switch',
'label' => $this->l('Scenes'),
@@ -328,26 +328,26 @@ class AdminImagesControllerCore extends AdminController
),
)
),
array(
'type' => 'switch',
'label' => $this->l('Stores'),
'name' => 'stores',
'required' => false,
'is_bool' => true,
'hint' => $this->l('This type will be used for Store images.'),
'values' => array(
array(
'id' => 'stores_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'stores_off',
'value' => 0,
'label' => $this->l('Disabled')
),
)
),
// array(
// 'type' => 'switch',
// 'label' => $this->l('Stores'),
// 'name' => 'stores',
// 'required' => false,
// 'is_bool' => true,
// 'hint' => $this->l('This type will be used for Store images.'),
// 'values' => array(
// array(
// 'id' => 'stores_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'stores_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// ),
// )
// ),
),
'submit' => array(
'title' => $this->l('Save')

View File

@@ -665,7 +665,7 @@ class AdminImportControllerCore extends AdminController
$_FILES['file']['filename'] = $filename_prefix.str_replace('\0', '', $_FILES['file']['name']);
}
die(Tools::jsonEncode($_FILES));
die(json_encode($_FILES));
}
public function renderView()
@@ -2110,7 +2110,7 @@ class AdminImportControllerCore extends AdminController
Tools::displayError('%s cannot be saved'),
(isset($image->id_product) ? ' ('.$image->id_product.')' : '')
);
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').mysql_error();
$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').Db::getInstance()->getMsgError()();
}
}
}

View File

@@ -127,8 +127,10 @@ class AdminInformationControllerCore extends AdminController
'fopen' => $this->l('Allow the PHP fopen() function on your server.'),
'register_globals' => $this->l('Set PHP "register_globals" option to "Off".'),
'gz' => $this->l('Enable GZIP compression on your server.'),
'files' => $this->l('Some PrestaShop files are missing from your server.'),
'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by PrestaShop will be PHP 5.4. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.4 now!'), phpversion())
'files' => $this->l('Some QloApps files are missing from your server.'),
'new_phpversion' => sprintf($this->l('You are using PHP %s version. Soon, the latest PHP version supported by QloApps will be PHP 5.4. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.4 now!'), phpversion()),
'pdo_mysql' => $this->l('PDO MySQL extension is not loaded')
'openssl' => $this->l('PHP OpenSSL extension is not loaded'),
);
// Functions list to test with 'test_system'
@@ -169,11 +171,11 @@ class AdminInformationControllerCore extends AdminController
$this->file_list = array('missing' => array(), 'updated' => array());
$xml = @simplexml_load_file(_PS_API_URL_.'/xml/md5/'._PS_VERSION_.'.xml');
if (!$xml || !isset($xml->ps_root_dir[0])) {
die(Tools::jsonEncode($this->file_list));
die(json_encode($this->file_list));
}
$this->getListOfUpdatedFiles($xml->ps_root_dir[0]);
die(Tools::jsonEncode($this->file_list));
die(json_encode($this->file_list));
}
public function getListOfUpdatedFiles(SimpleXMLElement $dir, $path = '')

View File

@@ -543,7 +543,7 @@ class AdminLanguagesControllerCore extends AdminController
// Get all iso code available
if ($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.Tools::getValue('ps_version').'&iso_lang='.Tools::strtolower(Tools::getValue('iso_lang')))) {
$result = Tools::jsonDecode($lang_packs);
$result = json_decode($lang_packs);
if ($lang_packs !== '' && $result && !isset($result->error)) {
$this->status = 'ok';
$this->content = $lang_packs;

View File

@@ -219,14 +219,14 @@ class AdminLoginControllerCore extends AdminController
}
if (Tools::isSubmit('ajax')) {
die(Tools::jsonEncode(array('hasErrors' => false, 'redirect' => $url)));
die(json_encode(array('hasErrors' => false, 'redirect' => $url)));
} else {
$this->redirect_after = $url;
}
}
}
if (Tools::isSubmit('ajax')) {
die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors)));
die(json_encode(array('hasErrors' => true, 'errors' => $this->errors)));
}
}
@@ -270,19 +270,19 @@ class AdminLoginControllerCore extends AdminController
if (!$result) {
$this->errors[] = Tools::displayError('An error occurred while attempting to change your password.');
} else {
die(Tools::jsonEncode(array(
die(json_encode(array(
'hasErrors' => false,
'confirm' => $this->l('Your password has been emailed to you.', 'AdminTab', false, false)
)));
}
} else {
die(Tools::jsonEncode(array(
die(json_encode(array(
'hasErrors' => true,
'errors' => array(Tools::displayError('An error occurred while attempting to change your password.'))
)));
}
} elseif (Tools::isSubmit('ajax')) {
die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors)));
die(json_encode(array('hasErrors' => true, 'errors' => $this->errors)));
}
}
}

View File

@@ -218,7 +218,7 @@ class AdminModulesControllerCore extends AdminController
public function displayAjaxRefreshModuleList()
{
echo Tools::jsonEncode(array('status' => $this->status));
echo json_encode(array('status' => $this->status));
}
@@ -403,7 +403,7 @@ class AdminModulesControllerCore extends AdminController
}
}
} else {
require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');
require_once _PS_TOOL_DIR_.'tar/Tar.php';
$archive = new Archive_Tar($file);
if ($archive->extract($tmp_folder)) {
$zip_folders = scandir($tmp_folder);
@@ -1091,7 +1091,7 @@ class AdminModulesControllerCore extends AdminController
// Get the list of installed module ans prepare it for ajax call.
if (($list = Tools::getValue('installed_modules'))) {
Context::getContext()->smarty->assign('installed_modules', Tools::jsonEncode(explode('|', $list)));
Context::getContext()->smarty->assign('installed_modules', json_encode(explode('|', $list)));
}
// If redirect parameter is present and module already installed, we redirect on configuration module page
@@ -1532,7 +1532,7 @@ class AdminModulesControllerCore extends AdminController
}
// AutoComplete array
$autocomplete_list .= Tools::jsonEncode(array(
$autocomplete_list .= json_encode(array(
'displayName' => (string)$module->displayName,
'desc' => (string)$module->description,
'name' => (string)$module->name,

View File

@@ -552,7 +552,7 @@ class AdminModulesPositionsControllerCore extends AdminController
}
}
$hookableList['hasError'] = false;
die(Tools::jsonEncode($hookableList));
die(json_encode($hookableList));
}
}
@@ -582,7 +582,7 @@ class AdminModulesPositionsControllerCore extends AdminController
}
}
}
die(Tools::jsonEncode($hookableModulesList));
die(json_encode($hookableModulesList));
}
}
public function ajaxProcessSaveHook()

View File

@@ -133,6 +133,7 @@ class AdminOrdersControllerCore extends AdminController
'align' => 'text-right',
'type' => 'price',
'currency' => true,
'havingFilter' => true,
'callback' => 'setOrderCurrency',
'badge_success' => true,
),
@@ -1548,7 +1549,7 @@ class AdminOrdersControllerCore extends AdminController
$bookingOrderInfo = $objBookingDetail->getBookingDataByOrderId($order->id);
// hotel booking statuses
$htlOrderStatus = HotelOrderStatus::getAllHotelOrderStatus();
$htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus();
$this->tpl_view_vars = array(
// refund info
@@ -1715,7 +1716,7 @@ class AdminOrdersControllerCore extends AdminController
$to_return = array('found' => false);
}
$this->content = Tools::jsonEncode($to_return);
$this->content = json_encode($to_return);
}
public function ajaxProcessSendMailValidateOrder()
@@ -1745,11 +1746,11 @@ class AdminOrdersControllerCore extends AdminController
true,
$cart->id_shop
)) {
die(Tools::jsonEncode(array('errors' => false, 'result' => $this->l('The email was sent to your customer.'))));
die(json_encode(array('errors' => false, 'result' => $this->l('The email was sent to your customer.'))));
}
}
}
$this->content = Tools::jsonEncode(array('errors' => true, 'result' => $this->l('Error in sending the email to your customer.')));
$this->content = json_encode(array('errors' => true, 'result' => $this->l('Error in sending the email to your customer.')));
}
}
@@ -1759,7 +1760,7 @@ class AdminOrdersControllerCore extends AdminController
$id_order = (int) Tools::getValue('id_order');
$order = new Order($id_order);
if (!Validate::isLoadedObject($order)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The order object cannot be loaded.')
)));
@@ -1768,7 +1769,7 @@ class AdminOrdersControllerCore extends AdminController
$old_cart_rules = Context::getContext()->cart->getCartRules();
if ($order->hasBeenShipped()) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('You cannot add products to delivered orders. ')
)));
@@ -1782,37 +1783,37 @@ class AdminOrdersControllerCore extends AdminController
$curr_date = date('Y-m-d');
/*Validations*/
if ($date_from == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter Check In Date.'),
)));
} elseif (!Validate::isDateFormat($date_from)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter a Valid Check In Date.'),
)));
} elseif ($date_to == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter Check Out Date.'),
)));
} elseif (!Validate::isDateFormat($date_to)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter a valid Check out Date.'),
)));
} elseif ($date_from < $curr_date) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Check In date should not be date before current date.'),
)));
} elseif ($date_to <= $date_from) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Check out Date Should be after Check In date.'),
)));
} elseif (!Validate::isUnsignedInt($product_informations['product_quantity'])) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter a valid Quantity.'),
)));
@@ -1836,19 +1837,19 @@ class AdminOrdersControllerCore extends AdminController
$total_available_rooms = $hotel_room_data['stats']['num_avail'];
if ($total_available_rooms < $req_rm) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Required number of rooms are not available.'),
)));
}
} else {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Some error occured Please try again.'),
)));
}
} else {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Some error occured Please try again.'),
)));
@@ -1865,7 +1866,7 @@ class AdminOrdersControllerCore extends AdminController
$idProduct = $product_informations['product_id'];
$product = new Product($idProduct, false, $order->id_lang);
if (!Validate::isLoadedObject($product)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The product object cannot be loaded.')
)));
@@ -1874,7 +1875,7 @@ class AdminOrdersControllerCore extends AdminController
if (isset($product_informations['product_attribute_id']) && $product_informations['product_attribute_id']) {
$combination = new Combination($product_informations['product_attribute_id']);
if (!Validate::isLoadedObject($combination)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The combination object cannot be loaded.')
)));
@@ -1986,9 +1987,9 @@ class AdminOrdersControllerCore extends AdminController
if ($update_quantity < 0) {
// If product has attribute, minimal quantity is set with minimal quantity of attribute
$minimal_quantity = ($product_informations['product_attribute_id']) ? Attribute::getAttributeMinimalQty($product_informations['product_attribute_id']) : $product->minimal_quantity;
die(Tools::jsonEncode(array('error' => sprintf(Tools::displayError('You must add %d minimum quantity', false), $minimal_quantity))));
die(json_encode(array('error' => sprintf(Tools::displayError('You must add %d minimum quantity', false), $minimal_quantity))));
} elseif (!$update_quantity) {
die(Tools::jsonEncode(array('error' => Tools::displayError('You already have the maximum quantity available for this product.', false))));
die(json_encode(array('error' => Tools::displayError('You already have the maximum quantity available for this product.', false))));
}
// If order is valid, we can create a new invoice or edit an existing invoice
@@ -2264,7 +2265,7 @@ class AdminOrdersControllerCore extends AdminController
}
}
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => true,
//'view' => $this->createTemplate('_product_line.tpl')->fetch(),
'can_edit' => $this->tabAccess['add'],
@@ -2290,7 +2291,7 @@ class AdminOrdersControllerCore extends AdminController
{
// $order_detail = new OrderDetail(Tools::getValue('id_order_detail'));
// if (!Validate::isLoadedObject($order_detail))
// die(Tools::jsonEncode(array(
// die(json_encode(array(
// 'result' => false,
// 'error' => Tools::displayError('The OrderDetail object cannot be loaded.')
// )));
@@ -2298,7 +2299,7 @@ class AdminOrdersControllerCore extends AdminController
$id_product = Tools::getValue('id_product');
$product = new Product($id_product);
if (!Validate::isLoadedObject($product)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The product object cannot be loaded.')
)));
@@ -2306,13 +2307,13 @@ class AdminOrdersControllerCore extends AdminController
$address = new Address(Tools::getValue('id_address'));
if (!Validate::isLoadedObject($address)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The address object cannot be loaded.')
)));
}
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => true,
'product' => $product,
'tax_rate' => $product->getTaxesRate($address),
@@ -2354,47 +2355,47 @@ class AdminOrdersControllerCore extends AdminController
$qty_diff = $product_quantity - $old_product_quantity;
/*By webkul to validate fields before deleting the cart and order data form the tables*/
if ($id_hotel == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Hotel Id is mising.'),
)));
} elseif ($id_room == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Room Id is missing.'),
)));
} elseif ($new_date_from == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter Check In Date.'),
)));
} elseif (!Validate::isDateFormat($new_date_from)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter a Valid Check In Date.'),
)));
} elseif ($new_date_to == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter Check Out Date.'),
)));
} elseif (!Validate::isDateFormat($new_date_to)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Please Enter a valid Check out Date.'),
)));
} elseif ($new_date_from < $curr_date) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Check In date should not be after current date.'),
)));
} elseif ($new_date_to <= $new_date_from) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Check out Date Should be after Check In date.'),
)));
} elseif (!Validate::isUnsignedInt($product_quantity)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Invalid quantity.'),
)));
@@ -2402,7 +2403,7 @@ class AdminOrdersControllerCore extends AdminController
$rooms_booked = $obj_booking_detail->getRoomBookinInformationForDateRangeByOrder($id_room, $old_date_from, $old_date_to, $new_date_from, $new_date_to);
if ($rooms_booked) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('This Room Unavailable For Selected Duration.'),
)));
@@ -2580,7 +2581,7 @@ class AdminOrdersControllerCore extends AdminController
));
if (!$res) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => $res,
'error' => Tools::displayError('An error occurred while editing the product line.')
)));
@@ -2597,7 +2598,7 @@ class AdminOrdersControllerCore extends AdminController
$this->sendChangedNotification($order);
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => $res,
'view' => $view,
'can_edit' => $this->tabAccess['add'],
@@ -2627,32 +2628,32 @@ class AdminOrdersControllerCore extends AdminController
$product_quantity = (int) $obj_booking_detail->getNumberOfDays($date_from, $date_to);
/*By webkul to validate fields before deleting the cart and order data form the tables*/
if ($id_hotel == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Hotel Id is mising.'),
)));
} elseif ($id_room == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Room Id is missing.'),
)));
} elseif ($date_from == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Check In Date is missing.'),
)));
} elseif ($date_to == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Check Out Date is missing.'),
)));
} elseif ($date_to == '') {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Check Out Date is missing.'),
)));
} elseif (!Validate::isUnsignedInt($product_quantity)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Invalid quantity.'),
)));
@@ -2757,7 +2758,7 @@ class AdminOrdersControllerCore extends AdminController
}
if (!$res) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => $res,
'error' => Tools::displayError('An error occurred while attempting to delete the product line.')
)));
@@ -2795,7 +2796,7 @@ class AdminOrdersControllerCore extends AdminController
$this->sendChangedNotification($order);
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => $res,
'order' => $order,
'invoices' => $invoice_array,
@@ -2807,28 +2808,28 @@ class AdminOrdersControllerCore extends AdminController
protected function doEditProductValidation(OrderDetail $order_detail, Order $order, OrderInvoice $order_invoice = null)
{
if (!Validate::isLoadedObject($order_detail)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The Order Detail object could not be loaded.')
)));
}
if (!empty($order_invoice) && !Validate::isLoadedObject($order_invoice)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The invoice object cannot be loaded.')
)));
}
if (!Validate::isLoadedObject($order)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The order object cannot be loaded.')
)));
}
if ($order_detail->id_order != $order->id) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('You cannot edit the order detail for this order.')
)));
@@ -2836,14 +2837,14 @@ class AdminOrdersControllerCore extends AdminController
// We can't edit a delivered order
if ($order->hasBeenDelivered()) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('You cannot edit a delivered order.')
)));
}
if (!empty($order_invoice) && $order_invoice->id_order != Tools::getValue('id_order')) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('You cannot use this invoice for the order')
)));
@@ -2854,21 +2855,21 @@ class AdminOrdersControllerCore extends AdminController
$product_price_tax_excl = str_replace(',', '.', Tools::getValue('product_price_tax_excl'));
if (!Validate::isPrice($product_price_tax_incl) || !Validate::isPrice($product_price_tax_excl)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Invalid price')
)));
}
//commented by webkul here quantity is gap between booking days which is calulated and validated in ajaxProcessEditProductOnOrder();
/*if (!is_array(Tools::getValue('product_quantity')) && !Validate::isUnsignedInt(Tools::getValue('product_quantity')))
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Invalid quantity')
)));
elseif (is_array(Tools::getValue('product_quantity')))
foreach (Tools::getValue('product_quantity') as $qty)
if (!Validate::isUnsignedInt($qty))
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('Invalid quantity')
)));*/
@@ -2877,21 +2878,21 @@ class AdminOrdersControllerCore extends AdminController
protected function doDeleteProductLineValidation(OrderDetail $order_detail, Order $order)
{
if (!Validate::isLoadedObject($order_detail)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The Order Detail object could not be loaded.')
)));
}
if (!Validate::isLoadedObject($order)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The order object cannot be loaded.')
)));
}
if ($order_detail->id_order != $order->id) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('You cannot delete the order detail.')
)));
@@ -2899,7 +2900,7 @@ class AdminOrdersControllerCore extends AdminController
// We can't edit a delivered order
if ($order->hasBeenDelivered()) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('You cannot edit a delivered order.')
)));
@@ -2916,13 +2917,13 @@ class AdminOrdersControllerCore extends AdminController
$StockAvailable = StockAvailable::getQuantityAvailableByProduct($order_detail->product_id, $order_detail->product_attribute_id, $order_detail->id_shop);
$product = new Product($order_detail->product_id, true, null, $order_detail->id_shop);
if (!Validate::isLoadedObject($product)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('The Product object could not be loaded.')
)));
} else {
if (($StockAvailable < $add_quantity) && (!$product->isAvailableWhenOutOfStock((int)$product->out_of_stock))) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => false,
'error' => Tools::displayError('This product is no longer in stock with those attributes ')
)));
@@ -3074,7 +3075,7 @@ class AdminOrdersControllerCore extends AdminController
$authorized_modules = array();
if (!Validate::isLoadedObject($customer) || !is_array($modules)) {
die(Tools::jsonEncode(array('result' => false)));
die(json_encode(array('result' => false)));
}
foreach ($modules as $module) {
@@ -3093,7 +3094,7 @@ class AdminOrdersControllerCore extends AdminController
'payment_modules' => $payment_modules,
));
die(Tools::jsonEncode(array(
die(json_encode(array(
'result' => true,
'view' => $this->createTemplate('_select_payment.tpl')->fetch(),
)));
@@ -3128,7 +3129,7 @@ class AdminOrdersControllerCore extends AdminController
$result['status'] = 'failed';
}
die(Tools::jsonEncode($result));
die(json_encode($result));
}
// To show rooms extra demands in the modal box in order details view page
@@ -3238,8 +3239,8 @@ class AdminOrdersControllerCore extends AdminController
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
$roomDemands = Tools::getValue('room_demands');
$roomDemands = Tools::jsonDecode($roomDemands, true);
$roomDemands = Tools::jsonEncode($roomDemands);
$roomDemands = json_decode($roomDemands, true);
$roomDemands = json_encode($roomDemands);
$objCartbookingCata->extra_demands = $roomDemands;
if ($objCartbookingCata->save()) {
die('1');
@@ -3255,7 +3256,7 @@ class AdminOrdersControllerCore extends AdminController
if ($idHtlBooking = Tools::getValue('id_htl_booking')) {
if (Validate::isLoadedObject($objBookingDetail = new HotelBookingDetail($idHtlBooking))) {
$roomDemands = Tools::getValue('room_demands');
if ($roomDemands = Tools::jsonDecode($roomDemands, true)) {
if ($roomDemands = json_decode($roomDemands, true)) {
$order = new Order($objBookingDetail->id_order);
$vatAddress = new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$idLang = (int)$order->id_lang;
@@ -3369,7 +3370,10 @@ class AdminOrdersControllerCore extends AdminController
if (!$newStatus) {
$this->errors[] = Tools::displayError('Invalid booking status found.');
} elseif ($newStatus == 2 || $newStatus == 3) {
} elseif (
$newStatus == HotelBookingDetail::STATUS_CHECKED_IN
|| $newStatus == HotelBookingDetail::STATUS_CHECKED_OUT
) {
if (!$statusDate || !Validate::isDate($statusDate)) {
$this->errors[] = Tools::displayError('Invalid dates found.');
} elseif ((strtotime($statusDate) < strtotime($dateFrom))
@@ -3381,24 +3385,24 @@ class AdminOrdersControllerCore extends AdminController
if (!count($this->errors)) {
$objBookingDetail = new HotelBookingDetail();
if ($roomBookingInfo = $objBookingDetail->getRoomBookingData($idRoom, $idOrder)) {
if ($roomBookingInfo = $objBookingDetail->getRoomBookingData($idRoom, $idOrder, $dateFrom, $dateTo)) {
// if admin choose Check-Out status
if ($newStatus == 3
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT
&& $roomBookingInfo['check_in'] == '0000-00-00 00:00:00'
) {
$this->errors[] = Tools::displayError('Room status must be set to Check-In before setting the room status to Check-Out.');
} elseif ($newStatus == 3
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT
&& $roomBookingInfo['check_in'] != '0000-00-00 00:00:00'
&& strtotime($roomBookingInfo['check_in']) >= strtotime($statusDate)
) {
$this->errors[] = Tools::displayError('Check-Out date can not be before Check-In date').
'('.date('d-m-Y', strtotime($roomBookingInfo['check_in'])).')';
} elseif ($newStatus == 2 && $roomBookingInfo['check_out'] == '0000-00-00 00:00:00'
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN && $roomBookingInfo['check_out'] == '0000-00-00 00:00:00'
&& strtotime($roomBookingInfo['check_in']) >= strtotime($dateTo)
) {
$this->errors[] = Tools::displayError('Check-In date can not be after Check-Out date').
'('.date('d-m-Y', strtotime($roomBookingInfo['date_to'])).')';
} elseif ($newStatus == 2 && $roomBookingInfo['check_out'] != '0000-00-00 00:00:00'
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN && $roomBookingInfo['check_out'] != '0000-00-00 00:00:00'
&& strtotime($roomBookingInfo['check_out']) <= strtotime($statusDate)
) {
$this->errors[] = Tools::displayError('Check-In date can not be after Check-Out date').

View File

@@ -460,49 +460,6 @@ class AdminPerformanceControllerCore extends AdminController
$this->fields_value['_MEDIA_SERVER_3_'] = Configuration::get('PS_MEDIA_SERVER_3');
}
public function initFieldsetCiphering()
{
$phpdoc_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr');
$php_lang = in_array($this->context->language->iso_code, $phpdoc_langs) ? $this->context->language->iso_code : 'en';
$warning_mcrypt = ' '.$this->l('(you must install the [a]Mcrypt extension[/a])');
$warning_mcrypt = str_replace('[a]', '<a href="http://www.php.net/manual/'.substr($php_lang, 0, 2).'/book.mcrypt.php" target="_blank">', $warning_mcrypt);
$warning_mcrypt = str_replace('[/a]', '</a>', $warning_mcrypt);
if (defined('_RIJNDAEL_KEY_') && defined('_RIJNDAEL_IV_')) {
$this->fields_form[5]['form'] = array(
'legend' => array(
'title' => $this->l('Ciphering'),
'icon' => 'icon-desktop'
),
'input' => array(
array(
'type' => 'hidden',
'name' => 'ciphering_up'
),
array(
'type' => 'radio',
'label' => $this->l('Algorithm'),
'name' => 'PS_CIPHER_ALGORITHM',
'values' => array(
array(
'id' => 'PS_CIPHER_ALGORITHM_1',
'value' => 1,
'label' => $this->l('Use Rijndael with mcrypt lib.').(function_exists('mcrypt_encrypt') ? '' : $warning_mcrypt)
),
)
)
),
'submit' => array(
'title' => $this->l('Save')
)
);
}
$this->fields_value['PS_CIPHER_ALGORITHM'] = Configuration::get('PS_CIPHER_ALGORITHM');
}
public function initFieldsetCaching()
{
$phpdoc_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr');
@@ -618,7 +575,6 @@ class AdminPerformanceControllerCore extends AdminController
if (!defined('_PS_HOST_MODE_')) {
$this->initFieldsetMediaServer();
$this->initFieldsetCiphering();
$this->initFieldsetCaching();
}
@@ -840,51 +796,6 @@ class AdminPerformanceControllerCore extends AdminController
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if ((bool)Tools::getValue('ciphering_up') && Configuration::get('PS_CIPHER_ALGORITHM') != (int)Tools::getValue('PS_CIPHER_ALGORITHM')) {
if ($this->tabAccess['edit'] === '1') {
$algo = (int)Tools::getValue('PS_CIPHER_ALGORITHM');
$prev_settings = file_get_contents(_PS_ROOT_DIR_.'/config/settings.inc.php');
$new_settings = $prev_settings;
if ($algo) {
if (!function_exists('mcrypt_encrypt')) {
$this->errors[] = Tools::displayError('The "Mcrypt" PHP extension is not activated on this server.');
} else {
if (!strstr($new_settings, '_RIJNDAEL_KEY_')) {
$key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$key = Tools::passwdGen($key_size);
$new_settings = preg_replace(
'/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i',
'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');',
$new_settings
);
}
if (!strstr($new_settings, '_RIJNDAEL_IV_')) {
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND));
$new_settings = preg_replace(
'/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i',
'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');',
$new_settings
);
}
}
}
if (!count($this->errors)) {
// If there is not settings file modification or if the backup and replacement of the settings file worked
if ($new_settings == $prev_settings || (
copy(_PS_ROOT_DIR_.'/config/settings.inc.php', _PS_ROOT_DIR_.'/config/settings.old.php')
&& (bool)file_put_contents(_PS_ROOT_DIR_.'/config/settings.inc.php', $new_settings)
)) {
Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo);
$redirectAdmin = true;
} else {
$this->errors[] = Tools::displayError('The settings file cannot be overwritten.');
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
if ((bool)Tools::getValue('cache_up')) {
if ($this->tabAccess['edit'] === '1') {
@@ -1014,7 +925,7 @@ class AdminPerformanceControllerCore extends AdminController
$res = @memcache_get_server_status($memcache, $host, $port);
}
}
die(Tools::jsonEncode(array($res)));
die(json_encode(array($res)));
}
}
die;

View File

@@ -600,7 +600,7 @@ class AdminProductsControllerCore extends AdminController
public function ajaxProcessAddAttachment()
{
if ($this->tabAccess['edit'] === '0') {
return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission'))));
return die(json_encode(array('error' => $this->l('You do not have the right permission'))));
}
if (isset($_FILES['attachment_file'])) {
if ((int)$_FILES['attachment_file']['error'] === 1) {
@@ -720,7 +720,7 @@ class AdminProductsControllerCore extends AdminController
}
}
die(Tools::jsonEncode($_FILES));
die(json_encode($_FILES));
}
}
@@ -1296,7 +1296,7 @@ class AdminProductsControllerCore extends AdminController
);
}
die(Tools::jsonEncode($json));
die(json_encode($json));
}
public function processSpecificPricePriorities()
@@ -1632,7 +1632,7 @@ class AdminProductsControllerCore extends AdminController
);
}
die(Tools::jsonEncode($json));
die(json_encode($json));
}
public function ajaxProcessDefaultProductAttribute()
@@ -1656,7 +1656,7 @@ class AdminProductsControllerCore extends AdminController
);
}
die(Tools::jsonEncode($json));
die(json_encode($json));
}
}
@@ -1671,7 +1671,7 @@ class AdminProductsControllerCore extends AdminController
$combinations[$key]['attributes'][] = array($combination['group_name'], $combination['attribute_name'], $combination['id_attribute']);
}
die(Tools::jsonEncode($combinations));
die(json_encode($combinations));
}
}
}
@@ -1732,13 +1732,13 @@ class AdminProductsControllerCore extends AdminController
public function ajaxProcessUpdateImagePosition()
{
if ($this->tabAccess['edit'] === '0') {
return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission'))));
return die(json_encode(array('error' => $this->l('You do not have the right permission'))));
}
$res = false;
if ($json = Tools::getValue('json')) {
$res = true;
$json = stripslashes($json);
$images = Tools::jsonDecode($json, true);
$images = json_decode($json, true);
foreach ($images as $id => $position) {
$img = new Image((int)$id);
$img->position = (int)$position;
@@ -1755,7 +1755,7 @@ class AdminProductsControllerCore extends AdminController
public function ajaxProcessUpdateCover()
{
if ($this->tabAccess['edit'] === '0') {
return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission'))));
return die(json_encode(array('error' => $this->l('You do not have the right permission'))));
}
Image::deleteCover((int)Tools::getValue('id_product'));
$img = new Image((int)Tools::getValue('id_image'));
@@ -2742,7 +2742,7 @@ class AdminProductsControllerCore extends AdminController
if ($manufacturers) {
foreach ($manufacturers as $manufacturer) {
$tmp = array("optionValue" => $manufacturer['id_manufacturer'], "optionDisplay" => htmlspecialchars(trim($manufacturer['name'])));
$jsonArray[] = Tools::jsonEncode($tmp);
$jsonArray[] = json_encode($tmp);
}
}
@@ -2925,7 +2925,9 @@ class AdminProductsControllerCore extends AdminController
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 (Validate::isLoadedObject(($this->object))) {
$this->product_name = $this->object->name[$this->context->language->id];
}
if (!method_exists($this, 'initForm'.$this->tab_display)) {
return;
@@ -2965,7 +2967,7 @@ class AdminProductsControllerCore extends AdminController
$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['post_data'] = json_encode($_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');
@@ -3322,8 +3324,8 @@ class AdminProductsControllerCore extends AdminController
$objHotelInfo = new HotelBranchInformation();
$hotelInfo = $objHotelInfo->hotelsNameAndId();
if ($hotelInfo) {
$objRoomStatus = new HotelRoomStatus();
$roomStatus = $objRoomStatus->getAllRoomStatus();
$objRoomInfo = new HotelRoomInformation();
$roomStatus = $objRoomInfo->getAllRoomStatus();
$objRoomType = new HotelRoomType();
if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($obj->id)) {
@@ -3332,14 +3334,13 @@ class AdminProductsControllerCore extends AdminController
$hotelFullInfo = $objHotelInfo->hotelBranchInfoById($hotelRoomType['id_hotel']);
$data->assign('htl_full_info', $hotelFullInfo);
$objRoomInfo = new HotelRoomInformation();
$objRoomDisableDates = new HotelRoomDisableDates();
$hotelRoomInfo = $objRoomInfo->getHotelRoomInfo($obj->id, $hotelRoomType['id_hotel']);
if ($hotelRoomInfo) {
foreach ($hotelRoomInfo as &$room) {
if ($room['id_status'] == 3) {
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
$room['disabled_dates_json'] = Tools::jsonEncode($disabledDates);
$room['disabled_dates_json'] = json_encode($disabledDates);
}
}
$data->assign('htl_room_info', $hotelRoomInfo);
@@ -3491,8 +3492,8 @@ class AdminProductsControllerCore extends AdminController
//validate room status
$disableDtsArr = array();
foreach ($room_status as $key => $status) {
if ($status == 3) {
$disableDtsArr[$key] = Tools::jsonDecode($disable_dates[$key], true);
if ($status == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDtsArr[$key] = json_decode($disable_dates[$key], true);
$this->validateDisableDateRanges($disableDtsArr[$key]);
}
}
@@ -3527,7 +3528,7 @@ class AdminProductsControllerCore extends AdminController
$objRoomInfo->floor = $room_floor[$key];
$objRoomInfo->comment = $room_comment[$key];
if ($objRoomInfo->save()) {
if ($room_status[$key] == 3) {
if ($room_status[$key] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$objDisDts = new HotelRoomDisableDates();
$objDisDts->deleteRoomDisableDates($objRoomInfo->id);
if (isset($disableDtsArr[$key]) && $disableDtsArr[$key]) {
@@ -3714,7 +3715,7 @@ class AdminProductsControllerCore extends AdminController
}
if ($booking_calendar_data) {
die(Tools::jsonEncode($booking_calendar_data));
die(json_encode($booking_calendar_data));
} else {
die(0);
}
@@ -4793,7 +4794,7 @@ class AdminProductsControllerCore extends AdminController
}
}
die(Tools::jsonEncode(array($image_uploader->getName() => $files)));
die(json_encode(array($image_uploader->getName() => $files)));
}
/**
@@ -5421,28 +5422,28 @@ class AdminProductsControllerCore extends AdminController
public function ajaxProcessProductQuantity()
{
if ($this->tabAccess['edit'] === '0') {
return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission'))));
return die(json_encode(array('error' => $this->l('You do not have the right permission'))));
}
if (!Tools::getValue('actionQty')) {
return Tools::jsonEncode(array('error' => $this->l('Undefined action')));
return json_encode(array('error' => $this->l('Undefined action')));
}
$product = new Product((int)Tools::getValue('id_product'), true);
switch (Tools::getValue('actionQty')) {
case 'depends_on_stock':
if (Tools::getValue('value') === false) {
die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
die(json_encode(array('error' => $this->l('Undefined value'))));
}
if ((int)Tools::getValue('value') != 0 && (int)Tools::getValue('value') != 1) {
die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
die(json_encode(array('error' => $this->l('Incorrect value'))));
}
if (!$product->advanced_stock_management && (int)Tools::getValue('value') == 1) {
die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
die(json_encode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
}
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)Tools::getValue('value') == 1 && (Pack::isPack($product->id) && !Pack::allUsesAdvancedStockManagement($product->id)
&& ($product->pack_stock_type == 2 || $product->pack_stock_type == 1 ||
($product->pack_stock_type == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 1 || Configuration::get('PS_PACK_STOCK_TYPE') == 2))))) {
die(Tools::jsonEncode(array('error' => $this->l('You cannot use advanced stock management for this pack because').'<br />'.
die(json_encode(array('error' => $this->l('You cannot use advanced stock management for this pack because').'<br />'.
$this->l('- advanced stock management is not enabled for these room types').'<br />'.
$this->l('- you have chosen to decrement room types quantities.'))));
}
@@ -5453,15 +5454,15 @@ class AdminProductsControllerCore extends AdminController
case 'pack_stock_type':
$value = Tools::getValue('value');
if ($value === false) {
die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
die(json_encode(array('error' => $this->l('Undefined value'))));
}
if ((int)$value != 0 && (int)$value != 1
&& (int)$value != 2 && (int)$value != 3) {
die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
die(json_encode(array('error' => $this->l('Incorrect value'))));
}
if ($product->depends_on_stock && !Pack::allUsesAdvancedStockManagement($product->id) && ((int)$value == 1
|| (int)$value == 2 || ((int)$value == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 1 || Configuration::get('PS_PACK_STOCK_TYPE') == 2)))) {
die(Tools::jsonEncode(array('error' => $this->l('You cannot use this stock management option because:').'<br />'.
die(json_encode(array('error' => $this->l('You cannot use this stock management option because:').'<br />'.
$this->l('- advanced stock management is not enabled for these room types').'<br />'.
$this->l('- advanced stock management is enabled for the pack'))));
}
@@ -5471,10 +5472,10 @@ class AdminProductsControllerCore extends AdminController
case 'out_of_stock':
if (Tools::getValue('value') === false) {
die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
die(json_encode(array('error' => $this->l('Undefined value'))));
}
if (!in_array((int)Tools::getValue('value'), array(0, 1, 2))) {
die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
die(json_encode(array('error' => $this->l('Incorrect value'))));
}
StockAvailable::setProductOutOfStock($product->id, (int)Tools::getValue('value'));
@@ -5482,10 +5483,10 @@ class AdminProductsControllerCore extends AdminController
case 'set_qty':
if (Tools::getValue('value') === false || (!is_numeric(trim(Tools::getValue('value'))))) {
die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
die(json_encode(array('error' => $this->l('Undefined value'))));
}
if (Tools::getValue('id_product_attribute') === false) {
die(Tools::jsonEncode(array('error' => $this->l('Undefined id room type attribute'))));
die(json_encode(array('error' => $this->l('Undefined id room type attribute'))));
}
StockAvailable::setQuantity($product->id, (int)Tools::getValue('id_product_attribute'), (int)Tools::getValue('value'));
@@ -5495,18 +5496,18 @@ class AdminProductsControllerCore extends AdminController
$error = ob_get_contents();
if (!empty($error)) {
ob_end_clean();
die(Tools::jsonEncode(array('error' => $error)));
die(json_encode(array('error' => $error)));
}
break;
case 'advanced_stock_management' :
if (Tools::getValue('value') === false) {
die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
die(json_encode(array('error' => $this->l('Undefined value'))));
}
if ((int)Tools::getValue('value') != 1 && (int)Tools::getValue('value') != 0) {
die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
die(json_encode(array('error' => $this->l('Incorrect value'))));
}
if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int)Tools::getValue('value') == 1) {
die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
die(json_encode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
}
$product->setAdvancedStockManagement((int)Tools::getValue('value'));
@@ -5516,7 +5517,7 @@ class AdminProductsControllerCore extends AdminController
break;
}
die(Tools::jsonEncode(array('error' => false)));
die(json_encode(array('error' => false)));
}
public function getCombinationImagesJS()
@@ -5666,7 +5667,7 @@ class AdminProductsControllerCore extends AdminController
GROUP BY pl.`id_product`
LIMIT '.(int)$limit);
}
die(Tools::jsonEncode($result));
die(json_encode($result));
}
}

View File

@@ -153,7 +153,7 @@ class AdminQuickAccessesControllerCore extends AdminController
public function getQuickAccessesList()
{
$links = QuickAccess::getQuickAccesses($this->context->language->id);
return Tools::jsonEncode(array_map(array($this, 'getLinkToken'), $links));
return json_encode(array_map(array($this, 'getLinkToken'), $links));
}
public function getLinkToken($item)
@@ -195,7 +195,7 @@ class AdminQuickAccessesControllerCore extends AdminController
$this->errors = array_unique($this->errors);
if (!empty($this->errors)) {
$this->errors['has_errors'] = true;
$this->ajaxDie(Tools::jsonEncode($this->errors));
$this->ajaxDie(json_encode($this->errors));
return false;
}
return $this->getQuickAccessesList();

View File

@@ -197,7 +197,7 @@ class AdminRequestSqlControllerCore extends AdminController
unset($attributes[$key]['Default']);
unset($attributes[$key]['Extra']);
}
die(Tools::jsonEncode($attributes));
die(json_encode($attributes));
}
}

View File

@@ -191,7 +191,7 @@ class AdminSearchControllerCore extends AdminController
$iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
$iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
if (($json_content = Tools::file_get_contents('https://api-addons.prestashop.com/'._PS_VERSION_.'/search/'.urlencode($this->query).'/'.$iso_country.'/'.$iso_lang.'/')) != false) {
$results = Tools::jsonDecode($json_content, true);
$results = json_decode($json_content, true);
if (isset($results['id'])) {
$this->_list['addons'] = array($results);
} else {

View File

@@ -36,7 +36,7 @@ class AdminShopControllerCore extends AdminController
$this->table = 'shop';
$this->className = 'Shop';
$this->multishop_context = Shop::CONTEXT_ALL;
$this->id_shop_group = (int)Tools::getValue('id_shop_group');
/* if $_GET['id_shop'] is transmitted, virtual url can be loaded in config.php, so we wether transmit shop_id in herfs */
@@ -250,7 +250,7 @@ class AdminShopControllerCore extends AdminController
elseif (Shop::getTotalShops() == 1)
$this->errors[] = Tools::displayError('You cannot disable the last shop.');
}*/
if (Tools::isSubmit('submitAddshopAndStay') || Tools::isSubmit('submitAddshop')) {
$shop_group = new ShopGroup((int)Tools::getValue('id_shop_group'));
if ($shop_group->shopNameExists(Tools::getValue('name'), (int)Tools::getValue('id_shop'))) {
@@ -475,7 +475,7 @@ class AdminShopControllerCore extends AdminController
$root_category = new Category($root_categories[0]['id_category']);
$children = $root_category->getAllChildren($this->context->language->id);
$selected_cat[] = $root_categories[0]['id_category'];
foreach ($children as $child) {
$selected_cat[] = $child->id;
}
@@ -576,7 +576,7 @@ class AdminShopControllerCore extends AdminController
'zone' => $this->l('Zones'),
'cart_rule' => $this->l('Cart rules'),
);
// Hook for duplication of shop data
$modules_list = Hook::getHookModuleExecList('actionShopDataDuplication');
if (is_array($modules_list) && count($modules_list) > 0) {
@@ -586,7 +586,7 @@ class AdminShopControllerCore extends AdminController
}
asort($import_data);
if (!$this->object->id) {
$this->fields_import_form = array(
'radio' => array(
@@ -615,9 +615,9 @@ class AdminShopControllerCore extends AdminController
$this->fields_value = array(
'id_shop_group' => (Tools::getValue('id_shop_group') ? Tools::getValue('id_shop_group') :
(isset($obj->id_shop_group)) ? $obj->id_shop_group : Shop::getContextShopGroupID()),
((isset($obj->id_shop_group)) ? $obj->id_shop_group : Shop::getContextShopGroupID())),
'id_category' => (Tools::getValue('id_category') ? Tools::getValue('id_category') :
(isset($obj->id_category)) ? $obj->id_category : (int)Configuration::get('PS_HOME_CATEGORY')),
((isset($obj->id_category)) ? $obj->id_category : (int)Configuration::get('PS_HOME_CATEGORY'))),
'id_theme_checked' => (isset($obj->id_theme) ? $obj->id_theme : $id_theme)
);
@@ -653,7 +653,7 @@ class AdminShopControllerCore extends AdminController
if (Tools::isSubmit('id_category_default')) {
$_POST['id_category'] = (int)Tools::getValue('id_category_default');
}
/* Checking fields validity */
$this->validateRules();
@@ -711,13 +711,13 @@ class AdminShopControllerCore extends AdminController
if (!array_key_exists('Edit', self::$cache_lang)) {
self::$cache_lang['Edit'] = $this->l('Edit', 'Helper');
}
$tpl->assign(array(
'href' => $this->context->link->getAdminLink('AdminShop').'&shop_id='.(int)$id.'&update'.$this->table,
'action' => self::$cache_lang['Edit'],
'id' => $id
));
return $tpl->fetch();
} else {
return;
@@ -738,7 +738,7 @@ class AdminShopControllerCore extends AdminController
$root_category = new Category($root_categories[0]['id_category']);
$children = $root_category->getAllChildren($this->context->language->id);
$selected_cat[] = $root_categories[0]['id_category'];
foreach ($children as $child) {
$selected_cat[] = $child->id;
}
@@ -860,6 +860,6 @@ class AdminShopControllerCore extends AdminController
'children' => $tree,
));
die(Tools::jsonEncode($tree));
die(json_encode($tree));
}
}

View File

@@ -281,7 +281,7 @@ class AdminShopUrlControllerCore extends AdminController
}
$this->tpl_form_vars = array(
'js_shop_url' => Tools::jsonEncode($list_shop_with_url)
'js_shop_url' => json_encode($list_shop_with_url)
);
$this->fields_value = array(

View File

@@ -542,7 +542,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
}
$value .= '%';
// ConfigurationKPI::updateValue('CONVERSION_RATE_CHART', Tools::jsonEncode($data));
// ConfigurationKPI::updateValue('CONVERSION_RATE_CHART', json_encode($data));
ConfigurationKPI::updateValue('CONVERSION_RATE', $value);
ConfigurationKPI::updateValue('CONVERSION_RATE_EXPIRE', strtotime(date('Y-m-d 00:00:00', strtotime('+1 day'))));
break;
@@ -793,8 +793,8 @@ class AdminStatsControllerCore extends AdminStatsTabController
if (isset($data)) {
$array['data'] = $data;
}
die(Tools::jsonEncode($array));
die(json_encode($array));
}
die(Tools::jsonEncode(array('has_errors' => true)));
die(json_encode(array('has_errors' => true)));
}
}

View File

@@ -51,7 +51,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
}
$this->content .= $this->renderView();
}
$this->content .= $this->displayMenu();
$this->content .= $this->displayCalendar();
$this->content .= $this->displayStats();
@@ -97,7 +97,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
$identifier = 'module';
$id = Tools::getValue('module');
}
$action = Context::getContext()->link->getAdminLink('AdminStats');
$action .= ($action && $table ? '&'.Tools::safeOutput($action) : '');
$action .= ($identifier && $id ? '&'.Tools::safeOutput($identifier).'='.(int)$id : '');
@@ -172,7 +172,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
return $tpl->fetch();
}
public function checkModulesNames($a, $b)
{
return (bool)($a['displayName'] > $b['displayName']);
@@ -205,7 +205,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
if (!isset($module_instance)) {
$module_instance = Module::getInstanceByName($module_name);
}
if ($module_instance && $module_instance->active) {
$hook = Hook::exec('displayAdminStatsModules', null, $module_instance->id);
}
@@ -223,9 +223,9 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
public function postProcess()
{
$this->context = Context::getContext();
$this->processDateRange();
if (Tools::getValue('submitSettings')) {
if ($this->tabAccess['edit'] === '1') {
self::$currentIndex .= '&module='.Tools::getValue('module');
@@ -237,7 +237,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
}
}
}
public function processDateRange()
{
if (Tools::isSubmit('submitDatePicker')) {
@@ -281,21 +281,21 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
}
}
}
public function ajaxProcessSetDashboardDateRange()
{
$this->processDateRange();
if ($this->isXmlHttpRequest()) {
if (is_array($this->errors) && count($this->errors)) {
die(Tools::jsonEncode(array(
die(json_encode(array(
'has_errors' => true,
'errors' => array($this->errors),
'date_from' => $this->context->employee->stats_date_from,
'date_to' => $this->context->employee->stats_date_to)
));
} else {
die(Tools::jsonEncode(array(
die(json_encode(array(
'has_errors' => false,
'date_from' => $this->context->employee->stats_date_from,
'date_to' => $this->context->employee->stats_date_to)

View File

@@ -719,7 +719,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
}
$this->tpl_form_vars['products_list'] = $products;
$this->tpl_form_vars['product_ids'] = implode($product_ids, '|');
$this->tpl_form_vars['product_ids'] = implode('|', $product_ids);
$this->tpl_form_vars['product_ids_to_delete'] = '';
$this->tpl_form_vars['supplier_id'] = $supply_order->id_supplier;
$this->tpl_form_vars['currency'] = $currency;
@@ -1771,7 +1771,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
}
}
if ($items) {
die(Tools::jsonEncode($items));
die(json_encode($items));
}
die(1);

View File

@@ -546,7 +546,7 @@ class AdminTaxRulesGroupControllerCore extends AdminController
foreach ($tax_rules as $key => $result) {
$output[$key] = $result;
}
die(Tools::jsonEncode($output));
die(json_encode($output));
}
}

View File

@@ -179,8 +179,8 @@ class AdminTranslationsControllerCore extends AdminController
$file_name = $this->link_lang_pack.'?version='._PS_VERSION_;
$array_stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 8)));
if ($lang_packs = Tools::file_get_contents($file_name, false, $array_stream_context)) {
// Notice : for php < 5.2 compatibility, Tools::jsonDecode. The second parameter to true will set us
if ($lang_packs != '' && $lang_packs = Tools::jsonDecode($lang_packs, true)) {
// Notice : for php < 5.2 compatibility, json_decode. The second parameter to true will set us
if ($lang_packs != '' && $lang_packs = json_decode($lang_packs, true)) {
foreach ($lang_packs as $key => $lang_pack) {
if (!Language::isInstalled($lang_pack['iso_code'])) {
$packs_to_install[$key] = $lang_pack;
@@ -481,7 +481,7 @@ class AdminTranslationsControllerCore extends AdminController
$this->exportTabs();
$items = array_flip(Language::getFilesList($this->lang_selected->iso_code, $this->theme_selected, false, false, false, false, true));
$file_name = _PS_TRANSLATIONS_DIR_.'/export/'.$this->lang_selected->iso_code.'.gzip';
require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');
require_once(_PS_TOOL_DIR_.'tar/Tar.php');
$gz = new Archive_Tar($file_name, true);
if ($gz->createModify($items, null, _PS_ROOT_DIR_)) {
ob_start();
@@ -718,7 +718,7 @@ class AdminTranslationsControllerCore extends AdminController
if (!isset($_FILES['file']['tmp_name']) || !$_FILES['file']['tmp_name']) {
$this->errors[] = Tools::displayError('No file has been selected.');
} else {
require_once(_PS_TOOL_DIR_.'tar/Archive_Tar.php');
require_once(_PS_TOOL_DIR_.'tar/Tar.php');
$gz = new Archive_Tar($_FILES['file']['tmp_name'], true);
$filename = $_FILES['file']['name'];
$iso_code = str_replace(array('.tar.gz', '.gzip'), '', $filename);
@@ -859,7 +859,7 @@ class AdminTranslationsControllerCore extends AdminController
if ($content) {
$file = _PS_TRANSLATIONS_DIR_.$arr_import_lang[0].'.gzip';
if ((bool)@file_put_contents($file, $content)) {
require_once(_PS_TOOL_DIR_.'/tar/Archive_Tar.php');
require_once(_PS_TOOL_DIR_.'/tar/Tar.php');
$gz = new Archive_Tar($file, true);
if (_PS_MODE_DEV_) {
$gz->setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
@@ -1019,7 +1019,7 @@ class AdminTranslationsControllerCore extends AdminController
$arr_good_ext = array('.tpl', '.php');
foreach ($files as $key => $file) {
if ($file{0} === '.' || in_array(substr($file, 0, strrpos($file, '.')), $this->all_iso_lang)) {
if ($file[0] === '.' || in_array(substr($file, 0, strrpos($file, '.')), $this->all_iso_lang)) {
unset($files[$key]);
} elseif ($type_clear === 'file' && !in_array(substr($file, strrpos($file, '.')), $arr_good_ext)) {
unset($files[$key]);
@@ -2872,7 +2872,7 @@ class AdminTranslationsControllerCore extends AdminController
$initial_root_dir = $root_dir;
foreach ($modules as $module) {
$root_dir = $initial_root_dir;
if ($module{0} == '.') {
if ($module[0] == '.') {
continue;
}

View File

@@ -204,7 +204,7 @@ class AddressControllerCore extends FrontController
'hasError' => (bool)$this->errors,
'errors' => $this->errors
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
}
@@ -231,7 +231,7 @@ class AddressControllerCore extends FrontController
'id_address_delivery' => (int)$this->context->cart->id_address_delivery,
'id_address_invoice' => (int)$this->context->cart->id_address_invoice
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
// Redirect to old page or current page
@@ -364,7 +364,7 @@ class AddressControllerCore extends FrontController
'hasError' => !empty($this->errors),
'errors' => $this->errors
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
}
}

View File

@@ -168,7 +168,7 @@ class AuthControllerCore extends FrontController
'page' => $this->context->smarty->fetch($this->template),
'token' => Tools::getToken(false)
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
}
@@ -349,7 +349,7 @@ class AuthControllerCore extends FrontController
'errors' => $this->errors,
'token' => Tools::getToken(false)
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
} else {
$this->context->smarty->assign('authentification_error', $this->errors);
}
@@ -516,7 +516,7 @@ class AuthControllerCore extends FrontController
'id_address_invoice' => $this->context->cart->id_address_invoice,
'token' => Tools::getToken(false)
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
@@ -690,7 +690,7 @@ class AuthControllerCore extends FrontController
'id_address_invoice' => $this->context->cart->id_address_invoice,
'token' => Tools::getToken(false)
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
// if registration type is in two steps, we redirect to register address
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) {
@@ -730,7 +730,7 @@ class AuthControllerCore extends FrontController
'isSaved' => false,
'id_customer' => 0
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
$this->context->smarty->assign('account_error', $this->errors);
}

View File

@@ -105,7 +105,7 @@ class CartControllerCore extends FrontController
}
} elseif (!$this->isTokenValid()) {
if (Tools::getValue('ajax')) {
$this->ajaxDie(Tools::jsonEncode(array(
$this->ajaxDie(json_encode(array(
'hasError' => true,
'errors' => array(Tools::displayError('Impossible to add the product to the cart. Please refresh page.')),
)));
@@ -137,7 +137,7 @@ class CartControllerCore extends FrontController
}
if ($total_quantity < $minimal_quantity) {
$this->ajaxDie(Tools::jsonEncode(array(
$this->ajaxDie(json_encode(array(
'hasError' => true,
'errors' => array(sprintf(Tools::displayError('You must add %d minimum quantity', !Tools::getValue('ajax')), $minimal_quantity)),
)));
@@ -210,7 +210,7 @@ class CartControllerCore extends FrontController
$new_id_address_delivery = (int)Tools::getValue('new_id_address_delivery');
if (!count(Carrier::getAvailableCarrierList(new Product($this->id_product), null, $new_id_address_delivery))) {
$this->ajaxDie(Tools::jsonEncode(array(
$this->ajaxDie(json_encode(array(
'hasErrors' => true,
'error' => Tools::displayError('It is not possible to deliver this product to the selected address.', false),
)));
@@ -312,7 +312,7 @@ class CartControllerCore extends FrontController
if (isset($hotel_room_data['stats']['num_avail'])) {
$total_available_rooms = $hotel_room_data['stats']['num_avail'];
if ($total_available_rooms < $req_rm) {
die(Tools::jsonEncode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms)));
die(json_encode(array('status' => 'unavailable_quantity', 'avail_rooms' => $total_available_rooms)));
}
} else {
$this->errors[] = Tools::displayError('Rooms are unavailable. Please try with different dates');
@@ -322,10 +322,10 @@ class CartControllerCore extends FrontController
}
}
} else {
die(Tools::jsonEncode(array('status' => 'failed3')));
die(json_encode(array('status' => 'failed3')));
}
} else {
die(Tools::jsonEncode(array('status' => 'failed4')));
die(json_encode(array('status' => 'failed4')));
}
}
@@ -416,8 +416,8 @@ class CartControllerCore extends FrontController
foreach ($hotel_room_info_arr as $key_hotel_room_info => $val_hotel_room_info) {
if ($chkQty < $req_rm) {
$roomDemand = Tools::getValue('roomDemands');
$roomDemand = Tools::jsonDecode($roomDemand, true);
$roomDemand = Tools::jsonEncode($roomDemand);
$roomDemand = json_decode($roomDemand, true);
$roomDemand = json_encode($roomDemand);
$obj_htl_cart_booking_data = new HotelCartBookingData();
$obj_htl_cart_booking_data->id_cart = $this->context->cart->id;
$obj_htl_cart_booking_data->id_guest = $this->context->cart->id_guest;
@@ -519,10 +519,10 @@ class CartControllerCore extends FrontController
public function displayAjax()
{
if ($this->errors) {
$this->ajaxDie(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors)));
$this->ajaxDie(json_encode(array('hasError' => true, 'errors' => $this->errors)));
}
if ($this->ajax_refresh) {
$this->ajaxDie(Tools::jsonEncode(array('refresh' => true)));
$this->ajaxDie(json_encode(array('refresh' => true)));
}
// write cookie if can't on destruct
@@ -560,7 +560,7 @@ class CartControllerCore extends FrontController
$json = '';
Hook::exec('actionCartListOverride', array('summary' => $result, 'json' => &$json));
$this->ajaxDie(Tools::jsonEncode(array_merge($result, (array)Tools::jsonDecode($json, true))));
$this->ajaxDie(json_encode(array_merge($result, (array)json_decode($json, true))));
}
// @todo create a hook
elseif (file_exists(_PS_MODULE_DIR_.'/blockcart/blockcart-ajax.php')) {

View File

@@ -305,7 +305,7 @@ class ContactControllerCore extends FrontController
if (Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
$hotelLocationArray = $objHotelInfo->getMapFormatHotelsInfo(Configuration::get('WK_MAP_HOTEL_ACTIVE_ONLY'));
if ($hotelLocationArray) {
$this->context->smarty->assign('hotelLocationArray', Tools::jsonEncode($hotelLocationArray));
$this->context->smarty->assign('hotelLocationArray', json_encode($hotelLocationArray));
}
}
//End

View File

@@ -138,7 +138,7 @@ class OrderControllerCore extends ParentOrderController
)
)
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
if ($this->nbProducts) {

View File

@@ -208,7 +208,7 @@ class OrderDetailControllerCore extends FrontController
$hasError = 1;
}
if ($bookingRefunds = Tools::getValue('bookings_to_refund')) {
if (!count($bookingRefunds = Tools::jsonDecode($bookingRefunds, true))) {
if (!count($bookingRefunds = json_decode($bookingRefunds, true))) {
$hasError = 1;
} else {
foreach ($bookingRefunds as $idHtlBooking) {
@@ -248,9 +248,9 @@ class OrderDetailControllerCore extends FrontController
// Emails to customer, admin on refund request state change
$objOrderReturn->changeIdOrderReturnState(OrderReturnState::ORDER_RETRUN_FIRST_STATUS, $objOrderReturn->id);
die(Tools::jsonEncode(array('status' => 1)));
die(json_encode(array('status' => 1)));
}
die(Tools::jsonEncode(array('status' => 0)));
die(json_encode(array('status' => 0)));
}
// END ajax request handle

View File

@@ -75,7 +75,7 @@ class OrderOpcControllerCore extends ParentOrderController
$this->getFormatedSummaryDetail()
);
Cart::addExtraCarriers($return);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the cart.');
}
@@ -89,7 +89,7 @@ class OrderOpcControllerCore extends ParentOrderController
case 'updateTOSStatusAndGetPayments':
if (Tools::isSubmit('checked')) {
$this->context->cookie->checkedTOS = (int)Tools::getValue('checked');
$this->ajaxDie(Tools::jsonEncode(array(
$this->ajaxDie(json_encode(array(
'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'),
'HOOK_PAYMENT' => $this->_getPaymentMethods()
)));
@@ -97,7 +97,7 @@ class OrderOpcControllerCore extends ParentOrderController
break;
case 'getCarrierList':
$this->ajaxDie(Tools::jsonEncode($this->_getCarrierList()));
$this->ajaxDie(json_encode($this->_getCarrierList()));
break;
case 'editCustomer':
@@ -132,14 +132,14 @@ class OrderOpcControllerCore extends ParentOrderController
} else {
$return['isSaved'] = false;
}
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
break;
case 'getAddressBlockAndCarriersAndPayments':
if ($this->context->customer->isLogged() || $this->context->customer->isGuest()) {
// check if customer have addresses
if (!Customer::getAddressesTotalById($this->context->customer->id)) {
$this->ajaxDie(Tools::jsonEncode(array('no_address' => 1)));
$this->ajaxDie(json_encode(array('no_address' => 1)));
}
if (file_exists(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php')) {
include_once(_PS_MODULE_DIR_.'blockuserinfo/blockuserinfo.php');
@@ -183,7 +183,7 @@ class OrderOpcControllerCore extends ParentOrderController
),
$this->getFormatedSummaryDetail()
);
$this->ajaxDie(Tools::jsonEncode($return));
$this->ajaxDie(json_encode($return));
}
die(Tools::displayError());
break;
@@ -265,11 +265,11 @@ class OrderOpcControllerCore extends ParentOrderController
'refresh' => (bool)$this->ajax_refresh),
$this->getFormatedSummaryDetail()
);
$this->ajaxDie(Tools::jsonEncode($result));
$this->ajaxDie(json_encode($result));
}
}
if (count($this->errors)) {
$this->ajaxDie(Tools::jsonEncode(array(
$this->ajaxDie(json_encode(array(
'hasError' => true,
'errors' => $this->errors
)));
@@ -958,8 +958,8 @@ class OrderOpcControllerCore extends ParentOrderController
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
$roomDemands = Tools::getValue('room_demands');
$roomDemands = Tools::jsonDecode($roomDemands, true);
$roomDemands = Tools::jsonEncode($roomDemands);
$roomDemands = json_decode($roomDemands, true);
$roomDemands = json_encode($roomDemands);
$objCartbookingCata->extra_demands = $roomDemands;
if ($objCartbookingCata->save()) {
die('1');

View File

@@ -969,7 +969,7 @@ class ProductControllerCore extends FrontController
$totalPrice += $totalRoomPrice;
$demandsPrice = 0;
if ($roomDemand = Tools::getValue('room_demands')) {
if ($roomDemand = Tools::jsonDecode($roomDemand, true)) {
if ($roomDemand = json_decode($roomDemand, true)) {
$objRoomDemandPrice = new HotelRoomTypeDemandPrice();
$demandsPrice = $objRoomDemandPrice->getRoomTypeDemandsTotalPrice(
$idProduct,
@@ -1009,6 +1009,6 @@ class ProductControllerCore extends FrontController
$result['msg'] = 'failed3';
$result['avail_rooms'] = 0;
}
die(Tools::jsonEncode($result));
die(json_encode($result));
}
}

View File

@@ -64,12 +64,12 @@ class SearchControllerCore extends FrontController
}
Hook::exec('actionSearch', array('expr' => $query, 'total' => count($searchResults)));
}
$this->ajaxDie(Tools::jsonEncode($searchResults));
$this->ajaxDie(json_encode($searchResults));
}
//Only controller content initialization when the user use the normal search
parent::initContent();
$product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int)$this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE');
if ($this->instant_search && !is_array($query)) {

View File

@@ -430,7 +430,7 @@ abstract class InstallControllerHttp
if (!$success && empty($message)) {
$message = print_r(@error_get_last(), true);
}
die(Tools::jsonEncode(array(
die(json_encode(array(
'success' => (bool)$success,
'message' => $message,
// 'memory' => round(memory_get_peak_usage()/1024/1024, 2).' Mo',

View File

@@ -221,7 +221,7 @@ class InstallControllerConsoleProcess extends InstallControllerConsole
$this->model_install->xml_loader_ids = $this->datas->xml_loader_ids;
$result = $this->model_install->populateDatabase();
$this->datas->xml_loader_ids = $this->model_install->xml_loader_ids;
Configuration::updateValue('PS_INSTALL_XML_LOADERS_ID', Tools::jsonEncode($this->datas->xml_loader_ids));
Configuration::updateValue('PS_INSTALL_XML_LOADERS_ID', json_encode($this->datas->xml_loader_ids));
return $result;
}
@@ -269,7 +269,7 @@ class InstallControllerConsoleProcess extends InstallControllerConsole
{
$this->initializeContext();
if ((!$this->datas->xml_loader_ids || !is_array($this->datas->xml_loader_ids)) && ($xml_ids = Tools::jsonDecode(Configuration::get('PS_INSTALL_XML_LOADERS_ID'), true))) {
if ((!$this->datas->xml_loader_ids || !is_array($this->datas->xml_loader_ids)) && ($xml_ids = json_decode(Configuration::get('PS_INSTALL_XML_LOADERS_ID'), true))) {
$this->datas->xml_loader_ids = $xml_ids;
}

View File

@@ -91,7 +91,7 @@ class InstallControllerHttpSystem extends InstallControllerHttp
'upload' => $this->l('Cannot upload files'),
'system' => $this->l('Cannot create new files and folders'),
'gd' => $this->l('GD library is not installed'),
'mysql_support' => $this->l('MySQL support is not activated'),
'pdo_mysql' => $this->l('PDO MySQL extension is not loaded'),
'curl' => $this->l('Curl extension is not loaded'),
'soap' => $this->l('SOAP extension is not loaded'),
'simplexml' => $this->l('SimpleXml extension is not loaded'),
@@ -99,6 +99,7 @@ class InstallControllerHttpSystem extends InstallControllerHttp
'max_execution_time' => $this->l('In the PHP configuration set max_execution_time to minimum 500'),
'upload_max_filesize' => $this->l('In the PHP configuration set upload_max_filesize to minimum 16M'),
'fopen' => $this->l('Cannot open external URLs (requires allow_url_fopen as On).'),
'zip' => $this->l('ZIP extension is not enabled'),
)
),
array(
@@ -139,7 +140,6 @@ class InstallControllerHttpSystem extends InstallControllerHttp
'mbstring' => $this->l('Mbstring extension is not enabled'),
'magicquotes' => $this->l('PHP magic quotes option is enabled'),
'dom' => $this->l('Dom extension is not loaded'),
'pdo_mysql' => $this->l('PDO MySQL extension is not loaded')
)
),
),

View File

@@ -113,7 +113,7 @@
$this->loader->setDefaultPath();
?>
<script type="text/javascript">
var dependencies = <?php echo Tools::jsonEncode($dependencies) ?>;
var dependencies = <?php echo json_encode($dependencies) ?>;
</script>
<form action="" method="post">
Selectionnez la liste des entités à resynchroniser. Afin d'éviter au maximum les erreurs, sélectionnez uniquement les entitiés que vous avez modifier.

View File

@@ -24,6 +24,8 @@
* International Registered Trademark & Property of PrestaShop SA
*/
require_once (_PS_TOOL_DIR_.'defuse/php-encryption/defuse-crypto.phar');
class InstallModelInstall extends InstallAbstractModel
{
const SETTINGS_FILE = 'config/settings.inc.php';
@@ -69,6 +71,7 @@ class InstallModelInstall extends InstallAbstractModel
$this->setError($this->language->l('%s folder is not writable (check permissions)', dirname(self::SETTINGS_FILE)));
return false;
}
$key = \Defuse\Crypto\Key::createNewRandomKey();
// Generate settings content and write file
$settings_constants = array(
@@ -82,17 +85,12 @@ class InstallModelInstall extends InstallAbstractModel
'_PS_CACHE_ENABLED_' => '0',
'_COOKIE_KEY_' => Tools::passwdGen(56),
'_COOKIE_IV_' => Tools::passwdGen(8),
'_NEW_COOKIE_KEY_' => $key->saveToAsciiSafeString(),
'_PS_CREATION_DATE_' => date('Y-m-d'),
'_PS_VERSION_' => _PS_INSTALL_VERSION_,
'_QLOAPPS_VERSION_' => _QLO_INSTALL_VERSION_,
);
// If mcrypt is activated, add Rijndael 128 configuration
if (function_exists('mcrypt_encrypt')) {
$settings_constants['_RIJNDAEL_KEY_'] = Tools::passwdGen(mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
$settings_constants['_RIJNDAEL_IV_'] = base64_encode(mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND));
}
$settings_content = "<?php\n";
foreach ($settings_constants as $constant => $value) {

View File

@@ -3,7 +3,7 @@
<script type="text/javascript">
<!--
var install_is_done = '<?php echo addslashes($this->l('Done!')) ?>';
var process_steps = <?php echo Tools::jsonEncode($this->process_steps) ?>;
var process_steps = <?php echo json_encode($this->process_steps) ?>;
var admin = '<?php echo(file_exists('../admin-dev') ? '../admin-dev' : '../admin') ?>';
-->
</script>

View File

@@ -86,7 +86,7 @@ class AddConfToFile
public function checkString($string)
{
if (get_magic_quotes_gpc()) {
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$string = stripslashes($string);
}
if (!is_numeric($string)) {

View File

@@ -25,7 +25,7 @@
*/
if (!defined('_PS_MAGIC_QUOTES_GPC_')) {
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
define('_PS_MAGIC_QUOTES_GPC_', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc());
}
if (!defined('_PS_MYSQL_REAL_ESCAPE_STRING_')) {
define('_PS_MYSQL_REAL_ESCAPE_STRING_', function_exists('mysql_real_escape_string'));

View File

@@ -31,7 +31,7 @@ function ps1607_language_code_update()
if (is_array($langs) && $langs) {
foreach ($langs as $lang) {
if (Tools::strlen($lang['language_code']) == 2) {
$result = Tools::jsonDecode(Tools::file_get_contents('https://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.Tools::strtolower($lang['iso_code'])));
$result = json_decode(Tools::file_get_contents('https://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.Tools::strtolower($lang['iso_code'])));
if ($result && !isset($result->error) && Tools::strlen($result->language_code) > 2) {
Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'lang` SET `language_code` = \''.pSQL($result->language_code).'\' WHERE `id_lang` = '.(int)$lang['id_lang']).' LIMIT 1';
}

View File

@@ -224,7 +224,8 @@ class blockcart extends Module
}
$this->assignContentVars($params);
$res = Tools::jsonDecode($this->display(__FILE__, 'blockcart-json.tpl'), true);
$res = json_decode(Tools::removeHtmlComments($this->display(__FILE__, 'blockcart-json.tpl')), true);
if (isset($params['cookie']->avail_rooms)) {
$res['avail_rooms'] = $params['cookie']->avail_rooms;
@@ -237,7 +238,7 @@ class blockcart extends Module
$res['crossSelling'] = $this->display(__FILE__, 'crossselling.tpl');
}
$res = Tools::jsonEncode($res);
$res = json_encode($res);
return $res;
}
@@ -249,7 +250,7 @@ class blockcart extends Module
}
$this->assignContentVars(array('cookie' => $this->context->cookie, 'cart' => $this->context->cart));
$params['json'] = $this->display(__FILE__, 'blockcart-json.tpl');
$params['json'] = Tools::removeHtmlComments($this->display(__FILE__, 'blockcart-json.tpl'));
}
public function hookHeader()

View File

@@ -57,21 +57,21 @@
break;
}
}
die(Tools::jsonEncode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms)));
die(json_encode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms)));
} else {
die(Tools::jsonEncode(array('status'=>'failed1')));
die(json_encode(array('status'=>'failed1')));
}
} else {
die(Tools::jsonEncode(array('status'=>'unavailable_quantity', 'avail_rooms'=>$total_available_rooms)));
die(json_encode(array('status'=>'unavailable_quantity', 'avail_rooms'=>$total_available_rooms)));
}
} else {
die(Tools::jsonEncode(array('status'=>'failed2')));
die(json_encode(array('status'=>'failed2')));
}
} else {
die(Tools::jsonEncode(array('status'=>'failed3')));
die(json_encode(array('status'=>'failed3')));
}
} else {
die(Tools::jsonEncode(array('status'=>'failed4')));
die(json_encode(array('status'=>'failed4')));
}
}
@@ -94,9 +94,9 @@
$result = $obj_htl_cart_booking_data->deleteCartBookingData($id_cart, $id_product);
if ($result) {
die(Tools::jsonEncode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms)));
die(json_encode(array('status'=>'success', 'avail_rooms'=>$total_available_rooms)));
} else {
die(Tools::jsonEncode(array('status'=>'failed')));
die(json_encode(array('status'=>'failed')));
}
}
@@ -109,10 +109,10 @@
$cart_obj = new Cart($id_cart);
$update_cart_product = $cart_obj->updateQty($num_rooms_to_decr_from_cart, $id_product, null, false, $operator = 'down', 0, null, true);
if ($update_cart_product) {
die(Tools::jsonEncode(array('status'=>'success', 'msg'=>'successfully cart product updated.')));
die(json_encode(array('status'=>'success', 'msg'=>'successfully cart product updated.')));
} else {
die(Tools::jsonEncode(array('status'=>'failed', 'msg'=>'error while updating cart product.')));
die(json_encode(array('status'=>'failed', 'msg'=>'error while updating cart product.')));
}
}
die(Tools::jsonEncode(array('status'=>'failed', 'msg'=>'error while deleting room from cart booking table.')));
die(json_encode(array('status'=>'failed', 'msg'=>'error while deleting room from cart booking table.')));
}

View File

@@ -50,7 +50,7 @@ class BlockcartCheckRoomAvailabilityAjaxProcessModuleFrontController extends Mod
}
}
die(
Tools::jsonEncode(
json_encode(
array(
'status'=>'success',
'msg'=>'successfully cart product updated.',
@@ -60,7 +60,7 @@ class BlockcartCheckRoomAvailabilityAjaxProcessModuleFrontController extends Mod
);
}
die(
Tools::jsonEncode(
json_encode(
array('status'=>'failed', 'msg'=>'error while deleting room from cart booking table.')
)
);

View File

@@ -48,7 +48,7 @@ class AdminBlockCategoriesController extends ModuleAdminController
}
public function ajaxProcessuploadThumbnailImages()
{
{
$category = new Category((int)Tools::getValue('id_category'));
if (isset($_FILES['thumbnail']))
@@ -74,7 +74,7 @@ class AdminBlockCategoriesController extends ModuleAdminController
{
$total_errors['name'] = sprintf(Tools::displayError('An error occurred while uploading the image :'));
$total_errors['error'] = sprintf(Tools::displayError('You cannot upload more files'));
die(Tools::jsonEncode(array('thumbnail' => array($total_errors))));
die(json_encode(array('thumbnail' => array($total_errors))));
}
foreach ($files as $key => &$file)
@@ -99,7 +99,7 @@ class AdminBlockCategoriesController extends ModuleAdminController
unset($file['save_path']);
if (isset($file['tmp_name']))
unset($file['tmp_name']);
unset($file['tmp_name']);
//Add image preview and delete url
$file['image'] = ImageManager::thumbnail(_PS_CAT_IMG_DIR_.(int)$category->id.'-'.$id.'_thumb.jpg',
@@ -113,7 +113,7 @@ class AdminBlockCategoriesController extends ModuleAdminController
else
Tools::clearSmartyCache();
die(Tools::jsonEncode(array('thumbnail' => $files)));
die(json_encode(array('thumbnail' => $files)));
}
}
}

View File

@@ -7,5 +7,5 @@ if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token'
die('Bad token');
$blockLayered = new BlockLayered();
$cursor = Tools::jsonDecode(Tools::getValue('cursor', '{}'), true);
$cursor = json_decode(Tools::getValue('cursor', '{}'), true);
echo $blockLayered->indexUrl($cursor, (int)Tools::getValue('truncate'));

View File

@@ -1621,7 +1621,7 @@ class BlockLayered extends Module
'template_name' => $template['name'],
'attribute_groups' => $attribute_groups,
'features' => $features,
'filters' => Tools::jsonEncode($filters),
'filters' => json_encode($filters),
'total_filters' => 6+count($attribute_groups)+count($features)
));
@@ -1862,7 +1862,7 @@ class BlockLayered extends Module
break;
case 'manufacturer':
$query_filters_where .= ' AND p.id_manufacturer IN ('.implode($selected_filters['manufacturer'], ',').')';
$query_filters_where .= ' AND p.id_manufacturer IN ('.implode(',', $selected_filters['manufacturer']).')';
break;
case 'condition':
@@ -2005,7 +2005,7 @@ class BlockLayered extends Module
$this->products = array();
else
{
$product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int)$this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE');
$product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int)$this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE');
$n = (int)Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'));
$nb_day_new_product = (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20);
@@ -3049,8 +3049,8 @@ class BlockLayered extends Module
$query_filters = '';
else
{
array_walk($filter_value, create_function('&$id_manufacturer', '$id_manufacturer = (int)$id_manufacturer;'));
$query_filters = ' AND p.id_manufacturer IN ('.implode($filter_value, ',').')';
array_walk($filter_value, function (&$id_manufacturer) {$id_manufacturer = (int)$id_manufacturer;});
$query_filters = ' AND p.id_manufacturer IN ('.implode(',', $filter_value).')';
}
if ($ignore_join)
return array('where' => $query_filters);
@@ -3177,7 +3177,7 @@ class BlockLayered extends Module
$vars = array_merge($vars, array('pagination_bottom' => $smarty->assign('paginationId', 'bottom')
->fetch(_PS_THEME_DIR_.'pagination.tpl')));
/* We are sending an array in jSon to the .js controller, it will update both the filters and the products zones */
return Tools::jsonEncode($vars);
return json_encode($vars);
}
public function getProducts($selected_filters, &$products, &$nb_products, &$p, &$n, &$pages_nb, &$start, &$stop, &$range)

View File

@@ -27,8 +27,9 @@
if (!defined('_PS_VERSION_'))
exit;
include_once(_PS_CLASS_DIR_.'../tools/pear/PEAR.php');
include_once(_PS_PEAR_XML_PARSER_PATH_.'Parser.php');
include_once _PS_CLASS_DIR_.'../tools/pear/PEAR.php';
require_once dirname(__FILE__).'/vendor/autoload.php';
class Blockrss extends Module
{

7
modules/blockrss/vendor/autoload.php vendored Normal file
View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit573edf418ff486f71fdaa7e03e5841ca::getLoader();

View File

@@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,10 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'PEAR_Exception' => $vendorDir . '/pear/pear_exception/PEAR/Exception.php',
);

Some files were not shown because too many files have changed in this diff Show More