4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: dipunm on July 22, 2005, 09:18:42 PM

Title: Upload multiple images via *.zip DONE
Post by: dipunm on July 22, 2005, 09:18:42 PM
DISCONTINUED.. probably still has bugs too, mite work if u dont expect too much from it
EDITED: (because it was all over the place  :oops:)
UPDATED 02/09/05
Okay, I heard that no one has created the upload via zip file mod... so, i decided to make one  :wink:

Description:

allow users to upload a zip file containing unlimited no of pictures (one category at a time) and the pictures will be extracted, zip file deleted, and the pictures will be added into the database... also, images can be resized, thumbnailed and so on (set using the checkand go settings in admin control panel) during this process.

Install Summary:

Install multiuploadform mod: http://www.4homepages.de/forum/index.php?topic=8517.0
Install checkandgo mod: http://www.4homepages.de/forum/index.php?topic=7245.0
Download: http://www.phpconcept.net/pclzip/index.en.php?PHPSESSID=f4054c78b4c9e9f490267719896a1e55#download and put pclzip.lib.php into the includes folder
From the zip file:
replace member_multiuploadform.html in the template folder
put upload2.php into the includes folder
put the admin_global.php and checkandgo.php files into the gallery's install folder (where index.php would be)
edit the member.php file.


THANKS TO: rroc and deejay_... If it weren't for your mods, i wouldnt be able to do this.

Editing member.php (should be done last)
the member.php file needs to edited so that the multiuploadform can give the sid info...
find:
Code: [Select]
if($action == "multiuploadform" || $action=="multiuploadimage")
  {
  $content = $site_template->parse_template("member_multiuploadform");

and replace with:
Code: [Select]
if($action == "multiuploadform" || $action=="multiuploadimage")
  {
  $content = '<script language="Javascript"> var sid="'.$sid.'" </script> '.$site_template->parse_template("member_multiuploadform");

Known (unsolved) bugs:

[li]Error for users WITHOUT direct upload permission for the category in question. (1ST PRIORITY)[/li]

[li]Files with the same filename as an existant image in its category will NOT be uploaded and has to be uploaded individually (working on it)[/li]
[li]all pages other than the upload form does not use template theme at all.[/li]
[/list]

I think thats all, if anyone has any problems or bugs or has a suggestion to make it look better, please be my guest and reply to this post.
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 16, 2005, 01:44:32 AM

Editing upload2.php
$uploadDir: change 'gallery' to the actual gallery folder (the folder which you instaled the gallery to: some call it 4images)
top.location: change 'lc.kurdistanserver.com/gallery' to your website name and install folder


Great, exactly what Iīm looking for - but unfortunatly after uploading the ZIP i get an error "Page not found" !
I donīt know whereīs my mistake, the path on the server is "/eventpics/4images/..." and so I add this to the $uploadDir, but after uploading the error page still is on
"http://www.event-pics.de/includes/upload2.php"
                                     ^^^^^^
the folder 4images is missing !?

JanSenf
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 16, 2005, 02:44:18 PM
okay, i went to your website and found your problem... well a differnt problem cause youve tried to edit it.. your form has action="4images/includes/upload2.php" get rid of the 4images bit... so its "includes/upload2.php"  :wink:

Also, It was my bad thinking that all ftp's were the same :oops:... make $uploadDir read...
$uploadDir = '/kunden/frankj.de/eventpics/4images/data/media/'.$cat_id.'/';  :wink:

I think this should fix your problems... try again... and come back with any other bugs
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 16, 2005, 04:17:52 PM
okay, i went to your website and found your problem... well a differnt problem cause youve tried to edit it.. your form has action="4images/includes/upload2.php" get rid of the 4images bit... so its "includes/upload2.php"  :wink:

Ok, this is my fault. Iīve tried so much to make it work !  :(

Quote
Also, It was my bad thinking that all ftp's were the same :oops:... make $uploadDir read...
$uploadDir = '/kunden/frankj.de/eventpics/4images/data/media/'.$cat_id.'/';  :wink:

I think this should fix your problems... try again... and come back with any other bugs

Ok, I didnīt get the right server-path !!!!
Upload is now working, but still there is an other error when working with the ZIP-FILE !

Look at this...
Warning:  move_uploaded_file(kunden/frankj.de/eventpics/4images/data/media/3/Kopie_web.zip): failed to open stream: No such file or directory in /kunden/frankj.de/eventpics/4images/includes/upload2.php on line 7

Warning:  move_uploaded_file(): Unable to move '/tmp/php0kuD0b' to 'kunden/frankj.de/eventpics/4images/data/media/3/Kopie_web.zip' in /kunden/frankj.de/eventpics/4images/includes/upload2.php on line 7
error:
Array
(
    [userfile] => Array
        (
            [name] => Kopie_web.zip
            [type] => application/x-zip-compressed
            [tmp_name] => /tmp/php0kuD0b
            [error] => 0
            [size] => 109598
        )

)
 
try again



Any Idea ?
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 16, 2005, 07:08:11 PM
Quote

Warning:  move_uploaded_file(kunden/frankj.de/eventpics/4images/data/media/3/Kopie_web.zip): failed to open stream: No such file or directory in /kunden/frankj.de/eventpics/4images/includes/upload2.php on line 7

Warning:  move_uploaded_file(): Unable to move '/tmp/php0kuD0b' to 'kunden/frankj.de/eventpics/4images/data/media/3/Kopie_web.zip' in /kunden/frankj.de/eventpics/4images/includes/upload2.php on line 7
error:
Array
(
    [userfile] => Array
        (
            [name] => Kopie_web.zip
            [type] => application/x-zip-compressed
            [tmp_name] => /tmp/php0kuD0b
            [error] => 0
            [size] => 109598
        )

)


Is your hosting service provides your site under Windows Server ?
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 16, 2005, 08:01:23 PM
Quote
Is your hosting service provides your site under Windows Server ?
Quote

No, the FAQ says:

Linux-/Apacheservern (1.3.X) with modified RedHat-Linux Version
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 17, 2005, 12:17:17 PM
it sounds like the upload directory doesnt exist ($uploadDir) :cry:

try this... upload this file to your site, run it, and youll get an error... use the error to work out what the location should be..
 if it is the same or if it still dusnt work, try this: "./../data/(blahblahblah)" so that the directory is with respect to the location of the file.
If it STILL dusnt work, then ill try and investigate further... also, your server is based on what (windows, linux, etc.)

(the file is .php... i just had to rename it)
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 17, 2005, 12:23:40 PM
@dipunm :

When I'm trying your attached ZIP file, from your post above, it says that the file is corrupted . . .
Title: Re: Upload multiple images via *.zip DONE
Post by: V@no on August 17, 2005, 02:45:42 PM
@dipunm :

When I'm trying your attached ZIP file, from your post above, it says that the file is corrupted . . .
rename it to UnZipper.php ;)
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 17, 2005, 08:31:06 PM
Indeed. It works.
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 17, 2005, 11:18:25 PM
it sounds like the upload directory doesnt exist ($uploadDir) :cry:

try this... upload this file to your site, run it, and youll get an error... use the error to work out what the location should be..
 if it is the same or if it still dusnt work, try this: "./../data/(blahblahblah)" so that the directory is with respect to the location of the file.
If it STILL dusnt work, then ill try and investigate further... also, your server is based on what (windows, linux, etc.)

(the file is .php... i just had to rename it)

The Server is based an Linux (see my posting above).

Sorry, I tried this file out but it doesnīt matter where i copy it, i always get an error
"Parse error: parse error, unexpected T_STRING in /kunden/frankj.de/eventpics/4images/data/media/3/UnZipper.php on line 5"
(Of course the path is changing to where i copy the file....!!!)

Or didnīt i get the instructions ???  8O
Title: Re: Upload multiple images via *.zip not so DONE
Post by: dipunm on August 18, 2005, 09:10:27 AM
Ive decided my upload form is too rubbish....

however, my next attempt will be to use the 4images upload script to help me...

first though, make sure your folder permissions allow you to write to these folders (but i dont see why not)
and try using:
define('ROOT_PATH', './../');
include('./upload.php');
$uploadDir='/var/www/4images/data/media/'.$cat_id.'/';


if it still doesnt work, just wait a little longer  :oops:
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 18, 2005, 10:01:22 AM
message to TheOracle

are you saying the whole thing works, or just the part when you renamed the the file to .php?  :?

what works?  :oops:
Title: Re: Upload multiple images via *.zip not so DONE
Post by: Jan Senf on August 18, 2005, 11:03:06 AM
Ive decided my upload form is too rubbish....

however, my next attempt will be to use the 4images upload script to help me...

first though, make sure your folder permissions allow you to write to these folders (but i dont see why not)
and try using:
define('ROOT_PATH', './../');
include('./upload.php');
$uploadDir='/var/www/4images/data/media/'.$cat_id.'/';


if it still doesnt work, just wait a little longer  :oops:

ok, i will wait ...!  8O

... but the coding will be easier if the instructions were a little more clearer ...
sometimes i donīt understand which line in which file i have to edit, and iīm not new to php (but also no professional) or 4images and it is not the first MOD or Change i make  :oops:

Is there anybody who installed this "MOD" and gets that thing working ?  :roll:
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 18, 2005, 04:24:44 PM
did u try to put the code above in first?...replace:
$uploadDir = '
(the whole of the line)
with the code in bold form my last post... try this first because i dont see why it shouldn't work
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 18, 2005, 05:52:53 PM
did u try to put the code above in first?...replace:
$uploadDir = '
(the whole of the line)
with the code in bold form my last post... try this first because i dont see why it shouldn't work

Ok, iīve changed the code in the includes/upload2.php to your "bold" code ...

After uploading a test zip there is a known error:

Warning:  move_uploaded_file(/var/www/4images/data/media/3/Kopie_web.zip): failed to open stream: No such file or directory in /kunden/frankj.de/eventpics/4images/includes/upload2.php on line 12

Warning:  move_uploaded_file(): Unable to move '/tmp/phpZgGtyu' to '/var/www/4images/data/media/3/Kopie_web.zip' in /kunden/frankj.de/eventpics/4images/includes/upload2.php on line 12
error:
Array
(
    [userfile] => Array
        (
            [name] => Kopie_web.zip
            [type] => application/x-zip-compressed
            [tmp_name] => /tmp/phpZgGtyu
            [error] => 0
            [size] => 109598
        )

)
 
try again


Line 12 is the following code:
Code: [Select]
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))

 8O
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 18, 2005, 06:32:04 PM
could you please post the whole php file plz?
id like to make sure it is correct

