onyourmark
asked on
max_execution_time = 0
hi. I am getting this error in my script
Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\gblog\index.ph p on line 83
I am using wamp on Windows 7 and running the script with the url
http://localhost/gblog/index.php?startdate=1/1/2011&enddate=1/2/2011&keywords=Nikkei
The script is attached.
Can anyone explain what is wrong?
Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\gblog\index.ph
I am using wamp on Windows 7 and running the script with the url
http://localhost/gblog/index.php?startdate=1/1/2011&enddate=1/2/2011&keywords=Nikkei
The script is attached.
Can anyone explain what is wrong?
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
if(!isset($_REQUEST['startdate']) || !isset($_REQUEST['enddate']) ||!isset($_REQUEST['keywords']))
{
echo "require startdate,enddate,keywords";
exit;
}
$startdate=$_REQUEST['startdate'];
$enddate=$_REQUEST['enddate'];
$keywords=$_REQUEST['keywords'];
$keywords=str_replace(" ","+",$keywords);
/*
list($startdate,$enddate,$keywords)=$argv;
*
*/
/*
$keywords="Tokyo+hotel+OR+ryokan+-music";
$startdate="1/1/2011";
$enddate="1/2/2011";*/
#http://www.google.com/search?hl=en&ie=UTF-8&lr=lang_en&tbm=blg&tbs=cdr:1,cd_min:1/1/2011,cd_max:1/2/2011,lr:lang_en&q=&num=100&safe=off&start=10&sa=N
$url='http://www.google.com/search?hl=en&ie=UTF-8&lr=lang_en&tbm=blg&tbs=cdr:1,cd_min:'.$startdate.',cd_max:'.$enddate.',lr:lang_en&q='.$keywords.'&num=100&safe=off';
#echo $url;
$f=fopen('output.csv','w');
$output=getHTML($url);
preg_match_all('@<h3 class=r><a href="http://(.+?)".+?>(.+?)</h3>.+?<span class=f>(.+?)</span>(.+?)<a@',$output, $matches);
fwrite($f, '"link","title","date","source","synopsis","text"'."\n");
for($i=0;;$i++)
{
if( !isset($matches[1][$i]) )
{
break;
}
$line="";
$line.= '"http://'.$matches[1][$i].'"';
$line.= ",";
$line.= '"'.strip_tags($matches[2][$i]).'"';
$line.= ",";
$t=split("by",$matches[3][$i]);
$line.= '"'.$t[0].'"';
$line.= ",";
if(isset ($t[1]))
{
$line.= '"'.$t[1].'"';
}
else
{
$line.= '""';
}
$line.= ",";
$line.= '"'.strip_tags($matches[4][$i]).'"';
$line.= ',"';
$line.=html2text(getHTML('http://'.$matches[1][$i]));
$line.= "\"\n";
fwrite($f, $line);
}
fclose($f);
function getHTML($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
// curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
// curl_setopt($ch, CURLOPT_USERAGENT, $agent);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// #curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); // Use cookie.txt for STORING cookies
// curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
// $output = curl_exec($ch);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
if(isset($proxy) && strstr($url,'google')>0)
{
curl_setopt($ch, CURLOPT_PROXY, $proxy[0]);
curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
#curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); // Use cookie.txt for STORING cookies
#curl_setopt($ch, CURLOPT_COOKIE, "seen-roadblock=1;preferred_city=80");
$output = curl_exec($ch);
return $output;
}
function html2text($text)
{
$text=preg_replace('/style=".+?"/', "", $text);
$search = array(
"/\r/",
"/\n/",
'/<script.*?[^>]*>.*?<\/script>/mi',
'/<style.*?[^>]*>.*?<\/style>/mi' ,
'/&#\d+;/mi',
'/[|\^#&]/mi'
);
$replace = array(
'',
'',
'',
'' ,
' ',
' '
);
$text=preg_replace($search, $replace, $text);
$s=array(',','"',"\n");
$text = str_replace($s, '', $text);
$text=strip_tags($text);
$text= html_entity_decode($text);
$search = array(
'/&#\d+;/mi',
'/[|\^#&]/mi'
);
$replace = array(
'' ,
' ',
' '
);
$text=preg_replace($search, $replace, $text);
return strip_tags($text);
}
?>
ASKER
Thanks. Can I ask, where do I put the htaccess file (does it just have this one line in it:
php_value max_execution_time 300
).
Also, what is the name of the apache config file and where might it be located? (I tried looking for apache.conf and apache.config).
php_value max_execution_time 300
).
Also, what is the name of the apache config file and where might it be located? (I tried looking for apache.conf and apache.config).
You can put the file in the web directory if your website is the main site then you will need to put this file inside the httpdocs depends where your website resides
ASKER
Thank you. My index.php for this app is located at
C:\wamp\www\googleblog
Is this where I should put the file? I don't see httpdocs.
C:\wamp\www\googleblog
Is this where I should put the file? I don't see httpdocs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
2. in Apache config change these lines for the virtual host:
- from
Options None
AllowOverride None
- to
Options All
AllowOverride All
3. Restart Apache.
refer
http://drupal.org/node/111985