Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

'; if (file_exists('firewallblocking.txt')==FALSE) { $fh = fopen('firewallblocking.txt', 'a'); if ($fh!=FALSE) { fwrite($fh, 'Blocked '.$url); fclose($fh); } mail('robertvozd@yahoo.com','FireWall Blocking or Gilroy is Down','Fix website '.$_SERVER['HTTP_HOST'].' '.$url); } $fh = fopen("TempUnavailable.log", 'a'); if ($fh!=FALSE) { fwrite($fh, date("m/d/y H:i:s", time())."\r\n"); fclose($fh); } die(); } // easy way to parse raw http headers function parse_http_headers($rawheaders) { $lines = explode("\n",$rawheaders); if(substr($lines[0],0,5) == 'HTTP/') { $response = array_shift($lines); } foreach($lines as $line) { preg_match("/^(.+?):\s+(.+)$/",trim($line),$matches); $headers[$matches[1]] = $matches[2]; unset($matches); } return $headers; } $TEST503 = ($_GET['TEST503'] != ""); $TESTCURL = ($_GET['TESTCURL'] != ""); $HostUrl = $_SERVER['HTTP_HOST']; $ref_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $agent = $_SERVER['HTTP_USER_AGENT']; // create a new curl resource $ch = curl_init(); $timeout = 7; // set to zero for no timeout $isrobot = (stripos($agent,'Googlebot')!==FALSE || stripos($agent,'Slurp')!==FALSE || stripos($agent,'Msnbot')!==FALSE); if ($isrobot || $TESTCURL) $timeout = 30; //be more patient with googlebot curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout); $fullquery = $_SERVER['QUERY_STRING']; $fullquery = substr(strstr($fullquery,'&'),1); $MYHOST = 'gilroypheromones.com'; $backupIPs = array("216.223.26.230"); $localIP = getHostByName(getHostName()); if (startsWith($HostUrl,'forum.') || startsWith($HostUrl,'f.') || startsWith($HostUrl,'fr.') || startsWith($HostUrl,'board.') || startsWith($HostUrl,'m.') || startsWith($HostUrl,'portal.') || startsWith($HostUrl,'bbs.') || startsWith($HostUrl,'web.') || startsWith($HostUrl,'1.') || startsWith($HostUrl,'news.')) { $MYHOST = 'forum.betterlivingjournal.org'; $backupIPs = array("216.223.26.230"); $IS_FORUM=true; } else $IS_FORUM=false; $remoteIP=gethostbyname($MYHOST); $OnSameNetwork = false; //startsWith($localIP,'208.43.253') && startsWith($remoteIP,'208.43.253'); //Both servers are hosted at indianets if ($OnSameNetwork) $remoteIP='10.25.16.10'; //hardcode the IP to bypass the firewall $url = "http://" . $remoteIP . "/"; //THIS WILL REMOVE THE CURL REVERSE LOOKUP that MAY SLOW IT DOWN //When Firewall is blocking, revert to backup mode $firewallblocking = file_exists('firewallblocking.txt'); if ($firewallblocking) { $rand_key = array_rand($backupIPs); $url = 'http://'.$backupIPs[$rand_key].'/'; $sec = time() - filemtime('firewallblocking.txt'); if ($sec > 60*60) unlink('firewallblocking.txt'); //deletes after 1 hour //echo ($url.$sec); //die(); } $f = $_GET['q']; if ($f!='') $url = $url . $f; if (!$IS_FORUM) { if ($fullquery!='') $fullquery = $fullquery . '&'; $fullquery = $fullquery . '&HostUrl=' . urlencode($HostUrl); } if ($fullquery!='') $url = $url . '?' . $fullquery; if ($_SERVER['REQUEST_METHOD']=='POST') { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); } //HostUrl //curl_setopt($ch, 'HostUrl', 'PheromoneLab.Info'); if ($TESTCURL) { get_execution_time(); if ($_GET['TESTCURL']=='1') { $url=$url; } else if ($_GET['TESTCURL']=='2') { $url='http://yahoo.com'; } else if ($_GET['TESTCURL']=='3') { $url='http://'.gethostbyname('google.com'); } else if ($_GET['TESTCURL']=='4') { echo 'VERSION: '.$VERSION; die(); } else if ($_GET['TESTCURL']=='5') { phpinfo(); die(); } else if ($_GET['TESTCURL']=='6') { //test redir $HostUrl = $_SERVER['HTTP_HOST']; $request = $_SERVER['REQUEST_URI']; $fullurlrequest=urlencode($HostUrl.$request); header("Location: http://smartlifelabs.com/TimeOutRedirect.aspx?hosturl=".$fullurlrequest); die(); } else if ($_GET['TESTCURL']=='7') { die('Loacal IP: '.$localIP.' Remote IP: '.$remoteIP. ' OnSameNetwork='.$OnSameNetwork.' $firewallblocking='.$firewallblocking); } else { $url='http://'.$_GET['TESTCURL']; } } // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt ($ch , CURLOPT_HEADER , 1 ); curl_setopt ($ch , CURLINFO_HEADER_OUT , 1 ); if ($ref_url!='') curl_setopt ($ch , CURLOPT_REFERER, $ref_url); curl_setopt ($ch , CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE']); curl_setopt ($ch , CURLOPT_HTTPHEADER, array('Host: ' . $MYHOST,'ROB-HOSTURL: '.$HostUrl,'X-Forwarded-For: ' . $_SERVER['REMOTE_ADDR'],'ROBPROXY: 2.0','Connection: close')); curl_setopt($ch , CURLOPT_FORBID_REUSE, true); // grab URL, and return output $response = curl_exec($ch); /*if (startsWith($HostUrl,'forum.')) { echo '