THANX
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 22, 2005, 12:31:00 PM
could you please post the whole php file plz?
id like to make sure it is correct

THANX

ok, hereīs my upload2.php ...

Code: [Select]
<?php

if (isset($cat_id)){
// $uploadDir = 'kunden/frankj.de/eventpics/4images/data/media/'.$cat_id.'/';

define('ROOT_PATH''./../');
include(
'./upload.php');
$uploadDir='/4images/data/media/'.$cat_id.'/';

$uploadFile $uploadDir $_FILES['userfile']['name'];
print 
"<pre>";
if (
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
{
 include(
'pclzip.lib.php');
  $archive = new PclZip($uploadFile);
  if ($archive->extract(PCLZIP_OPT_PATH$uploadDir,
                        PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
    die("Error : ".$archive->errorInfo(true));
  }
 
unlink($uploadFile);

?>

<script language="javascript">
top.location='http://www.event-pics.de/4images/checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'
</script>
<?php
}
else
{
?>

error:
<?php 
print_r
($_FILES);
?>

try again
<form enctype="multipart/form-data" action="upload2.php" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="hidden" name="cat_id" value="2" />
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>
<?php
}
print 
"</pre>";
}else
{
?>

<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="upload2.php" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="hidden" name="cat_id" value="2" />
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="userfile" type="file" />
    <input type="submit" value="Send File" />
</form>
<?php
}
?>


Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 22, 2005, 06:39:23 PM
Okay, I think I've found an all round solution... with this new upload2.php only 2 changes are needed:

1)  line 60 (in the new upload2.php file) reads:
Code: [Select]
top.location='http://lc.kurdistanserver.com/gallery/checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'simply edit this to read the directory of YOUR website... (like you did in the previous file)
and then replace the original upload2.php file in your includes folder.

2)  in the member_multiuploadform.html file in the templates directory:
find:
Code: [Select]
<input type="file" name="userfile" class="input" />replace with:
Code: [Select]
<input type="file" name="media_file" class="input" />
The code has been taken from the original members.php file and edited so if you can upload individual images in 4images, then you should be able to do the same here (fingers crossed :mrgreen:)

please post back whether it works or not just so I can know whether it works

the great thing about it, (and the bit that might fix your problem) ist that it doesn't need to know the FULL directory to the upload directory, just the relative directory
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 22, 2005, 10:41:11 PM
Okay, I think I've found an all round solution... with this new upload2.php only 2 changes are needed:

1)  line 60 (in the new upload2.php file) reads:
Code: [Select]
top.location='http://lc.kurdistanserver.com/gallery/checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'simply edit this to read the directory of YOUR website... (like you did in the previous file)
and then replace the original upload2.php file in your includes folder.

 ???????  8O
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 23, 2005, 09:15:14 AM
in the attachment from my last post, on line 60 (once you've exctracted the file):
Code: [Select]
top.location='http://lc.kurdistanserver.com/gallery/checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'
change to:
Code: [Select]
top.location='http://www.event-pics.de/4images/checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'
You did it before, which part of that was confusing???  :?
well, hope this clears it up :wink:
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 23, 2005, 04:36:28 PM
You did it before, which part of that was confusing???  :?
well, hope this clears it up :wink:

I didnīt understand the instructions - i didnīt get it thatīs so easy ...!?

Ok, changes made, but for some reason i get this....
Ok, itīs a little better than the last try, but it do not work...

error:
Array
(
    [media_file] => Array
        (
            [name] => Kopie_web.zip
            [type] => application/x-zip-compressed
            [tmp_name] => /tmp/phpW5lnhb
            [error] => 0
            [size] => 109598
        )

)
 
try again


Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 25, 2005, 11:57:37 AM
ok... CONFUSION...

the error you posted comes from my old upload2.php file... did u replace this with the new one inside the zip folder (attachment)? :?
I'll post the attachment again but did you read the instructions properly?

1) download the attachment and exctract it
2) in the upload2.php file (the new one found inside the zip folder):
    find:
   
Code: [Select]
    top.location='http://lc.kurdistanserver.com/gallery/checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'
   
    change to:
   
Code: [Select]
    top.location='http://www.event-pics.de/4images/checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'
   
3) in the member_multiuploadform.html (found in the templates folder):
    find:
   
Code: [Select]
    <input type="file" name="userfile" class="input" />
   
    replace with:
   
Code: [Select]
    <input type="file" name="media_file" class="input" />
   
NOTE: I've just realised that you put both upload forms into the upload page... this means that you will have to search from the bottom going up and replace only the first one you find
Title: Re: Upload multiple images via *.zip DONE
Post by: urmasmuld on August 25, 2005, 12:24:09 PM
I've got this error. What could be wrong? :?
Code: [Select]
Warning: Invalid argument supplied for foreach() in /4images/checkandgo.php on line 332
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 25, 2005, 12:54:57 PM
the only suggestion i can think of is reinstall the checkandgo mod... you'll otherwise have to ask this question here http://www.the-deejay.com/mantis/bug_report_page.php (if you need username and password then it is user:4images pass:4images) or here http://www.4homepages.de/forum/index.php?topic=7245.0 because i simply use this mod, i didnt make it :?
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 25, 2005, 01:16:43 PM
Quote

