View Single Post
  #2  
Old 12-05-2012, 04:54 AM
powerchaos's Avatar
powerchaos powerchaos is offline
WebMaster
 
Join Date: May 2008
Posts: 130
Gender: Male
Credits: 10,150
powerchaos
Send a message via AIM to powerchaos Send a message via MSN to powerchaos
Default

it is nice

maybe with this code snippet is it possible to automatic include mods with out the need to edit files

its taken from my own script and written as a function

maybe with some edits it could be possible to use that to check if some maps exist
and then showing the index file based on the map (or add a double check so it does not only look for php files but for the maps that contains a index file )


PHP Code:
//show admin pages + staff pages +  normal pages 
if ($_SESSION['admin'] == "1")
{
function 
showpage()
{
$file "./pages/".$_GET['page'].".php";
$admin "./pages/admin/".$_GET['admin'].".php";
$staff "./pages/staff/".$_GET['staff'].".php";
if (
file_exists($file))
{
include (
"$file");
}
else if (
file_exists($admin)) 
{
include (
"$admin");
}
else if (
file_exists($staff)) 
{
include (
"$staff");
}
else
{
include (
"./pages/home.php");
}
}
}
// show only staff + normal pages
else if ($_SESSION['staff'] == "1")
{
function 
showpage()
{
$file "./pages/".$_GET['page'].".php";
$staff "./pages/staff/".$_GET['staff'].".php";
if (
file_exists($file))
{
include (
"$file");
}
else if (
file_exists($staff)) 
{
include (
"$staff");
}
else
{
include (
"./pages/home.php");
}
}
}
else if (
$_SESSION['ban'] > "0")
{
// show a banned text and prevent other pages from opening
function showpage()
{
echo (
"we are sorry , but your account is banned");
}
}
else
{
// show normal pages only
function showpage()
{
$file "./pages/".$_GET['page'].".php";
if (
file_exists($file))
{
include (
"$file");
}
else
{
include (
"./pages/home.php");
}
}

in the above example i just need to put a file in a certian folder and it works
i can call the page then with ?admin=xxx or ?staff=XXX or ?page=XXX

to be able to work with this mod does it need a rewrite ofcourse , but this is just the core function

Greetings From PowerChaos
Reply With Quote