Inicio Al teu Web Codi font Analitzador amb PHP

Exemple en php

Manual per a integrar l'Índex IBP en aplicacions d'escriptori

 

Per a accedir des d'un programa o Web a l'índex IBP s'han de seguir els següents passos:
 
Llegir l'arxiu que conté les dades de la ruta GPS (traça).
 
Símplement accedint a l'arxiu i llegint tot el seu contingut. 

Exemple en php  ( escrit per Àlex Barros  www.gpsia.com )

ibp.class.php

<?php
// Class for getting the IBPIndex given a local filename, further information on http://www.ibpindex.com
// By Alex Barros for Gpsia software. License: GNU/GPL v3
// Requirements: PHP + Curl


define('IBP_TMP', '/tmp'); //temporary folder with 777 chmod permission

class IBP {
    var $filename; //Source filename
    var $ibp; //Resoult: NN XX (N=number X =alphabetic)
   
    function IBP($filename = false){ //Constructor
        if(!empty($filename)) $this->getIBP($filename);
    }
    function getIBP($filename) {
        if(strlen(basename($filename)) > 55) { //filenames are limited
            $filename = $this->shortenName($filename); //Makes a copy with shorter filename in the temporary folder
            $isTmp = true;
        }
       
        $this->filename = $filename;
       
        if(file_exists($filename)) {
            //Post fields
            $post_data = array();
            $post_data['fichero'] = "@$filename";
            $post_data['MOD'] = 'BTT';
            $post_data['UDO'] = 'Gpsia';
           
            //Curl connection
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "http://www.ibpindex.com/esp/ibpresponse.asp" );
            curl_setopt($ch, CURLOPT_POST, 1 );
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //Needed because redirection is used on the app
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $postResult = curl_exec($ch); //return result
           
            if (curl_errno($ch)) {
                die(curl_error($ch)); //this stops the execution under a Curl failure
            }
           
            curl_close($ch); //close connection
           
            $this->ibp = $postResult;
           
            if($isTmp) @unlink($filename); //remove temporary file
           
            return $postResult;
        }
    }
    function shortenName($filename) {
        $newName = IBP_TMP.'/IBP-'.substr(basename($filename),-20); //new shorter temporary filename
        if(file_put_contents($newName, file_get_contents($filename)))
            return $newName;
        return false;
    }
}

# usage: $ibp = new IBP('path/to/file.gpx'); echo $ibp->ibp; //Returns something like 696 AB

?>
 

Tenim 19 convidats connectat

Enquesta IBP

T'ha semblat útil el sistema IBPindex?