Exemple #1
0
 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("");
     }
 }
Exemple #2
0
 /**
  * 修改密码
  * @param unknown_type $username
  * @param unknown_type $password
  */
 function UpdatePassword($username, $password)
 {
     $this->load->database();
     $password = dohash($password, 'md5');
     $sql = "update users set password = '******' where username = '******'";
     $result = $this->db->query($sql);
 }
Exemple #3
0
 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');
     }
 }
 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 . "')");
     }
 }
Exemple #5
0
 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;
 }
Exemple #6
0
 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'));
 }
Exemple #7
0
 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='******'username') . "' and password='******'password'), 'md5') . "'");
     $return_array = $query->row_array();
     if (sizeof($return_array) != 0) {
         return $return_array;
     } else {
         return 0;
     }
 }
Exemple #8
0
 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='******'username'] . "' and u.password='******'password'], 'md5') . "'");
     $return_array = $query->row_array();
     if (sizeof($return_array) != 0) {
         // print_r($return_array);die;
         return $return_array;
     } else {
         return 0;
     }
 }
 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");
     }
 }
Exemple #10
0
 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);
 }
Exemple #11
0
 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);
 }
Exemple #12
0
 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;
     }
 }
 function validate_login($username, $password)
 {
     $result = $this->db->query("SELECT * FROM user WHERE 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');
     }
 }
 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
     }
 }
Exemple #15
0
 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';
     }
 }
Exemple #16
0
                                <input name="amount" type="hidden" value="<?php 
echo $amt1;
?>
">
                                <input name="txn_ref" type="hidden" value="<?php 
echo $reference;
?>
">
                                <input name="site_redirect_url" type="hidden" value="<?php 
echo $callbackpage;
?>
">
                                <fieldset class="form-group">
                                    <label for="formGroupExampleInput">Your Hash Result</label>
                                    <input type="text" class="form-control" value="<?php 
echo dohash($amt1);
?>
"
                                           name="hash"/>
                                </fieldset>
                                <input name="cust_name" type="hidden" value="Test">
                                <input name="cust_id" type="hidden" value="AD99">
                                <input name="payment_params" type="hidden" value="college_split"/>
                                <input name="xml_data" type="hidden" value=
                                '<payment_item_detail>
			  <item_details detail_ref="<?php 
echo $reference;
?>
" college="maritime academy oron" department="NAUTICAL SCIENCE" faculty="NA">
			  <item_detail item_id="1" item_name="school fees" item_amt="5166000" bank_id="8" acct_num="12345678910" />
			   </item_details> </payment_item_detail>'/>
Exemple #17
0
 function reset_password($first_name, $last_name, $email)
 {
     $this->CI->load->helper(array('string', 'security'));
     // Find a user with the supplied details
     $this->user_data = $this->CI->users_m->getUser(array('first_name' => $first_name, 'last_name' => $last_name, 'email' => $email));
     // No user found
     if (!$this->user_data) {
         $this->error_code = 'user_forgot_incorrect';
         return FALSE;
     }
     // Create a new password
     $password = random_string('alnum', 8);
     // Update user object with new password
     $this->user_data->password = dohash($password . $this->user_data->salt);
     // Store the new encrypted password in the database
     $result = $this->CI->users_m->updateUser($this->user_data->id, array('password' => $this->user_data->password));
     return $result ? $password : FALSE;
 }
Exemple #18
0
 function modifypasswordpost()
 {
     $messagetext = "";
     $messageclass = "";
     $oldpass = $_POST["oldpass"];
     $newpass = $_POST["newpass"];
     $confirmpass = $_POST["confirmpass"];
     if ($newpass == "") {
         $messageclass = "red";
         $messagetext = "新密码不能为空。";
     } else {
         if ($newpass != $confirmpass) {
             $messageclass = "red";
             $messagetext = "两次输入的密码不一至,请重新输入。";
         } else {
             //检查旧密码
             $username = get_cookie("username");
             $oldpass = dohash($oldpass, 'md5');
             if ($this->users->CheckLogin($username, $oldpass) == 0) {
                 $messageclass = "red";
                 $messagetext = "旧密码不正确。";
             } else {
                 $this->users->UpdatePassword($username, $newpass);
                 $messageclass = "";
                 $messagetext = "恭喜,您的密码修改成功。";
                 set_cookie("password", dohash($newpass, 'md5'), "3600", "", "/");
             }
         }
     }
     $data = array("css_filename" => "config", "title" => "修改密码 - 管理后台", "messageclass" => $messageclass, "messagetext" => $messagetext);
     $this->load->view("admin/config/modifypassword", $data);
 }
