Replace current checkRemoteFile function with a faster cURL implementation

Instead of downloading the entirity of the file that's there or risking
a HTTP server not being on port 80, I've decided to move with a faster,
more efficient and web browser complient cURL query

UnPS User Agent: UnPS-GAMATechnologies (UnPS WebQuery/4-2.8; +http://unps.us)
This commit is contained in:
Arctic Code 2013-10-08 17:54:07 -05:00
parent 9a3d013be1
commit 999d9d3623
1 changed files with 25 additions and 4 deletions

View File

@ -9,10 +9,31 @@
* ============================================================
*/
function checkRemoteFile($link){
if (@file_get_contents($link)): return true;
else: return false;
endif;
function checkRemoteFile($ip=null){
if($ip==null) return false;
// Setup the connection and only get the headers
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: ";
$curlInit = curl_init($ip);
curl_setopt($curlInit, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curlInit, CURLOPT_HEADER, true);
curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlInit, CURLOPT_USERAGENT, 'UnPS-GAMATechnologies (UnPS WebQuery/4-2.8; +http://unps.us)');
curl_setopt($curlInit, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($curlInit);
curl_close($curlInit);
if($response) return true;
return false;
}
include('hashpass.php');