Exemplo n.º 1
0
function get_driving_information($start, $finish)
{
    $start = urlencode($start);
    $finish = urlencode($finish);
    $url = 'http://maps.google.co.uk/maps?f=d&hl=en&saddr=' . $start . '&daddr=' . $finish . '&output=html';
    //echo $url;
    if ($data = file_get_contents($url)) {
        //echo $data;
        if (preg_match_all('!<div class="altroute-rcol altroute-info">!', $data, $matches, PREG_OFFSET_CAPTURE)) {
            p_array($matches);
            $time = substr($data, $matches[0][0][1], 60);
            //$time = substr($time,strpos($time,'>')+1);
            $time = substr($time, strpos($time, '>') + 1, strpos($time, '<', strpos($time, '>')) - 6);
            return "<div>" . $time;
            //p_array($matches);
            //$distance   = $matches[1];
            //$time       = $matches[2];
            /*
                        if(isset($matches[3]) AND $matches[3] > 0)
                        {
                            $time = $matches[2] * 60 + $matches[3];
                        }
            */
            //return array('distance' => $distance, 'time' => $time);
        } else {
            throw new Exception('Could not find that route');
        }
    } else {
        throw new Exception('Could not resolve URL');
    }
}
Exemplo n.º 2
0
 function updateHashKey($table, $hash, $new_hash)
 {
     $upArray = array('TableName' => (string) $table, 'Key' => array('HashKeyElement' => array(AmazonDynamoDB::TYPE_STRING => $hash)), 'AttributeUpdates' => array('upc_code' => array('Action' => AmazonDynamoDB::ACTION_PUT, 'Value' => array(AmazonDynamoDB::TYPE_STRING => $new_hash))));
     $update_response = $this->amazonDB->update_item($upArray);
     p_array($upArray);
     p_array($update_response);
 }