function bl_profile_update_listing_content()
{
    global $wpdb, $post;
    $bl_id = is_numeric($_GET["bl_id"]) ? $_GET["bl_id"] : "0";
    $data = get_option("bepro_listings");
    //get information
    $item = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " WHERE id = " . $bl_id);
    if (!$item) {
        return;
    }
    $post_data = get_post($item->post_id);
    //get categories
    $raw_categories = listing_types_by_post($item->post_id);
    $categories = array();
    if ($raw_categories) {
        foreach ($raw_categories as $category) {
            $categories[$category->term_id] = $category->term_id;
        }
    }
    $args = array('numberposts' => -1, 'post_parent' => $item->post_id, 'post_type' => 'attachment');
    //get images
    $attachments = get_posts($args);
    $thunmbnails = array();
    $file_icons = array("application/pdf" => "document.png", "text/plain" => "text.png", "text/csv" => "spreadsheet.png", "application/rar" => "archive.png", "application/x-tar" => "archive.png", "application/zip" => "archive.png", "application/x-gzip" => "archive.png", "application/x-7z-compressed" => "archive.png", "application/msword" => "document.png", "application/vnd.oasis.opendocument.text" => "document.png", "application/vnd.oasis.opendocument.presentation" => "text.png", "application/vnd.oasis.opendocument.spreadsheet" => "interactive.png", "application/vnd.oasis.opendocument.graphics" => "interactive.png", "application/vnd.oasis.opendocument.chart" => "spreadsheet.png", "application/wordperfect" => "document.png", "video/x-ms-asf" => "video.png", "video/x-ms-wmv" => "video.png", "video/x-ms-wmx" => "video.png", "video/x-ms-wm" => "video.png", "video/avi" => "video.png", "video/divx" => "video.png", "video/x-flv" => "video.png", "video/quicktime" => "video.png", "video/mpeg" => "video.png", "video/mp4" => "video.png", "video/ogg" => "video.png", "video/webm" => "video.png", "video/x-matroska" => "video.png");
    if ($attachments) {
        foreach ($attachments as $attachment) {
            $image = wp_get_attachment_image_src($attachment->ID, 'thumbnail', false);
            if (!$image) {
                $p_type = get_post_mime_type($attachment->ID);
                $f_type = empty($file_icons[$p_type]) ? "text.png" : $file_icons[$p_type];
                $image[0] = get_bloginfo("wpurl") . "/wp-includes/images/crystal/" . $f_type;
            }
            $image[4] = $attachment->ID;
            $image[5] = basename(get_attached_file($attachment->ID));
            $thunmbnails[] = $image;
        }
    }
    //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"];
    $cat_drop = $data["cat_drop"];
    $listing_url = "?bl_manage=1&bl_id=";
    $url = get_permalink($post->ID);
    if (!empty($_POST["save_bepro_listing"])) {
        echo "<p><a href='" . $url . "'>" . __("Return to List", "bepro-listings") . "</a></p>";
    } else {
        echo "<p><a href='" . $url . "'>" . __("Cancel", "bepro-listings") . "</a></p>";
    }
    $frontend_form = dirname(__FILE__) . "/templates/form.php";
    $frontend_form = apply_filters("bl_change_upload_form", $frontend_form);
    if ($frontend_form) {
        require $frontend_form;
    }
}
function update_listing_content()
{
    global $wpdb, $bp, $post;
    $data = get_option("bepro_listings");
    $listing_url = $bp->loggedin_user->domain . $bp->current_component . "/";
    //get information
    $item = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . BEPRO_LISTINGS_TABLE_NAME . " WHERE id = " . $bp->action_variables[0]);
    if (!$item) {
        header("Location: " . $listing_url . "?message=Listing Does not exist");
        exit;
    }
    $post_data = get_post($item->post_id);
    $user_id = get_current_user_id();
    if ($post_data->post_author != $user_id) {
        header("Location: " . $listing_url . "?message=You do not own this listing");
        exit;
    }
    //get categories
    $raw_categories = listing_types_by_post($item->post_id);
    $categories = array();
    if ($raw_categories) {
        foreach ($raw_categories as $category) {
            $categories[$category->term_id] = $category->term_id;
        }
    }
    $args = array('numberposts' => -1, 'post_parent' => $item->post_id, 'post_type' => 'attachment');
    //get images
    $attachments = get_posts($args);
    $thunmbnails = array();
    $file_icons = array("application/pdf" => "document.png", "text/plain" => "text.png", "text/csv" => "spreadsheet.png", "application/rar" => "archive.png", "application/x-tar" => "archive.png", "application/zip" => "archive.png", "application/x-gzip" => "archive.png", "application/x-7z-compressed" => "archive.png", "application/msword" => "document.png", "application/vnd.oasis.opendocument.text" => "document.png", "application/vnd.oasis.opendocument.presentation" => "text.png", "application/vnd.oasis.opendocument.spreadsheet" => "interactive.png", "application/vnd.oasis.opendocument.graphics" => "interactive.png", "application/vnd.oasis.opendocument.chart" => "spreadsheet.png", "application/wordperfect" => "document.png", "video/x-ms-asf" => "video.png", "video/x-ms-wmv" => "video.png", "video/x-ms-wmx" => "video.png", "video/x-ms-wm" => "video.png", "video/avi" => "video.png", "video/divx" => "video.png", "video/x-flv" => "video.png", "video/quicktime" => "video.png", "video/mpeg" => "video.png", "video/mp4" => "video.png", "video/ogg" => "video.png", "video/webm" => "video.png", "video/x-matroska" => "video.png");
    if ($attachments) {
        foreach ($attachments as $attachment) {
            $image = wp_get_attachment_image_src($attachment->ID, 'thumbnail', false);
            if (!$image) {
                $p_type = get_post_mime_type($attachment->ID);
                $f_type = empty($file_icons[$p_type]) ? "text.png" : $file_icons[$p_type];
                $image[0] = get_bloginfo("wpurl") . "/wp-includes/images/crystal/" . $f_type;
            }
            $image[4] = $attachment->ID;
            $image[5] = basename(get_attached_file($attachment->ID));
            $thunmbnails[] = $image;
        }
    }
    //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"];
    $cat_drop = $data["cat_drop"];
    $siteNo = $bp->groups->current_group->id;
    $listing_url = $bp->loggedin_user->domain . BEPRO_LISTINGS_SLUG . "/";
    require dirname(__FILE__) . '/templates/form.php';
}