Warning: Invalid argument supplied for foreach() in /4images/checkandgo.php on line 332


I assume you're using Windows Server ?
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 25, 2005, 01:24:07 PM
If I could be of assistance on this one.

Since the following goes into a PHP file, it could also be validated through sessions

from :

Quote

top.location='http://www.event-pics.de/4images/checkandgo.php?sid=<?php print "$sid" ?>&cat_id=<?php print "$cat_id" ?>'


to :

Code: [Select]

top.location=''.$site_sess->url(ROOT_PATH.'checkandgo.php?sid=".$sid."&cat_id=".$cat_id.").''


;)
Title: Re: Upload multiple images via *.zip DONE
Post by: jkn on August 25, 2005, 04:28:41 PM
Yeha, it’s a really great mod!!! and thx for your great work!

but one question: I’ve added the last code and the second upload2.php with the alternative code from theOracle

Quote
top.location=''.$site_sess->url(ROOT_PATH.'checkandgo.php?sid=".$sid."&cat_id=".$cat_id.").''

but the java-script doesn’t have any effect!??? the files are in the right folder, but not in the database!!?? and they are not resized and visible! The only what i see is an java-skript error!
on this url: http://www......de/images/includes/upload2.php

Fehler:    Syntaxfehler
Zeile:      4
Zeichen:   28

Zeile 4 is:   define('ROOT_PATH', './../');

redirect doesn’t work?!?

hmm... thx and sorry for my bad english  :oops:
jkn
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 25, 2005, 04:40:27 PM
Quote

/images/includes/upload2.php


should be :

Code: [Select]

includes/upload2.php


As for your images, it should go in your templates/<your_template>/images path.

;)
Title: Re: Upload multiple images via *.zip DONE
Post by: jkn on August 25, 2005, 04:46:06 PM
 :lol:

öhm no_oo oracle, 4images is installed in the /images/ folder!!

by
jkn
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 25, 2005, 05:02:16 PM
Quote

define('ROOT_PATH', './../');
include('./upload.php');


Change to :

Code: [Select]

define('ROOT_PATH', './');
include(ROOT_PATH.'includes/upload.php');

Title: Re: Upload multiple images via *.zip DONE
Post by: jkn on August 25, 2005, 05:47:42 PM
in includes/upload2.php ???

i’ve now this error:

Warning: Failed opening './includes/upload.php' for inclusion (include_path='.:/usr/share/php') in /home/www/web19/html/images/includes/upload2.php on line 5

Warning: Failed opening './global.php' for inclusion (include_path='.:/usr/share/php') in /home/www/web19/html/images/includes/upload2.php on line 6

Fatal error: Failed opening required './includes/sessions.php' (include_path='.:/usr/share/php') in /home/www/web19/html/images/includes/upload2.php on line 7
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 25, 2005, 06:13:21 PM
to: jkn

It is to my understanding that the error came after you made the changes that theoracle specified...
I tested theoracles changes and unfortunately, it doesn't work, instead it gives me a similar syntax error :mrgreen:

when you get an error which is not written onto the page, this means that the error is not a php error. Therefore, when the error specified line 4, you should have looked into the source of the loaded page and looked for line 4 from there.

If you did so, you would probably found that the error was in the change that theoracle specified.  :roll:

Unfortunately, theoracle did not realise that the part he told you to change was not written in php, instead it was written in javascript.

WHAT TO DO
 You should revert the file back to how it was before... this will cure all of your errors in the upload2.php file.

1) find

Code: [Select]
define('ROOT_PATH', './');
change back to

Code: [Select]
define('ROOT_PATH', './../');
2) find

