PHP Script crashes Apache Server (windows)
Posted by: shub (---.dsl.scarlet.be)
Date: August 19, 2009 07:25PM

Hello,

I have a script that resizes images and then put them in a database, when i run the function i get a windows error that the apache server crashed (and i should restard it).

There is a video of me generating the error at [fritz-hut.com]

In this video you see me filling in the form, uploading a image and then press submit, when i hit the submit button the following function starts:

function add_leiding($naam, $img, $groep, $bio, $size) {
	//little hack so we dont need to add to much in the declaration
	$ext = strtolower(substr($img['name'], strrpos($img['name'], '.') + 1));
	if($img['size'] > $size) {
		return get_error_type("error: De afbeelding is te groot." );
	 } elseif($ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "gif" ) {
	 	//the image is from the correct type, lets rescall it and add it to the database with the other information

		// Set a maximum height and width
		$width = 150;
		$height = 150;

		// Get new dimensions
		list($width_orig, $height_orig) = getimagesize($img['tmp_name']);

		$ratio_orig = $width_orig/$height_orig;

		if ($width/$height > $ratio_orig) {
   			$width = $height*$ratio_orig;
		} else {
   			$height = $width/$ratio_orig;
		}

		// Resample
		$image_p = imagecreatetruecolor($width, $height);
		$image = imagecreatefromjpeg($img['tmp_name']);
		$imgDATA = imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
		$imgnewdata = addslashes(file_get_contents($imgDATA));
		
		$sql = sprintf("INSERT INTO cms_leiding_groep(con_link, 'con_name', 'con_image', 'con_bio') VALUES('%s', '%s', '%s', '%s')",
			$groep,
			$naam,
			$imgnewdata,
			$bio);
		$result = mysql_query($sql);
		if(mysql_affected_rows() != '0') {
			return get_error_type("success: De nieuwe leiding werdt successvol toegevoegd." );
		} else {
			return get_error_type("error:Kon de leiding niet toevoegen." );
		}
		
					
	} else {
		return get_error_type("error:Alleen afbeeldingen zijn toegestaan." );
	}
	
}

Basicly this function resizes the image, then uploads in in the database, for some reason the apatch server crashes (totaly as you can see in the movie) when the function gets called. So is this a wamp error, apache error or a big fault in my script? Shouldnt it be impossible to crash the apache server with a php script?

Thanks alot for anyone that can help me!


-Shub



Edited 1 time(s). Last edit at 08/19/2009 11:26PM by shub.

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: yfastud (Moderator)
Date: August 19, 2009 09:18PM


Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: shub (---.dsl.scarlet.be)
Date: August 19, 2009 11:24PM

Yes,

php_GD2 is active

-Shub

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: DC80 (---.adsl-surfen.hetnet.nl)
Date: August 19, 2009 11:24PM

I got the same problem here. When i try to put information in the mysql database Apache (httptd.exe) crashes. When i examine the error it reports there is a problem with the php_mysql.dll extention. After some research on google the problem still exists and i did not found any solution for it.

So is there a solution for this problem? I also tried to install apache, php and mysql aside from eachother. In this configuration i get a blank page instead of the website.

I also tried to shutdown the php_mysql extention by using the tray icon. When i do this i get the following error:

Fatal error: Call to undefined function mysql_connect() in E:\wamp\www\some\path\to\file.php on line 5

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: shub (---.dsl.scarlet.be)
Date: August 19, 2009 11:28PM

DC80 Wrote:
-------------------------------------------------------
> I got the same problem here. When i try to put
> information in the mysql database Apache
> (httptd.exe) crashes. When i examine the error it
> reports there is a problem with the php_mysql.dll
> extention. After some research on google the
> problem still exists and i did not found any
> solution for it.
>
> So is there a solution for this problem? I also
> tried to install apache, php and mysql aside from
> eachother. In this configuration i get a blank
> page instead of the website.
>
> I also tried to shutdown the php_mysql extention
> by using the tray icon. When i do this i get the
> following error:
>
> Fatal error: Call to undefined function
> mysql_connect() in
> E:\wamp\www\some\path\to\file.php on line 5

Im not having that problem really, its only with this function, other mysql query's work perfectly... Its really strange that it only crashes with the GD library...

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: yfastud (Moderator)
Date: August 20, 2009 12:42AM

@ DC80
is your wamp all white color? if yes, did you already create db account? if not, follow this
[blog.jlbn.net]

@ shub
is it part of cms? if yes, either consult on that cms forums or post the link for that cms and I might take a look for you

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: shub (---.dsl.scarlet.be)
Date: August 20, 2009 12:41PM

Its part of my home made CMS smiling smiley, giving out the full script in public i cant really do, if you want i can send all the code 2 you in a email and then you can have a look at it.

Im also using smarty and some jQuery scripts, but it really seems to be the fault of the GD library.

-Shub

