Dr. Arne Jachens

Set up the Raspberry Pi

no warranty for any of the provided information

HV_Admin_Login

Function to login/logoff the user.
Special feature is the increasing delay if someone should try to steal the password.

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
function HV_Admin_Login(){
  include_once("HV_config.php");
    global $debug;
  /* log off */
  if (isset($_POST['logout']) AND $_POST['logout']=="logout"){
    $_SESSION['IamGod']=FALSE;
  }
  /* log in */
  if (isset($_POST['login'])  AND $_POST['login'] =="login" AND $_POST['pwd_tmp']==$adminpwd){
    $_SESSION['IamGod']=TRUE;
  }
  /* if someone tries to steal the login, increase delay */
  if(!isset($_SESSION['IamGod']) OR !$_SESSION['IamGod']){
    if(isset($_SESSION['loginCount'])){
      $_SESSION['loginCount']++;
    }else{
      $_SESSION['loginCount']=1;
    }
    if($_SESSION['loginCount']>0){
      $time=time();
      time_sleep_until($time+$_SESSION['loginCount']);
    }
    if(isset($_GET['mode'])){
      $log="&mode=".$_GET['mode']."&file=".$_GET['file'];
    }else{
      $log="";
    }
    $form = "\n\n <p></p><form action='?what2do=menu".$log."' method='POST'>
              <p align='center'>";
    $form.= "<input name='pwd_tmp' type='password' size='10' maxlength='10'>
               <input name='login' type='submit' value='login'>";
    $form.= "</p></form>";
  }else{
    $_SESSION['loginCount']=0;
    $form = "\n\n <p></p><form action='?what2do=login' method='POST'>
             <p align='center'>";
    $form.= "<a href='index.php?what2do=menu'>Control Panel</a>   ";
    $form.= "<input name='pwd_tmp' type='hidden' value='logout'>
             <INPUT name='logout' TYPE=submit VALUE='logout'>";
    $form.= "   <a href='index.php?what2do=showServiceLog'>Service Intervall</a>";
    $form.= "   <a href='index.php?what2do=editParams'>Parameter</a>";
    $form.= "</p></form>";
  }


    if($debug){
        echo "<p><aj>HV_Admin_Login( )</aj></p>\n";
    }
  
  return $form;
}
?>

python

1HvcControl.py
2HvcHCSR04ultrasonic.py
3HvcMain.py
4HvcMotorDriver.py
5HvcOneWire.py
6HvcOperationMode.py
7HvcRaw2phys.py
8HvcReadSPI.py
9HvcSendI2C.py
10HvcSetGPIO.py
11HvcTables.py
12HvcWeather.py
13makeDoc.py

php

1HV_Admin_Login.php
2HV_colorMap.php
3HV_composeH2Oplot.php
4HV_config.php
5HV_H2Olevel.php
6HV_readOperationState.php
7HV_restart.php
8HV_serviceLog.php
9HV_setParameters.php
10HV_showHouse.php
11HV_showLog.php
12HV_showWeatherForecast.php
13HV_TempCal.php
14index.php
15readFilenames.php
16readNamedData.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.