} 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); } /*if( $dummy_post_index==1); geodir_set_default_location(1); */
/** * Processes GeoDirectory ajax url calls. * * @see geodir_get_ajax_url() * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $current_user Current user object. * @todo check if nonce is required here and if so add one. */ function geodir_ajax_handler() { global $wpdb; if (isset($_REQUEST['gd_listing_view']) && $_REQUEST['gd_listing_view'] != '') { $_SESSION['gd_listing_view'] = $_REQUEST['gd_listing_view']; echo '1'; } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'category_ajax') { if (isset($_REQUEST['main_catid']) && isset($_REQUEST['cat_tax']) && isset($_REQUEST['exclude'])) { geodir_addpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['main_catid'], '', '', '', $_REQUEST['exclude']); } elseif (isset($_REQUEST['catpid']) && isset($_REQUEST['cat_tax'])) { geodir_editpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['catpid']); } } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'admin_ajax' || isset($_REQUEST['create_field']) || isset($_REQUEST['sort_create_field'])) { if (current_user_can('manage_options')) { /** * Contains admin ajax handling functions. * * @since 1.0.0 * @package GeoDirectory */ include_once geodir_plugin_path() . '/geodirectory-admin/geodir_admin_ajax.php'; } else { wp_redirect(home_url() . '/?geodir_signup=true'); exit; } } if (isset($_REQUEST['geodir_autofill']) && $_REQUEST['geodir_autofill'] != '' && isset($_REQUEST['_wpnonce'])) { if (current_user_can('manage_options')) { switch ($_REQUEST['geodir_autofill']) { case "geodir_dummy_delete": if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_delete_noncename')) { return; } if (isset($_REQUEST['posttype'])) { /** * Used to delete the dummy post data per post type. * * Uses dynamic hook, geodir_delete_dummy_posts_$_REQUEST['posttype']. * * @since 1.0.0 */ do_action('geodir_delete_dummy_posts_' . $_REQUEST['posttype']); } break; case "geodir_dummy_insert": if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_insert_noncename')) { return; } global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2; $dummy_post_index = $_REQUEST['insert_dummy_post_index']; $city_bound_lat1 = $_REQUEST['city_bound_lat1']; $city_bound_lng1 = $_REQUEST['city_bound_lng1']; $city_bound_lat2 = $_REQUEST['city_bound_lat2']; $city_bound_lng2 = $_REQUEST['city_bound_lng2']; if (isset($_REQUEST['posttype'])) { /** * Used to insert the dummy post data per post type. * * Uses dynamic hook, geodir_insert_dummy_posts_$_REQUEST['posttype']. * * @since 1.0.0 */ do_action('geodir_insert_dummy_posts_' . $_REQUEST['posttype']); } break; } } else { wp_redirect(home_url() . '/?geodir_signup=true'); exit; } } if (isset($_REQUEST['geodir_import_data']) && $_REQUEST['geodir_import_data'] != '') { if (current_user_can('manage_options')) { geodir_import_data(); } else { wp_redirect(home_url() . '/?geodir_signup=true'); exit; } } if (isset($_REQUEST['popuptype']) && $_REQUEST['popuptype'] != '' && isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != '') { if ($_REQUEST['popuptype'] == 'b_send_inquiry' || $_REQUEST['popuptype'] == 'b_sendtofriend') { require_once geodir_plugin_path() . '/geodirectory-templates/popup-forms.php'; } exit; } /*if(isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'filter_ajax'){ include_once ( geodir_plugin_path() . '/geodirectory-templates/advance-search-form.php'); }*/ if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') { /** * Contains map marker functions. * * @since 1.0.0 * @package GeoDirectory */ include_once geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'; } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') { if (is_user_logged_in()) { switch ($_REQUEST['ajax_action']) { case "add": geodir_add_to_favorite($_REQUEST['pid']); break; case "remove": geodir_remove_from_favorite($_REQUEST['pid']); break; } } else { wp_redirect(home_url() . '/?geodir_signup=true'); exit; } } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') { $is_current_user_owner = true; if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $is_current_user_owner = geodir_listing_belong_to_current_user($_REQUEST['pid']); } $request = isset($_SESSION['listing']) ? unserialize($_SESSION['listing']) : ''; if (is_user_logged_in() && $is_current_user_owner) { switch ($_REQUEST['ajax_action']) { case "add": case "update": if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { $last_id = geodir_save_listing(); if ($last_id) { //$redirect_to = get_permalink( $last_id ); $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $redirect_to = get_permalink(geodir_add_listing_page_id()); $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); } else { $redirect_to = get_permalink(geodir_add_listing_page_id()); } wp_redirect($redirect_to); } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(home_url()); } break; case "cancel": unset($_SESSION['listing']); if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid'])) { wp_redirect(get_permalink($_REQUEST['pid'])); } else { geodir_remove_temp_images(); wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type']))); } break; case "publish": if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $new_post = array(); $new_post['ID'] = $_REQUEST['pid']; //$new_post['post_status'] = 'publish'; $lastid = wp_update_post($new_post); if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(get_permalink($lastid)); } else { $last_id = geodir_save_listing(); if ($last_id) { //$redirect_to = get_permalink( $last_id ); $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id)); } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $redirect_to = get_permalink(geodir_add_listing_page_id()); $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false); } else { $redirect_to = get_permalink(geodir_add_listing_page_id()); } if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect($redirect_to); } } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(home_url()); } break; case "delete": if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { global $current_user; get_currentuserinfo(); $post_type = get_post_type($_REQUEST['pid']); $lastid = wp_delete_post($_REQUEST['pid']); if ($lastid && !is_wp_error($lastid)) { wp_redirect($_SERVER['HTTP_REFERER']); } //wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) ); } break; } if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(home_url() . '/?geodir_signup=true'); exit; } } if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') { /** * Contains registration and login functions. * @todo Fix the file path. * * @since 1.0.0 * @package GeoDirectory */ include_once geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php'; } if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') { $terms_o = get_terms(sanitize_text_field($_REQUEST['term'])); // Skip terms which has no listing if (!empty($terms_o)) { $filter_terms = array(); foreach ($terms_o as $term) { if ($term->count > 0) { $filter_terms[] = $term; } } $terms_o = $filter_terms; } $terms = geodir_sort_terms($terms_o, 'count'); geodir_helper_cat_list_output($terms, intval($_REQUEST['limit'])); exit; } die; }
/** * Saves listing data from request variable to database. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global object $current_user Current user object. * @global object $post WordPress Post object. * @param int $post_id The post ID. */ function geodir_post_information_save($post_id, $post) { global $wpdb, $current_user; //, $post; if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) { return; } /* echo '###post'; print_r($_POST); echo '###request'; print_r($_REQUEST); echo '###'; print_r($post); exit; */ //unsetting the listing session here causes problems, it should be the last thing to be done. /*if(isset($_SESSION['listing'])){ unset($_SESSION['listing']); }*/ $geodir_posttypes = geodir_get_posttypes(); if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) { if (isset($_REQUEST['_status'])) { geodir_change_post_status($post_id, $_REQUEST['_status']); } /*if ( !wp_verify_nonce( $_POST['geodir_post_setting_noncename'], plugin_basename( __FILE__ ) ) ) return;*/ if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) { return; } if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) { return; } /*if ( !wp_verify_nonce( $_POST['geodir_post_addinfo_noncename'], plugin_basename( __FILE__ ) ) ) return;*/ if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) { return; } geodir_save_listing($_REQUEST); } }
function payment_handler() { if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') { switch ($_REQUEST['ajax_action']) { case "paynow": $request = isset($_SESSION['listing']) ? unserialize($_SESSION['listing']) : ''; if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') { if (isset($_REQUEST['paymentmethod']) && isset($_SESSION['listing'])) { $last_id = geodir_save_listing(); $invoice_id = geodir_create_invoice($last_id, $_REQUEST['price_select'], $_REQUEST['paymentmethod'], $_REQUEST['coupon_code']); geodir_update_invoice_status($invoice_id, 'unpaid'); $paymentmethod = $_REQUEST['paymentmethod']; do_action('geodir_payment_form_handler_' . $paymentmethod, $invoice_id); } else { $postlink = get_permalink(get_option('geodir_add_listing_page')); $redirect_url = geodir_getlink($postlink, array('listing_type' => $_REQUEST['listing_type']), false); wp_redirect($redirect_url); } } else { if (isset($_SESSION['listing'])) { unset($_SESSION['listing']); } wp_redirect(home_url()); } break; } } }
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); } }