473,409 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Code execution Time

Hi,

I have the following script which I'm using to verify that websites
exist. However in either FF or IE it only runs for about 60 seconds.
I've changed what ini settings I think affect it, but to no avail. Can
you tell me how to make it run for longer. I could have quite a few
hundred sites and I simply want to make sure they return OK.

The code will work as is but you'll see it probably won't do quite a
long list. (stops at about 10).

Thanks

A

<?php
ini_set('max_execution_time',999);
ini_set('max_input_time',999);

if (!(isset($_POST['sites']))){
print "<form method=\"post\" action=\"test2.php\"><textarea name=
\"sites\" rows=25 cols=25></textarea><input type=\"submit\"></form>";
} else {

$sites = split("\r\n",$_POST['sites']);

foreach ($sites as $path){

$http_response_header = array(); // clear arrays in case previous
data still held
$file = array();
$file = @file_get_contents("http://$path");

if (!(is_numeric(strpos($http_response_header[0],"OK")))){ //
Is the website NOT ok
if (is_numeric(strpos($http_response_header[0],"30"))){ //
Has it been redirected?
foreach ($http_response_header as $k=>$value){
$value = str_replace("Content-Location","",$value); //
Strip out the Content tags which confuse issues
if (is_numeric(strpos($value,"Location"))){ //
If this one carries the location - use it
$value = str_replace("Location: ","",$value);
$http_response_header = array();
$file2 = @file_get_contents($value); // Connect
to the forwarded site just to check
if (!(is_numeric(strpos($http_response_header[0],"OK"))))
{
print "$path <b>IS NOW</b$value<br>";
} else {
print "$value redirected but is DEAD<br>";
}
}
}
} else {
print "$path is not live<br>";
}
} else {
print "$path is ok<br>";
}
}
}
?>
Nov 29 '07 #1
4 1705
On Nov 29, 8:45 am, UKuser <spiderc...@yahoo.co.ukwrote:
Hi,

I have the following script which I'm using to verify that websites
exist. However in either FF or IE it only runs for about 60 seconds.
I've changed what ini settings I think affect it, but to no avail. Can
you tell me how to make it run for longer. I could have quite a few
hundred sites and I simply want to make sure they return OK.

The code will work as is but you'll see it probably won't do quite a
long list. (stops at about 10).

Thanks

A

<?php
ini_set('max_execution_time',999);
ini_set('max_input_time',999);

if (!(isset($_POST['sites']))){
print "<form method=\"post\" action=\"test2.php\"><textarea name=
\"sites\" rows=25 cols=25></textarea><input type=\"submit\"></form>";

} else {

$sites = split("\r\n",$_POST['sites']);

foreach ($sites as $path){

$http_response_header = array(); // clear arrays in case previous
data still held
$file = array();
$file = @file_get_contents("http://$path");

if (!(is_numeric(strpos($http_response_header[0],"OK")))){ //
Is the website NOT ok
if (is_numeric(strpos($http_response_header[0],"30"))){ //
Has it been redirected?
foreach ($http_response_header as $k=>$value){
$value = str_replace("Content-Location","",$value); //
Strip out the Content tags which confuse issues
if (is_numeric(strpos($value,"Location"))){ //
If this one carries the location - use it
$value = str_replace("Location: ","",$value);
$http_response_header = array();
$file2 = @file_get_contents($value); // Connect
to the forwarded site just to check
if (!(is_numeric(strpos($http_response_header[0],"OK"))))
{
print "$path <b>IS NOW</b$value<br>";
} else {
print "$value redirected but is DEAD<br>";
}
}
}
} else {
print "$path is not live<br>";
}
} else {
print "$path is ok<br>";
}
}}

?>
Hey there UKUser, Have you considered using the command line binary
with lib_curl, then piping your output to an html file? I've done that
with MANY of my automated PHP scripts, with great success and no
concerns about timeouts. I've a script that can run as long as 2 hours
doing some data administration tasks from 1AM-3AM local, scheduled
through cron. Some of the data tasks required involve reading CSV
feeds from servers other than my own, as well as remote PostgreSQL
queries. There is another script that builds an HTML report on server
status and uptimes that's in a FF window with a META refresh tag that
triggers on 5 minute marks. Hope that gives you some ideas on how to
get your script doing what you need it to do.

Good Luck.
Nov 29 '07 #2
UKuser wrote:
Hi,

I have the following script which I'm using to verify that websites
exist. However in either FF or IE it only runs for about 60 seconds.
I've changed what ini settings I think affect it, but to no avail. Can
you tell me how to make it run for longer. I could have quite a few
hundred sites and I simply want to make sure they return OK.

The code will work as is but you'll see it probably won't do quite a
long list. (stops at about 10).

Thanks

A

<?php
ini_set('max_execution_time',999);
ini_set('max_input_time',999);

