function setUpUserDB() { if (!file_exists(USERDB_FILE_LOCATION)) { $aUserDB = new UserDB(); $aUserDB->setFileName(USERDB_FILE_LOCATION); $aNewUser = new User(); $aNewUser->setUserName("admin"); $aNewUser->setMD5Password("1234"); $aNewUser->setSecurityLevel(0); $aNewUser->setSecurityLevelType(SEC_LEVEL_GREATER_D); $aNewUser->rebuildElementLine(); $aUserDB->addElement($aNewUser); $aNewUser = new User(); $aNewUser->setType(PIN_TYPE_D); $aNewUser->setUserName("pin1"); $aNewUser->setMD5Password("1234"); $aNewUser->setSecurityLevel(0); $aNewUser->setSecurityLevelType(SEC_LEVEL_GREATER_D); $aNewUser->rebuildElementLine(); $aUserDB->addElement($aNewUser); $aUserDB->save(); } }
<?php require_once "../../include.php"; require_once FUNC_FILE_LOCATION . "debug.func.php"; require_once CLASS_FILE_LOCATION . "heyuconf.class.php"; require_once CLASS_FILE_LOCATION . "user.class.php"; //$testLine = "section timers"; echo "-------------------- Test bed for heyu conf classes --------------------<br/>"; echo "<br/>"; echo "The heyu conf file [x10.conf]<br/>"; echo "<br/>"; echo "* Test Heyu Conf file<br/>"; try { $aHeyuConf = new heyuConf("/etc/heyu/x10.conf"); echo " The return of heyu conf get alias objects<br/>"; $aUser = new User(); $aUser->setSecurityLevel(0); pr($aHeyuConf->getAliases($aUser)); echo " The return of heyu conf file<br/>"; pr($aHeyuConf); } catch (Exception $e) { echo " E!: " . $e->getMessage() . "<br/>"; } echo "-------------------- End Test bed for heyu conf classes --------------------<br/>";
case "edit": $tpl_edit = new Template(TPL_FILE_LOCATION . 'users_edit.tpl'); $tpl_edit->set('lang', $lang); $tpl_edit->set('theUser', $users[$_GET['line']]); $tpl_edit->set('config', $config); $tpl_body->set('form', $tpl_edit); break; case "add": $anUser = new User(); $anUser->setType($_POST["type"]); if ($_POST["type"] == PIN_TYPE_D) { $anUser->setUserName($userDB->getNextPINName()); } else { $anUser->setUserName($_POST["username"]); } $anUser->setSecurityLevel(intval($_POST["seclevel"])); $anUser->setSecurityLevelType($_POST["secleveltype"]); $anUser->setMD5Password($_POST["password"]); $anUser->rebuildElementLine(); $userDB->addElement($anUser); $mustSave = true; break; case "save": $users[$_POST["line"]]->setType($_POST["type"]); if ($_POST["type"] == PIN_TYPE_D && $_POST["username"] != $users[$_POST["line"]]->getUserName()) { $users[$_POST["line"]]->setUserName($userDB->getNextPINName()); } else { $users[$_POST["line"]]->setUserName($_POST["username"]); } $users[$_POST["line"]]->setSecurityLevel(intval($_POST["seclevel"])); $users[$_POST["line"]]->setSecurityLevelType($_POST["secleveltype"]);
function getUser() { if ($this->noSecurity) { $aUser = new User(); $aUser->setSecurityLevel(0); return $aUser; } return $this->theUser; }