php image script is slow

Alles, was PHP betrifft, kann hier besprochen werden.

php image script is slow

Postby bst82551 » 19. February 2005 00:48

english replies only, please.
i have a script that i was using before i installed amp that pings a server and displays a specified image depending on whether the ping is successful or not.
here is the code:
Code: Select all
<?php
$server = "bst82551.ath.cx";
$port = "8080";
#Timeout in seconds before displaying the offline message.
$tout = "3";


header("Content-type: image/jpeg");
$ftping = @fsockopen ($server, $port, $errno, $errstr, $tout);




if (!$ftping) {
readfile('images/camoff.jpg');
} else {
readfile('http://bst82551.ath.cx:8080/cam_1.jpg');
}


?>


it runs much slower than it did on my previous installation. before, i had apache 2.052 and php 5 installed. That was it, just apache and php. Is there something that i should do so that this script will run faster? Is there some extra error checking occuring?

Brian
bst82551
 
Posts: 5
Joined: 16. February 2005 13:15

Why not using fopen()?

Postby TConnect » 21. February 2005 12:36

Hi,

it seems to be better to use fopen() to open an external image:

if($fp = fopen($url_to_image, "rb") {

} else {

}

The header you want to send is required only, if opening image was successfull...


Best regards
TConnect
TConnect
 
Posts: 100
Joined: 31. March 2004 22:26


Return to PHP

Who is online

Users browsing this forum: No registered users and 1 guest