/** * üye girişi yaptırır... * * @param string $kullaniciadi * @param string $sifre * @return string|boolean */ public function giris_yap($kullaniciadi, $sifre) { if ($kullaniciadi == '' || $sifre == '') { //kullanici adı veya şifresi boş hatası.... return $this->error(4); } //uyeyi sorgulayalım... $uye = $this->ci->db->get_where('uyeler', array('kullanici_adi' => $kullaniciadi, 'sifre' => do_hash($sifre))); //üye varsa .... if ($uye->num_rows() > 0) { $uye = $uye->row(); if ($uye->durum != 'Aktif') { //aktif olmayan üye hatası... return $this->error(2); } else { //uye seviyesini kontrol ediyoruz.. $girenKim = $uye->uye_seviye == 'normal' ? 'kullanici' : 'yönetici'; //oturum bilgileri ... $sessions = array('girenKim' => $girenKim, 'giris_zamani' => time(), 'giris_tarihi' => date('d/m/Y H:i:s')); //oturum bilgileri ayarlanıyor... $this->session_ekle($sessions); //kullanıcı bilgileri atanıyor... $this->set_uyebilgi($uye); //giriş zamanı güncelleniyor.. $this->ci->db->update("uyeler", array("songiris" => date("d/m/Y H:i:s")), array('id' => $uye->id)); //uye id set ediliyor.. $this->set_uyeid($uye->id); return TRUE; } } else { //üye bulunamadı hatası... return $this->error(1); } }
private function _call($property, $method, $arguments = array(), $expires = null) { $this->_ci->load->helper('security'); if (!$expires or empty($expires)) { if ($this->_default_expires == 0) { $expires = 365 * 60 * 60 * 24; } else { $expires = $this->_default_expires; } } if (!is_array($arguments)) { $arguments = (array) $arguments; } $arguments = array_values($arguments); $cache_key = do_hash($property . $method . serialize($arguments), 'sha1'); if ($expires >= 0) { $cached_response = $this->_ci->cache->get($cache_key); } else { $this->_ci->cache->delete($cache_key); return; } if ($cached_response !== false && $cached_response !== null) { return $cached_response; } else { // Call the model or library with the method provided and the same arguments $new_response = call_user_func_array(array($this->_ci->{$property}, $method), $arguments); $this->_ci->cache->save($cache_key, $new_response, $expires); return $new_response; } }
function insert() { $this->load->helper('security'); $data = array('AddTime' => date('Y/m/d H:m:s'), 'AddIP' => $this->input->ip_address(), 'UserName' => $this->input->post('UserName'), 'WebSite' => $this->input->post('WebSite'), 'Password' => strtoupper(do_hash($pass = $this->input->post('Password'), 'md5')), 'IsShowID' => $this->input->post('IsShowID'), 'LastLogTime' => '', 'LastLogIP' => '', 'LogTimes' => 0); $this->db->insert('user', $data); return $this->db->insert_id(); }
public function edit($user, $type, $pass, $name, $email, $phone, $descr, $age_cat) { $this->load->helper('security'); $query = $this->db->query('Select ID from age where category="' . $age_cat . '"'); foreach ($query->result() as $row) { $id_age_cat = $row->ID; } if ($pass == "") { $query = $this->db->query('UPDATE all_users SET type="' . $type . '", name="' . $name . '", email="' . $email . '", phone_number="' . $phone . '", description="' . $descr . '", age_id="' . $id_age_cat . '" WHERE username="******"'); } else { if (preg_match("/[A-Z]+/", $pass) && preg_match("/[`'\"~!@# \$*()<>,:;{}\\|1234567890]/", $pass)) { $this->load->helper('security'); $passhash = do_hash($pass, 'md5'); $query = $this->db->query('UPDATE all_users SET type="' . $type . '", password="******", name="' . $name . '", email="' . $email . '", phone_number="' . $phone . '", description="' . $descr . '", age_id="' . $id_age_cat . '" WHERE username="******"'); } else { return "8"; } } if ($this->db->affected_rows() == 1) { return "3"; //The user's information was updated } else { return "4"; //Could not update user's information } }
function index() { session_start(); $this->load->helper('security'); $post = $_POST; $fullname = $post['fullname']; $zipcode = $post['zipcode']; $province = $post['province']; $email = $post['email']; $prsnnr = $post['child_birthnumber']; $adress = $post['adress']; $phone = $post['phonenumber']; $pass = $post['password']; $passRep = $post['password-repeat']; $pass = do_hash($post['password'], 'md5'); $this->db->query("INSERT INTO people\n (name, child_birthnumber, zipcode, province, adress, email, phone)\n VALUES\n ('{$fullname}', '{$prsnnr}', '{$zipcode}', '{$province}', '{$adress}', '{$email}', '{$phone}')"); $this->db->query("INSERT INTO cms_access\n (email, password)\n VALUES\n ('{$email}', '{$pass}')"); $newUser = $this->db->query("SELECT * FROM people WHERE email = '" . $email . "'")->row_array(); $_SESSION['access'] = 'user'; $_SESSION['id'] = $newUser['id']; $_SESSION['user'] = $newUser['email']; $_SESSION['img'] = $newUser['image']; $_SESSION['timestamp'] = time(); redirect("/profile/user/" . $newUser['id'] . "?access=" . $_SESSION['access'] . ""); }
function forgotpassword() { /*if(!isset($_SESSION)) session_start();*/ $this->load->helper('security'); $this->load->helper('string'); $this->load->model('check'); $email = $_POST['mail']; $forgotP = $this->check->email_pass($email); if (!empty($forgotP)) { $randomPass = random_string('alnum', 6); $hashedPass = do_hash($randomPass, 'md5'); $fullname = $this->db->query("SELECT name FROM people WHERE email = '" . $email . "'")->result_array(); $data['recipent'] = explode(' ', $fullname[0]['name']); $data['note'] = "Ditt lösenord har återställts. Ditt nya genererade lösenord hittar du nedan:<br /><br /><span style='font-weight: 600;'>" . $randomPass . '</span>'; $data['teacher'] = ""; $message = $this->load->view('mail_template', $data, TRUE); $result = $this->email->from('*****@*****.**', 'Studio Natali')->to($email)->subject('Glömt lösenord')->message($message)->send(); // to troubleshoot // var_dump($result); // echo $this->email->print_debugger(); $this->db->where('email', $email); $this->db->update('cms_access', array('password' => $hashedPass)); echo $randomPass; } else { echo "doesnt work"; } }
function createNewUser() { $result = ''; $this->user_email = $this->input->post('email', TRUE); $this->user_password = $this->encrypt->sha1($this->encrypt->sha1($this->input->post('password', TRUE))); $this->user_realname = $this->input->post('realname', TRUE); $this->user_bio = $this->input->post('bio', TRUE); // check if the email already exists $query = $this->db->get_where('users', array('user_email' => $this->input->post('email', TRUE))); if ($query->num_rows() > 0) { // user exists: return error message $result->error = "We already have that email on our database?"; return $result; } else { // user is new: write to db and return uid if (!$this->db->insert('users', $this)) { // error while writing to db: return error message $result->error = "We're sorry but the database dwarf made a mistake. The dungeon master has been notified"; return $result; } else { // everything went well. commit the transaction and return the uid hash $result->user_hash = do_hash($this->user_email); return $result; } } }
function login() { if ($this->input->post('email')) { $this->form_validation->set_rules('email', 'Username', 'trim|required|valid_email|xss_clean'); $this->form_validation->set_rules('password', 'Password', 'required'); if ($this->form_validation->run() == TRUE) { $email = $this->input->post('email'); $pw = substr(do_hash($this->input->post('password')), 0, 16); $this->MUsers->verify($email, $pw); if ($this->session->userdata('user_type') == 'sa') { redirect('sa/company', 'refresh'); } elseif ($this->session->userdata('user_type') == 'user') { redirect('voucher', 'refresh'); } else { redirect('homepage', 'refresh'); } } else { $data['title'] = 'Welcome to Simple Accounting System'; $data['menu'] = 'home'; $data['content'] = 'homepage'; $this->load->vars($data); $this->load->view('template'); } } else { $data['title'] = 'Welcome to Simple Accounting System'; $data['menu'] = 'home'; $data['content'] = 'homepage'; $this->load->vars($data); $this->load->view('template'); } }
public function send_email($user, $mail) { $query = $this->db->query('Select username,email from all_users where username="******" and email="' . $mail . '"'); if ($query->num_rows() == 1) { $this->load->helper('security'); $this->load->library('email'); $this->email->set_newLine("\r\n"); $this->email->from('User management website'); $this->email->to($mail); $this->email->subject("Password recover!"); $this->load->model("random_password"); $password = $this->random_password->get_password(); $passhash = do_hash($password, 'md5'); $query = $this->db->query('UPDATE all_users SET password ="******" WHERE username ="******";'); $this->email->message("As you requested, we sent you the new password for the user: <b>" . $user . " </b> " . ". It is <b>" . $password . '</b>'); if ($this->email->send()) { return "1"; // new password sent } else { return "2"; // something went wrong } } else { return "3"; //Username and email not registered } }
public function create() { if ($this->input->server('REQUEST_METHOD') == 'POST') { $userName = $this->input->post('username'); $email = $this->input->post('email'); $password = $this->input->post('password'); $passwordConfirm = $this->input->post('passwordConfirm'); $firstName = $this->input->post('firstname'); $lastName = $this->input->post('lastname'); $gender = $this->input->post('gender'); $birth = $this->input->post('birth'); $user = array('username' => $userName, 'group_user_id' => 2, 'password' => do_hash($password), 'first_name' => $firstName, 'email' => $email, 'last_name' => $lastName, 'birth_date' => $birth, 'sex' => $gender, 'status' => 1); // check user exists. $result = $this->user->get_entry_by_username($userName); if (sizeof($result) != 0) { echo json_encode(array('code' => 409, 'message' => "User already exists.")); return true; } $result = $this->user->insert_entry($user); if ($result) { echo json_encode(array('code' => 200, 'message' => "create success.")); } return true; } else { $groupUserList = $this->group_user->get_all_entries(); $data['group_user'] = $groupUserList; $this->load->view('user/create', $data); } }
function login($email, $password) { $this->load->helper('security'); $CI =& get_instance(); // Database query to lookup email and password $Login_result = new Users_model(); $Login_result->where("email", $email)->where("password", do_hash($this->config->item('encryption_key') . $password, 'md5'))->get(); // if email and password found checks permissions and sets session data if ($Login_result->exists()) { if (!$Login_result->enabled) { $CI->session->set_flashdata('message', '<p class="attention">Your account has been disabled.</p>'); } elseif ($CI->settings->users_module->email_activation && !$Login_result->activated) { $CI->session->set_flashdata('message', '<p class="attention">Your account has been not yet been activated.</p>'); } else { $Login_result->last_login = date("Y-m-d H:i:s"); $Login_result->create_session(); $Login_result->save(); if ($CI->input->post('remember_me')) { $this->set_remember_me($Login_result); } return TRUE; } } else { $CI->session->set_flashdata('message', '<p class="error">No match for Email and/or Password.</p>'); } return FALSE; }
public function index() { $this->form_validation->set_rules('regdisplayname', 'Display Name', 'trim|required'); $this->form_validation->set_rules('regusername', 'Username', 'trim|required|is_unique[users.username]'); $this->form_validation->set_rules('regpassword', 'Password', 'trim|required'); $this->form_validation->set_rules('regconfirm', 'Confirm Password', 'trim|required|matches[regpassword]'); if ($this->form_validation->run() == TRUE) { $data = array('username' => $this->input->post('regusername'), 'password' => do_hash($this->input->post('regpassword'), 'md5'), 'displayname' => $this->input->post('regdisplayname')); $this->load->model('register_model'); $this->register_model->add_user($data); $error_msg = '<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button>' . 'Registration Successful!' . '</div>'; //ni-recycle ko lang basta mag-ppop ung login after successful registration $error_action = "\$('#modalLogin').modal('show')"; $data = array('error_msg' => $error_msg, 'error_action' => $error_action, 'reg_error_msg' => NULL); //back to main page $this->load->view('includes/header'); $this->load->view('content', $data); $this->load->view('includes/footer'); } else { $reg_error_msg = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>' . validation_errors() . '</div>'; $error_action = "\$('#modalRegister').modal('show')"; $data = array('error_msg' => NULL, 'error_action' => $error_action, 'reg_error_msg' => $reg_error_msg); $this->load->view('includes/nocache'); $this->load->view('includes/header'); $this->load->view('content', $data); $this->load->view('includes/footer'); } }
function add() { if ($this->form_validation->run('user_add') == FALSE) { // show form //$data['heading'] = 'Add a New User'; $data['content'] = array('admin/users/add_edit'); $this->load->view('templates/admin', $data); } else { // process our form $this->load->helper('security'); $record['first_name'] = $this->input->post('first_name'); $record['last_name'] = $this->input->post('last_name'); $record['email'] = $this->input->post('email'); $record['username'] = $this->input->post('username'); $record['password'] = do_hash(trim($this->input->post('password'))); $record['role'] = $this->input->post('role'); $this->load->model('Users_model'); if ($this->Users_model->add_user($record)) { $id = $this->db->insert_id(); //$this->history->log_event('add', 'added the user ' . $this->History_model->get_historical_username($id)); $this->session->set_flashdata('message', 'User successfully added.'); } else { $this->session->set_flashdata('messsage_type', 'error'); $this->session->set_flashdata('message', 'An error occurred when trying to add this user.'); } redirect('admin_users'); } }
function users($num_users) { $users = $this->random_names($num_users); $user_hashes = array(); $i = 0; foreach ($users as $user) { $this->user_email = $user['email']; $this->user_password = $this->encrypt->sha1($this->encrypt->sha1($user['email'])); $this->user_realname = $user['name']; $this->user_bio = ''; // check if the email already exists $query = $this->db->get_where('user', array('user_email' => $this->user_email)); if ($query->num_rows() > 0) { // user exists: return error message $result->error = "We already have that email on our database?"; } else { // user is new: write to db and return uid if (!$this->db->insert('user', $this)) { // error while writing to db: return error message $result->error = "We're sorry but the database dwarf made a mistake. The dungeon master has been notified"; } else { // everything went well. commit the transaction and return the uid hash $result->user_hash = do_hash($this->user_email); //var_dump($result); } } $user_hashes[$i] = $result->user_hash; $i++; } $result->users = $user_hashes; return $result; }
function add_user($name, $password, $email, $level) { // add the user $password = do_hash($password, 'md5'); $data = array('name' => $name, 'password' => $password, 'email' => $email, 'level' => $level); $this->db->insert('user', $data); }
function forgotpassword() { session_start(); $this->load->helper('security'); $this->load->model('check'); $post = $this->input->post(NULL, TRUE); $email = $post['mail']; $forgotP = $this->check->email_pass($email); if (!empty($forgotP)) { $randomPass = random_string('alnum', 6); $hashedPass = do_hash($randomPass, 'md5'); $config['charset'] = 'utf-8'; $config['mailtype'] = 'html'; $config['newline'] = '\\r\\n'; $message = "Hej,<br /><br />"; $message .= "Ditt lösenord har återställts, du hittar det nya automatiserade lösenordet nedan:<br />"; $message .= $randomPass; $message .= "<br /><br />"; $message .= "Med vänlig hälsning / Natalis Dansstudio"; $this->email->initialize($config); $this->email->from('*****@*****.**', 'Natalis Dansstudio'); $this->email->to($email); $this->email->subject('Glömt lösenord'); $this->email->message($message); if (!$this->email->send()) { echo "Something went wrong when trying to retrieve new password"; } $this->db->where('email', $email); $this->db->update('cms_access', array('password' => $hashedPass)); echo $randomPass; } else { echo "doesnt work"; } }
/** * login() */ public function login() { $data['header'] = $this->load->view('system/header', NULL, TRUE); //Obtener y limpiar los datos $username = xss_clean($this->input->post('username')); $password = do_hash(xss_clean($this->input->post('password')), 'md5'); //Validar los datos obtenidos $this->form_validation->set_rules('username', 'User Name', 'required', array('required' => $this->lang->line('error_required_username'))); $this->form_validation->set_rules('password', 'Password', 'required', array('required' => $this->lang->line('error_required_password'))); if ($this->form_validation->run() == FALSE) { //Se despliega el login con mensajes de error $data['content'] = $this->load->view('system/login', NULL, TRUE); } else { try { //Se validan las credenciales de acceso $this->opx_auth->auth_user($username, $password); //Se redirecciona al controlador del dashboard redirect('dashboard'); } catch (Exception $e) { $data_login['error_login_message'] = $this->lang->line('error_login_message'); $data['content'] = $this->load->view('system/login', $data_login, TRUE); } } $data['footer'] = $this->load->view('system/footer', NULL, TRUE); $this->load->view('system/layout', $data); }
public function new_user_post() { $fn = $this->post("firstname"); $ln = $this->post("lastname"); $gender = $this->post("gender"); $dob = $this->post("dob"); $cnid = $this->post("country"); $email = $this->post("email"); $pwd = $this->post("pwd"); $datetime = mdate('%Y-%m-%d %h:%i:%s', time()); //$ra=rand(10000,100000); //$ra=$email.$ra; $link = md5($email); // to create randum number for activation link $pwd = do_hash($pwd, 'md5'); if ($fn && $ln && $dob && $gender && $cnid && $email && $pwd && $datetime && $link) { $this->load->model("registration_model"); $new_user = $this->registration_model->create_user($fn, $ln, $dob, $gender, $cnid, $email, $pwd, $datetime, $link); if ($new_user === false) { $this->response(array("status" => "failed")); } else { $this->response(array("status" => "success")); } } }
public function GirisBilgileriKaydet() { $_profilID = $this->uri->segment(3); if (!is_numeric($_profilID) || empty($_profilID)) { redirect('AdminPanel'); } else { $this->form_validation->set_rules('frmKullaniciAdi', 'Kullanıcı Adı', 'trim|required|min_length[5]|max_length[12]|xss_clean'); $this->form_validation->set_rules('frmSifre', 'Şifre', 'trim|matches[frmSifreTekrar]|min_length[5]|max_length[12]|required'); $this->form_validation->set_rules('frmSifreTekrar', 'Şifre Tekrarı', 'trim|required'); $this->form_validation->set_rules('frmEmail', 'Email Adresi', 'trim|valid_email|required|xss_clean'); $this->form_validation->set_message('required', '<b>%s</b> alanını girmek zorundasınız.'); $this->form_validation->set_message('valid_email', '<b>%s</b> alanına doğru bir email adresi giriniz.'); $this->form_validation->set_message('min_length', '<b>%s</b> alanı en az <b>%d</b> karakter olmalıdır.'); $this->form_validation->set_message('max_length', '<b>%s</b> alanı en fazla <b>%d</b> karakter olmalıdır.'); $this->form_validation->set_message('matches', '<b>%s</b> alanı ile <b>%s</b> alanı aynı olmalıdır.'); if ($this->form_validation->run() === FALSE) { $this->load->view('admin/ajax_formvalidation_error'); } else { $_KullaniciAdi = $this->input->post('frmKullaniciAdi', TRUE); $_Sifre = $this->input->post('frmSifre', TRUE); $_Email = $this->input->post('frmEmail', TRUE); $_update = $this->dbt->update('t_admin', $_profilID, array("f_KullaniciAdi" => $_KullaniciAdi, "f_Sifre" => do_hash($_Sifre), "f_Email" => $_Email)); if ($_update) { $this->load->view('admin/ajax_ok', array("_mesaj" => "Bilgiler Güncellendi.")); $this->sd_logger->_insert("Kullanıcı Giriş Bilgileri Güncellendi"); } else { $this->load->view('admin/ajax_error', array("_mesaj" => "Bilgiler Güncellenemedi.")); $this->sd_logger->_insert("Kullanıcı Firiş Bilgileri Güncellenemedi"); } } } }
function login() { if ($this->input->post('email')) { $this->form_validation->set_rules('email', 'Username', 'trim|required|valid_email|xss_clean'); $this->form_validation->set_rules('password', 'Password', 'required'); if ($this->form_validation->run() == TRUE) { $email = $this->input->post('email'); $pw = substr(do_hash($this->input->post('password')), 0, 16); $this->MUsers->verify($email, $pw); if ($this->session->userdata('user_id')) { redirect('pharmacy', 'refresh'); } else { redirect('homepage', 'refresh'); } } else { $data['title'] = 'Hospital Management System - Login'; $data['menu'] = 'home'; $data['content'] = 'homepage'; $this->load->vars($data); $this->load->view('template'); } } else { $data['title'] = 'Hospital Management System - Login'; $data['menu'] = 'home'; $data['content'] = 'homepage'; $this->load->vars($data); $this->load->view('template'); } }
public function editarSenhaUsuario($usuario) { $this->load->helper('security'); $user['usu_senha'] = do_hash($usuario['senha'] . '4rT%yH7uJ$3Fr5&uj9Lç0Ds21#4gf%$g54'); $user['usu_modificado_em'] = date("Y-m-d H:i:s"); $this->db->where('usu_id', $usuario['usu_id']); $this->db->update('tbl_usuario', $user); }
private function _generate_key() { do { $salt = do_hash(time() . mt_rand()); $new_key = substr($salt, 0, config_item('rest_key_length')); } while ($this->count_by('key', $new_key)); return $new_key; }
function edit($img_name) { $data = array('username' => $this->input->post('username', TRUE), 'password' => do_hash($this->input->post('password', TRUE), 'md5'), 'email' => $this->input->post('email', TRUE), 'first_name' => $this->input->post('first_name', TRUE), 'last_name' => $this->input->post('last_name', TRUE), 'phone' => $this->input->post('phone', TRUE), 'probation_status' => $this->input->post('probation_status', TRUE), 'marital_status' => $this->input->post('marital_status', TRUE), 'department_name' => $this->input->post('department_name', TRUE), 'designation_name' => $this->input->post('designation_name', TRUE), 'grade' => $this->input->post('grade', TRUE), 'basic_salary' => $this->input->post('basic_salary', TRUE), 'joining_date' => $this->input->post('joining_date', TRUE), 'address' => $this->input->post('address', TRUE), 'image' => $img_name); $uid = $this->input->post('id'); $this->db->where('ID', $uid); $this->db->update('employee', $data); //echo $this->db->last_query(); die(); }
public function check($parameter, $authkey) { $this->load->helper('security'); $checkCode = $this->input->get_post('check_code', TRUE); $paramString = implode('|||', $parameter) . '|||' . $authkey; $paramString = do_hash(do_hash($paramString, 'md5')); return $checkCode == $paramString; }
public function login() { $this->load->helper('security'); $username = $this->input->post("username"); $password = do_hash($this->input->post("password", TRUE), 'md5'); if ($this->checkLogin($username, $password) >= 1) { $this->show('tbl_siswa'); } }
public function _generate_key() { //$this->load->helper('security'); do { $salt = do_hash(time() . mt_rand()); $new_key = substr($salt, 0, config_item('rest_key_length')); } while (self::_key_exists($new_key)); return $new_key; }
function check_pass($row, $p) { $str = do_hash($p, 'md5'); if ($str == $row->password) { return TRUE; } else { return FALSE; } }
function store_new_user($username, $password, $email, $email_verify, $status) { //USE PLACEHOLDERS $data = array('username' => $username, 'password' => do_hash($password, 'md5'), 'email' => $email, 'verification_email' => $email_verify, 'status' => $status); //$str = $this->db->insert_string('users', $data); return $this->db->insert('users', $data); //$query = $this->db->query($sql); //return $query->num_rows(); }
private function _generate_key() { $this->load->helper('security'); do { $salt = do_hash(time() . mt_rand()); $new_key = substr($salt, 0, $this->config->item('rest_key_length', 'rest')); } while ($this->_key_exists($new_key)); return $new_key; }
/** * set_user() * * Inserta un usuario en la base de datos * * Retorna 1 si el registro fue insertado */ public function set_user($user) { $user['password'] = do_hash($user['password'], 'md5'); if ($this->db->insert('opx_user', $user)) { return TRUE; } else { return FALSE; } }