forked from xeonye/52video
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcs.php
67 lines (56 loc) · 1.55 KB
/
cs.php
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
<?php
/**
* @version 1.0111
*/
class CS {
private $siteId;
private $scheme;
private $imageDomain = 'c.cnzz.com';
/**
*
* @param Integer $siteId 站点ID
*/
public function __construct($siteId) {
$this->setAccount($siteId);
$this->initScheme();
}
/**
* 设置站点ID
* @param type $siteId
*/
public function setAccount($siteId) {
$this->siteId = $siteId;
}
private function initScheme() {
$this->scheme = $this->getScheme();
}
/**
* 得到url中的scheme
* @return String
*/
private function getScheme() {
return (isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] !== "off") ? 'https://' : 'http://');
}
/**
*
* @return String 回传数据的请求字符串
*/
public function trackPageView() {
return $this->getImageUrl();
}
private function getImageUrl() {
$imageLocation = $this->scheme . $this->imageDomain . '/wapstat.php';
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$query = array();
array_push($query, 'siteid=' . $this->siteId * 1);
array_push($query, 'r=' . urlencode($referer));
array_push($query, 'rnd=' . mt_rand(1, 2147483647));
$imageUrl = $imageLocation . '?' . implode('&', $query);
return $imageUrl;
}
}
function _cnzzTrackPageView($siteId) {
$cs = new CS($siteId);
return $cs->trackPageView();
}
?>