Jump to content


etogalThumbs


  • You cannot reply to this topic
17 replies to this topic

#1 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 07 June 2007 - 09:39 AM

OK I thought that I would try to get really familiar with etogalThumbs so that I know what it is really capable of before I go off and develop anything else.

First of all Mike F. It looks really great, you have obviously put a great deal of thought and time into the development of it, thank-you for sharing it with us.

I'm systematically trialling each of the variables passable by snippet call to see what it can do (and can't do).

So far so good, however, my first error was by trying to pass ?resize=200 which randomly returns an error:

Quote

PHP error debug
Error: Division by zero
Error type/ Nr.: Warning - 2
File: /home/www/mysite.com./index.php(506) : eval()'d code
Line: 209

This could have been caused by the previous calls which worked fine but could have [randomly] escaped error before I trialled the next variable call on the same page (not very scientific I know). However, in trying to understand the error, and looking at line 209...

Does this mean that I MUST have title and description filled for this variable to work?

EtoGalThumbs1.2prelim testing page here.

This page usually results in an error within 10 refreshes.

Edited by Cris D., 07 June 2007 - 09:56 AM.


#2 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2007 - 10:41 AM

Thanks, it got written when I got fed up of writing lots of similar snippets for similar uses, all with the same basic logic. I could never remember which one did exactly what, and which was the most recent variant (used on several sites). It seemed worth putting the common code in a parameterised wrapper. It then grw in response to requests from other users, with the common code getting increasingly complex.


I don't understand your error. The released snippet has the code
//	$title = stripslashes($pic['title']);
	$desc = stripslashes($pic['descr']);
	$title = $pic['title']; //leave slashes in to try to avoid problems in html
//	$desc = $pic['descr'];
in lines 207-210, none of which should be capable of returning a 'divide by zero error'. Are you sure its coming from this snippet and not something else?

If you don't have a title or description set, then $title and/or $desc should just end up containing an empty string. They've often been used with no descriptions (its sometimes hard to persuade artists that they need a description on the web!)

Are you still running on the free server that was giving problems sometimes while loading images?

#3 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2007 - 11:03 AM

can you try replacing (a few lines earlier)
	if (isset($resize)) {
	  if ($imgsize[0]>$imgsize[1]){
		$imgsize[1]=$resize*$imgsize[1]/$imgsize[0];
		$imgsize[0]=$resize;
	  } else {
		$imgsize[0]=$resize*$imgsize[0]/$imgsize[1];
		$imgsize[1]=$resize;
	  }
	}

with
	if (($imgsize[0]<1)||($imgsize[1]<1) ) {
	  $return .= "
<br /> image error in file $tn_file size[0],[1] = ".$imgsize[0].",".$imgsize[1]." <br />
";
	} else if (isset($resize)) {
	  if ($imgsize[0]>$imgsize[1]){
		$imgsize[1]=$resize*$imgsize[1]/$imgsize[0];
		$imgsize[0]=$resize;
	  } else {
		$imgsize[0]=$resize*$imgsize[0]/$imgsize[1];
		$imgsize[1]=$resize;
	  }
	}
please and see what happens?

#4 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 07 June 2007 - 11:17 AM

I still have the same server, however, the divide by zero error has only been seen when running this snippet.

I imagine that the divide by zero was part of the resize code...
Line196:
   if (isset($resize)) {
	  if ($imgsize[0]>$imgsize[1]){
		$imgsize[1]=$resize*$imgsize[1]/$imgsize[0];
		$imgsize[0]=$resize;
	  } else {
		$imgsize[0]=$resize*$imgsize[0]/$imgsize[1];
		$imgsize[1]=$resize;
	  }
	}
	$size = 'width="'.$imgsize[0].'" height="'.$imgsize[1].'"';
Line 209 (blank)
Line 210
//	$title = strip

I have deleted all etothumb snippets from the page EXCEPT for the "resize" snippet call

My guess is the the line 198 is creating the error:
 $imgsize[1]=$resize*$imgsize[1]/$imgsize[0];

(I might be wrong).

The same page still applies: here.

Edited by Cris D., 07 June 2007 - 11:20 AM.


#5 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2007 - 11:20 AM

please see post immediately above!

#6 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 07 June 2007 - 11:27 AM

Yes Mike,

A fairly good fix (your on to it), however, this replaces the error message with no output.

What is your next suggestion to ensure something is returned?

#7 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2007 - 11:57 AM

View PostCris D., on Jun 7 2007, 12:27 PM, said:

Yes Mike,

A fairly good fix (your on to it), however, this replaces the error message with no output.

What is your next suggestion to ensure something is returned?
I think the fault lies with your server, sorry.

I've cycled through your link above until it delivered a page with the image missing, and then looked at the html source. It wasn't caused by the same error. The html source was, as far as I can see, correct. The relevant section has an image specified, with title, description, and sizes. The image exists (checked by viewing it directly through the browser), but doesn't seem to be returned by the server within the page.

I've attached the contents of the img element Attached File  snip2.txt   208bytes   6 downloads (the forum won't let me upload the larger HTML context)

