Page 1 of 1

[Bug] Gallery Component - Frontend Multiple Upload

Posted: 01 Sep 2011, 17:39
by mccool1985
Hi,

Wanted to inform you that I have posted a message in this thread: viewtopic.php?f=1&t=15434

Basically, the code in geo.php needs to be rewritten in order to prevent division by zero errors. The OP there had a problem with multiple uploads, just like me. Did a little hack in the code to prevent this division by zero error, but I think you guys need to fix this bug for the next update.

If I can be of any help, I am happy to help. Keep up the good work, I love the Phoca components :D

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 01 Sep 2011, 17:43
by mccool1985
Below here my reply plus quick workaround.
-----------------------------------------------------------------------------
Hi, i had the same problem and did what was suggested, debugging it with Firebug.

It gave me an error in \administrator\components\com_phocagallery\libraries\phocagallery\geo\geo.php (division by zero) on line 63

It seems it tries to get the Location out of EXIF data. So when these coordinates are in there and are set to 0, you have a problem. In the code they did not think about this clearly. Anyway, after the first image is uploaded, it tries to get the location out of it, and exits after it receives multiple division by zero errors, that's why the uploader hangs after the first upload.

Did a little hack in the code, quick workaround

--- WORKAROUND ---

Find this code on line 47 in geo.php:

Code: Select all

if (!function_exists('exif_read_data')) {
		return array('latitude' => 0, 'longitude' => 0);
	} else {
	  
		$exif 		= exif_read_data($fileOriginal, 0, true);
		$GPSLatDeg 	= explode('/',$exif['GPS']['GPSLatitude'][0]);
		$GPSLatMin 	= explode('/',$exif['GPS']['GPSLatitude'][1]);
		$GPSLatSec 	= explode('/',$exif['GPS']['GPSLatitude'][2]);
		$GPSLonDeg 	= explode('/',$exif['GPS']['GPSLongitude'][0]);
		$GPSLonMin 	= explode('/',$exif['GPS']['GPSLongitude'][1]);
		$GPSLonSec 	= explode('/',$exif['GPS']['GPSLongitude'][2]);

		$lat = $GPSLatDeg[0]/$GPSLatDeg[1]+
			($GPSLatMin[0]/$GPSLatMin[1])/60+
			($GPSLatSec[0]/$GPSLatSec[1])/3600;
		$long = $GPSLonDeg[0]/$GPSLonDeg[1]+
			($GPSLonMin[0]/$GPSLonMin[1])/60+
			($GPSLonSec[0]/$GPSLonSec[1])/3600;
		// $exif['GPS']['GPSLatitudeRef'] SHIROTA: N=+; S=-
		// $exif['GPS']['GPSLongitudeRef'] DOLGOTA: E=+; W=-
		if($exif['GPS']['GPSLatitudeRef'] == 'S'){$lat=$lat*(-1);}
		if($exif['GPS']['GPSLongitudeRef'] == 'W'){$long=$long*(-1);}

		return array('latitude' => $lat, 'longitude' => $long);
	  }
Above this code-block, so on line 46, just insert this code:

Code: Select all

return array('latitude' => 0, 'longitude' => 0);
It basically rips out the option to get a location out of the EXIF data. I'm sure there are far better solutions for this, maybe rewrite the code with some type of try clause in it. I'll let the developers do their work, maybe someone has a suggestion to rewrite the formulas for $lat en $long to make them work (prevent it is divided by zero)

Anyway, for me the above did the trick (and I don't use the EXIF and GPS stuff, so I don't care). After I changed the code my HTML5 uploader worked like a charm!

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 06 Sep 2011, 22:22
by Jan
Hi, this will be solved in 3.0.3 version:

Code: Select all

if (isset($exif['GPS']['GPSLatitude'][0])) {$GPSLatDeg 		= explode('/',$exif['GPS']['GPSLatitude'][0]);}
		if (isset($exif['GPS']['GPSLatitude'][1])) {$GPSLatMin 		= explode('/',$exif['GPS']['GPSLatitude'][1]);}
		if (isset($exif['GPS']['GPSLatitude'][2])) {$GPSLatSec 		= explode('/',$exif['GPS']['GPSLatitude'][2]);}
		if (isset($exif['GPS']['GPSLongitude'][0])) {$GPSLongDeg 	= explode('/',$exif['GPS']['GPSLongitude'][0]);}
		if (isset($exif['GPS']['GPSLongitude'][1])) {$GPSLongMin 	= explode('/',$exif['GPS']['GPSLongitude'][1]);}
		if (isset($exif['GPS']['GPSLongitude'][2])) {$GPSLongSec 	= explode('/',$exif['GPS']['GPSLongitude'][2]);}
		
		
		if (isset($GPSLatDeg[0]) && isset($GPSLatDeg[1]) && (int)$GPSLatDeg[1] > 0
		 && isset($GPSLatMin[0]) && isset($GPSLatMin[1]) && (int)$GPSLatMin[1] > 0
		 && isset($GPSLatSec[0]) && isset($GPSLatSec[1]) && (int)$GPSLatSec[1] > 0) {

			$lat = $GPSLatDeg[0]/$GPSLatDeg[1]+
				($GPSLatMin[0]/$GPSLatMin[1])/60+
				($GPSLatSec[0]/$GPSLatSec[1])/3600;
				
			if(isset($exif['GPS']['GPSLatitudeRef']) && $exif['GPS']['GPSLatitudeRef'] == 'S'){$lat=$lat*(-1);}
			
		
		}
		
		 
		if (isset($GPSLongDeg[0]) && isset($GPSLongDeg[1]) && (int)$GPSLongDeg[1] > 0
		 && isset($GPSLongMin[0]) && isset($GPSLongMin[1]) && (int)$GPSLongMin[1] > 0
		 && isset($GPSLongSec[0]) && isset($GPSLongSec[1]) && (int)$GPSLongSec[1] > 0) {

	
			$long = $GPSLongDeg[0]/$GPSLongDeg[1]+
				($GPSLongMin[0]/$GPSLongMin[1])/60+
				($GPSLongSec[0]/$GPSLongSec[1])/3600;
				
			if(isset($exif['GPS']['GPSLongitudeRef']) && $exif['GPS']['GPSLongitudeRef'] == 'W'){$long=$long*(-1);}

		}
		


		return array('latitude' => $lat, 'longitude' => $long);

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 07 Sep 2011, 16:34
by mccool1985
Nice job, could learn a lot from this little piece of code :). Will be waiting for the next release, it will be integrated in the next version of arhdcomprix.nl (My website, dedicated to my fraternity, Dutch)

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 07 Oct 2011, 14:51
by Jan

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 24 Jan 2012, 18:00
by NoelFielder
Is this fixed now before I get started?

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 24 Jan 2012, 23:34
by SonRiab
Phoca Gallery has the version number 3.1.2 now so this should be fixed, yes.

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 14 Sep 2012, 22:53
by Canopus
Hello

I use the last Phoca galery (3.2.1) and the issue is still occurs :

Any multi-upload method selected make the error "Flash is not installed on your browser" *

I use Firefox 15 and French phoca translation.

Any help will be welcome.

Canopus

Re: [Bug] Gallery Component - Frontend Multiple Upload

Posted: 28 Sep 2012, 00:50
by Jan
Hi, testing now without any problem, do you get the problem with chrome too? Check if you don't have any javascript error on your site? Maybe such error prevents from running the javascript properly :idea:

Jan