Ejemplo n.º 1
0
        break;
        ////post end///
        /// Restaurants ////post start 10///
}
// end of switch
foreach ($post_info as $post_info) {
    $default_location = geodir_get_default_location();
    if ($city_bound_lat1 > $city_bound_lat2) {
        $dummy_post_latitude = geodir_random_float(geodir_random_float($city_bound_lat1, $city_bound_lat2), geodir_random_float($city_bound_lat2, $city_bound_lat1));
    } else {
        $dummy_post_latitude = geodir_random_float(geodir_random_float($city_bound_lat2, $city_bound_lat1), geodir_random_float($city_bound_lat1, $city_bound_lat2));
    }
    if ($city_bound_lng1 > $city_bound_lng2) {
        $dummy_post_longitude = geodir_random_float(geodir_random_float($city_bound_lng1, $city_bound_lng2), geodir_random_float($city_bound_lng2, $city_bound_lng1));
    } else {
        $dummy_post_longitude = geodir_random_float(geodir_random_float($city_bound_lng2, $city_bound_lng1), geodir_random_float($city_bound_lng1, $city_bound_lng2));
    }
    $post_address = array();
    $postal_code = '';
    $address = '';
    $post_address = geodir_get_address_by_lat_lan($dummy_post_latitude, $dummy_post_longitude);
    if (!empty($post_address)) {
        foreach ($post_address as $add_key => $add_value) {
            if ($add_value->types[0] == 'postal_code') {
                $postal_code = $add_value->long_name;
            }
            if ($add_value->types[0] == 'street_number') {
                if ($address != '') {
                    $address .= ',' . $add_value->long_name;
                } else {
                    $address .= $add_value->long_name;
Ejemplo n.º 2
0
function dt_geodir_dummy_content_generator($post_infos = array())
{
    global $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2;
    if (empty($post_infos)) {
        return;
    }
    foreach ($post_infos as $post_info) {
        $default_location = geodir_get_default_location();
        if ($city_bound_lat1 > $city_bound_lat2) {
            $dummy_post_latitude = geodir_random_float(geodir_random_float($city_bound_lat1, $city_bound_lat2), geodir_random_float($city_bound_lat2, $city_bound_lat1));
        } else {
            $dummy_post_latitude = geodir_random_float(geodir_random_float($city_bound_lat2, $city_bound_lat1), geodir_random_float($city_bound_lat1, $city_bound_lat2));
        }
        if ($city_bound_lng1 > $city_bound_lng2) {
            $dummy_post_longitude = geodir_random_float(geodir_random_float($city_bound_lng1, $city_bound_lng2), geodir_random_float($city_bound_lng2, $city_bound_lng1));
        } else {
            $dummy_post_longitude = geodir_random_float(geodir_random_float($city_bound_lng2, $city_bound_lng1), geodir_random_float($city_bound_lng1, $city_bound_lng2));
        }
        $postal_code = '';
        $address = '';
        $post_address = geodir_get_address_by_lat_lan($dummy_post_latitude, $dummy_post_longitude);
        if (!empty($post_address)) {
            foreach ($post_address as $add_key => $add_value) {
                if ($add_value->types[0] == 'postal_code') {
                    $postal_code = $add_value->long_name;
                }
                if ($add_value->types[0] == 'street_number') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
                if ($add_value->types[0] == 'route') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
                if ($add_value->types[0] == 'neighborhood') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
                if ($add_value->types[0] == 'sublocality') {
                    if ($address != '') {
                        $address .= ',' . $add_value->long_name;
                    } else {
                        $address .= $add_value->long_name;
                    }
                }
            }
            $post_info['post_address'] = $address;
            $post_info['post_city'] = $default_location->city;
            $post_info['post_region'] = $default_location->region;
            $post_info['post_country'] = $default_location->country;
            $post_info['post_zip'] = $postal_code;
            $post_info['post_latitude'] = $dummy_post_latitude;
            $post_info['post_longitude'] = $dummy_post_longitude;
        }
        geodir_save_listing($post_info, true);
    }
}