// Fix install with Db

This commit is contained in:
rMalie
2011-09-21 07:46:12 +00:00
parent be0176a514
commit 8c8eb83239
4 changed files with 32 additions and 32 deletions
+1 -1
View File
@@ -511,7 +511,7 @@ abstract class DbCore
*/ */
static public function checkEncoding($server, $user, $pwd) static public function checkEncoding($server, $user, $pwd)
{ {
return call_user_func_array(array(Db::getClass(), 'tryToConnect'), array($server, $user, $pwd)); return call_user_func_array(array(Db::getClass(), 'tryUTF8'), array($server, $user, $pwd));
} }
/** /**
+27 -27
View File
@@ -1,6 +1,6 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
@@ -27,13 +27,13 @@
class ToolsInstall class ToolsInstall
{ {
/** /**
* checkDB will call to the * checkDB will call to the
* *
* @param string $srv * @param string $srv
* @param string $login * @param string $login
* @param string $password * @param string $password
* @param string $name * @param string $name
* @param string $posted * @param string $posted
* @return void * @return void
*/ */
public static function checkDB ($srv, $login, $password, $name, $posted = true) public static function checkDB ($srv, $login, $password, $name, $posted = true)
@@ -47,17 +47,17 @@ class ToolsInstall
if (!class_exists('Db', false)) if (!class_exists('Db', false))
{ {
include_once(INSTALL_PATH.'/../classes/Db.php'); include_once(INSTALL_PATH.'/../classes/db/Db.php');
eval('abstract class Db extends DbCore{}'); eval('abstract class Db extends DbCore{}');
} }
if (!class_exists('MySQL', false)) if (!class_exists('MySQL', false))
{ {
include_once(INSTALL_PATH.'/../classes/MySQL.php'); include_once(INSTALL_PATH.'/../classes/db/MySQL.php');
eval('class MySQL extends MySQLCore{}'); eval('class MySQL extends MySQLCore{}');
} }
if($posted) if ($posted)
{ {
// Check POST data... // Check POST data...
$data_check = array( $data_check = array(
@@ -77,7 +77,7 @@ class ToolsInstall
switch (Db::checkConnection(trim($srv), trim($login), trim($password), trim($name))) switch (Db::checkConnection(trim($srv), trim($login), trim($password), trim($name)))
{ {
case 0: case 0:
if (MySQL::tryUTF8(trim($srv), trim($login), trim($password))) if (Db::checkEncoding(trim($srv), trim($login), trim($password)))
return true; return true;
return 49; return 49;
break; break;
@@ -92,7 +92,7 @@ class ToolsInstall
break; break;
} }
} }
public static function getHttpHost($http = false, $entities = false, $ignore_port = false) 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']); $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
@@ -104,21 +104,21 @@ class ToolsInstall
$host = 'http://'.$host; $host = 'http://'.$host;
return $host; return $host;
} }
public static function sendMail($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort = 25, $smtpEncryption) 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.php');
require_once(INSTALL_PATH.'/../tools/swift/Swift/Connection/SMTP.php'); require_once(INSTALL_PATH.'/../tools/swift/Swift/Connection/SMTP.php');
require_once(INSTALL_PATH.'/../tools/swift/Swift/Connection/NativeMail.php'); require_once(INSTALL_PATH.'/../tools/swift/Swift/Connection/NativeMail.php');
$swift = NULL; $swift = NULL;
$result = NULL; $result = NULL;
try try
{ {
if($smtpChecked) 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 = 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->setUsername($smtpLogin);
$smtp->setpassword($smtpPassword); $smtp->setpassword($smtpPassword);
@@ -129,9 +129,9 @@ class ToolsInstall
{ {
$swift = new Swift(new Swift_Connection_NativeMail()); $swift = new Swift(new Swift_Connection_NativeMail());
} }
$message = new Swift_Message($subject, $content, $type); $message = new Swift_Message($subject, $content, $type);
if ($swift->send($message, $to, $from)) if ($swift->send($message, $to, $from))
{ {
$result = true; $result = true;
@@ -150,15 +150,15 @@ class ToolsInstall
{ {
$result = $e->getCode(); $result = $e->getCode();
} }
return $result; return $result;
} }
public static function getNotificationMail($shopName, $shopUrl, $shopLogo, $firstname, $lastname, $password, $email) public static function getNotificationMail($shopName, $shopUrl, $shopLogo, $firstname, $lastname, $password, $email)
{ {
$iso_code = $_GET['isoCodeLocalLanguage']; $iso_code = $_GET['isoCodeLocalLanguage'];
$pathTpl = INSTALL_PATH.'/../mails/en/employee_password.html'; $pathTpl = INSTALL_PATH.'/../mails/en/employee_password.html';
$pathTplLocal = INSTALL_PATH.'/../mails/'.$iso_code.'/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 = (file_exists($pathTplLocal)) ? file_get_contents($pathTplLocal) : file_get_contents($pathTpl);
$content = str_replace('{shop_name}', $shopName, $content); $content = str_replace('{shop_name}', $shopName, $content);
$content = str_replace('{shop_url}', $shopUrl, $content); $content = str_replace('{shop_url}', $shopUrl, $content);
@@ -169,7 +169,7 @@ class ToolsInstall
$content = str_replace('{email}', $email, $content); $content = str_replace('{email}', $email, $content);
return $content; return $content;
} }
public static function getLangString($idLang) public static function getLangString($idLang)
{ {
switch ($idLang) switch ($idLang)
@@ -192,19 +192,19 @@ class ToolsInstall
return mb_strtoupper($str, 'utf-8'); return mb_strtoupper($str, 'utf-8');
return strtoupper($str); return strtoupper($str);
} }
static function ucfirst($str) static function ucfirst($str)
{ {
return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1); return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1);
} }
static function substr($str, $start, $length = false, $encoding = 'utf-8') static function substr($str, $start, $length = false, $encoding = 'utf-8')
{ {
if (function_exists('mb_substr')) if (function_exists('mb_substr'))
return mb_substr($str, $start, ($length === false ? self::strlen($str) : $length), $encoding); return mb_substr($str, $start, ($length === false ? self::strlen($str) : $length), $encoding);
return substr($str, $start, $length); return substr($str, $start, $length);
} }
static function strlen($str) static function strlen($str)
{ {
if (function_exists('mb_strlen')) if (function_exists('mb_strlen'))
+3 -3
View File
@@ -32,7 +32,7 @@ define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
require_once(INSTALL_PATH.'/classes/AddConfToFile.php'); require_once(INSTALL_PATH.'/classes/AddConfToFile.php');
require_once(INSTALL_PATH.'/../classes/Validate.php'); require_once(INSTALL_PATH.'/../classes/Validate.php');
require_once(INSTALL_PATH.'/../classes/Db.php'); require_once(INSTALL_PATH.'/../classes/db/Db.php');
require_once(INSTALL_PATH.'/../classes/Tools.php'); require_once(INSTALL_PATH.'/../classes/Tools.php');
require_once(INSTALL_PATH.'/../config/settings.inc.php'); require_once(INSTALL_PATH.'/../config/settings.inc.php');
@@ -89,7 +89,7 @@ if (!isset($_GET['infosCountry']) OR empty($_GET['infosCountry']))
$error['infosCountry'] = '0'; $error['infosCountry'] = '0';
else else
$error['infosCountry'] = ''; $error['infosCountry'] = '';
if (!isset($_GET['infosTimezone']) OR empty($_GET['infosTimezone'])) if (!isset($_GET['infosTimezone']) OR empty($_GET['infosTimezone']))
$error['infosTimezone'] = '0'; $error['infosTimezone'] = '0';
else else
@@ -268,7 +268,7 @@ if (isFormValid())
{ {
$sqlParams[] = 'DELETE c, cl FROM `'._DB_PREFIX_.'cms` AS c LEFT JOIN `'._DB_PREFIX_.'cms_lang` AS cl ON c.id_cms = cl.id_cms WHERE 1 AND c.`id_cms` IN (1, 5)'; $sqlParams[] = 'DELETE c, cl FROM `'._DB_PREFIX_.'cms` AS c LEFT JOIN `'._DB_PREFIX_.'cms_lang` AS cl ON c.id_cms = cl.id_cms WHERE 1 AND c.`id_cms` IN (1, 5)';
} }
$dbInstance = Db::getInstance(); $dbInstance = Db::getInstance();
foreach($sqlParams as $query) foreach($sqlParams as $query)
if(!$dbInstance->Execute($query)) if(!$dbInstance->Execute($query))
+1 -1
View File
@@ -38,7 +38,7 @@ if (file_exists(SETTINGS_FILE))
require_once(INSTALL_PATH.'/classes/AddConfToFile.php'); require_once(INSTALL_PATH.'/classes/AddConfToFile.php');
require_once(INSTALL_PATH.'/../classes/Validate.php'); require_once(INSTALL_PATH.'/../classes/Validate.php');
require_once(INSTALL_PATH.'/../classes/Db.php'); require_once(INSTALL_PATH.'/../classes/db/Db.php');
require_once(INSTALL_PATH.'/../classes/Tools.php'); require_once(INSTALL_PATH.'/../classes/Tools.php');
global $logger; global $logger;