From 7ef7bfc06a91e19b315d3ca91841d4f60b1da8c8 Mon Sep 17 00:00:00 2001 From: loiclau <loic.lau@gmail.com> Date: Mon, 5 Mar 2018 11:36:26 +0100 Subject: [PATCH] Php deprecated (#5995) * fix(function) replace split * fix(php) fix mktime is_dst * fix(php) function __construct * fix(php) clean magic quotes * fix(php) clean reference * fix(php) function __construct * fix(php) style * fix(php) constructor * fix(php) php tags --- www/class/centreonUser.class.php | 2 +- www/class/centreonXML.class.php | 7 ++++--- www/class/config-generate/engine.class.php | 11 ++--------- .../Administration/configChangelog/viewLogs.php | 4 ++-- .../configuration/configKnowledge/pagination.php | 2 +- .../configObject/command/listCommand.php | 2 -- www/include/eventLogs/xml/data.php | 4 ++-- www/include/monitoring/comments/AddSvcComment.php | 2 +- www/include/monitoring/downtime/AddDowntime.php | 2 +- www/include/monitoring/recurrentDowntime/json.php | 6 +++--- www/install/index.php | 1 + 11 files changed, 18 insertions(+), 25 deletions(-) diff --git a/www/class/centreonUser.class.php b/www/class/centreonUser.class.php index 894551e3d7..75e56b93fa 100644 --- a/www/class/centreonUser.class.php +++ b/www/class/centreonUser.class.php @@ -71,7 +71,7 @@ class CentreonUser * CentreonUser constructor. * @param array $user */ - public function CentreonUser($user = array()) + public function __construct($user = array()) { global $pearDB; diff --git a/www/class/centreonXML.class.php b/www/class/centreonXML.class.php index 6579e81ed7..91959dcec1 100644 --- a/www/class/centreonXML.class.php +++ b/www/class/centreonXML.class.php @@ -41,10 +41,11 @@ class CentreonXML { public $buffer; - /* - * Constructor + /** + * CentreonXML constructor. + * @param bool $indent */ - public function CentreonXML($indent = false) + public function __construct($indent = false) { $this->buffer = new XMLWriter(); $this->buffer->openMemory(); diff --git a/www/class/config-generate/engine.class.php b/www/class/config-generate/engine.class.php index 2f85f3b424..4ad370e8da 100644 --- a/www/class/config-generate/engine.class.php +++ b/www/class/config-generate/engine.class.php @@ -1,5 +1,4 @@ <?php - /* * Copyright 2005-2015 Centreon * Centreon is developped by : Julien Mathis and Romain Le Merlus under @@ -43,12 +42,9 @@ class Engine extends AbstractObject # lock_file, daemon_dumps_core protected $attributes_select = ' nagios_id, - use_timezone, - cfg_dir, cfg_file as cfg_filename, - log_file, status_file, check_result_path, @@ -114,7 +110,6 @@ class Engine extends AbstractObject debug_verbosity, max_debug_file_size, log_pid, - global_host_event_handler as global_host_event_handler_id, global_service_event_handler as global_service_event_handler_id, ocsp_command as ocsp_command_id, @@ -123,7 +118,6 @@ class Engine extends AbstractObject service_perfdata_command as service_perfdata_command_id, host_perfdata_file_processing_command as host_perfdata_file_processing_command_id, service_perfdata_file_processing_command as service_perfdata_file_processing_command_id, - enable_notifications, execute_service_checks, accept_passive_service_checks, @@ -143,7 +137,7 @@ class Engine extends AbstractObject auto_reschedule_checks, use_aggressive_host_checking, soft_state_dependencies, - obsess_over_services, + obsess_over_services, obsess_over_hosts, process_performance_data, host_perfdata_file_mode, @@ -227,7 +221,6 @@ class Engine extends AbstractObject 'debug_verbosity', 'max_debug_file_size', 'log_pid', // cengine - 'global_host_event_handler', 'global_service_event_handler', 'ocsp_command', @@ -257,7 +250,7 @@ class Engine extends AbstractObject 'auto_reschedule_checks', 'use_aggressive_host_checking', 'soft_state_dependencies', - 'obsess_over_services', + 'obsess_over_services', 'obsess_over_hosts', 'process_performance_data', 'host_perfdata_file_mode', diff --git a/www/include/Administration/configChangelog/viewLogs.php b/www/include/Administration/configChangelog/viewLogs.php index 83312fa182..ae78be4b9f 100644 --- a/www/include/Administration/configChangelog/viewLogs.php +++ b/www/include/Administration/configChangelog/viewLogs.php @@ -205,7 +205,7 @@ while ($res = $DBRESULT->fetchRow()) { if ($tmp != -1) { if (isset($tmp['h'])) { $tmp2 = $centreon->CentreonLogAction->getHostId($res['object_id']); - $tabHost = split(',', $tmp2["h"]); + $tabHost = explode(',', $tmp2["h"]); if (count($tabHost) == 1) { $host_name = $centreon->CentreonLogAction->getHostName($tmp2["h"]); } elseif (count($tabHost) > 1) { @@ -216,7 +216,7 @@ while ($res = $DBRESULT->fetchRow()) { } } elseif (isset($tmp['hg'])) { $tmp2 = $centreon->CentreonLogAction->getHostId($res['object_id']); - $tabHost = split(',', $tmp2["hg"]); + $tabHost = explode(',', $tmp2["hg"]); if (count($tabHost) == 1) { $hg_name = $centreon->CentreonLogAction->getHostGroupName($tmp2["hg"]); } elseif (count($tabHost) > 1) { diff --git a/www/include/configuration/configKnowledge/pagination.php b/www/include/configuration/configKnowledge/pagination.php index 19ea3b8e1c..2b292f0a65 100644 --- a/www/include/configuration/configKnowledge/pagination.php +++ b/www/include/configuration/configKnowledge/pagination.php @@ -244,7 +244,7 @@ $form->setDefaults(array("p" => $p, "search" => $search, "num" => $num)); /* * Init QuickForm */ -$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl); +$renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); $form->accept($renderer); isset($_GET["host_name"]) ? $host_name = $_GET["host_name"] : $host_name = null; diff --git a/www/include/configuration/configObject/command/listCommand.php b/www/include/configuration/configObject/command/listCommand.php index d8fb649695..3aca2dda57 100755 --- a/www/include/configuration/configObject/command/listCommand.php +++ b/www/include/configuration/configObject/command/listCommand.php @@ -84,8 +84,6 @@ include_once "./include/common/checkPagination.php"; * Smarty template Init */ -set_magic_quotes_runtime(0); - $tpl = new Smarty(); $tpl = initSmartyTpl($path, $tpl); diff --git a/www/include/eventLogs/xml/data.php b/www/include/eventLogs/xml/data.php index 99e99a7c2a..554f203cba 100644 --- a/www/include/eventLogs/xml/data.php +++ b/www/include/eventLogs/xml/data.php @@ -238,12 +238,12 @@ if ($EndDate != "" && $EndTime == "") { if ($StartDate != "") { preg_match("/^([0-9]*)\/([0-9]*)\/([0-9]*)/", $StartDate, $matchesD); preg_match("/^([0-9]*):([0-9]*)/", $StartTime, $matchesT); - $start = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3], -1); + $start = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3]); } if ($EndDate != "") { preg_match("/^([0-9]*)\/([0-9]*)\/([0-9]*)/", $EndDate, $matchesD); preg_match("/^([0-9]*):([0-9]*)/", $EndTime, $matchesT); - $end = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3], -1); + $end = mktime($matchesT[1], $matchesT[2], "0", $matchesD[1], $matchesD[2], $matchesD[3]); } $period = 86400; diff --git a/www/include/monitoring/comments/AddSvcComment.php b/www/include/monitoring/comments/AddSvcComment.php index 435c2721d5..ce4c5c1514 100644 --- a/www/include/monitoring/comments/AddSvcComment.php +++ b/www/include/monitoring/comments/AddSvcComment.php @@ -142,7 +142,7 @@ if ($centreon->user->access->checkAction("service_comment")) { //global services comment if (!isset($_POST["host_id"])) { foreach ($_POST["service_id"] as $value) { - $info = split('-', $value); + $info = explode('-', $value); AddSvcComment( $info[0], $info[1], diff --git a/www/include/monitoring/downtime/AddDowntime.php b/www/include/monitoring/downtime/AddDowntime.php index 830316fb33..2985856b5d 100644 --- a/www/include/monitoring/downtime/AddDowntime.php +++ b/www/include/monitoring/downtime/AddDowntime.php @@ -383,7 +383,7 @@ if (!$centreon->user->access->checkAction("host_schedule_downtime") } foreach ($_POST["service_id"] as $value) { - $info = split('-', $value); + $info = explode('-', $value); if ($centreon->user->access->admin || in_array($info[0], $host_acl_id)) { $ecObj->addSvcDowntime( $info[0], diff --git a/www/include/monitoring/recurrentDowntime/json.php b/www/include/monitoring/recurrentDowntime/json.php index 26df13f038..7ddac9590f 100644 --- a/www/include/monitoring/recurrentDowntime/json.php +++ b/www/include/monitoring/recurrentDowntime/json.php @@ -130,7 +130,7 @@ class Services_JSON * bubble up with an error, so all return values * from encode() should be checked with isError() */ - public function Services_JSON($use = 0) + public function __construct($use = 0) { $this->use = $use; } @@ -800,7 +800,7 @@ if (class_exists('PEAR_Error')) { class Services_JSON_Error extends PEAR_Error { - public function Services_JSON_Error( + public function __construct( $message = 'unknown error', $code = null, $mode = null, @@ -817,7 +817,7 @@ if (class_exists('PEAR_Error')) { */ class Services_JSON_Error { - public function Services_JSON_Error( + public function __construct( $message = 'unknown error', $code = null, $mode = null, diff --git a/www/install/index.php b/www/install/index.php index e69de29bb2..b3d9bbc7f3 100644 --- a/www/install/index.php +++ b/www/install/index.php @@ -0,0 +1 @@ +<?php -- GitLab