PHP Programmer India|PHP Programming | Php Web Programming | php web developer | Website designing php | Web development Php

Link Partners

$value) { $value = urlencode(stripslashes($value)); $querystring .= "&$key=$value"; } } $poststring = "userid=" .$userid; $poststring .= "&pagename=" .$currentpage; $poststring .= "&cat_col=" .$cat_col; $poststring .= "&linksperpage=" .$linksperpage; $poststring .= "&".$querystring; $scripname = "index.php/link/getlinks"; if(function_exists("curl_init")) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "www.linkexchangefree.com/".$scripname); /* set the user agent - might help, doesn't hurt */ //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring); /* try to follow redirects */ //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); /* timeout after the specified number of seconds. assuming that this script runs on a server, 20 seconds should be plenty of time to verify a valid URL. */ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $data = curl_exec($ch); curl_close($ch); echo $data; } else { $header = "POST ".$scripname . " HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($poststring) . "\r\n\r\n"; // open a connection to linkexchangefree.com $fp = fsockopen ('www.linkexchangefree.com', 80, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR echo "Some Error has occurred while processing request"; } else { // send form headers, form post fputs ($fp, $header . $poststring); // set our returned header flag to true, these we want to ignore // initialize our body variable $bHeader = true; $data = ""; while (!feof($fp)) { $res = fgets ($fp, 8192); $res = ereg_replace("[\r\n]", "", $res); // if we have an empty line, we are now past the headers. // set the flag so we can start retrieving data if (strlen($res) == 0) $bHeader = false; if ($bHeader == false) $data .= $res; } echo $data; fclose ($fp); } } ?>