Exemple #19
0
 function _fields()
 {
     $data = array('customer_first_name' => db_clean($_POST['customer_first_name'], 25), 'customer_last_name' => db_clean($_POST['customer_last_name'], 25), 'phone_number' => db_clean($_POST['phone_number'], 15), 'email' => db_clean($_POST['email'], 50), 'address' => db_clean($_POST['address'], 50), 'city' => db_clean($_POST['city'], 25), 'post_code' => db_clean($_POST['post_code'], 10), 'password' => db_clean(dohash($_POST['password']), 16));
     return $data;
 }
Exemple #20
0
 public function reset_password($key, $email)
 {
     $new_password = random_string('alnum', 8);
     $data = array('password' => dohash($new_password, 'md5'), 'secret_key' => '');
     $this->db->where('secret_key', $key);
     $this->db->where('email', $email);
     $this->db->update($this->_table['users'], $data);
     $this->send_new_password($email, $new_password);
 }
Exemple #21
0
 function edit($id = 0)
 {
     $this->load->library('validation');
     // Shouldnt need to have done this, but if password exists make confirm_password required
     if ($this->input->post('password')) {
         $this->rules['confirm_password'] .= '|required';
     }
     $this->validation->set_rules($this->rules);
     $this->validation->set_fields();
     $this->data->member = $this->users_m->getUser(array('id' => $id));
     if (!$this->data->member) {
         $this->session->set_flashdata('error', 'User not found.');
         redirect('admin/users');
     }
     if ($this->validation->run()) {
         $update_data['first_name'] = $this->input->post('first_name');
         $update_data['last_name'] = $this->input->post('last_name');
         $update_data['email'] = $this->input->post('email');
         $update_data['is_active'] = $this->input->post('is_active');
         // Only worry about role if there is one, it wont show to people who shouldnt see it
         if ($this->input->post('role')) {
             $update_data['role'] = $this->input->post('role');
         }
         // Password provided, hash it for storage
         if ($this->input->post('password') && $this->input->post('confirm_password')) {
             $this->load->helper('security');
             $update_data['password'] = dohash($this->input->post('password') . $this->data->member->salt);
         }
         if ($this->users_m->updateUser($id, $update_data)) {
             $this->session->set_flashdata('success', 'User successfully updated.');
         } else {
             $this->session->set_flashdata('error', 'Error occurred when trying to update user.');
         }
         redirect('admin/users');
     } else {
         $this->data->error_string = $this->validation->error_string;
     }
     // Override fields with provided values
     foreach (array_keys($this->rules) as $field) {
         if (isset($_POST[$field])) {
             $this->data->member->{$field} = $this->validation->{$field};
         }
     }
     $this->layout->create('admin/form', $this->data);
 }
Exemple #22
0
 /**
  * @method void csrf_token($varlen, $str_to_shuffer) construct a random input field name and assign the token to it.
  * @param int $varlen the length of the input field name that will be generated
  * @param string $str_to_shuffer the string that will be used to generate the input field name
  */
 function csrf_token($varlen = 6, $str_to_shuffer = "abcdefghijklmnopqrstuvwxyz0123456789_")
 {
     $start_pos = mt_rand(0, strlen($str_to_shuffer) - $varlen);
     $_SESSION["CSRF_NONCE_VARNAME_{$_SERVER["REQUEST_URI"]}"] = substr(str_shuffle($str_to_shuffer), $start_pos, $varlen);
     $_SESSION["CSRF_NONCE_VALUE_{$_SERVER["REQUEST_URI"]}"] = dohash(microtime() . mt_rand());
 }
