/* ============================================ Search script for Entireweb (C) 2006 WorldLight.com AB, Entireweb Free for use by Entireweb Free XML partners ============================================ */ /****************************************************************************** ** ** ** YOU MUST REPLACE THE FOLLOWING WITH YOUR 32-DIGIT PZ IDENTIFICATION STRING ** ** *******************************************************************************/ $identification = "--- MY ID STRING ---"; /* Collect parameters to send to Entireweb */ $query = $_REQUEST['q']; $numresults = $_REQUEST['n'] ? $_REQUEST['n'] : 10; $offset = $_REQUEST['of'] ? $_REQUEST['of'] : 0; $adult = $_REQUEST['a'] ? $_REQUEST['a'] : 0; $language = $_REQUEST['lang'] ? $_REQUEST['lang'] : 'world'; $region = $_REQUEST['reg'] ? $_REQUEST['reg'] : 'world'; $sc = $_REQUEST['sc'] ? $_REQUEST['sc'] : 1; $ip = $_SERVER['REMOTE_ADDR']; /* This can be disabled for non-Premium partners */ /* Get response from Entireweb */ if (!($fp = fsockopen('www.entireweb.com', 80, $errno, $errstr, 60))) { die("Can't connect to Entireweb ($errno: $errstr)"); } fwrite($fp, "GET /query?xml=1&ip=$ip&pz=$identification&q=$query&n=$numresults&of=$offset&a=$adult&lang=$language®=$region HTTP/1.0\r\nHost: www.entireweb.com\r\nConnection: Close\r\nUser-Agent: Entireweb XML Feed Test Script\r\n\r\n"); $xml_data = ""; while (!feof($fp)) { $xml_data .= fgets($fp, 1024); } fclose($fp); /* Make sure we got a valid response, and skip ahead to after the HTTP header */ if (strncasecmp($xml_data, "HTTP/1.1 200 OK", strlen("HTTP/1.1 200 OK"))) { die("Invalid response from Entireweb!"); } $xml_data = str_replace("\r\n", "\n", $xml_data); $xml_data = strstr($xml_data, "\n\n"); $xml_data = str_replace("\n\n", "", $xml_data); /* Output page header */ echo "