Code: [Select]
top.location=''.$site_sess->url(ROOT_PATH.'checkandgo.php?sid=".$sid."&cat_id=".$cat_id.").''
change to

Code: [Select]
top.location='./../checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>'
However, as I mentioned before, the previous error has nothing to do with the upload process, only the checkandgo process and if anything, the problem lies in there.  :wink:

Unfortunately, as I said before, i only used the checkandgo mod, so I cant give support for this, i reccomend that you reinstall the checkandgo mod but if this doesnt work, you should try and post your question at the checkandgo (allinone) forum.
Title: Re: Upload multiple images via *.zip DONE
Post by: TheOracle on August 25, 2005, 06:14:53 PM
Quote

I tested theoracles changes and unfortunately, it doesn't work, instead it gives me a similar syntax error


I never should of posted this. Put it back the way it was.  :oops:
Title: Re: Upload multiple images via *.zip DONE
Post by: jkn on August 25, 2005, 08:13:42 PM
thx guy's !

but now i have another error  :(


Fatal error: Cannot redeclare class upload in /home/www/web19/html/images/includes/upload.php on line 44

after line 44 is:

Code: [Select]
class Upload {

  var $upload_errors = array();
  var $accepted_mime_types = array();
  var $accepted_extensions = array();
  var $upload_mode = 3;

  var $image_type = "";
  var $max_width = array();
  var $max_height = array();
  var $max_size = array();
  var $upload_path = array();

  var $field_name;
  var $file_name;
  var $extension;

  var $image_size = 0;
  var $image_size_ok = 0;
  var $lang = array();
  var $upload_errors = array();

  function Upload() {
    global $config, $lang;

    $this->max_width['thumb'] = $config['max_thumb_width'];
    $this->max_width['media'] = $config['max_image_width'];
    $this->max_height['thumb'] = $config['max_thumb_height'];
    $this->max_height['media'] = $config['max_image_height'];
$this->auto_image['media'] = $config['auto_image'];

    $this->max_size['thumb'] = $config['max_thumb_size'] * 1024;
    $this->max_size['media'] = $config['max_media_size'] * 1024;

    $this->upload_mode = $config['upload_mode'];
    $this->lang = $lang;

    $this->set_allowed_filetypes();
  }


??? and thx for your help &answers!

jkn
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 26, 2005, 07:44:28 AM
Well as far as i can see, you've missed out the '}' at the end of the upload class
put this on line JUST before   'function Upload() {'

this might fix the problem :wink:
Title: Re: Upload multiple images via *.zip DONE
Post by: jkn on August 26, 2005, 08:41:34 AM
no, that was not the complete function!  8)

but i'm fix this error - here they are 2x:

include(ROOT_PATH.'includes/upload.php');

in the upload2.php! and now .. it works!!  :D   :lol:   :D

thx guy's!!!

jkn

p.s. another little question: upload-resizing is ok, but how can i save the original uploading image in a separate folder!???  :oops:
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 26, 2005, 10:57:03 AM
ITīS WORKING !!!!
Great !

(ok, i didīn use the new upload2.php - my fault !!!)

One thing left...
Iīve no chance to enter some keywords because the page where i may enter them jumps to the next page within a second oder two ????

Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 26, 2005, 11:50:14 AM
Jan Senf:
yeh, I did that because there are a few things that the uploader can change on that page which shouldn't be available to any user such as choosing which name to put as the uploader. for this reason, i placed an autosubmit code in to prevent unauthorised changes. If you want to play with it, the file to edit is checkandgo.php (the one on the 4images directory).

find:
Code: [Select]
print "<SCRIPT LANGUAGE=\"Javascript\"> document.forms(\"formular\").submit() </SCRIPT>";(should be on line 242)

this is the code that autosubmits the form... delete it and you can see and enter the excess info without any interruption...
However...I DO NOT RECCOMMEND THIS BECAUSE IT GIVES USERS PERMISSION TO ACT MISCHEIVIOUSLY.

Also, I believe that the comment box, when filled in, is applied to ALL the pictures.
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 26, 2005, 12:38:02 PM
jkn
Well, I dont use the auto resizer :roll:, You can decide what you want the mod to do to the picture once it is uploaded in the admin cpanel.

you should find CheckAndGo Settings in the General section of the menu on the left. :mrgreen:

If you want BOTH, big and resized images, and you dont mind that the big file is situated in a specific folder but 4images will not use it in any way, here's what to do:

in upload2.php:
find:
Code: [Select]
  if ($archive->extract(PCLZIP_OPT_PATH, $uploadDir,
                        PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
  die("Error : ".$archive->errorInfo(true));
 }else{
insert after:
Code: [Select]
big = $archive->extract(PCLZIP_OPT_PATH, ROOT_PATH.'put the directory here (relative to your 4images directory)', PCLZIP_OPT_REMOVE_ALL_PATH);
NOTE: the new directory cannot be the same as the original directory because it will simply be as if no change was made.
If you want the download link to download the big file but for the image to be resized when you view it, then let me know and i'll look into it  :wink:

ps. I take it youve solved the problem with checkandgo.php?
Quote
Warning: Invalid argument supplied for foreach() in /4images/checkandgo.php on line 332
Title: Re: Upload multiple images via *.zip DONE
Post by: jkn on August 26, 2005, 02:23:29 PM
hmmmm... i've added this as line 56:

Code: [Select]
big = $archive->extract(PCLZIP_OPT_PATH, ROOT_PATH.'/data/media/'.$cat_id.'/big/', PCLZIP_OPT_REMOVE_ALL_PATH);
but:   Parse error: parse error, unexpected '=' in /home/www/web19/html/images/includes/upload2.php on line 56

this mod is really fine, but it's nicer when we let the users download also the original uploaded files .. example from the "big" folder under the cat-folders!!

thx & by
jkn


Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 26, 2005, 03:10:54 PM
I guess i shudav tested the code first eh? :oops:

k, ill hav a go with the big pic mod
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 26, 2005, 04:13:33 PM
Try this: its not tested so if you find any error with it, please send me the error messages or if it just doesnt work, tell me so i can fix it  :wink:

oh and make BACKUPS OF UPLOAD2.PHP AND CHECKANDGO.PHP

in checkandgo.php

find:
Code: [Select]
$sql = "INSERT INTO ".IMAGES_TEMP_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, image_status)
          VALUES (".$cat_id.", ".$user_id.", '".$image_name."', '', '".$image_keywords."', ".$image_date.", ".$image_active.", '".$image_media_file."', '".$image_thumb_file."', '', ".$image_allow_comments.", '".$checkandgo_steps_status[0]."')";
replace with:
Code: [Select]
$sql = "INSERT INTO ".IMAGES_TEMP_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, image_status)
          VALUES (".$cat_id.", ".$user_id.", '".$image_name."', '', '".$image_keywords."', ".$image_date.", ".$image_active.", '".$image_media_file."', '".$image_thumb_file."', '".$bigurl.$image_name."', ".$image_allow_comments.", '".$checkandgo_steps_status[0]."')";

in upload2.php:

delete everything AFTER :
Code: [Select]
include('./pclzip.lib.php');
replace with:
Code: [Select]
$uploadDir = ROOT_PATH.'/data/media/'.$cat_id.'/';
 $archive = new PclZip($uploadDir.$new_name);
  if ($archive->extract(PCLZIP_OPT_PATH, $uploadDir,
                        PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
  die("Error : ".$archive->errorInfo(true));
 }else{
$uploadDir2 = ROOT_PATH.'/data/media/'.$cat_id.'/big/';
if ($archive->extract(PCLZIP_OPT_PATH, $uploadDir2,
                        PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
  die("Error : ".$archive->errorInfo(true));
 }else{

?>
<script language="javascript">
top.location='./../checkandgo.php?sid=<?php print "$sid?>&cat_id=<?php print "$cat_id?>&bigurl=<?php print "$uploadDir2?>'
</script>
<?php
}
 }
unlink($uploadDir.$new_name);
}
?>
Title: Re: Upload multiple images via *.zip DONE
Post by: jkn on August 26, 2005, 07:29:01 PM
hee hee heee .. you are my hero of the day!!!  :mrgreen:

it works perfect with
Code: [Select]
[b][color=Red]'[/color][/b]".$bigurl.$image_name."[color=Red][b]'[/b][/color] in the sql-querie!!

:)

and the last question: can we add images .. also the check-and-go-prozess .. in a little java-skript window!??? otherwise i have my gallery-page -> click upload -> now i have a blanc and after the prozess i have again my gallery page! hmmm...?

jkn
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 26, 2005, 10:31:26 PM
Quote
it works perfect with
Code:
'".$bigurl.$image_name."'
in the sql-querie!!

if you are gonna post a code, tags dont work inside them... it confused me wen i read it  :(
It's ok, i get it now...

HOWEVER, could you please rewrite your last question... i didnt quite get it  :? :oops:

if you're asking if the mod can work in a new window, you could try to edit the member_multiuploadform.html file in the template directory and in the form tag, put target="_blank"

(Im too tired to show where to change what, i'll modify this later... )

the change is not tested and i dont know if it will work
Title: Re: Upload multiple images via *.zip DONE
Post by: Jan Senf on August 27, 2005, 12:39:07 PM
Jan Senf:
yeh, I did that because there are a few things that the uploader can change on that page which shouldn't be available to any user such as choosing which name to put as the uploader. for this reason, i placed an autosubmit code in to prevent unauthorised changes. If you want to play with it, the file to edit is checkandgo.php (the one on the 4images directory).

... wouldnīt it be nice if the user is asked for describtion and/or keywords when uploading a ZIP-File ?
:-)

Hm, iīve not enough time in the moment to check this out ... , maybe later !!!
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on August 29, 2005, 12:16:11 PM
To be honest, the only thing I actually made was the upload and exctract code, the process of adding it to the database was done by modding the checkandgo (allinone) mod :mrgreen:

I am not really a good php programmer, just an ordinary person who wanted a mod for his website and couldnt find it so I made one. Then I shared my knowledge, (its fun to help ppl).  :D

I had a look at the code that makes the page (which i dont want any1 to edit) :| and i found it very confusing as to where the functions that make the page come from. This is why I cant REALLY mod it further, :? if I knew this, I cud hide certain inputs etc and then you COULD edit keywords and descriptions...

However, you have to take into consideration that the picutes would all have the same descriptions and keywords, this is why I didn't bother with looking too deep into the code. :lol:
Title: Re: Upload multiple images via *.zip DONE
Post by: iban on September 02, 2005, 02:34:41 AM
It is a great mod!!! But I have a problem and a pair of suggestions...

PROBLEM: when I try to upload a zip-file, then, I get a error at upload2.php:
Quote
Error : PCLZIP_ERR_MISSING_FILE (-4) : Missing archive file './..//data/media/7/'

The error is only when a user is who tries the upload. If the 4images' administrator uploads the same file there is no error.


SUGGESTIONS:
1st Three types of upload together: 1file, somefiles, zipfile
2nd When you upload a file one by one, the system renames the file if it exists yet. But, zip upload does not do it...


Could somebody help with my problem? Thanks!
Title: Re: Upload multiple images via *.zip DONE
Post by: iban on September 02, 2005, 01:02:10 PM
The problem is because the category was NOT "Direct Upload". If the category is only "Upload"-able for the user, the error occurs.
I think it is a bug.

Is there a way to enable "zip-upload" for users when the category is set by "Upload"=ON and "Direct Upload"=OFF?

Many thanks
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on September 02, 2005, 11:27:45 PM
Thanx 4 the hint  :wink:

You are right, it IS a bug and I'm working on it.  8O

As far as renaming goes, It is not possible at the moment. This is a problem even for me, the file will NOT be extracted if a file with the same name exists, so rest assured that the original file will not be replaced.  :lol:

HOWEVER, the PCLZIP program does not support this feature which is why on the last page, there is a message asking that if any pictures are not listed at the end which WERE in the zip file, that those pictures should be uploaded individually.

Okay, after a little investigation, I find that the proposed bug fix is a L-I-T-T-L-E harder than i suspected.
it would be ALOT easier if you didn't mind that uploads via zip file is treated as direct uploads???.... ( :( please say yes, please say yes, please say yes)

Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on September 05, 2005, 12:40:22 PM
OKAY, try this... its not been tested so keep a copy of your old upload2.php file
If it works, please say so  :wink:
(this should fix the upload without direct upload permission bug)
change the file to upload2.php  :wink:
Title: Re: Upload multiple images via *.zip DONE
Post by: cabdragon on November 16, 2005, 10:46:07 PM
Hey when I wanna upload a zip.file the following page shows this error:

DB Error: Bad SQL Query: INSERT INTO 4images_images_temp (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, image_status) VALUES (1, 1, 'bild 004', '', '', UNIX_TIMESTAMP('2005-11-16 22:37:34'), 1, 'bild 004.gif', '', '', 1, 'checkandgo_step_done_0')
Unknown column 'image_active' in 'field list'


And this error for each file within the zip file.

When I click "add" (german: "hinzufügen") on the bottom of that page I'm directed to a site which shows the same error for only my first file within the zip directory followed by this sentence:

   
#   Bild Name                  

If there are any pictures not in this list that were in the zip file then the file must be entered via single upload... thnxFINISH


(But However, the files are uploaded correctly)

What do I have to do?
Where's the mistake?
Title: Re: Upload multiple images via *.zip DONE
Post by: cabdragon on November 17, 2005, 06:37:19 PM
And another failure:

users may not upload several files per this mod, although i gave them the permission in control panel to direct upload, either in user level and also in group level
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on November 17, 2005, 08:06:37 PM
sorry bout thant, its just it took you so long to answer me, and no-one was posting that i gave up and left it as it was (it works how i need it to for me) (ps. not trying to be selfish, just a little busy nowadays)

anyways, the error seems to point out that there is a field missing from your sql database table 4images_images_temp check if the table has a field named image_active, if not, let me know and ill TRY to help you create the field, this HOPEFULLY will fix your problem...

However, the problem about multiple files not uploadable? i dont get it, this mod allows you to upload a zip file which CONTAINS multiple files which will all be inserted into the database in turn

please post your responses... thanx

----------------------------------------------------------------------
please hesitate to ask me any more questions, or i will blow your head off :@
Title: Re: Upload multiple images via *.zip DONE
Post by: cabdragon on November 18, 2005, 12:31:11 PM
hey thanks for your response
1.thats right, the field is missing, would you plz help me create that?
2.the administrator is able to upload files per multiupload thats right, but registered users are not although i gave them permission for direct upload
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on November 18, 2005, 03:21:16 PM
Firstly, this mod shudn't be giving you these problems... have you tried reinstalling?

now not to be rude, but i am a little busy rite now, so im gonna hav 2 look into adding the field later
the other problem, please, answer this quick question?... does normal upload work fine?
if so, then, is there an error, if so, please report it, if it is simply that the link is unclickable, let me know, i cant work with this much info, im gonna need to know what the problem ACTUALLY is so i can find the source.

thanx

dipunm

----------------------------------------------------------------------
please hesitate to ask me any more questions, or i will blow your head off :@
Title: Re: Upload multiple images via *.zip DONE
Post by: cabdragon on November 18, 2005, 04:01:40 PM
- not tried reinstall yet
- normal upload works fine, images are uploaded, no errors
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on November 18, 2005, 09:38:50 PM
ok, so what ACTUALLY happens? php error? or is the button just not clickable?
Title: Re: Upload multiple images via *.zip DONE
Post by: cabdragon on November 19, 2005, 06:51:24 PM
the button is clickable but the users get the message, that they have no permission for uploading files
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on November 20, 2005, 02:29:26 PM
ok thanx, ill look into it

----------------------------------------------------------------------
please hesitate to ask me any more questions, or i will blow your head off :@
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on November 28, 2005, 12:44:34 AM
ok, i dont understand this error, i will give you the code for my member.php file...

I'm not sure if it will work, if not, reinstall, (using instructions on 1st page)

ofcourse this may be a problem if you use more than 1 mod.

if you do so reinstall (which would mean reinstalling 4images) and would like to keep you settings and files...

keep a copy of your database and any files which have been modded, and the config file and all the files which have been uploaded
and THEN reinstall the program, then re-insert database values (or at least th ones you can) and replace files and then you can install my mod... btw, the program has only been tested on 4images 1.7
[code]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: member.php                                           *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.1                                                *
 *                                                                        *
 *    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', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');

if ($action == "") {
  $action = "lostpassword";
}
$content = "";
$txt_clickstream = "";

$sendprocess = 0;

if (isset($HTTP_GET_VARS[URL_COMMENT_ID]) || isset($HTTP_POST_VARS[URL_COMMENT_ID])) {
  $comment_id = (isset($HTTP_GET_VARS[URL_COMMENT_ID])) ? intval($HTTP_GET_VARS[URL_COMMENT_ID]) : intval($HTTP_POST_VARS[URL_COMMENT_ID]);
}
else {
  $comment_id = 0;
}

if ($action == "deletecomment") {
  if (!$comment_id || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $sql = "SELECT c.comment_id, c.user_id AS comment_user_id, i.image_id, i.cat_id, i.user_id, i.image_name
          FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".$comment_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_delete'];

  $sql = "UPDATE ".IMAGES_TABLE."
          SET image_comments = image_comments - 1
          WHERE image_id = ".$comment_row['image_id'];
  $site_db->query($sql);

  if ($comment_row['comment_user_id'] != GUEST) {
    $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")." = ".$comment_row['comment_user_id'];
    $site_db->query($sql);
  }

  $sql = "DELETE FROM ".COMMENTS_TABLE."
          WHERE comment_id = $comment_id";
  $result = $site_db->query($sql);
  $msg = ($result) ? $lang['comment_delete_success'] : $lang['comment_delete_error'];
}

if ($action == "removecomment") {
  if (!$comment_id || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
          FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".$comment_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_delete'];

  if (isset($comment_row[$user_table_fields['user_name']]) && $comment_row['comment_user_id'] != GUEST) {
    $user_name = $comment_row[$user_table_fields['user_name']];
  }
  else {
    $user_name = $comment_row['comment_user_name'];
  }

  $site_template->register_vars(array(
    "comment_id" => $comment_id,
    "image_name" => htmlspecialchars($comment_row['image_name']),
    "user_name" => htmlspecialchars($user_name),
    "comment_headline" => format_text($comment_row['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
    "comment_text" => format_text($comment_row['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
    "lang_delete_comment" => $lang['comment_delete'],
    "lang_delete_comment_confirm" => $lang['comment_delete_confirm'],
    "lang_image_name" => $lang['image_name'],
    "lang_name" => $lang['name'],
    "lang_headline" => $lang['headline'],
    "lang_comment" => $lang['comment'],
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));
  $content = $site_template->parse_template("member_deletecomment");
}

if ($action == "updatecomment") {
  if (!$comment_id || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }
  $sql = "SELECT c.comment_id, c.image_id, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
          FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".$comment_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_edit'];

  $error = 0;

  $comment_headline = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_headline']));
  $comment_text = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));

  if ($comment_headline == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['headline']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
  if ($comment_text == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['comment']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

  if (!$error) {
    $sql = "UPDATE ".COMMENTS_TABLE."
            SET comment_headline = '$comment_headline', comment_text = '$comment_text'
            WHERE comment_id = $comment_id";
    $result = $site_db->query($sql);
    $msg = ($result) ? $lang['comment_edit_success'] : $lang['comment_edit_error'];
  }
  else {
    $action = "editcomment";
    $sendprocess = 1;
  }
}

if ($action == "editcomment") {
  if (!$comment_id || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
          FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." i
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".$comment_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_edit'];

  $comment_headline = (isset($HTTP_POST_VARS['comment_headline'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['comment_headline']))) : $comment_row['comment_headline'];
  $comment_text = (isset($HTTP_POST_VARS['comment_text'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['comment_text']))) : $comment_row['comment_text'];

  if (isset($comment_row[$user_table_fields['user_name']]) && $comment_row['comment_user_id'] != GUEST) {
    $user_name = $comment_row[$user_table_fields['user_name']];
  }
  else {
    $user_name = $comment_row['comment_user_name'];
  }

  $bbcode = "";
  if ($config['bb_comments'] == 1) {
    $site_template->register_vars(array(
      "lang_bbcode" => $lang['bbcode'],
      "lang_tag_prompt" => $lang['tag_prompt'],
      "lang_link_text_prompt" => $lang['link_text_prompt'],
      "lang_link_url_prompt" => $lang['link_url_prompt'],
      "lang_link_email_prompt" => $lang['link_email_prompt'],
      "lang_list_type_prompt" => $lang['list_type_prompt'],
      "lang_list_item_prompt" => $lang['list_item_prompt']
    ));
    $bbcode = $site_template->parse_template("bbcode");
  }

  $site_template->register_vars(array(
    "bbcode" => $bbcode,
    "comment_id" => $comment_id,
    "image_name" => htmlspecialchars($comment_row['image_name']),
    "user_name" => htmlspecialchars($user_name),
    "comment_headline" => htmlspecialchars($comment_headline),
    "comment_text" => htmlspecialchars($comment_text),
    "lang_edit_comment" => $lang['comment_edit'],
    "lang_image_name" => $lang['image_name'],
    "lang_name" => $lang['name'],
    "lang_headline" => $lang['headline'],
    "lang_comment" => $lang['comment'],
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));
  $content = $site_template->parse_template("member_editcomment");
}

if ($action == "deleteimage") {
  if (!$image_id || ($config['user_delete_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = $lang['image_delete'];

  $sql = "DELETE FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $del_img = $site_db->query($sql);

  if (!is_remote($image_row['image_media_file']) && !is_local_file($image_row['image_media_file'])) {
    @unlink(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file']);
  }
  if (!empty($image_row['image_thumb_file']) && !is_remote($image_row['image_thumb_file']) && !is_local_file($image_row['image_thumb_file'])) {
    @unlink(THUMB_PATH."/".$image_row['cat_id']."/".$image_row['image_thumb_file']);
  }

  include(ROOT_PATH.'includes/search_utils.php');
  remove_searchwords($image_id);

  if (!empty($user_table_fields['user_comments'])) {
    $sql = "SELECT user_id
            FROM ".COMMENTS_TABLE."
            WHERE image_id = $image_id";
    $result = $site_db->query($sql);
    $user_id_sql = "";
    while ($row = $site_db->fetch_array($result)) {
      if ($row['user_id'] != GUEST) {
        $sql = "UPDATE ".USERS_TABLE."
                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_id";
  $del_com = $site_db->query($sql);

  if ($del_img) {
    $msg = $lang['image_delete_success'].". <p class=\"smalltext\" align=\"right\">".$lang['return_to'].get_category_path($image_row['cat_id'], 1)."</p>";
  }
  else {
    $msg = $lang['image_delete_error'];
  }
}

if ($action == "removeimage") {
  if (!$image_id || ($config['user_delete_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".$image_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_delete'];

  $site_template->register_vars(array(
    "image_id" => $image_id,
    "image_name" => htmlspecialchars($image_row['image_name']),
    "lang_delete_image" => $lang['image_delete'],
    "lang_delete_image_confirm" => $lang['image_delete_confirm'],
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));
  $content = $site_template->parse_template("member_deleteimage");
}

if ($action == "updateimage") {
  if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".$image_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_edit'];

  $error = 0;

  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $image_exif = "";
  $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 = ereg_replace("( ){2,}", " ", $image_keywords);

  if ($image_name == "")  {
    $error = 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 />" : "").$field_error;
  }

  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 = 1;
        $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $val[0]), $lang['field_required']);
        $msg .= (($msg != "") ? "<br />" : "").$field_error;
      }
    }
  }

  if (!$error) {
    $additional_sql = "";

    if (isset($HTTP_POST_VARS['image_allow_comments'])) {
      $additional_sql .= ", image_allow_comments = ".intval($HTTP_POST_VARS['image_allow_comments']);
    }

    if (!empty($additional_image_fields)) {
      $table_fields = $site_db->get_table_fields(IMAGES_TABLE);
      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 image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords'".$additional_sql."
            WHERE image_id = $image_id";
    $result = $site_db->query($sql);
    if ($result) {
      include(ROOT_PATH.'includes/search_utils.php');
      $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]);
        }
      }
      remove_searchwords($image_id);
      add_searchwords($image_id, $search_words);
      $msg = $lang['image_edit_success'];
    }
    else {
      $msg = $lang['image_edit_error'];
    }
  }
  else {
    $action = "editimage";
    $sendprocess = 1;
  }
}

if ($action == "editimage") {
  if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $additional_sql = "";
  if (!empty($additional_image_fields)) {
    foreach ($additional_image_fields as $key => $val) {
      $additional_sql .= ", ".$key;
    }
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_allow_comments".$additional_sql."
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".$image_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_edit'];

  $image_name = (isset($HTTP_POST_VARS['image_name'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_name']))) : $image_row['image_name'];
  $image_description = (isset($HTTP_POST_VARS['image_description'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_description']))) : $image_row['image_description'];
  $image_keywords = (isset($HTTP_POST_VARS['image_keywords'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_keywords']))) : $image_row['image_keywords'];
  $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments'])) ? intval($HTTP_POST_VARS['image_allow_comments']) : $image_row['image_allow_comments'];

  $site_template->register_vars(array(
    "image_id" => $image_id,
    "image_name" => htmlspecialchars($image_name),
    "image_description" => htmlspecialchars($image_description),
    "image_keywords" => htmlspecialchars($image_keywords),
    "image_allow_comments_yes" => ($image_allow_comments) ? " checked=\"checked\"" : "",
    "image_allow_comments_no" => (!$image_allow_comments) ? " checked=\"checked\"" : "",
    "lang_edit_image" => $lang['image_edit'],
    "lang_image_name" => $lang['image_name'],
    "lang_description" => $lang['description'],
    "lang_keywords" => $lang['keywords_ext'],
    "lang_allow_comments" => isset($lang['allow_comments']) ? $lang['allow_comments'] : "",
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));

  if (!empty($additional_image_fields)) {
    $additional_field_array = array();
    foreach ($additional_image_fields as $key => $val) {
      if ($val[1] == "radio") {
        $value = (isset($HTTP_POST_VARS[$key])) ? intval($HTTP_POST_VARS[$key]) : $image_row[$key];
        if ($value == 1) {
          $additional_field_array[$key.'_yes'] = " checked=\"checked\"";
          $additional_field_array[$key.'_no'] = "";
        }
        else {
          $additional_field_array[$key.'_yes'] = "";
          $additional_field_array[$key.'_no'] = " checked=\"checked\"";
        }
      }
      else {
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
      }
      $additional_field_array[$key] = $value;
      $additional_field_array['lang_'.$key] = $val[0];
    }
    if (!empty($additional_field_array)) {
      $site_template->register_vars($additional_field_array);
    }
  }
  $content = $site_template->parse_template("member_editimage");
}

if ($action == "uploadimage" || $action=="multiuploadimage") {
  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'];

//  $remote_media_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_media_file'])));
//  $remote_thumb_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_thumb_file'])));

  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $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 = ereg_replace("( ){2,}", " ", $image_keywords);

  $image_active = (isset($HTTP_POST_VARS['image_active']) && $HTTP_POST_VARS['image_active'] == 0) ? 0 : 1;
  $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments']) && $HTTP_POST_VARS['image_allow_comments'] == 0) ? 0 : 1;
  $image_download_url = (isset($HTTP_POST_VARS['image_download_url'])) ? format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['image_download_url']))) : "";

  $direct_upload = (check_permission("auth_directupload", $cat_id)) ? 1 : 0;
  $upload_cat = ($direct_upload) ? $cat_id : 0;

  $error = 0;
  $uploaderror = 0;

  if ($cat_id == 0)  {
    $error = 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;
  }
  //NO IMAGE FILE SPECIFIED
  if ((empty($HTTP_POST_FILES['media_file']['tmp_name']) || $HTTP_POST_FILES['media_file']['tmp_name'] == "none") /*&& ($remote_media_file == "" || !check_remote_media($remote_media_file))*/) {
    $error = 1;
    $msg .= (($msg != "") ? "<br />" : "").$lang['image_file_required'];
  }
  if ($image_name == "")  {
    $error = 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 />" : "").$field_error;
  }

  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 = 1;
        $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $val[0]), $lang['field_required']);
        $msg .= (($msg != "") ? "<br />" : "").$field_error;
      }
    }
  }

  // Required fields set: Start Upload
  if (!$error) {

   //MULTI FILE UPLOAD
   $fileext="";
   while(isset($HTTP_POST_FILES['media_file'.$fileext]))
      {
      if(!(empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) || $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] == "none"))
      {      
         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;
                 }
//            }
            
      /*    else {
           $new_name = $remote_media_file;
         }
      */
         // Upload thumb file
         $new_thumb_name = "";
         if (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$uploaderror) {
           $new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $upload_cat, basename($new_name));
           if (!$new_thumb_name) {
            $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$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'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['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']) {
              $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;

               $rotate=0;   
               if(preg_match("/Orientation:.{0,2}(Lower Right)|(Upper Right)|(Lower Left)/i",$site_upload->exif_txt,$matches))
                  $rotate = ($matches[3])?270:(($matches[2])?90:180);

               if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type, $rotate)) {
                  $new_thumb_name = $new_name;
              }
            }
           }
         }


      //--------------------------------------------
      //--------- Auto Image Resizing --------------
      //--------------------------------------------
         if ($config['auto_image'] && !$uploaderror)
            {
            if ($direct_upload) {
               $src = MEDIA_PATH."/".$cat_id."/".$new_name;
               }
            else {
               $src = MEDIA_TEMP_PATH."/".$new_name;
               }

            $do_resize = 0;
            if ($image_info = @getimagesize($src)) {
               if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
                  $do_resize = 1;
                  }
               }
            if ($do_resize) {
               if (!function_exists(init_convert_options)) {
                  require_once(ROOT_PATH.'includes/image_utils.php');
                  }
            //check if rotation is needed
            $rotate_image=0;   
            if(preg_match("/Orientation:.{0,2}(Lower Right)|(Upper Right)|(Lower Left)/i",$site_upload->exif_txt,$matches))
               $rotate_image = ($matches[3])?270:(($matches[2])?90:180);

            //Check if image size is good or not            
            $smaller = ($image_info[0]<$image_info[1])?$image_info[0]:$image_info[1];
            $bigger  = ($image_info[0]<$image_info[1])?$image_info[1]:$image_info[0];
            //0-none, 1-resize, 2-rotate, 3-both
            $transform = 0;
            //echo "TR: $transform <br>";
            $transform |= ($bigger > $config['max_image_width'] || $smaller > $config['max_image_height'])?1:0;
            //echo "TR: $transform <br>";
            $transform |= ($rotate_image>0)?2:0;
            //echo "TR: $transform <br>";
            if ($transform>0)
            //if ($image_info[0] > $config['max_image_width'] || $image_info[1] > $config['max_image_height'] || ($rotate_image>0))
               {
               $convert_options = init_convert_options();
               if (!$convert_options['convert_error']) {
                  $quality = (intval($config['auto_image_quality']) && intval($config['auto_image_quality']) <= 100) ? intval($config['auto_image_quality']) : 100;

                  if (!resize_image($src, $quality, $config['max_image_width'], $config['max_image_height'], 1, /*$config['max_image_height'],*/ $rotate_image, $transform)) {
                     $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name;
                     $uploaderror = 1;
                     }
                  }
               }
            }
         }
      //-------------------------------------------   
      //------------------------------------------- 
      //------------------------------------------- 


         if (!$uploaderror) {
           $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]) && isset($table_fields[$key])) {
               $additional_field_sql .= ", $key";
               $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
              }
            }
           }
           $image_exif = $site_upload->exif_txt;

           $current_time = time();
             $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.")";

            $result = $site_db->query($sql);
            $image_id = $site_db->get_insert_id();
            if ($result) {
              include_once(ROOT_PATH.'includes/search_utils.php');
              $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]);
               }
              }
              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, image_download_url".$additional_field_sql.")
                  VALUES
                  ($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url'".$additional_value_sql.")";
            $result = $site_db->query($sql);
           }

           if ($config['upload_notify'] == 1 && !$direct_upload) {
            include_once(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),
              "file_name" => $new_name,
              "cat_name" => $cat_cache[$cat_id]['cat_name'],
              "validation_url" => $validation_url,
              "site_name" => $config['site_name']
            ));
            $site_email->set_body("upload_notify", $config['language_dir_default']);
            $site_email->set_bcc($emails);
            $site_email->send_email();
           }

           $msg .= ucfirst($lang['image']).": <b>".stripslashes($image_name)."</b> (".$new_name.")";
           $msg .= " ".$lang['image_added_to'].get_category_path($cat_id, 1)."<br>";
           $msg .= (!$direct_upload) ? "<br />".$lang['new_upload_validate_desc'] : "";

           $file_extension = get_file_extension($new_name);
           $file = (is_remote($new_name)) ? $new_name : (($direct_upload) ? MEDIA_PATH."/".$cat_id."/".$new_name : MEDIA_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" => stripslashes($image_name),
            "width_height" => $width_height
           ));
           $media = $site_template->parse_template("media/".$file_extension);
           $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
               }
            }
         }//endif
         
         $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") {
  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 (!$sendprocess) {
//    $remote_media_file = "";
//    $remote_thumb_file = "";
    $image_name = "";
    $image_description = "";
    $image_keywords = "";
    $image_download_url = "";
    $image_allow_comments = 1;
  }

  $site_template->register_vars(array(
    "cat_id" => $cat_id,
    "cat_name" => ($cat_id != 0) ? htmlspecialchars($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),
//    "remote_media_file" => htmlspecialchars(stripslashes($remote_media_file)),
//    "remote_thumb_file" => htmlspecialchars(stripslashes($remote_thumb_file)),
    "image_name" => htmlspecialchars(stripslashes($image_name)),
    "image_description" => htmlspecialchars(stripslashes($image_description)),
    "image_keywords" => htmlspecialchars(stripslashes($image_keywords)),
    "image_allow_comments_yes" => ($image_allow_comments) ? " checked=\"checked\"" : "",
    "image_allow_comments_no" => (!$image_allow_comments) ? " checked=\"checked\"" : "",
    "image_download_url" => htmlspecialchars(stripslashes($image_download_url)),
    "lang_category" => $lang['category'],
    "lang_user_upload" => $lang['user_upload'],
    "lang_media_file" => $lang['media_file'],
    "lang_thumb_file" => $lang['thumb_file'],
    "lang_allowed_file_types" => $lang['allowed_mediatypes_desc'],
    "allowed_media_types" => str_replace(",",", ",$config['allowed_mediatypes']),
    "allowed_thumb_types" => "jpg, gif, png",
    "lang_max_filesize" => $lang['max_filesize'],
    "lang_max_imagewidth" => $lang['max_imagewidth'],
    "lang_max_imageheight" => $lang['max_imageheight'],
    "max_thumb_filsize" => $config['max_thumb_size']."&nbsp;".$lang['kb'],
    "max_thumb_imagewidth" => $config['max_thumb_width']."&nbsp;".$lang['px'],
    "max_thumb_imageheight" => $config['max_thumb_height']."&nbsp;".$lang['px'],
    "max_media_filsize" => $config['max_media_size']."&nbsp;".$lang['kb'],
    "max_media_imagewidth" => $config['max_image_width']."&nbsp;".$lang['px'],
    "max_media_imageheight" => $config['max_image_height']."&nbsp;".$lang['px'],
    "lang_image_name" => $lang['image_name'],
    "lang_description" => $lang['description'],
    "lang_keywords" => $lang['keywords_ext'],
    "lang_allow_comments" => isset($lang['allow_comments']) ? $lang['allow_comments'] : "",
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));

  if (!empty($additional_image_fields)) {
    $additional_field_array = array();
    foreach ($additional_image_fields as $key => $val) {
      if ($val[1] == "radio") {
        $value = (isset($HTTP_POST_VARS[$key])) ? intval($HTTP_POST_VARS[$key]) : 1;
        if ($value == 1) {
          $additional_field_array[$key.'_yes'] = " checked=\"checked\"";
          $additional_field_array[$key.'_no'] = "";
        }
        else {
          $additional_field_array[$key.'_yes'] = "";
          $additional_field_array[$key.'_no'] = " checked=\"checked\"";
        }
      }
      else {
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(stripslashes(trim($HTTP_POST_VARS[$key]))) : "";
      }
      $additional_field_array[$key] = $value;
      $additional_field_array['lang_'.$key] = $val[0];
    }
    if (!empty($additional_field_array)) {
      $site_template->register_vars($additional_field_array);
    }
  }
  if($action == "multiuploadform" || $action=="multiuploadimage")
     {
     $content = '<script language="Javascript"> var sid="'.$sid.'" </script> '.$site_template->parse_template("member_multiuploadform");
     }
  else
     {
     $content = $site_template->parse_template("member_uploadform");
     }
}

