Skip to content

Instantly share code, notes, and snippets.

@mymizan
Created March 14, 2018 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mymizan/e59e3bb5c23cbf41aaeac8733f2bf3e6 to your computer and use it in GitHub Desktop.
Save mymizan/e59e3bb5c23cbf41aaeac8733f2bf3e6 to your computer and use it in GitHub Desktop.
<?php
/**
* In addition to fixing the syntax error, I have also formatted the code to follow PSR coding standards
**/
define("ID_SITE", preg_replace("[^0-9a-z]*", "", strtolower(explode("/", $SERVER['REQUEST_URI'])[1])));
function redirect($uri, $getvar=null)
{
if (substr($uri, 0, 1) == '/') {
$uri=substr($uri, 1);
}
if (substr(strtolower($uri), 0, strlen(ID_SITE)) !=ID_SITE) {
$uri=ID_SITE . "/" . $uri;
}
if (is_array($getvar) && count($getvar)) {
if (substr_count($uri, "?")) {
foreach ($getvar as $key => $value) {
$uri .= "&" . $key . "=" . $value;
}
} else {
$uri="?";
foreach ($getvar as $key => $value) {
$uri.=$key."=".$value."&";
}
$uri=substr($uri, 0, -1);
}
}
header("Location: https://www.empowerdb.com/".$url);
die();
}
if (!$_GET['start'] || !$_GET['end']) {
redirect($SERVER["REQUEST_URI"] . "&e=6", array('start' => $_GET['start'], 'end' => $_GET['end']));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment