Esempio n. 1
0
function getGeoPostyWeather()
{
    global $geoMD5;
    $geoPosty = getGeoPosty();
    $data = get_transient('geoWeather-' . $geoMD5);
    if ($data === false) {
        $data = wp_remote_retrieve_body(wp_remote_get('http://www.google.com/ig/api?hl=en&weather=' . urlencode($geoPosty['PostalCode'])));
        $geoPostyWeatherXML = @simplexml_load_string($data);
        if (!$geoPostyWeatherXML) {
            return false;
        }
        // cache weather info for 2 hours per IP
        set_transient('geoWeather-' . $geoMD5, $data, 60 * 60 * 2);
    }
    if (empty($geoPostyWeatherXML)) {
        $geoPostyWeatherXML = @simplexml_load_string($data);
    }
    return $geoPostyWeatherXML;
}
Esempio n. 2
0
 function widget($args, $instance)
 {
     global $posty_plugin_url;
     $geoPosty = getGeoPosty();
     if (!empty($instance['distancefrom']) && $instance['miles'] > 1) {
         if ($instance['reverse'] && geoDistanceFrom($instance['distancefrom']) < $instance['miles']) {
             return false;
         } elseif (!$instance['reverse'] && geoDistanceFrom($instance['distancefrom']) > $instance['miles']) {
             return false;
         }
     }
     $locationTest = geoLocationContent($instance['locationtype'], $instance['location'], $instance['reverse']);
     if (!$locationTest) {
         return false;
     }
     recordGeoStats('w_business');
     extract($args, EXTR_SKIP);
     echo $args['before_widget'];
     echo $args['before_title'] . do_shortcode(stripslashes($instance['title'])) . $args['after_title'];
     echo '<div id="geoGoogleBusiness"></div>';
     echo '<script type="text/javascript"> googleBusinessSearch(' . $geoPosty['Latitude'] . ', ' . $geoPosty['Longitude'] . ', \'' . $instance['search'] . '\', \'' . $instance['results'] . '\');  </script>';
     //boo-urns
     echo $args['after_widget'];
 }
Esempio n. 3
0
function geoLocationContent($locationtype, $location, $reverse = false)
{
    $geoPosty = getGeoPosty();
    if (!is_array($geoPosty)) {
        return false;
    }
    $locationArray = explode(',', strtolower($location));
    switch ($locationtype) {
        case 'City':
            $locationString = $geoPosty['City'];
            break;
        case 'State/Province/Territory':
            $locationString = $geoPosty['State'];
            break;
        case 'Continent':
            $locationString = $geoPosty['Continent'];
            break;
        case 'Country':
            $locationString = $geoPosty['Country'];
            break;
        case 'Region':
            $locationString = $geoPosty['Region'];
            break;
        case 'Postal Code':
            $locationString = $geoPosty['PostalCode'];
            break;
        case 'US Area Code':
            $locationString = $geoPosty['AreaCode'];
            break;
    }
    // remove whitespace
    array_walk($locationArray, 'trim_value');
    if ($reverse && in_array(strtolower($locationString), $locationArray)) {
        return false;
    } elseif (!$reverse && !in_array(strtolower($locationString), $locationArray)) {
        return false;
    }
    return true;
}
Esempio n. 4
0
function geoLongitude()
{
    recordGeoStats('lon');
    $geoPosty = getGeoPosty();
    if ($geoPosty) {
        return $geoPosty['Longitude'];
    } else {
        return 'your longitude';
    }
}