(I'd suggest using it without the resize parameter unless you really needed it, except its impossible to tell if similar problems might arise at random elsewhere.)

Edited by mikef, 07 June 2007 - 12:00 PM.


#8 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2007 - 12:07 PM

PS:
there was an error in the replacement code - $return should have been $returnstring and would then output a message if either width or height were 0 pixels (or less!). However, the width and height were returned in the image parameter string, and were sensible, so that wasn't the cause of no output in this case. (thats why i said the error was not the same one)

#9 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 07 June 2007 - 12:33 PM

OK Thanks Mike,

I'll see what I can do with getting a reliable (paid host) server.

Cris D.

#10 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2007 - 01:51 PM

I've run a similar test on my own server on a live site, going through 100 iterations with no errors.

I've also added some more monitoring code to check on one other thing thats relatively easy to add a check on (dumping the contents of the array of picture information retrieved from the database into an HTML comment in the displayed page to check that everything comes across correctly, and survives a shuffle). The only effect of this on my server is to make it create pages much more slowly ... there are over three hundred images on the server.

I can send you a copy of taht snippet if you want to use it to make more checks, but guessing what might be going wrong is hard!

#11 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 08 June 2007 - 01:22 AM

Yes please.

#12 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 08 June 2007 - 12:45 PM

Firstly, I can live without the resize function, so if this is not woth the time, don't worry. I'm more intruiged than anything. These are the two errors I am getting with your test snippet...

Quote

image error in file size[0],[1] = ,

and more often...

Quote

Error: getimagesize(assets/galleries/0/tn_): failed to open stream: No such file or directory
Error type/ Nr.: Warning - 2
File: /home/www/mysite.com/index.php(506) : eval()'d code
Line: 212

Strange that this is looking for gallery "0". I have pumped up the number of pictures to 4 to try and force the error more often, and it returns an error approx. 1 in 3 cycles. here

If this gives you more to go on great, if it is too hard, let me know and I'll just use the snippet without the resize function.

#13 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 08 June 2007 - 01:13 PM

View PostCris D., on Jun 8 2007, 08:45 AM, said:

Firstly, I can live without the resize function, so if this is not woth the time, don't worry. I'm more intruiged than anything. These are the two errors I am getting with your test snippet...
and more often...
Strange that this is looking for gallery "0". I have pumped up the number of pictures to 4 to try and force the error more often, and it returns an error approx. 1 in 3 cycles. here

If this gives you more to go on great, if it is too hard, let me know and I'll just use the snippet without the resize function.
That error indicates to me that you might have something like a hidden file within the target directory, or some other anomaly, and you may need to add a conditional clause into the mix in order to avoid the error by making sure the data is valid... Either that or you need to clean up the directory itself... Just a thought...

#14 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 08 June 2007 - 01:33 PM

How right you are Ralph.
One (empty) gallery created but unused (displays children)
One picture with a ' in the name which was deleted in etogal, but somehow remained in the gallery.

That cleaned out and it's all good!

#15 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 08 June 2007 - 02:20 PM

No, its not a problem with the directory, as the data is all picked from the database (apart from determining the size of the image, which is determined by looking at the file, not stored).

Looking at the HTML source of the pages, the errors are in the data retrieved from the database, and are presumably actually in the database, as the data retrieved in two different runs are identical.

There are a significant number of empty rows in the table (these give gallery id=0). Can you check the table using phpmyadmin, please?

This would mean that its not the resize option itself that is the problem, but the data, and so the problem will also occur from time to time when other options (or none) are used.

If my diagnosis is right, then setting the gal parameter in the snippet call should avoid the problem, as would deleting all rows in the database table that have gal_id equal to zero. Can you check that setting gal to a list of all the legitimate gallery ids does in fact fix this, please?

Thanks for helping get to the bottom of this!

#16 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 08 June 2007 - 05:22 PM

I've written a small snippet to check the contents of the database, and report errors. Its very simple minded - all it tries to do is check for entries with a gallery number of zero (and report additionally any of these that have filenames), and check for entries where either file or thumbnail can't be found.

CrisD, could you try it on your database please?
(set the table name and gallery location are correct for your setup, and then just place in a page and show the page)

thanks,
mike

Attached File  EtoGalCheck.php   1.88K   2 downloads

#17 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 08 June 2007 - 09:58 PM

Strange that I wasn't having problems after deleting the empty gallery folder. That's random for you! Yes Mike you are right too...27 rows with gal_id set to "0" ...empty rows. I have no idea of how they got there, so I'll keep an eye on it. Thanks for all your help.

#18 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 08 June 2007 - 10:34 PM

View PostCris D., on Jun 8 2007, 10:58 PM, said:

Strange that I wasn't having problems after deleting the empty gallery folder. That's random for you! Yes Mike you are right too...27 rows with gal_id set to "0" ...empty rows. I have no idea of how they got there, so I'll keep an eye on it. Thanks for all your help.
My guess is that they appeared from the uploads that failed. One of the drawbacks of using a SQL DBMS that doesn't have usable transaction support, especially in an environment where tasks may just time out and be aborted. Its possible the etogal upload code could be reordered to get round the problem, but I'm loathe to touch it now - it works, even with versions of MySQL 3 and is tested on a wide range of servers (by the early users!) and I simply don't have access to that many servers, or (nowadays) the time I had then, to test on them.

I'll make a mod to EGThumbs (when I have time) to ensure that gallery 0 lines aren't returned, and I'll make the EGCheck snippet available with the others too. If you don't see these by the end of the month, remind me!

and thanks to you, too, for running the various special snippets so i could see what was really going on, without which I couldn't have got this far in sorting it out.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users