本文整理汇总了PHP中update_user函数的典型用法代码示例。如果您正苦于以下问题:PHP update_user函数的具体用法?PHP update_user怎么用?PHP update_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session
function session($user, $pass)
{
$user_file = 'config/users/' . $user . '.ini';
if (!file_exists($user_file)) {
return $str = '<li>Username not found in our record.</li>';
}
$user_enc = user('encryption', $user);
$user_pass = user('password', $user);
$user_role = user('role', $user);
if ($user_enc == "password_hash") {
if (password_verify($pass, $user_pass)) {
if (password_needs_rehash($user_pass, PASSWORD_DEFAULT)) {
update_user($user, $pass, $user_role);
}
$_SESSION[config("site.url")]['user'] = $user;
header('location: admin');
} else {
return $str = '<li>Your username and password mismatch.</li>';
}
} else {
if (old_password_verify($pass, $user_enc, $user_pass)) {
update_user($user, $pass, $user_role);
$_SESSION[config("site.url")]['user'] = $user;
header('location: admin');
} else {
return $str = '<li>Your username and password mismatch.</li>';
}
}
}
示例2: admin_test_main
function admin_test_main()
{
// Create user
echo '<br><h3>Creating User.</h3><br>';
$user_1 = user_1();
user\add_user($user_1);
echo '<br><h3>User created!</h3><br>';
// Verify
$user_1_db = user\authenticate_user($user_1['email_address'], $user_1['password']);
$user_1_id = $user_1_db['id'];
echo "<br><h3>User ID: {$user_1_id}</h3><br>";
// Update user
echo "<br><h3>Updating User.</h3><br>";
$user_1_db['email_address'] = 'User@Two.com';
$user_1_db['last_name'] = 'Two';
update_user($user_1_db);
echo "<br><h3>User Updated!</h3><br>";
// Verify
$user_2_db = user\authenticate_user('User@Two.com', $user_1['password']);
$new_last_name = $user_2_db['last_name'];
echo "<br><h3>New User Last Name: {$user_2_db}";
// Delete user
echo "<br><h3>Deleting User.</h3><br>";
delete_user(array("user_id" => $user_1_id));
echo "<br><h3>User deleted!</h3><br>";
}
示例3: set_cookie
function set_cookie($data)
{
//задаем cookie с уникальным идентификатором польз-ля
setcookie('user_id', $data['user_id'], time() + 3600 * 24 * 30);
//задаем cookie с хэш-строкой польз-ля
$hash_str = hash_gen(10);
update_user($data['user_id'], $hash_str);
setcookie('user_hash', $hash_str, time() + 3600 * 24 * 30);
header('Location: index.php');
exit;
}
示例4: recover
function recover($mode, $email)
{
$mode = sanitize($mode);
$email = sanitize($email);
$user_data = user_data(user_id_from_email($email), 'first_name', 'username');
if ($mode == 'username') {
email($email, 'Your username recvory', "Hello" . $user_data['first_name'] . ",\n\nYour username is:" . $user_data['username'] . "\n\n-stumbleupon");
} else {
if ($mode == 'password') {
$generated_password = substr(md5(rand(999, 999999)), 0, 8);
change_password($user_data['user_id'], $generated_password);
update_user($user_data['user_data'], array('password_recover' => '1'));
email($email, 'Your password recvory', "Hello" . $user_data['first_name'] . ",\n\nYour New Password is:" . $generated_password . "\n\n-StumbleUpon");
}
}
}
示例5: index
public function index()
{
$root = array();
$root['return'] = 1;
$email = addslashes($GLOBALS['request']['email']);
//用户名或邮箱
$pwd = addslashes($GLOBALS['request']['pwd']);
//密码
$user_info = user_check($email, $pwd);
$user_id = intval($user_info['id']);
if (!$user_info) {
$root['status'] = 0;
$root['message'] = "用户已失效,无法升级";
output($root);
} else {
$upd_user_name = addslashes($GLOBALS['request']['upd_user_name']);
$upd_password = addslashes($GLOBALS['request']['upd_password']);
$user_data = array('id' => $user_id, 'user_name' => $upd_user_name, 'user_pwd' => $upd_password, 'email' => $upd_user_name);
$res = update_user($user_id, $user_data);
//print_r($res);
if ($res['status'] == 1) {
$root['status'] = 1;
$root['uid'] = $user_id;
$root['user_name'] = $upd_user_name;
$root['password'] = md5($upd_password);
$root['is_account'] = 1;
output($root);
} else {
$error = $res['data'];
if (!$error['field_show_name']) {
$error['field_show_name'] = $GLOBALS['lang']['USER_TITLE_' . strtoupper($error['field_name'])];
}
if ($error['error'] == EMPTY_ERROR) {
$error_msg = sprintf($GLOBALS['lang']['EMPTY_ERROR_TIP'], $error['field_show_name']);
}
if ($error['error'] == FORMAT_ERROR) {
$error_msg = sprintf($GLOBALS['lang']['FORMAT_ERROR_TIP'], $error['field_show_name']);
}
if ($error['error'] == EXIST_ERROR) {
$error_msg = sprintf($GLOBALS['lang']['EXIST_ERROR_TIP'], $error['field_show_name']);
}
$root['status'] = 0;
$root['message'] = $error_msg;
output($root);
}
}
}
示例6: author_save
/**
* Updates a user.
*/
function author_save()
{
global $txp_user;
require_privs('admin.edit');
extract(psa(array('privs', 'name', 'RealName', 'email')));
$privs = assert_int($privs);
if (!is_valid_email($email)) {
author_list(array(gTxt('email_required'), E_ERROR));
return;
}
$rs = update_user($name, $email, $RealName);
if ($rs && ($txp_user === $name || change_user_group($name, $privs))) {
author_list(gTxt('author_updated', array('{name}' => $RealName)));
return;
}
author_list(array(gTxt('author_save_failed'), E_ERROR));
}
示例7: recover
function recover($mode, $email)
{
$user_data = user_data(user_id_from_email($email), 'user_id', 'first_name', 'username');
if ($mode == 'username') {
// recover username
email($email, 'Your username', "Hello " . $user_data['first_name'] . ",\n\nYour username is: " . $user_data['username'] . "\n\n-sparklet");
} else {
if ($mode == 'password') {
// recover password
$generated_password = substr(md5(rand(999, 999999)), 0, 8);
// die($generated_password);
change_password($user_data['user_id'], $generated_password);
update_user($user_data['user_id'], array('password_recover' => '1'));
email($email, 'Your password recovery', "Hello " . $user_data['first_name'] . ",\n\nYour new password is: " . $generated_password . "\n\n-sparklet");
}
}
}
示例8: recover
function recover($mode, $email)
{
$mode = sanitize($mode);
$email = sanitize($email);
$user_data = user_data(user_id_from_email($email), 'user_id', 'first_name');
if ($mode == 'username') {
email($email, 'Your username', " Hello " . $userdata['first_name'] . ",\n\nYour username is : " . $user_data['username'] . "\n\n-Utkal Placement");
} else {
if ($mode == 'password') {
$temp_password = substr(md5(rand(9999, 999999)), 0, 8);
change_password($user_data['user_id'], $temp_password);
update_user($user_data['user_id'], array('password_recover' => '1'));
email($email, 'Your password Recovery', " Hello " . $userdata['first_name'] . ",\n\nYour new password is : " . $temp_password . "\n\nPlease log in to change this.\n\n-Utkal Placement");
}
}
//$temp_pass= md5($temp_pass);
//mysql_query("UPDATE `users` SET `pass_temp` = '$temp_pass' WHERE `email` = '$email'");
}
示例9: recover
function recover($mode, $email)
{
// recupereaza numele de utilizator sau parola - $mode poate lua valoarea de 'username' sau 'password'
include 'core/db/db_connection.php';
$mode = sanitize($mode);
$email = sanitize($email);
$user_data = user_data(get_user_id_from_email($email), 'user_id', 'first_name', 'username');
if ($mode == 'username') {
email($email, 'Your username', "\n\t\t\t\tHello " . $user_data['first_name'] . ", <br><br>\n\t\t\t\tYour username is " . $user_data['username'] . " <br><br>\n\t\t\t\t-worldtour team\n\t\t\t");
} else {
if ($mode == 'password') {
$generated_password = substr(md5(rand(777, 7777)), 0, 7);
// generam o parola random de 7 caractere pe care o criptam cu md5
change_password($user_data['user_id'], $generated_password);
update_user($user_data['user_id'], array('pwd_recovery' => '1'));
// folosim un 'flag' asupra contului pentru a forta utilizatorul sa-si schimbe parola generata de noi prima oara cand se logheaza
email($email, 'Password recovery', "\n\t\t\t\tHello " . $user_data['first_name'] . ", <br><br>\n\t\t\t\tYour new password is " . $generated_password . "<br><br>\n\t\t\t\tKindly note that this is a temporary password and you are required to change it on your first log in. <br><br>\n\t\t\t\t-worldtour team\n\t\t\t");
}
}
}
示例10: save_user
function save_user($entity)
{
if (!$entity->is_new()) {
return update_user($entity);
} else {
if ($entity->validate()) {
global $__db_conn;
$sql = "INSERT INTO user(created_at,updated_at,username,password,role) values (':created_at:',':updated_at:',':username:',':password:',':role:')";
$sql = str_replace(":created_at:", Date("Y-m-d"), $sql);
$sql = str_replace(":updated_at:", Date("Y-m-d"), $sql);
preg_match_all("/:([a-zA-Z_0-9]*):/", $sql, $matches);
foreach ($matches[1] as $attr) {
$sql = str_replace(":{$attr}:", $entity->{$attr}, $sql);
}
mysql_query($sql, $__db_conn);
$entity->id = mysql_insert_id($__db_conn);
return true;
} else {
return false;
}
}
}
示例11: foreach
foreach ($bill_access_list as $ac) {
if ($ac == $bill['bill_id']) {
$done = 1;
}
}
if (!$done) {
echo "<option value='" . $bill['bill_id'] . "'>" . $bill['bill_name'] . "</option>";
}
}
echo "</select>\n </div>\n <button type='submit' class='btn btn-default' name='Submit' value='Add'>Add</button>\n </form>\n </div>";
} elseif ($vars['user_id'] && $vars['edit']) {
if (!empty($vars['new_level'])) {
if ($vars['can_modify_passwd'] == 'on') {
$vars['can_modify_passwd'] = '1';
}
update_user($vars['user_id'], $vars['new_realname'], $vars['new_level'], $vars['can_modify_passwd'], $vars['new_email']);
print_message("User has been updated");
}
if (can_update_users() == '1') {
$users_details = get_user($vars['user_id']);
if (!empty($users_details)) {
if (empty($vars['new_realname'])) {
$vars['new_realname'] = $users_details['realname'];
}
if (empty($vars['new_level'])) {
$vars['new_level'] = $users_details['level'];
}
if (empty($vars['can_modify_passwd'])) {
$vars['can_modify_passwd'] = $users_details['can_modify_passwd'];
} elseif ($vars['can_modify_passwd'] == 'on') {
$vars['can_modify_passwd'] = '1';
示例12: handle_user_update
function handle_user_update(&$HTTP_VARS, &$errors)
{
$user_r = fetch_user_r($HTTP_VARS['user_id']);
if (is_not_empty_array($user_r)) {
if (validate_user_info($user_r, $HTTP_VARS, $address_attribs_provided, $errors)) {
if (update_user($HTTP_VARS['user_id'], $HTTP_VARS['fullname'], $HTTP_VARS['uid_language'], $HTTP_VARS['uid_theme'], $HTTP_VARS['email_addr'], $HTTP_VARS['user_role'])) {
return update_user_addresses($user_r, $address_provided_r, $HTTP_VARS, $errors);
} else {
$db_error = db_error();
$errors[] = array('error' => get_opendb_lang_var('user_not_updated', 'user_id', $HTTP_VARS['user_id']), 'detail' => $db_error);
return FALSE;
}
} else {
return FALSE;
}
} else {
$errors[] = array('error' => get_opendb_lang_var('user_not_found', 'user_id', $HTTP_VARS['user_id']));
return FALSE;
}
}
示例13: get_action
} else {
return false;
}
}
function get_action($code)
{
global $ACTIONS;
return isset($ACTIONS[$code]) ? $ACTIONS[$code] : null;
}
function delete_action($code)
{
global $ACTIONS;
if (isset($ACTIONS[$code])) {
unset($ACTIONS[$code]);
return true;
} else {
return false;
}
}
function update_action($par)
{
if (isset($par['code']) && delete_action($par['code'])) {
add_action($par);
}
}
add_action(array('code' => 'track_activity', 'rule' => 'public', 'category' => 'all', 'zone' => 'before_template', 'priority' => 1000, 'function' => function () {
if (check_login()) {
$ID = current_user('ID');
update_user($ID, array('last_activity' => date('c'), 'last_place' => BASE_URL . $_SERVER['REQUEST_URI']));
}
}));
示例14: update_user
// attributes associated with
// a user
// the caller wishes to update
// attributes associated with
// a user
case "update_user":
$uid = $_POST['ajax_uid'];
$fname = $_POST['ajax_fname'];
$lname = $_POST['ajax_lname'];
$email = $_POST['ajax_email'];
$active = $_POST['ajax_active'];
$new_passwd = "";
if (isset($_POST['ajax_newpasswd'])) {
$new_passwd = $_POST['ajax_newpasswd'];
}
update_user($uid, $new_passwd, $fname, $lname, $email, $active);
break;
// the caller wishes to add a new
// user to the db
// the caller wishes to add a new
// user to the db
case "add_user":
$uname = $_POST['ajax_uname'];
$passwd = $_POST['ajax_passwd'];
$fname = $_POST['ajax_fname'];
$lname = $_POST['ajax_lname'];
$email = $_POST['ajax_email'];
$active = $_POST['ajax_active'];
add_user($uname, $passwd, $fname, $lname, $email, $active);
// regenerate the user list
// and send back the new list
示例15: foreach
if (false !== strpos(Session::allowedSensors($login), $sensor_ip)) {
if ($sensors == "") {
$sensors = $sensor_ip;
} else {
$sensors .= "," . $sensor_ip;
}
}
}
foreach ($ACL_MAIN_MENU as $mainmenu => $menus) {
foreach ($menus as $key => $menu) {
if ($gacl->acl_check($mainmenu, $key, ACL_DEFAULT_USER_SECTION, $login)) {
$perm_id = $permids[$mainmenu][$key];
if ($perm_id > 0) {
$perms[$perm_id] = true;
}
}
}
}
$template_id = insert_template($conn, $login . "_gacl", $nets, $sensors, $perms);
if ($template_id > 0) {
echo "Template '" . $login . "_gacl' ID{$template_id} successfully inserted into 'acl_templates'\n";
if (update_user($conn, $login, $template_id)) {
echo "...asigned to user {$login}\n\n";
} else {
echo "...not asigned to user {$login}. An error has occured\n\n";
}
} else {
echo "Error creating template '" . $login . "_gacl'\n";
}
}
$db->close();