Skip to content

Commit ddf3695

Browse files
committed
Run setup procedure again after already done
- except for password which stays the same
1 parent 2eb90b4 commit ddf3695

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

setup.php

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,27 @@
1010
$config->load("local.config", "defaults.php");
1111

1212
if(isset($_POST["complete"])){
13-
if(isset($_POST["pw"])){
14-
$val=$_POST["pw"];
13+
14+
if($config->get("general.initialsetup")=="0"){
15+
16+
if(isset($_POST["pw"])){
17+
$val=$_POST["pw"];
18+
}else{
19+
echo "Setup error - no password specified. Please create an issue <a href='https://github.com/femto-code/Raspberry-Pi-Dashboard/issues/new' target='blank'>here</a>.";
20+
exit();
21+
}
22+
$edit=array('general' => array ());
23+
$edit["general"]["pass"]=md5($val);
24+
$edit["general"]["initialsetup"]="1";
25+
//print_r($edit);
26+
1527
}else{
16-
echo "Setup error - no password specified. Please create an issue <a href='https://github.com/femto-code/Raspberry-Pi-Dashboard/issues/new' target='blank'>here</a>.";
17-
exit();
28+
$edit=$config->userconf;
1829
}
30+
1931

2032
$existing=$config->userconf;
2133

22-
$edit=array('general' => array ());
23-
$edit["general"]["pass"]=md5($val);
24-
$edit["general"]["initialsetup"]="1";
25-
//print_r($edit);
26-
2734
$combined=array_replace_recursive($existing, $edit);
2835
echo $config->save($combined);
2936
$_SESSION["setup"]="justfinished";
@@ -558,13 +565,37 @@ function completeSetup() {
558565
}, 1000);
559566
}, 1000);
560567
}else{
561-
alert("Error occured.");
568+
if(data.responseText=="perm_error"){
569+
if (confirm(("Config file (local.config) exists but could not be modified. Required permissions are not set correctly.\nShow help?"))){
570+
window.open('https://github.com/femto-code/Raspberry-Pi-Dashboard#valid-permissions');
571+
}
572+
}
573+
562574
}
563575
}, null, "POST", true, "complete=true&pw="+value);
564576
<?php
565577
}else{
566578
?>
567-
location.replace("index.php");
579+
$("#submit").html("Processing...").prop("disabled", true);
580+
var vReq = new ntwReq("setup.php", function (data) {
581+
console.log(data.responseText);
582+
if(data.responseText=="1"){
583+
window.setTimeout(function(){
584+
$('#submit').html("<i class='bi bi-check-circle'></i>&nbsp;Successful");
585+
window.setTimeout(function(){
586+
location.replace("index.php");
587+
}, 1000);
588+
}, 1000);
589+
}else{
590+
if(data.responseText=="perm_error"){
591+
if (confirm(("Config file (local.config) exists but could not be modified. Required permissions are not set correctly.\nShow help?"))){
592+
window.open('https://github.com/femto-code/Raspberry-Pi-Dashboard#valid-permissions');
593+
}
594+
}
595+
596+
}
597+
}, null, "POST", true, "complete=true&pw=xyz");
598+
//location.replace("index.php");
568599
<?php
569600
}
570601
?>

0 commit comments

Comments
 (0)