Hi!
This is my Version...for 4images V.1.7.8 and higher.
New: Is the image larger than in "General / Settings / upload settings" is specified, it will be automatically resized.
for better quality, they make the point in "includes / constans.php":
define ('CONVERT_IS_GD2', 1);
New: if the field "image name" is empty, filename is "image name".
Bug Fix:Step 6.) Create Thumbnail from Animated Gifs;
1.) search in root/categories.php:
$upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
insert below:
$multi_upload_url = "";
$multi_upload_button = "<img src=\"".get_gallery_image("multiupload_off.gif")."\" border=\"0\" alt=\"\" />";1.2) search:
$upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
insert below:
$multi_upload_url = $site_sess->url(ROOT_PATH."member_multi_upload.php?action=multi_upload&".URL_CAT_ID."=".$cat_id);
$multi_upload_button = "<a href=\"".$multi_upload_url."\"><img src=\"".get_gallery_image("multiupload.gif")."\" border=\"0\" alt=\"\" /></a>";
1.3) search:
"upload_button" => $upload_button,
insert below:
"multi_upload_url" => $multi_upload_url,
"multi_upload_button" => $multi_upload_button,
2.) search in lang/your lang/ main.php:
//--- Image Upload ------------------------------------
//-----------------------------------------------------
insert below:
(deutsch)
$lang['num_addnewimages'] = "Wieviele neue Bilder wollen Sie hinzufügen: ";
$lang['image'] = "Bild";
insert below:
(english)
$lang['num_addnewimages'] = "How many pictures you want to add: ";
$lang['image'] = "Image";
3.) create a new file and call it "multi_upload_notify.html" and store in lang/your lang/email:
(deutsch)
Neue Bilder wurden auf "{site_name}" hinzugefügt und muessen freigeschaltet werden.
Kategorie: {cat_name}
Bildnamen: {image_name}
Dateien: {file_name}
{validation_url}
--
Mit freundlichen Grüßen,
{site_name}
(english)
New images has been uploaded to "{site_name}" and awaits validation.
Category: {cat_name}
Image Name: {image_name}
File: {file_name}
{validation_url}
--
Best regards,
{site_name}
4.) search in your template/categories.html
<td align="right" valign="bottom">{upload_button}</td>
replace:
<td align="right" valign="bottom">{multi_upload_button} {upload_button}</td>
5.) create a new file and call it "member_multi_uploadform.html" and store in template/your template:
<form method="post" action="member_multi_upload.php" enctype="multipart/form-data" onsubmit="uploadbutton.disabled=true;">
<input type="hidden" name="action" value="uploadimage" />
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td valign="top" class="head1">
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="head1">{lang_user_upload}</td>
</tr>
{num_new}
<tr>
<td class="row2"><b>{lang_category}</b></td>
<td class="row2">{cat_name}</td>
</tr>
{content}
{if captcha_upload}
<tr>
<td class="row1" valign="top"><b>{lang_captcha}</b></td>
<td class="row1">
<a href="javascript:new_captcha_image();"><img src="{url_captcha_image}" border="0" alt="" id="captcha_image" /></a> <br />
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />
<br />
<table cellpadding="0" cellspacing="0" width="210">
<tr>
<td width="594">{lang_captcha_desc}</td>
</tr>
</table>
</td>
</tr>
{endif captcha_upload}
</table>
</td>
</tr>
</table>
<p align="center">
<input type="hidden" name="num_newimages" value="{num_newimages}">
<input type="submit" name="uploadbutton" value="{lang_submit}" class="button" />
<input type="reset" value="{lang_reset}" class="button" />
</p>
</form>
6.) create a new file and call it "member_multi_upload.php" and store in your galerie root:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: member_multi_upload.php *
* Copyright: (C) 2002-2010 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.10 *
* Fileversion: 3.1.1 by Rembrandt (vienna-pictures.com) *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$main_template = "member";
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('MAIN_SCRIPT', __FILE__);
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
include_once(ROOT_PATH.'includes/upload.php');
$site_upload = new Upload();
include_once(ROOT_PATH.'includes/search_utils.php');
if ($action == "") {
$action = "multi_upload";
}
$content = "";
$txt_clickstream = "";
$sendprocess = 0;
if ($action == "uploadimage") {
if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
show_error_page($lang['no_permission']);
exit;
}
$txt_clickstream = "";
if ($cat_id && isset($cat_cache[$cat_id])) {
$txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$txt_clickstream .= $lang['user_upload'];
$num_newimages = intval($HTTP_POST_VARS['num_newimages']);
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";
$direct_upload = (check_permission("auth_directupload", $cat_id)) ? 1 : 0;
$upload_cat = ($direct_upload) ? $cat_id : 0;
$error = array();
$uploaderror = 0;
if ($cat_id == 0) {
$error['cat_id'.$i] = 1;
$field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required']);
$msg .= (($msg != "") ? "<br />" : "").$field_error;
}
for ($i = 1; $i <= $num_newimages; $i++) {
$image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name_'.$i]));
if ((empty($HTTP_POST_FILES['media_file_'.$i]['tmp_name']) || $HTTP_POST_FILES['media_file_'.$i]['tmp_name'] == "none") && ($remote_media_file == "" || !check_remote_media($remote_media_file))) {
$error['media_file_'.$i] = 1;
$msg .= (($msg != "") ? "<br />" : "").$lang['image']." ".$i." ".$lang['image_file_required'];
}
/* if ($image_name == "") {
$error['image_name_'.$i] = 1;
$field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
$msg .= (($msg != "") ? "<br />" : "").$lang['image']." ".$i." ".$field_error;
} */
/* 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;
$field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $val[0]), $lang['field_required']);
$msg .= (($msg != "") ? "<br />" : "").$lang['image']." ".$i." ".$field_error;
}
}
} */
}//end for
if ($captcha_enable_upload && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
if (!$error) {
for ($i = 1; $i <= $num_newimages; $i++){
$uploaderror = 0;
$image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name_'.$i]));
// Upload Media file
$new_name = "";
if (!empty($HTTP_POST_FILES['media_file_'.$i]['tmp_name']) && $HTTP_POST_FILES['media_file_'.$i]['tmp_name'] != "none") {
$new_name = $site_upload->upload_file("media_file_".$i, "media", $upload_cat);
if (!$new_name) {
$msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].":<br /> ".$i.".)".$new_name."</b>".$site_upload->get_upload_errors();
$uploaderror = 1;
}
}
else {
$new_name = $remote_media_file;
}
if(empty($image_name)){
$image_name = get_file_name($new_name);
}
// Upload thumb file
$new_thumb_name = "";
if (!empty($HTTP_POST_FILES['thumb_file_'.$i]['tmp_name']) && $HTTP_POST_FILES['thumb_file_'.$i]['tmp_name'] != "none" && !$uploaderror) {
$new_thumb_name = $site_upload->upload_file("thumb_file_".$i, "thumb", $upload_cat, get_basefile($new_name));
if (!$new_thumb_name) {
$msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].":<br /> ".$i.".)".$new_thumb_name."</b><br />".$site_upload->get_upload_errors();
@unlink(MEDIA_TEMP_PATH."/".$new_name);
$uploaderror = 1;
}
}
elseif (check_remote_thumb($remote_thumb_file)) {
$new_thumb_name = $remote_thumb_file;
}
elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file_'.$i]['tmp_name']) && $HTTP_POST_FILES['media_file_'.$i]['tmp_name'] != "none" && !$uploaderror) {
if ($direct_upload) {
$src = MEDIA_PATH."/".$cat_id."/".$new_name;
$dest = THUMB_PATH."/".$cat_id."/".$new_name;
}
else {
$src = MEDIA_TEMP_PATH."/".$new_name;
$dest = THUMB_TEMP_PATH."/".$new_name;
}
$do_create = 0;
if ($image_info = @getimagesize($src)) {
if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
$do_create = 1;
}
}
if ($do_create) {
require_once(ROOT_PATH.'includes/image_utils.php');
$convert_options = init_convert_options();
if (!$convert_options['convert_error']&& $image_info[2] == 2||$image_info[2] == 3){
$quality = 100;
if (!resize_image($src, $quality, $config['max_image_width'], 1, $config['max_image_height'])){
$msg .= (($msg != "") ? "<br>" : "")."<b>".$lang['file_upload_error'].": ".$new_name;
$uploaderror = 1;
}
}
if (!$convert_options['convert_error']) {
$dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
$resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
$quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;
if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
$new_thumb_name = $new_name;
}
}
}
}
if (!$uploaderror) {
// error_reporting(E_ALL);
$image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description_'.$i]));
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords_'.$i]));
$image_keywords = preg_replace("/[\n\r]/is", ",", $image_keywords);
$image_keywords_arr = explode(',', $image_keywords);
array_walk($image_keywords_arr, 'trim_value');
$image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));
/* $additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields)) {
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key.'_'.$i]) && isset($table_fields[$key])) {
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key.'_'.$i]))."'";
}
}
} */
$current_time = time();
if ($direct_upload) {
$sql = "INSERT INTO ".IMAGES_TABLE."
(cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file".$additional_field_sql.")
VALUES
($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name'".$additional_value_sql.")";
$result = $site_db->query($sql);
$image_id = $site_db->get_insert_id();
if ($result) {
$search_words = array();
foreach ($search_match_fields as $image_column => $match_column) {
if (isset($HTTP_POST_VARS[$image_column.'_'.$i])) {
$search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column.'_'.$i]);
if ($image_column == 'image_keywords') {
$search_words[$image_column] = explode(',', $search_words[$image_column]);
}
}
}
add_searchwords($image_id, $search_words);
}
}
else {
$sql = "INSERT INTO ".IMAGES_TEMP_TABLE."
(cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file".$additional_field_sql.")
VALUES
($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name'".$additional_value_sql.")";
$result = $site_db->query($sql);
}
$msg_success = "<b>".$i.".)</b> ".$lang['image_add_success'].":<br>";
$msg_success .= " ".$lang['image_name']." <b>".format_text(stripslashes($image_name))."</b> (".$new_name.")";
$msg_success .= (!$direct_upload) ? "<br> ".$lang['new_upload_validate_desc'] : "";
$file_extension = get_file_extension($new_name);
$file = (is_remote($new_name)) ? $new_name : (($direct_upload) ? THUMB_PATH."/".$cat_id."/".$new_name : THUMB_TEMP_PATH."/".$new_name);
$width_height = "";
if (!is_remote($file) && $imageinfo = @getimagesize($file)) {
$width_height = " ".$imageinfo[3];
}
$media_icon = "<img src=\"".ICON_PATH."/".$file_extension.".gif\" border=\"0\" alt=\"\" />";
$site_template->register_vars(array(
"media_src" => $file,
"media_icon" => $media_icon,
"image_name" => format_text(stripslashes($image_name)),
"width_height" => $width_height
));
$media = $site_template->parse_template("media/".$file_extension);
$content .= "<table border=\"0\">\n
<tr>\n
<td>".$msg_success."</td>\n
</tr>\n
<tr>\n
<td> ".$media."</td>\n
</tr>\n
</table>\n
<hr>
";
$site_template->register_vars("content", $content);
//for mail
$image_name_array[] = $image_name;
$new_name_array[] = $new_name;
}
else {
$action = "multi_upload";
$sendprocess = 1;
}
} //end for
if ($config['upload_notify'] == 1 && !$direct_upload ) {
$image_name_send = "";
$new_name_send = "";
$image_name_send = implode("\",\" ", $image_name_array);
$new_name_send = implode("\",\" ", $new_name_array);
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$config['upload_emails'] = str_replace(" ", "", $config['upload_emails']);
$emails = explode(",", $config['upload_emails']);
$validation_url = $script_url."/admin/index.php?goto=".urlencode("validateimages.php?action=validateimages");
$site_email->set_to($config['site_email']);
$site_email->set_subject($lang['new_upload_emailsubject']);
$site_email->register_vars(array(
"image_name" => stripslashes('"'.$image_name_send.'"'),
"file_name" => '"'.$new_name_send.'"',
"cat_name" => $cat_cache[$cat_id]['cat_name'],
"validation_url" => $validation_url,
"site_name" => $config['site_name']
));
$site_email->set_body("multi_upload_notify", $config['language_dir_default']);
$site_email->set_bcc($emails);
$site_email->send_email();
}
}
else {
$action = "multi_upload";
$sendprocess = 1;
}
}
if ($action == "multi_upload") {
if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
show_error_page($lang['no_permission']);
exit;
}
$txt_clickstream = "";
if ($cat_id && isset($cat_cache[$cat_id])) {
$txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$txt_clickstream .= $lang['user_upload'];
if (isset($HTTP_GET_VARS['num_newimages']) || isset($HTTP_POST_VARS['num_newimages'])) {
$num_newimages = (isset($HTTP_GET_VARS['num_newimages'])) ? intval($HTTP_GET_VARS['num_newimages']) : intval($HTTP_POST_VARS['num_newimages']);
}
else {
$num_newimages = 1;
}
if (!$sendprocess) {
$media_file = "";
$thumb_file = "";
$image_name = "";
$image_description = "";
$image_keywords = "";
}
$num_new = "";
$num_new .= "<tr>\n<td class=\"row1\"><b>".$lang['num_addnewimages']."</b></td>\n";
$num_new .= "<td class=\"row1\">";
$num_new .= "<select class=\"categoryselect\" name=\"num\" onChange=\"if(this.options[this.selectedIndex].value){window.location.href='".$site_sess->url("member_multi_upload.php?action=multi_upload")."&";
$num_new .= "num_newimages='+this.options[this.selectedIndex].value+'&cat_id=$cat_id'}\">\n";
for ($i = 1; $i <= 10; $i++) {
$num_new .= "<option value=\"$i\"";
if ($i == $num_newimages) {
$num_new .= " selected";
}
$num_new .= ">".$i."</option>\n";
}
$num_new .= "</select></td>\n</tr>\n";
$content = "";
for ($i = 1; $i <= $num_newimages; $i++) {
$media_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['media_file_'.$i])));
$thumb_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['thumb_file_'.$i])));
$image_name = un_htmlspecialchars(trim($HTTP_GET_VARS['image_name_'.$i]));
$image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description_'.$i]));
$image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords_'.$i]));
$image_keywords = preg_replace("/[\n\r]/is", ",", $image_keywords);
$image_keywords_arr = explode(',', $image_keywords);
array_walk($image_keywords_arr, 'trim_value');
$image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));
$content .= "
<tr>
<td class=\"head1\"><b>".$lang['image']." ".$i."</b></td><td></td>
</tr>
<tr>
<td class=\"row2\" valign=\"top\"><b>".$lang['media_file']."</b><br>
<span class=\"smalltext\">
".$lang['max_filesize']."<b>".$config['max_media_size']." ".$lang['kb']."</b><br>
".$lang['max_imagewidth']."<b>".$config['max_image_width']." ".$lang['px']."</b><br>
".$lang['max_imageheight']."<b>".$config['max_image_height']." ".$lang['px']."</b><br>
</span><br>
<span class=\"smalltext\" valign=\"bottom\"><b>".$lang['allowed_mediatypes_desc']."</b></span>
</td>
<td class=\"row2\"><b>Upload:</b><br>
<input type=\"file\" name=\"media_file_".$i."\" class=\"input\">
<br>
<!-- <b>URL:</b><br>
<input type=\"text\" name=\"remote_media_file_".$i."\" size=\"30\" value= \"".format_text(stripslashes($remote_media_file), 2)."\" class=\"input\" />
-->
<br>
<br>
<span class=\"smalltext\">".str_replace(",",", ",$config['allowed_mediatypes'])."</span>
</td>
</tr>
<tr>
<td class=\"row1\" valign=\"top\"><b>".$lang['thumb_file']."</b><br>
<span class=\"smalltext\">
".$lang['max_filesize']."<b>".$config['max_thumb_size']." ".$lang['kb']."</b><br>
".$lang['max_imagewidth']."<b>".$config['max_thumb_width']." ".$lang['px']."</b><br>
".$lang['max_imageheight']."<b>".$config['max_thumb_height']." ".$lang['px']."</b><br>
</span><br>
<span class=\"smalltext\" valign=\"bottom\"><b>".$lang['allowed_mediatypes_desc']."</b></span>
</td>
<td class=\"row1\"><b>Upload:</b><br>
<input type=\"file\" name=\"thumb_file_".$i."\" class=\"input\">
<br>
<!-- <b>URL:</b><br>
<input type=\"text\" name=\"remote_thumb_file_".$i."\" size=\"30\" value=\"".format_text(stripslashes($remote_thumb_file), 2)."\" class=\"input\" />
-->
<br>
<br>
<span class=\"smalltext\">jpg, gif, png</span>
</td>
</tr>
<tr>
<td class=\"row2\"><b>".$lang['image_name']."</b></td>
<td class=\"row2\"><input type=\"text\" name=\"image_name_".$i."\" size=\"30\" value=\"".format_text(stripslashes($image_name), 2)."\" class=\"input\" /></td>
</tr>
<tr>
<td class=\"row1\" valign=\"top\"><b>".$lang['description']."</b></td>
<td class=\"row1\">
<textarea name=\"image_description_".$i."\" cols=\"30\" class=\"textarea\" rows=\"5\">".$image_description."</textarea>
</td>
</tr>
<tr>
<td class=\"row2\" valign=\"top\"><b>".$lang['keywords_ext']."</b></td>
<td class=\"row2\">
<textarea cols=\"30\" class=\"textarea\" rows=\"5\" name=\"image_keywords_".$i."\">".$image_keywords."</textarea>
</td>
</tr>
";
}
$site_template->register_vars(array(
"content" => $content,
"num_new" => $num_new,
"num_newimages" => $num_newimages,
"lang_num_addnewimages" => $lang['num_addnewimages'],
"image_name" => format_text(stripslashes($image_name), 2),
"lang_user_upload" => $lang['user_upload'],
"cat_id" => $cat_id,
"cat_name" => get_category_dropdown($cat_id),
"lang_category" => $lang['category'],
"lang_submit" => $lang['submit'],
"lang_reset" => $lang['reset'],
"lang_captcha" => $lang['captcha'],
"lang_captcha_desc" => $lang['captcha_desc'],
"captcha_upload" => (bool)$captcha_enable_upload
));
$content = $site_template->parse_template("member_multi_uploadform");
}
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"content" => $content,
"msg" => $msg,
"clickstream" => $clickstream,
"lang_control_panel" => $lang['control_panel']
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
7.) search in includes/upload.php: (patch from @Vano
)
$this->max_height['media'] = $config['max_image_height'];
insert below:
$this->auto_image['media'] = 1;
7.1) search:
$this->image_size = @getimagesize($this->upload_file);
$ok = 1;
insert below:
if ($this->auto_image[$this->image_type]) {
return 1; //auto image is on, don't need check for anything else.
}
8.) copy the two file from the attachment in templates/your templates/images
mfg Andi