function create_listings()
{
    global $wpdb, $bp;
    $current_user = wp_get_current_user();
    //categories
    $user_ID = $bp->displayed_user->id;
    if (isset($_POST["save_bepro_listing"]) && !empty($_POST["save_bepro_listing"])) {
        $success = false;
        $success = bepro_listings_save();
        if ($success) {
            $message = urlencode("Success saving listing");
        } else {
            $message = urlencode("Error saving listing");
        }
        $current_user = wp_get_current_user();
        $bp_profile_link = bp_core_get_user_domain($bp->displayed_user->id);
        wp_redirect($bp_profile_link . BEPRO_LISTINGS_SLUG . "?message=" . $message);
        exit;
    } elseif (isset($bp->action_variables[0]) && $bp->current_action == BEPRO_LISTINGS_CREATE_SLUG) {
        add_action('bp_template_content', 'update_listing_content');
    } else {
        add_action('bp_template_content', 'create_listing_content');
    }
    bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
}
function bl_my_listings()
{
    global $wpdb, $post;
    $current_url = get_permalink($post->ID);
    $return_text = "";
    if (!is_user_logged_in()) {
        $return_text .= "<p>" . __("You need to be Logged In to see your Listings.", "bepro-listings") . "</p>";
        $args = array('echo' => true, 'redirect' => $current_url, 'form_id' => 'loginform', 'label_username' => __('Username'), 'label_password' => __('Password'), 'label_remember' => __('Remember Me'), 'label_log_in' => __('Log In'), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => NULL, 'value_remember' => false);
        wp_login_form($args);
        return;
    }
    $types = listing_types();
    $current_user = wp_get_current_user();
    $user_id = $current_user->id;
    if (isset($_POST["save_bepro_listing"]) && !empty($_POST["save_bepro_listing"])) {
        $success = false;
        $success = bepro_listings_save();
        if ($success) {
            $success_message = apply_filters("bepro_form_success_message", "Listing Successfully Saved");
            $message = "<span class='bl_succsss_message'>" . __($success_message, "bepro-listings") . "</span>";
        } else {
            $fail_message = apply_filters("bepro_form_fail_message", __("Issue saving your listing. Please contact the website administrator", "bepro-listings"));
            $message = "<span class='bl_fail_message'>" . __($fail_message, "bepro-listings") . "</span>";
        }
        $current_user = wp_get_current_user();
        $current_url = get_permalink($post->ID);
        echo "<span class='classified_message'>" . $message . "</span>";
    }
    if (!empty($_GET["bl_manage"])) {
        if (!empty($_GET["bl_id"])) {
            bl_profile_update_listing_content();
        } else {
            bl_profile_add_listing_content();
        }
    } else {
        $data = get_option("bepro_listings");
        // get records
        if (@$data["require_payment"]) {
            $items = $wpdb->get_results("SELECT geo.*, orders.status as order_status, orders.expires, wp_posts.post_title, wp_posts.post_status FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " as geo \n\t\t\t\tLEFT JOIN " . $wpdb->prefix . "posts as wp_posts on wp_posts.ID = geo.post_id \n\t\t\t\tLEFT JOIN " . BEPRO_LISTINGS_ORDERS_TABLE_NAME . " AS orders on orders.bl_order_id = geo.bl_order_id WHERE wp_posts.post_status != 'trash' AND wp_posts.post_author = " . $user_id);
        } else {
            $items = $wpdb->get_results("SELECT geo.*, wp_posts.post_title, wp_posts.post_status FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " as geo \n\t\t\t\tLEFT JOIN " . $wpdb->prefix . "posts as wp_posts on wp_posts.ID = geo.post_id WHERE wp_posts.post_status != 'trash' AND wp_posts.post_author = " . $user_id);
        }
        $listing_url = "?bl_manage=1&bl_id=";
        $add_listing_button = "<p><a href='" . $listing_url . "'>" . __("Add a Listing") . "</a></p>";
        //allow addons to override create listing button
        $return_text .= apply_filters("bl_change_add_listing_button", $add_listing_button, $listing_url);
        //allow addons to change profile template
        $bl_my_list_template = apply_filters("bl_change_my_list_template", dirname(__FILE__) . '/templates/list.php', $items);
        ob_start();
        if (!empty($bl_my_list_template)) {
            include $bl_my_list_template;
        }
        $return_text .= ob_get_clean();
        return $return_text;
    }
}
function bl_my_listings()
{
    global $wpdb, $post;
    $current_url = get_permalink($post->ID);
    if (!is_user_logged_in()) {
        echo "<p>You need to be Logged In to see your Listings.</p>";
        $args = array('echo' => true, 'redirect' => $current_url, 'form_id' => 'loginform', 'label_username' => __('Username'), 'label_password' => __('Password'), 'label_remember' => __('Remember Me'), 'label_log_in' => __('Log In'), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => NULL, 'value_remember' => false);
        wp_login_form($args);
        return;
    }
    $types = listing_types();
    $current_user = wp_get_current_user();
    $user_id = $current_user->id;
    if (isset($_POST["save_bepro_listing"]) && !empty($_POST["save_bepro_listing"])) {
        $success = false;
        $success = bepro_listings_save();
        if ($success) {
            $message = urlencode("Success saving listing");
        } else {
            $message = urlencode("Error saving listing");
        }
        $current_user = wp_get_current_user();
        $current_url = get_permalink($post->ID);
        wp_redirect($current_url . "?message=" . $message);
        exit;
    }
    if (!empty($_GET["bl_manage"])) {
        if (!empty($_GET["bl_id"])) {
            bl_profile_update_listing_content();
        } else {
            bl_profile_add_listing_content();
        }
    } else {
        // get records
        $items = $wpdb->get_results("SELECT geo.*, wp_posts.post_title, wp_posts.post_status FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " as geo \r\n\t\t\tLEFT JOIN " . $wpdb->prefix . "posts as wp_posts on wp_posts.ID = geo.post_id WHERE wp_posts.post_status != 'trash' AND wp_posts.post_author = " . $user_id);
        $listing_url = "?bl_manage=1&bl_id=";
        echo "<p><a href='" . $listing_url . "'>Add a Listing</a></p>";
        require dirname(__FILE__) . '/templates/list.php';
    }
}
function user_create_listing($atts = array())
{
    global $wpdb;
    extract(shortcode_atts(array('register' => $wpdb->escape($_POST["register"])), $atts));
    //get settings
    $data = get_option("bepro_listings");
    $default_user_id = $data["default_user_id"];
    $num_images = $data["num_images"];
    $validate = $data["validate_form"];
    $show_cost = $data["show_cost"];
    $show_con = $data["show_con"];
    $show_geo = $data["show_geo"];
    if (empty($default_user_id) && empty($register)) {
        echo "You must provide a 'default user id' in the admin settings or use the registration=1 option.";
        return;
    }
    if (!empty($_POST["save_bepro_listing"])) {
        $wp_upload_dir = wp_upload_dir();
        if (bepro_listings_save()) {
            echo "<h2>Listing Successfully Saved</h2>";
        } else {
            echo "<h2>Issue saving your listing. Please contact the website administrator</h2>";
        }
    }
    ob_start();
    include dirname(__FILE__) . "/templates/form.php";
    $results = ob_get_contents();
    ob_end_clean();
    return $results;
}
function bepro_admin_save_details($post_id, $post_after, $post_before)
{
    global $wpdb;
    if (!isset($_POST['save_bepro_listing']) && !isset($_POST["package_duration"]) && !isset($_POST["bpl_save_order"])) {
        return;
    }
    if ($parent_id = wp_is_post_revision($post_id)) {
        $post_id = $parent_id;
    }
    $post_type = get_post_type($post_id);
    if ($post_type === "bepro_listings") {
        bepro_listings_save($post_id);
    }
    if ($post_type === "bpl_packages") {
        bp_payment_packages_save($post_id);
    }
    if ($post_type === "bpl_orders") {
        bl_order_meta_save($post_id);
    }
}
function save_data_and_redirect()
{
    if (!empty($_POST["save_bepro_listing"]) && !empty($_POST["redirect"])) {
        $wp_upload_dir = wp_upload_dir();
        if ($post_id = bepro_listings_save(false, true)) {
            $data = get_option("bepro_listings");
            //add to cart and redirect?
            if (is_numeric($data["require_payment"]) && empty($_POST["bepro_post_id"]) && class_exists("Bepro_cart")) {
                //find an order id with space for this type of order
                $bl_order_id = bl_get_vacant_order_id($user_id, $data["require_payment"], $_POST["bl_package"]);
                if ($data["require_payment"] == 1) {
                    $cost = bepro_get_total_cat_cost($post_id);
                } else {
                    if ($data["require_payment"] == 2 && is_numeric($_POST["bl_package"])) {
                        $cost = get_post_meta($_POST["bl_package"], "package_cost", true);
                    }
                }
                if (!empty($cost) && function_exists("bpc_cart_actions_handler")) {
                    $_POST["addcart"] = 1;
                    $_POST["price"] = $cost;
                    $_POST["item_number"] = $bl_order_id;
                    $_POST["product"] = __("Listing Submission");
                    bpc_cart_actions_handler();
                }
            }
            header("LOCATION: " . $_POST["redirect"]);
            exit;
        }
    }
}
function bepro_listings_options()
{
    $data = get_option("bepro_listings");
    if (!empty($_POST["update_options"])) {
        //general
        $data["show_cost"] = $_POST["show_cost"];
        $data["show_con"] = $_POST["show_con"];
        $data["show_geo"] = $_POST["show_geo"];
        $data["num_images"] = $_POST["num_images"];
        $data["cat_heading"] = $_POST["cat_heading"];
        $data["cat_empty"] = $_POST["cat_empty"];
        $data["cat_singular"] = $_POST["cat_singular"];
        //forms
        $data["validate_form"] = $_POST["validate_form"];
        $data["default_user_id"] = $_POST["default_user_id"];
        $data["default_status"] = $_POST["default_status"];
        $data["success_message"] = $_POST["success_message"];
        $data["fail_message"] = $_POST["fail_message"];
        //check cat exclude
        $data["bepro_listings_cat_exclude"] = bl_check_is_valid_cat($_POST["bepro_listings_cat_exclude"]) ? $_POST["bepro_listings_cat_exclude"] : "";
        //check cat required
        $data["bepro_listings_cat_required"] = bl_check_is_valid_cat($_POST["bepro_listings_cat_required"]) ? $_POST["bepro_listings_cat_required"] : "";
        //search listings
        $data["default_image"] = $_POST["default_image"];
        $data["link_new_page"] = $_POST["link_new_page"];
        $data["ajax_on"] = $_POST["ajax_on"];
        $data["num_listings"] = $_POST["num_listings"];
        $data["distance"] = $_POST["distance"];
        $data["details_link"] = $_POST["details_link"];
        $data["show_web_link"] = $_POST["show_web_link"];
        $data["show_date"] = $_POST["show_date"];
        $data["currency_sign"] = $_POST["currency_sign"];
        //Page/post
        $data["gallery_size"] = $_POST["gallery_size"];
        $data["gallery_cols"] = $_POST["gallery_cols"];
        $data["show_details"] = $_POST["show_details"];
        $data["add_detail_links"] = $_POST["add_detail_links"];
        $data["show_content"] = $_POST["show_content"];
        //map
        $data["map_query_type"] = $_POST["map_query_type"];
        //buddypress
        $data["buddypress"] = $_POST["buddypress"];
        //Support
        $data["footer_link"] = $_POST["footer_link"];
        update_option("bepro_listings", $data);
        if (isset($_FILES["csv_upload"]) && !empty($_FILES["csv_upload"]["size"])) {
            $delimiter = $_POST["csv_upload_delimiter"];
            $file_path = $_FILES["csv_upload"]["tmp_name"];
            $file = fopen($file_path, 'r');
            $csv_titles = array();
            $counter = 0;
            while (($results = fgetcsv($file, 1500, $delimiter)) !== false) {
                if ($counter > 0) {
                    $_POST = "";
                    foreach ($results as $key => $result) {
                        $_POST[$csv_titles[$key]] = $result;
                    }
                    if (!empty($csv_titles[0])) {
                        $_POST["save_bepro_listing"] = 1;
                        $post_id = bepro_listings_save(false, true);
                        if (!empty($_POST["photo"])) {
                            $remote_url = addslashes(strip_tags($_POST["photo"]));
                            bl_attach_remote_file($post_id, $remote_url);
                        }
                    }
                } else {
                    $csv_titles = array_values($results);
                }
                $counter++;
            }
            fclose($file);
        }
    }
    ?>
		<h1>BePro Listings Options</h1>
		<div class="wrap bepro_listings_admin_form">
			<form class="bepro_listings" method="post" enctype="multipart/form-data">
				<input type="hidden" name="update_options" value="1" />
				<div id="bepro_listings_tabs">
					<ul>
						<li><a href="#tabs-1">General</a></li>
						<li><a href="#tabs-2">Forms</a></li>
						<li><a href="#tabs-3">Search/Listings</a></li>
						<li><a href="#tabs-4">Page/Post</a></li>
						<li><a href="#tabs-5">Map</a></li>
						<li><a href="#tabs-6">Buddypress</a></li>
						<li><a href="#tabs-7">CSV Upload</a></li>
						<li><a href="#tabs-8">Support</a></li>
					</ul>
				
					<div id="tabs-1">
						<span class="form_label"><?php 
    _e("Show Cost", "bepro-listings");
    ?>
</span><input type="checkbox" name="show_cost" <?php 
    echo $data["show_cost"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
><br />
						<span class="form_label"><?php 
    _e("Show Contact", "bepro-listings");
    ?>
</span><input type="checkbox" name="show_con" <?php 
    echo $data["show_con"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
><br />
						<span class="form_label"><?php 
    _e("Show Geography", "bepro-listings");
    ?>
</span><input type="checkbox" name="show_geo" <?php 
    echo $data["show_geo"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
><br />
						<span class="form_label"><?php 
    _e("# Of Uploads", "bepro-listings");
    ?>
</span><select name="num_images"><br />
							<option value="1" <?php 
    echo $data["num_images"] == 1 ? 'selected="selected"' : "";
    ?>
>1</option>
							<option value="2" <?php 
    echo $data["num_images"] == 2 ? 'selected="selected"' : "";
    ?>
>2</option>
							<option value="3" <?php 
    echo $data["num_images"] == 3 ? 'selected="selected"' : "";
    ?>
>3</option>
							<option value="4" <?php 
    echo $data["num_images"] == 4 ? 'selected="selected"' : "";
    ?>
>4</option>
							<option value="5" <?php 
    echo $data["num_images"] == 5 ? 'selected="selected"' : "";
    ?>
>5</option>
							<option value="6" <?php 
    echo $data["num_images"] == 6 ? 'selected="selected"' : "";
    ?>
>6</option>
							<option value="7" <?php 
    echo $data["num_images"] == 7 ? 'selected="selected"' : "";
    ?>
>7</option>
							<option value="8" <?php 
    echo $data["num_images"] == 8 ? 'selected="selected"' : "";
    ?>
>8</option>
							<option value="9" <?php 
    echo $data["num_images"] == 9 ? 'selected="selected"' : "";
    ?>
>9</option>
							<option value="0" <?php 
    echo $data["num_images"] == 0 ? 'selected="selected"' : "";
    ?>
>None</option>
						</select><br />
						<span class="form_label"><?php 
    _e("Category Heading", "bepro-listings");
    ?>
</span><input type="input" name="cat_heading" value="<?php 
    echo $data["cat_heading"];
    ?>
"><br />
						<span class="form_label"><?php 
    _e("Category Empty", "bepro-listings");
    ?>
</span><input type="input" name="cat_empty" value="<?php 
    echo $data["cat_empty"];
    ?>
"><br />
						<span class="form_label"><?php 
    _e("Category Singular", "bepro-listings");
    ?>
</span><input type="input" name="cat_singular" value="<?php 
    echo $data["cat_singular"];
    ?>
"><br />
					</div>
					<div id="tabs-2">
						<span class="form_label"><?php 
    _e("Validate Form", "bepro-listings");
    ?>
</span><input type="checkbox" name="validate_form" <?php 
    echo $data["validate_form"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
><br />
						<span class="form_label"><?php 
    _e("Default User Id", "bepro-listings");
    ?>
</span><input type="text" name="default_user_id" value="<?php 
    echo $data["default_user_id"];
    ?>
"><br />
						<span class="form_label"><?php 
    _e("Default Status", "bepro-listings");
    ?>
</span><select name="default_status">
							<option value="pending" <?php 
    echo $data["default_status"] == "pending" ? 'selected="selected"' : "";
    ?>
>Pending</option>
							<option value="publish" <?php 
    echo $data["default_status"] == "publish" ? 'selected="selected"' : "";
    ?>
>Published</option>
						</select></br>
						<span class="form_label"><?php 
    _e("Success Message", "bepro-listings");
    ?>
</span><textarea name="success_message"><?php 
    echo $data["success_message"];
    ?>
</textarea><br />
						<span class="form_label"><?php 
    _e("Fail Message", "bepro-listings");
    ?>
</span><textarea name="fail_message"><?php 
    echo $data["fail_message"];
    ?>
</textarea><br />
						<span class="form_label"><?php 
    _e("Required Categories", "bepro-listings");
    ?>
</span><input type="text" name="bepro_listings_cat_required" value="<?php 
    echo $data["bepro_listings_cat_required"];
    ?>
" /></br>
						<span class="form_label"><?php 
    _e("Exclude Categories", "bepro-listings");
    ?>
</span><input type="text" name="bepro_listings_cat_exclude" value="<?php 
    echo $data["bepro_listings_cat_exclude"];
    ?>
" /></br>
					</div>
					<div id="tabs-3">
						<span class="form_label"><?php 
    _e("Default Listing Image", "bepro-listings");
    ?>
</span><input type="text" name="default_image" value="<?php 
    echo $data["default_image"];
    ?>
" /></br>
						<span class="form_label"><?php 
    _e("How Links Open", "bepro-listings");
    ?>
</span><select name="link_new_page">
							<option value="1" <?php 
    echo $data["link_new_page"] == 1 ? 'selected="selected"' : "";
    ?>
>Go To Page</option>
							<option value="2" <?php 
    echo $data["link_new_page"] == 2 ? 'selected="selected"' : "";
    ?>
>New Tab</option>
							<option value="3" <?php 
    echo $data["link_new_page"] == 3 ? 'selected="selected"' : "";
    ?>
>Ajax Page</option>
							<option value="4" <?php 
    echo $data["link_new_page"] == 4 ? 'selected="selected"' : "";
    ?>
>Hide Internal</option>
						</select><br />
						<span class="form_label"><?php 
    _e("Ajax On?", "bepro-listings");
    ?>
</span><input type="checkbox" name="ajax_on" <?php 
    echo $data["ajax_on"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
><br />
						<span class="form_label"><?php 
    _e("Default # Listings", "bepro-listings");
    ?>
</span><select name="num_listings">
							<option value="1" <?php 
    echo $data["num_listings"] == 1 ? 'selected="selected"' : "";
    ?>
>1</option>
							<option value="3" <?php 
    echo $data["num_listings"] == 3 ? 'selected="selected"' : "";
    ?>
>3</option>
							<option value="5" <?php 
    echo $data["num_listings"] == 5 ? 'selected="selected"' : "";
    ?>
>5</option>
							<option value="8" <?php 
    echo $data["num_listings"] == 8 ? 'selected="selected"' : "";
    ?>
>8</option>
							<option value="10" <?php 
    echo $data["num_listings"] == 10 ? 'selected="selected"' : "";
    ?>
>10</option>
							<option value="12" <?php 
    echo $data["num_listings"] == 12 ? 'selected="selected"' : "";
    ?>
>12</option>
							<option value="16" <?php 
    echo $data["num_listings"] == 16 ? 'selected="selected"' : "";
    ?>
>16</option>
							<option value="20" <?php 
    echo $data["num_listings"] == 20 ? 'selected="selected"' : "";
    ?>
>20</option>
							<option value="50" <?php 
    echo $data["num_listings"] == 50 ? 'selected="selected"' : "";
    ?>
>50</option>
						</select></br>
						<span class="form_label"><?php 
    _e("Default Search Distance (Mi)", "bepro-listings");
    ?>
</span><select name="distance">
							<option value="10" <?php 
    echo $data["distance"] == 10 ? 'selected="selected"' : "";
    ?>
>10</option>
							<option value="50" <?php 
    echo $data["distance"] == 50 ? 'selected="selected"' : "";
    ?>
>50</option>
							<option value="150" <?php 
    echo $data["distance"] == 150 ? 'selected="selected"' : "";
    ?>
>150</option>
							<option value="250" <?php 
    echo $data["distance"] == 250 ? 'selected="selected"' : "";
    ?>
>250</option>
							<option value="500" <?php 
    echo $data["distance"] == 500 ? 'selected="selected"' : "";
    ?>
>500</option>
							<option value="1000" <?php 
    echo $data["distance"] == 1000 ? 'selected="selected"' : "";
    ?>
>1000</option>
						</select>
						<span style="clear:both;display: block;"><br /></span>
						<span class="form_label"><?php 
    _e("Details Link Text", "bepro-listings");
    ?>
</span><input type="text" name="details_link" value="<?php 
    echo $data["details_link"];
    ?>
" /></br>
						<span class="form_label"><?php 
    _e("Show Website Link?", "bepro-listings");
    ?>
</span><input type="checkbox" name="show_web_link" <?php 
    echo $data["show_web_link"] == 1 || $data["show_web_link"] == "on" ? 'checked="checked"' : "";
    ?>
 value="1"><br />
						<span class="form_label"><?php 
    _e("Currency Sign?", "bepro-listings");
    ?>
</span><input type="text" name="currency_sign" value="<?php 
    echo $data["currency_sign"];
    ?>
" /></br>
						<span class="form_label"><?php 
    _e("Show Date filter?", "bepro-listings");
    ?>
</span><input type="checkbox" name="show_date" <?php 
    echo $data["show_date"] == 1 ? 'checked="checked"' : "";
    ?>
 value="1"><br />
						<span style="clear:both;display: block;"><br /></span>
					</div>
					<div id="tabs-4">
						<span class="form_label"><?php 
    _e("Gallery Size", "bepro-listings");
    ?>
</span><select name="gallery_size">
							<option value="thumbnail" <?php 
    echo $data["gallery_size"] == "thumbnail" ? 'selected="selected"' : "";
    ?>
>thumbnail</option>
							<option value="medium" <?php 
    echo $data["gallery_size"] == "medium" ? 'selected="selected"' : "";
    ?>
>medium</option>
							<option value="large" <?php 
    echo $data["gallery_size"] == "large" ? 'selected="selected"' : "";
    ?>
>large</option>
							<option value="full" <?php 
    echo $data["gallery_size"] == "full" ? 'selected="selected"' : "";
    ?>
>full</option>
						</select><br />
						<span class="form_label"><?php 
    _e("#Gallery Columns", "bepro-listings");
    ?>
</span><select name="gallery_cols">
							<option value="3" <?php 
    echo $data["gallery_cols"] == 3 ? 'selected="selected"' : "";
    ?>
>3</option>
							<option value="5" <?php 
    echo $data["gallery_cols"] == 5 ? 'selected="selected"' : "";
    ?>
>5</option>
							<option value="8" <?php 
    echo $data["gallery_cols"] == 8 ? 'selected="selected"' : "";
    ?>
>8</option>
						</select><br />
						<span class="form_label"><?php 
    _e("Show Details", "bepro-listings");
    ?>
</span><input type="checkbox" name="show_details" <?php 
    echo $data["show_details"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
><br />
						<span class="form_label"><?php 
    _e("Links on Details", "bepro-listings");
    ?>
</span><input type="checkbox" name="add_detail_links" <?php 
    echo $data["add_detail_links"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
><br />
						<span class="form_label"><?php 
    _e("Show Content", "bepro-listings");
    ?>
</span><input type="checkbox" name="show_content" <?php 
    echo $data["show_content"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
>
					</div>
					<div id="tabs-5">
						<span class="form_label"><?php 
    _e("Query Type", "bepro-listings");
    ?>
</span><select name="map_query_type">
							<option value="curl" <?php 
    echo $data["map_query_type"] == "curl" ? 'selected="selected"' : "";
    ?>
>Curl</option>
							<option value="file_get_contents" <?php 
    echo $data["map_query_type"] == "file_get_contents" ? 'selected="selected"' : "";
    ?>
>file_get_contents</option>
						</select>	
					</div>
					<div id="tabs-6">
						<span class="form_label"><?php 
    _e("Buddypress", "bepro-listings");
    ?>
</span><input type="checkbox" name="buddypress" <?php 
    echo $data["buddypress"] == (1 || "on") ? 'checked="checked"' : "";
    ?>
>
					</div>
					<div id="tabs-7">
						<p>CSV upload documenation avaialble <a href="http://beprosoftware.com/products/bepro-listings" target="_blank">here</a></p>
						<span class="form_label"><?php 
    _e("CSV File", "bepro-listings");
    ?>
</span><input type="file" name="csv_upload" value=""><br />
						<span class="form_label"><?php 
    _e("Delimiter", "bepro-listings");
    ?>
</span><select name="csv_upload_delimiter">
							<option value=";">;</option>
							<option value=",">,</option>
							<option value="#*">#*</option>
						</select>
					</div>
					<div id="tabs-8">
						<a href="http://beprosoftware.com"><img src="<?php 
    echo BEPRO_LISTINGS_PLUGIN_PATH . "/images/bepro_software_logo.png";
    ?>
"></a><br />
						<iframe width="560" height="315" src="//www.youtube.com/embed/D5YpZX0go88" frameborder="0" allowfullscreen></iframe>
						<p><b>THANK YOU</b> for your interest and support of this plugin. Our BePro Software Team is dedicated to providing you with the tools needed for great websites. You can get involved in any of the following ways:</p>
						<h2>Support For You</h2>
						<ul style="border:1px solid; padding:10px">
							<li>Support Forum - Join our <a href="http://beprosoftware.com/forums" target="_blank">forums</a> for any support questions</li>
							<li>Documentation - Instructions, videos, shortcodes, and more on <a href="http://beprosoftware.com/products/bepro-listings/">this dedicated page</a></li>
							<li>Contact Us - Send us an email via our <a href="http://www.beprosoftware.com/contact-us/">Contact Us</a> Page</li>
							<li>Upgrades - View our list of <a href="http://www.beprosoftware.com/products/" target="_blank">wordpress plugins and themes</a></li>
							<li>Services - We offer <a href="http://www.beprosoftware.com/services/" target="_blank">Various services</a> including support starting at $15/hr</li>
							<li>Social - Our <a href="https://twitter.com/BeProSoftware" target="_blank">Twitter Page</a></li>
							<li>Youtube - Our <a href="http://www.youtube.com/playlist?list=PLMzIqO2N1YpjMx4QfiCjwFsxxfHVy1goG" target="_blank">Youtube Playlist</a> managed by <a href="http://www.adcoordinates.com" target="_blank">Ad Coordinates</a></li>
						</ul>
						<h2>Support For The Plugin</h2>
						<ul style="border:1px solid; padding:10px">		
							<li><a href="http://wordpress.org/support/view/plugin-reviews/bepro-listings" target="_blank"><span style="color:green;font-weight:bold;font-size:18px;text-decoration:underline">Rate Us</span></a> - Give this plugin a <a href="http://wordpress.org/support/view/plugin-reviews/bepro-listings" target="_blank"><span style="color:green;font-weight:bold;font-size:18px;text-decoration:underline">rating</span></a> on <a href="http://wordpress.org/support/view/plugin-reviews/bepro-listings" target="_blank">Wordpress.org</a>. This is the best way to support the plugin and encourage its growth</li>
							<li>Donations - We accept donations of any amount <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@beprosoftware.com&item_name=Donation+for+BePro+Listings">via paypal</a></li>
							<li><?php 
    _e("Our Link in your footer?", "bepro-listings");
    ?>
 - <input style="vertical-align:middle" type="checkbox" name="footer_link" value="1" <?php 
    echo $data["footer_link"] == ("on" || 1) ? 'checked="checked"' : "";
    ?>
></li>
						</ul>
						<p>NOTE: We can help with customizing this plugin to fit any of your needs. Simply <a href="http://www.beprosoftware.com/contact-us/" target="_blank">reach out</a>. You will receive a personalized responce from a senior member of our <b>BePro Software Team</b></p>
						<hr />
						<p><b>BePro Software&trade;</b> is a service owned and operated by <a href="http://beyondprograms.ca" target="_blank">Beyond Programs Ltd.</a> a Canadian company.</p>
					</div>
				</div>
				<span style="clear:both;display: block;"><br /></span>
				<input type="submit" name="submit" value="Update BePro Listings Options &raquo" />
			</form>
		</div>
		<div class="bepro_listings_loading_msg">
		<p>Jquery is loading... Please wait</p>
		</div>	
			<?php 
}
function user_create_listing($atts = array())
{
    global $wpdb;
    extract(shortcode_atts(array('bl_form_id' => $wpdb->escape($_POST["bl_form_id"]), 'origami' => $wpdb->escape($_POST["origami"]), 'register' => $wpdb->escape($_POST["register"]), 'redirect' => $wpdb->escape($_POST["redirect"])), $atts));
    //addon tie ins
    if (empty($_POST["bl_form_id"])) {
        $_POST["bl_form_id"] = $bl_form_id;
    }
    $_POST["origami"] = $origami;
    $_POST["redirect"] = $redirect;
    //get settings
    $data = get_option("bepro_listings");
    $default_user_id = $data["default_user_id"];
    $num_images = $data["num_images"];
    $validate = $data["validate_form"];
    $show_cost = $data["show_cost"];
    $show_con = $data["show_con"];
    $show_geo = $data["show_geo"];
    if (empty($default_user_id) && empty($register)) {
        echo __("You must provide a 'default user id' in the admin settings or use the registration=1 option.", "bepro-listings");
        return;
    }
    if (!empty($_POST["save_bepro_listing"])) {
        $wp_upload_dir = wp_upload_dir();
        if (bepro_listings_save()) {
            if (!empty($_POST["redirect"])) {
                header("LOCATION: " . get_bloginfo("url") . $_POST["redirect"]);
                exit;
            }
            $success_message = apply_filters("bepro_form_success_message", __("Listing Successfully Saved", "bepro-listings"));
            echo "<h2>" . $success_message . "</h2>";
        } else {
            $fail_message = apply_filters("bepro_form_fail_message", __("Issue saving your listing. Please contact the website administrator", "bepro-listings"));
            echo "<h2>" . $fail_message . "</h2>";
        }
    }
    ob_start();
    $frontend_form = dirname(__FILE__) . "/templates/form.php";
    $frontend_form = apply_filters("bl_change_upload_form", $frontend_form);
    if ($frontend_form) {
        include $frontend_form;
    }
    $results = ob_get_contents();
    ob_end_clean();
    return $results;
}