[*] Installer : thanks to the old installer/upgrader which is now removed
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12525 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AddConfToFile
|
||||
{
|
||||
public $fd;
|
||||
public $file;
|
||||
public $mode;
|
||||
public $error = false;
|
||||
|
||||
public function __construct($file, $mode = 'r+')
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->mode = $mode;
|
||||
$this->checkFile($file);
|
||||
if ($mode == 'w' AND !$this->error)
|
||||
if (!$res = @fwrite($this->fd, '<?php'."\n"))
|
||||
$this->error = 6;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (!$this->error)
|
||||
@fclose($this->fd);
|
||||
}
|
||||
|
||||
private function checkFile($file)
|
||||
{
|
||||
if (!$fd = @fopen($this->file, $this->mode))
|
||||
$this->error = 5;
|
||||
elseif (!is_writable($this->file))
|
||||
$this->error = 6;
|
||||
$this->fd = $fd;
|
||||
}
|
||||
|
||||
public function writeInFile($name, $data)
|
||||
{
|
||||
if (!$res = @fwrite($this->fd,
|
||||
'define(\''.$name.'\', \''.$this->checkString($data).'\');'."\n"))
|
||||
{
|
||||
$this->error = 6;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function writeEndTagPhp()
|
||||
{
|
||||
if (!$res = @fwrite($this->fd, '?>'."\n")) {
|
||||
$this->error = 6;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkString($string)
|
||||
{
|
||||
if (get_magic_quotes_gpc())
|
||||
$string = stripslashes($string);
|
||||
if (!is_numeric($string))
|
||||
{
|
||||
$string = addslashes($string);
|
||||
$string = strip_tags(nl2br($string));
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
@@ -1,667 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class search Prestashop version from current database structure
|
||||
*
|
||||
* @since 1.4.2.3
|
||||
* @todo (priority low) compare index keys updates ; compare types range ; add custom methods to search versions with no SQL updates
|
||||
*/
|
||||
class GetVersionFromDb
|
||||
{
|
||||
/**
|
||||
* @var array Because of some errors and differences between some upgrades files and some db.sql files, we need to ignore some fields.
|
||||
*/
|
||||
private $ignore = array(
|
||||
'blocklink' => array(
|
||||
'fields' => array('id_link', 'id_blocklink'),
|
||||
),
|
||||
'blocklink_lang' => array(
|
||||
'fields' => array('id_link', 'id_blocklink'),
|
||||
'keys' => array('primary'),
|
||||
),
|
||||
'cms_block' => array(
|
||||
'fields' => array('id_block_cms', 'id_cms_block', 'display_store'),
|
||||
),
|
||||
'cms_block_lang' => array(
|
||||
'fields' => array('id_block_cms', 'id_cms_block'),
|
||||
),
|
||||
'cms_block_page' => array(
|
||||
'fields' => array('id_block_cms_page', 'id_cms_block_page'),
|
||||
),
|
||||
'cms_lang' => array(
|
||||
'types' => array('content'),
|
||||
),
|
||||
'log_email' => array(
|
||||
'keys' => array('date_add', 'id_cart'),
|
||||
),
|
||||
'newsletter' => array(
|
||||
'fields' => array('http_referer'),
|
||||
),
|
||||
'order_detail' => array(
|
||||
'fields' => array('group_reduction', 'ecotax_tax_rate', 'id_currency', 'reduction_percent', 'reduction_amount'),
|
||||
),
|
||||
'webservice_account' => array(
|
||||
'fields' => array('is_module', 'module_name'),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string Path to install directory
|
||||
*/
|
||||
private $installPath;
|
||||
|
||||
/**
|
||||
* @var array Store schemas of all upgrades
|
||||
*/
|
||||
private $schemas = array();
|
||||
|
||||
/**
|
||||
* @var array Store db.sql schema
|
||||
*/
|
||||
private $generalSchema = null;
|
||||
|
||||
/**
|
||||
* @var array Store current database schema
|
||||
*/
|
||||
private $currentSchema = null;
|
||||
|
||||
/**
|
||||
* @var bool If set to false, will compare all data of each table to get full error log
|
||||
*/
|
||||
private $fastExecution = false;
|
||||
|
||||
/**
|
||||
* @var bool If true, fields type will be compared too
|
||||
*/
|
||||
private $compareTypes = true;
|
||||
|
||||
/**
|
||||
* @var int Store microtime of the script execution
|
||||
*/
|
||||
private $totalTime = 0;
|
||||
|
||||
/**
|
||||
* @var array Error log
|
||||
*/
|
||||
private $errors = array();
|
||||
|
||||
/**
|
||||
* @var array Prefix for current database
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* @var string Found versions
|
||||
*/
|
||||
private $versions = array();
|
||||
|
||||
/**
|
||||
* Constructor, launch the compare algorithm
|
||||
*
|
||||
* @param bool $compareTypes If true, will compare field types
|
||||
* @param bool $fastExecution If false, will loose some performance but log all errors
|
||||
*/
|
||||
public function __construct($compareTypes = true, $fastExecution = false)
|
||||
{
|
||||
// added for compatibility prestashop version < 1.3.7
|
||||
if(!defined('_PS_CACHE_ENABLED_'))
|
||||
define('_PS_CACHE_ENABLED_', '0');
|
||||
|
||||
$this->installPath = INSTALL_PATH . '/';
|
||||
$this->prefix = _DB_PREFIX_;
|
||||
$this->compareTypes = $compareTypes;
|
||||
$this->fastExecution = $fastExecution;
|
||||
|
||||
$start = microtime(true);
|
||||
$this->generateSchemasFromUpdates();
|
||||
$this->getDatabaseSchema();
|
||||
$this->versions = $this->searchCurrentVersion();
|
||||
$this->totalTime = microtime(true) - $start;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int Get total execution time of class
|
||||
*/
|
||||
public function getTotalTime()
|
||||
{
|
||||
return $this->totalTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Get list of differences between current database and all upgrades
|
||||
*/
|
||||
public function getErrors($version = null)
|
||||
{
|
||||
if (!is_null($version))
|
||||
{
|
||||
return isset($this->errors[$version]) ? $this->errors[$version] : array();
|
||||
}
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Get found versions
|
||||
*/
|
||||
public function getVersions()
|
||||
{
|
||||
return $this->versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add more informations in database schema property in order to fix some troubles with missing data between db.sql and upgrades
|
||||
*/
|
||||
private function completeDatabaseSchema()
|
||||
{
|
||||
// Add key "discount" in "discount_category" table, because the name is different between the 1.2.2 upgrade and db.sql
|
||||
if (isset($this->currentSchema['discount_category']['@keys']['id_discount']))
|
||||
$this->currentSchema['discount_category']['@keys']['discount'] = $this->currentSchema['discount_category']['@keys']['id_discount'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the schema of all updates
|
||||
*/
|
||||
private function generateSchemasFromUpdates()
|
||||
{
|
||||
// Get list of sorted upgrades
|
||||
$fd = opendir($this->installPath . 'sql/upgrade');
|
||||
while ($file = readdir($fd))
|
||||
{
|
||||
if (substr($file, -3, 3) == 'sql' && version_compare(substr($file, 0, -4), INSTALL_VERSION) <= 0)
|
||||
{
|
||||
$list[] = $file;
|
||||
}
|
||||
}
|
||||
closedir($fd);
|
||||
usort($list, 'version_compare');
|
||||
$list = array_reverse($list);
|
||||
|
||||
for ($i = 0, $total = count($list); $i < $total - 1; $i++)
|
||||
{
|
||||
$file = $list[$i];
|
||||
$next = $list[$i + 1];
|
||||
|
||||
$this->generateSchema(substr($file, 0, -4), substr($next, 0, -4));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the schema of the given version
|
||||
*
|
||||
* @param string $currentVersion Version name
|
||||
* @param string $nextVersion Next version
|
||||
*/
|
||||
private function generateSchema($currentVersion, $nextVersion)
|
||||
{
|
||||
static $storeTypes = array();
|
||||
|
||||
// Load db.sql once
|
||||
if (is_null($this->generalSchema))
|
||||
{
|
||||
$this->loadGeneralSchema();
|
||||
}
|
||||
|
||||
$this->schemas[] = array(
|
||||
'name' => $nextVersion,
|
||||
'struct' => array(),
|
||||
);
|
||||
|
||||
// Read queries in upgrade files, and reverse structure from db.sql
|
||||
if (!file_exists($this->installPath . 'sql/upgrade/' . $currentVersion . '.sql'))
|
||||
{
|
||||
throw new Exception('File sql/upgrade/' . $currentVersion . '.sql not found');
|
||||
}
|
||||
|
||||
$struct = (count($this->schemas) >= 2) ? $this->schemas[count($this->schemas) - 2]['struct'] : $this->generalSchema;
|
||||
$content = file_get_contents($this->installPath . 'sql/upgrade/' . $currentVersion . '.sql');
|
||||
$queries = array_reverse(preg_split("/;\s*[\r\n]+/", $content));
|
||||
foreach ($queries as $query)
|
||||
{
|
||||
$query = trim($query);
|
||||
|
||||
// ALTER TABLE -> add, delete or update fields
|
||||
if (preg_match('#^alter\s+table\s+`?prefix_([a-z0-9_]+)`?\s+#si', $query, $m))
|
||||
{
|
||||
$table = $m[1];
|
||||
|
||||
// Alter drop index
|
||||
preg_match_all('#\s*drop\s+(index|primary key)(\s+`?([a-z0-9_]+)`?)?#si', $query, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
$name = $m[3][$i];
|
||||
if (strtolower($m[1][$i]) == 'primary key')
|
||||
{
|
||||
$name = 'primary';
|
||||
}
|
||||
|
||||
$struct[$table]['@keys'][$name] = '?';
|
||||
$query = str_replace($m[0][$i], '', $query);
|
||||
}
|
||||
|
||||
// Alter add index
|
||||
preg_match_all('#\s*add\s+(index|primary key|key|unique key|unique)\s*\(?([a-z0-9_,`\s]+)\)?(\s+\(([a-z0-9_,` ]+)\))?\s*(,|;|$)#si', $query, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
$name = str_replace(array('`', ' '), array('', ''), $m[2][$i]);
|
||||
$tmpName = explode(',', $name);
|
||||
$name = $tmpName[0];
|
||||
|
||||
if (strtolower($m[1][$i] == 'primary key'))
|
||||
{
|
||||
$name = 'primary';
|
||||
}
|
||||
|
||||
if (isset($struct[$table]['@keys']) && !isset($struct[$table]['@keys'][$name]))
|
||||
{
|
||||
// If key name doesn't exist, we try to match with list of fields and type
|
||||
$type = strtolower($m[1][$i]);
|
||||
if ($type == 'primary key')
|
||||
{
|
||||
$type = 'primary';
|
||||
}
|
||||
else if ($type == 'key')
|
||||
{
|
||||
$type = 'index';
|
||||
}
|
||||
else if ($type == 'unique key')
|
||||
{
|
||||
$type = 'unique';
|
||||
}
|
||||
|
||||
$fields = ($m[4][$i]) ? $m[4][$i] : $m[2][$i];
|
||||
$fields = explode(',', preg_replace('#[\s`]#si', '', $fields));
|
||||
|
||||
foreach ($struct[$table]['@keys'] as $key => $data)
|
||||
{
|
||||
if ($data['type'] == $type && !array_diff($data['fields'], $fields))
|
||||
{
|
||||
// Found it !
|
||||
unset($struct[$table]['@keys'][$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($struct[$table]['@keys'][$name]);
|
||||
}
|
||||
$query = str_replace($m[0][$i], '', $query);
|
||||
}
|
||||
|
||||
// Alter add
|
||||
preg_match_all('#\s*add\s+`?([a-z0-9_]+)`?\s+(([a-z]+)(\([ 0-9,]+\))?(\s+unsigned)?)(\s+not)?(\s+null)?(\s+auto_increment)?(\s+primary)?#si', $query, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
unset($struct[$table][$m[1][$i]]);
|
||||
if (strtolower(trim($m[9][$i])) == 'primary')
|
||||
{
|
||||
unset($struct[$table]['@keys']['primary']);
|
||||
}
|
||||
}
|
||||
|
||||
// Alter drop
|
||||
preg_match_all('#\s*drop\s+`?([a-z0-9_]+)`?#si', $query, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
$struct[$table][$m[1][$i]] = '?';
|
||||
}
|
||||
|
||||
// Alter change
|
||||
preg_match_all('#\s*change\s+`([a-z0-9_]+)`\s+`?([a-z0-9_]+)`?\s+([a-z]+)(\s*\([ 0-9,]+\))?(\s+unsigned)?#si', $query, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
if ($m[1][$i] != $m[2][$i])
|
||||
{
|
||||
unset($struct[$table][$m[1][$i]]);
|
||||
}
|
||||
$struct[$table][$m[2][$i]] = '?';
|
||||
}
|
||||
}
|
||||
// CREATE TABLE -> delete this table from structure
|
||||
else if (preg_match('#^create\s+table\s+(if\s+not\s+exists\s+)?`?prefix_([a-z0-9_]+)`?#si', $query, $m) && !preg_match('#_tmp[0-9]?$#i', $m[2]))
|
||||
{
|
||||
unset($struct[$m[2]]);
|
||||
}
|
||||
// DROP TABLE -> add this table in structure
|
||||
else if (preg_match('#^drop\s*table\s+(if\s+exists\s+)?`?prefix_([a-z0-9_]+)`?#si', $query, $m) && !preg_match('#_tmp[0-9]?$#i', $m[2]))
|
||||
{
|
||||
$struct[$m[2]] = array();
|
||||
}
|
||||
}
|
||||
|
||||
$this->schemas[count($this->schemas) - 1]['struct'] = $struct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read db.sql file and load tables structure
|
||||
*/
|
||||
private function loadGeneralSchema()
|
||||
{
|
||||
$this->generalSchema = array();
|
||||
if (!file_exists($this->installPath . 'sql/db.sql'))
|
||||
{
|
||||
throw new Exception('File sql/db.sql not found');
|
||||
}
|
||||
|
||||
// Get create queries from db.sql file
|
||||
$content = file_get_contents($this->installPath . 'sql/db.sql');
|
||||
$queries = preg_split("/;\s*[\r\n]+/", $content);
|
||||
foreach ($queries as $query)
|
||||
{
|
||||
$query = trim($query);
|
||||
if (!preg_match('#^create table `?prefix_([a-z0-9_]+)`?\s#i', $query, $m))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$table = $m[1];
|
||||
$this->generalSchema[$table] = array();
|
||||
|
||||
// Get fields list
|
||||
preg_match_all('#(\(|,)\s*`?([a-z0-9_]+)`?\s+(([a-z]+)(\([ 0-9,]+\))?(\s+unsigned)?)\s*[^,]*#si', $query, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
if (in_array(strtolower($m[2][$i]), array('primary', 'key', 'unique', 'index')))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$this->generalSchema[$table][$m[2][$i]] = $this->parseType($m[4][$i]);
|
||||
}
|
||||
|
||||
// Get index
|
||||
$this->generalSchema[$table]['@keys'] = array();
|
||||
preg_match_all('#(primary\s+key|unique\s+key|key|index)\s+\(?`?([a-z0-9_,` ]+)`?\)?(\s+\(([a-z0-9_,` ]+)\))?\s*(,|\))#si', $query, $m);
|
||||
for ($i = 0, $total = count($m[0]); $i < $total; $i++)
|
||||
{
|
||||
$type = strtolower($m[1][$i]);
|
||||
if ($type == 'primary key')
|
||||
{
|
||||
$type = 'primary';
|
||||
}
|
||||
else if ($type == 'key')
|
||||
{
|
||||
$type = 'index';
|
||||
}
|
||||
else if ($type == 'unique key')
|
||||
{
|
||||
$type = 'unique';
|
||||
}
|
||||
|
||||
$name = str_replace(array('`', ' '), array('', ''), $m[2][$i]);
|
||||
$tmpName = explode(',', $name);
|
||||
$name = $tmpName[0];
|
||||
if ($type == 'primary')
|
||||
{
|
||||
$name = 'primary';
|
||||
}
|
||||
|
||||
$fields = ($m[4][$i]) ? $m[4][$i] : $m[2][$i];
|
||||
$fields = explode(',', preg_replace('#[\s`]#si', '', $fields));
|
||||
|
||||
$this->generalSchema[$table]['@keys'][$name] = array(
|
||||
'type' => $type,
|
||||
'fields' => $fields,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->schemas[] = array(
|
||||
'name' => INSTALL_VERSION,
|
||||
'struct' => $this->generalSchema,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the schema of current database
|
||||
*/
|
||||
private function getDatabaseSchema()
|
||||
{
|
||||
$struct = array();
|
||||
$sql = 'SHOW TABLES';
|
||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
||||
{
|
||||
$table = current($row);
|
||||
if (substr($table, 0, strlen($this->prefix)) != $this->prefix)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$virtualTable = substr($table, strlen($this->prefix));
|
||||
$struct[$virtualTable] = array();
|
||||
|
||||
// List fields
|
||||
$sql = 'SHOW FIELDS FROM ' . $table;
|
||||
foreach (Db::getInstance()->executeS($sql) as $rowField)
|
||||
{
|
||||
$struct[$virtualTable][$rowField['Field']] = $this->parseType($rowField['Type']);
|
||||
}
|
||||
|
||||
// List keys
|
||||
$struct[$virtualTable]['@keys'] = array();
|
||||
$sql = 'SHOW INDEX FROM ' . $table;
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
if($results)
|
||||
foreach ($results as $rowIndex)
|
||||
{
|
||||
$keyName = strtolower($rowIndex['Key_name']);
|
||||
$type = 'index';
|
||||
if ($keyName == 'primary')
|
||||
{
|
||||
$type = 'primary';
|
||||
}
|
||||
else if (!$rowIndex['Non_unique'])
|
||||
{
|
||||
$type = 'unique';
|
||||
}
|
||||
|
||||
if (!isset($struct[$virtualTable]['@keys'][$keyName]))
|
||||
{
|
||||
$struct[$virtualTable]['@keys'][$keyName] = array(
|
||||
'type' => $type,
|
||||
'fields' => array(),
|
||||
);
|
||||
}
|
||||
$struct[$virtualTable]['@keys'][$keyName]['fields'][] = $rowIndex['Column_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->currentSchema = $struct;
|
||||
$this->completeDatabaseSchema();
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch comparison and search current version
|
||||
*/
|
||||
private function searchCurrentVersion()
|
||||
{
|
||||
$this->errors = array();
|
||||
$version = null;
|
||||
$versions = array();
|
||||
$state = 0;
|
||||
|
||||
// Browse all schema, we will compare all data of listed schema to current database structure, evertytime something is different
|
||||
// we break and go to next schema
|
||||
foreach ($this->schemas as $schema)
|
||||
{
|
||||
$struct = $schema['struct'];
|
||||
$this->errors[$schema['name']] = array();
|
||||
$isThisVersion = true;
|
||||
|
||||
// Browse all table for schema
|
||||
foreach ($struct as $table => $fields)
|
||||
{
|
||||
// Is this table ignored ?
|
||||
if (isset($this->ignore[$table]) && !$this->ignore[$table])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if table exists
|
||||
if (!isset($this->currentSchema[$table]))
|
||||
{
|
||||
$this->errors[$schema['name']][] = "Table '$table' not found";
|
||||
$isThisVersion = false;
|
||||
|
||||
if ($this->fastExecution)
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Browse all fields for this table
|
||||
foreach ($fields as $field => $type)
|
||||
{
|
||||
if ($field == '@keys')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is this field ignored ?
|
||||
if (isset($this->ignore[$table], $this->ignore[$table]['fields']) && in_array($field, $this->ignore[$table]['fields']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if field exists
|
||||
if (!isset($this->currentSchema[$table][$field]))
|
||||
{
|
||||
$this->errors[$schema['name']][] = "Field '$field' in table '$table' not found";
|
||||
$isThisVersion = false;
|
||||
|
||||
if ($this->fastExecution)
|
||||
{
|
||||
break 2;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is this type ignored ?
|
||||
if (isset($this->ignore[$table], $this->ignore[$table]['types']) && in_array($field, $this->ignore[$table]['types']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Compare the field type, ignore comparaison if we don't know the field type (? char)
|
||||
if ($this->compareTypes && $type != '?' && $this->currentSchema[$table][$field] != $type)
|
||||
{
|
||||
$this->errors[$schema['name']][] = "The field '$field' in table '$table' has a different type ('$type' :: '{$this->currentSchema[$table][$field]}')";
|
||||
$isThisVersion = false;
|
||||
|
||||
if ($this->fastExecution)
|
||||
{
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compare index
|
||||
if (isset($fields['@keys']))
|
||||
{
|
||||
foreach ($fields['@keys'] as $name => $data)
|
||||
{
|
||||
if ($data == '?')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is this index ignored ?
|
||||
if (isset($this->ignore[$table], $this->ignore[$table]['keys']) && in_array($name, $this->ignore[$table]['keys']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Test if index exists
|
||||
if (!isset($this->currentSchema[$table]['@keys'][$name]))
|
||||
{
|
||||
$this->errors[$schema['name']][] = "Key '$name' in table '$table' not found";
|
||||
$isThisVersion = false;
|
||||
|
||||
if ($this->fastExecution)
|
||||
{
|
||||
break 2;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Compare index type
|
||||
if ($this->currentSchema[$table]['@keys'][$name]['type'] != $data['type'])
|
||||
{
|
||||
$this->errors[$schema['name']][] = "Key '$name' in table '$table' has different type ('{$this->currentSchema[$table]['@keys'][$name]['type']}', '{$data['type']}')";
|
||||
$isThisVersion = false;
|
||||
|
||||
if ($this->fastExecution)
|
||||
{
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Compare list of fields
|
||||
$diff = array_diff($this->currentSchema[$table]['@keys'][$name]['fields'], $data['fields']);
|
||||
if ($diff)
|
||||
{
|
||||
$this->errors[$schema['name']][] = "Key '$name' in table '$table' has different fields ('" . implode("', '", $diff) . "')";
|
||||
$isThisVersion = false;
|
||||
|
||||
if ($this->fastExecution)
|
||||
{
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($isThisVersion)
|
||||
{
|
||||
$versions[] = $schema['name'];
|
||||
$state = 1;
|
||||
}
|
||||
|
||||
if (!$isThisVersion && $state == 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ($versions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format correctly a field type name
|
||||
*
|
||||
* @param string $type Type name
|
||||
* @return Parsed type name
|
||||
*/
|
||||
private function parseType($type)
|
||||
{
|
||||
$type = strtolower(preg_replace('#^([a-z]+).*$#i', '\\1', $type));
|
||||
$type = str_replace('boolean', 'tinyint', $type);
|
||||
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
@@ -1,652 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7442 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class Language extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
|
||||
/** @var string 2-letter iso code */
|
||||
public $iso_code;
|
||||
|
||||
/** @var string 5-letter iso code */
|
||||
public $language_code;
|
||||
|
||||
/** @var bool true if this language is right to left language */
|
||||
public $is_rtl = false;
|
||||
|
||||
/** @var boolean Status */
|
||||
public $active = true;
|
||||
|
||||
protected $fieldsRequired = array('name', 'iso_code');
|
||||
protected $fieldsSize = array('name' => 32, 'iso_code' => 2, 'language_code' => 5);
|
||||
protected $fieldsValidate = array('name' => 'isGenericName', 'iso_code' => 'isLanguageIsoCode', 'language_code' => 'isLanguageCode', 'active' => 'isBool', 'is_rtl' => 'isBool');
|
||||
|
||||
protected $table = 'lang';
|
||||
protected $identifier = 'id_lang';
|
||||
|
||||
/** @var array Languages cache */
|
||||
protected static $_checkedLangs;
|
||||
protected static $_LANGUAGES;
|
||||
protected static $countActiveLanguages;
|
||||
|
||||
protected $webserviceParameters = array(
|
||||
'objectNodeName' => 'language',
|
||||
'objectsNodeName' => 'languages',
|
||||
);
|
||||
|
||||
public function __construct($id = NULL, $id_lang = NULL)
|
||||
{
|
||||
parent::__construct($id);
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
parent::validateFields();
|
||||
$fields['name'] = pSQL($this->name);
|
||||
$fields['iso_code'] = pSQL(strtolower($this->iso_code));
|
||||
$fields['language_code'] = pSQL(strtolower($this->language_code));
|
||||
$fields['is_rtl'] = (int)$this->is_rtl;
|
||||
if (empty($fields['language_code']))
|
||||
$fields['language_code'] = $fields['iso_code'];
|
||||
$fields['active'] = (int)$this->active;
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
{
|
||||
if (!parent::add($autodate))
|
||||
return false;
|
||||
|
||||
$translationsFiles = array(
|
||||
'fields' => '_FIELDS',
|
||||
'errors' => '_ERRORS',
|
||||
'admin' => '_LANGADM',
|
||||
'pdf' => '_LANGPDF',
|
||||
);
|
||||
if (!file_exists(_PS_TRANSLATIONS_DIR_.$this->iso_code))
|
||||
mkdir(_PS_TRANSLATIONS_DIR_.$this->iso_code);
|
||||
foreach ($translationsFiles as $file => $var)
|
||||
if (!file_exists(_PS_TRANSLATIONS_DIR_.$this->iso_code.'/'.$file.'.php'))
|
||||
file_put_contents(_PS_TRANSLATIONS_DIR_.$this->iso_code.'/'.$file.'.php', '<?php
|
||||
global $'.$var.';
|
||||
$'.$var.' = array();
|
||||
?>');
|
||||
|
||||
$resUpdateSQL = $this->loadUpdateSQL();
|
||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
return $resUpdateSQL;
|
||||
|
||||
return ($resUpdateSQL AND Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
||||
''
|
||||
));
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
{
|
||||
if (!parent::toggleStatus())
|
||||
return false;
|
||||
|
||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
return true;
|
||||
return (Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
||||
''
|
||||
));
|
||||
}
|
||||
|
||||
public function checkFiles()
|
||||
{
|
||||
return self::checkFilesWithIsoCode($this->iso_code);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This functions checks if every files exists for the language $iso_code.
|
||||
* Concerned files are those located in translations/$iso_code/
|
||||
* and translations/mails/$iso_code .
|
||||
*
|
||||
* @param mixed $iso_code
|
||||
* @returntrue if all files exists
|
||||
*/
|
||||
public static function checkFilesWithIsoCode($iso_code)
|
||||
{
|
||||
if (isset(self::$_checkedLangs[$iso_code]) AND self::$_checkedLangs[$iso_code])
|
||||
return true;
|
||||
foreach (array_keys(self::getFilesList($iso_code, _THEME_NAME_, false, false, false, true)) as $key)
|
||||
if (!file_exists($key))
|
||||
return false;
|
||||
self::$_checkedLangs[$iso_code] = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getFilesList($iso_from, $theme_from, $iso_to = false, $theme_to = false, $select = false, $check = false, $modules = false)
|
||||
{
|
||||
if (empty($iso_from))
|
||||
die(Tools::displayError());
|
||||
|
||||
$copy = ($iso_to AND $theme_to) ? true : false;
|
||||
|
||||
$lPath_from = _PS_TRANSLATIONS_DIR_.(string)$iso_from.'/';
|
||||
$tPath_from = _PS_ROOT_DIR_.'/themes/'.(string)$theme_from.'/';
|
||||
$mPath_from = _PS_MAIL_DIR_.(string)$iso_from.'/';
|
||||
|
||||
if ($copy)
|
||||
{
|
||||
$lPath_to = _PS_TRANSLATIONS_DIR_.(string)$iso_to.'/';
|
||||
$tPath_to = _PS_ROOT_DIR_.'/themes/'.(string)$theme_to.'/';
|
||||
$mPath_to = _PS_MAIL_DIR_.(string)$iso_to.'/';
|
||||
}
|
||||
|
||||
$lFiles = array('admin'.'.php', 'errors'.'.php', 'fields'.'.php', 'pdf'.'.php');
|
||||
$mFiles = array(
|
||||
'account.html', 'account.txt',
|
||||
'bankwire.html', 'bankwire.txt',
|
||||
'cheque.html', 'cheque.txt',
|
||||
'contact.html', 'contact.txt',
|
||||
'contact_form.html', 'contact_form.txt',
|
||||
'credit_slip.html', 'credit_slip.txt',
|
||||
'download_product.html', 'download_product.txt',
|
||||
'download-product.tpl',
|
||||
'employee_password.html', 'employee_password.txt',
|
||||
'forward_msg.html', 'forward_msg.txt',
|
||||
'guest_to_customer.html', 'guest_to_customer.txt',
|
||||
'in_transit.html', 'in_transit.txt',
|
||||
'newsletter.html', 'newsletter.txt',
|
||||
'order_canceled.html', 'order_canceled.txt',
|
||||
'order_conf.html', 'order_conf.txt',
|
||||
'order_customer_comment.html', 'order_customer_comment.txt',
|
||||
'order_merchant_comment.html', 'order_merchant_comment.txt',
|
||||
'order_return_state.html', 'order_return_state.txt',
|
||||
'outofstock.html', 'outofstock.txt',
|
||||
'password.html', 'password.txt',
|
||||
'password_query.html', 'password_query.txt',
|
||||
'payment.html', 'payment.txt',
|
||||
'payment_error.html', 'payment_error.txt',
|
||||
'preparation.html', 'preparation.txt',
|
||||
'refund.html', 'refund.txt',
|
||||
'reply_msg.html', 'reply_msg.txt',
|
||||
'shipped.html', 'shipped.txt',
|
||||
'test.html', 'test.txt',
|
||||
'voucher.html', 'voucher.txt',
|
||||
);
|
||||
|
||||
$number = -1;
|
||||
|
||||
$files = array();
|
||||
$files_tr = array();
|
||||
$files_theme = array();
|
||||
$files_mail = array();
|
||||
$files_modules = array();
|
||||
|
||||
|
||||
// When a copy is made from a theme in specific language
|
||||
// to an other theme for the same language,
|
||||
// it's avoid to copy Translations, Mails files
|
||||
// and modules files which are not override by theme.
|
||||
if (!$copy OR $iso_from != $iso_to)
|
||||
{
|
||||
// Translations files
|
||||
if (!$check OR ($check AND (string)$iso_from != 'en'))
|
||||
foreach ($lFiles as $file)
|
||||
$files_tr[$lPath_from.$file] = ($copy ? $lPath_to.$file : ++$number);
|
||||
if ($select == 'tr')
|
||||
return $files_tr;
|
||||
$files = array_merge($files, $files_tr);
|
||||
|
||||
// Mail files
|
||||
if (!$check OR ($check AND (string)$iso_from != 'en'))
|
||||
$files_mail[$mPath_from.'lang.php'] = ($copy ? $mPath_to.'lang.php' : ++$number);
|
||||
foreach ($mFiles as $file)
|
||||
$files_mail[$mPath_from.$file] = ($copy ? $mPath_to.$file : ++$number);
|
||||
if ($select == 'mail')
|
||||
return $files_mail;
|
||||
$files = array_merge($files, $files_mail);
|
||||
|
||||
// Modules
|
||||
if ($modules)
|
||||
{
|
||||
$modList = Module::getModulesDirOnDisk();
|
||||
foreach ($modList as $mod)
|
||||
{
|
||||
$modDir = _PS_MODULE_DIR_.$mod;
|
||||
// Lang file
|
||||
if (file_exists($modDir.'/'.(string)$iso_from.'.php'))
|
||||
$files_modules[$modDir.'/'.(string)$iso_from.'.php'] = ($copy ? $modDir.'/'.(string)$iso_to.'.php' : ++$number);
|
||||
// Mails files
|
||||
$modMailDirFrom = $modDir.'/mails/'.(string)$iso_from;
|
||||
$modMailDirTo = $modDir.'/mails/'.(string)$iso_to;
|
||||
if (file_exists($modMailDirFrom))
|
||||
{
|
||||
$dirFiles = scandir($modMailDirFrom);
|
||||
foreach ($dirFiles as $file)
|
||||
if (file_exists($modMailDirFrom.'/'.$file) AND $file != '.' AND $file != '..' AND $file != '.svn')
|
||||
$files_modules[$modMailDirFrom.'/'.$file] = ($copy ? $modMailDirTo.'/'.$file : ++$number);
|
||||
}
|
||||
}
|
||||
if ($select == 'modules')
|
||||
return $files_modules;
|
||||
$files = array_merge($files, $files_modules);
|
||||
}
|
||||
}
|
||||
else if ($select == 'mail' OR $select == 'tr')
|
||||
{
|
||||
return $files;
|
||||
}
|
||||
|
||||
// Theme files
|
||||
if (!$check OR ($check AND (string)$iso_from != 'en'))
|
||||
{
|
||||
$files_theme[$tPath_from.'lang/'.(string)$iso_from.'.php'] = ($copy ? $tPath_to.'lang/'.(string)$iso_to.'.php' : ++$number);
|
||||
$module_theme_files = (file_exists($tPath_from.'modules/') ? scandir($tPath_from.'modules/') : array());
|
||||
foreach ($module_theme_files as $module)
|
||||
if ($module !== '.' AND $module != '..' AND $module !== '.svn' AND file_exists($tPath_from.'modules/'.$module.'/'.(string)$iso_from.'.php'))
|
||||
$files_theme[$tPath_from.'modules/'.$module.'/'.(string)$iso_from.'.php'] = ($copy ? $tPath_to.'modules/'.$module.'/'.(string)$iso_to.'.php' : ++$number);
|
||||
}
|
||||
if ($select == 'theme')
|
||||
return $files_theme;
|
||||
$files = array_merge($files, $files_theme);
|
||||
|
||||
// Return
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* loadUpdateSQL will create default lang values when you create a new lang, based on default id lang
|
||||
*
|
||||
* @return boolean true if succeed
|
||||
*/
|
||||
public function loadUpdateSQL()
|
||||
{
|
||||
$tables = Db::getInstance()->executeS('SHOW TABLES LIKE \''._DB_PREFIX_.'%_lang\' ');
|
||||
$langTables = array();
|
||||
|
||||
foreach($tables as $table)
|
||||
foreach($table as $t)
|
||||
$langTables[] = $t;
|
||||
|
||||
Db::getInstance()->execute('SET @id_lang_default = (SELECT c.`value` FROM `'._DB_PREFIX_.'configuration` c WHERE c.`name` = \'PS_LANG_DEFAULT\' LIMIT 1)');
|
||||
$return = true;
|
||||
foreach($langTables as $name)
|
||||
{
|
||||
$fields = '';
|
||||
$columns = Db::getInstance()->executeS('SHOW COLUMNS FROM `'.$name.'`');
|
||||
foreach($columns as $column)
|
||||
$fields .= $column['Field'].', ';
|
||||
$fields = rtrim($fields, ', ');
|
||||
$identifier = 'id_'.str_replace('_lang', '', str_replace(_DB_PREFIX_, '', $name));
|
||||
|
||||
$sql = 'INSERT IGNORE INTO `'.$name.'` ('.$fields.') (SELECT ';
|
||||
foreach($columns as $column) {
|
||||
if ($identifier != $column['Field'] and $column['Field'] != 'id_lang')
|
||||
$sql .= '(SELECT `'.$column['Field'].'` FROM `'.$name.'` tl WHERE tl.`id_lang` = @id_lang_default AND tl.`'.$identifier.'` = `'.str_replace('_lang', '', $name).'`.`'.$identifier.'`), ';
|
||||
else
|
||||
$sql.= '`'.$column['Field'].'`, ';
|
||||
}
|
||||
$sql = rtrim($sql, ', ');
|
||||
$sql .= ' FROM `'._DB_PREFIX_.'lang` CROSS JOIN `'.str_replace('_lang', '', $name).'`) ;';
|
||||
$return &= Db::getInstance()->execute(pSQL($sql));
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function recurseDeleteDir($dir)
|
||||
{
|
||||
if (!is_dir($dir))
|
||||
return false;
|
||||
if ($handle = @opendir($dir))
|
||||
{
|
||||
while (false !== ($file = readdir($handle)))
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
if (is_dir($dir.'/'.$file))
|
||||
self::recurseDeleteDir($dir.'/'.$file);
|
||||
elseif (file_exists($dir.'/'.$file))
|
||||
@unlink($dir.'/'.$file);
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (empty($this->iso_code))
|
||||
$this->iso_code = self::getIsoById($this->id);
|
||||
|
||||
// Database translations deletion
|
||||
$result = Db::getInstance()->executeS('SHOW TABLES FROM `'._DB_NAME_.'`');
|
||||
foreach ($result AS $row)
|
||||
if (preg_match('/_lang/', $row['Tables_in_'._DB_NAME_]))
|
||||
if (!Db::getInstance()->execute('DELETE FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)($this->id)))
|
||||
return false;
|
||||
|
||||
// Delete tags
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'tag WHERE id_lang = '.(int)($this->id));
|
||||
|
||||
// Delete search words
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'search_word WHERE id_lang = '.(int)($this->id));
|
||||
|
||||
// Files deletion
|
||||
foreach (self::getFilesList($this->iso_code, _THEME_NAME_, false, false, false, true, true) as $key => $file)
|
||||
if (file_exists($key))
|
||||
unlink($key);
|
||||
$modList = scandir(_PS_MODULE_DIR_);
|
||||
foreach ($modList as $mod)
|
||||
{
|
||||
self::recurseDeleteDir(_PS_MODULE_DIR_.$mod.'/mails/'.$this->iso_code);
|
||||
$files = @scandir(_PS_MODULE_DIR_.$mod.'/mails/');
|
||||
if (count($files) <= 2)
|
||||
self::recurseDeleteDir(_PS_MODULE_DIR_.$mod.'/mails/');
|
||||
|
||||
if(file_exists(_PS_MODULE_DIR_.$mod.'/'.$this->iso_code.'.php'))
|
||||
{
|
||||
unlink(_PS_MODULE_DIR_.$mod.'/'.$this->iso_code.'.php');
|
||||
$files = @scandir(_PS_MODULE_DIR_.$mod);
|
||||
if (count($files) <= 2)
|
||||
self::recurseDeleteDir(_PS_MODULE_DIR_.$mod);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists(_PS_MAIL_DIR_.$this->iso_code))
|
||||
self::recurseDeleteDir(_PS_MAIL_DIR_.$this->iso_code);
|
||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$this->iso_code))
|
||||
self::recurseDeleteDir(_PS_TRANSLATIONS_DIR_.$this->iso_code);
|
||||
if (!parent::delete())
|
||||
return false;
|
||||
|
||||
// delete images
|
||||
$files_copy = array('/en.jpg', '/en-default-thickbox.jpg', '/en-default-home.jpg', '/en-default-large.jpg', '/en-default-medium.jpg', '/en-default-small.jpg', '/en-default-large_scene.jpg');
|
||||
$tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
||||
foreach($tos AS $to)
|
||||
foreach($files_copy AS $file)
|
||||
{
|
||||
$name = str_replace('/en', ''.$this->iso_code, $file);
|
||||
|
||||
if (file_exists($to.$name))
|
||||
unlink($to.$name);
|
||||
if (file_exists(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg'))
|
||||
unlink(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg');
|
||||
}
|
||||
|
||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
return true;
|
||||
|
||||
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function deleteSelection($selection)
|
||||
{
|
||||
if (!is_array($selection) OR !Validate::isTableOrIdentifier($this->identifier) OR !Validate::isTableOrIdentifier($this->table))
|
||||
die(Tools::displayError());
|
||||
$result = true;
|
||||
foreach ($selection AS $id)
|
||||
{
|
||||
$this->id = (int)($id);
|
||||
$result = $result AND $this->delete();
|
||||
}
|
||||
|
||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
return true;
|
||||
|
||||
Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
||||
''
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return available languages
|
||||
*
|
||||
* @param boolean $active Select only active languages
|
||||
* @return array Languages
|
||||
*/
|
||||
public static function getLanguages($active = true)
|
||||
{
|
||||
if(!self::$_LANGUAGES)
|
||||
self::loadLanguages();
|
||||
|
||||
$languages = array();
|
||||
foreach (self::$_LANGUAGES AS $language)
|
||||
{
|
||||
if ($active AND !$language['active'])
|
||||
continue;
|
||||
$languages[] = $language;
|
||||
}
|
||||
return $languages;
|
||||
}
|
||||
|
||||
public static function getLanguage($id_lang)
|
||||
{
|
||||
if (!array_key_exists((int)($id_lang), self::$_LANGUAGES))
|
||||
return false;
|
||||
return self::$_LANGUAGES[(int)($id_lang)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return iso code from id
|
||||
*
|
||||
* @param integer $id_lang Language ID
|
||||
* @return string Iso code
|
||||
*/
|
||||
public static function getIsoById($id_lang)
|
||||
{
|
||||
if (isset(self::$_LANGUAGES[(int)$id_lang]['iso_code']))
|
||||
return self::$_LANGUAGES[(int)$id_lang]['iso_code'];
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return id from iso code
|
||||
*
|
||||
* @param string $iso_code Iso code
|
||||
* @return integer Language ID
|
||||
*/
|
||||
public static function getIdByIso($iso_code)
|
||||
{
|
||||
if (!Validate::isLanguageIsoCode($iso_code))
|
||||
die(Tools::displayError('Fatal error : iso code is not correct : ').$iso_code);
|
||||
|
||||
return Db::getInstance()->getValue('SELECT `id_lang` FROM `'._DB_PREFIX_.'lang` WHERE `iso_code` = \''.pSQL(strtolower($iso_code)).'\'');
|
||||
}
|
||||
|
||||
public static function getLanguageCodeByIso($iso_code)
|
||||
{
|
||||
if (!Validate::isLanguageIsoCode($iso_code))
|
||||
die(Tools::displayError('Fatal error : iso code is not correct : ').$iso_code);
|
||||
|
||||
return Db::getInstance()->getValue('SELECT `language_code` FROM `'._DB_PREFIX_.'lang` WHERE `iso_code` = \''.pSQL(strtolower($iso_code)).'\'');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array (id_lang, iso_code)
|
||||
*
|
||||
* @param string $iso_code Iso code
|
||||
* @return array Language (id_lang, iso_code)
|
||||
*/
|
||||
public static function getIsoIds($active = true)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT `id_lang`, `iso_code` FROM `'._DB_PREFIX_.'lang` '.($active ? 'WHERE active = 1' : ''));
|
||||
}
|
||||
|
||||
public static function copyLanguageData($from, $to)
|
||||
{
|
||||
$result = Db::getInstance()->executeS('SHOW TABLES FROM `'._DB_NAME_.'`');
|
||||
foreach ($result AS $row)
|
||||
if (preg_match('/_lang/', $row['Tables_in_'._DB_NAME_]) AND $row['Tables_in_'._DB_NAME_] != _DB_PREFIX_.'lang')
|
||||
{
|
||||
$result2 = Db::getInstance()->executeS('SELECT * FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)($from));
|
||||
if (!sizeof($result2))
|
||||
continue;
|
||||
Db::getInstance()->execute('DELETE FROM `'.$row['Tables_in_'._DB_NAME_].'` WHERE `id_lang` = '.(int)($to));
|
||||
$query = 'INSERT INTO `'.$row['Tables_in_'._DB_NAME_].'` VALUES ';
|
||||
foreach ($result2 AS $row2)
|
||||
{
|
||||
$query .= '(';
|
||||
$row2['id_lang'] = $to;
|
||||
foreach ($row2 AS $field)
|
||||
$query .= '\''.pSQL($field, true).'\',';
|
||||
$query = rtrim($query, ',').'),';
|
||||
}
|
||||
$query = rtrim($query, ',');
|
||||
Db::getInstance()->execute($query);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all languages in memory for caching
|
||||
*/
|
||||
public static function loadLanguages()
|
||||
{
|
||||
self::$_LANGUAGES = array();
|
||||
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT `id_lang`, `name`, `iso_code`, `active`
|
||||
FROM `'._DB_PREFIX_.'lang`');
|
||||
|
||||
foreach ($result AS $row)
|
||||
self::$_LANGUAGES[(int)$row['id_lang']] = array('id_lang' => (int)$row['id_lang'], 'name' => $row['name'], 'iso_code' => $row['iso_code'], 'active' => (int)$row['active']);
|
||||
}
|
||||
|
||||
public function update($nullValues = false)
|
||||
{
|
||||
if (!parent::update($nullValues))
|
||||
return false;
|
||||
|
||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
||||
return true;
|
||||
|
||||
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
public static function checkAndAddLanguage($iso_code)
|
||||
{
|
||||
if (Language::getIdByIso($iso_code))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
if(@fsockopen('api.prestashop.com', 80))
|
||||
{
|
||||
$lang = new Language();
|
||||
$lang->iso_code = $iso_code;
|
||||
$lang->active = true;
|
||||
|
||||
if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code)))
|
||||
{
|
||||
if (isset($lang_pack->name)
|
||||
&& isset($lang_pack->version)
|
||||
&& isset($lang_pack->iso_code))
|
||||
$lang->name = $lang_pack->name;
|
||||
}
|
||||
if (!$lang->name OR !$lang->add())
|
||||
return false;
|
||||
$insert_id = (int)($lang->id);
|
||||
|
||||
if ($lang_pack)
|
||||
{
|
||||
$flag = Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg');
|
||||
if ($flag != NULL && !preg_match('/<body>/', $flag))
|
||||
{
|
||||
$file = fopen(dirname(__FILE__).'/../img/l/'.$insert_id.'.jpg', 'w');
|
||||
if ($file)
|
||||
{
|
||||
fwrite($file, $flag);
|
||||
fclose($file);
|
||||
}
|
||||
else
|
||||
self::_copyNoneFlag($insert_id);
|
||||
}
|
||||
else
|
||||
self::_copyNoneFlag($insert_id);
|
||||
}
|
||||
else
|
||||
self::_copyNoneFlag($insert_id);
|
||||
|
||||
$files_copy = array('/en.jpg', '/en-default-thickbox.jpg', '/en-default-home.jpg', '/en-default-large.jpg', '/en-default-medium.jpg', '/en-default-small.jpg', '/en-default-large_scene.jpg');
|
||||
$tos = array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_);
|
||||
foreach($tos AS $to)
|
||||
foreach($files_copy AS $file)
|
||||
{
|
||||
$name = str_replace('/en', '/'.$iso_code, $file);
|
||||
copy(dirname(__FILE__).'/../img/l'.$file, $to.$name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function _copyNoneFlag($id)
|
||||
{
|
||||
return copy(dirname(__FILE__).'/../img/l/none.jpg', dirname(__FILE__).'/../img/l/'.$id.'.jpg');
|
||||
}
|
||||
|
||||
private static $_cache_language_installation = null;
|
||||
public static function isInstalled($iso_code)
|
||||
{
|
||||
if (self::$_cache_language_installation === null)
|
||||
{
|
||||
self::$_cache_language_installation = array();
|
||||
$result = Db::getInstance()->executeS('SELECT `id_lang`, `iso_code` FROM `'._DB_PREFIX_.'lang`');
|
||||
foreach ($result as $row)
|
||||
self::$_cache_language_installation[$row['iso_code']] = $row['id_lang'];
|
||||
}
|
||||
return (isset(self::$_cache_language_installation[$iso_code]) ? self::$_cache_language_installation[$iso_code] : false);
|
||||
}
|
||||
|
||||
public static function countActiveLanguages()
|
||||
{
|
||||
if (!self::$countActiveLanguages)
|
||||
self::$countActiveLanguages = Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'lang` WHERE `active` = 1');
|
||||
return self::$countActiveLanguages;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class LanguageManager
|
||||
{
|
||||
private $url_xml;
|
||||
private $lang;
|
||||
private $xml_file;
|
||||
|
||||
function __construct ($url_xml)
|
||||
{
|
||||
$this->loadXML($url_xml);
|
||||
$this->setLanguage();
|
||||
$this->getIncludeTradFilename();
|
||||
}
|
||||
|
||||
private function loadXML($url_xml)
|
||||
{
|
||||
global $errors;
|
||||
if (!$this->xml_file = simplexml_load_file($url_xml))
|
||||
$errors = 'Error when loading XML language file : '.$url_xml;
|
||||
}
|
||||
|
||||
public function getIdSelectedLang()
|
||||
{
|
||||
return $this->lang['id'];
|
||||
}
|
||||
|
||||
public function getIsoCodeSelectedLang()
|
||||
{
|
||||
return $this->lang->idLangPS;
|
||||
}
|
||||
|
||||
public function countLangs()
|
||||
{
|
||||
return sizeof($this->xml_file);
|
||||
}
|
||||
|
||||
public function getAvailableLangs()
|
||||
{
|
||||
return $this->xml_file;
|
||||
}
|
||||
|
||||
public function getSelectedLang()
|
||||
{
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
/** get the http_accept_language isocode (if exists),
|
||||
* and use it to find the corresponding prestashop id_lang
|
||||
* otherwise, return 0.
|
||||
* @return int id_lang to use
|
||||
*/
|
||||
private function getIdByHAL(){
|
||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
{
|
||||
$FirstHAL = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
$iso = $FirstHAL[0];
|
||||
if ($iso != "en-us")
|
||||
foreach ($this->xml_file as $lang)
|
||||
foreach ($lang->isos->iso as $anIso)
|
||||
if ($anIso == $iso)
|
||||
return $lang['id'];
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** set lang property with param $_GET['language'] if present,
|
||||
* or by $_SERVER['HTTP_ACCEPT_LANGUAGE'] otherwise
|
||||
*/
|
||||
private function setLanguage()
|
||||
{
|
||||
if (isset($_GET['language']))
|
||||
$id_lang = (int)($_GET['language'])>0 ? $_GET['language'] : 0;
|
||||
if (!isset($id_lang))
|
||||
$id_lang = ($this->getIdByHAL());
|
||||
$this->lang = $this->xml_file->lang[(int)($id_lang)];
|
||||
}
|
||||
|
||||
public function getIncludeTradFilename()
|
||||
{
|
||||
return ($this->lang == NULL) ? false : dirname(__FILE__).$this->lang['trad_file'];
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,208 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
class ToolsInstall
|
||||
{
|
||||
/**
|
||||
* checkDB will call to the
|
||||
*
|
||||
* @param string $srv
|
||||
* @param string $login
|
||||
* @param string $password
|
||||
* @param string $name
|
||||
* @param string $posted
|
||||
* @return void
|
||||
*/
|
||||
public static function checkDB ($srv, $login, $password, $name, $posted = true)
|
||||
{
|
||||
// Don't include theses files if classes are already defined
|
||||
if (!class_exists('Validate', false))
|
||||
{
|
||||
include_once(INSTALL_PATH.'/../classes/Validate.php');
|
||||
eval('class Validate extends ValidateCore{}');
|
||||
}
|
||||
|
||||
if (!class_exists('Db', false))
|
||||
{
|
||||
include_once(INSTALL_PATH.'/../classes/db/Db.php');
|
||||
eval('abstract class Db extends DbCore{}');
|
||||
}
|
||||
|
||||
if (!class_exists('MySQL', false))
|
||||
{
|
||||
include_once(INSTALL_PATH.'/../classes/db/MySQL.php');
|
||||
eval('class MySQL extends MySQLCore{}');
|
||||
}
|
||||
|
||||
if ($posted)
|
||||
{
|
||||
// Check POST data...
|
||||
$data_check = array(
|
||||
!isset($_GET['server']) OR empty($_GET['server']) OR !Validate::isUrl($_GET['server']),
|
||||
!isset($_GET['engine']) OR empty($_GET['engine']) OR !Validate::isMySQLEngine($_GET['engine']),
|
||||
!isset($_GET['name']) OR empty($_GET['name']) OR !Validate::isUnixName($_GET['name']),
|
||||
!isset($_GET['login']) OR empty($_GET['login']) OR !Validate::isUnixName($_GET['login']),
|
||||
!isset($_GET['password']),
|
||||
(!isset($_GET['tablePrefix']) OR !Validate::isTablePrefix($_GET['tablePrefix'])) && !empty($_GET['tablePrefix']),
|
||||
);
|
||||
|
||||
foreach ($data_check AS $data)
|
||||
if ($data)
|
||||
return 8;
|
||||
}
|
||||
|
||||
switch (Db::checkConnection(trim($srv), trim($login), trim($password), trim($name)))
|
||||
{
|
||||
case 0:
|
||||
if (Db::checkEncoding(trim($srv), trim($login), trim($password)))
|
||||
return true;
|
||||
return 49;
|
||||
break;
|
||||
case 1:
|
||||
return 25;
|
||||
break;
|
||||
case 2:
|
||||
return 24;
|
||||
break;
|
||||
case 3:
|
||||
return 50;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getHttpHost($http = false, $entities = false, $ignore_port = false)
|
||||
{
|
||||
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
|
||||
if ($ignore_port && $pos = strpos($host, ':'))
|
||||
$host = substr($host, 0, $pos);
|
||||
if ($entities)
|
||||
$host = htmlspecialchars($host, ENT_COMPAT, 'UTF-8');
|
||||
if ($http)
|
||||
$host = 'http://'.$host;
|
||||
return $host;
|
||||
}
|
||||
|
||||
public static function sendMail($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort = 25, $smtpEncryption)
|
||||
{
|
||||
require_once(INSTALL_PATH.'/../tools/swift/Swift.php');
|
||||
require_once(INSTALL_PATH.'/../tools/swift/Swift/Connection/SMTP.php');
|
||||
require_once(INSTALL_PATH.'/../tools/swift/Swift/Connection/NativeMail.php');
|
||||
|
||||
$swift = NULL;
|
||||
$result = NULL;
|
||||
try
|
||||
{
|
||||
if($smtpChecked)
|
||||
{
|
||||
|
||||
$smtp = new Swift_Connection_SMTP($smtpServer, $smtpPort, ($smtpEncryption == "off") ? Swift_Connection_SMTP::ENC_OFF : (($smtpEncryption == "tls") ? Swift_Connection_SMTP::ENC_TLS : Swift_Connection_SMTP::ENC_SSL));
|
||||
$smtp->setUsername($smtpLogin);
|
||||
$smtp->setpassword($smtpPassword);
|
||||
$smtp->setTimeout(5);
|
||||
$swift = new Swift($smtp);
|
||||
}
|
||||
else
|
||||
$swift = new Swift(new Swift_Connection_NativeMail());
|
||||
|
||||
$message = new Swift_Message($subject, $content, $type);
|
||||
|
||||
if ($swift->send($message, $to, $from))
|
||||
$result = true;
|
||||
else
|
||||
$result = 999;
|
||||
|
||||
$swift->disconnect();
|
||||
}
|
||||
catch (Swift_Connection_Exception $e)
|
||||
{
|
||||
$result = $e->getCode();
|
||||
}
|
||||
catch (Swift_Message_MimeException $e)
|
||||
{
|
||||
$result = $e->getCode();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getNotificationMail($shopName, $shopUrl, $shopLogo, $firstname, $lastname, $password, $email)
|
||||
{
|
||||
$iso_code = $_GET['isoCodeLocalLanguage'];
|
||||
$pathTpl = INSTALL_PATH.'/../mails/en/employee_password.html';
|
||||
$pathTplLocal = INSTALL_PATH.'/../mails/'.$iso_code.'/employee_password.html';
|
||||
|
||||
$content = (file_exists($pathTplLocal)) ? file_get_contents($pathTplLocal) : file_get_contents($pathTpl);
|
||||
$content = str_replace('{shop_name}', $shopName, $content);
|
||||
$content = str_replace('{shop_url}', $shopUrl, $content);
|
||||
$content = str_replace('{shop_logo}', $shopLogo, $content);
|
||||
$content = str_replace('{firstname}', $firstname, $content);
|
||||
$content = str_replace('{lastname}', $lastname, $content);
|
||||
$content = str_replace('{passwd}', $password, $content);
|
||||
$content = str_replace('{email}', $email, $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
public static function getLangString($idLang)
|
||||
{
|
||||
switch ($idLang)
|
||||
{
|
||||
case 'en' : return 'English (English)';
|
||||
case 'fr' : return 'Français (French)';
|
||||
}
|
||||
}
|
||||
|
||||
static function strtolower($str)
|
||||
{
|
||||
if (function_exists('mb_strtolower'))
|
||||
return mb_strtolower($str, 'utf-8');
|
||||
return strtolower($str);
|
||||
}
|
||||
|
||||
static function strtoupper($str)
|
||||
{
|
||||
if (function_exists('mb_strtoupper'))
|
||||
return mb_strtoupper($str, 'utf-8');
|
||||
return strtoupper($str);
|
||||
}
|
||||
|
||||
static function ucfirst($str)
|
||||
{
|
||||
return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1);
|
||||
}
|
||||
|
||||
static function substr($str, $start, $length = false, $encoding = 'utf-8')
|
||||
{
|
||||
if (function_exists('mb_substr'))
|
||||
return mb_substr($str, $start, ($length === false ? self::strlen($str) : $length), $encoding);
|
||||
return substr($str, $start, $length);
|
||||
}
|
||||
|
||||
static function strlen($str)
|
||||
{
|
||||
if (function_exists('mb_strlen'))
|
||||
return mb_strlen($str, 'utf-8');
|
||||
return strlen($str);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 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-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user