PHP User::check_username Examples

PHP User::check_username - 8 examples found. These are the top rated real world PHP examples of User::check_username extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function check_username()
 {
     if (User::check_username(Input::get("username"))) {
         return "true";
     } else {
         return "false";
     }
 }
Example #2
0
 public function postRegister()
 {
     var_dump(Input::all());
     $rules = array("username" => "required|min:3|max:25", "password" => "required|min:6|max:25", "email" => "required|email", "name" => "required|max:25");
     if (!Validator::make(Input::all(), $rules)->fails()) {
         if (User::check_username(Input::get("username")) && User::check_email(Input::get("email"))) {
             var_dump('fsdfsdfsdfsd');
             $user = new User();
             $user->username = Input::get("username");
             $user->password = md5(sha1(Input::get("password")));
             $user->email = Input::get("email");
             $user->name = Input::get("name");
             $user->save();
             Logfile::addData('Đăng ký', 'Thành viện', $user->id, $user->name);
             User::find($user->id)->roles()->attach(1);
             Session::put("logined", "true");
             Session::put('name', $user->name);
             Session::put('id_taikhoan', $user->id);
             Session::put("register_success", Input::get('username') . " đã đăng ký thành công");
             return Redirect::to("/");
         }
     }
     var_dump(Input::all());
 }
Example #3
0
     Error::add('username', T_("You did not enter a username"));
 }
 if (!$fullname) {
     Error::add('fullname', T_("Please fill in your full name (Firstname Lastname)"));
 }
 // Check the mail for correct address formation.
 if (!Mailer::validate_address($email)) {
     Error::add('email', T_('Invalid email address'));
 }
 if (!$pass1) {
     Error::add('password', T_("You must enter a password"));
 }
 if ($pass1 != $pass2) {
     Error::add('password', T_("Your passwords do not match"));
 }
 if (!User::check_username($username)) {
     Error::add('duplicate_user', T_("Error Username already exists"));
 }
 // If we've hit an error anywhere up there break!
 if (Error::occurred()) {
     require_once AmpConfig::get('prefix') . '/templates/show_user_registration.inc.php';
     break;
 }
 /* Attempt to create the new user */
 $access = '5';
 switch (AmpConfig::get('auto_user')) {
     case 'admin':
         $access = '100';
         break;
     case 'user':
         $access = '25';
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $validator = Validator::make(Input::all(), Member::$rules_update);
     //var_dump(Input::all());
     // process the login
     if ($validator->fails()) {
         return Redirect::to('members/' . $id . '/edit')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         var_dump(Input::all());
         $member = Member::find($id);
         if ($member->username != Input::get('username')) {
             if (User::check_username(Input::get("username"))) {
                 $member->username = Input::get('username');
             } else {
                 return Redirect::to("members/{$id}/edit")->with('error', 'ten dang nhap da ton tai')->withInput();
             }
         }
         if (Input::get('password_new') != null) {
             $member->password = md5(sha1(Input::get("password_new")));
         }
         $member->name = Input::get('name');
         if ($member->email != Input::get('email')) {
             if (User::check_email(Input::get("email"))) {
                 $member->email = Input::get('email');
             } else {
                 return Redirect::to("members/{$id}/edit")->with('error', 'Email da ton tai')->withInput();
             }
         }
         $member->status = Input::get('status');
         $member->save();
         Logfile::addData('sửa', 'thành viên', $member->id, $member->name);
         // redirect
         Session::flash('message', 'sua thanh vien  thành công!');
         return Redirect::to('members');
     }
 }
Example #5
0
    }
});
Route::get("edit-profile", array("before" => "check-login", function () {
    return View::make("edit-profile");
}));
Route::get("register", function () {
    if (Session::has("logined")) {
        return Redirect::to('edit-profile');
    }
    //Nếu tồn tại session đăng nhập sẽ trả về edit-profile
    return View::make("register");
});
Route::post("register", function () {
    $rules = array("username" => "required|min:3", "password" => "required|min:6", "email" => "required|email");
    if (!Validator::make(Input::all(), $rules)->fails()) {
        if (!User::check_username(Input::get("username")) && !User::check_email(Input::get("email"))) {
            $user = new User();
            $user->username = Input::get("username");
            $user->password = md5(sha1(Input::get("password")));
            $user->email = Input::get("email");
            $user->save();
            Session::put("register_success", Input::get('username') . " đã đăng ký thành công");
            return Redirect::to("login");
        }
    }
});
Route::get("login", function () {
    if (Session::has("logined")) {
        return Redirect::to('edit-profile');
    }
    //Nếu tồn tại session đăng nhập sẽ trả về edit-profile
Example #6
0
        return View::make('backend.home')->with('log', $log);
    });
});
Route::get('/', function () {
    $new = Post::all()->take(3);
    return View::make('frontend.home')->with('new', $new);
});
Route::get('data', function () {
    return View::make('frontend.ajax');
});
Route::get('ckfinder', function () {
    return View::make('ckfinder');
});
Route::group(array("prefix" => "check"), function () {
    Route::post("check-username", function () {
        if (User::check_username(Input::get("username"))) {
            return "true";
        } else {
            return "false";
        }
    });
    Route::post("check-email", function () {
        if (User::check_email(Input::get("email"))) {
            return "true";
        } else {
            return "false";
        }
    });
});
Route::filter("check-login", function () {
    if (!Session::has("logined")) {
Example #7
0
    }
    $audience = sprintf('%s://%s:%s', $scheme, $_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT']);
    $params = 'assertion=' . urlencode($assert) . '&audience=' . urlencode($audience);
    $ch = curl_init();
    $options = array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => 2, CURLOPT_POSTFIELDS => $params);
    curl_setopt_array($ch, $options);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
// Call the BrowserID API
$response = PersonaVerify();
// If the authentication is successful set the auth cookie
$result = json_decode($response, true);
if ('okay' == $result['status']) {
    $email = $result['email'];
    setcookie('auth', $email, time() + 3600, '/');
    $current_user = new User();
    if (!$current_user->check_username($email)) {
        // $current_user->email_address = $email;
        // $current_user->create();
        // $current_user->set_nonce();
        // setcookie('nonce', $current_user->nonce, time()+3600, '/');
    } else {
        $current_user->load($email);
        $current_user->set_nonce();
        setcookie('nonce', $current_user->nonce, time() + 3600, '/');
    }
}
// Print the response to the Ajax script
echo $response;
Example #8
0
 public function check_username()
 {
     if (User::check_username(Input::get('username'))) {
         return "false";
         //AJAX chỉ nhận giá trị chuỗi. Nếu username tồn tại, trả về "false" để báo lỗi
     } else {
         return "true";
     }
 }