class.helper.phps
<?php
class Helper
{
public static function getURL($path = null, $https = null)
{
return (($_SERVER['SERVER_PORT'] == 443 || $https === true) ? 'https://' : 'http://') .
$_SERVER['HTTP_HOST'] .
dirname($_SERVER['REQUEST_URI']) .
(isset($path)
? (strlen(dirname($_SERVER['REQUEST_URI'])) > 1 ? '/' : '')
: '');
}
public static function setURL($url)
{
if(empty($url)) {
return false;
}
if(!headers_send()) {
header('Location: ' . $url);
return true;
}
echo '<script>window.location.href="' . $url . '";</script><noscript><meta http-equiv="refresh" content="1;url=' . $url . '"></noscript>';
}
public static function getFileExtension($name)
{
if(strpos($name, '.') === false) {
return false;
}
return substr(strrchr($name, '.'), 1);
}
}
/* vim: set ts=4 sw=4 sts=4 tw=0 ft=php et :*/