net-mgmt/pandorafms_console: fix build with PHP 7.1+
PR: 233773 Reported by: Maroslav Lachman 000.fbsd@quip.cz Reviewed by: maintainer (actual diff) Approved by: maintainer MFH: 2019Q1
This commit is contained in:
parent
c8c051dfca
commit
e6575044d6
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=488875
@ -7,14 +7,9 @@ CATEGORIES= net-mgmt
|
||||
MAINTAINER= koichiro@rworks.jp
|
||||
COMMENT= Pandora FMS console
|
||||
|
||||
DEPRECATED= Works only with EOL php 5.6
|
||||
EXPIRATION_DATE= 2018-12-30
|
||||
|
||||
LICENSE= ${PANDORA_LICENSE}
|
||||
LICENSE_FILE= ${PANDORA_LICENSE_FILE}
|
||||
|
||||
IGNORE_WITH_PHP= 71 72 73
|
||||
|
||||
RUN_DEPENDS= ${LOCALBASE}/bin/twopi:graphics/graphviz
|
||||
|
||||
USES= apache:run,2.2+ php:web shebangfix
|
||||
@ -32,7 +27,7 @@ OPTIONS_DEFINE= DOCS PGSQL
|
||||
DOCS_DESC= Install AUTHORS and ChangeLog
|
||||
PGSQL_DESC= Use PostgreSQL backend (experimental)
|
||||
|
||||
USE_PHP= curl filter gd gettext hash json ldap mbstring mysql \
|
||||
USE_PHP= curl filter gd gettext hash json ldap mbstring mysqli \
|
||||
snmp session xml zip zlib
|
||||
|
||||
SUB_FILES+= pandora_console.conf pkg-message newsyslog.conf
|
||||
@ -42,7 +37,7 @@ PGSQL_USE= PHP=pgsql
|
||||
|
||||
.include "${.CURDIR}/../pandorafms_server/bsd.pandora.mk"
|
||||
|
||||
PORTREVISION= 2
|
||||
PORTREVISION= 3
|
||||
|
||||
PANDORA_INSTALLER_ARGS+= --destdir ${STAGEDIR}
|
||||
|
||||
|
192
net-mgmt/pandorafms_console/files/patch-include_db_mysql.php
Normal file
192
net-mgmt/pandorafms_console/files/patch-include_db_mysql.php
Normal file
@ -0,0 +1,192 @@
|
||||
--- include/db/mysql.php.orig 2016-04-08 09:50:59 UTC
|
||||
+++ include/db/mysql.php
|
||||
@@ -29,13 +29,13 @@ function mysql_connect_db($host = null,
|
||||
$port = $config["dbport"];
|
||||
|
||||
// Non-persistent connection: This will help to avoid mysql errors like "has gone away" or locking problems
|
||||
- // If you want persistent connections change it to mysql_pconnect().
|
||||
- $connect_id = @mysql_connect($host . ":" . $port, $user, $pass, true);
|
||||
+ // If you want persistent connections change it to mysqli_pconnect().
|
||||
+ $connect_id = @mysqli_connect($host . ":" . $port, $user, $pass);
|
||||
if (! $connect_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
- mysql_select_db($db, $connect_id);
|
||||
+ mysqli_select_db($connect_id, $db);
|
||||
return $connect_id;
|
||||
}
|
||||
|
||||
@@ -299,14 +299,14 @@ function mysql_db_process_sql($sql, $ret
|
||||
$dbconnection = $config['dbconnection'];
|
||||
}
|
||||
|
||||
- $result = mysql_query ($sql, $dbconnection);
|
||||
+ $result = mysqli_query($dbconnection, $sql);
|
||||
|
||||
$time = microtime (true) - $start;
|
||||
if ($result === false) {
|
||||
$backtrace = debug_backtrace ();
|
||||
$error = sprintf ('%s (\'%s\') in <strong>%s</strong> on line %d',
|
||||
- mysql_error (), $sql, $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
- db_add_database_debug_trace ($sql, mysql_error ($dbconnection));
|
||||
+ mysqli_error($dbconnection), $sql, $backtrace[0]['file'], $backtrace[0]['line']);
|
||||
+ db_add_database_debug_trace ($sql, mysqli_error($dbconnection));
|
||||
set_error_handler ('db_sql_error_handler');
|
||||
trigger_error ($error);
|
||||
restore_error_handler ();
|
||||
@@ -314,29 +314,29 @@ function mysql_db_process_sql($sql, $ret
|
||||
}
|
||||
elseif ($result === true) {
|
||||
if ($rettype == "insert_id") {
|
||||
- $result = mysql_insert_id ($dbconnection);
|
||||
+ $result = ((is_null($___mysqli_res = mysqli_insert_id($dbconnection))) ? false : $___mysqli_res);
|
||||
}
|
||||
elseif ($rettype == "info") {
|
||||
- $result = mysql_info ($dbconnection);
|
||||
+ $result = mysqli_info($dbconnection);
|
||||
}
|
||||
else {
|
||||
- $result = mysql_affected_rows ($dbconnection);
|
||||
+ $result = mysqli_affected_rows($dbconnection);
|
||||
}
|
||||
|
||||
- db_add_database_debug_trace ($sql, $result, mysql_affected_rows ($dbconnection),
|
||||
+ db_add_database_debug_trace ($sql, $result, mysqli_affected_rows($dbconnection),
|
||||
array ('time' => $time));
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
- db_add_database_debug_trace ($sql, 0, mysql_affected_rows ($dbconnection),
|
||||
+ db_add_database_debug_trace ($sql, 0, mysqli_affected_rows($dbconnection),
|
||||
array ('time' => $time));
|
||||
- while ($row = mysql_fetch_assoc ($result)) {
|
||||
+ while ($row = mysqli_fetch_assoc($result)) {
|
||||
array_push ($retval, $row);
|
||||
}
|
||||
|
||||
if ($cache === true)
|
||||
$sql_cache[$sql] = $retval;
|
||||
- mysql_free_result ($result);
|
||||
+ ((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,8 @@ function mysql_db_process_sql($sql, $ret
|
||||
* @return string String cleaned.
|
||||
*/
|
||||
function mysql_escape_string_sql($string) {
|
||||
- $str = mysql_real_escape_string($string);
|
||||
+ global $config;
|
||||
+ $str = mysqli_real_escape_string($config['dbconnection'], $string);
|
||||
|
||||
return $str;
|
||||
}
|
||||
@@ -754,10 +755,10 @@ function mysql_db_get_all_rows_filter ($
|
||||
function mysql_db_get_num_rows ($sql) {
|
||||
global $config;
|
||||
|
||||
- $result = mysql_query($sql, $config['dbconnection']);
|
||||
+ $result = mysqli_query($config['dbconnection'], $sql);
|
||||
|
||||
if ($result) {
|
||||
- return mysql_num_rows($result);
|
||||
+ return mysqli_num_rows($result);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
@@ -972,11 +973,12 @@ function mysql_db_process_sql_delete($ta
|
||||
* @return mixed The row or false in error.
|
||||
*/
|
||||
function mysql_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) {
|
||||
+ global $config;
|
||||
if ($new == true)
|
||||
- $result = mysql_query($sql);
|
||||
+ $result = mysqli_query($config['dbconnection'], $sql);
|
||||
|
||||
if ($result) {
|
||||
- return mysql_fetch_assoc($result);
|
||||
+ return mysqli_fetch_assoc($result);
|
||||
}
|
||||
else {
|
||||
return array();
|
||||
@@ -987,24 +989,27 @@ function mysql_db_get_all_row_by_steps_s
|
||||
* Starts a database transaction.
|
||||
*/
|
||||
function mysql_db_process_sql_begin() {
|
||||
- mysql_query ('SET AUTOCOMMIT = 0');
|
||||
- mysql_query ('START TRANSACTION');
|
||||
+ global $config;
|
||||
+ mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 0');
|
||||
+ mysqli_query($config['dbconnection'], 'START TRANSACTION');
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits a database transaction.
|
||||
*/
|
||||
function mysql_db_process_sql_commit() {
|
||||
- mysql_query ('COMMIT');
|
||||
- mysql_query ('SET AUTOCOMMIT = 1');
|
||||
+ global $config;
|
||||
+ mysqli_query($config['dbconnection'], 'COMMIT');
|
||||
+ mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollbacks a database transaction.
|
||||
*/
|
||||
function mysql_db_process_sql_rollback() {
|
||||
- mysql_query ('ROLLBACK ');
|
||||
- mysql_query ('SET AUTOCOMMIT = 1');
|
||||
+ global $config;
|
||||
+ mysqli_query($config['dbconnection'], 'ROLLBACK ');
|
||||
+ mysqli_query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1018,7 +1023,7 @@ function mysql_safe_sql_string($string)
|
||||
|
||||
global $config;
|
||||
|
||||
- return mysql_real_escape_string($string, $config['dbconnection']);
|
||||
+ return mysqli_real_escape_string($config['dbconnection'], $string);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1027,7 +1032,8 @@ function mysql_safe_sql_string($string)
|
||||
* @return string Return the string error.
|
||||
*/
|
||||
function mysql_db_get_last_error() {
|
||||
- return mysql_error();
|
||||
+ global $config;
|
||||
+ return mysqli_error($config['dbconnection']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1064,9 +1070,10 @@ function mysql_get_system_time() {
|
||||
* @return mixed Return the type name or False in error case.
|
||||
*/
|
||||
function mysql_db_get_type_field_table($table, $field) {
|
||||
- $result = mysql_query('SELECT parameters FROM ' . $table);
|
||||
+ global $config;
|
||||
+ $result = mysqli_query($config['dbconnection'], 'SELECT parameters FROM ' . $table);
|
||||
|
||||
- return mysql_field_type($result, $field);
|
||||
+ return ((is_object($___mysqli_tmp = mysqli_fetch_field_direct($result, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type)) ? ((($___mysqli_tmp = (string)(substr(( (($___mysqli_tmp == MYSQLI_TYPE_STRING) || ($___mysqli_tmp == MYSQLI_TYPE_VAR_STRING) ) ? "string " : "" ) . ( (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24))) ? "int " : "" ) . ( (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, ((defined("MYSQLI_TYPE_NEWDECIMAL")) ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)))) ? "real " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP) ? "timestamp " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_YEAR) ? "year " : "" ) . ( (($___mysqli_tmp == MYSQLI_TYPE_DATE) || ($___mysqli_tmp == MYSQLI_TYPE_NEWDATE) ) ? "date " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_TIME) ? "time " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_SET) ? "set " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_ENUM) ? "enum " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY) ? "geometry " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_DATETIME) ? "datetime " : "" ) . ( (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB))) ? "blob " : "" ) . ( ($___mysqli_tmp == MYSQLI_TYPE_NULL) ? "null " : "" ), 0, -1))) == "") ? "unknown" : $___mysqli_tmp) : false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1136,11 +1143,11 @@ function mysql_db_process_file ($path, $
|
||||
$query .= $sql_line;
|
||||
|
||||
if (preg_match("/;[\040]*\$/", $sql_line)) {
|
||||
- if (!$result = mysql_query($query)) {
|
||||
+ if (!$result = mysqli_query($config['dbconnection'], $query)) {
|
||||
// Error. Rollback the transaction
|
||||
mysql_db_process_sql_rollback();
|
||||
|
||||
- $error_message = mysql_error();
|
||||
+ $error_message = mysqli_error($config['dbconnection']);
|
||||
|
||||
// Handle the error
|
||||
if ($handle_error) {
|
@ -0,0 +1,11 @@
|
||||
--- include/functions.php.orig 2016-04-08 09:50:59 UTC
|
||||
+++ include/functions.php
|
||||
@@ -2322,7 +2322,7 @@ function clear_pandora_error_for_header(
|
||||
global $config;
|
||||
|
||||
$config["alert_cnt"] = 0;
|
||||
- $_SESSION["alert_msg"] = "";
|
||||
+ $_SESSION["alert_msg"] = array();
|
||||
}
|
||||
|
||||
function set_pandora_error_for_header($message, $title = null) {
|
121
net-mgmt/pandorafms_console/files/patch-install.php
Normal file
121
net-mgmt/pandorafms_console/files/patch-install.php
Normal file
@ -0,0 +1,121 @@
|
||||
--- install.php.orig 2016-04-08 09:51:58 UTC
|
||||
+++ install.php
|
||||
@@ -212,8 +212,8 @@ function parse_mysql_dump($url) {
|
||||
if (trim($sql_line) != "" && strpos($sql_line, "--") === false) {
|
||||
$query .= $sql_line;
|
||||
if(preg_match("/;[\040]*\$/", $sql_line)) {
|
||||
- if (!$result = mysql_query($query)) {
|
||||
- echo mysql_error(); //Uncomment for debug
|
||||
+ if (!$result = mysqli_query($GLOBALS["___mysqli_ston"], $query)) {
|
||||
+ echo mysqli_error($GLOBALS["___mysqli_ston"]); //Uncomment for debug
|
||||
echo "<i><br>$query<br></i>";
|
||||
return 0;
|
||||
}
|
||||
@@ -426,7 +426,7 @@ function adjust_paths_for_freebsd($engin
|
||||
for ($i = 0; $i < count ($adjust_sql); $i++) {
|
||||
switch ($engine) {
|
||||
case 'mysql':
|
||||
- $result = mysql_query($adjust_sql[$i]);
|
||||
+ $result = mysqli_query($GLOBALS["___mysqli_ston"], $adjust_sql[$i]);
|
||||
break;
|
||||
case 'oracle':
|
||||
//Delete the last semicolon from current query
|
||||
@@ -575,7 +575,8 @@ function install_step2() {
|
||||
font-size: 8.5pt;margin-top: 2px; font-weight: bolder;'>DB Engines</span>";
|
||||
echo "</td><td>";
|
||||
echo "</td></tr>";
|
||||
- check_extension("mysql", "PHP MySQL extension");
|
||||
+ check_extension("mysql", "PHP mysql extension (deprecated)");
|
||||
+ check_extension("mysqli", "PHP mysql extension");
|
||||
check_extension("pgsql", "PHP PostgreSQL extension");
|
||||
check_extension("oci8", "PHP Oracle extension");
|
||||
echo "</table>";
|
||||
@@ -617,8 +618,8 @@ function install_step2() {
|
||||
|
||||
function install_step3() {
|
||||
$options = '';
|
||||
- if (extension_loaded("mysql")) {
|
||||
- $options .= "<option value='mysql'>MySQL</option>";
|
||||
+ if (extension_loaded("mysql") || extension_loaded("mysqli")) {
|
||||
+ $options .= "<option value='mysql'>mysql</option>";
|
||||
}
|
||||
if (extension_loaded("pgsql")) {
|
||||
$options .= "<option value='pgsql'>PostgreSQL</option>";
|
||||
@@ -811,7 +812,7 @@ function install_step4() {
|
||||
<table width='100%'>";
|
||||
switch ($engine) {
|
||||
case 'mysql':
|
||||
- if (! mysql_connect ($dbhost, $dbuser, $dbpassword)) {
|
||||
+ if (! ($GLOBALS["___mysqli_ston"] = mysqli_connect($dbhost, $dbuser, $dbpassword))) {
|
||||
check_generic ( 0, "Connection with Database");
|
||||
}
|
||||
else {
|
||||
@@ -819,19 +820,19 @@ function install_step4() {
|
||||
|
||||
// Drop database if needed and don't want to install over an existing DB
|
||||
if ($dbdrop == 1) {
|
||||
- mysql_query ("DROP DATABASE IF EXISTS `$dbname`");
|
||||
+ mysqli_query($GLOBALS["___mysqli_ston"], "DROP DATABASE IF EXISTS `$dbname`");
|
||||
}
|
||||
|
||||
// Create schema
|
||||
if ($dbaction == 'db_new' || $dbdrop == 1) {
|
||||
- $step1 = mysql_query ("CREATE DATABASE `$dbname`");
|
||||
+ $step1 = mysqli_query($GLOBALS["___mysqli_ston"], "CREATE DATABASE `$dbname`");
|
||||
check_generic ($step1, "Creating database '$dbname'");
|
||||
}
|
||||
else {
|
||||
$step1 = 1;
|
||||
}
|
||||
if ($step1 == 1) {
|
||||
- $step2 = mysql_select_db($dbname);
|
||||
+ $step2 = mysqli_select_db($GLOBALS["___mysqli_ston"], $dbname);
|
||||
check_generic ($step2, "Opening database '$dbname'");
|
||||
|
||||
$step3 = parse_mysql_dump("pandoradb.sql");
|
||||
@@ -848,9 +849,9 @@ function install_step4() {
|
||||
$host = 'localhost';
|
||||
if ($dbhost != 'localhost')
|
||||
$host = $dbgrant;
|
||||
- $step5 = mysql_query ("GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host
|
||||
+ $step5 = mysqli_query($GLOBALS["___mysqli_ston"], "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host
|
||||
IDENTIFIED BY '".$random_password."'");
|
||||
- mysql_query ("FLUSH PRIVILEGES");
|
||||
+ mysqli_query($GLOBALS["___mysqli_ston"], "FLUSH PRIVILEGES");
|
||||
check_generic ($step5, "Established privileges for user pandora. A new random password has been generated: <b>$random_password</b><div class='warn'>Please write it down, you will need to setup your Pandora FMS server, editing the </i>/etc/pandora/pandora_server.conf</i> file</div>");
|
||||
|
||||
$step6 = is_writable("include");
|
||||
@@ -863,7 +864,7 @@ function install_step4() {
|
||||
$config_new = '<?php
|
||||
// Begin of automatic config file
|
||||
$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, postgresql...in future others)
|
||||
- $config["dbname"]="'.$dbname.'"; // MySQL DataBase name
|
||||
+ $config["dbname"]="'.$dbname.'"; // mysql DataBase name
|
||||
$config["dbuser"]="pandora"; // DB User
|
||||
$config["dbpass"]="'.$random_password.'"; // DB Password
|
||||
$config["dbhost"]="'.$dbhost.'"; // DB Host
|
||||
@@ -1145,7 +1146,7 @@ function install_step4() {
|
||||
$config_new = '<?php
|
||||
// Begin of automatic config file
|
||||
$config["dbtype"] = "' . $dbtype . '"; //DB type (mysql, postgresql...in future others)
|
||||
- $config["dbname"]="'.$dbname.'"; // MySQL DataBase name
|
||||
+ $config["dbname"]="'.$dbname.'"; // mysql DataBase name
|
||||
$config["dbuser"]="pandora"; // DB User
|
||||
$config["dbpass"]="'.$random_password.'"; // DB Password
|
||||
$config["dbhost"]="'.$dbhost.'"; // DB Host
|
||||
@@ -1208,12 +1209,12 @@ function install_step4() {
|
||||
|
||||
switch ($engine) {
|
||||
case 'mysql':
|
||||
- if (mysql_error() != "") {
|
||||
- echo "<div class='err'> <b>ERROR:</b> ". mysql_error().".</div>";
|
||||
+ if (mysqli_error($GLOBALS["___mysqli_ston"]) != "") {
|
||||
+ echo "<div class='err'> <b>ERROR:</b> ". mysqli_error($GLOBALS["___mysqli_ston"]).".</div>";
|
||||
}
|
||||
|
||||
if ($step1 == 1) {
|
||||
- mysql_query ("DROP DATABASE $dbname");
|
||||
+ mysqli_query($GLOBALS["___mysqli_ston"], "DROP DATABASE $dbname");
|
||||
}
|
||||
break;
|
||||
case 'pgsql':
|
Loading…
Reference in New Issue
Block a user