function delete_images($image_ids, $delfromserver = 1) { global $site_db, $lang, $ids; if (empty($image_ids)) { echo $lang['no_search_results']; return false; } $error_log = array(); echo "<br />"; $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file\n FROM " . IMAGES_TABLE . "\n WHERE image_id IN ({$image_ids})"; $image_result = $site_db->query($sql); while ($image_row = $site_db->fetch_array($image_result)) { $sql = "DELETE FROM " . IMAGES_TABLE . "\n WHERE image_id = " . $image_row['image_id']; if ($site_db->query($sql)) { echo "<b>" . $lang['image_delete_success'] . "</b> " . $image_row['image_name'] . " (ID: " . $image_row['image_id'] . ")<br />\n"; $ids[] = $image_row['image_id']; } else { $error_log[] = "<b>" . $lang['image_delete_error'] . "</b> " . $image_row['image_name'] . " (ID: " . $image_row['image_id'] . ")<br />"; } if ($delfromserver) { if (!is_remote($image_row['image_media_file']) && !is_local_file($image_row['image_media_file'])) { if (@unlink(MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_media_file'])) { echo " " . $lang['file_delete_success'] . " (" . $image_row['image_media_file'] . ")<br />\n"; } else { $error_log[] = "<b>" . $lang['file_delete_error'] . " (" . $image_row['image_media_file'] . ")<br />"; } } if (!empty($image_row['image_thumb_file']) && !is_remote($image_row['image_thumb_file']) && !is_local_file($image_row['image_thumb_file'])) { if (@unlink(THUMB_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_thumb_file'])) { echo " " . $lang['thumb_delete_success'] . " (" . $image_row['image_thumb_file'] . ")<br />\n"; } else { $error_log[] = "<b>" . $lang['thumb_delete_error'] . " (" . $image_row['image_thumb_file'] . ")<br />\n"; } } if (@unlink(MEDIA_PATH . "/" . $image_row['cat_id'] . "/big/" . $image_row['image_media_file'])) { echo " " . $lang['file_delete_success'] . " (big/" . $image_row['image_media_file'] . ")<br />\n"; } else { echo " No Original Found <br />\n"; } } if (!empty($user_table_fields['user_comments'])) { $sql = "SELECT user_id\n FROM " . COMMENTS_TABLE . "\n WHERE image_id = " . $image_row['image_id'] . " AND user_id <> " . GUEST; $result = $site_db->query($sql); while ($row = $site_db->fetch_array($result)) { $sql = "UPDATE " . USERS_TABLE . "\n SET " . get_user_table_field("", "user_comments") . " = " . get_user_table_field("", "user_comments") . " - 1\n WHERE " . get_user_table_field("", "user_id") . " = " . $row['user_id']; $site_db->query($sql); } } $sql = "DELETE FROM " . COMMENTS_TABLE . "\n WHERE image_id = " . $image_row['image_id']; if ($site_db->query($sql)) { echo $lang['comments_delete_success'] . "<br />\n"; } else { $error_log[] = "<b>" . $lang['comments_delete_success'] . "</b> " . $image_row['image_name'] . ", (ID: " . $image_row['image_id'] . ")<br />\n"; } echo "<br />\n"; } remove_searchwords($image_ids); return $error_log; }
$big = isset($HTTP_POST_VARS['big']) && $HTTP_POST_VARS['big'] == 1 ? 1 : $big_default; $annotate = isset($HTTP_POST_VARS['annotate']) && $HTTP_POST_VARS['annotate'] == 1 ? 1 : $annotate_default; $big_folder = isset($HTTP_POST_VARS['big_folder']) ? trim($HTTP_POST_VARS['big_folder']) : $big_folder_default; for ($i = 1; $i <= $num_newimages; $i++) { $addimage = isset($HTTP_POST_VARS['addimage_' . $i]) && $HTTP_POST_VARS['addimage_' . $i] == 1 ? 1 : 0; if ($addimage) { $image_name = trim($HTTP_POST_VARS['image_name_' . $i]); $cat_id = intval($HTTP_POST_VARS['cat_id_' . $i]); $image_download_url = isset($HTTP_POST_VARS['image_download_url_' . $i]) ? trim($HTTP_POST_VARS['image_download_url_' . $i]) : ""; if ($image_name == "") { $error['image_name_' . $i] = 1; } if ($cat_id == 0) { $error['cat_id_' . $i] = 1; } if ($image_download_url != "" && !is_remote($image_download_url) && !is_local_file($image_download_url)) { $error['image_download_url_' . $i] = 1; } if (!empty($additional_image_fields)) { foreach ($additional_image_fields as $key => $val) { if (isset($HTTP_POST_VARS[$key . '_' . $i]) && intval($val[2]) == 1 && trim($HTTP_POST_VARS[$key . '_' . $i]) == "") { $error[$key . '_' . $i] = 1; } } } } } if (empty($error)) { require ROOT_PATH . 'includes/image_utils.php'; $no_resize = 0; $convert_options = init_convert_options();
} else { $file['file_path'] = $image_row['image_download_url']; $remote_url = 1; } } elseif (is_remote_file($image_row['image_media_file'])) { preg_match("/(.+)\\.(.+)/", get_basefile($image_row['image_media_file']), $regs); $file_name = $regs[1]; $file_extension = $regs[2]; $file['file_name'] = $file_name . ($size ? "_" . $size : "") . "." . $file_extension; $file['file_path'] = dirname($image_row['image_media_file']) . "/" . $file['file_name']; } else { preg_match("/(.+)\\.(.+)/", get_basefile($image_row['image_media_file']), $regs); $file_name = $regs[1]; $file_extension = $regs[2]; $file['file_name'] = $file_name . ($size ? "_" . $size : "") . "." . $file_extension; $file['file_path'] = is_local_file($image_row['image_media_file']) ? dirname($image_row['image_media_file']) . "/" . $file['file_name'] : MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $file['file_name']; } if ($user_info['user_level'] != ADMIN) { $sql = "UPDATE " . IMAGES_TABLE . "\n SET image_downloads = image_downloads + 1\n WHERE image_id = {$image_id}"; $site_db->query($sql); } if (!empty($file['file_path'])) { @set_time_limit(120); if ($remote_url) { redirect($file['file_path']); } if ($action == "zip" && !preg_match("/\\.zip\$/i", $file['file_name']) && function_exists("gzcompress") && function_exists("crc32")) { include ROOT_PATH . "includes/zip.php"; $zipfile = new zipfile(); $zipfile->add_file(file_get_contents($file['file_path']), $file['file_name']); $zipfile->send(get_file_name($file['file_name']) . ".zip");
show_error_page($lang['no_permission']); exit; } $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file\n FROM " . IMAGES_TABLE . "\n WHERE image_id = {$image_id}"; $image_row = $site_db->query_firstrow($sql); if (!$image_row || $image_row['user_id'] <= USER_AWAITING || $user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN) { show_error_page($lang['no_permission']); exit; } $txt_clickstream = $lang['image_delete']; $sql = "DELETE FROM " . IMAGES_TABLE . "\n WHERE image_id = {$image_id}"; $del_img = $site_db->query($sql); if (!is_remote($image_row['image_media_file']) && !is_local_file($image_row['image_media_file'])) { @unlink(MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_media_file']); } if (!empty($image_row['image_thumb_file']) && !is_remote($image_row['image_thumb_file']) && !is_local_file($image_row['image_thumb_file'])) { @unlink(THUMB_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_thumb_file']); } include ROOT_PATH . 'includes/search_utils.php'; remove_searchwords($image_id); if (!empty($user_table_fields['user_comments'])) { $sql = "SELECT user_id\n FROM " . COMMENTS_TABLE . "\n WHERE image_id = {$image_id}"; $result = $site_db->query($sql); $user_id_sql = ""; while ($row = $site_db->fetch_array($result)) { if ($row['user_id'] != GUEST) { $sql = "UPDATE " . USERS_TABLE . "\n SET " . get_user_table_field("", "user_comments") . " = " . get_user_table_field("", "user_comments") . " - 1\n WHERE " . get_user_table_field("", "user_id") . " = " . $row['user_id']; $site_db->query($sql); } } }
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 ? "&" : "?") . "mode=" . $mode : ""; $lightbox_url .= strpos($lightbox_url, '?') !== false ? "&" : "?"; if (check_lightbox($image_row['image_id'])) { $lightbox_url .= "action=removefromlightbox&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&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&" . 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) ? "&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&" . 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) ? "&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; }
function delete_images($image_ids, $delfromserver = 1) { global $site_db, $lang; if (empty($image_ids)) { echo $lang['no_search_results']; return false; } $error_log = array(); echo "<br />"; $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file, l.lightbox_image_ids\n FROM " . IMAGES_TABLE . " i\n LEFT JOIN " . LIGHTBOXES_TABLE . " l ON (l.user_id = i.user_id)\n WHERE i.image_id IN ({$image_ids})"; $image_result = $site_db->query($sql); while ($image_row = $site_db->fetch_array($image_result)) { if ($image_row['user_id'] != GUEST) { $lightbox_array = explode(" ", $image_row['lightbox_image_ids']); foreach ($lightbox_array as $key => $val) { if ($val == $image_row['image_id']) { unset($lightbox_array[$key]); } } $lightbox_image_ids = trim(implode(" ", $lightbox_array)); $sql = "UPDATE " . LIGHTBOXES_TABLE . "\n SET lightbox_image_ids = '" . $lightbox_image_ids . "'\n WHERE user_id = " . $image_row['user_id']; $site_db->query($sql); } $sql = "DELETE FROM " . IMAGES_TABLE . "\n WHERE image_id = " . $image_row['image_id']; if ($site_db->query($sql)) { echo "<b>" . $lang['image_delete_success'] . "</b> " . format_text($image_row['image_name'], 2) . " (ID: " . $image_row['image_id'] . ")<br />\n"; } else { $error_log[] = "<b>" . $lang['image_delete_error'] . "</b> " . format_text($image_row['image_name'], 2) . " (ID: " . $image_row['image_id'] . ")<br />"; } if ($delfromserver) { if (!is_remote($image_row['image_media_file']) && !is_local_file($image_row['image_media_file'])) { if (@unlink(MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_media_file'])) { echo " " . $lang['file_delete_success'] . " (" . $image_row['image_media_file'] . ")<br />\n"; } else { $error_log[] = "<b>" . $lang['file_delete_error'] . " (" . $image_row['image_media_file'] . ")<br />"; } } if (!empty($image_row['image_thumb_file']) && !is_remote($image_row['image_thumb_file']) && !is_local_file($image_row['image_thumb_file'])) { if (@unlink(THUMB_PATH . "/" . $image_row['cat_id'] . "/" . $image_row['image_thumb_file'])) { echo " " . $lang['thumb_delete_success'] . " (" . $image_row['image_thumb_file'] . ")<br />\n"; } else { $error_log[] = "<b>" . $lang['thumb_delete_error'] . " (" . $image_row['image_thumb_file'] . ")<br />\n"; } } } if (!empty($user_table_fields['user_comments'])) { $sql = "SELECT user_id\n FROM " . COMMENTS_TABLE . "\n WHERE image_id = " . $image_row['image_id'] . " AND user_id <> " . GUEST; $result = $site_db->query($sql); while ($row = $site_db->fetch_array($result)) { $sql = "UPDATE " . USERS_TABLE . "\n SET " . get_user_table_field("", "user_comments") . " = " . get_user_table_field("", "user_comments") . " - 1\n WHERE " . get_user_table_field("", "user_id") . " = " . $row['user_id']; $site_db->query($sql); } } $sql = "DELETE FROM " . COMMENTS_TABLE . "\n WHERE image_id = " . $image_row['image_id']; if ($site_db->query($sql)) { echo $lang['comments_delete_success'] . "<br />\n"; } else { $error_log[] = "<b>" . $lang['comments_delete_success'] . "</b> " . format_text($image_row['image_name'], 2) . ", (ID: " . $image_row['image_id'] . ")<br />\n"; } echo "<br />\n"; } remove_searchwords($image_ids); return $error_log; }
show_hidden_input("image_id", $image_id); show_hidden_input("old_file_name", $image_row['image_media_file']); show_hidden_input("old_thumb_file_name", $image_row['image_thumb_file']); show_table_header($lang['nav_images_edit'] . ": " . format_text($image_row['image_name'], 2), 2); $file_src = get_file_path($image_row['image_media_file'], "media", 0, 1); show_image_row($lang['image'] . "<br /><span class=\"smalltext\">(" . $image_row['image_media_file'] . ")</span>", $file_src, 1); $value = is_remote($image_row['image_media_file']) || is_local_file($image_row['image_media_file']) ? $image_row['image_media_file'] : ""; show_upload_row($lang['image_file'], "file", "<br /><span class=\"smalltext\">" . $lang['allowed_mediatypes_desc'] . str_replace(",", ", ", $config['allowed_mediatypes']) . "</span>", $value); if (!empty($image_row['image_thumb_file'])) { $thumb_src = get_file_path($image_row['image_thumb_file'], "thumb", 0, 1); show_image_row($lang['thumb'] . "<br /><span class=\"smalltext\">(" . $image_row['image_thumb_file'] . ")</span>", $thumb_src, 1, "delete_thumb_file"); } else { $file_type = get_file_extension($image_row['image_media_file']); show_image_row($lang['thumb'] . "<br /><span class=smalltext>(" . $lang['no_thumb_found'] . ")</span>", ICON_PATH . "/" . $file_type . ".gif", 1); } $value = is_remote($image_row['image_thumb_file']) || is_local_file($image_row['image_thumb_file']) ? $image_row['image_thumb_file'] : ""; show_upload_row($lang['thumb_file'], "thumb_file", "<br /><span class=\"smalltext\">" . $lang['allowed_mediatypes_desc'] . " jpg, gif, png</span>", $value); show_input_row($lang['field_download_url'] . $lang['download_url_desc'], "image_download_url", "", $textinput_size); show_input_row($lang['field_image_name'], "image_name", $image_row['image_name'], $textinput_size); show_textarea_row($lang['field_description_ext'], "image_description", $image_row['image_description'], $textarea_size); show_textarea_row($lang['field_keywords_ext'], "image_keywords", $image_row['image_keywords'], $textarea_size); show_cat_select_row($lang['field_category'], $image_row['cat_id'], 3); show_user_select_row($lang['user'], $image_row['user_id']); show_input_row($lang['field_date'] . $lang['date_desc'], "image_date", $image_row['image_date'], $textinput_size); show_additional_fields("image", $image_row, IMAGES_TEMP_TABLE); show_form_footer($lang['save_changes'], $lang['reset'], 2, "", " onClick='showProgress()'"); } if ($action == "saveimages") { $image_list = isset($HTTP_POST_VARS['image_list']) ? $HTTP_POST_VARS['image_list'] : ""; if (!empty($image_list)) { $image_id_sql = "";