This commit is contained in:
Matteo Gheza 2020-06-05 19:41:47 +02:00
parent f67d378bd9
commit 62a5d4c3d6
2 changed files with 12 additions and 8 deletions

View File

@ -14,6 +14,7 @@ if (!file_exists("runInstall.php")) {
}
$populated = false;
$userPopulated = false;
if (file_exists("../config.php")) {
try {
require('../config.php');
@ -26,10 +27,15 @@ if (file_exists("../config.php")) {
$configExist = true;
try{
$connection = new PDO("mysql:host=$dbhostValue;dbname=$dbnameValue", $unameValue, $pwdValue,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$populated = !empty($connection->prepare(str_replace("%PREFIX%", DB_PREFIX, "SELECT * FROM `%PREFIX%_dbversion`;"))->execute());
$userPopulated = !empty($connection->prepare(str_replace("%PREFIX%", DB_PREFIX, "SELECT * FROM `%PREFIX%_users`;"))->execute());
$stmt = $connection->prepare(str_replace("%PREFIX%", DB_PREFIX, "SELECT * FROM `%PREFIX%_dbversion`;"));
$query = $stmt->execute();
$populated = !empty($stmt->fetchAll(PDO::FETCH_ASSOC));
$stmt2 = $connection->prepare(str_replace("%PREFIX%", DB_PREFIX, "SELECT * FROM `%PREFIX%_users`;"));
$query2 = $stmt2->execute();
$userPopulated = !empty($stmt2->fetchAll(PDO::FETCH_ASSOC));
} catch (PDOException $e){
$populated = false;
$userPopulated = false;
}
}
} catch (Exception $e) {
@ -142,7 +148,7 @@ if(!is_cli()){
} else if ($configExist && !$populated) {
initDB();
header("Location: install.php");
} else if ($populated && !$userPopulated) {
} else if ($populated && !$userPopulated && !in_array("5",$_POST)) {
?>
<h1 class="screen-reader-text">Evviva!</h1>
<p>Hai <b>quasi terminato</b> l'installazione di Allerta, devi solo inserire alcune informazioni.</p>

View File

@ -64,7 +64,7 @@ function checkConnection($host, $user, $password, $database, $return=false){
<summary>Informazioni avanzate</summary>
<pre><?php echo($e); ?></pre>
</details>
<p class="step"><a href="#" onclick="javascript:history.go(-1);return false;" class="button button-large">Riprova</a></p>
<p class="step"><a href="#" onclick="javascript:history.go(-2);return false;" class="button button-large">Riprova</a></p>
</div>
<?php
exit();
@ -99,7 +99,7 @@ function checkConnection($host, $user, $password, $database, $return=false){
<summary>Informazioni avanzate</summary>
<pre><?php echo($e); ?></pre>
</details>
<p class="step"><a href="#" onclick="javascript:history.go(-1);return false;" class="button button-large">Riprova</a></p>
<p class="step"><a href="#" onclick="javascript:history.go(-2);return false;" class="button button-large">Riprova</a></p>
</div>
<?php
exit();
@ -335,9 +335,7 @@ CREATE TABLE `".$prefix."_dbversion` (
PRIMARY KEY (`id`),
KEY `Id` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `".$prefix."_dbversion` (`id`, `version`, `timestamp`) VALUES (NULL, '1', current_timestamp()) WHERE NOT EXISTS (
SELECT version FROM `".$prefix."_dbversion` WHERE version = '1'
) LIMIT 1;");
INSERT INTO `".$prefix."_dbversion` (`version`, `timestamp`) VALUES('1', current_timestamp());");
} catch (Exception $e) {
if(is_cli()){
echo($e);