Exemplo n.º 1
0
     array_push($errors, $check_user_name_result[1]);
 }
 //check password
 $check_user_password_result = check_user_password($password, $password_again);
 if ($check_user_password_result[0]) {
     $has_error = TRUE;
     array_push($errors, $check_user_password_result[1]);
 }
 //check mobile
 $check_user_mobile_result = check_user_mobile($mobile, $medoo);
 if ($check_user_mobile_result[0]) {
     $has_error = TRUE;
     array_push($errors, $check_user_mobile_result[1]);
 }
 //check email
 $check_user_email_result = check_user_email($email, $medoo);
 if ($check_user_email_result[0]) {
     $has_error = TRUE;
     array_push($errors, $check_user_email_result[1]);
 }
 if (!$has_error) {
     $head_portrait_origin = 'origin_head_portrait.jpg';
     $insert_result = $medoo->insert('users', ['name' => $name, 'password' => md5($password), 'email' => $email, 'mobile' => $mobile, 'created_at' => date('Y-m-d H:i:s'), 'head_portrait' => $head_portrait_origin]);
     if ($insert_result) {
         $_SESSION['errors']['state'] = 'am-alert-success';
         $_SESSION['errors']['details'] = ['恭喜您,注册成功!'];
         $_SESSION['user'] = $medoo->select('users', '*', ['id' => $insert_result])[0];
         header("Location:{$host_url}index.php");
         exit;
     } else {
         $_SESSION['errors']['state'] = 'am-alert-warning';
Exemplo n.º 2
0
 $allow_users_to_change_email_with_no_password = true;
 if (is_platform_authentication() && api_get_setting('allow_users_to_change_email_with_no_password') == 'false') {
     $allow_users_to_change_email_with_no_password = false;
 }
 // If user sending the email to be changed (input available and not frozen )
 if (api_get_setting('profile', 'email') == 'true') {
     if ($allow_users_to_change_email_with_no_password) {
         if (!check_user_email($user_data['email'])) {
             $changeemail = $user_data['email'];
         }
     } else {
         // Normal behaviour
         if (!check_user_email($user_data['email']) && $validPassword) {
             $changeemail = $user_data['email'];
         }
         if (!check_user_email($user_data['email']) && empty($user_data['password0'])) {
             Display::addFlash(Display::return_message(get_lang('ToChangeYourEmailMustTypeYourPassword'), 'error', false));
         }
     }
 }
 // Upload picture if a new one is provided
 if ($_FILES['picture']['size']) {
     $new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'], $user_data['cropResult']);
     if ($new_picture) {
         $user_data['picture_uri'] = $new_picture;
         Display::addFlash(Display::return_message(get_lang('PictureUploaded'), 'normal', false));
     }
 } elseif (!empty($user_data['remove_picture'])) {
     // remove existing picture if asked
     UserManager::delete_user_picture(api_get_user_id());
     $user_data['picture_uri'] = '';
Exemplo n.º 3
0
     array_push($errors, $check_user_name_result[1]);
 }
 //check password
 $check_user_password_result = check_user_password($password, $password_again);
 if ($check_user_password_result[0]) {
     $has_error = TRUE;
     array_push($errors, $check_user_password_result[1]);
 }
 //check mobile
 $check_user_mobile_result = check_user_mobile($mobile, $medoo);
 if ($check_user_mobile_result[0]) {
     $has_error = TRUE;
     array_push($errors, $check_user_mobile_result[1]);
 }
 //check email
 $check_user_email_result = check_user_email($mobile, $medoo);
 if (!$check_user_email_result[0]) {
     $has_error = TRUE;
     array_push($errors, $check_user_email_result[1]);
 }
 if (!$has_error) {
     $insert_result = $medoo->insert('users', ['name' => $name, 'password' => md5($password), 'email' => $email, 'mobile' => $mobile, 'touxiang' => $origin_touxiang, 'created_at' => date('Y-m-d H:i:s')]);
     if ($insert_result) {
         $_SESSION['errors']['state'] = 'am-alert-success';
         $_SESSION['errors']['details'] = ['恭喜您,注册成功!'];
         $_SESSION['user'] = $medoo->select('users', '*', ['id' => $insert_result])[0];
         header("Location:{$host_url}index.php");
         exit;
     } else {
         $_SESSION['errors']['state'] = 'am-alert-warning';
         $_SESSION['errors']['details'] = ['Sorry,@~_~@,我们的数据库出问题啦,稍后再试'];