ctype_alnum
24-07-2014, 10:17
Thats probably a load balancer IP and google have a habit of changing things. Its never a good idea to hardcode IP addresses for that reason, you will go from it being slow to not working at all.
$url = 'www.google-analytics.com';
$fp = fsockopen($url, 80, $errno, $errstr, 5);
$fp=fsockopen('149.3.176.53', 80);
private function track() {
//set POST variables
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
$url = 'http://www.google-analytics.com/collect';
$fields = array(
'v' => '1',
'tid' => $this->GA_ID,
'cid' => $this->gaParseCookie(),
't' => 'pageview',
'dh' => 'webservice.fanart.tv',
'dp' => $this->ttype.' - '.$_GET["api_key"].' - '.$this->project,
'dt' => $this->tid,
'uip' => $_SERVER['REMOTE_ADDR']
);
$fields_string = http_build_query($fields);
//die($fields_string);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
}
private function track() {
//set POST variables
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
$url = 'www.google-analytics.com';
$page = '/collect';
$fields = array(
'v' => '1',
'tid' => $this->GA_ID,
'cid' => $this->gaParseCookie(),
't' => 'pageview',
'dh' => 'webservice.fanart.tv',
'dp' => $this->ttype.' - '.$_GET["api_key"].' - '.$this->project,
'dt' => $this->tid,
'uip' => $_SERVER['REMOTE_ADDR']
);
$fields_string = http_build_query($fields);
$fp = fsockopen($url, 80, $errno, $errstr, 5);
$output = "POST $page HTTP/1.1\r\n";
$output .= "Host: $url\r\n";
$output .= "Content-Type: application/x-www-form-urlencoded\r\n";
$output .= "Content-Length: ".strlen($fields_string)."\r\n";
$output .= "Connection: close\r\n";
$output .= $fields_string;
//die($output);
fwrite($fp, $output);
fclose($fp);
}