This commit is contained in:
+5
-1
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
abstract class CacheCore
|
abstract class CacheCore
|
||||||
{
|
{
|
||||||
|
/** @var Cache */
|
||||||
protected static $_instance;
|
protected static $_instance;
|
||||||
protected $_keysCached;
|
protected $_keysCached;
|
||||||
protected $_tablesCached = array();
|
protected $_tablesCached = array();
|
||||||
@@ -43,6 +43,10 @@ abstract class CacheCore
|
|||||||
'guest',
|
'guest',
|
||||||
'pagenotfound',
|
'pagenotfound',
|
||||||
'page_viewed');
|
'page_viewed');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Cache
|
||||||
|
*/
|
||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
if(!isset(self::$_instance))
|
if(!isset(self::$_instance))
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class ConnectionCore extends ObjectModel
|
|||||||
FROM `'._DB_PREFIX_.'connections`
|
FROM `'._DB_PREFIX_.'connections`
|
||||||
WHERE `id_guest` = '.(int)($cookie->id_guest).'
|
WHERE `id_guest` = '.(int)($cookie->id_guest).'
|
||||||
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
AND DATE_ADD(`date_add`, INTERVAL 30 MINUTE) > \''.pSQL(date('Y-m-d H:i:00')).'\'
|
||||||
AND id_shop = '.Shop::sqlRestriction().'
|
'.Shop::sqlRestriction(true).'
|
||||||
ORDER BY `date_add` DESC';
|
ORDER BY `date_add` DESC';
|
||||||
$result = Db::getInstance()->getRow($sql);
|
$result = Db::getInstance()->getRow($sql);
|
||||||
if (!$result['id_guest'] AND (int)($cookie->id_guest))
|
if (!$result['id_guest'] AND (int)($cookie->id_guest))
|
||||||
|
|||||||
+14
-6
@@ -251,11 +251,19 @@ abstract class DbCore
|
|||||||
abstract public function getVersion();
|
abstract public function getVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias of Db::getInstance()->ExecuteS
|
* Protect string against SQL injections
|
||||||
*
|
*
|
||||||
* @acces string query The query to execute
|
* @param string $str
|
||||||
* @return array Array of line returned by MySQL
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
abstract public function escape($str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias of Db::getInstance()->ExecuteS
|
||||||
|
*
|
||||||
|
* @acces string query The query to execute
|
||||||
|
* @return array Array of line returned by MySQL
|
||||||
|
*/
|
||||||
static public function s($query, $use_cache = 1)
|
static public function s($query, $use_cache = 1)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->ExecuteS($query, true, $use_cache);
|
return Db::getInstance()->ExecuteS($query, true, $use_cache);
|
||||||
@@ -313,7 +321,7 @@ function pSQL($string, $htmlOK = false)
|
|||||||
if (!is_numeric($string))
|
if (!is_numeric($string))
|
||||||
{
|
{
|
||||||
$link = Db::getInstance()->getRessource();
|
$link = Db::getInstance()->getRessource();
|
||||||
$string = _PS_MYSQL_REAL_ESCAPE_STRING_ ? mysql_real_escape_string($string, $link) : addslashes($string);
|
$string = _PS_MYSQL_REAL_ESCAPE_STRING_ ? Db::getInstance()->escape($string, $link) : addslashes($string);
|
||||||
if (!$htmlOK)
|
if (!$htmlOK)
|
||||||
$string = strip_tags(nl2br2($string));
|
$string = strip_tags(nl2br2($string));
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-19
@@ -46,7 +46,8 @@ class MySQLCore extends Db
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* do not remove, useful for some modules */
|
/* do not remove, useful for some modules */
|
||||||
public function set_db($db_name) {
|
public function set_db($db_name)
|
||||||
|
{
|
||||||
return mysql_select_db($db_name, $this->_link);
|
return mysql_select_db($db_name, $this->_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,24 +87,9 @@ class MySQLCore extends Db
|
|||||||
|
|
||||||
public function getValue($query, $use_cache = 1)
|
public function getValue($query, $use_cache = 1)
|
||||||
{
|
{
|
||||||
$query .= ' LIMIT 1';
|
if (!$result = $this->getRow($query, $use_cache))
|
||||||
$this->_result = false;
|
return false;
|
||||||
$this->_lastQuery = $query;
|
return array_shift($result);
|
||||||
if ($use_cache AND _PS_CACHE_ENABLED_)
|
|
||||||
if ($result = Cache::getInstance()->get(md5($query)))
|
|
||||||
{
|
|
||||||
$this->_lastCached = true;
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
if ($this->_link AND $this->_result = mysql_query($query, $this->_link) AND is_array($tmpArray = mysql_fetch_assoc($this->_result)))
|
|
||||||
{
|
|
||||||
$this->_lastCached = false;
|
|
||||||
$result = array_shift($tmpArray);
|
|
||||||
if($use_cache AND _PS_CACHE_ENABLED_)
|
|
||||||
Cache::getInstance()->setQuery($query, $result);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Execute($query, $use_cache = 1)
|
public function Execute($query, $use_cache = 1)
|
||||||
@@ -268,6 +254,14 @@ class MySQLCore extends Db
|
|||||||
{
|
{
|
||||||
return mysql_get_server_info();
|
return mysql_get_server_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DbCore::escape()
|
||||||
|
*/
|
||||||
|
public function escape($str)
|
||||||
|
{
|
||||||
|
return mysql_real_escape_string($str, $this->_link);
|
||||||
|
}
|
||||||
|
|
||||||
static public function tryToConnect($server, $user, $pwd, $db)
|
static public function tryToConnect($server, $user, $pwd, $db)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user