|
10 | 10 | $config->load("local.config", "defaults.php"); |
11 | 11 |
|
12 | 12 | 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 | + |
15 | 27 | }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; |
18 | 29 | } |
| 30 | + |
19 | 31 |
|
20 | 32 | $existing=$config->userconf; |
21 | 33 |
|
22 | | - $edit=array('general' => array ()); |
23 | | - $edit["general"]["pass"]=md5($val); |
24 | | - $edit["general"]["initialsetup"]="1"; |
25 | | - //print_r($edit); |
26 | | - |
27 | 34 | $combined=array_replace_recursive($existing, $edit); |
28 | 35 | echo $config->save($combined); |
29 | 36 | $_SESSION["setup"]="justfinished"; |
@@ -558,13 +565,37 @@ function completeSetup() { |
558 | 565 | }, 1000); |
559 | 566 | }, 1000); |
560 | 567 | }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 | + |
562 | 574 | } |
563 | 575 | }, null, "POST", true, "complete=true&pw="+value); |
564 | 576 | <?php |
565 | 577 | }else{ |
566 | 578 | ?> |
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> 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"); |
568 | 599 | <?php |
569 | 600 | } |
570 | 601 | ?> |
|
0 commit comments