Esempio n. 1
0
 public function login($username = null, $pass = null, $remember = false)
 {
     if (!$username && !$pass && $this->exist()) {
         Session::put($this->_sessionName, $this->data()->id);
     } else {
         $user = $this->find($username);
         if ($user) {
             if ($this->_data->password === Hash::make($pass, $this->_data->salt)) {
                 Session::put($this->_sessionName, $this->_data->id);
                 if ($remember) {
                     $hash = hash::unique();
                     $hashCheck = $this->_db->get('user_session', array('user_id', '=', $this->data()->id));
                     if (!$hashCheck->count()) {
                         $this->_db->insert('user_session', array('user_id' => $this->_data->id, 'hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     Cookies::put($this->_cookieName, $hash, config::get('remember/expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 2
0
 public function login($email = null, $password = null, $remember = false)
 {
     if (!$email && !$password && $this->exists()) {
         session::put($this->_session_name, $this->_data->id);
     } else {
         $user = $this->find($email);
         if ($user) {
             if ($this->_data->password === hash::make($password, $this->_data->salt)) {
                 session::put($this->_session_name, $this->_data->id);
                 if ($remember) {
                     $hash = hash::unique();
                     $hash_check = $this->_db->get('users_session', array('user_id', '=', $this->_data->id));
                     if (!$hash_check->count()) {
                         $this->_db->insert('users_session', array('user_id' => $this->_data->id, 'hash' => $hash));
                     } else {
                         $hash = $hash_check->firstResult()->hash;
                     }
                     cookie::put($this->_cookie_name, $hash, config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 3
0
 public function link($data)
 {
     $query = $this->db->prepare("SELECT * FROM logins Where usern = :login");
     $u = $data['username'];
     $query->bindParam(':login', $u);
     $query->execute();
     $results = $query->fetch(PDO::FETCH_ASSOC);
     try {
         if (!$results) {
             throw new Exception('No username found m8');
         }
         $p = hash::create('md5', $data['password'], HASH_KEY);
         if (!($results['passw'] === $p)) {
             throw new Exception('wrong password dumbass');
         }
         if ($results['Active'] == 0) {
             throw new Exception('Please activate your account');
         }
         session::set('loggedIn', true);
         session::set('role', $results['role']);
         session::set('userid', $results['u_id']);
         session::set('username', $results['usern']);
         if (isset($data['remember'])) {
             setcookie("user", $u, time() + 7200, "/");
         }
         session_regenerate_id();
         header('Location: ../dashboard/index');
         exit;
     } catch (Exception $e) {
         $_SESSION = array();
         $_SESSION['errors'] = $e->getMessage();
         header('Location: ../login');
     }
 }
Esempio n. 4
0
 /**
  * 唯一实例
  *
  * @return Base_Db_Hash
  */
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 5
0
 public static function public_key($key = null)
 {
     if ($key) {
         self::$_public_key = $key;
     }
     return self::$_public_key;
 }
Esempio n. 6
0
 public function adduser()
 {
     $username = '******';
     $password = hash::make('admin');
     $data = ['id' => "", 'username' => $username, 'password' => $password, 'fullname' => 'admin', 'jobdesc' => 'admin'];
     $save = DB::table('users')->insert($data);
     return $data;
 }
Esempio n. 7
0
 public function auth()
 {
     $username = input::get('username');
     $password = input::get('password');
     $sandi = hash::make('admin');
     $ceklogin = DB::table('users')->where('password', '=', $sandi)->get();
     return $sandi;
 }
Esempio n. 8
0
 public static function log_in($email, $password)
 {
     $acc = null;
     if (!($acc = static::load_one(array('email' => $email, 'hash' => hash::generate($password))))) {
         return false;
     }
     $_SESSION['.account_id'] = $acc->id;
     return true;
 }
Esempio n. 9
0
 /**
  * AutoGenerate the on for the specified relationship.
  *
  * @return string
  * @author Justin Palmer
  **/
 private function autoGenerateOn($name)
 {
     $options = $this->relationships->get($name);
     $ret = '';
     switch ($options->type) {
         case 'has-one':
             $ret = $this->model->alias() . "." . $this->model->primary_key() . " = " . $options->alias . "." . $options->foreign_key;
             break;
         case 'has-many':
             $ret = $options->table . "." . $options->foreign_key . " = ?";
             break;
     }
     return $ret;
 }
Esempio n. 10
0
 public function createUser($data)
 {
     $query = $this->db->prepare("INSERT INTO logins (usern,passw,Active,role,Email) VALUES (:username, :password, 0, 'default', :email)");
     $pass = hash::create('md5', $data['new_pass'], HASH_KEY);
     $query->bindParam(':username', $data['new_user']);
     $query->bindParam(':password', $pass);
     $query->bindParam(':email', $data['new_email']);
     if ($query->execute()) {
         session::set('activate', '<br /> You have successfully created an account! Please check your email, and follow the activation instructions from there');
         my_activation_mail();
         header('Location: ../index');
     } else {
         print_r($this->db->errorInfo());
         //header('Location: ../error');
     }
 }
Esempio n. 11
0
 public function showAesKey($ID)
 {
     global $DB;
     $this->h->getFromDB($ID);
     Session::initNavigateListItems("PluginAccountsAesKey", __('Hash', 'accounts') . " = " . $this->h->fields["name"]);
     $candelete = $this->h->can($ID, 'w');
     $query = "SELECT *\n      FROM `glpi_plugin_accounts_aeskeys`\n      WHERE `plugin_accounts_hashes_id` = '{$ID}' ";
     $result = $DB->query($query);
     $rand = mt_rand();
     echo "<div class='center'>";
     echo "<form method='post' name='show_aeskey{$rand}' id='show_aeskey{$rand}' action=\"./aeskey.form.php\">";
     echo "<input type='hidden' name='plugin_accounts_hashes_id' value='" . $ID . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='5'>" . __('Encryption key', 'accounts') . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th class='left'>" . __('Name') . "</th>";
     echo "</tr>";
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_array($result)) {
             Session::addToNavigateListItems("PluginAccountsAesKey", $data['id']);
             echo "<input type='hidden' name='item[" . $data["id"] . "]' value='" . $ID . "'>";
             echo "<tr class='tab_bg_1 center'>";
             echo "<td width='10'>";
             if ($candelete) {
                 echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
                 if (isset($_POST['check']) && $_POST['check'] == 'all') {
                     echo " checked ";
                 }
                 echo ">";
             }
             echo "</td>";
             $link = Toolbox::getItemTypeFormURL("PluginAccountsAesKey");
             echo "<td class='left'><a href='" . $link . "?id=" . $data["id"] . "&plugin_accounts_hashes_id=" . $ID . "'>";
             echo __('Encryption key', 'accounts') . "</a></td>";
             echo "</tr>";
         }
         echo "</table>";
         if ($candelete) {
             Html::openArrowMassives("show_aeskey{$rand}", true);
             Html::closeArrowMassives(array('delete' => __('Delete permanently')));
         }
     } else {
         echo "</table>";
     }
     Html::closeForm();
     echo "</div>";
 }
Esempio n. 12
0
 public function nextStep()
 {
     if (session::get('loggedIn') == TRUE) {
         // добавляем в бд данные из step1
         $pId = $this->addStepOne();
         // запускаем контролер step2
         header('location: ' . URL . 'details/edit/' . $pId[0]['postid']);
     } else {
         // логинимся
         $data['email'] = $_POST['login'];
         $data['password'] = $_POST['password'];
         $this->model->runReg($data['email'], hash::create('md5', $data['password'], HASH_KEY));
         //
         // добавляем в бд данные из step1
         $pId = $this->addStepOne();
         // запускаем контролер step2
         header('location: ' . URL . 'details/edit/' . $pId[0]['postid']);
     }
 }
Esempio n. 13
0
 public function postRegister(Request $Request)
 {
     $input = Input::all();
     $rules = ['name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required', 'password_confirmation' => 'required|same:password'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect('/register')->withErrors($validator);
     } else {
         $obj = new user();
         $obj->name = Input::get('name');
         $obj->email = Input::get('email');
         $obj->password = hash::make(Request::get('password'));
         $obj->status = 'unactive';
         $obj->active_token = md5(time());
         $obj->save();
         $obj->sendMail(Input::get('email'), Input::get('name'), $obj->active_token, $obj->id);
         return redirect('/auth/login')->withErrors(['error' => 'Please check Email active account ']);
     }
 }
Esempio n. 14
0
 public function store(UserRequest $request)
 {
     //validate data input
     $data = $request->all();
     if (isset($data['image'])) {
         $thumb = $data['image'];
         $new = 'ava' . uniqid() . '.' . $thumb->getClientOriginalExtension();
         $thumb->move('upload/users', $new);
     }
     $data['image'] = $new;
     $obj = new User();
     $obj->name = $data['name'];
     $obj->email = $data['email'];
     $obj->role_id = $data['role_id'];
     $obj->password = hash::make($data['role_id']);
     $obj->status = 'active';
     $obj->remember_token = $data['_token'];
     $obj->image = $new;
     $obj->save();
     return redirect('admin/users');
 }
Esempio n. 15
0
 public function savePassword($data)
 {
     $response_array = array();
     $agent_id = $data['agent_id'];
     $password = $data['password'];
     $cpassword = $data['cpassword'];
     $checkCPassword = user::checkCdata($password, $cpassword);
     if (!$checkCPassword) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Confirm Password</b> not match!</div>";
     } else {
         $data['tmp_password'] = NULL;
         $data['password'] = hash::create("sha256", $password, HASH_PASSWORD_KEY);
         //            Insert into Database
         $this->db->update("user_accounts", $data, "agent_id = '{$agent_id}'");
         //            Response
         $response_array['r'] = "true";
         $response_array['msg'] = BASE_PATH . "setup/details";
     }
     return $response_array;
 }
Esempio n. 16
0
 public function addNew_exec($data)
 {
     $response_array = array();
     $data['agent_id'] = session::get(AGENT_SESSION_NAME);
     $data['supplier_id'] = user::generateSupplierID();
     $data['comp_name'] = ucwords($data['comp_name']);
     $data['comp_reg_no'] = strtoupper($data['comp_reg_no']);
     $data['comp_address'] = ucwords($data['comp_address']);
     if ($data['comp_state'] != "oth") {
         unset($data['state_other']);
     }
     $data['token'] = hash::create("sha256", $data['supplier_id'], $data['comp_email']);
     $data['website'] = strtolower($data['website']);
     $data['website'] = str_replace("http://", "", $data['website']);
     $data['website'] = str_replace("https://", "", $data['website']);
     $data['tag'] = strtolower(str_replace(", ", ",", $data['tag']));
     $data['p_fullname'] = ucwords(strtolower($data['p_fullname']));
     $data['p_pos'] = ucwords(strtolower($data['p_pos']));
     $agent_id = $data['agent_id'];
     for ($x = 1; $x <= 5; $x++) {
         $userID = $this->db->select("user_accounts", "sponsor_id", "agent_id = {$agent_id}", "fetch");
         $agent_id = $userID['sponsor_id'];
         $data['lv' . $x] = $agent_id;
     }
     foreach ($data as $key => $value) {
         if ($value == "") {
             $data[$key] = NULL;
         }
     }
     $insert = $this->db->insert("user_suppliers", $data);
     if (!$insert) {
         $response_array['r'] = "false";
         $response_array['msg'] = "Oopps! Looks like there is some technical error while process your supplier registration. Please re-submit the form or refresh your browser.";
     } else {
         $response_array['r'] = "true";
         $response_array['msg'] = BASE_PATH . "supplier?r=success&t=addnew&a=" . $data['comp_name'];
     }
     return $response_array;
 }
Esempio n. 17
0
 public function login_exec($data)
 {
     $response_array = array();
     $username = $data['username'];
     $userExist = user::checkExist("user_accounts", "username = '******'");
     $rememberme = isset($data['rememberme']) ? TRUE : FALSE;
     //        check user exist
     if (!$userExist) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><strong>Username</strong> does not exist.</div>";
     } else {
         $userData = user::getUserData('username', $username);
         //            verify login details
         if ($userData['tmp_password'] == NULL) {
             $password = hash::create('sha256', $data['password'], HASH_PASSWORD_KEY);
             $checkLogin = user::checkExist("user_accounts", "username = '******' AND password = '******'");
         } else {
             $password = $data['password'];
             $checkLogin = user::checkExist("user_accounts", "username = '******' AND tmp_password = '******'");
         }
         //            execute login
         if (!$checkLogin) {
             $response_array['r'] = "false";
             $response_array['msg'] = "<div>Incorrect <strong>Username</strong> or <strong>Password</strong>.</div>";
         } else {
             //                update user database
             $updateData = array();
             $updateData['last_login'] = Date('Y-m-d H:i:s');
             $agent_id = $userData['agent_id'];
             $this->db->update("user_accounts", $updateData, "agent_id = '{$agent_id}'");
             //                start login session
             user::login($agent_id, $rememberme);
             $response_array['r'] = "true";
             $response_array['msg'] = BASE_PATH . "dashboard";
         }
     }
     return $response_array;
 }
Esempio n. 18
0
 public function validation()
 {
     try {
         $form = new form();
         $form->post('name')->val('minlength', 5)->val('maxlength', 20)->post('email')->val('minlength', 5)->val('emailCorrect')->post('password')->val('minlength', 5)->val('maxlength', 20)->post2('password', 'passwordConfirm')->val('samepass', 'password', 'passwordConfirm')->post('chkReadTerms')->val('check', 'chkReadTerms');
         $form->mit();
         $data = $form->fetch();
         //$this->model->checkemail($data['email']);
         /*
          * наши действия если валидация успешная
          * добавляем в базу данных addUser
          * стартуем сессию и логинем юзера runReg
          * отправляем почту с уведомлением об успешной регистрации
          */
         $this->model->addUser($data);
         $this->model->runReg($data['email'], hash::create('md5', $data['password'], HASH_KEY));
         $this->model->mailSuck($data['email']);
     } catch (Exception $e) {
         $str = $form->mit2();
         $this->view->ValError = $str;
         $this->view->render('signup/index');
     }
 }
Esempio n. 19
0
 public function run()
 {
     $sth = $this->db->prepare("SELECT id, name, role FROM boat_users WHERE email=:email AND password=:password");
     $sth->execute(array(':email' => $_POST['email'], ':password' => hash::create('md5', $_POST['password'], HASH_KEY)));
     $data = $sth->fetch();
     //print_r($data);
     //echo $data['role'];
     //die();
     $count = $sth->rowCount();
     if ($count > 0) {
         //login
         session::init();
         session::set('role', $data['role']);
         session::set('userName', $data['name']);
         session::set('userId', $data['id']);
         session::set('userEmail', $_POST['email']);
         session::set('loggedIn', TRUE);
         header('location: ../dashboard');
     } else {
         //error
         header('location: ../login');
     }
 }
 public function postCreate()
 {
     $values = Request::all();
     if ($values['emp_first_name'] == '' || $values['emp_first_name'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Nombre requerido'));
     }
     if ($values['emp_last_name'] == '' || $values['emp_last_name'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Apellido requerido'));
     }
     if ($values['emp_address'] == '' || $values['emp_address'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Dirección requerido'));
     }
     if ($values['emp_phone_number'] == '' || $values['emp_phone_number'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Número Fijo requerido'));
     }
     if ($values['emp_job'] == '' || $values['emp_job'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Puesto requerido'));
     }
     if ($values['emp_fk_business_unit'] == '' || $values['emp_fk_business_unit'] == null || $values['emp_fk_business_unit'] == 'null') {
         return Response::json(array('success' => false, 'data' => 'Campo Unidad de Negocio requerido'));
     }
     if ($values['emp_email'] == '' || $values['emp_email'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Correo/Usuario requerido'));
     }
     if ($values['emp_password'] == '' || $values['emp_password'] == null) {
         return Response::json(array('success' => false, 'data' => 'Campo Contraseña requerido'));
     }
     $values['emp_password'] = hash::make($values['emp_password']);
     $rows = fil_employee::where('emp_email', '=', $values['emp_email'])->count();
     if ($rows == 1) {
         return Response::json(array('success' => false, 'data' => 'Este correo ya está en uso, por favor utilice otro correo'));
     }
     fil_employee::create($values);
     $response = Response::json(array('success' => true, 'data' => 'Empleado guardado con exito'));
     return $response;
 }
Esempio n. 21
0
 public function editSave($data)
 {
     $postData = array('name' => $data['name'], 'password' => hash::create('md5', $data['password'], HASH_KEY));
     $this->db->update('boat_users', $postData, "`id` = {$data['id']}");
 }
Esempio n. 22
0
 public static function login($agent_id, $rememberme = FALSE)
 {
     session::set(AGENT_SESSION_NAME, $agent_id);
     session::set(AGENT_LOGIN_SESSION, TRUE);
     if ($rememberme) {
         if (!cookie::exists(TOKEN_NAME)) {
             $token = hash::create("sha256", $agent_id, HASH_GENERAL_KEY);
             cookie::set(TOKEN_NAME, $token, COOKIE_EXPIRY);
             $db = new database(DBTYPE, DBHOST, DBNAME, DBUSER, DBPASS);
             $data = array();
             $data['agent_id'] = $agent_id;
             $data['token'] = $token;
             $db->insert("users_session", $data);
         }
     }
 }
Esempio n. 23
0
 public function addagent_exec($data)
 {
     $response_array = array();
     foreach ($data as $key => $value) {
         if ($value == "") {
             $data[$key] = NULL;
         }
     }
     $agent = new user();
     $data['fullname'] = strtoupper($data['fullname']);
     $data['agent_id'] = $agent->generateID();
     $data['tmp_password'] = strtoupper(hash::create('crc32', uniqid(), HASH_PASSWORD_KEY));
     $data['activate_code'] = $agent->generateActivationCode($data['email']);
     $acc_type = $data['acc_type'];
     switch ($acc_type) {
         case "aa":
             $ads_pin_limit = 1;
             $available_pin = 1;
             break;
         case "ad":
             $ads_pin_limit = 15;
             $available_pin = 15;
             break;
         case "ed":
             $ads_pin_limit = 20;
             $available_pin = 20;
             break;
         case "ep":
             $ads_pin_limit = 40;
             $available_pin = 40;
             break;
         default:
             $ads_pin_limit = "unlimited";
             $available_pin = 40;
             break;
     }
     $data['ads_pin_limit'] = $ads_pin_limit;
     $data['available_pin'] = $available_pin;
     $data['address'] = ucwords($data['address']);
     $data['mobile'] = str_replace("-", "", $data['mobile']);
     $data['mobile'] = str_replace(" ", "", $data['mobile']);
     $data['mobile'] = str_replace("+6", "", $data['mobile']);
     $data['mobile'] = "+6" . $data['mobile'];
     if (!empty($data['phone'])) {
         $data['phone'] = str_replace("-", "", $data['phone']);
         $data['phone'] = str_replace(" ", "", $data['phone']);
         $data['phone'] = str_replace("+6", "", $data['phone']);
         $data['phone'] = "+6" . $data['phone'];
     }
     $checkEmail = $agent->checkEmail($data['email']);
     $checkCEmail = $agent->checkCdata($data['email'], $data['cemail']);
     $checkUsername = $data['chkusername'];
     $validUplineSponsor = FALSE;
     $sponsorId = $data['sponsor_id'];
     $uplineId = $data['lv1'];
     if ($sponsorId != $uplineId) {
         $upline_data = $this->db->select("user_accounts", "lv1,lv2,lv3,lv4,lv5,lv6,lv7,lv8,lv9,lv10", "agent_id = '{$uplineId}'", "fetch");
         foreach ($upline_data as $value) {
             if ($value == $sponsorId) {
                 $validUplineSponsor = TRUE;
             }
         }
     } else {
         $validUplineSponsor = TRUE;
     }
     //GENERATE ADS PIN
     if ($acc_type == "aa") {
         $ads_pin = "1000000";
     } else {
         $ads_pin = $agent->getRegPin();
     }
     $data['ads_pin'] = $ads_pin;
     if (!$checkCEmail) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Confirm Email</b> not match!</div>";
     } elseif (!$checkEmail) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Email</b> already exist!</div>";
     } elseif ($checkUsername == 0) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div>Please <b>Check Username</b> availability!<div>";
     } elseif ($checkUsername == '-1') {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Username</b> not available! Please choose another username.<div>";
     } elseif (!$validUplineSponsor) {
         $response_array['r'] = "false";
         $response_array['msg'] = "<div><b>Sponsor ID: {$sponsorId}</b> not related with <b>Upline ID: {$uplineId}</b>. Please make sure <b>Upline ID</b> is under correct <b>Sponsor ID</b> network.<div>";
     } else {
         $link = BASE_PATH . 'join/verify?a=' . $data['activate_code'] . '&s=' . $data['username'];
         unset($data['cemail']);
         unset($data['chkusername']);
         //            Insert into Database
         $this->db->insert("user_accounts", $data);
         //            Generate Email BODY
         $html = file_get_contents(BASE_PATH . 'email_template/activation');
         $html = htmlspecialchars($html);
         $html = str_replace('[USERNAME]', ucfirst($data['username']), $html);
         $html = str_replace('[ACTIVATION_CODE]', $link, $html);
         $html = html_entity_decode($html);
         $body = $html;
         //            Send Email
         $mailer = new mailer();
         $mailer->IsSMTP();
         // set mailer to use SMTP
         $mailer->Port = EMAIL_PORT;
         $mailer->Host = EMAIL_HOST;
         // specify main and backup server
         $mailer->SMTPAuth = true;
         // turn on SMTP authentication
         $mailer->Username = NOREPLY_EMAIL;
         // SMTP username
         $mailer->Password = NOREPLY_PASS;
         // SMTP password
         $mailer->From = NOREPLY_EMAIL;
         $mailer->FromName = SUPPORT_NAME;
         $mailer->AddAddress($data['email']);
         $mailer->IsHTML(true);
         $mailer->Subject = "Email verification to " . $data['email'];
         $mailer->Body = $body;
         if (!$mailer->Send()) {
             $response_array['r'] = "false";
             $response_array['msg'] = "Mailer Error: " . $mailer->ErrorInfo;
         } else {
             $response_array['r'] = "true";
             $response_array['msg'] = BASE_PATH . "mynetwork/addagent_success/" . $data['agent_id'];
         }
     }
     return $response_array;
 }
Esempio n. 24
0
 if (token::check(input::get('token'))) {
     $validate = new validate();
     $validation = $validate->check($_POST, array('Password' => array('required' => true, 'min' => 6), 'password_again' => array('required' => true, 'matches' => 'Password')));
     if ($validation->passed()) {
         //session::flash('success','You registered successfully!');
         //header('Location: index.php');
         $user = new user(null, $_log);
         $salt = hash::salt(32);
         if ($data = $_db->get('Users', array('Username', '=', $username))) {
             //var_dump($data);
             if ($data->counts() > 0) {
                 if ($data->first()->User_Verified == 0) {
                     if ($data->first()->Confirm_Hash == $confirmCode) {
                         $oldUser = $data->first()->Old_User;
                         try {
                             $user->updateUser(array('Password' => hash::make(input::get('Password'), $salt), 'Salt' => $salt, 'User_Verified' => 1, 'Confirm_Hash' => null, 'Old_User' => null), $_GET['Username']);
                             session::flash('home', 'Your password has been created');
                             $_log->info('Username verified: ' . $username);
                             // Will be logged
                             if ($oldUser !== null) {
                                 try {
                                     if ($user->delete($oldUser)) {
                                         $_log->info('Old user deleted: ' . (string) $oldUser);
                                     } else {
                                         $_log->warning('Old user NOT deleted: ' . (string) $oldUser);
                                     }
                                 } catch (Exception $e) {
                                     var_dump($e->getMessage());
                                     $_log->info($e->getMessage());
                                     die($e->getMessage());
                                 }
Esempio n. 25
0
 public function postRegister(Request $request)
 {
     $user = ["remember_token" => Request::get('_token'), "name" => Request::get('name'), "password" => hash::make(Request::get('password')), "email" => Request::get('email'), "role_id" => 1];
     User::Create($user);
 }
Esempio n. 26
0
 /** @test */
 public function can_set_password()
 {
     $pw = 'testpassword';
     $this->user->setPassword($pw);
     $this->assertTrue(hash::check($pw, $this->user->getAuthPassword()));
 }
Esempio n. 27
0
 public function getNewPassword($email)
 {
     $newPassword = $this->generate_password();
     $postData = array('password' => hash::create('md5', $newPassword, HASH_KEY));
     //echo $postData['password'];
     //echo $email;
     //        print_r($postData);
     //        die();
     //        $this->db->update('users', $postData, "`email` = {$email}");
     $sth = $this->db->prepare('UPDATE boat_users SET password = :password WHERE email= :email');
     $sth->execute(array(':password' => hash::create('md5', $newPassword, HASH_KEY), ':email' => $email));
     return $newPassword;
 }
Esempio n. 28
0
<?php

require_once '/opt/lampp/htdocs/MySpace/src/init.php';
$user = new user();
if (!$user->isLoggedIn()) {
    redirect::to('index.php');
}
if (input::exists()) {
    if (token::check(input::get('token'))) {
        $validate = new validation();
        $validation = $validate->check($_POST, array('Password' => array('required' => true, 'min' => 8), 'Npassword' => array('required' => true, 'min' => 8), 'Rpassword' => array('required' => true, 'min' => 8, 'matches' => 'Npassword')));
        if ($validation->passed()) {
            if (hash::make(input::get('Password')) !== $user->data()->Password) {
                echo 'your old password did not match';
            } else {
                if ($user->update(array('Password' => hash::make(input::get('Npassword'))))) {
                    session::flash('home', 'Your password have been updated!!');
                    redirect::to('index.php');
                }
            }
        }
    }
}
?>
<link href="<?php 
echo 'register.css';
?>
" rel='stylesheet' type='text/css'>
<form action="" method="post">
  <div class="field">
  <label id="icon" for="Password"><i class="icon-shield"></i></label>
Esempio n. 29
0
 public function login($UserID = null, $Password = null, $remember = false)
 {
     // $user=$this->find($UserID);
     if (!$UserID && !$Password && $this->exists()) {
         session::put($this->_sessionName, $this->data());
     } else {
         $user = $this->find($UserID);
         // print_r($user);
         // print_r($this->_data);
         if ($user) {
             if ($this->data()->Password === hash::make($Password)) {
                 echo 'ok!';
                 // need to check the node_id/UserID
                 session::put($this->_sessionName, $this->data()->node_id);
                 if ($remember) {
                     $hash = hash::unique();
                     $hashCheck = $this->_database->get('User_session', array('UserID', '=', $this->data()->node_id));
                     if (!$hashCheck->counts()) {
                         $this->_database->insert('User_session', array('userID' => $this->data()->SessionID, 'Hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 30
0
<?php

define('path', '../../../');
$page = "Register";
require path . 'inc/init.php';
$user = new User();
if ($user->hasPermission("Admin")) {
    if (Input::exists()) {
        if (Token::check(Input::get('token'))) {
            $val = new Validation();
            $val->check($_POST, array('name' => array('required' => true), 'username' => array('required' => true, 'min' => 2, 'max' => 50, 'unique' => 'users'), 'password' => array('required' => true, 'min' => 8), 'password_conf' => array('required' => true, 'matches' => 'password')));
            if ($val->passed()) {
                $salt = hash::salt(32);
                $password = hash::make(escape(Input::get('password')), $salt);
                try {
                    $user->create(array('username' => escape(Input::get('username')), 'password' => Hash::make(escape(Input::get('password')), $salt), 'salt' => $salt, 'name' => escape(Input::get('name')), 'joined' => date('Y-m-d- H:i:s'), 'group' => 1));
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            }
        }
    }
} else {
    session::flash("error", "You don't have admin permission! If you think this is an error contact your administrator or owner");
    Redirect::to(path . "index.php");
}
?>
<html>
	<head>
		<?php 
include path . 'assets/php/css.php';