function fAdminPage() { $aValSub = array('ausr' => array('inc' => 'adduser', 'func' => 'fAddUser'), 'dusr' => array('inc' => 'deluser', 'func' => 'fDelUser'), 'eusr' => array('inc' => 'edituser', 'func' => 'fEditUser')); if (isset($_REQUEST['sub'])) { if (isset($aValSub[$_REQUEST['sub']])) { include_once 'admin_' . $aValSub[$_REQUEST['sub']]['inc'] . INC; call_user_func($aValSub[$_REQUEST['sub']]['func']); exit; } else { $sAction = 'fake'; } } else { $sAction = 'default'; } switch ($sAction) { case 'fake': include_once 'fake' . INC; fFake(); break; default: include_once 'admin_startpage' . INC; fStartpage(); break; } exit; }
// define valid commands $aValCmd = array('adm' => array('inc' => 'admin', 'func' => 'fAdmin'), 'imp' => array('inc' => 'imprint', 'func' => 'fImprint'), 'li' => array('inc' => 'login', 'func' => 'fLogin'), 'pwd' => array('inc' => 'pwd', 'func' => 'fPwdLost'), 'reg' => array('inc' => 'register', 'func' => 'fRegister')); // validate input command, include command dependent function library and // call library main function if (isset($_REQUEST['cmd'])) { if (isset($aValCmd[$_REQUEST['cmd']])) { include_once $aValCmd[$_REQUEST['cmd']]['inc'] . INC; call_user_func($aValCmd[$_REQUEST['cmd']]['func']); exit; } else { $sAction = 'fake'; } } else { $sAction = 'default'; } // if there is no known library, check for alternatives switch ($sAction) { // if user tried to fake command parameter, log fake event and display // a message case 'fake': include_once 'fake' . INC; fFake(); break; // if there is no command parameter deliver the default start page // if there is no command parameter deliver the default start page default: include_once 'startpage' . INC; fStartpage(); break; } exit;