<?php
session_start();
$_SESSION=$_POST["number"];
$userAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)";
$target_url="http://example.com/".$_SESSION;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile"); # SAME cookiefile
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$html= curl_exec($ch);
echo $html;
$dom = new DOMDocument();
@$dom->loadHTML($html);
$all_div=$dom->getElementsByTagName('div');
foreach($all_div as $div)
{
if($div->getAttribute('class')=="d1-2")
{
echo "<center>";
echo "Example doesn't exist";
echo "</center>";
}
else
if($div->getAttribute('class')=="uinf-2-2-4-2")
{
echo "<center>";
echo "Example exist";
echo "</center>";
}
}
?>
This script runs perfectly on the localhost, but when i run the script on the server(yahoo small business). It just echo's html page, it doesn't output example doesn't exist or example exist.
I think script time's out, not sure what the problem is. Any suggestions?