smurg
2011-08-18 23:16:32
I currently running into problems when my php scripts run too long (probably the same issue as the cronjob).
[php]
<?php
set_time_limit(60);
$num = 615;
for($n=$num; $n < ($num + 50); $n++)
{
$url = 'http://services.runescape.com/m=itemdb_rs/3450_obj_sprite.gif?id='.$n;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$page_data = curl_exec ($ch);
curl_close ($ch);
if(preg_match('/Page not found/', $page_data)){
echo $n." –> 404<br />";
continue;
}
$i = file_get_contents($url);
$f = file_put_contents('******.'.gif', $i);
echo $n.' success<br />';
set_time_limit(30);
}
?>
[/php]This is downloading me all the sprites from the GE database. However without limiting the loop, it would run through 60 items before stopping and printing the data. So, the time limit sets don't seem to help at all and there's ~25,000 ID's, maybe half which don't have sprites though. Doing it every 50 would take a while.
Any ideas?
[php]
<?php
set_time_limit(60);
$num = 615;
for($n=$num; $n < ($num + 50); $n++)
{
$url = 'http://services.runescape.com/m=itemdb_rs/3450_obj_sprite.gif?id='.$n;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$page_data = curl_exec ($ch);
curl_close ($ch);
if(preg_match('/Page not found/', $page_data)){
echo $n." –> 404<br />";
continue;
}
$i = file_get_contents($url);
$f = file_put_contents('******.'.gif', $i);
echo $n.' success<br />';
set_time_limit(30);
}
?>
[/php]This is downloading me all the sprites from the GE database. However without limiting the loop, it would run through 60 items before stopping and printing the data. So, the time limit sets don't seem to help at all and there's ~25,000 ID's, maybe half which don't have sprites though. Doing it every 50 would take a while.
Any ideas?