Exemple #23
0
 function registration()
 {
     /* If you are using recaptcha, don't forget to configure modules/recaptcha/config/recaptcha.php
      * Add your own key
      * */
     $captcha_result = '';
     $data['cap_img'] = $this->_generate_captcha();
     $data['question'] = $this->security_question;
     $data['security_method'] = $this->security_method;
     if ($this->input->post('email')) {
         $data['title'] = $this->preference->item('site_name') . " | " . "Registration";
         // set rules
         $rules['email'] = 'trim|required|matches[emailconf]|valid_email';
         $rules['emailconf'] = 'trim|required|valid_email';
         $rules['password'] = '******';
         $rules['customer_first_name'] = 'trim|required|min_length[3]|max_length[20]';
         $rules['customer_last_name'] = 'trim|required|min_length[3]|max_length[20]';
         $rules['phone_number'] = 'trim|required|min_length[8]|max_length[12]|numeric';
         $rules['address'] = 'trim|required';
         $rules['city'] = 'trim|required|alpha_dash';
         $rules['post_code'] = 'trim|required|numeric';
         // if you want to use recaptcha, set modules/recaptcha/config and uncomment the following
         //$rules['recaptcha_response_field'] = 'trim|required|valid_captcha';
         if ($this->security_method == 'recaptcha') {
             $rules['recaptcha_response_field'] = 'trim|required|valid_captcha';
         } elseif ($this->security_method == 'question') {
             $rules['write_ans'] = 'trim|required|callback_security_check';
         }
         $this->validation->set_rules($rules);
         // set fields. This will be used for error messages
         // for example instead of customer_first_name, First Name will be used in errors
         $fields['email'] = lang('webshop_email');
         $fields['emailconf'] = lang('webshop_email_confirm');
         $fields['password'] = lang('webshop_pass_word');
         $fields['customer_first_name'] = lang('webshop_first_name');
         $fields['customer_last_name'] = lang('webshop_last_name');
         $fields['phone_number'] = lang('webshop_mobile_tel');
         $fields['address'] = lang('webshop_shipping_address');
         $fields['city'] = lang('webshop_city');
         $fields['post_code'] = lang('webshop_post_code');
         $fields['recaptcha_response_field'] = 'Recaptcha';
         $fields['write_ans'] = lang('webshop_security_question');
         $this->validation->set_fields($fields);
         // run validation
         if ($this->validation->run() == FALSE) {
             // if false outputs errors
             $this->validation->output_errors();
         } else {
             $e = $this->input->post('email');
             // otherwise check if the customer's email is in the database
             $numrow = $this->MCustomers->checkCustomer($e);
             if ($numrow == TRUE) {
                 // you have registered before, set the message and redirect to login page.
                 flashMsg('info', lang('webshop_registed_before'));
                 // $this->session->set_flashdata('msg', lang('webshop_registed_before'));
                 redirect($this->module . '/login', 'refresh');
             }
             // a customer is new, so create the new customer, set message and redirect to login page.
             $data = array('customer_first_name' => db_clean($_POST['customer_first_name'], 25), 'customer_last_name' => db_clean($_POST['customer_last_name'], 25), 'phone_number' => db_clean($_POST['phone_number'], 15), 'email' => db_clean($_POST['email'], 50), 'address' => db_clean($_POST['address'], 50), 'city' => db_clean($_POST['city'], 25), 'post_code' => db_clean($_POST['post_code'], 10), 'password' => db_clean(dohash($_POST['password']), 16));
             $module = 'customer';
             $this->MKaimonokago->addItem($module, $data);
             //$this->MCustomers->addCustomer();
             flashMsg('success', lang('webshop_thank_registration'));
             // $this->session->set_flashdata('msg', lang('webshop_thank_registration'));
             redirect($this->module . '/login');
         }
     }
     // end of if($this->input->post('email'))
     $data['title'] = $this->preference->item('site_name') . " | " . "Registration";
     $data['page'] = $this->config->item('backendpro_template_shop') . 'registration';
     $data['module'] = $this->module;
     $this->load->view($this->_container, $data);
 }
Exemple #24
0
 function _register()
 {
     $tmp = $this->_clean_data();
     $data['name'] = $tmp[$this->register_var[0]];
     $data['pass'] = dohash($tmp[$this->register_var[2]]);
     $data['email'] = $tmp[$this->register_var[1]];
     $data['lastip'] = $this->ci->input->ip_address();
     $data['permission'] = serialize($this->default_permision);
     $data = $this->ci->db->escape($data);
     $sql = "INSERT INTO " . $this->ci->db->dbprefix($this->table) . "(name,pass,email,created,lastip,permission) VALUES(?,?,?,NOW(),?,?);";
     if (!$this->if_exist(self::EMAIL, $data['email']) && !$this->if_exist(self::USER, $data['name'])) {
         $this->ci->db->query($sql, $data);
         if ($this->ci->config->item('smf') == TRUE) {
             require_once FCPATH . $this->ci->config->item('smfpath');
             smf_registerMember($data['name'], $data['email'], $tmp[$this->register_var[2]], $extra_fields = array(), $theme_options = array());
         }
         redirect(base_url() . lang_id() . '/');
     }
     unset($tmp);
     unset($data);
 }
 private function _generate_key()
 {
     $this->load->helper('security');
     do {
         $salt = dohash(time() . mt_rand());
         $new_key = substr($salt, 0, config_item('rest_key_length'));
     } while (self::_key_exists($new_key));
     return $new_key;
 }
Exemple #26
0
 public function checkContestPassword($contestid, $contestpass)
 {
     $q = '
   SELECT pcc.contest_id
   FROM pc_contest pcc
   WHERE contest_id     = ' . $contestid . '
   AND contest_password = '******'sha1')) . '
 ';
     $qr = $this->db->query($q);
     if ($qr->num_rows() > 0) {
         $row = $qr->first_row();
         $data = array('contestid' => $row->contest_id);
         $this->session->set_userdata($data);
     } else {
         $this->session->sess_destroy();
     }
     redirect(site_url() . '/contest');
 }
