Skip to content

Geo Loacation

PHP
  • In den exif Daten können sich die GPS Daten des Standortes verstecken. Die wollen wir haben 😉

     <?php
       
      //Test ob in der Datei GPS Daten drin sind   
      $img = '../upload/IMG_20181117_104123_ergebnis_34.jpg'; //or $fileName='xxxxxxxxx';
      $test = exif_read_data($img, 0, true);
      var_dump($test);
     
     echo "<br>";
     echo "<br>";
     
      $img = '../upload/IMG_20181206_153916.jpg'; //or $fileName='xxxxxxxxx';
      $test = exif_read_data($img, 0, true);
      var_dump($test);
     
           
      /**
      * get_image_location
      * Returns an array of latitude and longitude from the Image file
      * @param $image file path
      * @return multitype:array|boolean
      */
     function get_image_location($image = ''){
         $exif = exif_read_data($image, 0, true);
         if($exif && isset($exif['GPS'])){
             $GPSLatitudeRef = $exif['GPS']['GPSLatitudeRef'];
             $GPSLatitude    = $exif['GPS']['GPSLatitude'];
             $GPSLongitudeRef= $exif['GPS']['GPSLongitudeRef'];
             $GPSLongitude   = $exif['GPS']['GPSLongitude'];
             
             $lat_degrees = count($GPSLatitude) > 0 ? gps2Num($GPSLatitude[0]) : 0;
             $lat_minutes = count($GPSLatitude) > 1 ? gps2Num($GPSLatitude[1]) : 0;
             $lat_seconds = count($GPSLatitude) > 2 ? gps2Num($GPSLatitude[2]) : 0;
             
             $lon_degrees = count($GPSLongitude) > 0 ? gps2Num($GPSLongitude[0]) : 0;
             $lon_minutes = count($GPSLongitude) > 1 ? gps2Num($GPSLongitude[1]) : 0;
             $lon_seconds = count($GPSLongitude) > 2 ? gps2Num($GPSLongitude[2]) : 0;
             
             $lat_direction = ($GPSLatitudeRef == 'W' or $GPSLatitudeRef == 'S') ? -1 : 1;
             $lon_direction = ($GPSLongitudeRef == 'W' or $GPSLongitudeRef == 'S') ? -1 : 1;
             
             $latitude = $lat_direction * ($lat_degrees + ($lat_minutes / 60) + ($lat_seconds / (60*60)));
             $longitude = $lon_direction * ($lon_degrees + ($lon_minutes / 60) + ($lon_seconds / (60*60)));
     
             return array('latitude'=>$latitude, 'longitude'=>$longitude);
         }else{
             return false;
         }
     }
     
     function gps2Num($coordPart){
         $parts = explode('/', $coordPart);
         if(count($parts) <= 0)
         return 0;
         if(count($parts) == 1)
         return $parts[0];
         return floatval($parts[0]) / floatval($parts[1]);
     }
     
     
     $imageURL = "../upload/IMG_20181117_104123_ergebnis_34.jpg";
     //$imageURL = "../upload/IMG_20181201_081430.jpg";
     
     //get location of image
     $imgLocation = get_image_location($imageURL);
     var_dump($imgLocation);
    
    //Fehlerbehandlung
     if ($imgLocation == false) {
         echo "ERROR";
     }
    
     //Ausgabe
     //latitude & longitude
     $imgLat = $imgLocation['latitude'];
     $imgLng = $imgLocation['longitude'];
     echo "<br>";
     echo $imgLat . "<br>";
     echo $imgLng;
    

    Muss noch optimiert werden!

    Quelle: https://www.codexworld.com/get-geolocation-latitude-longitude-from-image-php/

  • PHP - ChatGPT

    PHP
    1
    0 Stimmen
    1 Beiträge
    63 Aufrufe
    Niemand hat geantwortet
  • PHP Webseite lokal einhängen mit sshfs

    PHP
    1
    0 Stimmen
    1 Beiträge
    39 Aufrufe
    Niemand hat geantwortet
  • PHP Installation

    Angeheftet PHP
    3
    0 Stimmen
    3 Beiträge
    517 Aufrufe
    FrankMF

    Falls jemand auch die Warnung in Joomla! bezüglich der php Version 7.4 loswerden möchte, installiert kein php8.1. Damit habe ich eine dicke Fehlermeldung. Es müssen wohl sämtliche Erweiterungen und Templates 8.1 unterstützen, was wohl derzeit noch nicht der Fall ist. Nehmt 8.0, das läuft bei mir aktuell.

    apt install php8.0-common php8.0-mysql php8.0-opcache php8.0-readline php8.0-xml php8.0-xsl php8.0-zip apt install php8.0-cli php8.0-curl php8.0-gd php8.0-intl php8.0-mbstring php8.0-redis apt install php8.0-bcmath php8.0-gmp php8.0-imagick apt install php8.0-fpm
  • Yubikey als 2FA

    PHP
    3
    0 Stimmen
    3 Beiträge
    256 Aufrufe
    FrankMF

    Die ersten 12 Stellen eines Yubikeys sind immer gleich. Diese 12 Stellen speichern wir in einer Datenbank.

    $otp = substr ($otpKey, 0, 12);

    In der Datenbank speichern.

    //SQL $statement = $pdo->prepare("UPDATE users SET otpKey = :otpKey_neu WHERE id = :id"); $statement->execute(array('otpKey_neu' => $otp, 'id' => $userid)); //Überwachung auf Erfolg if ($statement->execute()) { // DB Eintrag erfolgreich geschrieben echo "YubiKey Passwort erfolgreich gespeichert!"; } else { echo "Datenbank Fehler! Bitte informieren Sie den Administrator."; }

    Ich hoffe, es hilft dem ein oder anderen sich mit diesem Thema etwas zu beschäftigen.

  • Eingabefeld aktivieren

    PHP
    1
    0 Stimmen
    1 Beiträge
    189 Aufrufe
    Niemand hat geantwortet
  • Wichtige Info

    Angeheftet PHP
    1
    0 Stimmen
    1 Beiträge
    195 Aufrufe
    Niemand hat geantwortet
  • Reload einer PHP Seite verhindern

    PHP
    1
    0 Stimmen
    1 Beiträge
    687 Aufrufe
    Niemand hat geantwortet
  • PHP Exif Daten aus Bild auslesen

    Verschoben PHP
    1
    0 Stimmen
    1 Beiträge
    460 Aufrufe
    Niemand hat geantwortet