Skip to content

Commit

Permalink
Merge pull request #2 from BassemN/issue-#1
Browse files Browse the repository at this point in the history
Fix: Undefined index: SCRIPT_URI issue
  • Loading branch information
craig-davis committed Dec 9, 2015
2 parents 6c37f43 + 2fa8315 commit 1a0b5db
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/There4/Analytics/AnalyticsEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function trackEvent($object, $action, $label = '', $value = 1)
$var_cookie = rand(10000000, 99999999); //random cookie number
$var_random = rand(1000000000, 2147483647); //number under 2147483647
$var_today = time(); //today
$var_referer = $_SERVER['SCRIPT_URI']; //referer url
$var_referer = $this->getCurrentUrl(); //referer url
$var_utmp = 'index.php';
$var_uservar = '';

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

return $is_gif;
}

/**
* Get the current Url
*
* @return string current url
*/
public function getCurrentUrl() {
$url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
$url .= '://' . $_SERVER['SERVER_NAME'];
$url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
$url .= $_SERVER['REQUEST_URI'];
return $url;
}
}

/* End of file AnalyticsEvent.php */

0 comments on commit 1a0b5db

Please sign in to comment.