本文整理汇总了PHP中do_hash函数的典型用法代码示例。如果您正苦于以下问题:PHP do_hash函数的具体用法?PHP do_hash怎么用?PHP do_hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_hash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: giris_yap
/**
* ü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);
}
}
示例2: _call
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;
}
}
示例3: insert
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();
}
示例4: edit
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="' . $user . '"');
} 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="' . $passhash . '", name="' . $name . '", email="' . $email . '", phone_number="' . $phone . '", description="' . $descr . '", age_id="' . $id_age_cat . '" WHERE username="' . $user . '"');
} 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
}
}
示例5: index
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'] . "");
}
示例6: forgotpassword
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('info@studionatali.se', '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";
}
}
示例7: createNewUser
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;
}
}
}
示例8: login
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');
}
}
示例9: send_email
public function send_email($user, $mail)
{
$query = $this->db->query('Select username,email from all_users where username="' . $user . '" 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 ="' . $passhash . '" WHERE username ="' . $user . '";');
$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
}
}
示例10: create
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);
}
}
示例11: login
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;
}
示例12: index
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');
}
}
示例13: add
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');
}
}
示例14: 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;
}
示例15: add_user
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);
}