Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: A little functionality hack for batch upload  (Read 22954 times)

0 Members and 1 Guest are viewing this topic.

klingsor

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
A little functionality hack for batch upload
« on: July 12, 2005, 06:42:40 pm »

Hi people,

Currently I'm finishing the setup of a small image bank. We upload the pics with the batch utility, using one folder per each image owner.

As some owners can have more of 5,000 pics, it's tiring to open the batch upload and wait until the page finishes to load, only to search at the bottom for, say 300 new pics.

For that reason I have made the following change to searchnew.php (1.3.3)

Now only shows the new pics and doesn't shows the previously uploaded pics. As I have saw some requests of people for this I decided to publish it here:

Search for function picrow:

Code: [Select]
function picrow($picfile, $picid, $albid)
{
    global $CONFIG, $expic_array;

    $encoded_picfile = base64_encode($picfile);
    $picname = $CONFIG['fullpath'] . $picfile;
    $pic_url = urlencode($picfile);
    $pic_fname = basename($picfile);
    $pic_dirname = dirname($picname);

    $thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname;
    if (file_exists($thumb_file)) {
        $thumb_info = getimagesize($picname);
        $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48);
        $img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" />';
    } elseif (is_image($picname)) {
        $img = '<img src="showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0">';
    } else {
        $file['filepath'] = $pic_dirname.'/'; //substr($picname,0,strrpos($picname,'/'))
        $file['filename'] = $pic_fname;
        $filepathname = get_pic_url($file,'thumb');
        //$mime_content = get_type($picname);
        //$extension = file_exists("images/thumb_{$mime_content['extension']}.jpg") ? $mime_content['extension']:$mime_content['content'];
        //$img = '<img src="images/thumb_'.$extension.'.jpg" class="thumbnail" width="48" border="0">';
        $img = '<img src="'.$filepathname.'" class="thumbnail" width="48" border="0">';
    }

    if (filesize($picname) && is_readable($picname)) {
        //$fullimagesize = getimagesize($picname); COMMENTED OUT FOR VIDEO SUPPORT
        $winsizeX = ($fullimagesize[0] + 16);
        $winsizeY = ($fullimagesize[1] + 16);

        //$checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked';

        $checked = isset($expic_array[$picfile]) ? '' : 'checked';

        return <<<EOT
        <tr>
                <td class="tableb" valign="middle">
                        <input name="pics[]" id="picselector" type="checkbox" value="$picid" $checked />
                        <input name="album_lb_id_$picid" type="hidden" value="$albid" />
                        <input name="picfile_$picid" type="hidden" value="$encoded_picfile" />
                </td>
                <td class="tableb" valign="middle" width="100%">
                        <a href="javascript:;" onClick= "MM_openBrWindow('displayimage.php?&fullsize=1&picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')">$pic_fname</a>
                </td>
                <td class="tableb" valign="middle" align="center">
                        <a href="javascript:;" onClick= "MM_openBrWindow('displayimage.php?&fullsize=1&picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')"><img src="images/spacer.gif" width="1" height="48" alt="" border="0" />$img<br /></a>
                </td>
        </tr>
EOT;
    } else {
        $winsizeX = (300);
        $winsizeY = (300);
        return <<<EOT


Now replace with:


Code: [Select]
function picrow($picfile, $picid, $albid)
{
    global $CONFIG, $expic_array;

    $encoded_picfile = base64_encode($picfile);
    $picname = $CONFIG['fullpath'] . $picfile;
    $pic_url = urlencode($picfile);
    $pic_fname = basename($picfile);
    $pic_dirname = dirname($picname);

    $thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname;
    if (file_exists($thumb_file)) {
        $thumb_info = getimagesize($picname);
        $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48);
        $img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" />';
    } elseif (is_image($picname)) {
        $img = '<img src="showthumb.php?picfile=' . $pic_url . '&size=48" class="thumbnail" border="0">';
    } else {
        $file['filepath'] = $pic_dirname.'/'; //substr($picname,0,strrpos($picname,'/'))
        $file['filename'] = $pic_fname;
        $filepathname = get_pic_url($file,'thumb');
        //$mime_content = get_type($picname);
        //$extension = file_exists("images/thumb_{$mime_content['extension']}.jpg") ? $mime_content['extension']:$mime_content['content'];
        //$img = '<img src="images/thumb_'.$extension.'.jpg" class="thumbnail" width="48" border="0">';
        $img = '<img src="'.$filepathname.'" class="thumbnail" width="48" border="0">';
    }

    if (filesize($picname) && is_readable($picname)) {
        //$fullimagesize = getimagesize($picname); COMMENTED OUT FOR VIDEO SUPPORT
        $winsizeX = ($fullimagesize[0] + 16);
        $winsizeY = ($fullimagesize[1] + 16);

        //$checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked';

        $checked = isset($expic_array[$picfile]) ? '' : 'checked';

    if ($checked == 'checked'){
        return <<<EOT
        <tr>
                <td class="tableb" valign="middle">
                        <input name="pics[]" id="picselector" type="checkbox" value="$picid" $checked />
                        <input name="album_lb_id_$picid" type="hidden" value="$albid" />
                        <input name="picfile_$picid" type="hidden" value="$encoded_picfile" />
                </td>
                <td class="tableb" valign="middle" width="100%">
                        <a href="javascript:;" onClick= "MM_openBrWindow('displayimage.php?&fullsize=1&picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')">$pic_fname</a>
                </td>
                <td class="tableb" valign="middle" align="center">
                        <a href="javascript:;" onClick= "MM_openBrWindow('displayimage.php?&fullsize=1&picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')"><img src="images/spacer.gif" width="1" height="48" alt="" border="0" />$img<br /></a>
                </td>
        </tr>
EOT;
}
    } else {
        $winsizeX = (300);
        $winsizeY = (300);
        return <<<EOT



It uses the checked variable to decide if a picture has been uploaded (it must has a thumbnail)

I hope that it can be useful for some of you.

Regards,

Klingsor
« Last Edit: September 15, 2005, 07:11:16 am by TranzNDance »
Logged

JasonB

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 37
    • The Big Squiff
Re: A little functionality hack for batch upload
« Reply #1 on: August 07, 2005, 06:40:07 am »

Nice!
Logged

Hein Traag

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: nl
  • Offline Offline
  • Gender: Male
  • Posts: 2166
  • A, B, Cpg
    • Personal website - Spintires.nl
Re: A little functionality hack for batch upload
« Reply #2 on: August 08, 2005, 06:25:34 pm »

I thank you. Just what i needed.

Just one question. Can you perhaps add a option one the searchnew page which you can select if you do wish to see the entire list ?
Logged

tricoven

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: A little functionality hack for batch upload
« Reply #3 on: August 11, 2005, 05:20:51 pm »

omg this hack f*cking rocks!!!
« Last Edit: August 11, 2005, 06:29:59 pm by tricoven »
Logged

Yukino

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
Re: A little functionality hack for batch upload
« Reply #4 on: September 15, 2005, 05:56:21 am »

just so you know i run version 1.4.1 and i just applied this hack and it works with it great. 

u r tha best!
Logged

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: A little functionality hack for batch upload
« Reply #5 on: September 15, 2005, 07:11:44 am »

just so you know i run version 1.4.1 and i just applied this hack and it works with it great.

u r tha best!
Thank you for letting us know.
Logged

falarious

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 46
Re: A little functionality hack for batch upload
« Reply #6 on: December 28, 2005, 12:10:49 am »

HOLY MOTHER and FATHERS!!!!  :o

This is the best hack in the world!!  ;D ;D :D
Logged

tmpicture

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 29
Re: A little functionality hack for batch upload
« Reply #7 on: February 09, 2006, 01:00:09 am »

Hi,

Has anybody improved or extended this hack? And what about that...
Quote
Just one question. Can you perhaps add a option one the searchnew page which you can select if you do wish to see the entire list ?


Thanks, Thomas
Logged

n3n

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 173
Re: A little functionality hack for batch upload
« Reply #8 on: May 26, 2006, 03:56:52 pm »

Very nice ! Tnx for the work.
Logged

wirewolf

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 35
    • Ship Modeling Forum
Re: A little functionality hack for batch upload
« Reply #9 on: June 15, 2006, 01:19:11 am »

It's the simple things that make one happy!  :) Just tried it on cpg version: 1.4.8. Works like a charm!
Thank you Klingsor.
John

lamama

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 404
Re: A little functionality hack for batch upload
« Reply #10 on: November 18, 2006, 10:28:31 am »

This is a fine piece of code.

I expierenced a lot of "out of memory"-errors (leading to Apace Error 503's) while batch-adding ca. 190 big-sized pics (up to 2 megapixels, 150-450 kb per pic) to an album that already contained 400 pics.

With this mod, the batch-add worked fine and used only half of the servers memory while it was running (compared to the regular code that just stopped working during batch-add).



Logged

cavok

  • Coppermine regular visitor
  • **
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 93
Re: A little functionality hack for batch upload
« Reply #11 on: November 09, 2010, 04:42:50 pm »

Hello.
Is it possible to do the same for 1.5.8 version ?
Logged
Coppermine 1.5.22 hosting by Free

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: A little functionality hack for batch upload
« Reply #12 on: November 10, 2010, 08:43:02 am »

Logged
Pages: [1]   Go Up
 

Page created in 0.04 seconds with 22 queries.