Edit, my Error log (maybe handy)
APACHE
[Wed Aug 19 17:34:00 2009] [error] [client 127.0.0.1] PHP Warning:  imagecreatefromjpeg() [<a href='function.imagecreatefromjpeg'>function.imagecreatefromjpeg</a>]: gd-jpeg: JPEG library reports unrecoverable error:  in C:\\wamp\\www\\includes\\functions.admin.php on line 36, referer: [localhost]
[Wed Aug 19 17:34:13 2009] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Wed Aug 19 17:34:13 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Aug 19 17:34:13 2009] [notice] Server built: Dec 10 2008 00:10:06
[Wed Aug 19 17:34:13 2009] [notice] Parent: Created child process 55376
[Wed Aug 19 17:34:14 2009] [notice] Child 55376: Child process is running
[Wed Aug 19 17:34:14 2009] [notice] Child 55376: Acquired the start mutex.
[Wed Aug 19 17:34:14 2009] [notice] Child 55376: Starting 64 worker threads.
[Wed Aug 19 17:34:14 2009] [notice] Child 55376: Starting thread to listen on port 80.
[Wed Aug 19 19:28:32 2009] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Wed Aug 19 19:28:32 2009] [notice] Child 55376: Exit event signaled. Child process is ending.
[Wed Aug 19 19:28:33 2009] [notice] Child 55376: Released the start mutex
[Wed Aug 19 19:28:34 2009] [notice] Child 55376: All worker threads have exited.
[Wed Aug 19 19:28:34 2009] [notice] Child 55376: Child process is exiting
[Wed Aug 19 19:28:34 2009] [notice] Parent: Child process exited successfully.
[Wed Aug 19 23:20:57 2009] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Aug 19 23:20:57 2009] [notice] Server built: Dec 10 2008 00:10:06
[Wed Aug 19 23:20:57 2009] [notice] Parent: Created child process 42148
[Wed Aug 19 23:20:58 2009] [notice] Child 42148: Child process is running
[Wed Aug 19 23:20:58 2009] [notice] Child 42148: Acquired the start mutex.
[Wed Aug 19 23:20:58 2009] [notice] Child 42148: Starting 64 worker threads.
[Wed Aug 19 23:20:58 2009] [notice] Child 42148: Starting thread to listen on port 80.

MYSQL log
090819 17:25:22 [Note] Plugin 'FEDERATED' is disabled.
090819 17:25:23  InnoDB: Started; log sequence number 0 46409
090819 17:25:23 [Note] Event Scheduler: Loaded 0 events
090819 17:25:23 [Note] wampmysqld: ready for connections.
Version: '5.1.36-community-log'  socket: ''  port: 3306  MySQL Community Server (GPL)
090819 19:28:32 [Note] wampmysqld: Normal shutdown

090819 19:28:32 [Note] Event Scheduler: Purging the queue. 0 events
090819 19:28:32  InnoDB: Starting shutdown...
090819 19:28:32  InnoDB: Shutdown completed; log sequence number 0 46409
090819 19:28:32 [Warning] Forcing shutdown of 1 plugins
090819 19:28:32 [Note] wampmysqld: Shutdown complete



Edited 1 time(s). Last edit at 08/20/2009 12:51PM by shub.

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: yfastud (Moderator)
Date: August 20, 2009 01:45PM

since it's your own-created cms and not yet release, don't give it out to anyone including me; thus, suggest you create some small scripts, which are not part of cms, to test each function of gd, smarty, jQuery or whatever function you're using in your cms script winking smiley

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: shub (---.dsl.scarlet.be)
Date: August 20, 2009 03:55PM

Found it, what the problem was is that i uploaded a png file and then used the jpg functions to handel that png (resize it and stuff) resulting in a crash.

This means there is a exploit in the wamp configuration because on my real server i get a error spit out by php...

Something to look into!


-Shub

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: DC80 (---.adsl-surfen.hetnet.nl)
Date: August 20, 2009 07:21PM

yfastud Wrote:
-------------------------------------------------------
> @ DC80
> is your wamp all white color? if yes, did you
> already create db account? if not, follow this
> [blog.jlbn.net]
>
> @ shub
> is it part of cms? if yes, either consult on that
> cms forums or post the link for that cms and I
> might take a look for you


I already did so. The strange thing is, phpmyadmin is working perfectly. It's just a page that won't load normaly (at all), instead Apache crashes.

The connection is re-initialisted by Apache or so the webbrowser says.

Then windows want to sent a error report and when i check this report it has something to do with php_mysql.dll.

Options: ReplyQuote
Re: PHP Script crashes Apache Server (windows)
Posted by: toumimi (84.6.111.---)
Date: August 21, 2009 05:47AM

See here if this is the same problem : [forum.wampserver.com]

Florian

WampServer Patch (Screenshots)
Topic EN : www.wampserver.com
Topic FR : www.wampserver.com

Options: ReplyQuote


Sorry, only registered users may post in this forum.