A new user interface for you! Read more...

File centreon-web-php7.patch of Package centreon-web

diff -Pdpru centreon-web-2.8.4.orig/GPL_LIB/Smarty/libs/Smarty_Compiler.class.php centreon-web-2.8.24/GPL_LIB/Smarty/libs/Smarty_Compiler.class.php
--- centreon-web-2.8.4.orig/GPL_LIB/Smarty/libs/Smarty_Compiler.class.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/GPL_LIB/Smarty/libs/Smarty_Compiler.class.php	2018-06-29 11:19:28.711227290 +0200
@@ -262,12 +262,12 @@ class Smarty_Compiler extends Smarty {
         reset($this->_folded_blocks);
 
         /* replace special blocks by "{php}" */
-        $source_content = preg_replace($search.'e', "'"
-                                       . $this->_quote_replace($this->left_delimiter) . 'php'
-                                       . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
-                                       . $this->_quote_replace($this->right_delimiter)
-                                       . "'"
-                                       , $source_content);
+        $repl_func = function ($matches) {
+                     return $this->_quote_replace($this->left_delimiter) . 'php'
+                     . str_repeat("\n", substr_count($matches[1], "\n"))
+                     . $this->_quote_replace($this->right_delimiter);
+        };
+        $source_content = preg_replace_callback($search, $repl_func, $source_content);
 
         /* Gather all template tags. */
         preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match);
diff -Pdpru centreon-web-2.8.4.orig/www/api/class/centreon_keepalive.class.php centreon-web-2.8.24/www/api/class/centreon_keepalive.class.php
--- centreon-web-2.8.4.orig/www/api/class/centreon_keepalive.class.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/api/class/centreon_keepalive.class.php	2018-06-29 11:03:41.244331298 +0200
@@ -68,7 +68,7 @@ class CentreonKeepalive extends Centreon
      * @param boolean $isInternal If the api is call in internal
      * @return boolean If the user has access to the action
      */
-    public function authorize($action, $user, $isInternal)
+    public function authorize($action, $user, $isInternal = false)
     {
         return true;
     }
diff -Pdpru centreon-web-2.8.4.orig/www/class/centreonAuth.SSO.class.php centreon-web-2.8.24/www/class/centreonAuth.SSO.class.php
--- centreon-web-2.8.4.orig/www/class/centreonAuth.SSO.class.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/class/centreonAuth.SSO.class.php	2018-06-29 11:02:41.220654472 +0200
@@ -108,7 +108,7 @@ class CentreonAuthSSO extends CentreonAu
         }
     }
 
