本文整理匯總了PHP中Constants::GET_USERS_DIRECTORY方法的典型用法代碼示例。如果您正苦於以下問題:PHP Constants::GET_USERS_DIRECTORY方法的具體用法?PHP Constants::GET_USERS_DIRECTORY怎麽用?PHP Constants::GET_USERS_DIRECTORY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Constants
的用法示例。
在下文中一共展示了Constants::GET_USERS_DIRECTORY方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sha1
$message = '';
if (!isset($_SESSION['UID']) || !isset($_SESSION['USER'])) {
//If the form is submitted, then check the username and password
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['loginp']) && isset($_POST['loginu'])) {
$u = $_POST['loginu'];
$p = $_POST['loginp'];
$p = sha1($p);
//Unserialize all our users to check for a user with this name
$io = new FileIO();
$users = array();
$userFiles = $io->getDirectoryFiles(Constants::GET_USERS_DIRECTORY());
$cuser = new User('dummy1', 'dummy2');
$userFound = false;
foreach ($userFiles as $userFile) {
$val = $io->readFile(Constants::GET_USERS_DIRECTORY() . '/' . $userFile);
$cuser = unserialize($val);
if ($cuser->getUsername() == $u) {
$userFound = true;
break;
}
}
if ($userFound) {
if ($cuser->getPassword() == $p) {
$_SESSION['UID'] = $cuser->getUsername();
$_SESSION['USER'] = $cuser;
header("Location: " . get_absolute_uri('index.php'));
} else {
$message = "Please try again";
}
} else {
示例2: createUser
private function createUser($username, $password, $usertype, $pagePermissions)
{
$io = new FileIO();
$newuser = new User($username, $usertype);
$newuser->setPassword($password);
if (!empty($pagePermissions)) {
foreach ($pagePermissions as $page => $perm) {
$newuser->addPagePermission($page, $perm);
}
}
$filename = Constants::GET_USERS_DIRECTORY() . '/' . $username . '.usr';
$serialized = serialize($newuser);
return $io->writeFile($filename, $serialized);
}