Der Code von meiner images.php
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: images.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7 - 1.7.9 *
* File Version: 4.15.7 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
/*
Changes since previous version:
- FIXED: search keywords not being saved at quick edit unless image keywords edited
- FIXED: yet another issue with keywords when adding images
*/
define('IN_CP', 1);
define('ROOT_PATH', './../');
require('admin_global.php');
@include_once(ROOT_PATH . 'includes/ims_core.php');
define('MAIN_SCRIPT', 'images.php');
define('SCRIPT', MAIN_SCRIPT); //backwards compatibility with config file from previous versions
define('KEYWORDS_NEW', version_compare(SCRIPT_VERSION, "1.7.8", ">="));
$additional_image_fields_settings = array();
$preset = array();
/*
These are default settings. You should NOT change them. Instead, use admin/images_config.php to override any of these default settings.
Doing so you won't need edit this file after each update.
*/
//--- Settings -----------------------
$thumbsize = 48; //thumbnail size showed at find image page (will be resized by browser)
$imagesize = 640; //image size showed at edit image page (will be resized by browser)
//quick edit description and keywords field size
$cols = 30; //textarea width
$rows = 4; //textarea height
$target = true; //Open links to edit/delete a single image in a new window? (true or false)
$limitnumber = 25; //number of images per page by default
//Quick Edit options:
$quickedit_checkboxes = 0; //1 = show checkboxes; 0 = show multiline dropdown
$quickedit_checkboxes_height = 200; //when show checkboxes limit height of the column in pixels (0 = disable)
$quickedit_default = array(); //list of image fields that will be selected by default and after search form reset.
//example select image name, description and date by default or when reset search form
/*
$quickedit_default = array(
"image_name",
"image_description",
"image_date",
);
*/
$nextpage_default = 1; //select "Continue next page after save" by default? (1 = yes, 0 = no)
$savedate = 1; //select "save date" on copy/move by default? (1 = yes, 0 = no)
$use_media_template = 1; //use media template at edit image page (useful for non-image files)
$num_newimages_max = 10; //max number of "add new images"
$exif_enable = 1; //use exif? if PHP doesn't support read_exif_data() function, this setting will be ignored and exif support will be disabled.
$image_resize_default = 1; //resize image by default for add new images page (1 = yes, 0 = no)
$thumb_tools_default = 2; //thumbnail tools by default for add new images page (0 = skip, 1 = resize, 2 = create)
$image_resize_type = -1; //image resize type (-1 = use settings, 1 = proportionally, 2 = fixed width, 3 = fixed height)
$image_resize_quality = -1; //image quality (-1 = use settings, 0-100 = quality)
$image_resize_width = -1; //image resize width (-1 = use settings)
$image_resize_height = -1; //image resize height (-1 = use settings)
$thumb_resize_type = -1; //thumbnail resize type (-1 = use settings, 1 = proportionally, 2 = fixed width, 3 = fixed height)
$thumb_resize_quality = -1; //thumbnail quality (-1 = use settings, 0-100 = quality)
$thumb_resize_dimension = -1; //thumbnail resize dimention (-1 = use settings)
$presets_session = 0; //use sessions to store presets? (1 = yes, 0 = no) If no, use $presets_file
$presets_file = ROOT_PATH."data/images_presets.txt"; //file where presets will be stored. Must be writable!
//--- End Settings -------------------
//--- Additional Fields Settings -----
/*
$additional_image_fields_settings["example_field_name0"] = array(true, "%s = '%s'"); //show this field in the search form and do exact string match, this should be used for radio type fields
$additional_image_fields_settings["example_field_name1"] = array(true, "%s LIKE '%s'");
$additional_image_fields_settings["example_field_name2"] = array(true, "%s LIKE '%s\%'");
$additional_image_fields_settings["example_field_name3"] = array(true, "%s LIKE '\%%s'");
$additional_image_fields_settings["example_field_name4"] = array(true, "INSTR(LCASE(%s), '%s')"); //show this field in the search form and search using INSTR() mysql function
$additional_image_fields_settings["example_field_name5"] = array(false, ""); //don't show this field in the search form
*/
//--- End Additional Fields Settings--
//--- Language Settings --------------
if (!isset($lang['big_not_found']))
{
if ($config['language_dir'] == "deutsch")
{
$lang['changeowner'] = "Username ersetzen";
$lang['copy'] = "Kopieren";
$lang['move'] = "Verschieben";
$lang['save'] = "Speichern";
$lang['big_not_found'] = "Kein Original in Big Ordner gefunden";
$lang['orig_not_found'] = "Kein Original gefunden";
$lang['copy_file_error_perm'] = "Error Kopieren. (Datei %s zu %s) Bitte uberprufe Deine Ordner Rechte.";
$lang['skipped'] = "Ubersprungen";
$lang['in_cat_id'] = "von Kategorie ID";
$lang['error_del_big'] = "Error geloschte \"Big\" Datei";
$lang['error_del_backup'] = "Error geloschte \"Backup\" Datei";
$lang['src_des_same'] = "Quelle und Ziel sind gleich";
$lang['owner_error'] = "Error User ersetzen";
$lang['no_user_select'] = "Kein User ausgewahlt";
$lang['owner_success'] = "Username erfolgreich gewechselt";
$lang['file_delete_success'] = "Bild-Datei erfolgreich geloscht";
$lang['file_big_delete_success'] = "Bild-Datei in Big Ordner erfolgreich geloscht";
$lang['user_id_contains'] = "User ID enthalt";
$lang['image_active'] = "Aktiviert";
$lang['quick_edit'] = "Bilder Optionen";
$lang['continue_next_page'] = "Weiter auf nachste Seite";
$lang['move_confirm'] = "Verschiebe Datei(en) nach Kategorie <b>%s</b> [ID: %s]?";
$lang['error_log'] = "Ereignis Log:";
$lang['save_log'] = "Save Log:";
$lang['image_update_success'] = "Bilder erfolgreich aktualisiert";
$lang['copy_confirm'] = "Kopiere Datei(en) nach <b>%s</b> [ID: %s]?";
$lang['upload_error'][0] = "Error Bild aktualisierung"; //single
$lang['upload_error'][1] = "Error Bilder aktualisierung"; //plural
$lang['upload_success'][0] = "Bild erfolgreich aktualisiert"; //single
$lang['upload_success'][1] = "Bilder erfolgreich aktualisiert"; //plural
$lang['edit_image'][0] = "Editiere Bild";
$lang['edit_image'][1] = "Editiere Bilder";
$lang['cat_image'] = "Kategorie Bild";
$lang['current_image'] = "Aktuelles Bild:";
$lang['copy_success'] = "<b>Bild \"%s\" erfolgreich kopiert</b> (von Kategorie %s nach %s)";
$lang['copy_error_skipped'] = "<b>Bild</b> %s <b>wurde nicht kopiert</b>";
$lang['copy_error_thumb'] = "<b>Error Thumbnail Datei kopieren</b> %s";
$lang['copy_error_media'] = "<b>Error Media Datei kopieren</b> %s";
$lang['copy_error_db'] = "<b>Error Datenbank Update. Bild %s wurde nicht kopiert</b>";
$lang['move_success'] = "<b>Bild \"%s\" erfolgreich verschoben</b> (von Kategorie %s nach %s)";
$lang['move_error'] = "<b>Error Bild verschieben</b> %s (from category: %s to %s)";
$lang['move_error_thumb'] = "<b>Error Thumbnail Datei verschieben</b> %s";
$lang['move_error_media'] = "<b>Error Media Datei verschieben</b> %s";
$lang['move_error_skipped'] = "<b>Bild</b> %s <b>wurde nicht verschoben</b>";
$lang['move_error_db'] = "<b>Error Datenbank Update. Bild %s wurde nicht verschoben</b>";
$lang['no_image'] = "Kein Bild mit dieser ID gefunden";
$lang['save_date'] = "Speichere Original Datum";
$lang['save_date_exp'] = "Bei nicht aktivierter CheckBox wird das heutige Datum eingefugt!";
$lang['ims_file_delete_success'] = "Bild Cache Datei erfolgreich geloscht (<i>%s</i>)";
$lang['ims_file_delete_error'] = "Error loschen Bild Cache Datei (<i>%s</i>)";
$lang['additional_fields'] = "Zusatzliche Bild Felder <span class=\"smalltext\">(muss aktiviert sein durch das Auswahlmenu neben jedem Feld)</span>";
$lang['default'] = "Standard";
$lang['edit_log'] = "Editiere Bilder Log:";
$lang['quick_edit_fields'] = "Schnelle editierbare Felder";
$lang['quick_edit_fields_exp'] = "<span class=\"smalltext\"><i>(Selektiere mehrere Felder, drucke und halte die CTRL Taste, wahle dann die gewunschten Felder.<br />Entferne ein Feld, drucke die CTRL Taste und klicke auf das selektierte Feld.<br />Ist nichts ausgewahlt, ist die Funktion ausgeschaltet.)</i></span>";
$lang['field_cat_id'] = "Kategorie ID";
$lang['field_user_id'] = "User ID";
$lang['field_media_file'] = "Media Datei";
$lang['select_all'] = "Alle auswahlen";
$lang['select_none'] = "Nichts auswahlen";
$lang['comments_delete_success'] = "Kommentar(e) erfolgreich geloscht";
$lang['comments_delete_error'] = "Error Kommentar(e) loschen";
$lang['skip'] = "Uberspringen";
$lang['resize'] = "Verkleinern";
$lang['create_thumb'] = "Erstellen";
$lang['thumb_tools_add'] = "Thumbnail Werkzeug<br /><span class=\"smalltext\"><b>Verkleinern</b> - Hochgeladenes Thumbnail verkleinern<br /><b>Erstellen</b> - Erstelle Thumbnail von Media Datei</span>";
$lang['thumb_tools_edit'] = "Thumbnail Werkzeug<br /><span class=\"smalltext\"><b>Loschen</b> - Losche existierendes Thumbnail<br /><b>Verkleinern</b> - Verkleinere existierendes oder neu hochgeladenes Thumbnail<br /><b>Erstellen</b> - Erstelle Thumbnail von Media Datei</span>";
$lang['image_resize'] = "Verkleinertes Bild";
$lang['image_resize_skipped'] = "Bild verkleinern ubersprungen";
$lang['image_resize_error'] = "Bild Error verkleinern";
$lang['image_resize_success'] = "<b>Bild verkleinert</b> (von %sx%s nach %sx%s)";
$lang['thumb_resize_skipped'] = "Thumbnail verkleinern ubersprungen";
$lang['thumb_resize_error'] = "Thumbnail Error verkleiner";
$lang['thumb_resize_success'] = "Thumbnail verkleinert";
$lang['thumb_create_skipped'] = "Thumbnail erstellen ubersprungen";
$lang['thumb_create_error'] = "Thumbnail Error erstellen";
$lang['thumb_create_success'] = "Thumbnail erstellt";
$lang['log'] = "Log";
$lang['load'] = "Laden";
$lang['msg'] = "Nachricht";
$lang['presets'] = "Einstellungen";
$lang['preset_save'] = "Einstellungen in einer Datei speichern<br /><span class=\"smalltext\">Ist die Checkbox vor dem Speichern aktiviert, werden die Einstellungen immer \"Automatisch geladen\"</span>";
$lang['preset_load_error'] = "Error Einstellungen laden";
$lang['preset_delete_error'] = "Error Einstellungen loschen";
$lang['preset_save_error'] = "Error Einstellungen speichern";
$lang['preset_loaded'] = "Geladen";
$lang['qe_cat_id_error'] = "Kategorie mit ID \"%s\" existiert nicht";
$lang['include_subcats'] = "Inklusive Subkategorien";
}
else
{
$lang['changeowner'] = "Change owner";
$lang['copy'] = "Copy";
$lang['move'] = "Move";
$lang['save'] = "Save";
$lang['big_not_found'] = "No Original size (big) Found";
$lang['orig_not_found'] = "No Original Found";
$lang['copy_file_error_perm'] = "Copy error. (File %s to %s) Please check the directory permissions.";
$lang['copy_success'] = "<b>Image \"%s\" successfully copied</b> (from category %s to %s)";
$lang['copy_error_thumb'] = "<b>Error copying thumbnail file</b> %s";
$lang['copy_error_media'] = "<b>Error copying media file</b> %s";
$lang['copy_error_skipped'] = "<b>Image</b> %s <b>was not coppied</b>";
$lang['copy_error_db'] = "<b>Error updating database. Image %s was not coppied</b>";
$lang['skipped'] = "Skipped";
$lang['in_cat_id'] = "in category ID";
$lang['error_del_big'] = "Error deleting \"big\" file";
$lang['error_del_backup'] = "Error deleting \"backup\" file";
$lang['src_des_same'] = "Source and destination are the same";
$lang['move_success'] = "<b>Image \"%s\" successfully moved</b> (from category %s to %s)";
$lang['move_error'] = "<b>Error moving image</b> %s (from category: %s to %s)";
$lang['move_error_thumb'] = "<b>Error moving thumbnail file</b> %s";
$lang['move_error_media'] = "<b>Error moving media file</b> %s";
$lang['move_error_skipped'] = "<b>Image</b> %s <b>was not moved</b>";
$lang['move_error_db'] = "<b>Error updating database. Image %s was not moved</b>";
$lang['owner_error'] = "Error changing owner";
$lang['no_user_select'] = "No user selected";
$lang['owner_success'] = "Owner successfuly changed";
$lang['file_delete_success'] = "Image file successfully deleted";
$lang['file_big_delete_success'] = "Image file successfully in Big file deleted";
$lang['user_id_contains'] = "User ID contains";
$lang['image_active'] = "Activated";
$lang['quick_edit'] = "Quick edit";
$lang['continue_next_page'] = "Continue next page after save";
$lang['save_date'] = "Save original date";
$lang['save_date_exp'] = "If checked, the images original date will not be changed, otherwise current date will be used";
$lang['move_confirm'] = "Move image files to category <b>%s</b> [ID: %s]?";
$lang['error_log'] = "Error Log:";
$lang['save_log'] = "Save Log:";
$lang['image_update_success'] = "Images successfuly updated";
$lang['copy_confirm'] = "Copy image(s) to category <b>%s</b> [ID: %s]?";
$lang['upload_error'][0] = "Error updating image"; //single
$lang['upload_error'][1] = "Error updating images"; //plural
$lang['upload_success'][0] = "Image updated successfuly"; //single
$lang['upload_success'][1] = "Images updated successfuly"; //plural
$lang['edit_image'][0] = "Edit image"; //single
$lang['edit_image'][1] = "Edit images"; //plural
$lang['cat_image'] = "Category image";
$lang['current_image'] = "Current image:";
$lang['no_image'] = "No image found with this ID";
$lang['additional_fields'] = "Additional image fields <span class=\"smalltext\">(must be enabled by the dropdown menu next to each field)</span>";
$lang['ims_file_delete_success'] = "Image cache file successfully deleted (<i>%s</i>)";
$lang['ims_file_delete_error'] = "Error deleting image cache file (<i>%s</i>)";
$lang['default'] = "Default";
$lang['edit_log'] = "Edit images log";
$lang['quick_edit_fields'] = "Quick Edit Fields";
$lang['quick_edit_fields_exp'] = "<span class=\"smalltext\"><i>(To select multiple fields press and hold CTRL key, then click on needed field.<br />To deselect hold CTRL key and click on selected field.<br />If nothing selected quick edit will be disabled)</i></span>";
$lang['field_cat_id'] = "Category ID";
$lang['field_user_id'] = "User ID";
$lang['field_media_file'] = "Media file";
$lang['select_all'] = "Select all";
$lang['select_none'] = "Select none";
$lang['comments_delete_success'] = "Comment(s) deleted";
$lang['comments_delete_error'] = "Error deleting comment(s)";
$lang['skip'] = "Skip";
$lang['resize'] = "Resize";
$lang['create_thumb'] = "Create";
$lang['thumb_tools_add'] = "Thumbnail tools<br /><span class=\"smalltext\"><b>Resize</b> - resize uploaded thumbnail<br /><b>Create</b> - create thumbnail from image file</span>";
$lang['thumb_tools_edit'] = "Thumbnail tools<br /><span class=\"smalltext\"><b>Delete</b> - delete existing thumbnail<br /><b>Resize</b> - resize existing or new uploaded thumbnail<br /><b>Create</b> - create thumbnail from image file</span>";
$lang['image_resize'] = "Resize image";
$lang['image_resize_skipped'] = "Image resize skipped";
$lang['image_resize_error'] = "Image resize error";
$lang['image_resize_success'] = "<b>Image resized</b> (from %sx%s to %sx%s)";
$lang['thumb_resize_skipped'] = "Thumbnail resize skipped";
$lang['thumb_resize_error'] = "Thumbnail resize error";
$lang['thumb_resize_success'] = "Thumbnail resized";
$lang['thumb_create_skipped'] = "Thumbnail create skipped";
$lang['thumb_create_error'] = "Thumbnail create error";
$lang['thumb_create_success'] = "Thumbnail created";
$lang['log'] = "Log";
$lang['load'] = "Load";
$lang['msg'] = "Message";
$lang['presets'] = "Presets";
$lang['preset_save'] = "Save this form in a preset<br /><span class=\"smalltext\">Use the checkbox to save the preset as \"auto load\"</span>";
$lang['preset_load_error'] = "Error loading preset";
$lang['preset_delete_error'] = "Error deleting preset";
$lang['preset_save_error'] = "Error saving preset";
$lang['preset_loaded'] = "loaded";
$lang['qe_cat_id_error'] = "Category with ID \"%s\" doesn't exist";
$lang['include_subcats'] = "Include subcategories";
}
}
//--- End Language Settings ----------
@include(ROOT_PATH . 'admin/images_config.php');
/*set BIGDIR variable with the name of your "big" folder for "big" images (no trailing slashes!)*/
//define("BIGDIR", "");
if (!defined('BIGDIR'))
{
define('BIGDIR', "big"); // http://www.4homepages.de/forum/index.php?topic=3236.0
}
/*set BACKUPDIR variable with the full path to your backup dir (no trailing slashes!)*/
if (!defined('BACKUPDIR'))
{
define('BACKUPDIR', "");
// define('BACKUPDIR', "/home/4images/backup"); //example full path on unix systems
// define('BACKUPDIR', "C:/4images/backup"); //example full path on windows systems
}
if (!defined("EXIF_ENABLE"))
{
$exif_enble = (function_exists("read_exif_data")) ? $exif_enable : 0;
define("EXIF_ENABLE", $exif_enable);
}
$header_insert = "<style>.tablerow_error {
BACKGROUND-COLOR: #ECDFDF;
}
.tablerow2_error {
BACKGROUND-COLOR: #F9F2F2;
}
.categoryselect {
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
color: #0f5475;
font-size: 11px;
}
.categoryselect1 {
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
color: #0f5475;
font-size: 11px;
BACKGROUND-COLOR: #F9F8D2;
}
</style>
<script type=\"text/javascript\">
<!--
function changeStyle(obj, c)
{
obj.className=c;
}
function get_element(f, e)
{
alert(f.e);
}
// -->
</script>
";
include(ROOT_PATH.'includes/search_utils.php');
// Start Upload
include(ROOT_PATH.'includes/upload.php');
$site_upload = new Upload();
include(ROOT_PATH.'includes/image_utils.php');
$convert_options = init_convert_options();
if ($action == "")
{
$action = "modifyimages";
}
if (isset($HTTP_POST_VARS['action2']) && !empty($HTTP_POST_VARS['action2']))
{
$action = $HTTP_POST_VARS['action2'];
}
$action = fixaction($action); // since we use $lang for some actions we should remove any spaces
$owner = $user_info['user_id'];
$types_array_text = array(
"LIKE" => "%s LIKE '%s'",
"LIKE %...%" => "%s LIKE '%%%s%%'",
"NOT LIKE" => "%s NOT LIKE '%s'",
"=" => "%s = '%s'",
"!=" => "%s != '%s'",
"REGEXP" => "%s REGEXP '%s'",
"NOT REGEXP" => "%s NOT REGEXP '%s'",
);
$types_array_int = array(
"=" => "%s = '%s'",
"!=" => "%s != '%s'",
">" => "%s > '%s'",
">=" => "%s >= '%s'",
"<" => "%s < '%s'",
"<=" => "%s <= '%s'",
);
$types_array_radio = array(
"=" => "%s = '%s'",
);
$types_array_dropdown = array(
"=" => "%s = '%s'",
"!=" => "%s != '%s'",
);
$fields_default = array(
"image_name" => array($lang['field_image_name'], "text"),
"cat_id" => array($lang['field_cat_id'], "text", array(1)),
"user_id" => array($lang['field_user_id'], "text", array(1)),
"image_description" => array($lang['field_description'], "textarea"),
"image_keywords" => array($lang['field_keywords'], "textarea"),
"image_date" => array($lang['field_date'], "date"),
"image_active" => array($lang['field_free'], "radio", array(1)),
// "image_media_file" => array($lang['field_media_file'], "text"),
// "image_thumb_file" => array($lang['field_thumb_file'], "text"),
"image_download_url" => array($lang['field_download_url'], "text"),
"image_allow_comments" => array($lang['field_allow_comments'], "radio", array(1)),
"image_comments" => array($lang['field_comment'], "text", array(1)),
"image_downloads" => array($lang['field_downloads'], "text", array(1)),
"image_votes" => array($lang['field_votes'], "text", array(1)),
"image_rating" => array($lang['field_rating'], "text", array(1)),
"image_hits" => array($lang['field_hits'], "text", array(1)),
);
$quickedit_fields_all = $fields_default;
$table_fields = $site_db->get_table_fields(IMAGES_TABLE);
$preset_additional_fields = array();
foreach ($additional_image_fields as $field => $val)
{
if (!isset($table_fields[$field]) || (isset($additional_image_fields_settings[$field][0]) && !$additional_image_fields_settings[$field][0]))
continue;
$quickedit_fields_all[$field] = $val;
$value = "";
if ($val[1] == "radio")
{
$value = 1;
}
$preset_additional_fields[$field."_type"] = array("int", 0);
$preset_additional_fields[$field] = array("trim", $value);
}
//--- Presets ------------------------
// doesn't work (yet)
$preset = "default";
if (!$presets_session || ($presets_session && !$presests = $site_sess->get_session_var("acp_images_presets")))
{
$presets = @file_get_contents($presets_file);
}
if (!$presets = @unserialize($presets))
{
$presets = array();
}
$presets['default'] = array(
"image_id_type" => array("int", -1),
"image_id" => array("int", ""),
"image_name_type" => array("int", -1),
"image_name" => array("trim", ""),
"image_description_type" => array("int", -1),
"image_description" => array("trim", ""),
"image_keywords_type" => array("int", -1),
"image_keywords" => array("trim", ""),
"cat_id_type" => array("int", -1),
"cat_id" => array("int", 0),
"user_id_type" => array("int", -1),
"user_id" => array("int", ""),
"user_name_type" => array("int", -1),
"user_name" => array("trim", ""),
"image_active" => array("int", 1),
"image_media_file_type" => array("int", -1),
"image_media_file" => array("trim", ""),
"image_thumb_file_type" => array("int", -1),
"image_thumb_file" => array("trim", ""),
"dateafter" => array("trim", ""),
"datebefore" => array("trim", ""),
"downloadsupper" => array("int", ""),
"downloadslower" => array("int", ""),
"ratingupper" => array("trim", ""),
"ratinglower" => array("trim", ""),
"votesupper" => array("int", ""),
"voteslower" => array("int", ""),
"hitsupper" => array("int", ""),
"hitslower" => array("int", ""),
"orderby" => array("trim", "i.image_date"),
"direction" => array("trim", "DESC"),
"limitnumber" => array("int", $limitnumber),
"additional_fields" => array("", $preset_additional_fields),
"quickedit" => array("", $quickedit_default),
"subcat" => array("bool", 1),
);
if (!isset($presets['_default_']))
{
$presets['_default_'] = $preset;
}
$preset_new = (isset($HTTP_POST_VARS['preset']) && $HTTP_POST_VARS['preset']) ? trim($HTTP_POST_VARS['preset']) : ((isset($HTTP_GET_VARS['preset']) && $HTTP_GET_VARS['preset']) ? trim($HTTP_GET_VARS['preset']) : false);
if (!$preset_new || !isset($presets[$preset]))
{
$preset = $presets['_default_'];
}
else
{
$preset = $preset_new;
}
//--- End Presets -----
$image_resize_type = ($image_resize_type != -1) ? $image_resize_type : (isset($config['auto_image_resize_type']) ? $config['auto_image_resize_type'] : $config['auto_thumbnail_resize_type']);
$image_resize_quality = ($image_resize_quality != -1) ? $image_resize_quality : (isset($config['auto_image_quality']) ? $config['auto_image_quality'] : $config['auto_thumbnail_quality']);
$image_resize_width = ($image_resize_width != -1) ? $image_resize_width : $config['max_image_width'];
$image_resize_height = ($image_resize_height != -1) ? $image_resize_height : $config['max_image_height'];
$thumb_resize_type = ($thumb_resize_type != -1) ? $thumb_resize_type : $config['auto_thumbnail_resize_type'];
$thumb_resize_quality = ($thumb_resize_quality != -1) ? $thumb_resize_quality : $config['auto_thumbnail_quality'];
$thumb_resize_dimension = ($thumb_resize_dimension != -1) ? $thumb_resize_dimension : $config['auto_thumbnail_dimension'];
function preset_save()
{
global $presets, $site_sess, $msg, $presets_session, $presets_file;
$data = $presets;
unset($data['default']);
$data = serialize($data);
if ($presets_session || !@file_put_contents($presets_file, $data))
{
$site_sess->set_session_var("acp_images_presets", $data);
}
}
if (!function_exists("get_exif_insert_link"))
{
function get_exif_insert_link($file, $tag, $input, $add_text = 1, $before = "", $after = "")
{
if (!EXIF_ENABLE || !function_exists('exif_read_data') || !$exif_data = @exif_read_data($file, 'EXIF'))
return;
if (!isset($exif_data[$tag]))
return;
global $lang;
$value = "";
switch ($tag)
{
case "DateTimeOriginal":
case "DateTime":
case "DateTimeDigitized";
$value = preg_replace("/([0-9]{4}):([0-9]{2}):([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/", "\\1-\\2-\\3 \\4:\\5:\\6", $exif_data[$tag]);
break;
default:
$value = $exif_data[$tag];
break;
}
if (!empty($value))
{
$txt = (isset($lang['exif_'.$tag])) ? $lang['exif_'.$tag] : "EXIF: ".$tag;
/*
$html .= "<script language=\"javascript\">\n<!--\n";
$html .= "this.document.writeln('".(isset($beforeafter[0]) ? $beforeafter[0] : "")."<input type=\"button\" value=\"$txt\" onClick=\"this.form.elements[\'".$input."\'].value=".(($add_text) ? "this.form.elements[\'".$input."\'].value + " : "")."\'".trim(str_replace('"', '"', str_replace("'", "\'", $value)))."\'\" class=\"button\"> $value".(isset($beforeafter[1]) ? $beforeafter[1] : "")."');";
$html .= "\n//-->\n</script>\n";
*/
$html = $before;
$html .= "<input type=\"button\" value=\"$txt\" onClick=\"this.form.elements['".$input."'].value=".(($add_text) ? "this.form.elements['".$input."'].value + " : "")."'".trim(str_replace('"', '"', $value))."'\" class=\"button\"> $value";
$html .= $after;
return $html;
}
}
}
function _show_num_select_row($title, $option, $desc = "", $max = 10)
{
global $site_sess, $PHP_SELF, $action, $$option;
if ($max < ${$option})
$max = ${$option};
echo "<tr class=\"".get_row_bg()."\">\n<td><p>".$title."</p></td>\n";
echo "<td align=\"right\"><p>".$desc;
$url = $PHP_SELF;
$url .= preg_match("/\?/", $url) ? "&" : "?";
$url .= "action=".$action;
$url = $site_sess->url($url);
echo "<select name=\"num\" onchange=\"window.location=('".$url."&";
echo $option."='+this.options[this.selectedIndex].value)\">\n";
for ($i = 1; $i <= $max; $i++)
{
echo "<option value=\"$i\"";
if ($i == ${$option})
{
echo " selected";
}
echo ">".$i."</option>\n";
}
echo "</select> ";
echo "<script type=\"text/javascript\">
function checkEnter(e,v){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable
if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}
if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
window.location=('".$url."&".$option."='+v);
return false
}
else{
return true
}
}
</script>";
echo "<input name=\"num2\" value=\"".${$option}."\" size=\"3\" onkeypress=\"return checkEnter(event, this.value);\"></p></td>\n</tr>\n";
}
if (!function_exists("safe_htmlspecialchars"))
{
function safe_htmlspecialchars($chars)
{
// Translate all non-unicode entities
$chars = preg_replace(
'/&(?!(#[0-9]+|[a-z]+);)/si',
'&',
$chars
);
$chars = str_replace(">", ">", $chars);
$chars = str_replace("<", "<", $chars);
$chars = str_replace('"', """, $chars);
return $chars;
}
}
function get_type_dropdown($name, $select = 0, $type = "text", $field = "", $default = true, $empty = true, $class = "", $js = "")
{
global $HTTP_POST_VARS;
if (isset($HTTP_POST_VARS[$name]))
{
$select = (int)$HTTP_POST_VARS[$name];
}
$return = "<select name=\"" . $name . "\" class=\"categoryselect" . $class . "\" " . $js . ">\n";
$return .= get_type_dropdown_options($select, $type, $field, $default, $empty);
$return .= "</select>\n";
return $return;
}
function get_type_dropdown_options($select = 0, $type = "text", $field = "", $default = true, $empty = true)
{
global $lang;
switch ($type)
{
case "radio":
$var = "radio";
break;
case "dropdown":
$var = "dropdown";
break;
default:
$var = (strstr(strtolower($field), "int") === false) ? "text" : "int";
break;
}
$var = "types_array_" . $var;
global $$var;
$var = array_keys($$var);
$return = "";
$count = count($var);
if ($empty)
{
$return .= "<option value=\"0\"" . (!$select ? " selected" : "") . "></option>\n";
}
if ($default)
{
$return .= "<option value=\"-1\"" . ($select == -1 ? " selected" : "") . ">" . $lang['default'] . "</option>\n";
}
for($i = 1; $i <= $count; $i++)
{
$selected = ($select == $i) ? " selected" : "";
$return .= "<option value=\"" . $i . "\"" . $selected . ">" . $var[$i-1] . "</option>\n";
}
return $return;
}
function get_type_condition($select = 0, $type = "text", $field = "", $default = true, $empty = true, $array = array(""))
{
if ($select == -1) return false; //use default
if ($default) $select--;
if ($empty) $select--;
switch ($type)
{
case "radio":
$var = "radio";
break;
case "dropdown":
$var = "dropdown";
break;
default:
$var = (strstr(strtolower($field), "int") === false) ? "text" : "int";
break;
}
$var = "types_array_" . $var;
global $$var;
$key = array_keys($$var);
$var = array_values($$var);
if (!isset($var[$select]) || ($key[$select] == "REGEXP" && !$array[1]))
return false;
return vsprintf($var[$select], $array);
}
function show_input_row_type($title, $name, $value = "", $size = "", $type = null, $default = true, $empty = true)
{
if ($type !== null)
{
$d = ($empty) ? 0 : (($default) ? -1 : $type[0]);
$class = ($type[0] == $d) ? "" : 1;
$js = "onChange=\"changeStyle(this,'categoryselect1');if(this.value!=" . $d . "){changeStyle(this,'categoryselect1');}else{changeStyle(this,'categoryselect');}\"";
$title = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"rowtitle\"><td width=\"100%\">".$title."</td>";
$title .= "<td>" . get_type_dropdown($name . "_type", $type[0], "", $type[1], $default, $empty, $class, $js) . "</td></table>";
}
echo "<div>";
show_input_row($title, $name, $value, $size);
echo "</div>";
}
function show_cat_select_row_type($title, $cat_id, $admin = 0, $i = 0, $type = null, $default = true, $empty = true, $subcat = null)
{
if ($type !== null)
{
$d = ($empty) ? 0 : (($default) ? -1 : $type);
$class = ($type == $d) ? "" : 1;
$js = "onChange=\"if(this.value!=" . $d . "){changeStyle(this, 'categoryselect1');}else{changeStyle(this, 'categoryselect')}\"";
$title = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"rowtitle\"><td width=\"100%\">".$title."</td>";
$title .= "<td>" . get_type_dropdown("cat_id_type", $type, "dropdown", "", $default, $empty, $class, $js) . "</td></table>";
}
ob_start();
show_cat_select_row($title, $cat_id, $admin, $i);
$dropdown = ob_get_contents();
ob_end_clean();
if ($subcat !== null)
{
global $lang;
$radio = ' <label for="subcat"><input type="checkbox" name="subcat" id="subcat"' . ($subcat ? ' checked=checked' : '') . ($cat_id ? '' : ' disabled') . '> ' . $lang['include_subcats'] . '</label>';
$dropdown = str_replace("</td>\n</tr>", $radio . "\n</td>\n</tr>", $dropdown);
$select = 'name="cat_id" onchange="this.form.subcat.disabled = (this.value == 0);"';
$dropdown = str_replace('name="cat_id"', $select, $dropdown);
}
echo $dropdown;
}
function show_user_dropdown_row_type($name, $val, $value = 0, $type = null, $default = true, $empty = true)
{
if ($type !== null)
{
$d = ($empty) ? 0 : (($default) ? -1 : $type);
$class = ($type == $d) ? "" : 1;
$js = "onChange=\"if(this.value!=" . $d . "){changeStyle(this, 'categoryselect1');}else{changeStyle(this, 'categoryselect')}\"";
$val[0] = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"rowtitle\"><td width=\"100%\">".$val[0]."</td>";
$val[0] .= "<td>" . get_type_dropdown($name . "_type", $type, "dropdown", "", $default, $empty, $class, $js) . "</td></table>";
}
if (function_exists("show_user_dropdown_row"))
show_user_dropdown_row($name, $val, $value);
}
function show_radio_row_type($title, $name, $value = 1, $type = null, $default = true, $empty = true)
{
if ($type !== null)
{
$d = ($empty) ? 0 : (($default) ? -1 : $type);
$class = ($type == $d) ? "" : 1;
$js = "onChange=\"if(this.value!=" . $d . "){changeStyle(this, 'categoryselect1');}else{changeStyle(this, 'categoryselect')}\"";
$title = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"rowtitle\"><td width=\"100%\">".$title."</td>";
$title .= "<td>" . get_type_dropdown($name . "_type", $type, "radio", "", $default, $empty, $class, $js) . "</td></table>";
}
show_radio_row($title, $name, $value);
}
if (!function_exists("redirect"))
{
function redirect($url)
{
global $script_url, $site_sess;
if (strpos($url, '://') === false)
{
$url = $script_url.'/'.$url;
}
$location = @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ? 'Refresh: 0; URL=' : 'Location: ';
if (is_object($site_sess))
{
$url = $site_sess->url($url, "&");
}
header($location.$url);
exit;
}
}
function get_resize2($file, $dim, $height = false, $file_info = false)
{
if ($file_info === false)
{
$file_info = @getimagesize($file);
}
if (!$file_info)
return array(0, 0, array(), 0);;
$width = $file_info[0];
$height = $file_info[1];
if ($width && $height)
{
if ($width > $dim || $height > $dim)
{
@$ratio = $width / $height;
if ($ratio > 1)
{
$new_width = $dim;
$new_height = round(($dim/$width) * $height);
}
else
{
$new_width = round(($dim/$height) * $width);
$new_height = $dim;
}
}
else
{
$new_width = $width;
$new_height = $height;
}
}
else
{
$new_width = $dim;
$new_height = $dim;
}
return array($new_width, $new_height, $file_info, 1);
}
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
FROM ".IMAGES_TABLE." i
LEFT JOIN ".LIGHTBOXES_TABLE." l ON (l.user_id = i.user_id)
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."
SET lightbox_image_ids = '".$lightbox_image_ids."'
WHERE user_id = ".$image_row['user_id'];
$site_db->query($sql);
}
$sql = "DELETE FROM ".IMAGES_TABLE."
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 (BIGDIR)
{
if (@unlink(MEDIA_PATH."/".$image_row['cat_id']."/".BIGDIR."/".$image_row['image_media_file']))
{
echo " ".$lang['file_big_delete_success']." (".BIGDIR."/".$image_row['image_media_file'].")<br />\n";
}
else
{
echo " ".$lang['big_not_found']." <br />\n";
}
}
if (BACKUPDIR)
{
if (@unlink(BACKUPDIR."/".$image_row['cat_id']."/".$image_row['image_media_file']))
{
echo " ".$lang['file_delete_success']." (".BACKUPDIR."/".$image_row['image_media_file'].")<br />\n";
}
else
{
echo " ".$lang['orig_not_found']." <br />\n";
}
}
}
if (defined("IMS_DIR"))
{
$list = IMS_getFileList($image_row);
foreach($list as $file)
{
if (@unlink($file))
{
echo " ".sprintf($lang['ims_file_delete_success'], $file)."<br />\n";
}
else
{
echo " ".sprintf($lang['ims_file_delete_error'], $file)."<br />\n";
}
}
}
if (!empty($user_table_fields['user_comments']))
{
$sql = "SELECT user_id
FROM ".COMMENTS_TABLE."
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."
SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
$site_db->query($sql);
}
}
$sql = "DELETE FROM ".COMMENTS_TABLE."
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_error']."</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;
}
function do_copy($image_media_file, $image_thumb_file = "", $from_cat = 0, $to_cat = 0, $media = 1)
{
global $config, $error_log, $lang;
if ($media)
{
if (is_remote($image_media_file))
return $image_media_file;
$ok = 0;
$new_file = $image_media_file;
$image_src = ($from_cat != -1) ? MEDIA_PATH.(($from_cat != 0) ? "/".$from_cat : "") : MEDIA_TEMP_PATH;
$image_dest = ($to_cat != -1) ? MEDIA_PATH.(($to_cat != 0) ? "/".$to_cat : "") : MEDIA_TEMP_PATH;
$image_src_file = $image_src."/".$image_media_file;
if (BIGDIR && file_exists((($from_cat != -1) ? MEDIA_PATH.(($from_cat != 0) ? "/".$from_cat : "") : MEDIA_TEMP_PATH)."/".BIGDIR."/".$image_media_file))
{
$image_src_big = (($from_cat != -1) ? MEDIA_PATH.(($from_cat != 0) ? "/".$from_cat : "") : MEDIA_TEMP_PATH)."/".BIGDIR;
$image_dest_big = (($to_cat != -1) ? MEDIA_PATH.(($to_cat != 0) ? "/".$to_cat : "") : MEDIA_TEMP_PATH)."/".BIGDIR;
$image_src_file_big = $image_src_big."/".$image_media_file;
}
else
{
$image_src_big = "";
$image_dest_big = "";
$image_src_file_big = "";
}
if (BACKUPDIR && file_exists(BACKUPDIR."/".(($from_cat != 0 && $from_cat != -1) ? $from_cat : "")))
{
$image_src_backup = BACKUPDIR."/".(($from_cat != 0 && $from_cat != -1) ? $from_cat : "");
$image_dest_backup = BACKUPDIR."/".(($to_cat != 0 && $to_cat != -1) ? $to_cat : "");
$image_src_file_backup = $image_src_backup."/".$image_media_file;
}
else
{
$image_src_backup = "";
$image_dest_backup = "";
$image_src_file_backup = "";
}
if (file_exists($image_src."/".$image_media_file))
{
$file_extension = get_file_extension($image_media_file);
$file_name = get_file_name($image_media_file);
$n = 2;
$copy = "";
while (file_exists($image_dest."/".$file_name.$copy.".".$file_extension))
{
$copy = "_".$n;
$n++;
}
$new_file = $file_name.$copy.".".$file_extension;
$ok = copy($image_src_file, $image_dest."/".$new_file);
if (BIGDIR)
{
@copy($image_src_file_big, $image_dest_big."/".$new_file);
}
if (BACKUPDIR)
{
@copy($image_src_file_backup, $image_dest_backup."/".$new_file);
}
}
if (file_exists($image_src_file_big))
{
if (!@is_dir($image_dest_big))
{
$oldumask = umask(0);
$result = @mkdir($image_dest_big);
umask($oldumask);
if (!@is_dir($image_dest_big) || !$result)
{
@mkdir($image_dest_big, CHMOD_DIRS);
}
}
if (!file_exists($image_dest_big."/".$new_file))
{
if (!copy($image_src_file_big, $image_dest_big."/".$new_file))
{
$error_log[] = sprintf($lang['copy_file_error_perm'], $image_src_file_big, $image_dest_big."/".$new_file);
}
}
}
if (file_exists($image_src_file_backup))
{
if (!@is_dir($image_dest_backup))
{
$oldumask = umask(0);
$result = @mkdir($image_dest_backup);
umask($oldumask);
if (!@is_dir($image_dest_backup) || !$result)
{
@mkdir($image_dest_backup, CHMOD_DIRS);
}
}
if (!file_exists($image_dest_backup."/".$new_file))
{
if (!copy($image_src_file_backup, $image_dest_backup."/".$new_file))
{
$error_log[] = sprintf($lang['copy_file_error_perm'], $image_src_file_backup, $image_dest_backup."/".$new_file);
}
}
}
if ($ok)
{
@chmod($image_dest."/".$new_file, CHMOD_FILES);
@chmod($image_dest_big."/".$new_file, CHMOD_FILES);
@chmod($image_dest_backup."/".$new_file, CHMOD_FILES);
return $new_file;
}
else
{
return false;
}
}
else
{
if (is_remote($image_thumb_file))
{
return $image_thumb_file;
}
$thumb_src = ($from_cat != -1) ? THUMB_PATH.(($from_cat != 0) ? "/".$from_cat : "") : THUMB_TEMP_PATH;
$thumb_dest = ($to_cat != -1) ? THUMB_PATH.(($to_cat != 0) ? "/".$to_cat : "") : THUMB_TEMP_PATH;
if ($image_thumb_file != "" && file_exists($thumb_src."/".$image_thumb_file))
{
$thumb_extension = get_file_extension($image_thumb_file);
$thumb_name = get_file_name($image_thumb_file);
$n = 2;
$copy = "";
while (file_exists($thumb_dest."/".$thumb_name.$copy.".".$thumb_extension))
{
$copy = "_".$n;
$n++;
}
$new_thumb = $thumb_name.$copy.".".$thumb_extension;
if (copy($thumb_src."/".$image_thumb_file, $thumb_dest."/".$new_thumb))
{
@chmod($thumb_dest."/".$new_thumb, CHMOD_FILES);
$image_thumb_file = $new_thumb;
}
}
return $image_thumb_file;
}
}
function copy_images($image_ids, $cat_id, $date, $move = 0)
{
global $site_db, $lang, $site_sess, $cat_cache;
if (empty($image_ids))
{
echo $lang['no_search_results'];
return false;
}
if (!$cat_id)
{
echo $lang['no_category'];
return false;
}
$copymove = $move ? "move" : "copy";
$error_log = array();
echo "<br />";
$sql = "SELECT *
FROM ".IMAGES_TABLE."
WHERE image_id IN ($image_ids)";
$image_result = $site_db->query($sql);
while ($image_row = $site_db->fetch_array($image_result))
{
$ok = false;
$msg = "";
$ok_media = "";
$ok_thumb = "";
$image_cat_id = $image_row['cat_id'];
$image_id = $image_row['image_id'];
if ($cat_id != $image_cat_id)
{
$ok_media = do_copy($image_row['image_media_file'], "", $image_cat_id, $cat_id);
if ($ok_media && $image_row['image_thumb_file'] !== "")
{
$ok_thumb = do_copy($image_row['image_media_file'], $image_row['image_thumb_file'], $image_cat_id, $cat_id, 0);
}
if (!$ok_media)
{
$error_log[] = sprintf($lang[$copymove.'_error_media'], "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" target=_blank>".$image_row['image_name']."</a>", format_text($cat_cache[$image_cat_id]['cat_name'], 2)." [ID:".$image_cat_id."]", format_text($cat_cache[$cat_id]['cat_name'], 2)." [ID:".$cat_id."]")."<br />";
}
elseif ($ok_thumb === false)
{
$error_log[] = sprintf($lang[$copymove.'_error_thumb'], $image_row['image_name']). "<br />";
}
$new_media_name = $ok_media;
$new_thumb_name = $ok_thumb;
if ($ok_media && $ok_thumb !== false)
{
if ($move)
{
$date_sql = ($date) ? "" : ", image_date = ".time();
$filenames = (($new_media_name) ? ", image_media_file = '".$new_media_name."'" : "").(($new_thumb_name) ? ", image_thumb_file = '".$new_thumb_name."'" : "");
$sql = "UPDATE ".IMAGES_TABLE." SET cat_id = ".$cat_id.$filenames.$date_sql." WHERE image_id = ".$image_id;
}
else
{
$image_row['cat_id'] = $cat_id;
unset($image_row['image_id']);
$keys = array();
$vals = array();
foreach ($image_row as $key => $val)
{
if (!intval($key) && $key && $val)
{
if ($key == "image_date" && !$date)
{
$val = time();
}
if ($key == "image_media_file" && $new_media_name)
{
$val = addslashes($new_media_name);
}
if ($key == "image_thumb_file" && $new_thumb_name)
{
$val = addslashes($new_thumb_name);
}
$keys[] = $key;
$vals[] = "'".addslashes($val)."'";
}
}
$sql = "INSERT INTO ".IMAGES_TABLE."
(".implode(", ", $keys).")
VALUES
(".implode(", ", $vals).")";
}
if ($site_db->query($sql))
{
if (!$move)
{
$image_id = $site_db->get_insert_id();
}
if ($move && isset($cat_cache[$image_row['cat_id']]['cat_image']) && $cat_cache[$image_row['cat_id']]['cat_image'] == $image_row['image_id'])
{
$sql = "UPDATE " . CATEGORIES_TABLE . " SET cat_image = '' WHERE cat_id = " . $image_row['cat_id'];
$site_db->query($sql);
}
$msg = sprintf($lang[$copymove.'_success'], "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" target=_blank>".$image_row['image_name']."</a>", format_text($cat_cache[$image_cat_id]['cat_name'], 2)." [ID:".$image_cat_id."]", format_text($cat_cache[$cat_id]['cat_name'], 2)." [ID:".$cat_id."]")."<br />\n";
$ok = 1;
}
else
{
$error_log[] = sprintf($lang[$copymove.'_error_db'], "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" target=_blank>".$image_row['image_name']."</a>", format_text($cat_cache[$image_cat_id]['cat_name'], 2)." [ID:".$image_cat_id."]", format_text($cat_cache[$cat_id]['cat_name'], 2)." [ID:".$cat_id."]")."<br />";
}
}
else
{
$error_log[] = sprintf($lang[$copymove.'_error_skipped'], "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" target=_blank>".$image_row['image_name']."</a>", format_text($cat_cache[$image_cat_id]['cat_name'], 2)." [ID:".$image_cat_id."]", format_text($cat_cache[$cat_id]['cat_name'], 2)." [ID:".$cat_id."]")."<br />";
}
}
else
{
$msg = "<b>".$lang['skipped']."</b> ".$image_row['image_name']." (".$lang['src_des_same'].")<br />\n";
}
if ($move && $cat_id != $image_cat_id && $ok)
{
if (!is_remote($image_row['image_media_file']) && !is_local_file($image_row['image_media_file']))
{
if (@unlink(MEDIA_PATH."/".$image_cat_id."/".$image_row['image_media_file']))
{
$ok_media = 1;
}
else
{
$error_log[] = "<b>".$lang['file_delete_error']."</b> (".$image_row['image_media_file']." ".$lang['in_cat_id'].": ".$image_cat_id.")<br />";
}
}
if ($ok_media && !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_cat_id."/".$image_row['image_thumb_file']))
{
$ok_thumb = 1;
}
else
{
$error_log[] = "<b>".$lang['thumb_delete_error']." (".$image_row['image_thumb_file']." ".$lang['in_cat_id'].": ".$image_cat_id.")<br />\n";
}
}
if (BIGDIR && file_exists(MEDIA_PATH."/".$image_cat_id."/".BIGDIR."/".$image_row['image_media_file']))
{
if (!@unlink(MEDIA_PATH."/".$image_cat_id."/".BIGDIR."/".$image_row['image_media_file']))
{
$error_log[] = "<b>".$lang['error_del_big']."</b> (".BIGDIR."/".$image_row['image_media_file']." ".$lang['in_cat_id'].": ".$image_cat_id.")<br />";
}
}
if (BACKUPDIR && file_exists(BACKUPDIR."/".$image_cat_id."/".$image_row['image_media_file']))
{
if (!unlink(BACKUPDIR."/".$image_cat_id."/".$image_row['image_media_file']))
{
$error_log[] = "<b>".$lang['error_del_backup']."</b> (".BACKUPDIR."/".$image_row['image_media_file']." ".$lang['in_cat_id'].": ".$image_cat_id.")<br />";
}
}
}
echo $msg."<br />\n";
}
return $error_log;
}
function fixaction($txt)
{
// return preg_replace("#[ ,._\-\[\]{}]#", "", $txt);
return trim($txt);
}
function get_thumbnail($image_row)
{
global $config;
if (!check_media_type($image_row['image_media_file']))
{
$return = ICON_PATH."/404.gif";
}
else
{
if (!get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0))
{
$return = ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif";
}
else
{
$return = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
}
}
return $return;
}
if ($action == "reset" || $action == fixaction($lang['reset']))
{
$presets['_default_'] = "default";
preset_save();
redirect(ROOT_PATH . "admin/images.php");
}
show_admin_header($header_insert);
if ($action == "deleteimage")
{
$selectimages = (isset($HTTP_POST_VARS['selectimages'])) ? $HTTP_POST_VARS['selectimages'] : array();
$delfromserver = (isset($HTTP_POST_VARS['delfromserver'])) ? intval($HTTP_POST_VARS['delfromserver']) : 1;
$image_ids = "";
if (!empty($selectimages))
{
foreach ($selectimages as $val)
{
$image_ids .= (($image_ids != "") ? ", " : "").$val;
}
}
$lang_key = (count($selectimages) > 1) ? 'images' : 'image';
show_table_header($lang['delete'].": ".$lang[$lang_key], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
$error_log = delete_images($image_ids, $delfromserver);
echo "</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
if (!empty($error_log))
{
show_table_header($lang['error_log'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$lang['error_log_desc']."</b>\n<ul>\n";
foreach ($error_log as $val)
{
printf("<li>%s</li>\n", $val);
}
echo "</ul>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
echo "<p>";
show_text_link($lang['back_overview'], "images.php?action=modifyimages");
}
if ($action == "removeimage")
{
$image_ids = array();
if ((isset($HTTP_GET_VARS['image_id']) && intval($HTTP_GET_VARS['image_id'])) || (isset($HTTP_POST_VARS['image_id']) && intval($HTTP_POST_VARS['image_id'])))
{
$image_id = (isset($HTTP_GET_VARS['image_id'])) ? intval($HTTP_GET_VARS['image_id']) : intval($HTTP_POST_VARS['image_id']);
$image_ids[] = $image_id;
}
elseif (isset($HTTP_POST_VARS['selectimages']))
{
$image_ids = $HTTP_POST_VARS['selectimages'];
}
else
{
$image_ids[] = 0;
}
if ($image_ids[0] != 0)
{
show_form_header("images.php", "deleteimage");
foreach ($image_ids as $val)
{
show_hidden_input("selectimages[]", $val);
}
$lang_key = (count($image_ids) > 1) ? 'images' : 'image';
show_table_header($lang['delete'].": ".$lang[$lang_key], 2);
show_description_row($lang['delete_image_confirm']);
show_radio_row($lang['delete_image_files_confirm'], "delfromserver", 1);
show_form_footer($lang['yes'], "", 2, $lang['no']);
}
else
{
$error_log[] = $lang['no_search_results'];
$action = "findimages";
}
}
if ($action == "changeowner" || $action == fixaction($lang['changeowner']))
{
$image_ids = array();
if (isset($HTTP_POST_VARS['selectimages']) && $HTTP_POST_VARS['selectimages'])
{
$image_ids = $HTTP_POST_VARS['selectimages'];
}
if ((isset($HTTP_GET_VARS['owner']) && intval($HTTP_GET_VARS['owner'])) || (isset($HTTP_POST_VARS['owner']) && intval($HTTP_POST_VARS['owner'])))
{
$owner = (isset($HTTP_GET_VARS['owner'])) ? intval($HTTP_GET_VARS['owner']) : intval($HTTP_POST_VARS['owner']);
}
if (!empty($image_ids) && is_array($image_ids))
{
if ($owner)
{
$sql = "UPDATE ".IMAGES_TABLE."
SET user_id = ".$owner."
WHERE image_id IN (".implode(",",$image_ids).")";
if ($site_db->query($sql))
{
echo "<b>".$lang['owner_success']."</b><br /><br />\n";
}
else
{
$error_log[] = $lang['owner_error'];
}
}
else
{
$error_log[] = $lang['no_user_select'];
}
}
else
{
$error_log[] = $lang['no_search_results'];
}
$action = "findimages";
}
if ($action == "saveedit")
{
$selectimages = (isset($HTTP_POST_VARS['selectimages'])) ? $HTTP_POST_VARS['selectimages'] : array();
$image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments']) && $HTTP_POST_VARS['image_allow_comments']) ? $HTTP_POST_VARS['image_allow_comments'] : 0;
$image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
$image_date = (trim($HTTP_POST_VARS['image_date']) != "") ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date'])."')" : 0;
$image_active = intval($HTTP_POST_VARS['image_active']);
if (KEYWORDS_NEW)
{
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
$image_keywords = preg_replace("/[\n\r]/is", ",", $image_keywords);
$image_keywords_arr = explode(',', $image_keywords);
array_walk($image_keywords_arr, 'trim_value');
$image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));
}
else
{
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
$image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
$image_keywords = str_replace(","," ",$image_keywords);
$image_keywords = preg_replace("/( ){2,}/", " ", $image_keywords);
}
$HTTP_POST_VARS['image_keywords'] = $image_keywords;
$image_ids = implode(",",$selectimages);
echo "<script language=javascript>\n showProgress();\n hideProgress();\n</script>";
show_table_header($lang['edit_log'], 2);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
$date = ($image_date) ? ", image_date = ".$image_date : "";
$sql = "UPDATE ".IMAGES_TABLE."
SET image_description = '$image_description', image_keywords = '$image_keywords', image_allow_comments = $image_allow_comments, image_active = $image_active.$date
WHERE image_id IN ($image_ids)";
$result = $site_db->query($sql);
if ($result)
{
remove_searchwords($image_ids);
foreach($selectimages as $image_id)
{
$search_words = array();
foreach ($search_match_fields as $image_column => $match_column)
{
if (isset($HTTP_POST_VARS[$image_column]))
{
$search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column]);
if (KEYWORDS_NEW && $image_column == 'image_keywords')
{
$search_words[$image_column] = explode(',', $search_words[$image_column]);
}
}
}
add_searchwords($image_id, $search_words);
}
echo "<b>".$lang['upload_success'][(count($selectimages) > 1) ? 1 : 0]."</b>\n</td></tr></table>\n";
echo "</td></tr>\n";
echo "</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
else
{
echo "</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
show_table_header($lang['error_log'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$lang['upload_error'][(count($selectimages) > 1) ? 1 : 0]."</b>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
$HTTP_POST_VARS = array();
$action = "modifyimages";
// echo "<p>";
// show_text_link($lang['back_overview'], "images.php?action=modifyimages");
}
if ($action == "edit" || $action == fixaction($lang['edit']))
{
$image_ids = array();
if ((isset($HTTP_GET_VARS['image_id']) && intval($HTTP_GET_VARS['image_id'])) || (isset($HTTP_POST_VARS['image_id']) && intval($HTTP_POST_VARS['image_id'])))
{
$image_id = (isset($HTTP_GET_VARS['image_id'])) ? intval($HTTP_GET_VARS['image_id']) : intval($HTTP_POST_VARS['image_id']);
$image_ids[] = $image_id;
}
elseif (isset($HTTP_POST_VARS['selectimages']))
{
$image_ids = $HTTP_POST_VARS['selectimages'];
}
else
{
$image_ids[] = 0;
}
if (count($image_ids) > 1)
{
if ($image_ids[0] != 0)
{
show_form_header("images.php", "saveedit");
foreach ($image_ids as $val)
{
show_hidden_input("selectimages[]", $val);
}
$sql = "SELECT image_id, cat_id, image_name, image_keywords, image_description, image_allow_comments, image_active, FROM_UNIXTIME(image_date) AS image_date, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_id IN (".implode(",", $image_ids).")";
$result = $site_db->query($sql);
$list = "<div style=\"display: block;\">";
$i = 0;
$keywords = "";
$keywords_sep = KEYWORDS_NEW ? "," : " ";
while ($row = $site_db->fetch_array($result))
{
$image_row[$row['image_id']] = $row;
$file_src = get_thumbnail($row);
$height = $thumbsize;
$width = $thumbsize;
$file_size = get_resize2($file_src, $thumbsize);
$width = $file_size[0];
$height = $file_size[1];
$list .= "<div style=\"float: left;" . (($i) ? " margin: 2px 2px 2px 5px;" : "") . "\">";
$list .= "<div><a href=\"". $site_sess->url(ROOT_PATH . "details.php?".URL_IMAGE_ID."=".$row['image_id'])."\" target=\"_blank\">";
$list .= "<img src=\"".$file_src."\" width=\"" . $width . "\" height=\"" . $height . "\" border=\"1\" alt=\"\"></div><div>";
$list .= $row['image_name'];
$list .= " [ID: ".$row['image_id']."]</a></div></div>";
$i++;
if ($row['image_keywords'])
{
$keywords .= $keywords_sep . trim($row['image_keywords']);
}
}
$list .= "</div>";
$keywords = trim($keywords, $keywords_sep);
$keywords = implode($keywords_sep, array_unique(explode($keywords_sep, trim($keywords))));
$HTTP_POST_VARS = array();
show_table_header($lang['edit_image'][(count($image_ids) > 1) ? 1 : 0], 2);
show_custom_row($lang['edit_image'][(count($image_ids) > 1) ? 1 : 0] . ":", trim($list, ", "));
$file_src = get_file_path($image_row[$image_ids[0]]['image_media_file'], "media", $image_row[$image_ids[0]]['cat_id'], 1);
$title = $lang['field_description_ext'].((isset($file_src)) ? get_iptc_insert_link($file_src, "caption", "image_description") : "");
show_textarea_row($title, "image_description", $image_row[$image_ids[0]]['image_description'], $textarea_size);
$title = $lang['field_keywords_ext'].((isset($file_src)) ? get_iptc_insert_link($file_src, "keyword", "image_keywords") : "");
show_textarea_row($title, "image_keywords", $keywords, $textarea_size);
$title = $lang['field_date'].$lang['date_desc'].$lang['date_format'];
if (function_exists("show_date_input_row"))
show_date_input_row($title, "image_date", $image_row[$image_ids[0]]['image_date'], $textinput_size);
else
show_input_row($title, "image_date", $image_row[$image_ids[0]]['image_date'], $textinput_size);
show_radio_row($lang['field_free'], "image_active", $image_row[$image_ids[0]]['image_active']);
show_radio_row($lang['field_allow_comments'], "image_allow_comments", $image_row[$image_ids[0]]['image_allow_comments']);
show_form_footer($lang['save_changes'], $lang['reset'], 2, "", " onClick='showProgress()'");
}
else
{
$error_log[] = $lang['no_search_results'];
$action = "findimages";
}
}
else
{
$HTTP_POST_VARS['image_id'] = $image_ids[0];
$action = "editimage";
}
}
if ($action == "docopy")
{
$selectimages = (isset($HTTP_POST_VARS['selectimages'])) ? $HTTP_POST_VARS['selectimages'] : array();
$cat_id = (isset($HTTP_POST_VARS['new_cat_id'])) ? $HTTP_POST_VARS['new_cat_id'] : 0;
$date = (isset($HTTP_POST_VARS['date']) && intval($HTTP_POST_VARS['date'])) ? 1 : 0;
$image_ids = "";
if (!empty($selectimages))
{
foreach ($selectimages as $val)
{
$image_ids .= (($image_ids != "") ? ", " : "").$val;
}
}
$lang_key = (count($selectimages) > 1) ? 'images' : 'image';
show_table_header($lang['copy']." ".$lang[$lang_key], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
$error_log = copy_images($image_ids, $cat_id, $date);
echo "</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
if (!empty($error_log))
{
show_table_header($lang['error_log'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$lang['error_log_desc']."</b>\n<ul>\n";
foreach ($error_log as $val)
{
printf("<li>%s</li>\n", $val);
}
echo "</ul>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
echo "<p>";
show_text_link($lang['back_overview'], "images.php?action=modifyimages");
}
if ($action == "copy" || $action == fixaction($lang['copy']))
{
$image_ids = array();
if (isset($HTTP_POST_VARS['selectimages']))
{
$image_ids = $HTTP_POST_VARS['selectimages'];
}
else
{
$image_ids[] = 0;
}
$cat_id = (isset($HTTP_POST_VARS['new_cat_id'])) ? $HTTP_POST_VARS['new_cat_id'] : 0;
$date = (isset($HTTP_POST_VARS['date']) && intval($HTTP_POST_VARS['date'])) ? 1 : 0;
if ($image_ids[0] != 0 && $cat_id)
{
show_form_header("images.php", "docopy");
foreach ($image_ids as $val)
{
show_hidden_input("selectimages[]", $val);
}
show_hidden_input("new_cat_id", $cat_id);
show_hidden_input("date", $date);
$lang_key = (count($image_ids) > 1) ? 'images' : 'image';
show_table_header($lang['copy']." ".$lang[$lang_key], 2);
show_description_row(sprintf($lang['copy_confirm'], format_text($cat_cache[$cat_id]['cat_name'], 2), $cat_id));
show_form_footer($lang['yes'], "", 2, $lang['no']);
}
else
{
if ($image_ids[0] == 0)
{
$error_log[] = $lang['no_search_results'];
}
if (!$cat_id)
{
$error_log[] = $lang['no_category'];
}
$action = "findimages";
}
}
if ($action == "domove")
{
$selectimages = (isset($HTTP_POST_VARS['selectimages'])) ? $HTTP_POST_VARS['selectimages'] : array();
$cat_id = (isset($HTTP_POST_VARS['new_cat_id'])) ? $HTTP_POST_VARS['new_cat_id'] : 0;
$date = (isset($HTTP_POST_VARS['date']) && intval($HTTP_POST_VARS['date'])) ? 1 : 0;
$image_ids = "";
if (!empty($selectimages))
{
foreach ($selectimages as $val)
{
$image_ids .= (($image_ids != "") ? ", " : "").$val;
}
}
$lang_key = (count($selectimages) > 1) ? 'images' : 'image';
show_table_header($lang['move'].": ".$lang[$lang_key], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
$error_log = copy_images($image_ids, $cat_id, $date, 1);
echo "</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
if (!empty($error_log))
{
show_table_header($lang['error_log'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$lang['error_log_desc']."</b>\n<ul>\n";
foreach ($error_log as $val)
{
printf("<li>%s</li>\n", $val);
}
echo "</ul>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
echo "<p>";
show_text_link($lang['back_overview'], "images.php?action=modifyimages");
}
if ($action == "move" || $action == fixaction($lang['move']))
{
$image_ids = array();
if (isset($HTTP_POST_VARS['selectimages']))
{
$image_ids = $HTTP_POST_VARS['selectimages'];
}
else {
$image_ids[] = 0;
}
$cat_id = (isset($HTTP_POST_VARS['new_cat_id'])) ? $HTTP_POST_VARS['new_cat_id'] : 0;
$date = (isset($HTTP_POST_VARS['date']) && intval($HTTP_POST_VARS['date'])) ? 1 : 0;
if ($image_ids[0] != 0 && $cat_id && isset($cat_cache[$cat_id]))
{
show_form_header("images.php", "domove");
foreach ($image_ids as $val)
{
show_hidden_input("selectimages[]", $val);
}
show_hidden_input("date", $date);
show_hidden_input("new_cat_id", $cat_id);
$lang_key = (count($image_ids) > 1) ? 'images' : 'image';
show_table_header($lang['move'].": ".$lang[$lang_key], 2);
show_description_row(sprintf($lang['move_confirm'], format_text($cat_cache[$cat_id]['cat_name'], 2), $cat_id));
show_form_footer($lang['yes'], "", 2, $lang['no']);
}else{
if ($image_ids[0] == 0)
{
$error_log[] = $lang['no_search_results'];
}
if (!$cat_id)
{
$error_log[] = $lang['no_category'];
}
$action = "findimages";
}
}
if ($action == "updateimage")
{
$error_msg = "";
$error = array();
$image_id = (isset($HTTP_POST_VARS['image_id'])) ? intval($HTTP_POST_VARS['image_id']) : intval($HTTP_GET_VARS['image_id']);
$image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
$image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
if (KEYWORDS_NEW)
{
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
$image_keywords = preg_replace("/[\n\r]/is", ",", $image_keywords);
$image_keywords_arr = explode(',', $image_keywords);
array_walk($image_keywords_arr, 'trim_value');
$image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));
}
else
{
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
$image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
$image_keywords = str_replace(","," ",$image_keywords);
$image_keywords = preg_replace("/( ){2,}/", " ", $image_keywords);
}
$HTTP_POST_VARS['image_keywords'] = $image_keywords;
$cat_id = intval($HTTP_POST_VARS['cat_id']);
$old_cat_id = intval($HTTP_POST_VARS['old_cat_id']);
$user_id = (intval($HTTP_POST_VARS['user_id']) != 0) ? intval($HTTP_POST_VARS['user_id']) : $user_info['user_id'];
$image_date = (trim($HTTP_POST_VARS['image_date']) != "") ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date'])."')" : time();
$image_active = intval($HTTP_POST_VARS['image_active']);
$image_allow_comments = intval($HTTP_POST_VARS['image_allow_comments']);
$image_downloads = (trim($HTTP_POST_VARS['image_downloads']) != "") ? intval($HTTP_POST_VARS['image_downloads']) : 0;
$image_votes = (trim($HTTP_POST_VARS['image_votes']) != "") ? intval($HTTP_POST_VARS['image_votes']) : 0;
$image_rating = (trim($HTTP_POST_VARS['image_rating']) != "") ? sprintf("%.2f", trim($HTTP_POST_VARS['image_rating'])) : "0.00";
$image_hits = (trim($HTTP_POST_VARS['image_hits']) != "") ? intval(trim($HTTP_POST_VARS['image_hits'])) : 0;
$remote_file = trim($HTTP_POST_VARS['remote_file']);
$remote_thumb_file = trim($HTTP_POST_VARS['remote_thumb_file']);
$old_file_name = trim($HTTP_POST_VARS['old_file_name']);
$old_thumb_file_name = trim($HTTP_POST_VARS['old_thumb_file_name']);
$image_download_url = trim($HTTP_POST_VARS['image_download_url']);
$image_resize = (isset($HTTP_POST_VARS['image_resize'])) ? intval($HTTP_POST_VARS['image_resize']) : 0;
$thumb_tools = (isset($HTTP_POST_VARS['thumb_tools'])) ? intval($HTTP_POST_VARS['thumb_tools']) : 0;
if ($thumb_tools == -1)
{
$HTTP_POST_VARS['delete_thumb_file'] = 1;
$thumb_tools = 0;
}
$delete_thumb_file = (isset($HTTP_POST_VARS['delete_thumb_file']) && $HTTP_POST_VARS['delete_thumb_file'] == 1) ? 1 : 0;
if ($image_name == "")
{
$error['image_name'] = 1;
}
if ($cat_id == 0)
{
$error['cat_id'] = 1;
}
if ($image_download_url != "" && !is_remote($image_download_url) && !is_local_file($image_download_url))
{
$error['image_download_url'] = 1;
}
if ((empty($HTTP_POST_FILES['file']['tmp_name']) || $HTTP_POST_FILES['file']['tmp_name'] == "none") && $remote_file != "" && !check_remote_media($remote_file) && !check_local_media($remote_file))
{
$error['remote_file'] = 1;
}
if ((empty($HTTP_POST_FILES['thumb_file']['tmp_name']) || $HTTP_POST_FILES['thumb_file']['tmp_name'] == "none") && $remote_thumb_file != "" && !check_remote_thumb($remote_thumb_file) && !check_local_thumb($remote_thumb_file))
{
$error['remote_thumb_file'] = 1;
}
if (!empty($additional_image_fields))
{
foreach ($additional_image_fields as $key => $val)
{
if (isset($HTTP_POST_VARS[$key]) && intval($val[2]) == 1 && trim($HTTP_POST_VARS[$key]) == "")
{
$error[$key] = 1;
}
}
}
if (!empty($HTTP_POST_FILES['file']['tmp_name']) && $HTTP_POST_FILES['file']['tmp_name'] != "none" && !$error)
{
unset($HTTP_POST_VARS['remote_file']);
@rename(MEDIA_PATH."/".$old_cat_id."/".$old_file_name, MEDIA_PATH."/".$old_cat_id."/".$old_file_name.".bak");
if (BIGDIR)
{
@rename(MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name, MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name.".bak");
}
if (BACKUPDIR)
{
@rename(BACKUPDIR."/".$old_cat_id."/".$old_file_name, BACKUPDIR."/".$old_cat_id."/".$old_file_name.".bak");
}
$new_name = $site_upload->upload_file("file", "media", $cat_id);
if (!$new_name)
{
$error_msg .= $lang['file_upload_error'].": <b>".$HTTP_POST_FILES['file']['name']."</b><br />".$site_upload->get_upload_errors();
@rename(MEDIA_PATH."/".$old_cat_id."/".$old_file_name.".bak", MEDIA_PATH."/".$old_cat_id."/".$old_file_name);
if (BIGDIR)
{
@rename(MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name.".bak", MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name);
}
if (BACKUPDIR)
{
@rename(BACKUPDIR."/".$old_cat_id."/".$old_file_name.".bak", BACKUPDIR."/".$old_cat_id."/".$old_file_name);
}
$error[''] = 1;
}
else
{
@unlink(MEDIA_PATH."/".$old_cat_id."/".$old_file_name.".bak");
@unlink(MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name.".bak");
@unlink(BACKUPDIR."/".$old_cat_id."/".$old_file_name.".bak");
if (defined("IMS_DIR"))
{
$list = IMS_getFileList($image_id);
foreach($list as $file)
{
@unlink($file);
}
}
$log[] = $lang['file_upload_success'].": <b>$new_name</b>";
}
}
elseif ((empty($HTTP_POST_FILES['file']['tmp_name']) || $HTTP_POST_FILES['file']['tmp_name'] == "none") && $remote_file != "" && (check_remote_media($remote_file) || check_local_media($remote_file)))
{
$new_name = $remote_file;
if (file_exists(MEDIA_PATH."/".$old_cat_id."/".$old_file_name) && is_file(MEDIA_PATH."/".$old_cat_id."/".$old_file_name))
{
unlink(MEDIA_PATH."/".$old_cat_id."/".$old_file_name);
@unlink(MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name);
@unlink(BACKUPDIR."/".$old_cat_id."/".$old_file_name);
if (defined("IMS_DIR"))
{
$list = IMS_getFileList($image_id);
foreach($list as $file)
{
@unlink($file);
}
}
}
}
else
{
if ($cat_id != $old_cat_id && !empty($old_file_name))
{
if ($new_name = do_copy($old_file_name, "", $old_cat_id, $cat_id, 1))
{
if (!is_remote($old_file_name) && !is_local_file($old_file_name))
{
if (!@unlink(MEDIA_PATH."/".$old_cat_id."/".$old_file_name))
{
$error_msg .= "<b>".$lang['file_delete_error']."</b> (".$old_file_name." ".$lang['in_cat_id'].": ".$old_cat_id.")<br />";
$error[''] = 1;
}
else
{
if (BIGDIR && file_exists(MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name))
{
if (!@unlink(MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name))
{
$error_msg .= "<b>".$lang['error_del_big']."</b> (".BIGDIR."/".$old_file_name." ".$lang['in_cat_id'].": ".$old_cat_id.")<br />";
$error[''] = 1;
}
}
if (BACKUPDIR && file_exists(BACKUPDIR."/".$old_cat_id."/".$old_file_name))
{
if (!@unlink(BACKUPDIR."/".$old_cat_id."/".$old_file_name))
{
$error_msg .= "<b>".$lang['error_del_backup']."</b> (".BACKUPDIR."/".$old_file_name." ".$lang['in_cat_id'].": ".$old_cat_id.")<br />";
$error[''] = 1;
}
}
}
}
}
else
{
$error[''] = 1;
}
}
else
{
$new_name = $old_file_name;
}
}
if ($delete_thumb_file == 1)
{
if (!empty($old_thumb_file_name) && file_exists(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name))
{
unlink(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name);
}
$new_thumb_name = "";
unset($HTTP_POST_VARS['remote_thumb_file']);
}
elseif (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$error)
{
unset($HTTP_POST_VARS['remote_thumb_file']);
@rename(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name, THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name.".bak");
$new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $cat_id, get_basefile($new_name));
if (!$new_thumb_name)
{
$error_msg .= $lang['thumb_upload_error'].": <b>".$HTTP_POST_FILES['thumb_file']['name']."</b><br />".$site_upload->get_upload_errors();
@rename(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name.".bak", THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name);
@unlink(MEDIA_PATH."/".$old_cat_id."/".$new_name);
$error[''] = 1;
}
else
{
$log[] = $lang['thumb_upload_success'].": <b>$new_thumb_name</b>";
}
}
elseif ((empty($HTTP_POST_FILES['thumb_file']['tmp_name']) || $HTTP_POST_FILES['thumb_file']['tmp_name'] == "none") && $remote_thumb_file != "" && (check_remote_thumb($remote_thumb_file) || check_local_thumb($remote_thumb_file)))
{
$new_thumb_name = $remote_thumb_file;
if (file_exists(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name) && is_file(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name))
{
unlink(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name);
}
}
else
{
if ($cat_id != $old_cat_id && !empty($old_thumb_file_name))
{
$new_thumb_name = copy_thumbnail($new_name, $old_thumb_file_name, $old_cat_id, $cat_id);
}
else
{
$new_thumb_name = $old_thumb_file_name;
}
}
if (empty($error) && !$convert_options['convert_error'])
{
if ($image_resize)
{
@set_time_limit(90);
$file = MEDIA_PATH."/".$cat_id."/".$new_name;
if (!$image_info = getimagesize($file))
{
$log[] = $lang['image_resize_error'];
}
else
{
if ($image_info[2] && $image_info[2] < 4)
{
if ($image_info[0] > $image_resize_width || $image_info[1] > $image_resize_height)
{
if (resize_image($file, $image_resize_quality, $image_resize_width, $image_resize_type, $image_resize_height))
{
$image_info2 = getimagesize($file);
$log[] = sprintf($lang['image_resize_success'], $image_info[0], $image_info[1], $image_info2[0], $image_info2[1]);
}
else
{
$log[] = $lang['image_resize_error'];
}
}
else
{
$log[] = $lang['image_resize_skipped'];
}
}
else
{
$log[] = $lang['image_resize_skipped'];
}
}
}
if (!$delete_thumb_file && $thumb_tools)
{
$type = ($thumb_tools == 1) ? "resize" : "create";
if (($new_thumb_name === "" || $thumb_tools == 2) && file_exists(MEDIA_PATH."/".$cat_id."/".$new_name))
{
if (file_exists(THUMB_PATH."/".$cat_id."/".$new_name))
{
unlink(THUMB_PATH."/".$cat_id."/".$new_name);
}
if (copy(MEDIA_PATH."/".$cat_id."/".$new_name, THUMB_PATH."/".$cat_id."/".$new_name))
{
chmod(THUMB_PATH."/".$cat_id."/".$new_name, CHMOD_FILES);
$new_thumb_name = $new_name;
$type = "create";
}
}
if ($new_thumb_name !== "")
{
@set_time_limit(90);
$file = THUMB_PATH."/".$cat_id."/".$new_thumb_name;
if (!$image_info = getimagesize($file))
{
$log[] = $lang['thumb_'.$type.'_error'];
}
else
{
if ($image_info[2] && $image_info[2] < 4)
{
if ($image_info[0] > $thumb_resize_dimension || $image_info[1] > $thumb_resize_dimension)
{
@unlink($file.".bak");
if (resize_image($file, $thumb_resize_quality, $thumb_resize_dimension, $thumb_resize_type))
{
$image_info2 = getimagesize($file);
$log[] = $lang['thumb_'.$type.'_success'];
}
else
{
$log[] = $lang['thumb_'.$type.'_error'];
}
}
else
{
$log[] = $lang['thumb_'.$type.'_skipped'];
}
}
else
{
$log[] = $lang['thumb_'.$type.'_skipped'];
}
}
}
}
$image_resize = 0;
$thumb_tools = 0;
}
if (empty($error))
{
$additional_sql = "";
if (!empty($additional_image_fields))
{
foreach ($additional_image_fields as $key => $val)
{
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key]))
{
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
$sql = "UPDATE ".IMAGES_TABLE."
SET cat_id = $cat_id, user_id = $user_id, image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords', image_date = $image_date, image_active = $image_active, image_media_file = '$new_name', image_thumb_file = '$new_thumb_name', image_download_url = '$image_download_url', image_allow_comments = $image_allow_comments, image_downloads = $image_downloads, image_votes = $image_votes, image_rating = '$image_rating', image_hits = $image_hits".$additional_sql."
WHERE image_id = $image_id";
$result = $site_db->query($sql);
if (isset($HTTP_POST_VARS['cat_image']))
{
if ($old_cat_id == $cat_id)
{
$sql = "UPDATE ".CATEGORIES_TABLE."
SET cat_image = ".((intval($HTTP_POST_VARS['cat_image'])) ? intval($HTTP_POST_VARS['cat_image']) : ((isset($HTTP_POST_VARS['cat_image_old']) && $HTTP_POST_VARS['cat_image_old'] != $image_id) ? $HTTP_POST_VARS['cat_image_old'] : 0))."
WHERE cat_id = $cat_id";
$result = $site_db->query($sql);
}
else
{
unset($HTTP_POST_VARS['cat_image']);
}
if ($old_cat_id != $cat_id && isset($cat_cache[$old_cat_id]['cat_image']) && $cat_cache[$old_cat_id]['cat_image'] == $image_id)
{
$sql = "UPDATE " . CATEGORIES_TABLE . "
SET cat_image = ''
WHERE cat_id = " . $old_cat_id;
$site_db->query($sql);
}
}
@unlink(MEDIA_PATH."/".$old_cat_id."/".$old_file_name.".bak");
@unlink(MEDIA_PATH."/".$old_cat_id."/".BIGDIR."/".$old_file_name.".bak");
@unlink(BACKUPDIR."/".$old_cat_id."/".$old_file_name.".bak");
@unlink(THUMB_PATH."/".$old_cat_id."/".$old_thumb_file_name.".bak");
update_comment_count($image_id);
if ($result)
{
$search_words = array();
foreach ($search_match_fields as $image_column => $match_column)
{
if (isset($HTTP_POST_VARS[$image_column]))
{
$search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column]);
if (KEYWORDS_NEW && $image_column == 'image_keywords')
{
$search_words[$image_column] = explode(',', $search_words[$image_column]);
}
}
}
remove_searchwords($image_id);
add_searchwords($image_id, $search_words);
$msg .= $lang['image_edit_success'];
}
else
{
$msg .= $lang['image_edit_error'];
}
}
else
{
$msg .= sprintf("<span class=\"marktext\">%s</span>", $lang['lostfield_error']);
$msg .= $error_msg;
}
echo "<script language=javascript>\n showProgress();\n hideProgress();\n</script>";
$action = "editimage";
if (!empty($log))
{
show_table_header($lang['log'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
foreach ($log as $val)
{
echo $val."<br />";
}
echo "</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
}
if ($action == "save" || $action == fixaction($lang['save']))
{
$image_ids = array();
$image_name = array();
$image_description = array();
$image_keywords = array();
if (isset($HTTP_POST_VARS['selectimages']))
{
$image_ids = $HTTP_POST_VARS['selectimages'];
}
else
{
$image_ids[] = 0;
}
$editkeywords = 0;
$image_info = array();
if (isset($HTTP_POST_VARS['qe_cat_id']))
{
$sql = "SELECT cat_id, image_id, image_media_file, image_thumb_file
FROM " . IMAGES_TABLE . "
WHERE image_id IN (" . implode(",", $image_ids) . ")";
$result = $site_db->query($sql);
$image_info = array();
while($image_row = $site_db->fetch_array($result))
{
$image_info[$image_row['image_id']] = $image_row;
}
}
foreach ($image_ids as $key => $val)
{
$set = array();
foreach($quickedit_fields_all as $field => $data)
{
if (!isset($HTTP_POST_VARS["qe_".$field][$key]) || (isset($HTTP_POST_VARS['qe_orig_'.$field][$key]) && trim($HTTP_POST_VARS['qe_orig_'.$field][$key]) == trim($HTTP_POST_VARS['qe_'.$field][$key])))
continue;
$value = trim($HTTP_POST_VARS["qe_".$field][$key]);
if (isset($data[2]) && is_array($data[2]) && $data[2][0] == 1)
$value = (int)$value;
$editkeywords = 0;
if ($field == "image_keywords")
{
if (KEYWORDS_NEW)
{
$value = un_htmlspecialchars(trim($value));
$value = preg_replace("/[\n\r]/is", ",", $value);
$value_arr = explode(',', $value);
array_walk($value_arr, 'trim_value');
$value = implode(',', array_unique(array_filter($value_arr)));
}
else
{
$value = preg_replace("/[\n\r]/is", " ", $value);
$value = str_replace(","," ",$value);
$value = preg_replace("/( ){2,}/", " ", $value);
}
$HTTP_POST_VARS["qe_image_keywords"][$key] = $value;
$value = "'".$value."'";
$editkeywords = 1;
}
elseif ($field == "image_date")
{
$value = "UNIX_TIMESTAMP('".$value."')";
}
elseif ($field == "cat_id")
{
if (!isset($cat_cache[$value]))
{
$error_log[] = "<b>".sprintf($lang['qe_cat_id_error'], $value)."<b>";
continue;
}
if (!empty($image_info[$val]['image_media_file']) && file_exists(MEDIA_PATH."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_media_file']) && is_file(MEDIA_PATH."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_media_file']))
{
if (!is_remote($image_info[$val]['image_media_file']) && !is_local_file($image_info[$val]['image_media_file']))
{
if ($new_name = do_copy($image_info[$val]['image_media_file'], "", $image_info[$val]['cat_id'], $value, 1))
{
if (!@unlink(MEDIA_PATH."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_media_file']))
{
$error_log[] = "<b>".$lang['file_delete_error']."</b> (".MEDIA_PATH."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_media_file'].")";
$error[''] = 1;
}
else
{
if (BIGDIR && file_exists(MEDIA_PATH."/".$image_info[$val]['cat_id']."/".BIGDIR."/".$image_info[$val]['image_media_file']))
{
if (!@unlink(MEDIA_PATH."/".$image_info[$val]['cat_id']."/".BIGDIR."/".$image_info[$val]['image_media_file']))
{
$error_log[] = "<b>".$lang['error_del_big']."</b> (".MEDIA_PATH."/".$image_info[$val]['cat_id']."/".BIGDIR."/".$image_info[$val]['image_media_file'].")";
$error[''] = 1;
}
}
if (BACKUPDIR && file_exists(BACKUPDIR."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_media_file']))
{
if (!@unlink(BACKUPDIR."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_media_file']))
{
$error_log[] = "<b>".$lang['error_del_backup']."</b> (".BACKUPDIR."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_media_file'].")";
$error[''] = 1;
}
}
}
}
else
{
$error[''] = 1;
}
}
}
else
{
$new_name = $image_info[$val]['image_media_file'];
}
if (!empty($image_info[$val]['image_thumb_file']) && file_exists(THUMB_PATH."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_thumb_file']) && is_file(THUMB_PATH."/".$image_info[$val]['cat_id']."/".$image_info[$val]['image_thumb_file']))
{
$new_thumb_name = copy_thumbnail($new_name, $image_info[$val]['image_thumb_file'], $image_info[$val]['cat_id'], $value);
}
else
{
$new_thumb_name = $image_info[$val]['image_thumb_file'];
}
$set[] = "image_media_file = '".addslashes($new_name)."'";
$set[] = "image_thumb_file = '".addslashes($new_thumb_name)."'";
}
else
{
$value = "'".$value."'";
}
$set[] = $field . " = " . $value;
}
if (!empty($set))
{
$sql = "UPDATE ".IMAGES_TABLE."
SET ".implode(", ", $set)."
WHERE image_id = $val";
$result = $site_db->query($sql);
}
$search_words = array();
foreach ($search_match_fields as $image_column => $match_column)
{
if (isset($HTTP_POST_VARS["qe_".$image_column][$key]))
{
$search_words[$image_column] = stripslashes($HTTP_POST_VARS["qe_".$image_column][$key]);
if (KEYWORDS_NEW && $image_column == 'image_keywords')
{
$search_words[$image_column] = explode(',', $search_words[$image_column]);
}
}
}
remove_searchwords($val);
add_searchwords($val, $search_words);
}
$msg = $lang['image_update_success'];
$action = "findimages";
echo "<script language=javascript>\n showProgress();\n hideProgress();\n</script>";
show_table_header($lang['save_log']);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$lang['image_update_success']."</b>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
if ($action == "editimage")
{
if ($msg != "")
{
printf("<b>%s</b>\n", $msg);
}
printf("<p>%s</p>\n", $lang['upload_note']);
$image_id = (isset($HTTP_POST_VARS['image_id'])) ? intval($HTTP_POST_VARS['image_id']) : (isset($HTTP_GET_VARS['image_id']) ? intval($HTTP_GET_VARS['image_id']) : 0);
$cat_image = array_keys($cat_cache);
if (isset($cat_cache[$cat_image[0]]['cat_image']))
{
$sql = "SELECT i.*, FROM_UNIXTIME(i.image_date) AS image_date, c.cat_image, b.image_name as cat_image_name, b.image_media_file as cat_image_media_file, b.image_thumb_file as cat_image_thumb_file
FROM ".IMAGES_TABLE." i
LEFT JOIN ".CATEGORIES_TABLE." c ON (c.cat_id = i.cat_id)
LEFT JOIN ".IMAGES_TABLE." b ON (b.image_id = c.cat_image)
WHERE i.image_id = $image_id";
}
else
{
$sql = "SELECT *, FROM_UNIXTIME(image_date) AS image_date
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
}
if ($image_id && $image_row = $site_db->query_firstrow($sql))
{
$site_sess->set_session_var('back_url', ROOT_PATH."admin/images.php?action=editimage&".URL_IMAGE_ID."=".$image_id);
show_form_header("images.php", "updateimage", "form", 1);
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_hidden_input("old_cat_id", $image_row['cat_id']);
$name = $lang['nav_images_edit'].": ";
$name .= "<a href=\"" . $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" target=\"_blank\"><span class=\"tableheader\">";
$name .= format_text($image_row['image_name'], 2) . "</span></a>";
$name .= "<span class=\"tableheader\" style=\"font-weight: normal;\"> [ID: ".$image_row['image_id']."]</span>";
$name .= " <a href=\"".$site_sess->url(ROOT_PATH."admin/images.php?action=removeimage&".URL_IMAGE_ID."=".$image_id)."\"".($target ? " target=\"_blank\"" : "")."><span class=\"tableheader\" style=\"font-weight: normal;\">[".$lang['delete']."]</span></a>";
show_table_header($name, 2);
$file_src = get_file_path($image_row['image_media_file'], "media", $image_row['cat_id'], 1);
$height = $imagesize;
$width = $imagesize;
$file_size = get_resize2($file_src, $imagesize);
$width = $file_size[0];
$height = $file_size[1];
echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">";
$file_path = get_file_path($image_row['image_media_file'], "media", $image_row['cat_id'], 0, 0);
$file_path = ($file_path) ? $file_path : (($image_row['cat_id']) ? MEDIA_PATH."/".$image_row['cat_id'] : MEDIA_TEMP_PATH)."/".$image_row['image_media_file'];
echo $lang['image']."<br /><span class=\"smalltext\">(<a href=\"".$file_path."\" target=\"_blank\">".$image_row['image_media_file']."</a>)<br />".$file_size[2][0]."x".$file_size[2][1]."</span>"."</p>";
echo "</td>\n";
echo "<td>";
echo "<a href=\"" . $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_row['image_id'])."\" target=\"_blank\">";
$user_info['ims_user_dim'] = $imagesize;
if ($use_media_template)
{
include_once(ROOT_PATH."includes/page_header.php");
echo str_replace("width=\"".$file_size[2][0]."\"", "width=\"".$file_size[0]."\"", str_replace("height=\"".$file_size[2][1]."\"", "height=\"".$file_size[1]."\"", get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, 1, 1)));
}
else
{
if (defined("IMS_DIR"))
{
$_file_src = $site_sess->url(ROOT_PATH . "multisizes.php?" . URL_IMAGE_ID . "=" . $image_row['image_id'] . "&" . IMS_URL_SIZE_TEMP . "=" . $imagesize);
}
else
{
$_file_src = $file_src;
}
echo "<img src=\"".$_file_src."\" width=\"" . $width . "\" height=\"" . $height . "\" border=\"1\" alt=\"\">";
}
echo "</td>\n</tr>\n";
$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);
$image_resize = 0;
$thumb_tools = 0;
if (!$convert_options['convert_error'])
{
echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">";
echo $lang['image_resize'];
echo "</p>";
echo "</td>\n";
echo "<td>";
echo "<input type=\"radio\" name=\"image_resize\" value=\"1\"";
if ($image_resize)
{
echo " checked=\"checked\"";
}
echo "> ".$lang['yes']." \n";
echo "<input type=\"radio\" name=\"image_resize\" value=\"0\"";
if (!$image_resize)
{
echo " checked=\"checked\"";
}
echo "> ".$lang['no']." ";
echo "</td>";
echo "</tr>";
}
if (!empty($image_row['image_thumb_file']))
{
$file_path = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0);
$file_path = ($file_path) ? $file_path : (($image_row['cat_id']) ? THUMB_PATH."/".$image_row['cat_id'] : THUMB_TEMP_PATH)."/".$image_row['image_thumb_file'];
$thumb_src = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 1);
show_image_row($lang['thumb']."<br /><span class=\"smalltext\">(<a href=\"".$file_path."\" target=\"_blank\">".$image_row['image_thumb_file']."</a>)</span>", $thumb_src, 1);
}
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);
if (!$convert_options['convert_error'])
{
echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">";
echo $lang['thumb_tools_edit']."</p>";
echo "</td>\n";
echo "<td valign=\"middle\">";
echo "<select name=\"thumb_tools\">";
echo "<option value=\"0\" selected></option>";
echo "<option value=\"-1\"".($thumb_tools == -1 ? " selected" : "").">".$lang['delete']."</option>";
echo "<option value=\"1\"".($thumb_tools == 1 ? " selected" : "").">".$lang['resize']."</option>";
echo "<option value=\"2\"".($thumb_tools == 2 ? " selected" : "").">".$lang['create_thumb']."</option>";
echo "</select>";
echo "</td>";
echo "</tr>";
}
show_input_row($lang['field_download_url'].$lang['download_url_desc'], "image_download_url", $image_row['image_download_url'], $textinput_size);
$title = $lang['field_image_name'].((isset($file_src)) ? get_iptc_insert_link($file_src, "object_name", "image_name", 0) : "");
show_input_row($title, "image_name", $image_row['image_name'], $textinput_size);
$title = $lang['field_description_ext'].((isset($file_src)) ? get_iptc_insert_link($file_src, "caption", "image_description") : "");
show_textarea_row($title, "image_description", $image_row['image_description'], $textarea_size);
$title = $lang['field_keywords_ext'].((isset($file_src)) ? get_iptc_insert_link($file_src, "keyword", "image_keywords") : "");
show_textarea_row($title, "image_keywords", $image_row['image_keywords'], $textarea_size);
// ob_start();
show_cat_select_row($lang['field_category'], $image_row['cat_id'], 3);
// $dropdown = ob_get_contents();
// ob_end_clean();
// $dropdown = str_replace("name=\"cat_id\"", "name=\"cat_id\" onChange=\"document.getElementById('cat_image').style.display=(this.value != ".$image_row['cat_id'].")?'none':'block';\"", $dropdown);
// echo $dropdown;
show_user_select_row($lang['user'], $image_row['user_id']);
$title = $lang['field_date'].$lang['date_desc'].$lang['date_format'].((isset($file_src)) ? get_iptc_insert_link($file_src, "date_created", "image_date", 0) : "");
if (EXIF_ENABLE && isset($file_src))
{
$title .= get_exif_insert_link($file_src, "DateTimeOriginal", "image_date", 0, "<br />");
$title .= get_exif_insert_link($file_src, "DateTimeDigitized", "image_date", 0, "<br />");
$title .= get_exif_insert_link($file_src, "DateTime", "image_date", 0, "<br />");
}
if (function_exists("show_date_input_row"))
show_date_input_row($title, "image_date", $image_row['image_date'], $textinput_size);
else
show_input_row($title, "image_date", $image_row['image_date'], $textinput_size);
show_radio_row($lang['field_free'], "image_active", $image_row['image_active']);
show_radio_row($lang['field_allow_comments'], "image_allow_comments", $image_row['image_allow_comments']);
show_input_row($lang['field_downloads'], "image_downloads", $image_row['image_downloads'], 10);
show_input_row($lang['field_votes'], "image_votes", $image_row['image_votes'], 10);
show_input_row($lang['field_rating'], "image_rating", $image_row['image_rating'], 10);
show_input_row($lang['field_hits'], "image_hits", $image_row['image_hits'], 10);
show_additional_fields("image", $image_row, IMAGES_TABLE);
if (isset($image_row['cat_image']))
{
$value = ($image_row['cat_image'] && $image_row['image_id'] == $image_row['cat_image']) ? 1 : 0;
if (isset($HTTP_POST_VARS['cat_image']))
{
$value = $HTTP_POST_VARS['cat_image'];
}
echo "<tr class=\"".get_row_bg()."\" id=\"cat_image\">\n";
echo "<td><p class=\"rowtitle\">".$lang['cat_image'];
if ($image_row['cat_image'])
{
if (!get_file_path($image_row['cat_image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0))
{
$cat_image = ICON_PATH."/".get_file_extension($image_row['cat_image_media_file']).".gif";
}
else
{
$cat_image = get_file_path($image_row['cat_image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
}
$wh = get_resize2($cat_image, 50);
echo "<br /><span class=\"smalltext\">".$lang['current_image']."<br /><a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_row['cat_image'])."\" target=\"_blank\"><img src=\"".$cat_image."\" width=\"".$wh[0]."\" height=\"".$wh[1]."\" align=\"middle\"></a> <a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_row['cat_image'])."\" target=\"_blank\">".$image_row['cat_image_name']."</a></span>";
}
echo "</p></td>\n<td><p>";
echo "<input type=\"radio\" name=\"cat_image\" value=\"".$image_row['image_id']."\"";
if ($value)
{
echo " checked=\"checked\"";
}
echo "> ".$lang['yes']." \n";
echo "<input type=\"radio\" name=\"cat_image\" value=\"0\"";
if (!$value)
{
echo " checked=\"checked\"";
}
echo "> ".$lang['no']." ";
echo "</p></td>\n</tr>";
show_hidden_input("cat_image_old", $image_row['cat_image']);
}
show_form_footer($lang['save_changes'], $lang['reset'], 2, "", " onClick='showProgress()'");
}
else
{
$action = "modifyimages";
$error_log[] = $lang['no_image'];
}
}
if ($action == "saveimages")
{
$date = time();
$ip = getenv("REMOTE_ADDR");
$error_msg = "";
$num_newimages = $HTTP_POST_VARS['num_newimages'];
$error = array();
for ($i = 1; $i <= $num_newimages; $i++)
{
$image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name_'.$i]));
$cat_id = intval($HTTP_POST_VARS['cat_id_'.$i]);
$remote_file = trim($HTTP_POST_VARS['remote_file_'.$i]);
$remote_thumb_file = trim($HTTP_POST_VARS['remote_thumb_file_'.$i]);
$image_download_url = trim($HTTP_POST_VARS['image_download_url_'.$i]);
if ($cat_id == 0)
{
$error['cat_id_'.$i] = 1;
}
if (((empty($HTTP_POST_FILES['file_'.$i]['tmp_name']) || $HTTP_POST_FILES['file_'.$i]['tmp_name'] == "none") && $remote_file == "") || ($remote_file != "" && !check_remote_media($remote_file) && !check_local_media($remote_file)))
{
$error['file_'.$i] = 1;
}
if ($remote_thumb_file != "" && !check_remote_thumb($remote_thumb_file) && !check_local_thumb($remote_thumb_file))
{
$error['remote_thumb_file_'.$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))
{
for ($i = 1; $i <= $num_newimages; $i++)
{
$log = array();
$uploaderror = 0;
$thumb = "";
$image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name_'.$i]));
$cat_id = intval($HTTP_POST_VARS['cat_id_'.$i]);
$user_id = (intval($HTTP_POST_VARS['user_id_'.$i]) != 0) ? intval($HTTP_POST_VARS['user_id_'.$i]) : $user_info['user_id'];
$remote_file = trim($HTTP_POST_VARS['remote_file_'.$i]);
$remote_thumb_file = trim($HTTP_POST_VARS['remote_thumb_file_'.$i]);
//Upload Image
$file = "file_".$i;
$remote_file = trim($HTTP_POST_VARS['remote_file_'.$i]);
if (!empty($HTTP_POST_FILES[$file]['tmp_name']) && $HTTP_POST_FILES[$file]['tmp_name'] != "none")
{
$new_name = $site_upload->upload_file($file, "media", $cat_id);
if (!$new_name)
{
$log[] = "<b>".$lang['file_upload_error'].":</b> ".$HTTP_POST_FILES[$file]['name']."<br />".$site_upload->get_upload_errors();
$uploaderror = 1;
}
else
{
$log[] = "<b>".$lang['file_upload_success'].":</b> ".$new_name;
}
$name = $HTTP_POST_FILES[$file]['name'];
}
else
{
$new_name = $name = $remote_file;
}
$name = str_replace(" ", "_", $name);
$name = str_replace("%20", "_", $name);
$name = get_file_name(trim(basename($name)));
if ($image_name === "")
{
$image_name = $name;
}
if ($image_name === "")
{
$error['image_name_'.$i] = 1;
continue;
}
//Upload Thumbnail if exists
$thumb_file = "thumb_file_".$i;
$remote_thumb_file = trim($HTTP_POST_VARS['remote_thumb_file_'.$i]);
$new_thumb_name = "";
if (!empty($HTTP_POST_FILES[$thumb_file]['tmp_name']) && $HTTP_POST_FILES[$thumb_file]['tmp_name'] != "none" && !$uploaderror)
{
$new_thumb_name = $site_upload->upload_file($thumb_file, "thumb", $cat_id, get_basefile($new_name));
if (!$new_thumb_name)
{
$log[] = "<b>".$lang['thumb_upload_error'].":</b> ".$HTTP_POST_FILES[$thumb_file]['name']."<br />".$site_upload->get_upload_errors();
@unlink(MEDIA_PATH."/".$cat_id."/".$new_name);
$log[] = $lang['error_image_deleted'];
$uploaderror = 1;
}
else
{
$log[] = "<b>".$lang['thumb_upload_success'].":</b> ".$new_thumb_name;
}
}
else
{
$new_thumb_name = $remote_thumb_file;
}
if (empty($uploaderror) && !$convert_options['convert_error'])
{
$image_resize = (isset($HTTP_POST_VARS['image_resize_'.$i])) ? intval($HTTP_POST_VARS['image_resize_'.$i]) : 0;
$thumb_tools = (isset($HTTP_POST_VARS['thumb_tools_'.$i])) ? intval($HTTP_POST_VARS['thumb_tools_'.$i]) : 0;
if ($image_resize)
{
@set_time_limit(90);
$file = MEDIA_PATH."/".$cat_id."/".$new_name;
if (!$image_info = getimagesize($file))
{
$log[] = "<b>".$lang['image_resize_error']."</b>";
}
else
{
if ($image_info[2] && $image_info[2] < 4)
{
if ($image_info[0] > $image_resize_width || $image_info[1] > $image_resize_height)
{
if (resize_image($file, $image_resize_quality, $image_resize_width, $image_resize_type, $image_resize_height))
{
$image_info2 = getimagesize($file);
$log[] = sprintf($lang['image_resize_success'], $image_info[0], $image_info[1], $image_info2[0], $image_info2[1]);
}
else
{
$log[] = "<b>".$lang['image_resize_error']."</b>";
}
}
else
{
$log[] = "<b>".$lang['image_resize_skipped']."</b>";
}
}
else
{
$log[] = "<b>".$lang['image_resize_skipped']."</b>";
}
}
}
if ($thumb_tools)
{
$type = ($thumb_tools == 1) ? "resize" : "create";
if (($new_thumb_name === "" || $thumb_tools == 2) && file_exists(MEDIA_PATH."/".$cat_id."/".$new_name))
{
if (file_exists(THUMB_PATH."/".$cat_id."/".$new_name))
{
unlink(THUMB_PATH."/".$cat_id."/".$new_name);
}
if (copy(MEDIA_PATH."/".$cat_id."/".$new_name, THUMB_PATH."/".$cat_id."/".$new_name))
{
chmod(THUMB_PATH."/".$cat_id."/".$new_name, CHMOD_FILES);
$new_thumb_name = $new_name;
$type = "create";
}
}
if ($new_thumb_name !== "")
{
@set_time_limit(90);
$file = THUMB_PATH."/".$cat_id."/".$new_thumb_name;
if (!$image_info = getimagesize($file))
{
$log[] = "<b>".$lang['thumb_'.$type.'_error']."</b>";
}
else
{
if ($image_info[2] && $image_info[2] < 4)
{
if ($image_info[0] > $thumb_resize_dimension || $image_info[1] > $thumb_resize_dimension)
{
@unlink($file.".bak");
if (resize_image($file, $thumb_resize_quality, $thumb_resize_dimension, $thumb_resize_type))
{
$image_info2 = getimagesize($file);
$log[] = "<b>".$lang['thumb_'.$type.'_success']."</b>";
}
else
{
$log[] = "<b>".$lang['thumb_'.$type.'_error']."</b>";
}
}
else
{
$log[] = "<b>".$lang['thumb_'.$type.'_skipped']."</b>";
}
}
else
{
$log[] = "<b>".$lang['thumb_'.$type.'_skipped']."</b>";
}
}
}
}
}
//Save to Database
if (!$uploaderror)
{
$image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description_'.$i]));
if (KEYWORDS_NEW)
{
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords_'.$i]));
$image_keywords = preg_replace("/[\n\r]/is", ",", $image_keywords);
$image_keywords_arr = explode(',', $image_keywords);
array_walk($image_keywords_arr, 'trim_value');
$image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));
}
else
{
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords_'.$i]));
$image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
$image_keywords = str_replace(","," ",$image_keywords);
$image_keywords = preg_replace("/( ){2,}/", " ", $image_keywords);
}
$HTTP_POST_VARS['image_keywords_'.$i] = $image_keywords;
$image_active = trim($HTTP_POST_VARS['image_active_'.$i]);
$image_allow_comments = trim($HTTP_POST_VARS['image_allow_comments_'.$i]);
$image_download_url = trim($HTTP_POST_VARS['image_download_url_'.$i]);
$additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields))
{
foreach ($additional_image_fields as $key => $val)
{
if (isset($HTTP_POST_VARS[$key.'_'.$i]) && isset($table_fields[$key]))
{
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key.'_'.$i]))."'";
}
}
}
$current_time = time();
$sql = "INSERT INTO ".IMAGES_TABLE."
(cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments".$additional_field_sql.")
VALUES
($cat_id, $user_id, '$image_name', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";
$result = $site_db->query($sql);
$image_id = $site_db->get_insert_id();
if ($result)
{
$search_words = array();
foreach ($search_match_fields as $image_column => $match_column)
{
if (isset($HTTP_POST_VARS[$image_column.'_'.$i]))
{
$search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column.'_'.$i]);
if (KEYWORDS_NEW && $image_column == 'image_keywords')
{
$search_words[$image_column] = explode(',', $search_words[$image_column]);
}
}
}
add_searchwords($image_id, $search_words);
$name = "";
if ($new_thumb_name)
{
$thumb_src = ROOT_PATH.THUMB_DIR."/".$cat_id."/".$new_thumb_name;
$width = $thumbsize;
$height = $thumbsize;
$thumb_size = get_resize2($thumb_src, $thumbsize);
$width = $thumb_size[0];
$height = $thumb_size[1];
$thumb = "<img src=\"".((is_remote($new_thumb_name)) ? $new_thumb_name : $thumb_src)."\" width=\"".$width."\" height=\"".$height."\" border=\"1\" alt=\"\" hspace=\"5\" vspace=\"3\" align=\"left\" />";
$thumb = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" target=_blank>" . $thumb . "</a>";
}
$name .= "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" target=_blank>" . format_text(stripslashes($image_name), 2) . "</a>";
$log[] = "<b>".$lang['image_add_success'].":</b> ".$name." (".$new_name.") <a href=\"".$site_sess->url(ROOT_PATH."admin/images.php?action=editimage&".URL_IMAGE_ID."=".$image_id)."\"".($target ? " target=\"_blank\"" : "").">[".$lang['edit']."]</a>";
}
else
{
$log[] = "<b>".$lang['image_add_error'].":</b> ".format_text(stripslashes($image_name), 2)." (".$new_name.")";
}
}
else
{
$log[] = $lang['no_db_entry'];
}
show_table_header($lang['image']." $i", 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\"><tr><td>\n";
echo $thumb;
foreach ($log as $val)
{
echo $val."<br />";
}
echo "</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
// echo "<br />";
}
}
echo "<script language=javascript>\n showProgress();\n hideProgress();\n</script>";
if (!empty($error))
{
$msg = sprintf("<span class=\"marktext\">%s</span>", $lang['lostfield_error']);
}
$action = "addimages";
}
if ($action == "addimages")
{
if (isset($HTTP_GET_VARS['num_newimages']) || isset($HTTP_POST_VARS['num_newimages']))
{
$num_newimages = (isset($HTTP_GET_VARS['num_newimages'])) ? intval($HTTP_GET_VARS['num_newimages']) : intval($HTTP_POST_VARS['num_newimages']);
}
else
{
$num_newimages = 1;
}
if ($msg != "")
{
printf("<b>%s</b>\n", $msg);
}
printf("<p>%s</p>\n", $lang['upload_note']);
show_form_header("images.php", "saveimages", "form", 1);
show_table_header($lang['nav_images_add'], 2);
_show_num_select_row(" ", "num_newimages", $lang['num_addnewimages_desc'], $num_newimages_max);
for ($i = 1; $i <= $num_newimages; $i++)
{
show_table_separator($lang['image']." ".$i, 2);
show_upload_row($lang['image'], "file_".$i, "<br /><span class=smalltext>".$lang['allowed_mediatypes_desc'].str_replace(",",", ",$config['allowed_mediatypes'])."</span>");
$image_resize = (isset($image_resize)) ? $image_resize : $image_resize_default;
$thumb_tools = (isset($thumb_tools)) ? $thumb_tools : $thumb_tools_default;
if (!$convert_options['convert_error'])
{
echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">";
echo $lang['image_resize'];
echo "</p>";
echo "</td>\n";
echo "<td>";
echo "<input type=\"radio\" name=\"image_resize_".$i."\" value=\"1\"";
if ($image_resize)
{
echo " checked=\"checked\"";
}
echo "> ".$lang['yes']." \n";
echo "<input type=\"radio\" name=\"image_resize_".$i."\" value=\"0\"";
if (!$image_resize)
{
echo " checked=\"checked\"";
}
echo "> ".$lang['no']." ";
echo "</td>";
echo "</tr>";
}
show_upload_row($lang['thumb'], "thumb_file_".$i, "<br /><span class=smalltext>".$lang['allowed_mediatypes_desc']." jpg, gif, png</span>");
if (!$convert_options['convert_error'])
{
echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">";
echo $lang['thumb_tools_add']."</p>";
echo "</td>\n";
echo "<td valign=\"middle\">";
echo "<select name=\"thumb_tools_".$i."\">";
echo "<option value=\"0\" selected></option>";
echo "<option value=\"1\"".($thumb_tools == 1 ? " selected" : "").">".$lang['resize']."</option>";
echo "<option value=\"2\"".($thumb_tools == 2 ? " selected" : "").">".$lang['create_thumb']."</option>";
echo "</select>";
echo "</td>";
echo "</tr>";
}
show_input_row($lang['field_download_url'].$lang['download_url_desc'], "image_download_url_".$i, "", $textinput_size);
show_input_row($lang['field_image_name'], "image_name_".$i, "", $textinput_size);
show_textarea_row($lang['field_description_ext'],"image_description_".$i, "", $textarea_size);
show_textarea_row($lang['field_keywords_ext'], "image_keywords_".$i, "", $textarea_size);
show_cat_select_row($lang['field_category'], 0, 3, $i);
show_user_select_row($lang['user'], $user_info['user_id'], $i);
show_radio_row($lang['field_free'], "image_active_".$i, 1);
show_radio_row($lang['field_allow_comments'], "image_allow_comments_".$i, 1);
show_additional_fields("image", array(), IMAGES_TABLE, $i);
}
show_hidden_input("num_newimages", $num_newimages);
show_form_footer($lang['add'], $lang['reset'], 2, "", " onClick='showProgress()'");
}
if (isset($HTTP_GET_VARS['presetload'])|| isset($HTTP_POST_VARS['presetload']))
{
if (isset($HTTP_POST_VARS['preset']) && $HTTP_POST_VARS['preset'])
{
$preset = trim($HTTP_POST_VARS['preset']);
}
elseif (isset($HTTP_GET_VARS['preset']) && $HTTP_GET_VARS['preset'])
{
$preset = trim($HTTP_GET_VARS['preset']);
}
else
{
$msg .= $lang['preset_load_error'];
}
if (!isset($presets[$preset]))
{
$preset = $presets['_default_'];
}
else
{
foreach($presets['default'] as $key => $val)
{
if (!isset($presets[$preset][$key]))
{
$presets[$preset][$key] = $val;
}
}
}
$HTTP_POST_VARS = array();
$action = "modifyimages";
}
elseif (isset($HTTP_GET_VARS['presetdelete']) || isset($HTTP_POST_VARS['presetdelete']))
{
if (isset($HTTP_POST_VARS['preset']) && $HTTP_POST_VARS['preset'])
{
$preset_name = trim($HTTP_POST_VARS['preset']);
}
elseif (isset($HTTP_GET_VARS['preset']) && $HTTP_GET_VARS['preset'])
{
$preset_name = trim($HTTP_GET_VARS['preset']);
}
else
{
$msg .= $lang['preset_delete_error'];
}
if ($preset_name == "default" || !isset($presets[$preset_name]))
{
$msg .= $lang['preset_delete_error'];
}
else
{
unset($presets[$preset_name]);
if ($preset_name == $presets['_default_'])
{
$presets['_default_'] = "default";
}
$preset = $presets['_default_'];
preset_save();
}
$HTTP_POST_VARS = array();
$action = "modifyimages";
}
elseif (isset($HTTP_POST_VARS['presetsave']))
{
$preset_name = "";
$action = "modifyimages";
if (isset($HTTP_POST_VARS['presetnew']) && $HTTP_POST_VARS['presetnew'])
{
$preset_name = trim($HTTP_POST_VARS['presetnew']);
}
if ($preset_name == "default")
{
$preset_name = "";
}
if ($preset_name)
{
unset($presets[$preset_name]);
foreach($presets['default'] as $key => $val)
{
if ($key == "quickedit")
{
$presets[$preset_name][$key] = array("", (isset($HTTP_POST_VARS[$key]) ? $HTTP_POST_VARS[$key] : array()));
continue;
}
if ($val[0])
{
$presets[$preset_name][$key] = array($val[0], $HTTP_POST_VARS[$key]);
switch($val[0])
{
case "int":
if (trim($presets[$preset_name][$key][1]) !== "")
$presets[$preset_name][$key][1] = (int)trim($presets[$preset_name][$key][1]);
break;
case "trim":
$presets[$preset_name][$key][1] = trim($presets[$preset_name][$key][1]);
break;
case "bool":
$presets[$preset_name][$key][1] = trim($presets[$preset_name][$key][1]) ? 1 : 0;
break;
default:
break;
}
continue;
}
$array = array();
foreach($val[1] as $key2 => $val2)
{
if (is_array($val2))
{
$array[$key2] = array($val2[0], @$HTTP_POST_VARS[$key2]);
}
else
{
$array[$key2] = @$HTTP_POST_VARS[$key2];
}
}
$presets[$preset_name][$key] = array("", $array);
}
$preset = $preset_name;
$presets['_default_'] = (isset($HTTP_POST_VARS['presetdefault']) && intval($HTTP_POST_VARS['presetdefault'])) ? $preset : ($presets['_default_'] == $preset ? "default" : $presets['_default_']);
if ($action == "modifyimages")
{
$HTTP_POST_VARS = array();
}
preset_save();
}
else
{
$msg .= $lang['preset_save_error'];
}
}
if ($action == "modifyimages")
{
if (!empty($error_log))
{
show_table_header($lang['error_log'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$lang['error_log_desc']."</b>\n<ul>\n";
foreach ($error_log as $val)
{
printf("<li>%s</li>\n", $val);
}
echo "</ul>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
if (!empty($msg))
{
show_table_header($lang['msg'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$msg."</b>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
$last_image_id_type = $presets[$preset]['image_id_type'][1];
$last_image_name_type = $presets[$preset]['image_name_type'][1];
$last_image_description_type = $presets[$preset]['image_description_type'][1];
$last_image_keywords_type = $presets[$preset]['image_keywords_type'][1];
$last_user_id_type = $presets[$preset]['user_id_type'][1];
$last_user_name_type = $presets[$preset]['user_name_type'][1];
$last_image_media_file_type = $presets[$preset]['image_media_file_type'][1];
$last_image_thumb_file_type = $presets[$preset]['image_thumb_file_type'][1];
$last_cat_id_type = $presets[$preset]['cat_id_type'][1];
$last_cat_id = $presets[$preset]['cat_id'][1];
$last_image_active = $presets[$preset]['image_active'][1];
$last_orderby = $presets[$preset]['orderby'][1];
$last_direction = $presets[$preset]['direction'][1];
$last_limitnumber = $presets[$preset]['limitnumber'][1];
$last_quickedit = $presets[$preset]['quickedit'][1];
show_form_header("images.php", "findimages", "form");
show_table_header($lang['nav_images_edit'], 2);
show_input_row_type($lang['field_image_id_contains'], "image_id", $presets[$preset]['image_id'][1], $textinput_size, array($last_image_id_type, "int"), 1, 0);
show_input_row_type($lang['field_image_name_contains'], "image_name", $presets[$preset]['image_name'][1], $textinput_size, array($last_image_name_type, ""), 1, 0);
show_input_row_type($lang['field_description_contains'], "image_description", $presets[$preset]['image_description'][1], $textinput_size, array($last_image_description_type, ""), 1, 0);
show_input_row_type($lang['field_keywords_contains'], "image_keywords", $presets[$preset]['image_keywords'][1], $textinput_size, array($last_image_keywords_type, ""), 1, 0);
show_cat_select_row_type($lang['field_category'], $last_cat_id, 2, 0, $last_cat_id_type, 1, 0, $presets[$preset]['subcat'][1]);
show_input_row_type($lang['user_id_contains'], "user_id", $presets[$preset]['user_id'][1], $textinput_size, array($last_user_id_type, "int"), 1, 0);
show_input_row_type($lang['field_username_contains'], "user_name", $presets[$preset]['user_name'][1], $textinput_size, array($last_user_name_type, ""), 1, 0);
show_radio_row($lang['image_active'], "image_active", $last_image_active);
show_input_row_type($lang['field_image_file_contains'], "image_media_file", $presets[$preset]['image_media_file'][1], $textinput_size, array($last_image_media_file_type, ""), 1, 0);
show_input_row_type($lang['field_thumb_file_contains'], "image_thumb_file", $presets[$preset]['image_thumb_file'][1], $textinput_size, array($last_image_thumb_file_type, ""), 1, 0);
if (function_exists("show_date_input_row"))
show_date_input_row($lang['field_date_after'].$lang['date_format'], "dateafter", $presets[$preset]['dateafter'][1], $textinput_size);
else
show_input_row($lang['field_date_after'].$lang['date_format'], "dateafter", $presets[$preset]['dateafter'][1], $textinput_size);
if (function_exists("show_date_input_row"))
show_date_input_row($lang['field_date_before'].$lang['date_format'], "datebefore", $presets[$preset]['datebefore'][1], $textinput_size);
else
show_input_row($lang['field_date_before'].$lang['date_format'], "datebefore", $presets[$preset]['datebefore'][1], $textinput_size);
show_input_row($lang['field_downloads_upper'], "downloadsupper", $presets[$preset]['downloadsupper'][1], $textinput_size);
show_input_row($lang['field_downloads_lower'], "downloadslower", $presets[$preset]['downloadslower'][1], $textinput_size);
show_input_row($lang['field_rating_upper'], "ratingupper", $presets[$preset]['ratingupper'][1], $textinput_size);
show_input_row($lang['field_rating_lower'], "ratinglower", $presets[$preset]['ratinglower'][1], $textinput_size);
show_input_row($lang['field_votes_upper'], "votesupper", $presets[$preset]['votesupper'][1], $textinput_size);
show_input_row($lang['field_votes_lower'], "voteslower", $presets[$preset]['voteslower'][1], $textinput_size);
show_input_row($lang['field_hits_upper'], "hitsupper", $presets[$preset]['hitsupper'][1], $textinput_size);
show_input_row($lang['field_hits_lower'], "hitslower", $presets[$preset]['hitslower'][1], $textinput_size);
if (!empty($additional_image_fields))
{
show_table_separator($lang['additional_fields'], 2);
}
foreach ($additional_image_fields as $key => $val)
{
if (!isset($table_fields[$key]) || (isset($additional_image_fields_settings[$key][0]) && !$additional_image_fields_settings[$key][0]))
continue;
$type = (isset($presets[$preset]['additional_fields'][1][$key."_type"][1])) ? (int)$presets[$preset]['additional_fields'][1][$key."_type"][1] : 0;
$value = "";
switch($val[1])
{
case "radio":
$value = (isset($presets[$preset]['additional_fields'][1][$key][1])) ? $presets[$preset]['additional_fields'][1][$key][1] : "";
$value = ($value === "") ? 1 : $value;
show_radio_row_type($val[0], $key, $value, $type, 0, 1);
break;
case "dropdown":
$value = (isset($presets[$preset]['additional_fields'][1][$key][1])) ? $presets[$preset]['additional_fields'][1][$key][1] : "";
show_user_dropdown_row_type($key, $val, $value, array($type, "dropdown"), 0, 1);
break;
case "text":
case "textarea":
default:
$value = "";
$value = (isset($presets[$preset]['additional_fields'][1][$key][1])) ? $presets[$preset]['additional_fields'][1][$key][1] : "";
show_input_row_type($val[0], $key, $value, $textinput_size, array($type, "text"), 1, 1);
break;
} // end switch
$fields[$key] = $value;
$fields[$key . "_type"] = $type;
}
show_table_separator($lang['sort_options'], 2);
?>
<tr class="<?php echo get_row_bg(); ?>"><td><p><b><?php echo $lang['order_by'] ?></b></p></td><td><p>
<select name="orderby">
<?php
$sort_array = array(
"i.image_name" => $lang['field_image_name'],
"i.image_name" => $lang['field_image_name'],
"i.image_media_file" => $lang['field_image_file'],
"i.image_thumb_file" => $lang['field_thumb_file'],
"i.cat_id" => $lang['field_category'],
"i.image_date" => $lang['field_date'],
"i.image_downloads" => $lang['field_downloads'],
"i.image_rating" => $lang['field_rating'],
"i.image_votes" => $lang['field_votes'],
"i.image_hits" => $lang['field_hits'],
);
foreach($sort_array as $key => $val)
{
echo '<option value="'.$key.'"'.($key == $last_orderby ? " selected" :"").'>'.$val.'</option>';
}
?>
</select>
<select name="direction">
<option value="ASC"<?=($last_direction == "ASC" ? " selected" : "")?>><?php echo $lang['asc'] ?></option>
<option value="DESC"<?=($last_direction == "DESC" ? " selected" : "")?>><?php echo $lang['desc'] ?></option>
</select>
</p></td></tr>
<?php
show_input_row($lang['results_per_page'], "limitnumber", $last_limitnumber);
if ($quickedit_checkboxes)
{
show_table_separator($lang['quick_edit']."</td><td><input name=\"allbox\" type=\"checkbox\" onClick=\"CheckAll();\" style=\"margin: 0; height: 12px;\" />", 1);
}
else
{
show_table_separator($lang['quick_edit'], 2);
}
$i = 0;
if (!is_array($last_quickedit))
$last_quickedit = explode("|", $last_quickedit);
echo "<tr class=\"".get_row_bg()."\">\n";
echo "<td><p class=\"rowtitle\">".$lang['quick_edit_fields'];
if (!$quickedit_checkboxes)
{
echo "<br />".$lang['quick_edit_fields_exp'];
}
echo "</p></td>\n";
echo "<td><div".($quickedit_checkboxes && $quickedit_checkboxes_height ? " style=\"height:".$quickedit_checkboxes_height."px;overflow:auto;\"" : "").">";
if (!$quickedit_checkboxes)
{
echo "<table><tr><td>";
echo "<select name=\"quickedit[]\" multiple size=\"10\" width=\"20\" />\n";
// echo "<option value=\"\"></option>\n";
}
$i = 0;
foreach ($quickedit_fields_all as $field => $val)
{
if ($quickedit_checkboxes)
{
$select = (in_array($field, $last_quickedit)) ? " checked" : "";
echo "<label for=\"quickedit[$i]\"><input type=\"checkbox\" name=\"quickedit[]\" id=\"quickedit[$i]\" value=\"".$field."\" ".$select.">".$val[0]."</label><br />\n";
}
else
{
$select = (in_array($field, $last_quickedit) || (isset($HTTP_POST_VARS['quickedit']) && in_array($field, $HTTP_POST_VARS['quickedit']))) ? " selected" : "";
echo "<option value=\"".$field."\" ".$select.">".$val[0]."</option>\n";
}
$i++;
}
if (!$quickedit_checkboxes)
{
echo "</select>";
echo "</td><td valign=\"top\">";
echo "<a href=\"#\" onClick=\"for(i=0;i<this.parentNode.parentNode.getElementsByTagName('select')[0].options.length;i++)this.parentNode.parentNode.getElementsByTagName('select')[0].options[i].selected=true;return false;\">".$lang['select_all']."</a><br />";
echo "<a href=\"#\" onClick=\"for(i=0;i<this.parentNode.parentNode.getElementsByTagName('select')[0].options.length;i++)this.parentNode.parentNode.getElementsByTagName('select')[0].options[i].selected=false;return false;\">".$lang['select_none']."</a><br />";
echo "</td></tr></table>";
}
echo "</div></td>\n</tr>";
show_table_separator($lang['presets']." <span style=\"font-weight: normal;\">(".$lang['preset_loaded'].": <b>".(($preset == "default") ? $lang['default'] : $preset)."</b>)</span>", 2);
echo "<tr class=\"".get_row_bg()."\">\n";
echo "<td><p class=\"rowtitle\">";
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"rowtitle\"><td width=\"100%\">".$lang['preset_save']."</td>";
echo "<td><input type=\"checkbox\" name=\"presetdefault\" value=\"1\"".(($preset == $presets['_default_']) ? " checked" : "")." /></td></table>";
echo "</p></td>\n";
echo "<td>";
echo "<input name=\"presetnew\" value=\"".($preset == "default" ? "" : str_replace("\"", """, $preset))."\" />";
echo " <input type=\"submit\" name=\"presetsave\" value=\" ".$lang['save']." \" onClick=\"return (this.form.presetnew.value&&this.form.presetnew.value!='default') ? true : false;\"class=\"button\" />\n";
$options = "";
foreach($presets as $key => $val)
{
if ($key == "default" || $key == "_default_")
continue;
$key = str_replace(array("\"", "<", ">"), array(""", "<", ">"), $key);
$options .= "<option value=\"".$key."\"".(($key == $preset) ? " selected" : "").">".$key."</option>";
}
if ($options)
{
echo " <select name=\"preset\" onChange=\"if(this.value!='default')this.form.presetnew.value=this.value;this.form.presetdefault.checked=(this.value=='".str_replace(array("\"", "'"), array(""", "\'"), $presets['_default_'])."');\">";
// echo "<option value=\"\"".(($preset == "default" || $preset == "_default_") ? "" : " selected")."></option>";
echo "<option value=\"default\"".(($preset == "default" || $preset == "_default_") ? "" : " selected").">".$lang['default']."</option>";
// echo "<option value=\"default\">".$lang['default']."</option>";
echo $options;
echo "</select>";
echo " <input type=\"submit\" name=\"presetload\" value=\" ".$lang['load']." \" onClick=\"return (this.form.preset.value) ? true : false;\"class=\"button\" />\n";
echo " <input type=\"submit\" name=\"presetdelete\" value=\" ".$lang['delete']." \" onClick=\"return (this.form.preset.value&&this.form.preset.value!='default') ? true : false;\"class=\"button\" />\n";
}
echo "</td>";
echo "</tr>";
/*
if ($savesearchform)
{
*/
echo "<tr class=\"tablefooter\">\n<td colspan=\"2\" align=\"center\">\n ";
echo "<input type=\"submit\" value=\" ".$lang['search']." \" class=\"button\">\n";
echo "<input type=\"submit\" name=\"action2\" value=\" ".$lang['reset']." \" class=\"button\">\n";
echo " \n</td>\n</tr>\n</table>\n</td>\n</tr>\n</table>\n</form>\n";
/*
}
else
{
show_form_footer($lang['search'], $lang['reset'], 2);
}
*/
}
if ($action == "findimages")
{
if (!empty($error_log))
{
show_table_header($lang['error_log'], 1);
echo "<tr><td class=\"tablerow\">\n";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td> </td><td>\n";
echo "<b>".$lang['error_log_desc']."</b>\n<ul>\n";
foreach ($error_log as $val)
{
printf("<li>%s</li>\n", $val);
}
echo "</ul>\n</td></tr></table>\n";
echo "</td></tr>\n";
show_table_footer();
}
$condition = "1=1";
$image_id = intval($HTTP_POST_VARS['image_id']);
$image_id_type = (isset($HTTP_POST_VARS["image_id_type"]) && (int)$HTTP_POST_VARS["image_id_type"]) ? (int)$HTTP_POST_VARS["image_id_type"] : 0;
if ($image_id != "" || $image_id_type != -1)
{
$cond = "";
if ($image_id_type)
{
if ($cond = get_type_condition($image_id_type, "text", "int", 1, 0, array("i.image_id", $image_id)))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(i.image_id,'$image_id')>0";
}
}
$image_name = trim($HTTP_POST_VARS['image_name']);
$image_name_type = (isset($HTTP_POST_VARS["image_name_type"]) && (int)$HTTP_POST_VARS["image_name_type"]) ? (int)$HTTP_POST_VARS["image_name_type"] : 0;
if ($image_name != "" || $image_name_type != -1)
{
$cond = "";
if ($image_name_type)
{
if ($cond = get_type_condition($image_name_type, "text", "text", 1, 0, array("i.image_name", strtolower($image_name))))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(LCASE(i.image_name),'".strtolower($image_name)."')>0";
}
}
$user_name = trim($HTTP_POST_VARS['user_name']);
$user_name_type = (isset($HTTP_POST_VARS["user_name_type"]) && (int)$HTTP_POST_VARS["user_name_type"]) ? (int)$HTTP_POST_VARS["user_name_type"] : 0;
if ($user_name != "" || $user_name_type != -1)
{
$cond = "";
if ($user_name_type)
{
if ($cond = get_type_condition($user_name_type, "text", "text", 1, 0, array("u.user_name", strtolower($user_name))))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(LCASE(u.user_name),'".strtolower($user_name)."')>0";
}
}
$user_id = intval($HTTP_POST_VARS['user_id']);
$user_id_type = (isset($HTTP_POST_VARS["user_id_type"]) && (int)$HTTP_POST_VARS["user_id_type"]) ? (int)$HTTP_POST_VARS["user_id_type"] : 0;
if ($user_id != "" || $user_id_type != -1)
{
$cond = "";
if ($user_id_type)
{
if ($cond = get_type_condition($user_id_type, "text", "int", 1, 0, array("i.user_id", $user_id)))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(i.user_id,'$user_id')>0";
}
}
$image_description = trim($HTTP_POST_VARS['image_description']);
$image_description_type = (isset($HTTP_POST_VARS["image_description_type"]) && (int)$HTTP_POST_VARS["image_description_type"]) ? (int)$HTTP_POST_VARS["image_description_type"] : 0;
if ($image_description != "" || $image_description_type != -1)
{
$cond = "";
if ($image_description_type)
{
if ($cond = get_type_condition($image_description_type, "text", "text", 1, 0, array("i.image_description", strtolower($image_description))))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(LCASE(i.image_description),'".strtolower($image_description)."')>0";
}
}
$image_keywords = trim($HTTP_POST_VARS['image_keywords']);
$image_keywords_type = (isset($HTTP_POST_VARS["image_keywords_type"]) && (int)$HTTP_POST_VARS["image_keywords_type"]) ? (int)$HTTP_POST_VARS["image_keywords_type"] : 0;
if ($image_keywords != "" || $image_keywords_type != -1)
{
$cond = "";
if ($image_keywords_type)
{
if ($cond = get_type_condition($image_keywords_type, "text", "text", 1, 0, array("i.image_keywords", strtolower($image_keywords))))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(LCASE(i.image_keywords),'".strtolower($image_keywords)."')>0";
}
}
$cat_id = intval(trim($HTTP_POST_VARS['cat_id']));
$cat_id_type = (isset($HTTP_POST_VARS["cat_id_type"]) && (int)$HTTP_POST_VARS["cat_id_type"]) ? (int)$HTTP_POST_VARS["cat_id_type"] : 0;
$subcat = isset($HTTP_POST_VARS['subcat']);
if ($cat_id != 0 && $cat_id != "" || $cat_id_type != -1)
{
$cond = "";
if ($cat_id_type)
{
if ($cond = get_type_condition($cat_id_type, "text", "dropdown", 1, 0, array("i.cat_id", $cat_id)))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
if ($subcat)
{
$subcat_ids = array();
get_subcat_ids($cat_id, $cat_id, $cat_parent_cache);
if (@$subcat_ids[$cat_id])
{
$subcats = "," . implode(",", $subcat_ids[$cat_id]);
}
}
$condition .= " AND i.cat_id IN($cat_id$subcats)";
}
}
$image_media_file = trim($HTTP_POST_VARS['image_media_file']);
$image_media_file_type = (isset($HTTP_POST_VARS["image_media_file_type"]) && (int)$HTTP_POST_VARS["image_media_file_type"]) ? (int)$HTTP_POST_VARS["image_media_file_type"] : 0;
if ($image_media_file != "" || $image_media_file_type != -1)
{
$cond = "";
if ($image_media_file_type)
{
if ($cond = get_type_condition($image_media_file_type, "text", "text", 1, 0, array("i.image_media_file", strtolower($image_media_file))))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(LCASE(i.image_media_file),'".strtolower($image_media_file)."')>0";
}
}
$image_thumb_file = trim($HTTP_POST_VARS['image_thumb_file']);
$image_thumb_file_type = (isset($HTTP_POST_VARS["image_thumb_file_type"]) && (int)$HTTP_POST_VARS["image_thumb_file_type"]) ? (int)$HTTP_POST_VARS["image_thumb_file_type"] : 0;
if ($image_thumb_file != "" || $image_thumb_file_type != -1)
{
$cond = "";
if ($image_thumb_file_type)
{
if ($cond = get_type_condition($image_thumb_file_type, "text", "text", 1, 0, array("i.image_thumb_file", strtolower($image_thumb_file))))
{
$cond = " AND " . $cond;
}
}
if ($cond)
{
$condition .= $cond;
}
else
{
$condition .= " AND INSTR(LCASE(i.image_thumb_file),'".strtolower($image_thumb_file)."')>0";
}
}
$dateafter = trim($HTTP_POST_VARS['dateafter']);
if ($dateafter != "")
{
$condition .= " AND i.image_date > UNIX_TIMESTAMP('$dateafter')";
}
$datebefore = trim($HTTP_POST_VARS['datebefore']);
if ($datebefore != "")
{
$condition .= " AND i.image_date < UNIX_TIMESTAMP('$datebefore')";
}
$downloadslower = trim($HTTP_POST_VARS['downloadslower']);
if ($downloadslower != "")
{
$condition .= " AND i.image_downloads < '$downloadslower'";
}
$downloadsupper = trim($HTTP_POST_VARS['downloadsupper']);
if ($downloadsupper != "")
{
$condition .= " AND i.image_downloads > '$downloadsupper'";
}
$ratinglower = trim($HTTP_POST_VARS['ratinglower']);
if ($ratinglower != "")
{
$condition .= " AND i.image_rating < '$ratinglower'";
}
$ratingupper = trim($HTTP_POST_VARS['ratingupper']);
if ($ratingupper != "")
{
$condition .= " AND i.image_rating > '$ratingupper'";
}
$voteslower = trim($HTTP_POST_VARS['voteslower']);
if ($voteslower != "")
{
$condition .= " AND i.image_votes < '$voteslower'";
}
$votesupper = trim($HTTP_POST_VARS['votesupper']);
if ($votesupper != "")
{
$condition .= " AND i.image_votes > '$votesupper'";
}
$hitslower = trim($HTTP_POST_VARS['hitslower']);
if ($hitslower != "")
{
$condition .= " AND i.image_hits < '$hitslower'";
}
$hitsupper = trim($HTTP_POST_VARS['hitsupper']);
if ($hitsupper != "")
{
$condition .= " AND i.image_hits > '$hitsupper'";
}
$orderby = trim($HTTP_POST_VARS['orderby']);
if ($orderby == "")
{
$orderby = $presets['default']['orderby'];
}
$limitstart = (isset($HTTP_POST_VARS['limitstart'])) ? intval(trim($HTTP_POST_VARS['limitstart'])) : 0;
if (!$limitstart)
{
$limitstart = 0;
}
$limitnumber = (isset($HTTP_POST_VARS['limitnumber'])) ? trim($HTTP_POST_VARS['limitnumber']) : 1;
if (!$limitnumber)
{
$limitnumber = 1;
}
if (isset($HTTP_GET_VARS['direction']) || isset($HTTP_POST_VARS['direction']))
{
$direction = (isset($HTTP_GET_VARS['direction'])) ? trim($HTTP_GET_VARS['direction']) : trim($HTTP_POST_VARS['direction']);
}
else
{
$direction = $presets['default']['direction'];
}
$image_active = (isset($HTTP_POST_VARS['image_active']) && $HTTP_POST_VARS['image_active']) ? 1 : 0;
$condition .= " AND i.image_active = ".$image_active;
$new_cat_id = isset($HTTP_POST_VARS['new_cat_id']) ? intval(trim($HTTP_POST_VARS['new_cat_id'])) : 0;
$quickedit = isset($HTTP_POST_VARS['quickedit']) ? $HTTP_POST_VARS['quickedit'] : array();
if (!is_array($quickedit))
$quickedit = array();
if (isset($quickedit[0]) && empty($quickedit[0]))
{
array_shift($quickedit);
}
$nextpage = isset($HTTP_POST_VARS['nextpage']) ? intval(trim($HTTP_POST_VARS['nextpage'])) : 2;
$date = isset($HTTP_POST_VARS['date']) ? intval(trim($HTTP_POST_VARS['date'])) : $savedate;
$nextpageabort = isset($HTTP_POST_VARS['nextpageabort']) ? intval(trim($HTTP_POST_VARS['nextpageabort'])) : 0;
$owner = (isset($HTTP_POST_VARS['owner'])) ? intval($HTTP_POST_VARS['owner']) : $owner;
$fields = array();
foreach ($additional_image_fields as $key => $val)
{
if (!isset($table_fields[$key]))
continue;
switch($val[1])
{
case "radio":
$data = (isset($HTTP_POST_VARS[$key])) ? (int)trim($HTTP_POST_VARS[$key]) : 0;
break;
case "dropdown":
$data = (isset($HTTP_POST_VARS[$key])) ? trim($HTTP_POST_VARS[$key]) : "";
break;
case "text":
case "textarea":
default:
$data = (isset($HTTP_POST_VARS[$key])) ? trim($HTTP_POST_VARS[$key]) : "";
break;
} // end switch
$selected = (isset($HTTP_POST_VARS[$key . "_type"]) && (int)$HTTP_POST_VARS[$key . "_type"]) ? (int)$HTTP_POST_VARS[$key . "_type"] : 0;
if ($selected)
{
if (!isset($additional_image_fields_settings[$key][0])
|| (isset($additional_image_fields_settings[$key][0])
&& $additional_image_fields_settings[$key][0]))
{
if (isset($additional_image_fields_settings[$key][1])
&& $additional_image_fields_settings[$key][1] !== "")
{
$condition .= " AND " . sprintf($additional_image_fields_settings[$key][1], "i." . $key, $data);
}
else
{
if ($result = get_type_condition($selected, $val, $table_fields[$key], 0, 1, array("i." . $key, $data)))
{
$condition .= " AND " . $result;
}
else
{
$condition .= " AND INSTR(LCASE(i." . $key ."),'".strtolower($data)."')>0";
}
}
}
}
$fields[$key . "_type"] = $selected;
$fields[$key] = $data;
}
if ($nextpage && $nextpage != 2 && !$nextpageabort)
{
$limitstart = $limitstart + $limitnumber;
}
$sql = "SELECT COUNT(*) AS images
FROM ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE $condition";
$countimages = $site_db->query_firstrow($sql);
$limitfinish = $limitstart + $limitnumber;
$start = 0;
if ($countimages['images'] > 0)
{
$start = $limitstart + 1;
}
echo $lang['found']." <b>".$countimages['images']."</b>. ".$lang['showing']." <b>$start</b>-";
if ($limitfinish > $countimages['images'] == 0)
{
echo "<b>".$limitfinish."</b>.";
}
else
{
echo "<b>".$countimages['images']."</b>.";
}
echo "<br />".$lang['no_image_found'];
show_form_header("images.php", "removeimage", "form");
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" align=\"center\"><tr><td class=\"tableborder\">\n<table cellpadding=\"3\" cellspacing=\"1\" border=\"0\" width=\"100%\">\n";
if ($countimages['images'] > 0)
{
echo "<tr class=\"tableseparator\">\n";
if (empty($quickedit))
{
echo "<td class=\"tableseparator\"><input name=\"allbox\" type=\"checkbox\" onClick=\"CheckAll();\" /></td>\n";
}
echo "<td class=\"tableseparator\"> </td><td class=\"tableseparator\">".$lang['field_image_name']."</td>\n";
if (!empty($quickedit))
{
foreach ($quickedit as $field)
{
if ($field != "image_name" && $field != "image_date" && ($field != "user_id" || !function_exists("get_user_id_by_name")))
echo "<td class=\"tableseparator\">".$quickedit_fields_all[$field][0]."</td>\n";
}
}
echo "<td class=\"tableseparator\">".$lang['field_category']."</td>\n<td class=\"tableseparator\">".$lang['field_username']."</td>\n<td class=\"tableseparator\">".$lang['field_date']."</td>\n<td class=\"tableseparator\">".$lang['options']."</td>\n</tr>\n";
$sql_fields = ($quickedit) ? ", i.".implode(", i.", $quickedit) : "";
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file, i.image_date, i.image_description, i.image_keywords".get_user_table_field(", u.", "user_name").$sql_fields."
FROM ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE $condition
ORDER BY $orderby $direction, i.image_id $direction
LIMIT ".$limitstart.", $limitnumber";
$result = $site_db->query($sql);
$i = 0;
while ($image_row = $site_db->fetch_array($result))
{
$mark = "";
if (!get_file_path($image_row['image_media_file'], "media", $image_row['cat_id'], 1, 0))
{
$mark = "_error";
}
echo "<tr class=\"".get_row_bg().$mark."\">";
if (!empty($quickedit))
{
echo "<input type=\"hidden\" name=\"selectimages[$i]\" value=\"".$image_row['image_id']."\" />";
}
else
{
echo "<td><input type=\"checkbox\" name=\"selectimages[]\" value=\"".$image_row['image_id']."\" /></td>";
}
$thumb_src = get_thumbnail($image_row);
$width = $thumbsize;
$height = $thumbsize;
$thumb_size = get_resize2($thumb_src, $thumbsize);
$width = $thumb_size[0];
$height = $thumb_size[1];
echo "<td align=\"center\"><a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_row['image_id'])."\" target=_blank><img src=\"".((empty($image_row['image_thumb_file'])) ? ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif" : ((is_remote($image_row['image_thumb_file'])) ? $image_row['image_thumb_file'] : $thumb_src))."\" width=\"".$width."\" height=\"".$height."\" border=\"1\" alt=\"\" /></a></td><td>";
if (in_array("image_name", $quickedit))
{
echo "<input type=\"hidden\" name=\"qe_orig_image_name[$i]\" value=\"".str_replace("\"", """, stripslashes($image_row['image_name']))."\" />";
echo "<input name=\"qe_image_name[$i]\" value=\"".str_replace("\"", """, stripslashes($image_row['image_name']))."\" />";
}
else
{
echo "<b><a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_row['image_id'])."\" target=_blank>".$image_row['image_name']."</a></b> ";
}
echo " [ID: ".$image_row['image_id']."]<br />(<i>".$image_row['image_media_file']."</i>";
if ($mark)
{
echo " <b class=\"marktext\">!</b>";
}
echo ")</td>\n";
if (!empty($quickedit))
{
foreach ($quickedit as $field)
{
if ($field == "image_name" || $field == "image_date" || ($field == "user_id" && function_exists("get_user_id_by_name")))
continue;
echo "<td>";
switch ($quickedit_fields_all[$field][1])
{
case "dropdown":
if (function_exists("get_dropdown_options"))
{
echo "<input type=\"hidden\" name=\"qe_orig_".$field."[$i]\" value=\"".safe_htmlspecialchars($image_row[$field])."\" />";
echo get_dropdown_options("qe_".$field."[$i]", $quickedit_fields_all[$field][3], $image_row[$field], $quickedit_fields_all[$field][4], $quickedit_fields_all[$field][5], $quickedit_fields_all[$field][7], 1, "", "select", $quickedit_fields_all[$field][6]);
break;
}
else
{
$quickedit_fields_all[$field][1] = "text";
}
case "text":
echo "<input type=\"hidden\" name=\"qe_orig_".$field."[$i]\" value=\"".safe_htmlspecialchars($image_row[$field])."\" />";
echo "<input name=\"qe_".$field."[$i]\" value=\"".safe_htmlspecialchars($image_row[$field])."\">";
break;
case "textarea":
echo "<input type=\"hidden\" name=\"qe_orig_".$field."[$i]\" value=\"".safe_htmlspecialchars($image_row[$field])."\" />";
echo "<textarea cols=\"$cols\" rows=\"$rows\" name=\"qe_".$field."[$i]\">".safe_htmlspecialchars($image_row[$field])."</textarea>";
break;
case "radio":
echo "<input type=\"hidden\" name=\"qe_orig_".$field."[$i]\" value=\"".safe_htmlspecialchars($image_row[$field])."\" />";
echo "<label for=\"y_".$field."$i\"><input type=\"radio\" name=\"qe_".$field."[$i]\" id=\"y_".$field."$i\" value=\"1\"";
if ($image_row[$field] == 1)
{
echo " checked=\"checked\"";
}
echo ">".$lang['yes']."</label>";
echo "<label for=\"n_".$field."$i\"><input type=\"radio\" name=\"qe_".$field."[$i]\" id=\"n_".$field."$i\" value=\"0\"";
if ($image_row[$field] != 1)
{
echo " checked=\"checked\"";
}
echo ">".$lang['no']."</label> ";
break;
default:
echo safe_htmlspecialchars($image_row[$field]);
break;
}
echo "</td>\n";
}
}
echo "<td><b><a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$image_row['cat_id'])."\" target=\"_blank\">".safe_htmlspecialchars($cat_cache[$image_row['cat_id']]['cat_name'])."</a></b> [ID: ".$image_row['cat_id']."]</td>\n";
$show_user_name = format_text($image_row[$user_table_fields['user_name']], 2);
if (function_exists("get_user_id_by_name") && in_array("user_id", $quickedit))
{
unset($HTTP_POST_VARS["qe_user_id"][$i]);
echo "<input type=\"hidden\" name=\"qe_orig_user_id[$i]\" value=\"".safe_htmlspecialchars($image_row['user_id'])."\" />";
ob_start();
show_user_select_row("", $image_row['user_id'], $i, 0, "qe_user_id", 1, 0, 0);
$show_user_name = ob_get_contents();
ob_end_clean();
}
elseif ($image_row['user_id'] != GUEST)
{
$show_user_name = "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$image_row['user_id'])."\" target=\"_blank\">$show_user_name</a>";
}
echo "<td>".$show_user_name."</td>\n";
echo "<td>";
if (in_array("image_date", $quickedit))
{
$value = format_date("Y-m-d H:i:s", $image_row['image_date']);
echo "<input type=\"hidden\" name=\"qe_orig_image_date[$i]\" value=\"".safe_htmlspecialchars($image_row['image_date'])."\" />";
echo "<input name=\"qe_image_date[$i]\" id=\"image_date[$i]\" value=\"".$value."\" />";
if (function_exists("get_calendar_js"))
echo get_calendar_js("image_date[$i]", $value);
echo "<br />yyyy-mm-dd hh:mm:ss";
if (EXIF_ENABLE && $file_src = get_file_path($image_row['image_media_file'], "media", $image_row['cat_id'], 1))
{
echo get_exif_insert_link($file_src, "DateTimeOriginal", "qe_image_date[$i]", 0, "<br />");
echo get_exif_insert_link($file_src, "DateTimeDigitized", "image_date", 0, "<br />");
echo get_exif_insert_link($file_src, "DateTime", "image_date", 0, "<br />");
}
}
else
{
echo format_date($config['date_format'] . " " . $config['time_format'], $image_row['image_date']);
}
echo "</td>\n";
echo "<td><p>";
$site_sess->set_session_var('back_url', ROOT_PATH."admin/images.php?action=modifyimages");
show_text_link($lang['edit'],"images.php?action=editimage&".URL_IMAGE_ID."=".$image_row['image_id'], $target);
show_text_link($lang['delete'],"images.php?action=removeimage&".URL_IMAGE_ID."=".$image_row['image_id'], $target);
echo "</p></td>\n";
echo "</tr>\n";
$i++;
}
show_hidden_input("image_id_type", $image_id_type);
show_hidden_input("image_name_type", $image_name_type);
show_hidden_input("image_description_type", $image_description_type);
show_hidden_input("image_keywords_type", $image_keywords_type);
show_hidden_input("user_id_type", $user_id_type);
show_hidden_input("user_name_type", $user_name_type);
show_hidden_input("image_media_file_type", $image_media_file_type);
show_hidden_input("image_thumb_file_type", $image_thumb_file_type);
show_hidden_input("cat_id_type", $cat_id_type);
show_hidden_input("image_id", $image_id);
show_hidden_input("image_name", $image_name, 1);
show_hidden_input("user_id", $user_id);
show_hidden_input("user_name", $user_name, 1);
show_hidden_input("image_active", $image_active, 1);
show_hidden_input("image_description", $image_description, 1);
show_hidden_input("image_keywords", $image_keywords, 1);
show_hidden_input("cat_id", $cat_id);
show_hidden_input("subcat", $subcat);
show_hidden_input("image_media_file", $image_media_file, 1);
show_hidden_input("image_thumb_file", $image_thumb_file, 1);
show_hidden_input("dateafter", $dateafter);
show_hidden_input("datebefore", $datebefore);
show_hidden_input("downloadsupper", $downloadsupper);
show_hidden_input("downloadslower", $downloadslower);
show_hidden_input("ratingupper", $ratingupper);
show_hidden_input("ratinglower", $ratinglower);
show_hidden_input("votesupper", $votesupper);
show_hidden_input("voteslower", $voteslower);
show_hidden_input("hitsupper", $hitsupper);
show_hidden_input("hitslower", $hitslower);
show_hidden_input("orderby", $orderby, 1);
show_hidden_input("direction", $direction, 1);
show_hidden_input("limitstart", $limitstart);
show_hidden_input("limitnumber", $limitnumber);
show_hidden_input("preset", safe_htmlspecialchars($preset));
foreach($quickedit as $val)
{
show_hidden_input("quickedit[]", $val);
}
show_hidden_input("date", 0); //checkboxes value not sent at all if its unchecked.
show_hidden_input("nextpage", 0); //checkboxes value not sent at all if its unchecked.
foreach ($fields as $key => $val)
{
show_hidden_input($key, $val, 1);
}
echo "<tr class=\"tablefooter\">\n<td colspan=\"10\" align=\"left\" class=\"tableseparator\">\n ";
if (!empty($quickedit))
{
echo "<input type=\"submit\" value=\" ".$lang['save']." \" class=\"button\" name=\"action2\"> \n";
if ($limitnumber != 5000 && $limitfinish < $countimages['images'])
{
echo "<label for=\"nextpage\"><input type=\"checkbox\" value=\"1\" class=\"button\" id=\"nextpage\" name=\"nextpage\"".((($nextpage && $nextpage != 2) || ($nextpage == 2 && $nextpage_default)) ? " checked" : "")."> " . $lang['continue_next_page'] . "</label>\n";
}
}
else
{
echo "<input type=\"submit\" value=\" ".$lang['edit']." \" class=\"button\" name=\"action2\">\n";
echo "<input type=\"submit\" value=\" ".$lang['delete']." \" class=\"button\">\n";
$category = "\n<select name=\"new_cat_id\" class=\"categoryselect\">\n";
$category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
$category .= "<option value=\"0\">-------------------------------</option>\n";
$drop_down_cat_cache = array();
$drop_down_cat_cache = $cat_parent_cache;
$category .= get_category_dropdown_bits($new_cat_id);
$category .= "</select>\n";
echo "<hr />";
echo $category;
echo "<label for=\"date\" title=\"".$lang['save_date_exp']."\"><input type=\"checkbox\" name=\"date\" value=\"1\" id=\"date\" ".(($date) ? " checked" : "")."/> " . $lang['save_date'] . "</label>";
echo " <input type=\"submit\" value=\" ".$lang['move']." \" class=\"button\" name=\"action2\">\n";
echo "<input type=\"submit\" value=\" ".$lang['copy']." \" class=\"button\" name=\"action2\">\n";
echo "<hr />";
if (function_exists("get_user_id_by_name"))
{
// unset($HTTP_POST_VARS["owner"]);
show_user_select_row("", $owner, "", 30, "owner", 0, 0, 0);
}
else
{
if (empty($user_select_row_cache))
{
$sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_id")." <> ".GUEST."
ORDER BY ".get_user_table_field("", "user_name")." ASC";
$result = $site_db->query($sql);
$user_select_row_cache = array();
while ($row = $site_db->fetch_array($result))
{
$user_select_row_cache[$row[$user_table_fields['user_id']]] = $row[$user_table_fields['user_name']];
}
}
// echo " | ";
echo "<select name=\"owner\" class=\"categoryselect\">\n";
echo "<option value=\"".GUEST."\">".$lang['userlevel_guest']."</option>\n";
echo "<option value=\"".GUEST."\">-------------------------------</option>\n";
foreach ($user_select_row_cache as $key => $val)
{
echo "<option value=\"".$key."\"";
if (($owner && $key == $owner) || (!$owner && $key == $user_info['user_id']))
{
echo " selected=\"selected\"";
}
echo ">".$val."</option>\n";
}
echo "</select>\n";
}
echo " <input type=\"submit\" value=\"".$lang['changeowner']."\" class=\"button\" name=\"action2\">\n";
}
echo " \n</td>\n";
echo "</tr>\n</table>\n</td>\n</tr>\n</table>\n";
echo "</form>\n";
}
else
{
show_description_row($lang['no_search_results'], 6);
show_form_footer("", "");
}
echo "<div align=\"right\">";
echo "<form action=\"".$site_sess->url("images.php")."\" name=\"form2\" method=\"post\">\n";
show_hidden_input("image_id_type", $image_id_type);
show_hidden_input("image_name_type", $image_name_type);
show_hidden_input("image_description_type", $image_description_type);
show_hidden_input("image_keywords_type", $image_keywords_type);
show_hidden_input("user_id_type", $user_id_type);
show_hidden_input("user_name_type", $user_name_type);
show_hidden_input("image_media_file_type", $image_media_file_type);
show_hidden_input("image_thumb_file_type", $image_thumb_file_type);
show_hidden_input("cat_id_type", $cat_id_type);
show_hidden_input("action", "findimages");
show_hidden_input("image_id", ($image_id !== 0 ? $image_id : ""));
show_hidden_input("image_name", $image_name, 1);
show_hidden_input("user_id", ($user_id !== 0 ? $user_id : ""));
show_hidden_input("user_name", $user_name, 1);
show_hidden_input("image_active", $image_active, 1);
show_hidden_input("image_description", $image_description, 1);
show_hidden_input("image_keywords", $image_keywords, 1);
show_hidden_input("cat_id", $cat_id);
show_hidden_input("subcat", $subcat);
show_hidden_input("image_media_file", $image_media_file, 1);
show_hidden_input("image_thumb_file", $image_thumb_file, 1);
show_hidden_input("dateafter", $dateafter);
show_hidden_input("datebefore", $datebefore);
show_hidden_input("downloadsupper", $downloadsupper);
show_hidden_input("downloadslower", $downloadslower);
show_hidden_input("ratingupper", $ratingupper);
show_hidden_input("ratinglower", $ratinglower);
show_hidden_input("votesupper", $votesupper);
show_hidden_input("voteslower", $voteslower);
show_hidden_input("hitsupper", $hitsupper);
show_hidden_input("hitslower", $hitslower);
show_hidden_input("orderby", $orderby, 1);
show_hidden_input("direction", $direction, 1);
show_hidden_input("limitstart", $limitstart + $limitnumber);
show_hidden_input("limitnumber", $limitnumber);
show_hidden_input("owner", $owner);
show_hidden_input("preset", safe_htmlspecialchars($preset));
foreach($quickedit as $val)
{
show_hidden_input("quickedit[]", $val, 1);
}
show_hidden_input("nextpage", $nextpage);
show_hidden_input("nextpageabort", 1);
show_hidden_input("date", $date); //checkboxes value not sent at all if its unchecked.
foreach ($fields as $key => $val)
{
show_hidden_input($key, $val, 1);
}
if ($limitnumber != 5000 && $limitfinish < $countimages['images'])
{
echo "<input type=\"submit\" value=\" ".$lang['search_next_page']." \" class=\"button\">\n";
}
echo "<input type=\"submit\" value=\" ".$lang['back']." \" onclick=\"".(($limitstart) ? "limitstart.value = '".($limitstart - $limitnumber)."'" : "action.value = ''")."\" class=\"button\">\n";
echo "</form>";
echo "</div>";
}
show_admin_footer();
?>
und die details.php
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: details.php *
* Copyright: (C) 2002-2015 4homepages.de *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.12 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$main_template = 'details';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('MAIN_SCRIPT', __FILE__);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
if (!$image_id) {
redirect($url);
}
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", i.".$key;
}
}
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").", c.multi_download FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_id = $image_id AND i.image_active = 1 AND c.cat_id = i.cat_id";
$image_row = $site_db->query_firstrow($sql);
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
$is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 1 : 0;
// MOD multi download
$multi_download = $image_row['multi_download'];
if($multi_download){
if(!strpos(",jpg,jpeg,JPG,JPEG,png,gif",pathinfo($image_row['image_media_file'], PATHINFO_EXTENSION))){
$multi_download=0;
}
}
// END MOD multi download
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
redirect($url);
}
$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image($cat_id);
$site_template->register_vars("random_cat_image", $random_cat_image);
unset($random_cat_image);
//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------
$image_allow_comments = (check_permission("auth_readcomment", $cat_id)) ? $image_row['image_allow_comments'] : 0;
$image_name = format_text($image_row['image_name'], 2);
show_image($image_row, $mode, 0, 1);
//--- SEO variables -------------------------------
//$meta_keywords = !empty($image_row['image_keywords']) ? implode(", ", explode(",", $image_row['image_keywords'])) : "";
//$meta_description = !empty($image_row['image_description']) ? strip_tags($image_row['image_description']) . ". " : "";
$meta_keywords = !empty($image_row['image_keywords']) ? strip_tags(implode(", ", explode(",", $image_row['image_keywords']))) : "";
$meta_description = !empty($image_row['image_description']) ? strip_tags($image_row['image_description']) . ". " : "";
$site_template->register_vars(array(
"detail_meta_description" => addslashes($meta_description),
"detail_meta_keywords" => addslashes($meta_keywords),
"prepend_head_title" => $image_name . ",",
));
$in_mode = 0;
$sql = "";
if ($mode == "lightbox") {
if (!empty($user_info['lightbox_image_ids'])) {
$image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
$in_mode = 1;
}
}
elseif ($mode == "search") {
if (!isset($session_info['searchid']) || empty($session_info['searchid'])) {
$session_info['search_id'] = $site_sess->get_session_var("search_id");
}
if (!empty($session_info['search_id'])) {
$search_id = unserialize($session_info['search_id']);
}
$sql_where_query = "";
if (!empty($search_id['image_ids'])) {
$sql_where_query .= "AND image_id IN (".$search_id['image_ids'].") ";
}
if (!empty($search_id['user_ids'])) {
$sql_where_query .= "AND user_id IN (".$search_id['user_ids'].") ";
}
if (!empty($search_id['search_new_images']) && $search_id['search_new_images'] == 1) {
$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
$sql_where_query .= "AND image_date >= $new_cutoff ";
}
if (!empty($search_id['search_cat']) && $search_id['search_cat'] != 0) {
$cat_id_sql = 0;
if (check_permission("auth_viewcat", $search_id['search_cat'])) {
$sub_cat_ids = get_subcat_ids($search_id['search_cat'], $search_id['search_cat'], $cat_parent_cache);
$cat_id_sql .= ", ".$search_id['search_cat'];
if (!empty($sub_cat_ids[$search_id['search_cat']])) {
foreach ($sub_cat_ids[$search_id['search_cat']] as $val) {
if (check_permission("auth_viewcat", $val)) {
$cat_id_sql .= ", ".$val;
}
}
}
}
$cat_id_sql = $cat_id_sql !== 0 ? "AND cat_id IN ($cat_id_sql)" : "";
}
else {
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$cat_id_sql = $cat_id_sql !== 0 ? "AND cat_id NOT IN (".$cat_id_sql.")" : "";
}
if (!empty($sql_where_query)) {
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1
$sql_where_query
$cat_id_sql
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
$in_mode = 1;
}
}
if (!$in_mode || empty($sql)) {
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id = $cat_id
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
}
$result = $site_db->query($sql);
$image_id_cache = array();
$next_prev_cache = array();
$break = 0;
$prev_id = 0;
while($row = $site_db->fetch_array($result)) {
$image_id_cache[] = $row['image_id'];
$next_prev_cache[$row['image_id']] = $row;
if ($break) {
break;
}
if ($prev_id == $image_id) {
$break = 1;
}
$prev_id = $row['image_id'];
}
$site_db->free_result();
if (!function_exists("array_search")) {
function array_search($needle, $haystack) {
$match = false;
foreach ($haystack as $key => $value) {
if ($value == $needle) {
$match = $key;
}
}
return $match;
}
}
$act_key = array_search($image_id, $image_id_cache);
$next_image_id = (isset($image_id_cache[$act_key + 1])) ? $image_id_cache[$act_key + 1] : 0;
$prev_image_id = (isset($image_id_cache[$act_key - 1])) ? $image_id_cache[$act_key - 1] : 0;
unset($image_id_cache);
// Get next and previous image
if (!empty($next_prev_cache[$next_image_id])) {
$next_image_name = format_text($next_prev_cache[$next_image_id]['image_name'], 2);
$next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
if (!get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
$next_image_file = ICON_PATH."/404.gif";
}
else {
$next_image_file = get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
}
if (!get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
$next_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$next_image_id]['image_media_file']).".gif";
}
else {
$next_thumb_file = get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
}
}
else {
$next_image_name = REPLACE_EMPTY;
$next_image_url = REPLACE_EMPTY;
$next_image_file = REPLACE_EMPTY;
$next_thumb_file = REPLACE_EMPTY;
}
if (!empty($next_prev_cache[$prev_image_id])) {
$prev_image_name = format_text($next_prev_cache[$prev_image_id]['image_name'], 2);
$prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
if (!get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
$prev_image_file = ICON_PATH."/404.gif";
}
else {
$prev_image_file = get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
}
if (!get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
$prev_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$prev_image_id]['image_media_file']).".gif";
}
else {
$prev_thumb_file = get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
}
}
else {
$prev_image_name = REPLACE_EMPTY;
$prev_image_url = REPLACE_EMPTY;
$prev_image_file = REPLACE_EMPTY;
$prev_thumb_file = REPLACE_EMPTY;
}
$site_template->register_vars(array(
"next_image_id" => $next_image_id,
"next_image_name" => $next_image_name,
"next_image_url" => $next_image_url,
"next_image_file" => $next_image_file,
"next_thumb_file" => $next_thumb_file,
"prev_image_id" => $prev_image_id,
"prev_image_name" => $prev_image_name,
"prev_image_url" => $prev_image_url,
"prev_image_file" => $prev_image_file,
"prev_thumb_file" => $prev_thumb_file
));
unset($next_prev_cache);
//##################################### Start MOD: Photo Preview Hack ###################################
$total = "5"; // always an odd number e.g. 5,7,9,11... e.t.c
$center = 0; // for table-width 100% set 0;
$result = $site_db->query($sql);
while($row = $site_db->fetch_array($result)){
$image_preview[] = $row['image_id'];
$preview_row[$row['image_id']] = $row;
}
$lastPage = count($image_preview);
if ($center == 1){
$t_template = "<table align=\"center\" width=\"10%;\">\n";
}
else{
$t_template = "<table width=\"100%;\">\n";
}
$t_template .= "<tr>";
if($lastPage < ($total + 1)){
$start = 0;
$end = $lastPage -1;
}
elseif ($act_key <= (($total-1)/2 -1)){
$start = 0;
$end = ($total - 1);
}
elseif ($act_key >= $lastPage - (($total-1)/2)){
$start = $lastPage - $total;
$end = $lastPage - 1;
}
else {
$start = $act_key - ($total-1)/2;
$end = $act_key + ($total-1)/2;
}
for($i=$start; $i<=$end; $i++){
if ($preview_row[$image_preview[$i]]['image_id'] == $image_row['image_id']) {
$t_template .= "<td class=\"minirow1\">\n";
}
else {
$t_template .= "<td class=\"minirow2\">\n";
}
$t_template .= get_thumbnail_small_code($preview_row[$image_preview[$i]]['image_media_file'], $preview_row[$image_preview[$i]]['image_thumb_file'], $preview_row[$image_preview[$i]]['image_id'], $preview_row[$image_preview[$i]]['cat_id'], format_text(trim($preview_row[$image_preview[$i]]['image_name']), 2), $mode, 1);
$t_template .= "</td>";
}
$t_template .= "</tr>";
$t_template .= "</table><br>\n";
$site_template->register_vars("preview_box", $t_template);
unset($image_preview);
//######################################## End MOD: Photo Preview Hack #######################################
//-----------------------------------------------------
//--- Save Comment ------------------------------------
//-----------------------------------------------------
$error = 0;
if ($action == "postcomment" && isset($HTTP_POST_VARS[URL_ID])) {
$id = intval($HTTP_POST_VARS[URL_ID]);
$sql = "SELECT cat_id, image_allow_comments
FROM ".IMAGES_TABLE."
WHERE image_id = $id";
$row = $site_db->query_firstrow($sql);
if ($row['image_allow_comments'] == 0 || !check_permission("auth_postcomment", $row['cat_id']) || !$row) {
$msg = $lang['comments_deactivated'];
}
else {
$user_name = un_htmlspecialchars(trim($HTTP_POST_VARS['user_name']));
$comment_headline = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_headline']));
$comment_text = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";
//###################### captcha mathematics start #######################
$result = (isset($_POST['result'])) ? intval(trim($_POST['result'])):"";
//###################### captcha mathematics end #######################
// Flood Check
$sql = "SELECT comment_ip, comment_date
FROM ".COMMENTS_TABLE."
WHERE image_id = $id
ORDER BY comment_date DESC
LIMIT 1";
$spam_row = $site_db->query_firstrow($sql);
$spamtime = $spam_row['comment_date'] + 180;
if ($session_info['session_ip'] == $spam_row['comment_ip'] && time() <= $spamtime && $user_info['user_level'] != ADMIN) {
$msg .= (($msg != "") ? "<br />" : "").$lang['spamming'];
$error = 1;
}
$user_name_field = get_user_table_field("", "user_name");
if (!empty($user_name_field)) {
if ($site_db->not_empty("SELECT $user_name_field FROM ".USERS_TABLE." WHERE $user_name_field = '".strtolower($user_name)."' AND ".get_user_table_field("", "user_id")." <> '".$user_info['user_id']."'")) {
$msg .= (($msg != "") ? "<br />" : "").$lang['username_exists'];
$error = 1;
}
}
if ($user_name == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['name_required'];
$error = 1;
}
if ($comment_headline == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['headline_required'];
$error = 1;
}
if ($comment_text == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
$error = 1;
}
if ($captcha_enable_comments && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
//###################### captcha mathematics start #######################
if ($captcha_enable_comments && $captcha_calculation && !captcha_validate_sum($result)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_result'];
$error = 1;
}
//###################### captcha mathematics end #######################
if (!$error) {
$sql = "INSERT INTO ".COMMENTS_TABLE."
(image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
VALUES
($id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().")";
$site_db->query($sql);
$commentid = $site_db->get_insert_id();
update_comment_count($id, $user_info['user_id']);
$msg = $lang['comment_success'];
$site_sess->set_session_var("msgdetails", $msg);
redirect(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id.((!empty($mode)) ? "&mode=".$mode : "").(($page > 1) ? "&page=".$page : ""));
}
}
unset($row);
unset($spam_row);
}
//-----------------------------------------------------
//--- Show Comments -----------------------------------
//-----------------------------------------------------
if ($msgdetails = $site_sess->get_session_var("msgdetails"))
{
$msg .= ($msg !== "" ? "<br />" : "").$msgdetails;
unset($msgdetails);
$site_sess->drop_session_var("msgdetails");
}
if ($image_allow_comments == 1) {
$site_template->register_vars(array(
"has_rss" => true,
"rss_title" => "RSS Feed: ".$image_name." (".str_replace(':', '', $lang['comments']).")",
"rss_url" => $script_url."/rss.php?action=comments&".URL_IMAGE_ID."=".$image_id
));
$sql = "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_ip, c.comment_date".get_user_table_field(", u.", "user_level").get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").get_user_table_field(", u.", "user_showemail").get_user_table_field(", u.", "user_invisible").get_user_table_field(", u.", "user_joindate").get_user_table_field(", u.", "user_lastaction").get_user_table_field(", u.", "user_comments").get_user_table_field(", u.", "user_homepage").get_user_table_field(", u.", "user_icq")."
FROM ".COMMENTS_TABLE." c
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.image_id = $image_id
ORDER BY c.comment_date ASC";
$result = $site_db->query($sql);
$comment_row = array();
while ($row = $site_db->fetch_array($result)) {
$comment_row[] = $row;
}
$site_db->free_result($result);
$num_comments = sizeof($comment_row);
if (!$num_comments) {
$comments = "<tr><td class=\"commentrow1\" colspan=\"2\">".$lang['no_comments']."</td></tr>";
}
else {
$comments = "";
$bgcounter = 0;
for ($i = 0; $i < $num_comments; $i++) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$comment_user_email = "";
$comment_user_email_save = "";
$comment_user_mailform_link = "";
$comment_user_email_button = "";
$comment_user_homepage_button = "";
$comment_user_icq_button = "";
$comment_user_profile_button = "";
$comment_user_status_img = REPLACE_EMPTY;
$comment_user_name = format_text($comment_row[$i]['comment_user_name'], 2);
$comment_user_info = $lang['userlevel_guest'];
$comment_user_id = $comment_row[$i]['user_id'];
if (isset($comment_row[$i][$user_table_fields['user_name']]) && $comment_user_id != GUEST) {
$comment_user_name = format_text($comment_row[$i][$user_table_fields['user_name']], 2);
$comment_user_profile_link = !empty($url_show_profile) ? $site_sess->url(preg_replace("/{user_id}/", $comment_user_id, $url_show_profile)) : $site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$comment_user_id);
$comment_user_profile_button = "<a href=\"".$comment_user_profile_link."\"><img src=\"".get_gallery_image("profile.gif")."\" border=\"0\" alt=\"".$comment_user_name."\" /></a>";
$comment_user_status_img = ($comment_row[$i][$user_table_fields['user_lastaction']] >= (time() - 300) && ((isset($comment_row[$i][$user_table_fields['user_invisible']]) && $comment_row[$i][$user_table_fields['user_invisible']] == 0) || $user_info['user_level'] == ADMIN)) ? "<img src=\"".get_gallery_image("user_online.gif")."\" border=\"0\" alt=\"Online\" />" : "<img src=\"".get_gallery_image("user_offline.gif")."\" border=\"0\" alt=\"Offline\" />";
$comment_user_homepage = (isset($comment_row[$i][$user_table_fields['user_homepage']])) ? format_url($comment_row[$i][$user_table_fields['user_homepage']]) : "";
if (!empty($comment_user_homepage)) {
$comment_user_homepage_button = "<a href=\"".$comment_user_homepage."\" target=\"_blank\"><img src=\"".get_gallery_image("homepage.gif")."\" border=\"0\" alt=\"".$comment_user_homepage."\" /></a>";
}
$comment_user_icq = (isset($comment_row[$i][$user_table_fields['user_icq']])) ? format_text($comment_row[$i][$user_table_fields['user_icq']]) : "";
if (!empty($comment_user_icq)) {
$comment_user_icq_button = "<a href=\"http://www.icq.com/people/about_me.php?uin=".$comment_user_icq."\" target=\"_blank\"><img src=\"http://status.icq.com/online.gif?icq=".$comment_user_icq."&img=5\" width=\"18\" height=\"18\" border=\"0\" alt=\"".$comment_user_icq."\" /></a>";
}
if (!empty($comment_row[$i][$user_table_fields['user_email']]) && (!isset($comment_row[$i][$user_table_fields['user_showemail']]) || (isset($comment_row[$i][$user_table_fields['user_showemail']]) && $comment_row[$i][$user_table_fields['user_showemail']] == 1))) {
$comment_user_email = format_text($comment_row[$i][$user_table_fields['user_email']]);
$comment_user_email_save = format_text(str_replace("@", " at ", $comment_row[$i][$user_table_fields['user_email']]));
if (!empty($url_mailform)) {
$comment_user_mailform_link = $site_sess->url(preg_replace("/{user_id}/", $comment_user_id, $url_mailform));
}
else {
$comment_user_mailform_link = $site_sess->url(ROOT_PATH."member.php?action=mailform&".URL_USER_ID."=".$comment_user_id);
}
$comment_user_email_button = "<a href=\"".$comment_user_mailform_link."\"><img src=\"".get_gallery_image("email.gif")."\" border=\"0\" alt=\"".$comment_user_email_save."\" /></a>";
}
if (!isset($comment_row[$i][$user_table_fields['user_level']]) || (isset($comment_row[$i][$user_table_fields['user_level']]) && $comment_row[$i][$user_table_fields['user_level']] == USER)) {
$comment_user_info = $lang['userlevel_user'];
}
elseif ($comment_row[$i][$user_table_fields['user_level']] == ADMIN) {
$comment_user_info = $lang['userlevel_admin'];
}
$comment_user_info .= "<br />";
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_joindate']])) ? "<br />".$lang['join_date']." ".format_date($config['date_format'], $comment_row[$i][$user_table_fields['user_joindate']]) : "";
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_comments']])) ? "<br />".$lang['comments']." ".$comment_row[$i][$user_table_fields['user_comments']] : "";
}
$comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";
$admin_links = "";
if ($user_info['user_level'] == ADMIN) {
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=editcomment&comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['edit']."</a> ";
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=removecomment&comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['delete']."</a>";
}
elseif ($is_image_owner) {
$admin_links .= ($config['user_edit_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
}
$site_template->register_vars(array(
"comment_id" => $comment_row[$i]['comment_id'],
"comment_user_id" => $comment_user_id,
"comment_user_status_img" => $comment_user_status_img,
"comment_user_name" => $comment_user_name,
"comment_user_info" => $comment_user_info,
"comment_user_profile_button" => $comment_user_profile_button,
"comment_user_email" => $comment_user_email,
"comment_user_email_save" => $comment_user_email_save,
"comment_user_mailform_link" => $comment_user_mailform_link,
"comment_user_email_button" => $comment_user_email_button,
"comment_user_homepage_button" => $comment_user_homepage_button,
"comment_user_icq_button" => $comment_user_icq_button,
"comment_user_ip" => $comment_user_ip,
"comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
"comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),
"row_bg_number" => $row_bg_number,
"admin_links" => $admin_links
));
$comments .= $site_template->parse_template("comment_bit");
} // end while
} //end else
$site_template->register_vars("comments", $comments);
unset($comments);
//-----------------------------------------------------
//--- BBCode & Form -----------------------------------
//-----------------------------------------------------
$allow_posting = check_permission("auth_postcomment", $cat_id);
$bbcode = "";
if ($config['bb_comments'] == 1 && $allow_posting) {
$site_template->register_vars(array(
"lang_bbcode" => $lang['bbcode'],
"lang_tag_prompt" => $lang['tag_prompt'],
"lang_link_text_prompt" => $lang['link_text_prompt'],
"lang_link_url_prompt" => $lang['link_url_prompt'],
"lang_link_email_prompt" => $lang['link_email_prompt'],
"lang_list_type_prompt" => $lang['list_type_prompt'],
"lang_list_item_prompt" => $lang['list_item_prompt']
));
$bbcode = $site_template->parse_template("bbcode");
}
if (!$allow_posting) {
$comment_form = "";
}
else {
$user_name = (isset($HTTP_POST_VARS['user_name']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['user_name'])), 2) : (($user_info['user_level'] != GUEST) ? format_text($user_info['user_name'], 2) : "");
$comment_headline = (isset($HTTP_POST_VARS['comment_headline']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_headline'])), 2) : "";
$comment_text = (isset($HTTP_POST_VARS['comment_text']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_text'])), 2) : "";
$site_template->register_vars(array(
"bbcode" => $bbcode,
"user_name" => $user_name,
"comment_headline" => $comment_headline,
"comment_text" => $comment_text,
"lang_post_comment" => $lang['post_comment'],
"lang_name" => $lang['name'],
"lang_headline" => $lang['headline'],
"lang_comment" => $lang['comment'],
"lang_captcha" => $lang['captcha'],
// "lang_captcha_desc" => $lang['captcha_desc'],
//###################### captcha mathematics start #######################
"captcha_calculation" => (bool)$captcha_calculation,
"lang_captcha_desc" => ($captcha_calculation) ? $lang['captcha_desc_result'] : $lang['captcha_desc'],
//###################### captcha mathematics end #########################
"captcha_comments" => (bool)$captcha_enable_comments
));
$comment_form = $site_template->parse_template("comment_form");
}
$site_template->register_vars("comment_form", $comment_form);
unset($comment_form);
} // end if allow_comments
// Admin Links
$admin_links = "";
if ($user_info['user_level'] == ADMIN) {
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&image_id=".$image_id))."\" target=\"_blank\">".$lang['edit']."</a> ";
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&image_id=".$image_id))."\" target=\"_blank\">".$lang['delete']."</a>";
}
elseif ($is_image_owner) {
$admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['delete']."</a>";
}
$site_template->register_vars("admin_links", $admin_links);
// Update Hits
if ($user_info['user_level'] != ADMIN) {
$sql = "UPDATE ".IMAGES_TABLE."
SET image_hits = image_hits + 1
WHERE image_id = $image_id";
$site_db->query($sql);
}
//MOD multi download
if (!$multi_download){
$site_template->register_vars("yes_multi_download", 0);
$site_template->register_vars("not_multi_download", 1);
}
else{
$site_template->register_vars("yes_multi_download", 1);
$site_template->register_vars("not_multi_download", 0);
}
//END MOD multi download
//-----------------------------------------------------
//---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" && $in_mode) {
$page_url = "";
if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
if (!empty($regs[1]) && $regs[1] != 1) {
$page_url = "?".URL_PAGE."=".$regs[1];
}
}
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php".$page_url)."\" class=\"clickstream\">".$lang['lightbox']."</a>".$config['category_separator'];
}
elseif ($mode == "search" && $in_mode) {
$page_url = "";
if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
if (!empty($regs[1]) && $regs[1] != 1) {
$page_url = "&".URL_PAGE."=".$regs[1];
}
}
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."search.php?show_result=1".$page_url)."\" class=\"clickstream\">".$lang['search']."</a>".$config['category_separator'];
}
else {
$clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$clickstream .= $image_name."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
//$site_template->register_vars(array(
// "msg" => $msg,
$site_template->register_vars("no_adds", in_array($cat_id,explode(",",$config['cat_rand_pic']))? "":1);
//$search_array = explode(",",$config['cat_rand_pic']);
$site_template->register_vars(array(
//"no_adds" => ($cat_id == 395)|| ($cat_id == 499) || ($cat_id == 544) || ($cat_id == 359) || ($cat_id == 516) || ($cat_id == 508) || ($cat_id == 534) || ($cat_id == 504) || ($cat_id == 474) || ($cat_id == 491) || ($cat_id == 360) || ($cat_id == 142) || ($cat_id == 152) || ($cat_id == 153) || ($cat_id == 154) || ($cat_id == 340) || ($cat_id == 516) || ($cat_id == 421) ? "":1,
//"no_adds" => in_array($cat_id,$search_array)? "":1,
"msg" => $msg,
"clickstream" => $clickstream,
"lang_category" => $lang['category'],
"lang_added_by" => $lang['added_by'],
"lang_description" => $lang['description'],
"lang_keywords" => $lang['keywords'],
"lang_date" => $lang['date'],
"lang_hits" => $lang['hits'],
"lang_downloads" => $lang['downloads'],
"lang_rating" => $lang['rating'],
"lang_votes" => $lang['votes'],
"lang_author" => $lang['author'],
"lang_comment" => $lang['comment'],
"lang_prev_image" => $lang['prev_image'],
"lang_next_image" => $lang['next_image'],
"lang_file_size" => $lang['file_size']
));
//-----------------------------------------------------
//--- [MOD] Ajax Star Rating --------------by Bash-T---
//START------------------------------------------------
$site_template->register_vars(array(
"ajax_rating_labels_0" => $lang['ajax_rating_labels'][0],
"ajax_rating_labels_1" => $lang['ajax_rating_labels'][1],
"ajax_rating_labels_2" => $lang['ajax_rating_labels'][2],
"ajax_rating_labels_3" => $lang['ajax_rating_labels'][3],
"ajax_rating_labels_4" => $lang['ajax_rating_labels'][4],
"ajax_rating_labels_5" => $lang['ajax_rating_labels'][5],
"ajax_rating_messages_0" => $lang['ajax_rating_messages'][0],
"ajax_rating_messages_1" => $lang['ajax_rating_messages'][1],
"ajax_rating_messages_2" => $lang['ajax_rating_messages'][2],
"ajax_rating_messages_3" => $lang['ajax_rating_messages'][3],
"ajax_rating_points" => $lang['ajax_rating_points']
));
//-----------------------------------------------------
//--- [MOD] Ajax Star Rating --------------by Bash-T---
//--------------------------------------------------END
//-----------------------------------------------------
//--- ImageCodes v1.0 Begins --------------------------
//-----------------------------------------------------
// Mod: ImageCodes v1.0
// Version: 1.0
// Description : Get image path, link and bbcode on the details page
// Contact: arjoon@gmail.com
// Last update: June 30 2007
$sql = "SELECT image_media_file FROM ".IMAGES_TABLE." WHERE image_id= $image_id";
$image_codes = $site_db->query_firstrow($sql);
$new_name = $image_codes['image_media_file'];
$uploaded_image_path = $script_url."/".MEDIA_DIR."/".$cat_id."/".$new_name;
$uploaded_thumb_path = $script_url."/".THUMB_DIR."/".$cat_id."/".$new_name;
$uploaded_image_link = $script_url."/details.php?image_id=".$image_id;
$uploaded_thumb_hotlink = "<a href=\"".$uploaded_image_link."\"><img src=\"".$uploaded_thumb_path."\" border=\"0\" alt=\"".$new_name."\"></a>";
$uploaded_image_hotlink = "<a href=\"".$uploaded_image_link."\"><img src=\"".$uploaded_image_path."\" border=\"0\" alt=\"".$new_name."\"></a>";
$uploaded_image_bbcode = "[URL=".$script_url."][IMG]".$uploaded_image_path."[/IMG][/URL]";
$uploaded_thumb_bbcode = "[URL=".$uploaded_image_link."][IMG]".$uploaded_thumb_path."[/IMG][/URL]";
$uploadinfo .= "<font size='2' face='Tahoma'><b>Image Codes:</b><br />";
$uploadinfo .= "<input onclick='highlight(this);' style='border-style:solid; border-width:1; padding:2; width: 300px; background-color:#FFFFFF; color:#000000' size='70' value='".$uploaded_thumb_hotlink."' type='text' name='image'> Thumbnail for websites<br />";
$uploadinfo .= "<input onclick='highlight(this);' style='border-style:solid; border-width:1; padding:2; width: 300px; background-color:#FFFFFF; color:#000000' size='70' value='".$uploaded_thumb_bbcode."' type='text' name='image'> Thumbnail for forums<br /><br />";
$uploadinfo .= "<font size='1' face='Tahoma'>Use the below codes to post the full sized image on other websites or forums</font><br />";
$uploadinfo .= "<input onclick='highlight(this);' style='border-style:solid; border-width:1; padding:2; width: 300px; background-color:#FFFFFF; color:#000000' size='70' value='".$uploaded_image_hotlink."' type='text' name='image'> Hotlink for websites<br />";
$uploadinfo .= "<input onclick='highlight(this);' style='border-style:solid; border-width:1; padding:2; width: 300px; background-color:#FFFFFF; color:#000000' size='70' value='".$uploaded_image_bbcode."' type='text' name='image'> Hotlink for forums<br /><br />";
$uploadinfo .= "<font size='1' face='Tahoma'>Share this image with your friends</font><br />";
$uploadinfo .= "<input onclick='highlight(this);' style='border-style:solid; border-width:1; padding:2; width: 300px; background-color:#FFFFFF; color:#000000' size='70' value='".$uploaded_image_link."' type='text' name='image'> Share this image<br />";
$uploadinfo .= "<input onclick='highlight(this);' style='border-style:solid; border-width:1; padding:2; width: 300px; background-color:#FFFFFF; color:#000000' size='70' value='".$uploaded_image_path."' type='text' name='image'> Direct path to image<br /><br /></font>";
$icodes .= "<table border=\"0\" width=\"500px\" align=\"center\">\n<tr>\n<td>\n".$uploadinfo."\n</td>\n</tr>\n</table>\n";
$site_template->register_vars("image_codes", $icodes);
//-----------------------------------------------------
//--- end of ImageCodes v1.0 --------------------------
//-----------------------------------------------------
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>