if (!(isset($_POST['sites']))){
print "<form method=\"post\" action=\"test2.php\"><textarea name=
\"sites\" rows=25 cols=25></textarea><input type=\"submit\"></form>";
} else {

$sites = split("\r\n",$_POST['sites']);

foreach ($sites as $path){

$http_response_header = array(); // clear arrays in case previous
data still held
$file = array();
$file = @file_get_contents("http://$path");

if (!(is_numeric(strpos($http_response_header[0],"OK")))){ //
Is the website NOT ok
if (is_numeric(strpos($http_response_header[0],"30"))){ //
Has it been redirected?
foreach ($http_response_header as $k=>$value){
$value = str_replace("Content-Location","",$value); //
Strip out the Content tags which confuse issues
if (is_numeric(strpos($value,"Location"))){ //
If this one carries the location - use it
$value = str_replace("Location: ","",$value);
$http_response_header = array();
$file2 = @file_get_contents($value); // Connect
to the forwarded site just to check
if (!(is_numeric(strpos($http_response_header[0],"OK"))))
{
print "$path <b>IS NOW</b$value<br>";
} else {
print "$value redirected but is DEAD<br>";
}
}
}
} else {
print "$path is not live<br>";
}
} else {
print "$path is ok<br>";
}
}
}
?>
If you can change the PHP timeout parameter (some hosting companies let
you do so, some don't), you're probably running into a browser timeout.

If so, you might be able to keep the browser from timing out by calling
ob_flush() and flush() after printing a message. No guarantees - the
output may still be cached by your server. But then PHP isn't caching
it, also.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 29 '07 #3
On 29 Nov, 17:11, Jerry Stuckle <jstuck...@attglobal.netwrote:
UKuser wrote:
Hi,
I have the following script which I'm using to verify that websites
exist. However in either FF or IE it only runs for about 60 seconds.
I've changed what ini settings I think affect it, but to no avail. Can
you tell me how to make it run for longer. I could have quite a few
hundred sites and I simply want to make sure they return OK.
The code will work as is but you'll see it probably won't do quite a
long list. (stops at about 10).
Thanks
A
<?php
ini_set('max_execution_time',999);
ini_set('max_input_time',999);
if (!(isset($_POST['sites']))){
print "<form method=\"post\" action=\"test2.php\"><textarea name=
\"sites\" rows=25 cols=25></textarea><input type=\"submit\"></form>";
} else {
$sites = split("\r\n",$_POST['sites']);
foreach ($sites as $path){
$http_response_header = array(); // clear arrays in case previous
data still held
$file = array();
$file = @file_get_contents("http://$path");
if (!(is_numeric(strpos($http_response_header[0],"OK")))){ //
Is the website NOT ok
if (is_numeric(strpos($http_response_header[0],"30"))){ //
Has it been redirected?
foreach ($http_response_header as $k=>$value){
$value = str_replace("Content-Location","",$value); //
Strip out the Content tags which confuse issues
if (is_numeric(strpos($value,"Location"))){ //
If this one carries the location - use it
$value = str_replace("Location: ","",$value);
$http_response_header = array();
$file2 = @file_get_contents($value); // Connect
to the forwarded site just to check
if (!(is_numeric(strpos($http_response_header[0],"OK"))))
{
print "$path <b>IS NOW</b$value<br>";
} else {
print "$value redirected but is DEAD<br>";
}
}
}
} else {
print "$path is not live<br>";
}
} else {
print "$path is ok<br>";
}
}
}
?>

If you can change the PHP timeout parameter (some hosting companies let
you do so, some don't), you're probably running into a browser timeout.

If so, you might be able to keep the browser from timing out by calling
ob_flush() and flush() after printing a message. No guarantees - the
output may still be cached by your server. But then PHP isn't caching
it, also.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Just wanted to say thanks guys for both your input. It is a mix of the
max-executiont time, the socket connection time and the browsers. I'm
nearly there - and get better results by running my script with php-
cgi.exe rather than through a browser.

Many thanks

A
Dec 5 '07 #4
Greetings, UKuser.
In reply to Your message dated Wednesday, December 5, 2007, 19:06:27,
and get better results by running my script with php-
cgi.exe rather than through a browser.
O.o What You mean "running script through a browser"?
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Dec 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Johannes Lebek | last post by:
Hi there, lately, I experienced a strange thing on my DB2 V8.1 on Windows: Some queries took a very long time. A snapshot discovered the following: Number of executions = 47...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
3
by: iam980 | last post by:
Hello All. We have tested following SQL script from query analyzer: -- Script begin DECLARE @I int; SET @I = 1; WHILE @I < 10000000 BEGIN SET @I = @I + 1; END -- Script end
88
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
3
by: vashwath | last post by:
Hi all, I have written program for calculating the execution time of a function.Any critics (on the method of calculating execution time) are welcome. #include <stdio.h> #include <time.h>...
2
by: Ina Schmitz | last post by:
Hi NG, does IBM Universal Database 8.2 make any difference between actual and estimated execution plans like in SQL Server ("set showplan_all on" for estimated execution plan and "set statistics...
8
by: Magesh | last post by:
Consider a block, fncall( ); /* tells me the current millisecond or something like that: time-1 */ {/* block of code for which I need to know the exec time ... ... ... } fncall( ); /* tells...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
6
by: Mikhail Kovalev | last post by:
I'm using set_time_limit() to set maximum execution time. Is there a way to check how much time is left at any time during the execution itself?
4
by: sphinney | last post by:
Hi everyone. I'm creating an application inside Access 2007. The application will retrieve data from various locations on my company's network servers. Depending on the time of day, alignment of...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.