Skip to content

Commit

Permalink
password for settings added
Browse files Browse the repository at this point in the history
  • Loading branch information
snaptec committed Aug 4, 2019
1 parent 5108b2f commit a692c26
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 3 deletions.
8 changes: 8 additions & 0 deletions runs/atreboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,14 @@ if ! grep -Fq "displaypincode=" /var/www/html/openWB/openwb.conf
then
echo "displaypincode=1234" >> /var/www/html/openWB/openwb.conf
fi
if ! grep -Fq "settingspw=" /var/www/html/openWB/openwb.conf
then
echo "settingspw='openwb'" >> /var/www/html/openWB/openwb.conf
fi
if ! grep -Fq "settingspwakt=" /var/www/html/openWB/openwb.conf
then
echo "settingspwakt=0" >> /var/www/html/openWB/openwb.conf
fi



Expand Down
46 changes: 45 additions & 1 deletion web/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@
if(strpos($line, "ledsofort=") !== false) {
list(, $ledsofortold) = explode("=", $line);
}

if(strpos($line, "settingspw=") !== false) {
list(, $settingspwold) = explode("=", $line, 2);
}
if(strpos($line, "lednurpv=") !== false) {
list(, $lednurpvold) = explode("=", $line);
}
Expand Down Expand Up @@ -467,7 +469,12 @@
if(strpos($line, "ledsakt=") !== false) {
list(, $ledsaktold) = explode("=", $line);
}
if(strpos($line, "settingspwakt=") !== false) {
list(, $settingspwaktold) = explode("=", $line);
}
}
$settingspwsold = str_replace( "'", "", $settingspwold);

$bezug_http_w_urlold = str_replace( "'", "", $bezug_http_w_urlold);
$bezug_http_ikwh_urlold = str_replace( "'", "", $bezug_http_ikwh_urlold);
$bezug_http_ekwh_urlold = str_replace( "'", "", $bezug_http_ekwh_urlold);
Expand Down Expand Up @@ -549,6 +556,18 @@
Definiert den Lademodus nach Boot der openWB.<br> <br>
</div>
<hr>

<div class="row">
<b><label for="settingspwakt">Passwortabfrage für Einstellseiten:</label></b>
<select type="text" name="settingspwakt" id="settingspwakt">
<option <?php if($settingspwaktold == 0) echo selected ?> value="0">Deaktiviert</option>
<option <?php if($settingspwaktold == 1) echo selected ?> value="1">Aktiviert</option>
</select><br>Passwort:
<input type="password" name="settingspw" id="settingspw" value="<?php echo $settingspwsold ?>"><br>

</div>

<hr>
<div class="row">
<b><label for="rfidakt">RFID Lesung:</label></b>
<select type="text" name="rfidakt" id="rfidakt">
Expand Down Expand Up @@ -1232,4 +1251,29 @@
</form>
</div></div>
</div>
<script>
var settingspwaktold = <?php echo $settingspwaktold ?>;

var settingspwold = <?php echo $settingspwold ?>;
if ( settingspwaktold == 1 ) {
passWord();
}
function passWord() {
var testV = 1;
var pass1 = prompt('Einstellungen geschützt, bitte Password eingeben:','');

while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == settingspwold) {
break;
}
testV+=1;
var pass1 = prompt('Passwort falsch','Password');
}
if (pass1.toLowerCase()!="password" & testV == 3)
history.go(-1);
return " ";
}
</script>
</body></html>
35 changes: 35 additions & 0 deletions web/modulconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ function checkmodification(){
}
}
</script>



<?php


Expand All @@ -54,6 +57,12 @@ function checkmodification(){
if(strpos($line, "bezug_victronip=") !== false) {
list(, $bezug_victronipold) = explode("=", $line);
}
if(strpos($line, "settingspwakt=") !== false) {
list(, $settingspwaktold) = explode("=", $line);
}
if(strpos($line, "settingspw=") !== false) {
list(, $settingspwold) = explode("=", $line);
}
if(strpos($line, "sonnenecoip=") !== false) {
list(, $sonnenecoipold) = explode("=", $line);
}
Expand Down Expand Up @@ -3600,4 +3609,30 @@ function display_speichermodul() {
</form>
</div></div>
</div>

<script>
var settingspwaktold = <?php echo $settingspwaktold ?>;

var settingspwold = <?php echo $settingspwold ?>;
if ( settingspwaktold == 1 ) {
passWord();
}
function passWord() {
var testV = 1;
var pass1 = prompt('Einstellungen geschützt, bitte Password eingeben:','');

while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == settingspwold) {
break;
}
testV+=1;
var pass1 = prompt('Passwort falsch','Password');
}
if (pass1.toLowerCase()!="password" & testV == 3)
history.go(-1);
return " ";
}
</script>
</body></html>
31 changes: 31 additions & 0 deletions web/pvconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
if(strpos($line, "speicherpvui=") !== false) {
list(, $speicherpvuiold) = explode("=", $line);
}
if(strpos($line, "settingspw=") !== false) {
list(, $settingspwold) = explode("=", $line);
}
if(strpos($line, "settingspwakt=") !== false) {
list(, $settingspwaktold) = explode("=", $line);
}

