]> projects.mako.cc - scuttle/commitdiff
Supporting PHP7.0 on "mysqli" DB driver.
authorTakuya Ono <takuya-o@users.sourceforge.net>
Mon, 15 Aug 2016 09:00:15 +0000 (18:00 +0900)
committerTakuya Ono <takuya-o@users.sourceforge.net>
Mon, 15 Aug 2016 14:30:56 +0000 (23:30 +0900)
* 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.

header.inc.php
includes/db/mysqli.php
services/servicefactory.php
services/userservice.php

index d3c6ed898927f26e7cc5d5e6d4e7f57c13a94daa..9c23c12ddfa6c80b51b65415df1ed4aadb10b1f7 100644 (file)
@@ -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
index fa643c241899854a3e13001eb2a71dbb7d83468c..267229f5b3b03dbcbb87889d2f2cd3a8bdf5548f 100644 (file)
@@ -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);
                }
 
index 5f7635a91ebcc1500b8cdf28261300308284338c..987d908727e8365abc6887fd3158c7364dfefa7c 100644 (file)
@@ -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];
     }
index 44374a076e09d8a8f053f30201046c27a4ae614b..dde67b5718dc2490b3be7a4de8adc20a1d682c96 100644 (file)
@@ -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') .

Benjamin Mako Hill || Want to submit a patch?