From: Takuya Ono Date: Mon, 15 Aug 2016 09:00:15 +0000 (+0900) Subject: Supporting PHP7.0 on "mysqli" DB driver. X-Git-Url: https://projects.mako.cc/source/scuttle/commitdiff_plain/6b82542171500ea7134f7a4095b79cb781351465?ds=sidebyside Supporting PHP7.0 on "mysqli" DB driver. * Only supported only "mysqli" DB driver. The driver don't support $dbport in config.inc.php. It needs to keep it a null string as ''. * Including the UTF-8 patch. * Ignoring E_USER_WARNING. --- diff --git a/header.inc.php b/header.inc.php index d3c6ed8..9c23c12 100644 --- a/header.inc.php +++ b/header.inc.php @@ -37,4 +37,6 @@ else { ini_set('display_errors', '0'); ini_set('mysql.trace_mode', '0'); error_reporting(E_ALL); + //PHP5.4 PHP Notice: Undefined variable: PHP7 STOP deprecated and Warning + error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_WARNING); } \ No newline at end of file diff --git a/includes/db/mysqli.php b/includes/db/mysqli.php index fa643c2..267229f 100644 --- a/includes/db/mysqli.php +++ b/includes/db/mysqli.php @@ -46,6 +46,8 @@ class sql_db { if (@mysqli_select_db($this->db_connect_id, $this->dbname)) { + //Set utf-8 + mysqli_query($this->db_connect_id, 'SET CHARACTER SET utf8'); return $this->db_connect_id; } } @@ -380,10 +382,10 @@ class sql_db } function sql_escape($msg) { - if (function_exists('mysql_real_escape_string')) { - return @mysql_real_escape_string($msg, $this->db_connect_id); + if (function_exists('mysqli_real_escape_string')) { + return @mysqli_real_escape_string($this->db_connect_id, $msg); } else { - return mysql_escape_string($msg); + return mysqli_escape_string($this->db_connect_id, $msg); } } @@ -400,7 +402,7 @@ class sql_db { $this->sql_transaction('rollback'); } - + trigger_error($message, E_USER_ERROR); } diff --git a/services/servicefactory.php b/services/servicefactory.php index 5f7635a..987d908 100644 --- a/services/servicefactory.php +++ b/services/servicefactory.php @@ -25,7 +25,7 @@ class ServiceFactory { } require_once $servicedir . strtolower($name) .'.php'; } - $instances[$name] = call_user_func(array($name, 'getInstance'), $db); + $instances[$name] = call_user_func_array(array($name, 'getInstance'), array(&$db)); } return $instances[$name]; } diff --git a/services/userservice.php b/services/userservice.php index 44374a0..dde67b5 100644 --- a/services/userservice.php +++ b/services/userservice.php @@ -41,7 +41,7 @@ class UserService { if(!empty($host)) { @exec("nslookup -type=$type $host", $output); while(list($k, $line) = each($output)) { - if(eregi("^$host", $line)) { + if(preg_match("/^$host/i", $line)) { //eregi("^$host", $line) return true; } } @@ -132,7 +132,7 @@ class UserService { if (isset($_SESSION[$this->getSessionKey()])) { return $_SESSION[$this->getSessionKey()]; } else if (isset($_COOKIE[$this->getCookieKey()])) { - $cook = split(':', $_COOKIE[$this->getCookieKey()]); + $cook = explode(':', $_COOKIE[$this->getCookieKey()]); //split(':', $_COOKIE[$this->getCookieKey()]); //cookie looks like this: 'id:md5(username+password)' $query = 'SELECT * FROM '. $this->getTableName() . ' WHERE MD5(CONCAT('.$this->getFieldName('username') .