Пример #1
0
 public function check_email()
 {
     if (User::check_email(Input::get("email"))) {
         return "true";
     } else {
         return "false";
     }
 }
Пример #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());
 }
Пример #3
0
<?php

require 'vendor/autoload.php';
$db = new Database();
$user = new User($db->conn);
$vendor = new Vendor($db->conn);
$item = new Item($db->conn);
$isAvailable = false;
if (!isset($_POST['type'])) {
    echo json_encode(array('valid' => $isAvailable));
    exit;
}
switch ($_POST['type']) {
    case 'email':
        if ($user->check_email($_POST['email'])) {
            $isAvailable = true;
        }
        break;
    case 'phone':
        if ($user->check_phone($_POST['phone'])) {
            $isAvailable = true;
        }
        break;
    case 'vendor_email':
        if ($vendor->check_email($_POST['email'])) {
            $isAvailable = true;
        }
        break;
    case 'delete_item':
        if ($item->delete($_POST['object_id'])) {
            $isAvailable = true;
Пример #4
0
 /**
  * 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');
     }
 }
Пример #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
Пример #6
0
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")) {
        return Redirect::to("users/login");
    }
});
// người sử dụng
Route::controller('users', 'UserController');
// Admin
Route::group(array('before' => 'checkUser'), function () {
Пример #7
0
<?php

session_start();
require_once 'models/user.php';
$userModel = new User();
if (!empty($_POST['register'])) {
    $email = $_POST['email'];
    $password = $_POST['password'];
    $phone = $_POST['phone'];
    $real_name = $_POST['real_name'];
    $free_mail = $userModel->check_email($email);
    if ($free_mail) {
        $userModel->add_user($real_name, $email, $phone, $password);
        $user = $userModel->check_user($email, $password);
        $_SESSION['user_id'] = $user['id'];
        redirect('/profile.php');
    } else {
        $_SESSION['message'] = 'Этот email уже используется!';
        redirect('/profile.php');
    }
}
redirect('/404.html');
Пример #8
0
 public function check_email()
 {
     if (User::check_email(Input::get('email'))) {
         return "false";
         //AJAX chỉ nhận giá trị chuỗi. Nếu email tồn tại, trả về "false" để báo lỗi
     } else {
         return "true";
     }
 }
Пример #9
0
<?php

require_once 'include/init.inc';
require_once 'include/util.inc';
$email = "";
$nickname = "";
$password = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $email = $_POST['email'];
    $nickname = $_POST['nickname'];
    $password = $_POST['password'];
    if (!validate_email($email)) {
        alert(s("请输入有效的电子邮箱地址", 'Please input valid email address'), 'error');
    } else {
        if (User::check_email($email)) {
            alert(s("该Email已被占用", 'This email is aleady taken'), 'error');
        }
    }
    if (!validate_nickname($nickname)) {
        alert(s("请输入有效的昵称", 'Please input valid nick name'), 'error');
    } else {
        if (User::check_nickname($nickname)) {
            alert(s("该昵称已被占用", 'This nick name is aleady taken'), 'error');
        }
    }
    if (!validate_password($password)) {
        alert(s("请输入有效的密码", 'Please input valid password'), 'error');
    }
    if (count($alerts) <= 0) {
        $hashed_password = md5($password . $config['salt']);
        $verify_hash = make_random_key();
Пример #10
0
            $dk->set_email($e);
            $dk->set_hoten($ht);
            $dk->set_diachi($dc);
            $dk->set_dienthoai($dt);
            $dk->set_level($lv);
            $ngaydk = date("d");
            $thangdk = date("m");
            $namdk = date("Y");
            $ngaydk = "{$namdk}-{$thangdk}-{$ngaydk}";
            $ngaysinh = "{$namsinh}-{$thangsinh}-{$ngaysinh}";
            $dk->set_ngaydangky($ngaydk);
            $dk->set_ngaysinh($ngaysinh);
            if ($dk->check_user() == FALSE) {
                echo "<div align='center' style='margin:10px;'><font size='+1' color='#FF0033'>Tên này đã có người dùng</font></div>";
            }
            if ($dk->check_email() == FALSE) {
                echo "<div align='center' style='margin:10px;'><font size='+1' color='#FF0033'>Email này đã có người dùng</font></div>";
            } else {
                if ($dk->insert_user() == FALSE) {
                    echo "<div align='center' style='margin:10px;'><font size='+1' color='#FF0033'>Đăng ký thất bại</font></div>";
                } else {
                    $dk->insert_user();
                    echo "<div align='center' style='margin:10px;'><font size='+1' color='#FF0033'>Đăng ký thành công !</font></div>";
                }
            }
        }
    }
} else {
    ?>