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: 1.4 $
|
||||
* @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,215 +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: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class ConfigurationTest
|
||||
{
|
||||
static function check($tests)
|
||||
{
|
||||
$res = array();
|
||||
foreach ($tests AS $key => $test)
|
||||
$res[$key] = self::run($key, $test);
|
||||
return $res;
|
||||
}
|
||||
|
||||
static function run($ptr, $arg = 0)
|
||||
{
|
||||
if (call_user_func(array('ConfigurationTest', 'test_'.$ptr), $arg))
|
||||
return ('ok');
|
||||
return ('fail');
|
||||
}
|
||||
|
||||
// Misc functions
|
||||
static function test_phpversion()
|
||||
{
|
||||
return version_compare(substr(phpversion(), 0, 3), '5.0', '>=');
|
||||
}
|
||||
|
||||
static function test_mysql_support()
|
||||
{
|
||||
return function_exists('mysql_connect');
|
||||
}
|
||||
|
||||
static function test_upload()
|
||||
{
|
||||
return ini_get('file_uploads');
|
||||
}
|
||||
|
||||
static function test_fopen()
|
||||
{
|
||||
return ini_get('allow_url_fopen');
|
||||
}
|
||||
|
||||
static function test_system($funcs)
|
||||
{
|
||||
foreach ($funcs AS $func)
|
||||
if (!function_exists($func))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static function test_gd()
|
||||
{
|
||||
return function_exists('imagecreatetruecolor');
|
||||
}
|
||||
|
||||
static function test_register_globals()
|
||||
{
|
||||
return !ini_get('register_globals');
|
||||
}
|
||||
|
||||
static function test_gz()
|
||||
{
|
||||
if (function_exists('gzencode'))
|
||||
return !(@gzencode('dd') === false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// is_writable dirs
|
||||
static function test_dir($dir, $recursive = false)
|
||||
{
|
||||
if (!file_exists($dir) OR !$dh = opendir($dir))
|
||||
return false;
|
||||
$dummy = rtrim($dir, '/').'/'.uniqid();
|
||||
if (@file_put_contents($dummy, 'test'))
|
||||
{
|
||||
@unlink($dummy);
|
||||
if (!$recursive)
|
||||
return true;
|
||||
}
|
||||
elseif (!is_writable($dir))
|
||||
return false;
|
||||
if ($recursive)
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
if (@filetype($dir.$file) == 'dir' AND $file != '.' AND $file != '..')
|
||||
if (!self::test_dir($dir.$file, true))
|
||||
return false;
|
||||
}
|
||||
closedir($dh);
|
||||
return true;
|
||||
}
|
||||
|
||||
// is_writable files
|
||||
static function test_file($file)
|
||||
{
|
||||
return (file_exists($file) AND is_writable($file));
|
||||
}
|
||||
|
||||
static function test_config_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_sitemap($dir)
|
||||
{
|
||||
return self::test_file($dir);
|
||||
}
|
||||
|
||||
static function test_root_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_admin_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_img_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir, true);
|
||||
}
|
||||
|
||||
static function test_module_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir, true);
|
||||
}
|
||||
|
||||
static function test_tools_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_cache_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_tools_v2_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_cache_v2_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_download_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_mails_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir, true);
|
||||
}
|
||||
|
||||
static function test_translations_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir, true);
|
||||
}
|
||||
|
||||
static function test_theme_lang_dir($dir)
|
||||
{
|
||||
if (!file_exists($dir))
|
||||
return true;
|
||||
return self::test_dir($dir, true);
|
||||
}
|
||||
|
||||
static function test_theme_cache_dir($dir)
|
||||
{
|
||||
if (!file_exists($dir))
|
||||
return true;
|
||||
return self::test_dir($dir, true);
|
||||
}
|
||||
|
||||
static function test_customizable_products_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_virtual_products_dir($dir)
|
||||
{
|
||||
return self::test_dir($dir);
|
||||
}
|
||||
|
||||
static function test_mcrypt()
|
||||
{
|
||||
return function_exists('mcrypt_encrypt');
|
||||
}
|
||||
}
|
||||
@@ -1,105 +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: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
include_once("../classes/Validate.php");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
private function setLanguage()
|
||||
{
|
||||
if( isset($_GET['language']) AND Validate::isInt($_GET['language']))
|
||||
$id_lang = (int)($_GET['language']);
|
||||
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'];
|
||||
}
|
||||
}
|
||||
@@ -1,189 +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: 1.4 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
class ToolsInstall
|
||||
{
|
||||
public static function checkDB ($srv, $login, $password, $name, $posted = true, $engine = false)
|
||||
{
|
||||
include_once(INSTALL_PATH.'/../classes/Validate.php');
|
||||
include_once(INSTALL_PATH.'/../classes/Db.php');
|
||||
include_once(INSTALL_PATH.'/../classes/MySQL.php');
|
||||
|
||||
if($posted)
|
||||
{
|
||||
// Check POST data...
|
||||
$data_check = array(
|
||||
!isset($_GET['server']) OR empty($_GET['server']),
|
||||
!Validate::isMailName($_GET['server']),
|
||||
!isset($_GET['type']) OR empty($_GET['type']),
|
||||
!Validate::isMailName($_GET['type']),
|
||||
!isset($_GET['name']) OR empty($_GET['name']),
|
||||
!Validate::isMailName($_GET['name']),
|
||||
!isset($_GET['login']) OR empty($_GET['login']),
|
||||
!Validate::isMailName($_GET['login']),
|
||||
!isset($_GET['password'])
|
||||
);
|
||||
foreach ($data_check AS $data)
|
||||
if ($data)
|
||||
return 8;
|
||||
}
|
||||
|
||||
switch(MySQL::tryToConnect(trim($srv), trim($login), trim($password), trim($name), trim($engine)))
|
||||
{
|
||||
case 0:
|
||||
if (MySQL::tryUTF8(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)
|
||||
{
|
||||
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
|
||||
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)
|
||||
{
|
||||
include(INSTALL_PATH.'/../tools/swift/Swift.php');
|
||||
include(INSTALL_PATH.'/../tools/swift/Swift/Connection/SMTP.php');
|
||||
include(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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user