Merge branch 'fronkdev' into 'master'
Added fancyurl execption in mfRouter for Login process See merge request fronk/thetool!69
This commit is contained in:
@@ -72,6 +72,7 @@ class mfRouter {
|
||||
|
||||
// get baseurl from fancy urls if used
|
||||
if(MFUSEFANCYURLS) {
|
||||
//var_dump($umod, $uaction, $_SERVER);
|
||||
if(!$umod) {
|
||||
$baseurl = $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
@@ -85,6 +86,89 @@ class mfRouter {
|
||||
$baseurl = $m[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Special case for login, because mod/action in $request mask the real url
|
||||
if($_SERVER['REQUEST_METHOD'] == "POST" && $umod == "mfLogin" && $uaction == "Login") {
|
||||
// try to extract baseurl from env
|
||||
// may not work on all webservers
|
||||
$virtual = preg_replace('@/+$@', "", $_SERVER["REQUEST_URI"]);
|
||||
$real = preg_replace('@/+$@', "", $_SERVER['PHP_SELF']);
|
||||
|
||||
$virtual_parts = explode("/", $virtual);
|
||||
$real_parts = explode("/", $real);
|
||||
|
||||
/*
|
||||
* if there are no parts then we're good.
|
||||
* Else find Action in last and Mod in second to last part.
|
||||
* Action is optional.
|
||||
*
|
||||
* In rare cases some parts can match by accident if a folder is
|
||||
* named the same as a mod or action. There is nothing we can do.
|
||||
*/
|
||||
$id_part_virtual = false;
|
||||
$action_part = false;
|
||||
$mod_part = false;
|
||||
|
||||
if(is_numeric($virtual_parts[count($virtual_parts) - 1]) && count($virtual_parts) > 2 && count($real_parts)) {
|
||||
|
||||
$id_part_virtual = $virtual_parts[count($virtual_parts) - 1];
|
||||
$id_part_real = $real_parts[count($real_parts) - 1];
|
||||
|
||||
$action_part_virtual = $virtual_parts[count($virtual_parts) - 2];
|
||||
$action_part_real = $real_parts[count($real_parts) - 2];
|
||||
|
||||
$mod_part_virtual = $virtual_parts[count($virtual_parts) - 3];
|
||||
$mod_part_real = $real_parts[count($real_parts) - 3];
|
||||
|
||||
if($id_part_virtual != $id_part_real) {
|
||||
$id_part = $id_part_virtual;
|
||||
}
|
||||
if($action_part_virtual != $action_part_real) {
|
||||
$action_part = $action_part_virtual;
|
||||
}
|
||||
if($mod_part_virtual != $mod_part_real) {
|
||||
$mod_part = $mod_part_virtual;
|
||||
}
|
||||
|
||||
} elseif(count($virtual_parts) > 1 && count($real_parts)) {
|
||||
$action_part_virtual = $virtual_parts[count($virtual_parts) - 1];
|
||||
$action_part_real = $real_parts[count($real_parts) - 1];
|
||||
|
||||
$mod_part_virtual = $virtual_parts[count($virtual_parts) - 2];
|
||||
$mod_part_real = $real_parts[count($real_parts) - 2];
|
||||
|
||||
if($action_part_virtual != $action_part_real) {
|
||||
$action_part = $action_part_virtual;
|
||||
}
|
||||
if($mod_part_virtual != $mod_part_real) {
|
||||
$mod_part = $mod_part_virtual;
|
||||
}
|
||||
|
||||
} elseif(count($virtual_parts) && count($real_parts)) {
|
||||
$mod_part_virtual = $virtual_parts[count($virtual_parts) - 1];
|
||||
$mod_part_real = $real_parts[count($real_parts) - 1];
|
||||
|
||||
if($mod_part_virtual != $mod_part_real) {
|
||||
$mod_part = $mod_part_virtual;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($id_part) {
|
||||
if(preg_match("#^(.+)/$mod_part/$action_part/$id_part/?\\??#i",$_SERVER['REQUEST_URI'],$m)) {
|
||||
$baseurl = $m[1];
|
||||
}
|
||||
} elseif($mod_part) {
|
||||
if(preg_match("#^(.+)/$mod_part/$action_part/?\\??#i",$_SERVER['REQUEST_URI'],$m)) {
|
||||
$baseurl = $m[1];
|
||||
}
|
||||
} else {
|
||||
if(preg_match("#^(.+)/$action_part/?\\??#i",$_SERVER['REQUEST_URI'],$m)) {
|
||||
$baseurl = $m[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
define("MFFANCYBASEURL",$baseurl);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user