1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| $v = 1; $t ='pageview'; $tid = 'UA-000000-0'; $z = mt_rand();
$uip = getIp(); $dt = $_GET['dt']; $dl = $_GET['dl']; $dr = $_GET['dr']; $ul = $_GET['ul']; $sd = $_GET['sd']; $sr = $_GET['sr']; $vp = $_GET['vp']; $de = $_GET['de']; $ua = $_GET['ua']; $cid = clientId();
send_post2('https://www.google-analytics.com/collect', $post_data); function clientId() { $cid = $_COOKIE["statcid"]; if(!$cid) { try { $cid = Uuid::uuid4()->toString(); } catch (UnsatisfiedDependencyException $e) { $cid = gen_uuid(); } setcookie("statcid", $cid, time() + 3600 * 24 * 365 * 2); } return $cid; }
function gen_uuid() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), // 16 bits for "time_mid" mt_rand( 0, 0xffff ), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 4 mt_rand( 0, 0x0fff ) | 0x4000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 mt_rand( 0, 0x3fff ) | 0x8000, // 48 bits for "node" mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); } function send_post($url, $post_data) { $postdata = http_build_query($post_data); $options = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 15 * 60 ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return $result; } function send_post2($url, $post_data) { $postData = ''; foreach($post_data as $k => $v) { $postData .= $k . '=' . $v . '&'; } $postData = rtrim($postData, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, count($postData)); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); $output = curl_exec($ch); if($output === false) { echo "Error Number:".curl_errno($ch)."<br>"; echo "Error String:".curl_error($ch); } curl_close($ch); return $output; }
|