Exemple #27
0
	private function _call($property, $method, $arguments = array(), $expires = NULL)
	{
		$this->_ci->load->helper('security');

		if(!is_array($arguments))
		{
			$arguments = (array) $arguments;
		}

		// Clean given arguments to a 0-index array
		$arguments = array_values($arguments);

		$cache_file = $property.DIRECTORY_SEPARATOR.dohash($method.serialize($arguments), 'sha1');

		// See if we have this cached or delete if $expires is negative
		if($expires >= 0)
		{
			$cached_response = $this->get($cache_file);
		}
		else
		{
			$this->delete($cache_file);
			return;
		}

		// Not FALSE? Return it
		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->write($new_response, $cache_file, $expires);

			return $new_response;
		}
	}
 public function _parse_single($key, $val, $string)
 {
     $newval = $val;
     $find = "/" . $this->l_delim . "" . $key . ".*" . $this->r_delim . "/U";
     preg_match($find, $string, $matches);
     if (!empty($matches)) {
         $temp = trim($matches[0], "{}");
         $res = explode(":", $temp);
         // var_dump($res);
         if (count($res) > 1) {
             switch ($res[1]) {
                 case "allcaps":
                     $newval = strtoupper($val);
                     break;
                 case "money":
                     $newval = number_format((int) $val, 2, ".", ",");
                     break;
                 case "caps":
                     $newval = ucwords(strtolower($val));
                     break;
                 case "nocaps":
                     $newval = strtolower($val);
                     break;
                 case "ucfirst":
                     $newval = ucfirst($val);
                     break;
                 case "bool1":
                     $newval = $val == 1 ? "True" : "False";
                     break;
                 case "bool2":
                     $newval = $val == 1 ? "Yes" : "No";
                     break;
                 case "bool3":
                     $newval = $val == 1 ? "Active" : "Inactive";
                     break;
                 case "climit":
                     $int = count($res) < 3 ? 128 : $res[2];
                     $newval = character_limiter($val, $int);
                     break;
                 case "htmlchars":
                     $newval = quotes_to_entities($val);
                     break;
                 case "wlimit":
                     $int = count($res) < 3 ? 25 : $res[2];
                     $newval = word_limiter($val, $int);
                     break;
                 case "wrap":
                     $int = count($res) < 3 ? 76 : $res[2];
                     $newval = word_wrap($val, $int);
                     break;
                 case "hilite":
                     $str = count($res) < 3 ? "" : $res[2];
                     $color = count($res) < 4 ? "#990000" : $res[3];
                     $newval = highlight_phrase($val, $str, "<span style=\"color:{$color}\">", "</span>");
                     break;
                 case "safe_mailto":
                     $alt_text = count($res) < 3 ? "" : $res[2];
                     $newval = safe_mailto($val, $alt_text);
                     break;
                 case "url_title":
                     $sep = count($res) < 3 ? "dash" : $res[2];
                     $newval = url_title($val, $sep);
                     break;
                 case "remove_img":
                     $newval = strip_image_tags($val);
                     break;
                 case "hash":
                     $hash = count($res) < 3 ? "md5" : $res[2];
                     $newval = dohash($val, $hash);
                     break;
                 case "stripslashes":
                     $newval = stripslashes($val);
                     break;
                 case "strip_tags":
                     $allowed = count($res) < 3 ? "" : $res[2];
                     $newval = strip_tags($val, $allowed);
                     break;
                     /** other output string format options here **/
             }
             return str_replace($matches[0], $newval, $string);
         }
     }
     return parent::_parse_single($key, $val, $string);
 }
Exemple #29
0
 function register()
 {
     $data = array('company' => $_POST['company'], 'edate' => date('Y-m-d'));
     $this->db->insert('company', $data);
     $company_id = $this->db->insert_id();
     $data = array('email' => $_POST['email'], 'company_id' => $company_id, 'password' => substr(dohash($_POST['password']), 0, 16), 'fname' => $_POST['fname'], 'type' => 'admin', 'status' => 'inactive', 'code' => dohash($_POST['fname']), 'edate' => date('Y-m-d'));
     $this->db->insert('users', $data);
     $user_id = $this->db->insert_id();
     $mail = array('id' => $user_id, 'code' => dohash($_POST['fname']));
     return $mail;
 }
Exemple #30
0
	public function hash_password($old='') 
	{
		if (!function_exists('dohash'))
		{
			$this->load->helper('security');
		}
	
		$salt = $this->generate_salt();
		$pass = dohash($salt . $old);
		
		return array($pass, $salt);
	}