-    protected function checkPassword($password, $token, $autoimport = false)
+    protected function checkPassword($password, $token = '', $autoimport = false)
     {
         if ($this->sso_mandatory == 1) {
            # Mode LDAP autoimport. Need to call it
diff -Pdpru centreon-web-2.8.4.orig/www/class/centreonDB.class.php centreon-web-2.8.24/www/class/centreonDB.class.php
--- centreon-web-2.8.4.orig/www/class/centreonDB.class.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/class/centreonDB.class.php	2018-06-29 11:36:55.293582668 +0200
@@ -35,11 +35,19 @@
 include_once(realpath(dirname(__FILE__) . "/../../config/centreon.config.php"));
 require_once("DB.php");
 
+function mysql_real_escape_string($str)
+{
+    $search = array("\\", "\0", "\n", "\r", "\b", "\t", "\x1a", "'", '"' );
+    $replace = array("\\\\", "\\0", "\\n", "\\r", "\\b", "\\t", "\\Z", "\\'", '\\"');
+    $escapedStr = str_replace($search, $replace, $str);
+    return $escapedStr;
+}
+
 class CentreonDB
 {
 
     private static $instance = array();
-    protected $db_type = "mysql";
+    protected $db_type = "mysqli";
     protected $db_port = "3306";
     protected $retry;
     protected $db;
diff -Pdpru centreon-web-2.8.4.orig/www/class/centreon-knowledge/procedures_DB_Connector.class.php centreon-web-2.8.24/www/class/centreon-knowledge/procedures_DB_Connector.class.php
--- centreon-web-2.8.4.orig/www/class/centreon-knowledge/procedures_DB_Connector.class.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/class/centreon-knowledge/procedures_DB_Connector.class.php	2018-06-29 10:46:22.701916267 +0200
@@ -34,7 +34,7 @@
  */
 
 class procedures_DB_Connector {
-	private $db_type = "mysql";
+	private $db_type = "mysqli";
 	private $retry;
 	private $privatePearDB;
 	private $dsn;
diff -Pdpru centreon-web-2.8.4.orig/www/include/configuration/configCentreonBroker/wizard/save.php centreon-web-2.8.24/www/include/configuration/configCentreonBroker/wizard/save.php
--- centreon-web-2.8.4.orig/www/include/configuration/configCentreonBroker/wizard/save.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/include/configuration/configCentreonBroker/wizard/save.php	2018-06-29 10:47:16.269628542 +0200
@@ -172,7 +172,7 @@ $central_broker_configuration = array(
     'output' => array(
         array(
             'name' => $wizard->getValue(2, 'prefix_configname') . '-broker-master-sql',
-            'db_type' => 'mysql',
+            'db_type' => 'mysqli',
             'failover' => '',
             'db_host' => $conf_centreon['hostCentstorage'],
             'retry_interval' => '60',
@@ -193,7 +193,7 @@ $central_broker_configuration = array(
             'failover' => '',
             'retry_interval' => '60',
             'buffering_timeout' => '0',
-            'db_type' => 'mysql',
+            'db_type' => 'mysqli',
             'db_host' => $conf_centreon['hostCentstorage'],
             'db_port' => '3306',
             'db_user' => $conf_centreon['user'],
diff -Pdpru centreon-web-2.8.4.orig/www/install/DB-Func.php centreon-web-2.8.24/www/install/DB-Func.php
--- centreon-web-2.8.4.orig/www/install/DB-Func.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/DB-Func.php	2018-06-29 10:23:38.065224865 +0200
@@ -35,7 +35,7 @@
 
 function Connexion ($pNom, $pMotPasse, $pServeur)	{
 	$msg = '';
-	$connexion = @mysql_pconnect($pServeur, $pNom, $pMotPasse) or ($msg = mysql_error());
+	$connexion = @mysqli_connect("p:".$pServeur, $pNom, $pMotPasse) or ($msg = mysqli_error());
 	return array ($connexion, $msg);
 }
 
diff -Pdpru centreon-web-2.8.4.orig/www/install/steps/functions.php centreon-web-2.8.24/www/install/steps/functions.php
--- centreon-web-2.8.4.orig/www/install/steps/functions.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/steps/functions.php	2018-06-29 10:31:19.930755438 +0200
@@ -49,7 +49,7 @@ function myConnect() {
     if (isset($_SESSION['DB_PORT']) && $_SESSION['DB_PORT']) {
         $port = $_SESSION['DB_PORT'];
     }
-    return mysql_connect($host.':'.$port, 'root', $pass);
+    return mysqli_connect($host.':'.$port, 'root', $pass);
 }
 
 /**
@@ -109,9 +109,9 @@ function splitQueries($file, $delimiter
                     $count++;
                     if ($count > $start) {
                         if (is_null($connector)) {
-                            if (mysql_query($query) === false) {
+                            if (mysqli_query($query) === false) {
                                 fclose($file);
-                                return "$fileName Line $line:".mysql_error();
+                                return "$fileName Line $line:".mysqli_error();
                             }
                         } else {
                             try {
@@ -147,13 +147,13 @@ function splitQueries($file, $delimiter
  * @return void
  */
 function importFile($file) {
-    mysql_query('BEGIN');
+    mysqli_query('BEGIN');
     if (false == splitQueries($file)) {
-        $error = mysql_error();
-        mysql_query('ROLLBACK');
+        $error = mysqli_error();
+        mysqli_query('ROLLBACK');
         exitProcess(PROCESS_ID, 1, $error);
     }
-    mysql_query('COMMIT');
+    mysqli_query('COMMIT');
 }
 
 /**
@@ -171,7 +171,7 @@ function exitProcess($id, $result, $msg)
         "result" : "'.$result.'",
         "msg" : "'.$msg.'"
         }';
-    @mysql_close();
+    @mysqli_close();
     exit;
 }
 
@@ -247,16 +247,16 @@ function setSessionVariables($conf_centr
 
 function getDatabaseVariable($variable) {
     $query = "SHOW VARIABLES LIKE '" . $variable . "'";
-    $res = mysql_query($query);
+    $res = mysqli_query($query);
 
-    $row = mysql_fetch_assoc($res);
+    $row = mysqli_fetch_assoc($res);
 
     $value = null;
     if ($row && isset($row['Value'])) {
         $value = $row['Value'];
     }
 
-    mysql_free_result($res);
+    mysqli_free_result($res);
 
     return $value;
 }
diff -Pdpru centreon-web-2.8.4.orig/www/install/steps/process/createDbUser.php centreon-web-2.8.24/www/install/steps/process/createDbUser.php
--- centreon-web-2.8.4.orig/www/install/steps/process/createDbUser.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/steps/process/createDbUser.php	2018-06-29 10:25:39.316576518 +0200
@@ -39,7 +39,7 @@ define('PROCESS_ID', 'createuser');
 
 $link = myConnect();
 if (false === $link) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
 if (!isset($_SESSION['DB_USER'])) {
     exitProcess(PROCESS_ID, 1, _('Could not find database user. Session probably expired.'));
@@ -53,10 +53,10 @@ if (isset($_SESSION['ADDRESS']) && $_SES
         $host = $_SERVER['SERVER_ADDR'];
 }
 $query = "GRANT ALL PRIVILEGES ON `%s`.* TO `". $dbUser . "`@`". $host . "` IDENTIFIED BY '". $dbPass . "' WITH GRANT OPTION";
-if (false === mysql_query(sprintf($query, $_SESSION['CONFIGURATION_DB']))) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+if (false === mysqli_query(sprintf($query, $_SESSION['CONFIGURATION_DB']))) {
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
-if (false === mysql_query(sprintf($query, $_SESSION['STORAGE_DB']))) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+if (false === mysqli_query(sprintf($query, $_SESSION['STORAGE_DB']))) {
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
 exitProcess(PROCESS_ID, 0, "OK");
diff -Pdpru centreon-web-2.8.4.orig/www/install/steps/process/insertBaseConf.php centreon-web-2.8.24/www/install/steps/process/insertBaseConf.php
--- centreon-web-2.8.4.orig/www/install/steps/process/insertBaseConf.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/steps/process/insertBaseConf.php	2018-06-29 10:34:48.413640952 +0200
@@ -39,13 +39,13 @@ define('PROCESS_ID', 'baseconf');
 
 $link = myConnect();
 if (false === $link) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
 
 /**
  * Create tables
  */
-mysql_select_db($_SESSION['CONFIGURATION_DB']);
+mysqli_select_db($_SESSION['CONFIGURATION_DB']);
 
 splitQueries('../../insertMacros.sql', ';', null, '../../tmp/insertMacros');
 splitQueries('../../insertCommands.sql', ';', null, '../../tmp/insertCommands.sql');
@@ -57,19 +57,19 @@ splitQueries('../../insertBaseConf.sql',
 
 # Manage timezone
 $timezone = date_default_timezone_get();
-$resTimezone = mysql_query("SELECT timezone_id FROM timezone WHERE timezone_name= '" . $timezone . "'", $link);
-if ($row = mysql_fetch_assoc($resTimezone)) {
+$resTimezone = mysqli_query("SELECT timezone_id FROM timezone WHERE timezone_name= '" . $timezone . "'", $link);
+if ($row = mysqli_fetch_assoc($resTimezone)) {
     $timezoneId = $row['timezone_id'];
 } else {
     $timezoneId = '334'; # Europe/London timezone
 }
-mysql_query("INSERT INTO `options` (`key`, `value`) VALUES ('gmt','" . $timezoneId . "')", $link);
+mysqli_query("INSERT INTO `options` (`key`, `value`) VALUES ('gmt','" . $timezoneId . "')", $link);
 
 splitQueries('../../insertACL.sql', ';', null, '../../tmp/insertACL');
 
 /* Get Centreon version */
-$res = mysql_query("SELECT `value` FROM informations WHERE `key` = 'version'", $link);
-$row = mysql_fetch_assoc($res);
+$res = mysqli_query("SELECT `value` FROM informations WHERE `key` = 'version'", $link);
+$row = mysqli_fetch_assoc($res);
 $_SESSION['version'] = $row['value'];
 
 exitProcess(PROCESS_ID, 0, "OK");
diff -Pdpru centreon-web-2.8.4.orig/www/install/steps/process/installConfigurationDb.php centreon-web-2.8.24/www/install/steps/process/installConfigurationDb.php
--- centreon-web-2.8.4.orig/www/install/steps/process/installConfigurationDb.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/steps/process/installConfigurationDb.php	2018-06-29 10:34:55.477603192 +0200
@@ -44,7 +44,7 @@ if (isset($_SESSION['MONITORING_VAR_LOG'
 
 $link = myConnect();
 if (false === $link) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
 if (!isset($_SESSION['CONFIGURATION_DB'])) {
     exitProcess(PROCESS_ID, 1, _('Could not find configuration database. Session probably expired.'));
@@ -73,14 +73,14 @@ if ($open_files_limit < 32000) {
     exitProcess(PROCESS_ID, 1, _($exitMessage));
 }
 
-if (false === mysql_query("CREATE DATABASE ".$_SESSION['CONFIGURATION_DB']) && !is_file('../../tmp/createTables')) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+if (false === mysqli_query("CREATE DATABASE ".$_SESSION['CONFIGURATION_DB']) && !is_file('../../tmp/createTables')) {
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
 
 /**
  * Create tables
  */
-mysql_select_db($_SESSION['CONFIGURATION_DB']);
+mysqli_select_db($_SESSION['CONFIGURATION_DB']);
 $result = splitQueries('../../createTables.sql', ';', null, '../../tmp/createTables');
 if ("0" != $result) {
     exitProcess(PROCESS_ID, 1, $result);
diff -Pdpru centreon-web-2.8.4.orig/www/install/steps/process/installStorageDb.php centreon-web-2.8.24/www/install/steps/process/installStorageDb.php
--- centreon-web-2.8.4.orig/www/install/steps/process/installStorageDb.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/steps/process/installStorageDb.php	2018-06-29 10:35:01.373571676 +0200
@@ -39,15 +39,15 @@ define('PROCESS_ID', 'dbstorage');
 
 $link = myConnect();
 if (false === $link) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
 if (!isset($_SESSION['STORAGE_DB'])) {
     exitProcess(PROCESS_ID, 1, _('Could not find storage database. Session probably expired.'));
 }
-if (false === mysql_query("CREATE DATABASE ".$_SESSION['STORAGE_DB']) && !is_file('../../tmp/createTablesCentstorage')) {
-    exitProcess(PROCESS_ID, 1, mysql_error());
+if (false === mysqli_query("CREATE DATABASE ".$_SESSION['STORAGE_DB']) && !is_file('../../tmp/createTablesCentstorage')) {
+    exitProcess(PROCESS_ID, 1, mysqli_error());
 }
-mysql_select_db($_SESSION['STORAGE_DB']);
+mysqli_select_db($_SESSION['STORAGE_DB']);
 $result = splitQueries('../../createTablesCentstorage.sql', ';', null, '../../tmp/createTablesCentstorage');
 if ("0" != $result) {
     exitProcess(PROCESS_ID, 1, $result);
diff -Pdpru centreon-web-2.8.4.orig/www/install/steps/process/process_step6.php centreon-web-2.8.24/www/install/steps/process/process_step6.php
--- centreon-web-2.8.4.orig/www/install/steps/process/process_step6.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/steps/process/process_step6.php	2018-06-29 10:27:59.111829068 +0200
@@ -55,7 +55,7 @@ if ($_POST['DB_PASS'] != $_POST['db_pass
 if (!$strError) {
     $link = myConnect();
     if (false === $link) {
-        $strError .= 'jQuery("input[name=ADDRESS]").next().html("'.mysql_error().'");';
+        $strError .= 'jQuery("input[name=ADDRESS]").next().html("'.mysqli_error().'");';
     } else {
         $dbHost = $_SESSION['ADDRESS'];
         if ($dbHost == "") {
@@ -68,7 +68,7 @@ if (!$strError) {
         }
     }
     if ($link) {
-        mysql_close($link);
+        mysqli_close($link);
     }
 }
 
diff -Pdpru centreon-web-2.8.4.orig/www/install/step_upgrade/functions.php centreon-web-2.8.24/www/install/step_upgrade/functions.php
--- centreon-web-2.8.4.orig/www/install/step_upgrade/functions.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/step_upgrade/functions.php	2018-06-29 10:23:10.681371296 +0200
@@ -38,7 +38,7 @@
 
 function Connexion($pNom, $pMotPasse, $pServeur)
 {
-    $connexion = @mysql_pconnect($pServeur, $pNom, $pMotPasse) or ($msg = mysql_error());
+    $connexion = @mysqli_connect("p:".$pServeur, $pNom, $pMotPasse) or ($msg = mysqli_error());
     if (!isset($msg)) {
         $msg = "";
     }
diff -Pdpru centreon-web-2.8.4.orig/www/install/var/baseconf/centreon-broker.sql centreon-web-2.8.24/www/install/var/baseconf/centreon-broker.sql
--- centreon-web-2.8.4.orig/www/install/var/baseconf/centreon-broker.sql	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/var/baseconf/centreon-broker.sql	2018-06-29 10:48:16.285306204 +0200
@@ -29,7 +29,7 @@ INSERT INTO `cfg_centreonbroker_info` (`
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'type','file','logger',1);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'blockId','3_17','logger',1);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'name','central-broker-master-sql','output',1);
-INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'db_type','mysql','output',1);
+INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'db_type','mysqli','output',1);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'retry_interval','60','output',1);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'buffering_timeout','0','output',1);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'failover','','output',1);
@@ -65,7 +65,7 @@ INSERT INTO `cfg_centreonbroker_info` (`
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'retry_interval','60','output',3);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'buffering_timeout','0','output',3);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'length','15552000','output',3);
-INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'db_type','mysql','output',3);
+INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'db_type','mysqli','output',3);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'db_host','@DB_HOST@','output',3);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'db_port','@DB_PORT@','output',3);
 INSERT INTO `cfg_centreonbroker_info` (`config_id`, `config_key`, `config_value`, `config_group`, `config_group_id`) VALUES (1,'db_user','@DB_USER@','output',3);
diff -Pdpru centreon-web-2.8.4.orig/www/install/var/phplib centreon-web-2.8.24/www/install/var/phplib
--- centreon-web-2.8.4.orig/www/install/var/phplib	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/install/var/phplib	2018-06-29 10:36:02.277246127 +0200
@@ -1,4 +1,4 @@
-MySQL:mysql
+MySQL:mysqli
 GD:gd
 LDAP:ldap
 XML Writer:xmlwriter
diff -Pdpru centreon-web-2.8.4.orig/www/lib/HTML/QuickForm.php centreon-web-2.8.24/www/lib/HTML/QuickForm.php
--- centreon-web-2.8.4.orig/www/lib/HTML/QuickForm.php	2018-06-21 17:27:36.000000000 +0200
+++ centreon-web-2.8.24/www/lib/HTML/QuickForm.php	2018-06-29 11:05:26.703763569 +0200
@@ -1873,7 +1873,8 @@ class HTML_QuickForm extends HTML_Common
     function toArray($collectHidden = false)
     {
         include_once 'HTML/QuickForm/Renderer/Array.php';
-        $renderer =& new HTML_QuickForm_Renderer_Array($collectHidden);
+        $a = new HTML_QuickForm_Renderer_Array($collectHidden);
+        $renderer =& $a;
         $this->accept($renderer);
         return $renderer->toArray();
      } // end func toArray