public function current($skip_ajax = false, $no_get = false)
{
$u = false;
if ($skip_ajax == true) {
$is_ajax = $this->is_ajax();
if ($is_ajax == true) {
if ($_SERVER['HTTP_REFERER'] != false) {
$u = $_SERVER['HTTP_REFERER'];
}
}
}
if ($u == false and $this->current_url_var != false) {
$u = $this->current_url_var;
}
if ($u == false) {
if (!isset($_SERVER['REQUEST_URI'])) {
$serverrequri = $_SERVER['PHP_SELF'];
} else {
$serverrequri = $_SERVER['REQUEST_URI'];
}
$s = empty($_SERVER['HTTPS']) ? '' : $_SERVER['HTTPS'] == 'on' ? 's' : '';
$protocol = 'http';
$port = 80;
if (isset($_SERVER['SERVER_PROTOCOL'])) {
$protocol = $this->strleft(strtolower($_SERVER['SERVER_PROTOCOL']), '/') . $s;
}
if (isset($_SERVER['SERVER_PORT'])) {
$port = $_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] == '443' ? '' : ':' . $_SERVER['SERVER_PORT'];
}
if (isset($_SERVER['SERVER_PORT']) and isset($_SERVER['HTTP_HOST'])) {
if (strstr($_SERVER['HTTP_HOST'], ':')) {
// port is contained in HTTP_HOST
$u = $protocol . '://' . $_SERVER['HTTP_HOST'] . $serverrequri;
} else {
$u = $protocol . '://' . $_SERVER['HTTP_HOST'] . $port . $serverrequri;
}
} elseif (isset($_SERVER['HOSTNAME'])) {
$u = $protocol . '://' . $_SERVER['HOSTNAME'] . $port . $serverrequri;
}
}
if ($no_get == true) {
$u = strtok($u, '?');
}
if (is_string($u)) {
$u = str_replace(' ', '%20', $u);
}
return $u;
}