本文整理汇总了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);
}