Ejemplo n.º 1
0
    /**
    	Get long and lat for a tr set 
    */
    public static function getLongLat($data)
    {
        global $dbconn, $trNumLimit;
        $result = array();
        $longLatArray = array();
        $wTrs = '';
        $trCoordinates = '';
        $c = 0;
        // build SQL where for the given TR set
        foreach ($data as $trId) {
            if ($c == 0) {
                $wTrs .= ' traceroute.id=' . $trId;
            } else {
                $wTrs .= ' OR traceroute.id=' . $trId;
            }
            $c++;
            if ($c == $trNumLimit) {
                echo '<p style="color:red;">The number of traceroutes exceeded the limit. <br/>Displaying the first <b>' . $trNumLimit . ' records</b>. 
				<br/> Please add new parameters to your Custom Filter.</p>';
                break;
            }
        }
        // free some memory here
        unset($data);
        // ANTO says: only one query to the db is the way!
        //		$sql = "SELECT tr_item.traceroute_id, tr_item.hop, traceroute.id, ip_addr_info.ip_addr, ip_addr_info.mm_lat, ip_addr_info.mm_long FROM tr_item, traceroute, ip_addr_info WHERE (tr_item.traceroute_id=traceroute.id) AND (ip_addr_info.ip_addr=tr_item.ip_addr) AND tr_item.attempt = 1 AND (".$wTrs.") order by tr_item.traceroute_id, tr_item.hop, tr_item.attempt";
        $sql = "SELECT tr_item.traceroute_id, tr_item.hop, traceroute.id, ip_addr_info.ip_addr, ip_addr_info.lat, ip_addr_info.long, as_users.num, as_users.name FROM tr_item, traceroute, ip_addr_info, as_users WHERE (tr_item.traceroute_id=traceroute.id) AND (ip_addr_info.ip_addr=tr_item.ip_addr) AND (as_users.num=ip_addr_info.asnum) AND tr_item.attempt = 1 AND (" . $wTrs . ") order by tr_item.traceroute_id, tr_item.hop, tr_item.attempt";
        //echo '<textarea>'.$sql.'</textarea>';
        $wTrs = '';
        $result = pg_query($dbconn, $sql) or die('Query failed: ' . pg_last_error());
        //$tot = pg_num_rows($result);
        // get all data in a single array
        $trArr = pg_fetch_all($result);
        //return $trArr;
        Traceroute::dataTrensform($trArr);
    }