Ejemplo n.º 1
0
function show_image($image_row, $mode = "", $show_link = 1, $detailed_view = 0)
{
    global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile;
    $is_new = $image_row['image_date'] >= time() - 60 * 60 * 24 * $config['new_cutoff'] ? 1 : 0;
    $description = !empty($image_row['image_description']) ? format_text($image_row['image_description'], 1, 0, 1) : REPLACE_EMPTY;
    if (!empty($image_row['image_keywords'])) {
        $split_keywords = explode(",", $image_row['image_keywords']);
        $keywords = "";
        foreach ($split_keywords as $key => $val) {
            $url_val = $val;
            if (preg_match('/[^a-z0-9]+/i', $url_val)) {
                $url_val = '"' . $url_val . '"';
            }
            $keywords .= ($keywords != "" ? ", " : "") . "<a href=\"" . $site_sess->url(ROOT_PATH . "search.php?search_keywords=" . urlencode($url_val)) . "\">" . format_text($val, 2) . "</a>";
        }
    } else {
        $keywords = REPLACE_EMPTY;
    }
    if (!check_permission("auth_readcomment", $image_row['cat_id'])) {
        $image_row['image_allow_comments'] = 0;
    }
    $num_comments = $image_row['image_allow_comments'] == 1 ? $image_row['image_comments'] : "";
    if ($user_info['user_level'] != GUEST) {
        $lightbox_url = $self_url;
        $lightbox_url .= !empty($mode) ? (strpos($lightbox_url, '?') !== false ? "&amp;" : "?") . "mode=" . $mode : "";
        $lightbox_url .= strpos($lightbox_url, '?') !== false ? "&amp;" : "?";
        if (check_lightbox($image_row['image_id'])) {
            $lightbox_url .= "action=removefromlightbox&amp;id=" . $image_row['image_id'];
            $lightbox_button = "<a href=\"" . $site_sess->url($lightbox_url) . "\"><img src=\"" . get_gallery_image("lightbox_yes.gif") . "\" border=\"0\" alt=\"\" /></a>";
        } else {
            $lightbox_url .= "action=addtolightbox&amp;id=" . $image_row['image_id'];
            $lightbox_button = "<a href=\"" . $site_sess->url($lightbox_url) . "\"><img src=\"" . get_gallery_image("lightbox_no.gif") . "\" border=\"0\" alt=\"\" /></a>";
        }
    } else {
        $lightbox_button = "<img src=\"" . get_gallery_image("lightbox_off.gif") . "\" border=\"0\" alt=\"\" />";
    }
    if (!check_permission("auth_download", $image_row['cat_id'])) {
        $download_button = "<img src=\"" . get_gallery_image("download_off.gif") . "\" border=\"0\" alt=\"\" />";
        $download_zip_button = function_exists("gzcompress") && function_exists("crc32") ? "<img src=\"" . get_gallery_image("download_zip_off.gif") . "\" border=\"0\" alt=\"\" />" : "";
        $allow_download = 0;
        clear_download_token($image_row['image_id']);
    } else {
        $target = !empty($image_row['image_download_url']) && !is_remote_file($image_row['image_download_url']) && !is_local_file($image_row['image_download_url']) ? "target=\"_blank\"" : "";
        $download_button = "<a href=\"" . $site_sess->url(ROOT_PATH . "download.php?" . URL_IMAGE_ID . "=" . $image_row['image_id']) . "\"" . $target . "><img src=\"" . get_gallery_image("download.gif") . "\" border=\"0\" alt=\"\" /></a>";
        $download_zip_button = $target == "" && function_exists("gzcompress") && function_exists("crc32") ? "<a href=\"" . $site_sess->url(ROOT_PATH . "download.php?action=zip&amp;" . URL_IMAGE_ID . "=" . $image_row['image_id']) . "\"" . $target . "><img src=\"" . get_gallery_image("download_zip.gif") . "\" border=\"0\" alt=\"\" /></a>" : "";
        $allow_download = 1;
        set_download_token($image_row['image_id']);
    }
    if (!check_permission("auth_sendpostcard", $image_row['cat_id'])) {
        $postcard_button = "<img src=\"" . get_gallery_image("postcard_off.gif") . "\" border=\"0\" alt=\"\" />";
    } else {
        $postcard_button = "<a href=\"" . $site_sess->url(ROOT_PATH . "postcards.php?" . URL_IMAGE_ID . "=" . $image_row['image_id'] . (!empty($mode) ? "&amp;mode=" . $mode : "")) . "\"><img src=\"" . get_gallery_image("postcard.gif") . "\" border=\"0\" alt=\"\" /></a>";
    }
    if (!check_permission("auth_viewimage", $image_row['cat_id']) || !check_permission("auth_viewcat", $image_row['cat_id'])) {
        $show_link = 0;
    }
    $file_size = "n/a";
    if (!is_remote($image_row['image_media_file'])) {
        if ($file_size = @filesize(MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_media_file'])) {
            $file_size = format_file_size($file_size);
        }
    } elseif ($detailed_view) {
        $file_size = get_remote_file_size($image_row['image_media_file']);
    }
    if (isset($image_row[$user_table_fields['user_name']]) && $image_row['user_id'] != GUEST) {
        $user_name = format_text($image_row[$user_table_fields['user_name']], 2);
        $user_profile_link = !empty($url_show_profile) ? str_replace("{user_id}", $image_row['user_id'], $url_show_profile) : ROOT_PATH . "member.php?action=showprofile&amp;" . URL_USER_ID . "=" . $image_row['user_id'];
        $user_name_link = "<a href=\"" . $site_sess->url($user_profile_link) . "\">" . $user_name . "</a>";
    } else {
        $user_name = format_text($lang['userlevel_guest'], 2);
        $user_name_link = $user_name;
    }
    $site_template->register_vars(array("image_id" => $image_row['image_id'], "user_id" => $image_row['user_id'], "user_name" => $user_name, "user_name_link" => $user_name_link, "image_name" => format_text($image_row['image_name'], 2), "image_description" => $description, "image_keywords" => $keywords, "image_date" => format_date($config['date_format'] . " " . $config['time_format'], $image_row['image_date']), "image_is_new" => $is_new, "lang_new" => $lang['new'], "image_active" => $image_row['image_active'], "cat_id" => $image_row['cat_id'], "cat_name" => format_text($image_row['cat_name'], 2), "cat_url" => $site_sess->url(ROOT_PATH . "categories.php?" . URL_CAT_ID . "=" . $image_row['cat_id']), "image_downloads" => $image_row['image_downloads'], "image_votes" => $image_row['image_votes'], "image_rating" => $image_row['image_rating'], "image_hits" => $image_row['image_hits'], "allow_comments" => $image_row['image_allow_comments'], "lang_comments" => $lang['comments'], "image_comments" => $num_comments, "lightbox_button" => $lightbox_button, "postcard_button" => $postcard_button, "download_button" => $download_button, "download_zip_button" => $download_zip_button, "image_download_url" => $image_row['image_download_url'], "allow_download" => $allow_download, "url_download" => $site_sess->url(ROOT_PATH . "download.php?" . URL_IMAGE_ID . "=" . $image_row['image_id']), "image_file_size" => $file_size, "image_url" => $show_link ? $site_sess->url(ROOT_PATH . "details.php?" . URL_IMAGE_ID . "=" . $image_row['image_id'] . (!empty($mode) ? "&amp;mode=" . $mode : "")) : "", "thumbnail" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link), "thumbnail_openwindow" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, 1), "image_file_name" => $image_row['image_media_file'], "thumbnail_file_name" => $image_row['image_thumb_file']));
    if (!empty($additional_image_fields)) {
        $additional_field_array = array();
        foreach ($additional_image_fields as $key => $val) {
            $additional_field_array[$key] = !empty($image_row[$key]) ? format_text($image_row[$key], 1) : REPLACE_EMPTY;
            $additional_field_array['lang_' . $key] = $val[0];
        }
        if (!empty($additional_field_array)) {
            $site_template->register_vars($additional_field_array);
        }
    }
    $rate_form = "";
    if (check_permission("auth_vote", $image_row['cat_id'])) {
        $site_template->register_vars("rate", $lang['rate']);
        $rate_form = $site_template->parse_template("rate_form");
    }
    $site_template->register_vars("rate_form", $rate_form);
    $site_template->register_vars(array("image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view)));
    return true;
}
Ejemplo n.º 2
0
        $message = "";
    }
    if ($action == "modifycard") {
        $bg_color = un_htmlspecialchars(trim($HTTP_POST_VARS['bg_color']));
        $border_color = un_htmlspecialchars(trim($HTTP_POST_VARS['border_color']));
        $font_color = un_htmlspecialchars(trim($HTTP_POST_VARS['font_color']));
        $font_face = un_htmlspecialchars(trim($HTTP_POST_VARS['font_face']));
        $sender_name = un_htmlspecialchars(trim($HTTP_POST_VARS['sender_name']));
        $sender_email = un_htmlspecialchars(trim($HTTP_POST_VARS['sender_email']));
        $recipient_name = un_htmlspecialchars(trim($HTTP_POST_VARS['recipient_name']));
        $recipient_email = un_htmlspecialchars(trim($HTTP_POST_VARS['recipient_email']));
        $headline = un_htmlspecialchars(trim($HTTP_POST_VARS['headline']));
        $message = un_htmlspecialchars(trim($HTTP_POST_VARS['message']));
        $message = strip_tags($message);
    }
    $image = get_media_code($image_row['image_media_file'], $image_id, $cat_id, $image_row['image_name'], $mode, 1);
    $thumbnail = get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_id, $cat_id, $image_row['image_name'], $mode);
    $site_template->register_vars(array("image" => $image, "thumbnail" => $thumbnail, "image_name" => format_text($image_row['image_name']), "lang_bg_color" => $lang['bg_color'], "bg_color" => $bg_color, "lang_border_color" => $lang['border_color'], "border_color" => $border_color, "lang_font_color" => $lang['font_color'], "font_color" => $font_color, "lang_font_face" => $lang['font_face'], "font_face" => $font_face, "image_id" => $image_id, "lang_sender" => $lang['sender'], "lang_recipient" => $lang['recipient'], "lang_email" => $lang['email'], "lang_name" => $lang['name'], "lang_headline" => $lang['headline'], "lang_message" => $lang['message'], "lang_preview_postcard" => $lang['preview_postcard'], "url_postcard" => $site_sess->url(ROOT_PATH . "postcards.php?" . URL_IMAGE_ID . "=" . $image_id), "sender_name" => format_text(stripslashes($sender_name), 2), "sender_email" => format_text(stripslashes($sender_email), 2), "recipient_name" => format_text(stripslashes($recipient_name), 2), "recipient_email" => format_text(stripslashes($recipient_email), 2), "headline" => format_text(stripslashes($headline), 2), "message" => format_text(stripslashes($message), 2), "lang_send_postcard" => $lang['send_postcard'], "back_url" => format_text(stripslashes($url), 2)));
}
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"" . $site_sess->url(ROOT_PATH . "index.php") . "\" class=\"clickstream\">" . $lang['home'] . "</a>" . $config['category_separator'];
if ($mode == "lightbox" && !empty($user_info['lightbox_image_ids'])) {
    $clickstream .= "<a href=\"" . $site_sess->url(ROOT_PATH . "lightbox.php") . "\" class=\"clickstream\">" . $lang['lightbox'] . "</a>" . $config['category_separator'] . "<a href=\"" . $site_sess->url(ROOT_PATH . "details.php?" . URL_IMAGE_ID . "=" . $image_id . "&amp;mode=" . $mode) . "\" class=\"clickstream\">" . $image_row['image_name'] . "</a>" . $config['category_separator'];
} elseif ($mode == "search" && !empty($session_info['search_id'])) {
    $clickstream .= "<a href=\"" . $site_sess->url(ROOT_PATH . "search.php?show_result=1") . "\" class=\"clickstream\">" . $lang['search'] . "</a>" . $config['category_separator'] . "<a href=\"" . $site_sess->url(ROOT_PATH . "details.php?" . URL_IMAGE_ID . "=" . $image_id . "&amp;mode=" . $mode) . "\" class=\"clickstream\">" . $image_row['image_name'] . "</a>" . $config['category_separator'];
} else {
    $clickstream .= get_category_path($cat_id, 1) . $config['category_separator'] . "<a href=\"" . $site_sess->url(ROOT_PATH . "details.php?" . URL_IMAGE_ID . "=" . $image_id) . "\" class=\"clickstream\">" . $image_row['image_name'] . "</a>" . $config['category_separator'];
}
$clickstream .= $lang['send_postcard'] . "</span>";