本文整理汇总了PHP中dohash函数的典型用法代码示例。如果您正苦于以下问题:PHP dohash函数的具体用法?PHP dohash怎么用?PHP dohash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dohash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit
function submit()
{
$data = array("css_filename" => "login", "title" => "管理后台登录", "message" => "", "messageclass" => "");
$this->load->view("admin/Login", $data);
if (!$_POST) {
redirect("cp/login");
}
$username = $_POST["username"];
$password = $_POST["password"];
if ($username == "") {
$this->_showMessage("您还未输入用户名。", 0);
return;
}
if ($password == "") {
$this->_showMessage("您的密码还未输入。", 0);
return;
}
$this->load->model("Users");
//MD5加密码
$password = dohash($password, 'md5');
$result = $this->Users->CheckLogin($username, $password);
if ($result == 0) {
$this->_showMessage("对不起,您的密码不正确,请重新输入。", 0);
} else {
set_cookie("username", $username, "3600", "", "/");
set_cookie("password", $password, "3600", "", "/");
redirect("");
}
}
示例2: UpdatePassword
/**
* 修改密码
* @param unknown_type $username
* @param unknown_type $password
*/
function UpdatePassword($username, $password)
{
$this->load->database();
$password = dohash($password, 'md5');
$sql = "update users set password = '" . $password . "' where username = '" . $username . "'";
$result = $this->db->query($sql);
}
示例3: edit
function edit()
{
if ($this->form_validation->run('user_edit') == FALSE) {
// show form
$this->db->where('id', $this->uri->segment(3));
$data['query'] = $this->db->get('users');
$data['id'] = $this->uri->segment(3);
//$data['heading'] = 'Edit a User';
$data['content'] = array('admin/users/add_edit');
$this->load->view('templates/admin', $data);
} else {
// We submitted and passed, so lets do our db update
$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['role'] = $this->input->post('role');
if ($this->input->post('password') != '') {
$record['password'] = dohash(trim($this->input->post('password')));
}
$id = $this->input->post('id');
$this->db->where('id', $id);
$this->db->update('users', $record);
//$this->history->log_event('edit', 'edited the user ' . $this->History_model->get_historical_username($id));
$this->session->set_flashdata('message', 'User updated successfully.');
redirect('admin_users');
}
}
示例4: create_drink
function create_drink($username, $password, $password_confirm, $email)
{
if ($username && $password && $password == $password_confirm && $email) {
$salt = substr(str_pad(dechex(mt_rand()), 8, '0', STR_PAD_LEFT), -8);
$hash = $salt . dohash($password, 'md5');
$query = $this->db->query("INSERT INTO user (username, hash, email) VALUES\n\t\t\t ('" . $username . "', '" . $hash . "', '" . $email . "')");
}
}
示例5: key_generate
private function key_generate()
{
$this->load->helper('security');
do {
$salt = dohash(time() . mt_rand());
$new_key = substr($salt, 0, config_item("api_key_length"));
} while ($this->key_exists($new_key));
return $new_key;
}
示例6: addRememberMe
function addRememberMe($username)
{
// start by removing any current cookie before the re-issue
$this->removeRememberMe();
$random_string = random_string('alnum', 128);
$remember_me_info = array('username' => $username, 'usernamehash' => dohash($username), 'random_string' => $random_string, 'origin_time' => now());
$this->db->insert($this->db_table, $remember_me_info);
set_cookie("userhash", dohash($username), $this->config->item('remember_me_life'));
set_cookie("randomstring", $random_string, $this->config->item('remember_me_life'));
}
示例7: loginValidate
function loginValidate()
{
$query = $this->db->query("select id\r\n\t\t\t\t\t\t\t\t\tFROM bd_user\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\twhere username='" . $this->input->post('username') . "' and password='" . dohash($this->input->post('password'), 'md5') . "'");
$return_array = $query->row_array();
if (sizeof($return_array) != 0) {
return $return_array;
} else {
return 0;
}
}
示例8: loginValidate
function loginValidate($data)
{
$query = $this->db->query("select u.user_details_id, u.username, ud.designation_id,ud.profile_image, ud.f_name, ud.l_name, ud.department_id, bl.abbreviation, b.branch_name,b.branch_abbreviation, b.branch_code, b.branch_id, de.access\n\t\t\t\t\t\t\t\t\tFROM tia_user as u\n\t\t\t\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t\t\ttia_user_details as ud\n\t\t\t\t\t\t\t\t\tON u.user_details_id = ud.user_details_id\n\t\t\t\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t\t\ttia_branch as b\n\t\t\t\t\t\t\t\t\tON ud.branch_id = b.branch_id\n\t\t\t\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t\t\ttia_branch_level as bl\n\t\t\t\t\t\t\t\t\tON b.branch_level_id = bl.branch_level_id\n\t\t\t\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t\t\ttia_designation as de\n\t\t\t\t\t\t\t\t\tON ud.designation_id = de.designation_id\n\t\t\t\t\t\t\t\t\twhere ud.status=1 and u.username='" . $data['username'] . "' and u.password='" . dohash($data['password'], 'md5') . "'");
$return_array = $query->row_array();
if (sizeof($return_array) != 0) {
// print_r($return_array);die;
return $return_array;
} else {
return 0;
}
}
示例9: emp_login
function emp_login()
{
$eid = $this->session->userdata('eid');
if (!$eid) {
if ($_POST) {
$fail = false;
$username = mysql_real_escape_string($_POST['username']);
$password = dohash($_POST['password'], 'md5');
$query = $this->db->query("SELECT `passwd` FROM `employees` WHERE `e_id` = '{$username}' AND `active` = 1");
if ($query->num_rows() == 1) {
$hash = $query->first_row();
$hash = $hash->passwd;
if ($hash == $password) {
$user_info = $this->db->query("SELECT `uniq_id` FROM `employees` WHERE `e_id` = {$username}");
foreach ($user_info->result() as $info) {
$this->session->set_userdata('eid', $info->uniq_id);
}
$eid = $this->session->userdata('eid');
if ($eid) {
$ip = getenv("REMOTE_ADDR");
$this->db->query("UPDATE `employees` SET `last_login` = CURRENT_TIMESTAMP WHERE `uniq_id` = {$eid}");
//$this->db->query("INSERT INTO `user_log` (`iduser_log`,`logged_in`,`ip_address`) VALUES ('$eid',CURRENT_TIMESTAMP,'$ip')");
$changepw = $this->db->query("SELECT DATEDIFF(DATE(NOW()),DATE(`last_pw_change`)) AS `days` FROM `employees` WHERE `uniq_id` = {$eid}");
$changepw = $changepw->first_row();
$uname = $this->db->query("SELECT CONCAT(`first_name`,' ',`last_name`) as `uname` FROM `employees` WHERE `uniq_id` = {$eid}");
$uname = $uname->first_row();
$this->session->set_userdata('uname', $uname->uname);
//$this->session->set_userdata('utype',$uname->user_type);
if ($changepw->days > $this->max_pw_age) {
$data = array("site" => "employees");
$this->load->view('changepw_view', $data);
} else {
header("Location: /cpm/index.php/employees/emp_home");
}
}
} else {
$fail = true;
}
} else {
$fail = true;
}
if ($fail) {
echo "Username or password incorrect.";
}
} else {
$this->load->view('emp_login');
}
} else {
header("Location: /cpm/index.php/employees/emp_home");
}
}
示例10: edit
function edit()
{
if (!$this->user_lib->logged_in()) {
redirect('users/login');
}
$this->load->library('validation');
$rules = array('settings_first_name' => 'required|alpha_dash', 'settings_last_name' => ($this->settings->item('require_lastname') ? 'required|' : '') . 'alpha_dash', 'settings_password' => 'min_length[6]|max_length[20]', 'settings_confirm_password' => ($this->input->post('settings_password') ? 'required|' : '') . 'matches[settings_password]', 'settings_email' => 'required|valid_email', 'settings_confirm_email' => 'valid_email|matches[settings_email]', 'settings_lang' => 'alpha|max_length[2]');
$this->validation->set_rules($rules);
$fields = array('settings_first_name' => $this->lang->line('user_first_name'), 'settings_last_name' => $this->lang->line('user_last_name'), 'settings_password' => $this->lang->line('user_password'), 'settings_confirm_password' => $this->lang->line('user_confirm_password'), 'settings_email' => $this->lang->line('user_email'), 'settings_confirm_email' => $this->lang->line('user_confirm_email'), 'settings_lang' => $this->lang->line('user_lang'));
$this->validation->set_fields($fields);
// Get settings for this user
$this->data->user_settings = $this->users_m->get(array('id' => $this->user_id));
foreach (array_keys($rules) as $field) {
if (isset($_POST[$field])) {
$this->data->user_settings->{str_replace('settings_', '', $field)} = $this->validation->{$field};
}
}
// Settings valid?
if ($this->validation->run()) {
$set['first_name'] = $this->input->post('settings_first_name', TRUE);
$set['last_name'] = $this->input->post('settings_last_name', TRUE);
// The cookie has been changed, lets set a new one and update their record
if ($this->input->cookie('lang_code') != $this->input->post('settings_lang', TRUE)) {
// Set the language for this user
$this->user_lib->set_lang_cookie($this->input->post('settings_lang', TRUE));
$set['lang'] = $this->input->post('settings_lang', TRUE);
}
// If password is being changed (and matches)
if ($this->input->post('settings_password')) {
$this->load->helper('security');
$set['password'] = dohash($this->input->post('settings_password') . $this->user_lib->user_data->salt);
}
// If email is being changed (and matches)
if ($this->input->post('settings_email')) {
$set['email'] = $this->input->post('settings_email');
}
if ($this->users_m->update($this->user_id, $set)) {
$this->session->set_flashdata(array('success' => $this->lang->line('user_settings_saved_success')));
} else {
$this->session->set_flashdata(array('error' => $this->lang->line('user_settings_saved_error')));
}
redirect('edit-settings');
}
// Format languages for the dropdown box
$this->data->languages = array();
foreach ($this->config->item('supported_languages') as $lang_code => $lang) {
$this->data->languages[$lang_code] = $lang['name'];
}
$this->template->build('settings/edit', $this->data);
}
示例11: form_token
function form_token($varlen = 6, $str_to_shuffer = "abcdefghijklmnopqrstuvwxyz0123456789_")
{
$start_pos = mt_rand(0, strlen($str_to_shuffer) - $varlen);
$token_name = substr(str_shuffle($str_to_shuffer), $start_pos, $varlen);
$token_value = dohash(microtime() . mt_rand());
$CI =& get_instance();
if ($CI->session) {
$CI->load->library('session');
}
$CI->session->set_userdata('token_name', $token_name);
$CI->session->set_userdata('token_value', $token_value);
//pr($CI->input);
//exit;
return form_hidden($token_name, $token_value);
}
示例12: call
private function call($property, $method, $arguments = array(), $expires = null)
{
$this->ci->load->helper('security');
// Clean given arguments to a 0-index array
$arguments = array_values($arguments);
$cache_file = $property . '/' . dohash($method . serialize($arguments), 'sha1');
// See if we have this cached
$cached_responce = $this->get($cache_file);
// Not FALSE? Return it
if ($cached_responce) {
return $cached_responce;
} else {
// Call the model or library with the method provided and the same arguments
$new_responce = call_user_func_array(array($this->ci->{$property}, $method), $arguments);
$this->write($new_responce, $cache_file, $expires);
return $new_responce;
}
}
示例13: validate_login
function validate_login($username, $password)
{
$result = $this->db->query("SELECT * FROM user WHERE username='{$username}'");
if (!$result->row()) {
$this->session->set_flashdata('message', '<div id="message">The username that you entered does not exist in our database.</div>');
redirect('login/index');
}
$row = $result->row();
$admin = $row->level;
$salt = substr($row->hash, 0, 8);
$hash = dohash($password, 'md5');
if ($row->hash == $salt . $hash) {
$data = array('username' => $username, 'logged_in' => TRUE, 'admin' => $admin);
$this->session->set_userdata($data);
redirect('dashboard/index');
} else {
$this->session->set_flashdata('message', '<div id="message">Your password is incorrect, please try again.</div>');
redirect('login/index');
}
}
示例14: verifyCustomer
function verifyCustomer($e, $pw)
{
$this->db->where('email', db_clean($e, 50));
$this->db->where('password', db_clean(dohash($pw), 16));
$this->db->limit(1);
$Q = $this->db->get('omc_customer');
if ($Q->num_rows() > 0) {
$row = $Q->row_array();
$_SESSION['customer_id'] = $row['customer_id'];
$_SESSION['customer_first_name'] = $row['customer_first_name'];
$_SESSION['customer_last_name'] = $row['customer_last_name'];
$_SESSION['phone_number'] = $row['phone_number'];
$_SESSION['email'] = $row['email'];
$_SESSION['address'] = $row['address'];
$_SESSION['city'] = $row['city'];
$_SESSION['post_code'] = $row['post_code'];
} else {
// $_SESSION['customer_id'] = 0; // this will eliminate error
}
}
示例15: regAdmin
function regAdmin()
{
// FIXME ESTE MÉTODO NO PUEDE QUEDAR ASÍ: SE DEBE ELIMINAR AL LANZAR LA VERSIÓN FINAL
$this->load->library('input');
$u = $this->input->post('rut', TRUE);
$p = $this->input->post('pass', TRUE);
$pe = $this->input->post('per', TRUE);
if ($this->user->addNewAdmin($u, dohash($p), $pe)) {
echo 'registrado con exito';
} else {
echo 'ocurrio un error';
}
}