A little functionality hack for batch upload A little functionality hack for batch upload
 

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]

Main Menu

A little functionality hack for batch upload

Started by klingsor, July 12, 2005, 06:42:40 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

klingsor

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:


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:



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

JasonB


Hein Traag

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 ?

tricoven

#3
omg this hack f*cking rocks!!!

Yukino

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!

Tranz

Quote from: Yukino 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!
Thank you for letting us know.

falarious

HOLY MOTHER and FATHERS!!!!  :o

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

tmpicture

Hi,

Has anybody improved or extended this hack? And what about that...
QuoteJust 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

n3n


wirewolf

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

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).




cavok

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

Joachim Müller