if(strpos($line, "speichermaxwatt=") !== false) {
list(, $speichermaxwattold) = explode("=", $line);
Expand Down Expand Up @@ -580,4 +586,29 @@


</div>
<script>
var settingspwaktold = <?php echo $settingspwaktold ?>;

var settingspwold = <?php echo $settingspwold ?>;
if ( settingspwaktold == 1 ) {
passWord();
}
function passWord() {
var testV = 1;
var pass1 = prompt('Einstellungen geschützt, bitte Password eingeben:','');

while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == settingspwold) {
break;
}
testV+=1;
var pass1 = prompt('Passwort falsch','Password');
}
if (pass1.toLowerCase()!="password" & testV == 3)
history.go(-1);
return " ";
}
</script>
</body></html>
31 changes: 31 additions & 0 deletions web/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
if(strpos($line, "sofortll=") !== false) {
list(, $sofortllold) = explode("=", $line);
}
if(strpos($line, "settingspwakt=") !== false) {
list(, $settingspwaktold) = explode("=", $line);
}
if(strpos($line, "settingspw=") !== false) {
list(, $settingspwold) = explode("=", $line);
}
if(strpos($line, "dspeed=") !== false) {
list(, $dspeedold) = explode("=", $line);
}
Expand Down Expand Up @@ -1221,4 +1227,29 @@


</div>
<script>
var settingspwaktold = <?php echo $settingspwaktold ?>;

var settingspwold = <?php echo $settingspwold ?>;
if ( settingspwaktold == 1 ) {
passWord();
}
function passWord() {
var testV = 1;
var pass1 = prompt('Einstellungen geschützt, bitte Password eingeben:','');

while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == settingspwold) {
break;
}
testV+=1;
var pass1 = prompt('Passwort falsch','Password');
}
if (pass1.toLowerCase()!="password" & testV == 3)
history.go(-1);
return " ";
}
</script>
</body></html>
32 changes: 32 additions & 0 deletions web/smarthome.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@

$lines = file('/var/www/html/openWB/openwb.conf');
foreach($lines as $line) {
if(strpos($line, "settingspw=") !== false) {
list(, $settingspwold) = explode("=", $line, 2);
}
if(strpos($line, "settingspwakt=") !== false) {
list(, $settingspwaktold) = explode("=", $line, 2);
}

if(strpos($line, "hook1_ausverz=") !== false) {
list(, $hook1_ausverzold) = explode("=", $line, 2);
}
Expand Down Expand Up @@ -744,4 +751,29 @@ function display_verbraucher2 () {


</div>
<script>
var settingspwaktold = <?php echo $settingspwaktold ?>;

var settingspwold = <?php echo $settingspwold ?>;
if ( settingspwaktold == 1 ) {
passWord();
}
function passWord() {
var testV = 1;
var pass1 = prompt('Einstellungen geschützt, bitte Password eingeben:','');

while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == settingspwold) {
break;
}
testV+=1;
var pass1 = prompt('Passwort falsch','Password');
}
if (pass1.toLowerCase()!="password" & testV == 3)
history.go(-1);
return " ";
}
</script>
</body></html>
8 changes: 8 additions & 0 deletions web/tools/savemisc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
$result .= 'pushbenachrichtigung='.$_POST[pushbenachrichtigung]."\n";
$writeit = '1';
}
if(strpos($line, "settingspw=") !== false) {
$result .= 'settingspw=\''.$_POST[settingspw]."'\n";
$writeit = '1';
}
if(strpos($line, "pushbstartl=") !== false) {
$result .= 'pushbstartl='.$_POST[pushbstartl]."\n";
$writeit = '1';
Expand Down Expand Up @@ -210,6 +214,10 @@
if(strpos($line, "ledsakt=") !== false) {
$result .= 'ledsakt='.$_POST[ledsakt]."\n";
$writeit = '1';
}
if(strpos($line, "settingspwakt=") !== false) {
$result .= 'settingspwakt='.$_POST[settingspwakt]."\n";
$writeit = '1';
}
if ( $writeit == '0') {
$result .= $line;
Expand Down
13 changes: 12 additions & 1 deletion web/values.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@
if(strpos($line, "displayconfigured=") !== false) {
list(, $displayconfiguredold) = explode("=", $line, 2);
}
if(strpos($line, "displaypinaktiv=") !== false) {
list(, $displaypinaktivold) = explode("=", $line);
}

if(strpos($line, "displaypincode=") !== false) {
list(, $displaypincodeold) = explode("=", $line);
}
if(strpos($line, "settingspw=") !== false) {
list(, $settingspwold) = explode("=", $line);
}
}
$displaypincodeold = str_replace("\n", '', $displaypincodeold);
$themeold = preg_replace('~[\r\n]+~', '', $themeold);
$lastregelungaktiv = file_get_contents('/var/www/html/openWB/ramdisk/lastregelungaktiv');
$lademodusold = file_get_contents('/var/www/html/openWB/ramdisk/lademodus');
Expand All @@ -137,7 +148,7 @@
$soc1vorhanden = file_get_contents('/var/www/html/openWB/ramdisk/soc1vorhanden');
$verbraucher1vorhanden = file_get_contents('/var/www/html/openWB/ramdisk/verbraucher1vorhanden');
$verbraucher2vorhanden = file_get_contents('/var/www/html/openWB/ramdisk/verbraucher2vorhanden');

$settingspwold = str_replace("\n", '', $settingspwold);

$owbversion = file_get_contents('/var/www/html/openWB/web/version');
if (isset($_GET[theme])) {
Expand Down
2 changes: 1 addition & 1 deletion web/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.597 Beta
1.598 Beta

0 comments on commit a692c26

Please sign in to comment.