if ($action == "emailuser") {
  $txt_clickstream = $lang['profile'];
  $user_id = (isset($HTTP_POST_VARS[URL_USER_ID])) ? intval($HTTP_POST_VARS[URL_USER_ID]) : GUEST;
  $error = 0;

  if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
    show_error_page($lang['no_permission']);
    exit;
  }
  $subject = stripslashes(trim($HTTP_POST_VARS['subject']));
  $message = stripslashes(trim($HTTP_POST_VARS['message']));

  if ($subject == "" || $message == "") {
    $msg = $lang['lostfield_error'];
    $sendprocess = 1;
    $error = 1;
  }

  if (!$error) {
    if ($user_row = get_user_info($user_id)) {
      if (isset($user_row['user_showemail']) && $user_row['user_showemail'] == 0) {
        $content = $lang['invalid_user_id'];
      }
      else {
        $sender_user_name = ($user_info['user_level'] != GUEST) ? (isset($user_info['user_name']) ? $user_info['user_name'] : $lang['userlevel_user']) : $lang['userlevel_guest'];
        $sender_user_email = ($user_info['user_level'] != GUEST && isset($user_info['user_email'])) ? $user_info['user_email'] : $config['site_email'];

        // Start Emailer
        include(ROOT_PATH.'includes/email.php');
        $site_email = new Email();
        $site_email->set_from($sender_user_email, $sender_user_name);
        $site_email->set_to($user_row['user_email']);
        $site_email->set_subject($subject);
        $site_email->register_vars(array(
          "sender_user_name" => $sender_user_name,
          "sender_user_email" => $sender_user_email,
          "message" => $message,
          "site_name" => $config['site_name']
        ));
        $site_email->set_body("mailform_message", $config['language_dir']);
Title: Re: Upload multiple images via *.zip DONE
Post by: alti on February 13, 2006, 09:05:16 PM
hi!

I just implemented your mod in my gallery.

zip-Upload with admin user works well!

zip-upload with normal user gives the following error:
Error : PCLZIP_ERR_MISSING_FILE (-4) : Missing archive file './../data/media/2/XPreston_10.zip'
User has permission to upload and directupload.

the file doesn't exist on the server, but why is it working with admin users?
anyone has a hint for me?

thx!!
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on February 13, 2006, 10:32:05 PM
hey Alti,

just read your post and i can see whats happened (sort of) but i have no idea why...

heres my suggestion...
first of all, see if you can find the file that has uploaded somewhere else using ftp access (or any other method)

now, if you find the file, this means that the file is being uploaded to the wrong place (my assumption would be somewhere in the data/tmp_media/ folder but look everywhere else just incase) so that when the pcl script tries to unzip the folder, it cant find it.

If possilbe, could you tell me where the file is,
if you cant find the file anywhere, then maybe the file has not even uploaded, have you noticed the upload process is faster as a normal user?

please reply back with an answer thanx ;)
Title: Re: Upload multiple images via *.zip DONE
Post by: alti on February 15, 2006, 10:48:57 PM
hi!

sorry for my late response, had some troubles with my internet connection at home....

yes, the file is uploaded! you are completely right. it is in the data/tmp_media/ folder.

any fixes?

thx
Title: Re: Upload multiple images via *.zip DONE
Post by: alti on March 04, 2006, 03:36:44 PM
hey!

i have adopted the upload2.php script now by myself. maybe this information is usefull to anyone...

the following lines had to be changed as follows:
Code: [Select]
include('./pclzip.lib.php');
 $tmp_dir = ROOT_PATH.'data/tmp_media/';
 $uploadDir = ROOT_PATH.'data/media/'.$cat_id.'/';
 $archive = new PclZip($tmp_dir.$new_name);

i thought that it would also be nice if the admin gets an email when users add images to the gallery.
so this is the complete code replacement i have done:
Code: [Select]
include('./pclzip.lib.php');
 $tmp_dir = ROOT_PATH.'data/tmp_media/';
 $uploadDir = ROOT_PATH.'data/media/'.$cat_id.'/';
 $archive = new PclZip($tmp_dir.$new_name);
  if ($archive->extract(PCLZIP_OPT_PATH, $uploadDir,
                        PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
  die("Error : ".$archive->errorInfo(true));
 }else{

//send mail to admin (info that there are new images)
include(ROOT_PATH.'includes/email.php');
$myEmail = new Email();
//siteemail
$myEmail->set_to('webmaster@myGallerysite.net');
$myEmail->set_subject('new images in gallery');
$txt="Please check admin section of the gallery to insert users images. ";
$txt .= "from User: " .$user_info[$user_table_fields['user_name']];
$myEmail->set_simple_body($txt);
$myEmail->send_email();

don't forget to adopt the email address!!
this is for sure not the best solution but it was quick to implement and it works!

greetings!
Title: Re: Upload multiple images via *.zip DONE
Post by: dipunm on July 16, 2006, 08:22:06 PM
I GOT SOME REALLY BAD NEWS

unfortunately, my site got taken down n i dont use the site anymore so testing is not doable... i cant afford to get another site so i cant b able to do this anymore... soory if any1 out there can finish my work or see wat i did and make their own that would bv good... for all the ppl out there who need it...   :D and bye :cry: