Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - rroc

Pages: [1]
1
Mods & Plugins (Releases & Support) / [MOD] multiupload
« on: June 22, 2005, 01:04:20 AM »
[MOD] MultiUpload
- This mod enables the users to add multiple files to a category at once.
- The images will get name and index, ie. "My pet", "My pet 2", "My pet 3",...
- for 4images 1.7.1

The best way to install this is to use the provided files, which give the changes compared to original installation of 4 images.

FILES
Files to be modified: (please take a backup copy of all of these!)
-categories.php  //settings
-categories.html  //To access the new action
-member.php //functionality (ie. looping the default upload method as long as required)

New files:
-member_multiuploadform.html //this is a simplified template for the multiupload
-two buttons... multiupload.gif, and multiupload_off.gif, I attached some as samples.

*NEW* I have included the clean versions of all these files to this post. They contain nothing more than the multiupload mod, it should be easy to integrate from there.


Recommended/required MODS
-auto thumbnailer and auto resizer MODs are highly recommended
-I also use my own EXIF reader and autorotate(according to the EXIF) MODs... these are yet to be released...


INSTALL
------------------------------------

I. SETTING THE VARIABLES

categories.php:

1.
AFTER:
Code: [Select]
$upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
ADD:
Code: [Select]
$multiupload_button = "<img src=\"".get_gallery_image("multiupload_off.gif")."\" border=\"0\" alt=\"MultiUpload images to this Gallery\" />";

2.
AFTER:
Code: [Select]
$upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
ADD:
Code: [Select]
$multiupload_url = $site_sess->url(ROOT_PATH."member.php?action=multiuploadform&amp;".URL_CAT_ID."=".$cat_id);
  $multiupload_button = "<a href=\"".$multiupload_url."\"><img src=\"".get_gallery_image("multiupload.gif")."\" border=\"0\" alt=\"Upload Multiple files\" /></a>";
 

3.
AFTER:
Code: [Select]
"upload_button" => $upload_button,
ADD:
Code: [Select]
"multiupload_button" => $multiupload_button,


categories.html
4.
REPLACE:
Code: [Select]
{upload_button}
BY:
Code: [Select]
{upload_button} {multiupload_button}





II. FUNCTIONALITY

member.php

1.
REPLACE:
Code: [Select]
if ($action == "uploadimage") {
BY:
Code: [Select]
if ($action == "uploadimage" || $action=="multiuploadimage") {


2.1
REPLACE:
Code: [Select]
if (!$error) {
    // Start Upload
    include(ROOT_PATH.'includes/upload.php');
    $site_upload = new Upload();

    // Upload Media file
    if (!empty($HTTP_POST_FILES['media_file']['tmp_name']) && $HTTP_POST_FILES['media_file']['tmp_name'] != "none") {
      $new_name = $site_upload->upload_file("media_file", "media", $upload_cat);
      if (!$new_name) {
        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name."</b><br />".$site_upload->get_upload_errors();
        $uploaderror = 1;
      }
    }
    else {
      $new_name = $remote_media_file;
    }
BY:
Code: [Select]
if (!$error) {
//MULTI FILE UPLOAD
$fileext="";
while(isset($HTTP_POST_FILES['media_file'.$fileext]))
{
include_once(ROOT_PATH.'includes/upload.php');
    $site_upload = new Upload();

    // Upload Media file
    if (!empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none") {
      $new_name = $site_upload->upload_file('media_file'.$fileext, "media", $upload_cat);
      if (!$new_name) {
        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name."</b><br />".$site_upload->get_upload_errors();
        $uploaderror = 1;
      }
    }
    elseif($action=="uploadimage") {
      $new_name = $remote_media_file;
    }
    else
    {
    $new_name = "";
    break;
    }


2.2  * new *
REPLACE:
Code: [Select]
elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file']['tmp_name']) && $HTTP_POST_FILES['media_file']['tmp_name'] != "none" && !$uploaderror) {
BY:
Code: [Select]
elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {


3.1 (NOW START REPLACING ALL THE includes and requires INSIDE THIS ACTION by include_once and require_once)
REPLACE:
Code: [Select]
require(ROOT_PATH.'includes/image_utils.php');
BY:
Code: [Select]
require_once(ROOT_PATH.'includes/image_utils.php');


3.2 do this to change the image names to have index
REPLACE:
Code: [Select]
if ($direct_upload) {
        $sql = "INSERT INTO ".IMAGES_TABLE."
                (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments".$additional_field_sql.")
                VALUES
                ($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";

BY:
Code: [Select]
$imgname = ($fileext!="")?"$image_name $fileext":$image_name;
  if ($direct_upload) {
$sql = "INSERT INTO ".IMAGES_TABLE."
(cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments".$additional_field_sql.")
VALUES
($cat_id, ".$user_info['user_id'].", '$imgname', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";


4.
REPLACE:
Code: [Select]
include(ROOT_PATH.'includes/search_utils.php');
BY:
Code: [Select]
include_once(ROOT_PATH.'includes/search_utils.php');


5.
REPLACE:
Code: [Select]
include(ROOT_PATH.'includes/email.php');
BY:
Code: [Select]
include_once(ROOT_PATH.'includes/email.php');


6.
REPLACE:
Code: [Select]
$msg .= $lang['image_add_success'].": <b>".stripslashes($image_name)."</b> (".$new_name.")";BY:
Code: [Select]
      $msg .= $lang['image_add_success'].": <b>".stripslashes($image_name)."</b> (".$new_name.")<br>";
7. (almost over... )
REPLACE:
Code: [Select]
      $content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
    }
    else {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }
  else {
    $action = "uploadform";
    $sendprocess = 1;
  }
}

if ($action == "uploadform") {
BY:
Code: [Select]
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
    $good=1;
  }
  else {
  //Atleast 1 multifile succeeded.
  if(count($HTTP_POST_FILES) && $good==1)
  {
  $action = "multiuploadform";
  break;
  }
  else
  {
  $action=($action=="multiuploadimage")?"multiuploadform":"uploadform";
  $sendprocess = 1;
  break; //break the while if any image upload fails
  }
  }
  $fileext=($fileext=="")?2:$fileext+1;
  }//end while
  }//end if
    else
    {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }//end upload action
 
  //Show the form
if ($action == "uploadform" || $action == "multiuploadform") {

8. to parse the correct html...
REPLACE:
Code: [Select]
$content = $site_template->parse_template("member_uploadform");BY:
Code: [Select]
  if($action == "multiuploadform" || $action=="multiuploadimage")
    {
    $content = $site_template->parse_template("member_multiuploadform");
    }
    else
    {
    $content = $site_template->parse_template("member_uploadform");
  }


FINALLY...

III. CREATE A PAGE FOR MULTIUPLOAD FORM 'member_multiuploadform.html'
- download the file from below and copy it to your template folder (of course rename to member_multiuploadform.html)
- you may un-comment more file items, if you expect the users to download smaller files. For me 5 is quite enough when uploading jpgs directly from 5MP digital camera... (I  use the auto thumbnailer and auto resizer), but for photos from my 2MP camera I can use even 10...
- 4 images will just give (a bit misleading though), timeout error, if one tries to add too many images at once... complaining that you have invalid password(or something I can't recall...).
- Please edit this HTML to use your current locals (actually, you should add some variables to your language main.php -file...), I was too busy to do that.


...READY. Now starts the testing. :) (at first it is good to check that the 'normal' upload works as it used to... )


22 June 2005 CORRECTED the steps II.2 and II.7 were changed
23 June 2005 CORRECTED I fixed step II.2, incorrectly, leaving out the ".$fileext"-extension when checking the input files. And added a new II.2.2, to enable the auto thumbnailing...
26 July 2005 ADDED attachments of 'clean' multiupload files.
27 July 2005 UPDATED the instructions to match the provided files.

2
Hi,
I have just installed 4images a week ago. I have a background on PHP programming, and so I have done some modifications to my 4 images. I just wanted to ask if people would be interested if I'd write actual MOD instructions for these...

UPLOAD MODS

1. EXIF (No exif extension for PHP required!):

1a) [required] Extract and save Exif information -
saves exif to database before the image resize (which seems to lose this data),
and display it on a click of a button.

1b) [optional] Rotate images automatically, according to the Exif-Orientation


2. Multiupload - [DONE]
Upload multiple files with a simple interface. The amount depends on the file sizes, for me it works great with 5 images straight from 5MP camera, but gives timeout when I try 10. But it takes just fine 10 photos from my 2MP camera.

This is now ready... I hope it works...
http://www.4homepages.de/forum/index.php?topic=8517.0


3. better proportional (auto)resize (I use this with auto resize mod), to allow landscapes and portraits in, both Standard sized images (ie. <600 x <800) + Panoramas(ie. <600 x <3500):

-it works so that it makes sure the shorter side(can be either width or height) of an image is compared to the set limit and the longer side is proportionally resized accordingly (but it also has a maximum limit).

-the old one had to have limits 800x800, if you needed to allow same length in both landscapes and in portraits, which made it impossiple to add panoramas.


VIEW MODS

4. Random image thumbnail is searched from subfolders, if the main category doesn't have any.

...All these are ready and working together, I just ought to make the mod instructions for them (by comparing the original 1.7.1 release to the files I have modified...). I just don't know when I have the time... Which of these if any would you like to have? My gallery is a private kind, but I may provide screenshots, if you are interested.

Pages: [1]