mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
moved check for valid url-params to Util (will be reused in spells, ect)
This commit is contained in:
@@ -1497,6 +1497,26 @@ class Util
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function isValidPage($struct, $keys)
|
||||
{
|
||||
switch (count($keys))
|
||||
{
|
||||
case 0:
|
||||
return true;
|
||||
case 1:
|
||||
return !$keys[0] || isset($struct[$keys[0]]);
|
||||
case 2:
|
||||
if (!isset($struct[$keys[0]]))
|
||||
return false;
|
||||
|
||||
return in_array($keys[1], $struct[$keys[0]]) || isset($struct[$keys[0]][$keys[1]]);
|
||||
case 3:
|
||||
return isset($struct[$keys[0]][$keys[1]]) && in_array($keys[2], $struct[$keys[0]][$keys[1]]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// BaseType::_construct craaap!
|
||||
// todo: unify names
|
||||
public static function getNameFieldName($tpl)
|
||||
|
||||
@@ -36,22 +36,7 @@ $validCats = array(
|
||||
)
|
||||
);
|
||||
|
||||
$valid = false;
|
||||
switch (count($cats))
|
||||
{
|
||||
case 0:
|
||||
$valid = true;
|
||||
case 1:
|
||||
$valid = !$cats[0] || isset($validCats[$cats[0]]);
|
||||
break;
|
||||
case 2:
|
||||
$valid = $cats[0] == 1 ? isset($validCats[$cats[0]][$cats[1]]) : isset($validCats[$cats[0]]) && in_array($cats[1], $validCats[$cats[0]]);
|
||||
break;
|
||||
case 3:
|
||||
$valid = $cats[0] == 1 ? isset($validCats[$cats[0]][$cats[1]]) && in_array($cats[2], $validCats[$cats[0]][$cats[1]]) : false;
|
||||
break;
|
||||
}
|
||||
if (!$valid)
|
||||
if (!Util::isValidPage($validCats, $cats))
|
||||
$smarty->error();
|
||||
|
||||
if (!$smarty->loadCache($cacheKey, $pageData))
|
||||
|
||||
Reference in New Issue
Block a user