Geofency Iphone Lokalisierung, Nach Hause Kommen etc.

Mittlerweile gibt es im Forum ja einige Geofency Beiträge.
Die neue Geofency Version (appstore: Geofency) läuft nun absolut stabil, genau und auch ohne den Akku zu schmälern.

Gefency kann bestimmte URLs aufrufen, nachdem das IPHONE einen bestimmten Ort verlassen oder betreten hat.
Meine IPS Lösung hier:

[ol]
[li]Neuen Ordner webfront\user\geofency
[/li][li]index.php rein -fertig
[/li][li]settings.ips.php wird benötigt: (siehe hier:http://www.ip-symcon.de/forum/threads/20529-Script-(Klasse)-um-dauerhaft-Variablen-bzw-Arrays-zu-speichern?highlight=settings.ips.php)
[/li][/ol]

INDEX.PHP


<?php
  // Geofency IPS Script für IP-Symcon
  include "../../../scripts/settings.ips.php"; // ggf. Pfad anpassen (Siehe http://www.ip-symcon.de/forum/threads/20529)
  
  $CONF["logfile"]            = "./geofency.log";       // Pfad zum schreiben von LogFiles
  $CONF["AUTH_USER"]          = "";                     // Derzeit nicht unterstützt bzw. beta.
  $CONF["AUTH_PW"]            = "";                     // 
  $CONF["ScriptID"]           = 58228;                  // Script ID oder auch andere OBjektID unter der die Variablen in IPS erzeugt werden.
  $CONF["CreateLocationVars"] = true;                   // erzeuge Variable mit Positionsinfo unterhalb ID (s.o.) (MultiVar beachten!) 
  $CONF["MultiVar"]           = false;                   // wenn true, wird pro Lokation eine Bool-Variable angelegt, sonst eine String mit Position
  $CONF["AllowedDevices"]     = Array("IphoneMax","IphoneMoritz"); // List of allowed Devices
  $CONF["PosUnknown"]         = "unbekannt";            // text for unknown Positoin (set when leaving)
  $CONF["debug"]              = true;                   // schreibt Logs (s.o.)
  
  
  $set = new Settings;
  $testmode = (@$_GET["test"] == "1")? true : false;
  logentry("NEW REQUEST -------------------------------------------------------------");
  if($CONF["debug"]){
    logentry("Writing Debug Log entries:");
    file_put_contents("./dbg.log", date('Y-m-d H:i:s')." NEW Action: ---------------------------
", FILE_APPEND);
    file_put_contents("./dbg.log", "SERVER:
".print_r($_SERVER,true)."
", FILE_APPEND);
    file_put_contents("./dbg.log", "GET:
".print_r($_GET,true)."
", FILE_APPEND);
    file_put_contents("./dbg.log", "POST:
".print_r($_POST,true)."
", FILE_APPEND);
  }
  
  //Prüfen, ob Authentifizierung
  if(!empty($CONF["AUTH_USER"])){
    logentry("Authentication active");
    if (empty($_SERVER['PHP_AUTH_USER'])) {
        logentry("ERROR: Client does not send basic auth user - requesting authentication.");
        header('WWW-Authenticate: Basic realm="Geofency Submit"');
        header('HTTP/1.0 401 Unauthorized');
        echo '<h1>Not Authorized</h2>';
        die;
    } elseif( ($_SERVER['PHP_AUTH_USER'] == $CONF["AUTH_USER"]) && 
              ($_SERVER['PHP_AUTH_PW']   == $CONF["AUTH_PW"]) ) {
              logentry("Authentication successfull. Continue...");
            // Alles passt - nichts weiter tun.
    } else {
        logentry("ERROR: Wrong authentication credentials. EXIT.");
        header('WWW-Authenticate: Basic realm="Geofency Submit"');
        header('HTTP/1.0 401 Unauthorized');
        echo '<h1>Not Authorized</h2>';
        die;
    }
  }
  
  $a_track = $set->getValue("TRACKING", $CONF["ScriptID"]);
  
  // Ein paar Prüfungen 
  if((!stristr($_SERVER["HTTP_USER_AGENT"],"Geofency")) && (!$testmode) ){
      logentry("Wrong Client submitted. EXIT.");
      header("Status: 403"); 
      die("WRONG CLIENT");
  }
  // Check if Device is sent and correct
  if(!$testmode){
      if (isset($_GET["device"])) {
        $t_device = $_GET["device"];
        logentry("Recieved GET Device: $t_device");
      } else {
        logentry("ERROR. No Device is submitted.");
        header("Status: 403");
        die("No Device given");
      }
  } else {
    $t_device = "Test";
    logentry("Testmode Active. Test Device set.");
  }
  
  // Check Allowed Device
  if(!in_array($t_device, $CONF["AllowedDevices"]) && ($t_device != "Test")){
      logentry("ERROR: Device not allowed: $t_device");
      header("Status: 403"); 
      die("Device Not Allowed");
  }
  if($testmode){
    $t_date       = "2013-12-04T12:14:37Z"; 
    $t_entry      = (@"" == "1")? true : false;
    $t_location   = "Aesculap";  
    $t_locationID = "5C780537-21E6-41CB-ABFE-5A260AAD4BB3";
    $t_long       = 1.1111 ;
    $t_lat        = 2.2222 ;
  } else {
    $t_date       = @$_POST["date"];
    $t_entry      = (@$_POST["entry"] == "1")? true : false;
    $t_location   = @$_POST["name"];
    $t_locationID = @$_POST["id"];
    $t_long       = @$_POST["longitude"];
    $t_lat        = @$_POST["latitude"];
    logentry("Recieved data: Date: $t_date, Entry: $t_entry, Location: $t_location, LocationID: $t_locationID, Long: $t_long, Lat: $t_lat");
  }
  // IPS Array schreiben
  $a_track[$t_device] = Array("update" => time(), "date" => $t_date, "entry" => $t_entry, "location" => $t_location, "locationID" => $t_locationID, "longitude" => $t_long, "latitude" => $t_lat);
  $set->setValue("TRACKING", $a_track, $CONF["ScriptID"]);
  logentry("Settings DB updated.");
  
  if($CONF["CreateLocationVars"] && (!empty($t_location))){
      if($CONF["MultiVar"] == true){
        logentry("Creating IPS Variable $t_location");
        $id = CreateVariableByName($CONF["ScriptID"],$t_device." - ".utf8_decode($t_location) ,0);
        setValue($id, $t_entry);
        logentry("Value set to: $t_entry");
      } else {
        logentry("Creating IPS Location String Variable $t_device");
        $id = CreateVariableByName($CONF["ScriptID"], $t_device, 3); //typ Sring
        $position = ($t_entry)? trim(utf8_decode($t_location)) : $CONF["PosUnknown"];
        setValue($id, $position);
        logentry("$t_device Value set to: ".$position);
      }
  }
  // Create Log String
  $lgw = date('Y-m-d H:i:s') . ", ActionDate: ".$t_date.", Device: ".$t_device.", Location: ". $t_location . ", LocationID: ".$t_locationID.", Entry: ".$t_entry.", Longitude: ".$t_long.", Latitude: ".$t_lat."
";
  logentry("Writing log entry: $lgw");
  if(!empty($CONF["logfile"]))file_put_contents($CONF["logfile"], $lgw, FILE_APPEND);
  logentry("SUCESS.");
  echo "SUCCESS";
  
  function logentry($msg = ""){
    global $CONF;
    if($CONF["debug"])file_put_contents("./dbg.log", date('Y-m-d H:i:s').": ".$msg."
", FILE_APPEND);
  }

	function CreateVariableByName($id, $name, $type, $profile = "")
	{
		# type: 0=boolean, 1 = integer, 2 = float, 3 = string;
	    global $_IPS;
	    $vid = @IPS_GetVariableIDByName($name, $id);
	    if($vid === false)
	    {
	        $vid = IPS_CreateVariable($type);
	        IPS_SetParent($vid, $id);
	        IPS_SetName($vid, $name);
	        IPS_SetInfo($vid, "this variable was created by script #".$_IPS['SELF']);
	        if($profile !== "") { IPS_SetVariableCustomProfile($vid, $profile); }
	    }
	    return $vid;
	}  
  
?>

in der Geofency App im IPhone gibt man dann folgendes beim Webhook einer Lokation an:
Event-URL Einstellung ->
Mitteilung bei Eintritt - AN
URL http://mydynhost.irgendwas.com:8080/user/geofency/?device=IphoneMax

Mitteilung bei Austritt - AN
URL http://mydynhost.irgendwas.com:8080/user/geofency/?device=IphoneMax

Fertig.

Und so sieht das dann in IPS aus:
user.png
Hier mit $CONF[„MultiVar“] = false (also Eine Variable pro Gerät mit Inhalt Position)

Ein Ereignis mit bedingung = zuhause bedeutet dann den start des scriptes Alarmanlage ausschalten.
Dh. komme ich in den Radius meines Hauses, wird die Alarmanlage deaktiviert :slight_smile:

Das ganze Script kann man noch kann man noch etwas schützen dh. Kennwort etc. damit kein böswilliger es aufruft oder noch Zusatzdaten abfragen etc.
Falls es Probleme gibt, kann man auch mal in das Log einsicht nehmen:
gefency.log
oder
dbg.log (wenn aktiviert)

Hi,

echt coole Idee.

hab mir gleich mal die App aufs iPhone geladen.

leider scheitere ich aber noch an der IPS Anbindung.

Habe das index.php Skript erstellt.


 <?php
  // Geofency IPS Script für IP-Symcon
  include "C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php"; // ggf. Pfad anpassen (Siehe http://www.ip-symcon.de/forum/threads/20529)

  $CONF["logfile"]            = "./geofency.log";       // Pfad zum schreiben von LogFiles
  $CONF["AUTH_USER"]          = "";                     // Derzeit nicht unterstützt bzw. beta.
  $CONF["AUTH_PW"]            = "";                     //
  $CONF["ScriptID"]           = 58228;                  // Script ID oder auch andere OBjektID unter der die Variablen in IPS erzeugt werden.
  $CONF["CreateLocationVars"] = true;                   // erzeuge Variable mit Positionsinfo unterhalb ID (s.o.) (MultiVar beachten!)
  $CONF["MultiVar"]           = false;                   // wenn true, wird pro Lokation eine Bool-Variable angelegt, sonst eine String mit Position
  $CONF["AllowedDevices"]     = Array("IphoneMax","IphoneMoritz"); // List of allowed Devices
  $CONF["PosUnknown"]         = "unbekannt";            // text for unknown Positoin (set when leaving)
  $CONF["debug"]              = true;                   // schreibt Logs (s.o.)


  $set = new Settings;
  $testmode = (@$_GET["test"] == "1")? true : false;
  logentry("NEW REQUEST -------------------------------------------------------------");
  if($CONF["debug"]){
    logentry("Writing Debug Log entries:");
    file_put_contents("./dbg.log", date('Y-m-d H:i:s')." NEW Action: ---------------------------
", FILE_APPEND);
    file_put_contents("./dbg.log", "SERVER:
".print_r($_SERVER,true)."
", FILE_APPEND);
    file_put_contents("./dbg.log", "GET:
".print_r($_GET,true)."
", FILE_APPEND);
    file_put_contents("./dbg.log", "POST:
".print_r($_POST,true)."
", FILE_APPEND);
  }

  //Prüfen, ob Authentifizierung
  if(!empty($CONF["AUTH_USER"])){
    logentry("Authentication active");
    if (empty($_SERVER['PHP_AUTH_USER'])) {
        logentry("ERROR: Client does not send basic auth user - requesting authentication.");
        header('WWW-Authenticate: Basic realm="Geofency Submit"');
        header('HTTP/1.0 401 Unauthorized');
        echo '<h1>Not Authorized</h2>';
        die;
    } elseif( ($_SERVER['PHP_AUTH_USER'] == $CONF["AUTH_USER"]) &&
              ($_SERVER['PHP_AUTH_PW']   == $CONF["AUTH_PW"]) ) {
              logentry("Authentication successfull. Continue...");
            // Alles passt - nichts weiter tun.
    } else {
        logentry("ERROR: Wrong authentication credentials. EXIT.");
        header('WWW-Authenticate: Basic realm="Geofency Submit"');
        header('HTTP/1.0 401 Unauthorized');
        echo '<h1>Not Authorized</h2>';
        die;
    }
  }

  $a_track = $set->getValue("TRACKING", $CONF["ScriptID"]);

  // Ein paar Prüfungen
  if((!stristr($_SERVER["HTTP_USER_AGENT"],"Geofency")) && (!$testmode) ){
      logentry("Wrong Client submitted. EXIT.");
      header("Status: 403");
      die("WRONG CLIENT");
  }
  // Check if Device is sent and correct
  if(!$testmode){
      if (isset($_GET["device"])) {
        $t_device = $_GET["device"];
        logentry("Recieved GET Device: $t_device");
      } else {
        logentry("ERROR. No Device is submitted.");
        header("Status: 403");
        die("No Device given");
      }
  } else {
    $t_device = "Test";
    logentry("Testmode Active. Test Device set.");
  }

  // Check Allowed Device
  if(!in_array($t_device, $CONF["AllowedDevices"]) && ($t_device != "Test")){
      logentry("ERROR: Device not allowed: $t_device");
      header("Status: 403");
      die("Device Not Allowed");
  }
  if($testmode){
    $t_date       = "2013-12-04T12:14:37Z";
    $t_entry      = (@"" == "1")? true : false;
    $t_location   = "Aesculap";
    $t_locationID = "5C780537-21E6-41CB-ABFE-5A260AAD4BB3";
    $t_long       = 1.1111 ;
    $t_lat        = 2.2222 ;
  } else {
    $t_date       = @$_POST["date"];
    $t_entry      = (@$_POST["entry"] == "1")? true : false;
    $t_location   = @$_POST["name"];
    $t_locationID = @$_POST["id"];
    $t_long       = @$_POST["longitude"];
    $t_lat        = @$_POST["latitude"];
    logentry("Recieved data: Date: $t_date, Entry: $t_entry, Location: $t_location, LocationID: $t_locationID, Long: $t_long, Lat: $t_lat");
  }
  // IPS Array schreiben
  $a_track[$t_device] = Array("update" => time(), "date" => $t_date, "entry" => $t_entry, "location" => $t_location, "locationID" => $t_locationID, "longitude" => $t_long, "latitude" => $t_lat);
  $set->setValue("TRACKING", $a_track, $CONF["ScriptID"]);
  logentry("Settings DB updated.");

  if($CONF["CreateLocationVars"] && (!empty($t_location))){
      if($CONF["MultiVar"] == true){
        logentry("Creating IPS Variable $t_location");
        $id = CreateVariableByName($CONF["ScriptID"],$t_device." - ".utf8_decode($t_location) ,0);
        setValue($id, $t_entry);
        logentry("Value set to: $t_entry");
      } else {
        logentry("Creating IPS Location String Variable $t_device");
        $id = CreateVariableByName($CONF["ScriptID"], $t_device, 3); //typ Sring
        $position = ($t_entry)? trim(utf8_decode($t_location)) : $CONF["PosUnknown"];
        setValue($id, $position);
        logentry("$t_device Value set to: ".$position);
      }
  }
  // Create Log String
  $lgw = date('Y-m-d H:i:s') . ", ActionDate: ".$t_date.", Device: ".$t_device.", Location: ". $t_location . ", LocationID: ".$t_locationID.", Entry: ".$t_entry.", Longitude: ".$t_long.", Latitude: ".$t_lat."
";
  logentry("Writing log entry: $lgw");
  if(!empty($CONF["logfile"]))file_put_contents($CONF["logfile"], $lgw, FILE_APPEND);
  logentry("SUCESS.");
  echo "SUCCESS";

  function logentry($msg = ""){
    global $CONF;
    if($CONF["debug"])file_put_contents("./dbg.log", date('Y-m-d H:i:s').": ".$msg."
", FILE_APPEND);
  }

    function CreateVariableByName($id, $name, $type, $profile = "")
    {
        # type: 0=boolean, 1 = integer, 2 = float, 3 = string;
        global $_IPS;
        $vid = @IPS_GetVariableIDByName($name, $id);
        if($vid === false)
        {
            $vid = IPS_CreateVariable($type);
            IPS_SetParent($vid, $id);
            IPS_SetName($vid, $name);
            IPS_SetInfo($vid, "this variable was created by script #".$_IPS['SELF']);
            if($profile !== "") { IPS_SetVariableCustomProfile($vid, $profile); }
        }
        return $vid;
    }

?>

Leider bekomme ich beim Ausführen diese fehlerzeilen…

Fatal error: Uncaught exception ‚PDOException‘ with message ‚could not find driver‘ in C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php:54
Stack trace:
#0 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(54): PDO->__construct(‚sqlite:C:\IPS\I…‘)
#1 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(44): settings->initDB()
#2 C:\IPS\IPS-PC\IPS\ips\scripts\54871.ips.php(16): settings->__construct()
#3 {main}
thrown in C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php on line 54
Abort Processing during Fatal-Error: Uncaught exception ‚PDOException‘ with message ‚could not find driver‘ in C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php:54
Stack trace:
#0 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(54): PDO->__construct(‚sqlite:C:\IPS\I…‘)
#1 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(44): settings->initDB()
#2 C:\IPS\IPS-PC\IPS\ips\scripts\54871.ips.php(16): settings->__construct()
#3 {main}
thrown
Error in Script C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php on Line 54

Das ist mein Settings Skript


 <?
/* Settings Class 2013-01-27--------------------------------------------------
    Klasse zum Speichern von Werten in der Datenbank abhängig vom Script

    Beispiel:

    Einbindung in Script:
    require_once "settings.ips.php";
    $set = new settings();

    Schreiben:
    $set->SetValue([NAME], [WERT], [INSTANZ])

    Lesen:
    $set->GetValue([NAME], [INSTANZ])

    Löschen:
    $set->DeleteValue([NAME], [INSTANZ])

    [NAME]:    Name der Einstellung (Stringfeld, max. 25 Stellen)
    [WERT]:    Wert der zur Einstellung gespeichert werden soll (
               String oder Array, max 28kb)
    [INSTANZ]: InstanzID zu der die Einstellung gehört. Wird nichts angegeben, wird
                  die Instanz ID aus $_IPS["SELF"] ermittelt

    Alle Daten anzeigen (HTML Tabelle):
    echo $set->ShowEntries(); // Rückgabe STRING(HTML Tabelle)

    ChangeLog:__________________________________________________________________
    Version 1.0 : Initial
    Version 1.1 : Now with Arrays
    Version 1.2 : DeleteValue added
    Version 1.3 : File Path adjusted, delete with % supported

*/
 class settings {
    // Falls es Probleme mit dem Pfad gibt, bitte ggf. anpassen. bzw. das user (ip-symcon\user) Verzeichnis erstellen!!!!
    var $CONF_DB = "../user/settings.sqlite";
    var $DBH = "";
    function __construct(){
        $this->CONF_DB = __DIR__ . "/".$this->CONF_DB;
        // Verzeichnis ggf. erstellen
        @mkdir(dirname($this->CONF_DB));
        $this->initDB();
    }

    public function destroyDB(){

        $this->DBH = null;
        unlink($this->CONF_DB);
    }

   private function initDB() {
           $this->DBH = new PDO("sqlite:".$this->CONF_DB);
           $sql = "CREATE TABLE IF NOT EXISTS settings
                    (id       INTEGER PRIMARY KEY,
                        instance INTEGER,
                        name     CHAR(25),
                     value    TEXT,
                        array    INTEGER,
                        changed  INTEGER)";
            $res = $this->DBH->query($sql);
            $this->checkdberr();
    }

    private function checkDBErr(){
          $error = $this->DBH->errorInfo();
          if($error[0] != "" & $error[0] != "00000") {
              print "<p>DATABASE CONNECTION ERROR:</p>";
              print_r($error);
              die;
          } else {
           return true;
          }
    }

     public function setValue($name, $value, $instance = 0){
        $instance = intval($instance);
        if($instance == 0) $instance = $_IPS['SELF'];
        if(intval($instance) == 0) die("Settings SetValue: No Instance given or 0
");
        if(empty($name)) die("Settings SetValue: No Name of attribute given, Abort. 
");

        // Alten Eintrag oder Enträge löschen
        $sql = "SELECT count(*) as anz FROM settings WHERE instance=$instance AND name='$name'";
        $res = $this->DBH->query($sql);
        $row = $res->fetch();
        $rowcount = $row["anz"];
       // Single Einträg in Value
          if(is_array($value)){
              $value = serialize($value); // Serialisieren für Arrays
            $arr=1;
        } else {
           $arr = 0;
        }
        if(strlen($value) > (1024*28))die("Settings SetValue: value to big!
");
        if($rowcount > 1 || $rowcount == 0){
            $sql = "DELETE FROM settings WHERE instance=$instance AND name='$name'";
             $this->DBH->exec($sql);
             $sql = "INSERT INTO settings (instance, name, value, changed, array) VALUES (
                      $instance, '$name', '$value', ".time().", $arr)";

        } else {
           // get ID and update
            $sql = "SELECT * FROM settings WHERE instance=$instance AND name='$name'";
            $res = $this->DBH->query($sql);
            $row = $res->fetch();
           $id = $row["id"];
           $sql = "UPDATE settings set instance=$instance, name='$name', value='$value',
                                        changed=".time().", array=$arr WHERE id=$id";
        }
      $this->DBH->exec($sql);
      $this->checkDBErr();


     }

     public function getValue($name, $instance = 0, $time = false){
        $instance = intval($instance);
        if($instance == 0) $instance = $_IPS['SELF'];
        if(intval($instance) == 0) die("Settings SetValue: No Instance given or 0
");
        if(empty($name)) die("Settings SetValue: No Name of attribute given, Abort. 
");

        // Alten Eintrag oder Enträge löschen
        $sql = "SELECT * FROM settings WHERE instance=$instance AND name='$name' ORDER by instance, name";
        $res = $this->DBH->query($sql);
        $this->checkDBErr();

        $count = 0;
        foreach($res as $row){
            if($row["array"] == 1){
               return unserialize($row["value"]);
            } else {
                if($time){ // Mit Zeitrückgabe
               return Array("VALUE" => $row["value"], "LASTUPDATE"=>$row["changed"]);
                }else{
               return $row["value"];
                }
            }
        }
        if($count == 0){
            return false;
        }
    }
    public function getValueTime($name, $instance = 0){
       return $this->getValue($name, $instance, true);
    }


 public function DeleteValue($name, $instance = 0){
        $instance = intval($instance);
        if($instance == 0) $instance = $_IPS['SELF'];
        if(intval($instance) == 0) die("Settings SetValue: No Instance given or 0
");
        if(empty($name)) die("Settings SetValue: No Name of attribute given, Abort. 
");

        // Alten Eintrag oder Enträge löschen
        $sql = "DELETE FROM settings WHERE instance=$instance AND name LIKE '$name'";
      $this->DBH->exec($sql);
      return $this->checkDBErr();
 }

 public function ShowEntries(){
        $sql = "SELECT * FROM settings ORDER by instance, name";
        $res = $this->DBH->query($sql);
        $this->checkDBErr();

        $count = 0;
        $output = "<table border=1>";
        $output .= "<thead><tr><td>Instance</td><td>Name</td></td><td>Value</td><td>Is Array</td><td>Last Update</td></tr></thead>";
        foreach($res as $row){
           $output .="<tr>";
            $output .=" <td>".@IPS_GetName(intval($row["instance"])).", (".$row["instance"].")</td>
                            <td>".$row["name"]."</td>
                            <td>".$row["value"]."</td>
                            <td>".$row["array"]."</td>
                            <td>".date("d.m.Y, H:i",$row["changed"])."</td>
                         ";
             $output .="</tr>";
        }
          $output .= "</table>";
          return $output;
    }
}


?>


Vielleicht kannst ja mal drüber schauen. Danke schon mal :slight_smile:

Das ist nichts wildes.
Du musst in der PHP.INI noch PDO aktivieren und ggf. IPS neu starten.

seht hier am ende des posts:

Geht das auch mit Geofancy für Andoid?

Hi,

die PHP Datei im IPS Ordner habe ich bereits bearbeitet wie in dem Thread beschrieben.

Die schaut jetzt so aus…


ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ

```php

max_execution_time=30
error_reporting=E_ALL
memory_limit=32M
register_globals=off
extension_dir="C:\IPS\IPS-PC\IPS\ips\ext"
auto_prepend_file="C:\IPS\IPS-PC\IPS\ips\scripts\__autoinclude.inc.php"
extension = php_curl.dll
extension = php_gd2.dll
extension = php_gettext.dll
extension = php_mbstring.dll
extension = php_soap.dll
[DATE]
date.timezone="Europe/Berlin"


Bekomme aber leider noch immer diesen Fehler

Fatal error: Uncaught exception ‚PDOException‘ with message ‚could not find driver‘ in C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php:54
Stack trace:
#0 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(54): PDO->__construct(‚sqlite:C:\IPS\I…‘)
#1 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(44): settings->initDB()
#2 C:\IPS\IPS-PC\IPS\ips\scripts\54871.ips.php(16): settings->__construct()
#3 {main}
thrown in C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php on line 54
Abort Processing during Fatal-Error: Uncaught exception ‚PDOException‘ with message ‚could not find driver‘ in C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php:54
Stack trace:
#0 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(54): PDO->__construct(‚sqlite:C:\IPS\I…‘)
#1 C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php(44): settings->initDB()
#2 C:\IPS\IPS-PC\IPS\ips\scripts\54871.ips.php(16): settings->__construct()
#3 {main}
thrown
Error in Script C:\IPS\IPS-PC\IPS\ips\scripts\settings.ips.php on Line 54

Und wo sind die?

Zitat Zitat von Stele99 Beitrag anzeigen
Das ist nichts wildes.
Du musst in der PHP.INI noch PDO aktivieren und ggf. IPS neu starten.

seht hier am ende des posts:
http://www.ip-symcon.de/forum/thread...787#post185787

extension = php_pdo_sqlite.dll
extension = php_sqlite3.dll
max_execution_time=30 
error_reporting=E_ALL 
memory_limit=32M 
register_globals=off 
extension_dir="C:\IPS\IPS-PC\IPS\ips\ext" 
auto_prepend_file="C:\IPS\IPS-PC\IPS\ips\scripts\__autoinclude.inc.php" 
extension = php_curl.dll 
extension = php_gd2.dll 
extension = php_gettext.dll 
extension = php_mbstring.dll 
extension = php_soap.dll 
extension = php_pdo_sqlite.dll
extension = php_sqlite3.dll
[DATE] 
date.timezone="Europe/Berlin"  

Das müsstest Du einfach mal probieren.
Ich nutze Geofency mit dem iPhone - auf den ersten Blick sieht GeofAncy wie ein Klon aus.
Test the Best…
Leider hab ich keine Androids rumliegen zum testen. Evlt. kann ja ein anderer Member mal mit GeofAncy rumspielen.

Bitte prüfen:

[ul]
[li]Liegen die extension DLLs im extensions im ornder (IP-Symcon\ext)
[/li][li]IPS Dienst neu gestartet?
[/li][/ul]

Heißt das, dass ich alle Dateien mit .dll in den Extension Ordner packen muss? :confused:

Ok, kurz ein paar Grundlagen:
in der PHP.ini kann man definieren, dass PHP ein paar Erweiterungen kennt und nutzt bzw. lädt.
Dazu gehört auch PDO.
Die Erweiterungen sind hier DLL Dateien die in den ext ordner müssen.

Dh. wenn in der PHP.INI die Extension (s.o.) geladen werden soll, dann sucht PHP die Dateien im ext Ordner.
Wenn dort die DLLs nicht liegen, kann die Extension auch nicht geladen werden -> PROBLEM

Die Extensions (DLLs) bekommst du hier alls Download: http://www.ip-symcon.de/forum/threads/16631-PHP-Extensions-f�r-IP-Symcon-2-6-oder-neuer

Also

  1. PHP.INI anpssen
  2. sicherstellen dass die entsprechenden DLL Dateien im ext Ordner sind

So habe alles nochmal zurückgesetzt und nochmal alles von Anfang an gemacht…

Jetzt läuft das index Skript…

Bringt aber diesen Error…

"
Notice: Undefined index: HTTP_USER_AGENT in C:\ips\scripts\index.ips.php on line 52

Warning: Cannot modify header information - headers already sent by (output started at C:\ips\scripts\index.ips.php:1) in C:\ips\scripts\index.ips.php on line 54
WRONG CLIENT
"

Irgendwie gibt’s noch ein Problem mit deinen Ausführungen…

wie kommt es denn zu dem fehler - das ist mir nicht ganz klar.
Das Script von mir - das kannst du eigentlich gar nicht in IPS ausführen. das soll ja über geofency getriggert werden.

Hast Du das script (s.o.) in den ordner: c:\ips\webfront\user\geofency gelegt?

das müsstest du dann so aufrufen können - vom browser!
http://deinrechner:deinIPSPort/user/geofency

Hi,
also ich habe das index.php Skript in den Ordner gelegt. Siehe Anhang.

Und es sieht so aus…


 <?php
  // Geofency IPS Script für IP-Symcon
  include "C:/ips/scripts/settings.ips.php"; // ggf. Pfad anpassen (Siehe http://www.ip-symcon.de/forum/threads/20529)

  $CONF["logfile"]            = "./geofency.log";       // Pfad zum schreiben von LogFiles
  $CONF["AUTH_USER"]          = "";                     // Derzeit nicht unterstützt bzw. beta.
  $CONF["AUTH_PW"]            = "";                     //
  $CONF["ScriptID"]           = 37696 /*[Skripte\Geofency]*/;                  // Script ID oder auch andere OBjektID unter der die Variablen in IPS erzeugt werden.
  $CONF["CreateLocationVars"] = true;                   // erzeuge Variable mit Positionsinfo unterhalb ID (s.o.) (MultiVar beachten!)
  $CONF["MultiVar"]           = false;                   // wenn true, wird pro Lokation eine Bool-Variable angelegt, sonst eine String mit Position
  $CONF["AllowedDevices"]     = Array("IphoneMax","IphoneMoritz"); // List of allowed Devices
  $CONF["PosUnknown"]         = "unbekannt";            // text for unknown Positoin (set when leaving)
  $CONF["debug"]              = true;                   // schreibt Logs (s.o.)


  $set = new Settings;
  $testmode = (@$_GET["test"] == "1")? true : false;
  logentry("NEW REQUEST -------------------------------------------------------------");
  if($CONF["debug"]){
    logentry("Writing Debug Log entries:");
    file_put_contents("./dbg.log", date('Y-m-d H:i:s')." NEW Action: ---------------------------
", FILE_APPEND);
    file_put_contents("./dbg.log", "SERVER:
".print_r($_SERVER,true)."
", FILE_APPEND);
    file_put_contents("./dbg.log", "GET:
".print_r($_GET,true)."
", FILE_APPEND);
    file_put_contents("./dbg.log", "POST:
".print_r($_POST,true)."
", FILE_APPEND);
  }

  //Prüfen, ob Authentifizierung
  if(!empty($CONF["AUTH_USER"])){
    logentry("Authentication active");
    if (empty($_SERVER['PHP_AUTH_USER'])) {
        logentry("ERROR: Client does not send basic auth user - requesting authentication.");
        header('WWW-Authenticate: Basic realm="Geofency Submit"');
        header('HTTP/1.0 401 Unauthorized');
        echo '<h1>Not Authorized</h2>';
        die;
    } elseif( ($_SERVER['PHP_AUTH_USER'] == $CONF["AUTH_USER"]) &&
              ($_SERVER['PHP_AUTH_PW']   == $CONF["AUTH_PW"]) ) {
              logentry("Authentication successfull. Continue...");
            // Alles passt - nichts weiter tun.
    } else {
        logentry("ERROR: Wrong authentication credentials. EXIT.");
        header('WWW-Authenticate: Basic realm="Geofency Submit"');
        header('HTTP/1.0 401 Unauthorized');
        echo '<h1>Not Authorized</h2>';
        die;
    }
  }

  $a_track = $set->getValue("TRACKING", $CONF["ScriptID"]);

  // Ein paar Prüfungen
  if((!stristr($_SERVER["HTTP_USER_AGENT"],"Geofency")) && (!$testmode) ){
      logentry("Wrong Client submitted. EXIT.");
      header("Status: 403");
      die("WRONG CLIENT");
  }
  // Check if Device is sent and correct
  if(!$testmode){
      if (isset($_GET["device"])) {
        $t_device = $_GET["device"];
        logentry("Recieved GET Device: $t_device");
      } else {
        logentry("ERROR. No Device is submitted.");
        header("Status: 403");
        die("No Device given");
      }
  } else {
    $t_device = "Test";
    logentry("Testmode Active. Test Device set.");
  }

  // Check Allowed Device
  if(!in_array($t_device, $CONF["AllowedDevices"]) && ($t_device != "Test")){
      logentry("ERROR: Device not allowed: $t_device");
      header("Status: 403");
      die("Device Not Allowed");
  }
  if($testmode){
    $t_date       = "2013-12-04T12:14:37Z";
    $t_entry      = (@"" == "1")? true : false;
    $t_location   = "Aesculap";
    $t_locationID = "5C780537-21E6-41CB-ABFE-5A260AAD4BB3";
    $t_long       = 1.1111 ;
    $t_lat        = 2.2222 ;
  } else {
    $t_date       = @$_POST["date"];
    $t_entry      = (@$_POST["entry"] == "1")? true : false;
    $t_location   = @$_POST["name"];
    $t_locationID = @$_POST["id"];
    $t_long       = @$_POST["longitude"];
    $t_lat        = @$_POST["latitude"];
    logentry("Recieved data: Date: $t_date, Entry: $t_entry, Location: $t_location, LocationID: $t_locationID, Long: $t_long, Lat: $t_lat");
  }
  // IPS Array schreiben
  $a_track[$t_device] = Array("update" => time(), "date" => $t_date, "entry" => $t_entry, "location" => $t_location, "locationID" => $t_locationID, "longitude" => $t_long, "latitude" => $t_lat);
  $set->setValue("TRACKING", $a_track, $CONF["ScriptID"]);
  logentry("Settings DB updated.");

  if($CONF["CreateLocationVars"] && (!empty($t_location))){
      if($CONF["MultiVar"] == true){
        logentry("Creating IPS Variable $t_location");
        $id = CreateVariableByName($CONF["ScriptID"],$t_device." - ".utf8_decode($t_location) ,0);
        setValue($id, $t_entry);
        logentry("Value set to: $t_entry");
      } else {
        logentry("Creating IPS Location String Variable $t_device");
        $id = CreateVariableByName($CONF["ScriptID"], $t_device, 3); //typ Sring
        $position = ($t_entry)? trim(utf8_decode($t_location)) : $CONF["PosUnknown"];
        setValue($id, $position);
        logentry("$t_device Value set to: ".$position);
      }
  }
  // Create Log String
  $lgw = date('Y-m-d H:i:s') . ", ActionDate: ".$t_date.", Device: ".$t_device.", Location: ". $t_location . ", LocationID: ".$t_locationID.", Entry: ".$t_entry.", Longitude: ".$t_long.", Latitude: ".$t_lat."
";
  logentry("Writing log entry: $lgw");
  if(!empty($CONF["logfile"]))file_put_contents($CONF["logfile"], $lgw, FILE_APPEND);
  logentry("SUCESS.");
  echo "SUCCESS";

  function logentry($msg = ""){
    global $CONF;
    if($CONF["debug"])file_put_contents("./dbg.log", date('Y-m-d H:i:s').": ".$msg."
", FILE_APPEND);
  }

    function CreateVariableByName($id, $name, $type, $profile = "")
    {
        # type: 0=boolean, 1 = integer, 2 = float, 3 = string;
        global $_IPS;
        $vid = @IPS_GetVariableIDByName($name, $id);
        if($vid === false)
        {
            $vid = IPS_CreateVariable($type);
            IPS_SetParent($vid, $id);
            IPS_SetName($vid, $name);
            IPS_SetInfo($vid, "this variable was created by script #".$_IPS['SELF']);
            if($profile !== "") { IPS_SetVariableCustomProfile($vid, $profile); }
        }
        return $vid;
    }

?>


Wenn ich jetzt das in den Browser eingebe…

http://192.168.178.xxx:xx/user/geofency/

Dann bringt mir der Browser einen Fehler…

„Warning: Cannot modify header information - headers already sent by (output started at C:\ips\webfront\user\geofency\index.php:1) in C:\ips\webfront\user\geofency\index.php on line 54
WRONG CLIENT“

OK dann sieht es doch gar nicht so schlecht aus:
Die aussgabe WRONG CLIENT KOMMT heirvon - Das Programm prüft, ob es von Geofency aufgerufen wurde!:
Probier mal das script so aufzurufen … index.php?testmode=1

hiervon kommt die ausgabe:
// Ein paar Prüfungen
if((!stristr($_SERVER[„HTTP_USER_AGENT“],„Geofency“)) && (!$testmode) ){
logentry(„Wrong Client submitted. EXIT.“);
header(„Status: 403“);
die(„WRONG CLIENT“);

Wie rufst du überhaupt das script auf?
über den webbrowser und wie - oder über das iphone etc . mit dem browser?

Ja habe das Script normal über den Browser meines MacBooks aufgerufen…
Dazu habe ich einfach in die Adresszeile „http://192.168.178.xxx:xx/user/geofency/“ eingegeben…

Edit: das iPhone bringt den selben Fehler

Edit2: Wie meinst du das mit der anderen Adresse?

index.php?testmode=1

So?
http://192.168.178.xxx:xx/index.php?testmode=1
So bekomm ich ein „Not found“ zurück…

also wenn du das script so aufruftst:
http://192.168.178.xxx:xx/user/geofency/index.php?test=1

Hi,

also wenn ich so das Script ausführe…

http://192.168.178.xxx:xx/user/geofency/index.php?testmode=1“

Dann bekomm ich auch wieder

„Warning: Cannot modify header information - headers already sent by (output started at C:\ips\webfront\user\geofency\index.php:1) in C:\ips\webfront\user\geofency\index.php on line 54
WRONG CLIENT“

das ist schon etwas seltsam bei dir…
schick mir mal eine PM mit deiner email-adresse und ich schicke dir das Script mal als datei zu.
Es kann sein, dass du irgendwo vor dem ersten <?php ein leerzeichen hast

es muss http://127.0.0.1:82/user/geofency/index.php?test=1
nicht „testmode“ heissen.

einmal ausführen zeigt nochmal einen fehler da noch keine variable angelegt wurde.
zweites mal ausführen erzeugt „success“

Edit: erledigt