Hallo,
ich habe gerade einen Fehler bei meiner Bildergallerie gefunden, jedoch finde ich einfach nicht raus wo ich was ändern muss
.
Wenn ich aufs Bild gehe und dann auf edit -> index.php?goto=images.php?action=editimage...
Dann steht oben : NOTE: In case the thumbnail file name does not correspond with the image file name it will be adapted to the image file name.
Dann Edit images: XXXX
Image
und bei dem Link steht dann
www.domain.com/picgallerie/.data/media/793/XXXXXX.jpgebenfalls rechts kann das Bild nicht angezeigt werden weil die adresse
.data anstatt data hat.
Dieser Fehler tritt aber nur hier beim bearbeiten eines einzelnen Bildes auf.
auszug aus 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")
{