// 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
+27 -27
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -27,13 +27,13 @@
class ToolsInstall
{
/**
* checkDB will call to the
*
* @param string $srv
* @param string $login
* @param string $password
* @param string $name
* @param string $posted
* 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)
@@ -47,17 +47,17 @@ class ToolsInstall
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{}');
}
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{}');
}
if($posted)
if ($posted)
{
// Check POST data...
$data_check = array(
@@ -77,7 +77,7 @@ class ToolsInstall
switch (Db::checkConnection(trim($srv), trim($login), trim($password), trim($name)))
{
case 0:
if (MySQL::tryUTF8(trim($srv), trim($login), trim($password)))
if (Db::checkEncoding(trim($srv), trim($login), trim($password)))
return true;
return 49;
break;
@@ -92,7 +92,7 @@ class ToolsInstall
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']);
@@ -104,21 +104,21 @@ class ToolsInstall
$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);
@@ -129,9 +129,9 @@ class ToolsInstall
{
$swift = new Swift(new Swift_Connection_NativeMail());
}
$message = new Swift_Message($subject, $content, $type);
if ($swift->send($message, $to, $from))
{
$result = true;
@@ -150,15 +150,15 @@ class ToolsInstall
{
$result = $e->getCode();
}
return $result;
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);
@@ -169,7 +169,7 @@ class ToolsInstall
$content = str_replace('{email}', $email, $content);
return $content;
}
public static function getLangString($idLang)
{
switch ($idLang)
@@ -192,19 +192,19 @@ class ToolsInstall
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'))