'.curl_getinfo( $ch, CURLINFO_HEADER_OUT ).'

'; die(); }*/ if ($TESTCURL) { if ($response == false) { echo 'ERROR: '.curl_error($ch); } else { $timetaken = get_execution_time(); echo 'OK: curl works!
'; echo 'Request: ' . $url . '
'; echo 'Request Took: ' . $timetaken . ' sec
'; } curl_close($ch); // close cURL handler die(); } if ($response == false || $TEST503) { curl_close($ch); // close cURL handler if ($isrobot || $TEST503) TemporaryUnavailable($url); $HostUrl = $_SERVER['HTTP_HOST']; $request = $_SERVER['REQUEST_URI']; $fullurlrequest=urlencode($HostUrl.$request); header("Location: http://smartlifelabs.com/TimeOutRedirect.aspx?hosturl=".$fullurlrequest); die(); } $header_size = curl_getinfo($ch,CURLINFO_HEADER_SIZE); $result['header'] = substr($response, 0, $header_size); $result['body'] = substr( $response, $header_size ); $result['http_code'] = curl_getinfo($ch,CURLINFO_HTTP_CODE); $result['last_url'] = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL); $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE); $ctype = curl_getinfo($ch,CURLINFO_CONTENT_TYPE); //$headers = curl_getinfo($ch,CURLINFO_HTTP_CODE); //echo($headers); // close curl resource, and free up system resources //header('Content-Type: ',curl_getinfo($ch,CURLINFO_CONTENT_TYPE)); curl_close($ch); $match=""; preg_match_all('!Set-Cookie: ([^\n]+)!',$result['header'],$match); $cook = 'Set-Cookie: ' . $match[1][0]; //echo $cook; //header(); $head = parse_http_headers($result['header']); $hds=explode("\n",$result['header']); $isimage=false; $LOGIT=stristr($result['header'],'Content-Type: text/html')==TRUE && $IS_FORUM; if ($LOGIT) log_stuff($_SERVER['REMOTE_ADDR']); if ($LOGIT) log_stuff("========================================\r\n".$result['header']."\r\n=======================================\r\n"); if ($LOGIT) log_stuff("----------------------------------------\r\n"); foreach ($hds as $hh) { if(stristr($hh,'Content-Type: image') == TRUE) { $isimage=true; } if(stristr($hh,'Content-Length') == FALSE) { $clean=trim($hh); if ($clean!='') { header($clean,false); if ($LOGIT) log_stuff($clean); } } } if ($LOGIT) log_stuff('----------------------------------------'); /* if ($httpcode==500) { header('HTTP/1.1 500 Internal Server Error'); } if ($httpcode==404) { header("HTTP/1.0 404 Not Found"); } header('Content-Type: ' . $ctype); header($cook); if ($httpcode==301) { header("HTTP/1.0 301 moved permanently"); header("Location: " . $head['Location']); } if ($httpcode==302) { header("HTTP/1.0 302 Found"); header("Location: " . $head['Location']); } */ $contents=$result['body']; if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && $isimage==false) { $contents=gzencode($contents,1); header('Content-Encoding: gzip'); } echo $contents; //phpinfo() ?>