本文整理汇总了PHP中user::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP user::exists方法的具体用法?PHP user::exists怎么用?PHP user::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user
的用法示例。
在下文中一共展示了user::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user
function get_user()
{
if (is_null($this->logged_in_user)) {
$id = $this->session->userdata('flogged_in_id');
if (is_numeric($id)) {
$u = new user();
$u->get_by_id($id);
if ($u->exists()) {
$this->logged_in_user = $u;
return $this->logged_in_user;
}
}
return FALSE;
} else {
return $this->logged_in_user;
}
}
示例2: add
/**
* Add new maintainer
*
* @static
* @param mixed Name of the package or it's ID
* @param string Handle of the user
* @param string Role of the user
* @param integer Is the developer actively working on the project?
* @return mixed True or PEAR error object
*/
static function add($package, $user, $role, $active = 1)
{
global $dbh;
include_once 'pear-database-user.php';
if (!user::exists($user)) {
throw new InvalidArgumentException("User {$user} does not exist");
}
include_once 'pear-database-package.php';
if (is_string($package)) {
$package = package::info($package, 'id');
}
$sql = 'INSERT INTO maintains (handle, package, role, active) VALUES (?, ?, ?, ?)';
$err = $dbh->query($sql, array($user, $package, $role, (int) $active));
if (DB::isError($err)) {
return $err;
}
$packagename = package::info($package, 'name');
include_once 'pear-rest.php';
$pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
$pear_rest->savePackageMaintainerREST($packagename);
return true;
}
示例3: array
if (PEAR::isError($pacid)) {
$errors[] = $pacid->getMessage();
break;
}
include_once 'pear-database-user.php';
if (!auth_check('pear.admin') && !auth_check('pear.qa') && !user::maintains($auth_user->handle, $pacid, 'lead')) {
$errors[] = 'You don\'t have permissions to upload this release.';
break;
}
$license = $info->getLicense();
if (is_array($license)) {
$license = $license['_content'];
}
$users = array();
foreach ($info->getMaintainers() as $user) {
if (!user::exists($user['handle'])) {
$errors[] = 'Unknown user: ' . $user['handle'];
continue;
}
$users[strtolower($user['handle'])] = array('role' => $user['role'], 'active' => !isset($user['active']) || $user['active'] == 'yes');
}
include_once 'pear-database-maintainer.php';
$e = maintainer::updateAll($pacid, $users, false, true);
if (PEAR::isError($e)) {
$errors[] = $e->getMessage();
break;
}
$e = package::updateInfo($pacid, array('summary' => $info->getSummary(), 'description' => $info->getDescription(), 'license' => $license));
if (PEAR::isError($e)) {
$errors[] = $e->getMessage();
break;
示例4: user
<?php
$ci =& get_instance();
$u = new user();
$u->get_by_name($ci->input->post('name'));
if ($u->exists()) {
$ci->app->add_error("user name duplication please choose another name ");
} else {
$u->name = $ci->input->post('name');
$u->set_password($ci->input->post('password'));
$u->email = $ci->input->post('email');
$u->level = $ci->input->post('level');
$u->save();
redirect($ci->app->app_url('View users'));
}
示例5: validateRequest
function validateRequest($handle, $password, $password2, $name)
{
$errors = array();
if (empty($handle) || !preg_match('/^[0-9a-z_]{2,20}\\z/', $handle)) {
$errors[] = 'Username is invalid.';
$display_form = true;
}
if ($password == md5('') || empty($password)) {
$errors[] = 'Password must not be empty';
}
if ($password !== $password2) {
$errors[] = 'Passwords do not match';
}
include_once 'pear-database-user.php';
if (user::exists($handle)) {
$errors[] = 'User name "' . $handle . '" already exists, please choose another user name';
}
$name_parts = explode(' ', $name, 2);
if (count($name_parts) == 2) {
$firstname = $name_parts[0];
$lastname = $name_parts[1];
} else {
$firstname = $name_parts[0];
$lastname = null;
}
// First- and lastname must be longer than 1 character
if (strlen($firstname) == 1) {
$errors[] = 'Your firstname appears to be too short.';
}
if (strlen($lastname) == 1) {
$errors[] = 'Your lastname appears to be too short.';
}
// No names with only uppercase letters
if ($firstname === strtoupper($firstname)) {
$errors[] = 'Your firstname must not consist of only uppercase letters.';
}
if ($lastname === strtoupper($lastname)) {
$errors[] = 'Your lastname must not consist of only uppercase letters.';
}
return $errors;
}
示例6: foreach
include_once 'pear-database-release.php';
$items = release::getPopular(10, true);
foreach ($items as $i => $item) {
$items[$i]['releasenotes'] = 'Downloads per day: ' . number_format($item['releasenotes'], 2);
}
$channel_title = 'PEAR: Popular releases';
$channel_description = 'The most popular releases in PEAR.';
break;
case 'bug':
$_REQUEST = array('id' => $argument, 'format' => 'rss');
include dirname(dirname(__FILE__)) . '/bugs/rss/bug.php';
exit;
case 'user':
$user = $argument;
include_once 'pear-database-user.php';
if (!user::exists($user)) {
rss_bailout();
}
$name = user::info($user, "name");
$channel_title = "PEAR: Latest releases for " . $user;
$channel_description = "The latest releases for the PEAR developer " . $user . " (" . $name['name'] . ")";
$items = user::getRecentReleases($user);
break;
case 'pkg':
$package = $argument;
include_once 'pear-database-package.php';
if (package::isValid($package) == false) {
rss_bailout();
return PEAR::raiseError("The requested URL " . $_SERVER['REQUEST_URI'] . " was not found on this server.");
}
$channel_title = "Latest releases of " . $package;
示例7: perform_user_removal
function perform_user_removal()
{
// User accounts are not actually deleted from the database. They are flagged as INACTIVE because the user ID is referenced
// by other tables that need to maintain a historical record of actions performed by that user (e.g. rappels.confirmed_by).
if (!isset($_POST['user_id'])) {
throw new Exception('You must specify a user account to remove!');
}
if (!user::exists($_POST['user_id'])) {
throw new Exception('The requested user account does not exist!');
}
$user = new user();
$user->load($_POST['user_id']);
$user->set('inactive', 1);
$user->save();
return 1;
}
示例8: md5
case update:
group::set($_GET[user], $_GET[group]);
break;
case add:
if ($_GET[user] and $_GET[password]) {
if (!user::exists($_GET[user])) {
$user = $_GET[user];
$md5Password = md5($_GET[password]);
database::query("INSERT INTO user SET user='{$user}',password='{$md5Password}',`group`='4'");
} else {
echo "<div id='alert'><b>User schon vergeben</div>";
}
}
break;
case deleteuser:
if (user::exists($id)) {
echoalert("Benutzer " . user::name($id) . " gelöscht");
database::query("DELETE FROM user WHERE ID='{$id}'");
}
break;
}
$userArray = fetch_to_array(database::query("SELECT user.ID,user.user,user.password,user.group,user.status,`group`.name FROM user,`group` WHERE user.group=group.ID ORDER BY user"), "");
// list users
echo "<div id='infobig'>";
echo "<fieldset><legend>User</legend>";
echo "<table border='1'>";
echo "<th>User</th>";
echo "<th>Group</th>";
echo "<th></th>";
echo "<th></th>";
echo "<th>Last Login</th>";
示例9: user
<?php
$ci =& get_instance();
$l = new user();
$l->get_by_id($ci->uri->segment(5));
if (!$l->exists()) {
$ci->app->add_error("User not found");
} else {
$l->delete();
$ci->app->add_info(" user deleted ");
}
示例10: substr
+----------------------------------------------------------------------+
$Id$
*/
/**
* On 404 error this will search for a package with the same
* name as the requested document. Thus enabling urls such as:
*
* http://pear.php.net/Mail_Mime
*/
/**
* Requesting something like /~foobar will redirect to the account
* information page of the user "foobar".
*/
if (strlen($_SERVER['REDIRECT_URL']) > 0 && $_SERVER['REDIRECT_URL'][1] == '~') {
$user = substr($_SERVER['REDIRECT_URL'], 2);
if (preg_match(PEAR_COMMON_USER_NAME_REGEX, $user) && user::exists($user)) {
localRedirect("/user/" . urlencode($user));
}
}
$pkg = strtr($_SERVER['REDIRECT_URL'], '-', '_');
$pinfo_url = '/package/';
// Check strictly
$name = package::info(basename($pkg), 'name');
if (!DB::isError($name) && !empty($name)) {
if (!empty($name)) {
localRedirect($pinfo_url . $name);
} else {
$name = package::info(basename($pkg), 'name', true);
if (!empty($name)) {
header('HTTP/1.0 301 Moved Permanently');
header('Location: http://pear.php.net/package/' . $name);
示例11: _fget_user
private function _fget_user()
{
$id = $this->session->userdata('flogged_in_id');
if (is_numeric($id)) {
$u = new user();
$u->get_by_id($id);
if ($u->exists()) {
$logged_in_user = $u;
return $logged_in_user;
}
}
return FALSE;
}
示例12: user
// $Lname=input::get('LastName');
// echo $Fname." ".$Lname ;
/*
* if ($user->hasPermission ( 'admin' )) {
* echo 'You are an admin';
* }
*/
// $currentID=$_SESSION['UserID'];
// echo $currentID;
$UserID2 = input::get('User');
// $user= new user($UserID);
if (!$UserID2 == input::get('User')) {
redirect::to('index.php');
} else {
$user2 = new user($UserID2);
if (!$user2->exists()) {
redirect::to('404');
} else {
$data = $user2->data();
?>
<link href="<?php
echo 'style.css';
?>
" rel='stylesheet' type='text/css'>
<h3><?php
echo escape($data->UserID);
?>
</h3>
<p>FirstName: <?php
echo escape($data->FirstName);
示例13: user
<?php
require_once '../Core/init.php';
if (!($username = input::get('user'))) {
redirect::to('../index.php');
} else {
$user = new user($username, $_log);
if (!$user->exists()) {
redirect::to(404);
} else {
$data = $user->data();
}
?>
<h3><?php
echo escape($data->User_Name);
?>
</h3>
<p>Full name: <?php
echo escape($data->Name);
?>
</p>
<?php
}
示例14: ___onTarget
function ___onTarget()
{
if ($_REQUEST['action'] == 'register') {
$GLOBALS['core']->event('register');
//validation
if (empty($_REQUEST['username'])) {
$GLOBALS['err']->add("Name can't be blank.", array('username', 'register'));
}
if (user::exists($_REQUEST['username'])) {
$GLOBALS['err']->add("Name already exists. choose another.", array('username', 'register'));
}
if (empty($_REQUEST['password1'])) {
$GLOBALS['err']->add("Password can't be blank.", array('password1', 'register'));
} elseif ($_REQUEST['password1'] != $_REQUEST['password2']) {
$GLOBALS['err']->add("Passwords don't match.", array('password2', 'register'));
} elseif ($_REQUEST['password1'] == $_REQUEST['password2'] && $GLOBALS['err']->none()) {
//logout first, just in case
if (user::whoAmI() == 'temp') {
user::logout();
}
if (user::register($_REQUEST['username'], $_REQUEST['password1'])) {
session_regenerate_id();
//sort of prevent session-hijacking
$_REQUEST['password'] = $_REQUEST['password1'];
$_REQUEST['action'] = 'login';
$GLOBALS['state'] = 'successful registration';
$GLOBALS['core']->event('registrationSuccess');
} else {
$GLOBALS['err']->add("Unable to register for some reason. Please let us know about it.", 'registration');
$GLOBALS['core']->event('registrationFailure');
}
}
}
if ($_REQUEST['action'] == 'login') {
$GLOBALS['core']->event('login');
if (empty($_REQUEST['username'])) {
$GLOBALS['err']->add("You left out the name.", array('username', 'login'));
}
if (empty($_REQUEST['password'])) {
$GLOBALS['err']->add("You left out the password.", array('password', 'login'));
}
if (!empty($_REQUEST['username']) && !empty($_REQUEST['password'])) {
if (!user::login($_REQUEST['username'], $_REQUEST['password'])) {
$GLOBALS['err']->add("Wrong.", 'login');
} else {
$loginSuccess = true;
session_regenerate_id();
//prevent session hijacking.
}
}
$GLOBALS['core']->event($loginSuccess ? 'loginSuccess' : 'loginFailure');
}
if ($_REQUEST['action'] == 'logout') {
$GLOBALS['core']->event('logout');
session_regenerate_id(true);
//kill old session.
user::logout();
header("Location: /");
exit;
}
if (!user::loggedIn()) {
//login as temp user
//user::loginTemp();
}
}
示例15: auth_require
if (!(isset($maintainers[$auth_user->handle]) && $maintainers[$auth_user->handle]['role'] == 'lead')) {
auth_require('pear.qa');
}
if (isset($_POST) && isset($_POST['role'])) {
if (!validate_csrf_token($csrf_token_name)) {
report_error('Invalid token.');
response_footer();
exit;
}
// Got a new maintainer?
if (isset($_POST['handle']['new']) && !empty($_POST['handle']['new'])) {
$new = strip_tags($_POST['handle']['new']);
include_once 'pear-database-user.php';
if (!ereg('^[0-9a-z_]{2,20}$', $new)) {
report_error('Invalid handle: ' . $new);
} elseif (!user::exists($new)) {
report_error($new . ' does not exist.');
} else {
$role = $_POST['role']['new'];
if (!maintainer::isValidRole($role)) {
report_error('Invalid role.');
} else {
if (maintainer::add($pid, $new, $role)) {
$message = 'Maintainer ' . $new . 'sucessfully added.';
$maintainers[$new] = array('role' => $role, 'active' => 1);
}
}
}
} else {
$new = '';
}