Skip to content

Commit 1a0b5db

Browse files
committed
Merge pull request #2 from BassemN/issue-#1
Fix: Undefined index: SCRIPT_URI issue
2 parents 6c37f43 + 2fa8315 commit 1a0b5db

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/There4/Analytics/AnalyticsEvent.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function trackEvent($object, $action, $label = '', $value = 1)
9393
$var_cookie = rand(10000000, 99999999); //random cookie number
9494
$var_random = rand(1000000000, 2147483647); //number under 2147483647
9595
$var_today = time(); //today
96-
$var_referer = $_SERVER['SCRIPT_URI']; //referer url
96+
$var_referer = $this->getCurrentUrl(); //referer url
9797
$var_utmp = 'index.php';
9898
$var_uservar = '';
9999

@@ -143,6 +143,19 @@ public function trackEvent($object, $action, $label = '', $value = 1)
143143

144144
return $is_gif;
145145
}
146+
147+
/**
148+
* Get the current Url
149+
*
150+
* @return string current url
151+
*/
152+
public function getCurrentUrl() {
153+
$url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
154+
$url .= '://' . $_SERVER['SERVER_NAME'];
155+
$url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
156+
$url .= $_SERVER['REQUEST_URI'];
157+
return $url;
158+
}
146159
}
147160

148161
/* End of file AnalyticsEvent.php */

0 commit comments

Comments
 (0)