From 475a2970cc59a000da221807f0daf3ca6933f8ce Mon Sep 17 00:00:00 2001
From: phpipam <miha.petkovsek@telemach.si>
Date: Wed, 20 Dec 2023 10:52:55 +0100
Subject: [PATCH] small fixes for installation process

---
 app/install/install_mysqlimport.php  |  2 +-
 app/install/select_install_type.php  | 10 +++++-----
 functions/checks/check_php_build.php |  2 ++
 functions/classes/class.Install.php  |  2 +-
 functions/classes/class.PDO.php      |  2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/app/install/install_mysqlimport.php b/app/install/install_mysqlimport.php
index e5c53329..dd6d94d8 100755
--- a/app/install/install_mysqlimport.php
+++ b/app/install/install_mysqlimport.php
@@ -52,7 +52,7 @@ exit</pre>
 				<pre><?php
 					$esc_user = escape_input($db['user']);
 					$esc_pass = escape_input(_("<YOUR SECRET PASSWORD FROM config.php>"));
-					$esc_webhost = is_string($db['webhost']) && strlen($db['webhost']) ? escape_input($db['webhost']) : 'localhost';
+					$esc_webhost = is_string(@$db['webhost']) && strlen(@$db['webhost']) ? escape_input($db['webhost']) : 'localhost';
 					$db_name  = escape_input($db['name']);
 
 					print "# Set permissions for phpipam user <br>";
diff --git a/app/install/select_install_type.php b/app/install/select_install_type.php
index c36b8391..c817eb4d 100755
--- a/app/install/select_install_type.php
+++ b/app/install/select_install_type.php
@@ -12,7 +12,7 @@ $text_prefix  = @$_GET['subnetId']=="migrate" ? _("migrate") : _("install");
 	<div style="padding:10px;">
 
 		<div class="text-mute2d" style="margin:10px;">
-			<?php print _("We are glad you decided phpipam to")." ".$text_prefix.". "._("Before you can start to process please:"); ?><br><br>
+			<?php print _("We are glad you decided to")." ".$text_prefix." phpipam. "._("Before you can start to process please:"); ?><br><br>
 			<ul>
 				<li><?php print _("Edit settings in config.php file"); ?></li>
 				<li><?php print _("Create a MySQL/MariaDB database for phpipam, you can do this three ways (select below)"); ?></li>
@@ -23,7 +23,7 @@ $text_prefix  = @$_GET['subnetId']=="migrate" ? _("migrate") : _("install");
 
 			<?php
 			// migrate
-			if($_GET['subnetId']=="migrate") { ?>
+			if(@$_GET['subnetId']=="migrate") { ?>
 				<hr>
 				<div class="alert alert-warning">
 				<?php print _("You selected option to migrate from old database.")."<br>"._("Please put SQL dump file from old phpipam installation to db/MIGRATE.sql file !"); ?>
@@ -38,7 +38,7 @@ $text_prefix  = @$_GET['subnetId']=="migrate" ? _("migrate") : _("install");
 		<ol style="margin-top:20px;">
 		<!-- automatic -->
 		<li>
-			<a href="<?php print create_link("install","install_automatic", $_GET['subnetId']); ?>" class="btn btn-sm btn-default"><?php print _("Automatic database")." ".$title_prefix; ?></a>
+			<a href="<?php print create_link("install","install_automatic", @$_GET['subnetId']); ?>" class="btn btn-sm btn-default"><?php print _("Automatic database")." ".$title_prefix; ?></a>
 			<br>
 			<div class="text-muted"><?php print _("phpipam installer will create database for you automatically."); ?></div>
 			<br>
@@ -46,7 +46,7 @@ $text_prefix  = @$_GET['subnetId']=="migrate" ? _("migrate") : _("install");
 
 		<!-- Mysql inport -->
 		<li>
-			<a href="<?php print create_link("install","install_mysqlimport", $_GET['subnetId']); ?>" class="btn btn-sm btn-default"><?php print _("MySQL/MariaDB import instructions"); ?></a>
+			<a href="<?php print create_link("install","install_mysqlimport", @$_GET['subnetId']); ?>" class="btn btn-sm btn-default"><?php print _("MySQL/MariaDB import instructions"); ?></a>
 			<br>
 			<div class="text-muted"><?php print _("Install DB files with mysqlimport tool."); ?></div>
 			<br>
@@ -54,7 +54,7 @@ $text_prefix  = @$_GET['subnetId']=="migrate" ? _("migrate") : _("install");
 
 		<!-- Manual install -->
 		<li>
-			<a href="<?php print create_link("install","install_manual", $_GET['subnetId']); ?>" class="btn btn-sm btn-default"><?php print _("Manual database")." ".$title_prefix; ?></a>
+			<a href="<?php print create_link("install","install_manual", @$_GET['subnetId']); ?>" class="btn btn-sm btn-default"><?php print _("Manual database")." ".$title_prefix; ?></a>
 			<br>
 			<div class="text-muted"><?php print _("Install database manually with SQL queries."); ?></div>
 			<br>
diff --git a/functions/checks/check_php_build.php b/functions/checks/check_php_build.php
index 612f0618..9a0dcb93 100755
--- a/functions/checks/check_php_build.php
+++ b/functions/checks/check_php_build.php
@@ -54,6 +54,8 @@ if (!@include_once 'PEAR.php') {
     $missingExt[] = "php PEAR support";
 }
 
+if(!isset($url)) { $url = ""; }
+
 /* headers */
 $error   = [];
 $error[] = "<html>";
diff --git a/functions/classes/class.Install.php b/functions/classes/class.Install.php
index f5046627..5babec06 100644
--- a/functions/classes/class.Install.php
+++ b/functions/classes/class.Install.php
@@ -146,7 +146,7 @@ class Install extends Common_functions {
 		$esc_user = addcslashes($this->db['user'],"'");
 		$esc_pass = addcslashes($this->db['pass'],"'");
 		$db_name  = $this->db['name'];
-		$webhost  = is_string($this->db['webhost']) && !is_blank($this->db['webhost']) ? addcslashes($this->db['webhost'],"'") : 'localhost';
+		$webhost  = is_string(@$this->db['webhost']) && !is_blank(@$this->db['webhost']) ? addcslashes($this->db['webhost'],"'") : 'localhost';
 
 		try {
 			# Check if user exists;
diff --git a/functions/classes/class.PDO.php b/functions/classes/class.PDO.php
index ba2d379e..3fc9c89f 100644
--- a/functions/classes/class.PDO.php
+++ b/functions/classes/class.PDO.php
@@ -292,7 +292,7 @@ abstract class DB {
 	 * @return bool
 	 */
 	public function isConnected() {
-		return ($this->pdo !== null);
+		return (@$this->pdo !== null);
 	}
 
 	/**
-- 
GitLab