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
|
<?php
class TrackingIframe { public static $fields = array('tracking_code', 'action', 'userid', 'clientid', /*'ip_address', 'browser_user_agent',*/'language_code', 'data' /*, 'session'*/); public $url = 'http://www.hkosl.com/tracking/hit.php';
public function __construct($settings = array()) { $this->action = preg_replace("/\.(.*)$/", "", basename($_SERVER['SCRIPT_NAME']));
foreach (self::$fields as $field) { if (isset($settings[$field])) { $this->{$field} = is_array($settings[$field]) ? json_encode($settings[$field]) : $settings[$field]; } } }
public function toUrl() { foreach (self::$fields as $field) { if (isset($this->{$field}) && $this->{$field}) { $tmp[$field] = $this->{$field}; } } return "{$this->url}?" . http_build_query($tmp); }
public function toHtml() { return "<iframe src='{$this->toUrl()}' class='tracking' style='visibility:hidden;display:none'></iframe>"; } }
|