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: Batch Add Files times out with large videos  (Read 2011 times)

0 Members and 1 Guest are viewing this topic.

stimpy2k

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Batch Add Files times out with large videos
« on: January 24, 2014, 02:24:46 am »

Hello. I am trying to use some large videos (~5-10gb) in my CPG installation. I upload them via FTP, and I'm trying to add them through Batch Add Files, but the system chokes with the error...
Quote
Fatal error: Maximum execution time of 30 seconds exceeded in /home/xxxMyCpgDirectoryxxx/include/functions.inc.php on line 5459

It does this regardless of if I use Browsable interface, or Display preview thumbnails. I get the error no matter what.

Now, I'm no web developer, but I cracked open functions.inc.php and checked out line 5459. It reads...
Code: [Select]
$size = getimagesize($image);
It seems that it's trying to crack open these massive files and determine their dimensions. I suspect, even if it were successful in churning through the whole file, it likely wouldn't be able to pull out actual dimensions anyway, as I assume it's expecting an image, not a video.

On a hunch, I modified line 5396 from...
Code: [Select]
function cpg_getimagesize($image, $force_cpg_function = false)
...to...
Code: [Select]
function cpg_getimagesize($image, $force_cpg_function = true)
Tada! The Batch Add Files page loads great and allows me to select and add my large video files. ...however, now any images within the gallery are misshaped, so obviously this isn't really a fix.

Again, I'm not web developer, and I'm hardly able to pick apart the PHP, but it seems like the function, or whatever is calling the function, ought to first check the file extension of the file it's looking at. If that extension is registered as a video clip, it should just skip over this step, cause it's likely not going to get any useful information anyway (maybe I'm wrong?).

Like I said, I don't really know what I'm talking about here, so I of course defer to the actual CPG developers regarding what a fix ought to be, but I at least wanted to bring the issue up. It would be great if I could Batch Add these large videos.

Thanks in advance for your help.
-= Brandon.
Logged

stimpy2k

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Batch Add Files times out with large videos
« Reply #1 on: January 27, 2014, 02:31:26 am »

...any thoughts?  ...anybody?
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 785
    • GMC Design Photo Gallery
Re: Batch Add Files times out with large videos
« Reply #2 on: January 27, 2014, 03:16:27 am »

Not an area I've done a lot with... but looking at your description and reviewing the code in that area:
$force_cpg_function controls whether a call is made to the php provided getimagesize function (or system modified version) - or if the custom cpg function should be used... the default of "$force_cpg_function = false" uses the php/system getimagesize...

From your change and reported results, it appears the custom cpg function is desired for your video file - but not for everything...

I would suggest the following 'band-aid' based on those statements... I'll defer to others whether that is the best place to address.

In  functions.inc.php:
Find:
Code: [Select]
function cpg_getimagesize($image, $force_cpg_function = false)
{
    if (!function_exists('getimagesize') || $force_cpg_function) {
and replace with: ** Adjust the array as needed to include your desired video format(s) **
Code: [Select]
function cpg_getimagesize($image, $force_cpg_function = false)
{
    if (in_array(strrchr($image , '.' ), array('.avi', '.mov', '.mpg', '.mpeg')) ) {
        $force_cpg_function = true;
    }
    if (!function_exists('getimagesize') || $force_cpg_function) {

I have no means of testing this - but the intent is to leave the default option in place for everything except your video file format(s).  The code extracts from the image name the string starting with the last period - ie: the filetype - and compares it to see if it is in an array of values...  If so - change behavior to use custom cpg function.

A more permanent solution might consider all possible movie formats in cpg_filetypes - or perhaps there is a better place/way to approach this.

Give it a try and let me know how it works.
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Batch Add Files times out with large videos
« Reply #3 on: January 27, 2014, 01:23:52 pm »

Of course stimpy2k is right to skip cpg_getimagesize for non-image files. I'll have a closer look and try to fix it as soon as possible.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Batch Add Files times out with large videos
« Reply #4 on: January 27, 2014, 01:44:50 pm »

I just checked the code and the issue shouldn't occur while actually adding the file to the gallery. I assume it happens after you selected the file path, on the page where Coppermine let select you the album and displays thumbnails for picture files, right?

If so, I assume the following code block causes the issue:
Code: (searchnew.php) [Select]
        if ($CONFIG['display_thumbs_batch_add'] == 1) {
          $return .= <<<EOT
                        <img src="showthumb.php?picfile=$pic_url&amp;size=48" class="thumbnail" border="0" alt="" />
EOT;
        }
as all other occurrences of cpg_getimagesize are wrapped into is_image conditions.
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.