[Bug] Gallery Component - Frontend Multiple Upload

mccool1985
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 01 Sep 2011, 03:37

[Bug] Gallery Component - Frontend Multiple Upload

Post 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
mccool1985
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 01 Sep 2011, 03:37

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post 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!
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post 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);
If you find Phoca extensions useful, please support the project
mccool1985
Phoca Newbie
Phoca Newbie
Posts: 4
Joined: 01 Sep 2011, 03:37

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post 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)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post by Jan »

If you find Phoca extensions useful, please support the project
NoelFielder
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 24 Jan 2012, 17:58

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post by NoelFielder »

Is this fixed now before I get started?
SonRiab
Phoca Professional
Phoca Professional
Posts: 258
Joined: 02 Jun 2011, 09:29
Contact:

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post by SonRiab »

Phoca Gallery has the version number 3.1.2 now so this should be fixed, yes.
Canopus
Phoca Member
Phoca Member
Posts: 11
Joined: 10 Jan 2011, 23:25

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post 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
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [Bug] Gallery Component - Frontend Multiple Upload

Post 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
If you find Phoca extensions useful, please support the project
Post Reply