Exemplo n.º 1
0
 function update_pwd($data)
 {
     $query = $this->get_user_by_uid($data['uid']);
     $password = password_dohash($data['password'], @$query['salt']);
     $this->db->where('uid', $data['uid']);
     $this->db->update('users', array('password' => $password));
     return $this->db->affected_rows();
 }
Exemplo n.º 2
0
 /**
  * 安装过程
  */
 public function process()
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $data['item']['dbhost'] = $this->input->post('dbhost') ? $this->input->post('dbhost') : 'localhost';
     $data['item']['port'] = $this->input->post('port') ? $this->input->post('port') : '3306';
     $data['item']['dbprefix'] = $this->input->post('dbprefix') ? $this->input->post('dbprefix') : 'stb_';
     $data['item']['username'] = $this->input->post('username') ? $this->input->post('username') : 'admin';
     $data['item']['email'] = $this->input->post('email') ? $this->input->post('email') : '*****@*****.**';
     if ($this->form_validation->run() === TRUE) {
         $dbhost = $this->input->post('dbhost');
         $dbuser = $this->input->post('dbuser');
         $dbpsw = $this->input->post('dbpsw');
         $dbname = $this->input->post('dbname');
         $port = $this->input->post('port');
         $dbprefix = $this->input->post('dbprefix');
         $salt = get_salt();
         $password = password_dohash($this->input->post('password'), $salt);
         $admin = array('group_type' => 0, 'gid' => 1, 'is_active' => 1, 'username' => $this->input->post('username'), 'password' => $password, 'salt' => $salt, 'email' => $this->input->post('email'), 'regtime' => time(), 'ip' => get_onlineip());
         if (function_exists(@mysqli_connect)) {
             $con = mysqli_connect($dbhost, $dbuser, $dbpsw, $dbname, $port);
         } else {
             $con = mysql_connect($dbhost . ':' . $dbport, $dbuser, $dbpsw);
         }
         //检查数据库信息是否正确
         if (!$con) {
             $string = '
             <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
             <script>
             alert("无法访问数据库,请重新安装!");
             top.location="' . site_url('install') . '";
             </script>
             ';
             exit($string);
         }
         //写入数据库配置文件
         $this->_writeDBConfig($dbhost, $dbuser, $dbpsw, $dbname, $port, $dbprefix);
         //创建数据表
         $this->_createTables($dbhost, $dbuser, $dbpsw, $dbname, $port, $dbprefix, $con);
         //禁止安装的文件
         file_put_contents(FCPATH . 'install.lock', time());
         //写入config文件
         $sub_folder = $this->input->post('base_url');
         if ($sub_folder) {
             $this->config->update('myconfig', 'sub_folder', $sub_folder);
         }
         $encryption_key = md5(uniqid());
         if ($encryption_key) {
             $this->config->update('myconfig', 'encryption_key', $encryption_key);
         }
         sleep(1);
         //添加管理员
         $this->load->database();
         $this->load->model('user_m');
         $this->user_m->register($admin);
         //update stats
         $this->db->set('value', 1)->where('item', 'total_users')->update('site_stats');
         $this->db->set('value', 1)->where('item', 'last_uid')->update('site_stats');
         $this->user_m->login($admin);
         $this->load->view('install_done');
     } else {
         $this->load->view('install_process', $data);
     }
 }
Exemplo n.º 3
0
 public function resetpwd()
 {
     $this->load->helper('form');
     $array = explode('.', base64_decode(@$_GET['p']));
     $data = $this->user_m->getpwd_by_username($array['0']);
     //$sql = "select passwords from member where username = '******'0'])."'";
     $checkCode = md5($array['0'] . '+') . @$data['password'];
     if (@$array['1'] === $checkCode) {
         if ($this->form_validation->run() === TRUE) {
             $salt = get_salt();
             $password = password_dohash($this->input->post('password'), $salt);
             if ($this->user_m->update_user(@$data['uid'], array('password' => $password, 'salt' => $salt))) {
                 $this->session->set_userdata(array('uid' => $data['uid'], 'username' => $array['0'], 'group_type' => $data['group_type'], 'gid' => $data['gid']));
                 redirect('/');
             }
         }
     } else {
         show_message('非法重置!!');
     }
     $data['title'] = '设置新密码';
     $data['p'] = $_GET['p'];
     $data['csrf_name'] = $this->security->get_csrf_token_name();
     $data['csrf_token'] = $this->security->get_csrf_hash();
     $this->load->view('findpwd', $data);
 }