Recent Topics

is ob_start my friend?

Started by on Apr 19, 2007 – Contents updated: Apr 19, 2007

Apr 19, 2007 19:07    

Look I don't know very much about how this whole "php mysql" stuff happens. I'm kinda hip to how b2evolution does stuff, but not really HOW it does it. So everything I've done with this application has been to either make subtle changes to something that exists, or to piece together a few different things into something new. No actual creation of code, if ya dig what I mean.

So now I've got this problem. I dig on the visiglyph thing. It's a graphic image that, more or less, comes from your commenter's IP address. It could be the visitors name or their email address, but since it started as IP address that's what I made a hack for b2evolution use. It worked just dandy in 1.9.2, but fails horribly in 1.9.3 - and I've no clue where to begin fixing it.

http://wonderwinds.com/hackblog.php/2007/02/12/visiglyphs_for_b2evolution_1_9_2 is what it was and shows that it worked. Back then! Now, except for I turned it off, it generates a bunch of errors when someone leaves a comment. Here is the text it gave a commenter recently, and it is typical of what you'll see if I turn it back on and you leave a comment on my blog:

Warning: imagepng() [function.imagepng]: Unable to open '/home/wonderw/public_html/zzzz192/rsc/visiglyphs/caa4e68a03cdaf621b1198755a1e45c1.png' for writing in /home/wonderw/public_html/inc/_misc/_visiglyph.class.php on line 120

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/htsrv/comment_post.php on line 288

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/htsrv/comment_post.php on line 289

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/htsrv/comment_post.php on line 290

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/inc/_misc/_misc.funcs.php on line 2851

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/inc/_misc/_misc.funcs.php on line 2852

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/inc/_misc/_misc.funcs.php on line 2853

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/inc/_misc/_misc.funcs.php on line 2854

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/inc/_misc/_misc.funcs.php on line 2931

Warning: Cannot modify header information - headers already sent by (output started at /home/wonderw/public_html/inc/_misc/_visiglyph.class.php:120) in /home/wonderw/public_html/inc/_misc/_misc.funcs.php on line 2933

That doesn't tell me much, except for the header is already started and isn't allowed to start again. So to my tiny little brain I think ob_start() is gonna be my friend, but I don't really understand what to do with ob_start and ob_end. Other than look at the class file around line 120 and see what it is all about...

	function visidisplay(){

		if ($this->resize > 0){ // if we need to resample down
			$this->visisize = $this->resize;
			$imgsizeR = $this->visisize*3;

			$imresize = imagecreatetruecolor($imgsizeR,$imgsizeR);
			$backgroundcolor = imagecolorallocate($imresize, $this->bgr, $this->bgg, $this->bgb);
			imagecopyresampled ( $imresize, $this->glyph, 0, 0, 0, 0, $imgsizeR, $imgsizeR, $this->imgsize, $this->imgsize );
			// ImageColorTransparent($imresize,$backgroundcolor); // FIXME transparency feature not finished.
			imagepng($imresize,VISIUPLOAD.$this->visip.'.png', 0);
		} else {
			imagepng($this->glyph,VISIUPLOAD.$this->visip.'.png', 0); // this is line 120
		}
	}

I'm pretty sure line 118 would freak out if "$this->resize > 0" was true, so it seems to me that somehow I need to stash this header output - somehow - so that it would not conflict with b2evolution's header output.

Anyway if anyone has a clue your help will be greatly appreciated.

Apr 19, 2007 19:22

I assume that you've chmod'd /<huge path>/zzzz192/ to a reasonable number for the script to write files?

... don't ask me for a reasonable number though ... cos all mine involve doubles, the underside of tables and a taxi fare :|

¥

Apr 19, 2007 20:10

Oh.
My.
God.

I can't believe I'm that stupid, but apparently I am. THAT path is for a now-dead test installation. Somewhere during the process of getting all my various installations and versions consistent I must have allowed that particular detail into my active installations.

I'll be back after I see if that actually is my mistake. And I'll correct it. And I'll change my seeds so that your particular IP doesn't look so ... well ... you know 8|

Apr 19, 2007 22:17

It seems if I follow my own instructions it still works in 1.9.3 after all. Hm!

er ... never mind!!!

Apr 20, 2007 09:35

Yay I have a new visiglyph ;)

¥


Form is loading...

b2evolution CMS – This forum is powered by b2evolution CMS, a complete engine for your website.