public function edit() { $this->Purview_model->checkPurviewAjax($this->tablefunc, 'edit'); $post = $this->input->post(NULL, TRUE); if ($post['id'] && $post['action'] == site_aurl($this->tablefunc)) { if ($this->Data_model->getSingle(array('username' => $post['username'], 'id !=' => $post['id']))) { show_jsonmsg(array('status' => 206)); } $time = time(); $data = elements($this->fields, $post); $data['updatetime'] = $time; if ($post['password'] != '') { $this->load->helper('string'); $salt = random_string('alnum', 6); $data['password'] = md5pass($post['password'], $salt); $data['salt'] = $salt; } $datawhere = array('id' => $post['id']); $this->Data_model->editData($datawhere, $data); show_jsonmsg(array('status' => 200, 'id' => $post['id'], 'remsg' => $this->_setlist($this->Data_model->getSingle(array('id' => $post['id'])), false))); } else { $id = $this->uri->segment(4); if ($id > 0 && ($view = $this->Data_model->getSingle(array('id' => $id)))) { $res = array('tpl' => 'view', 'tablefunc' => $this->tablefunc, 'view' => $view, 'usergroup' => $this->Data_model->getData(array('status' => 1), 'listorder', 0, 0, 'usergroup')); show_jsonmsg(array('status' => 200, 'remsg' => $this->load->view($this->tablefunc, $res, true))); } else { show_jsonmsg(array('status' => 203)); } } }
function login($username, $userpass) { $this->CI->Data_model->setTable('user'); $user = $this->CI->Data_model->getSingle(array('username' => $username)); if (isset($user['status']) && $user['status'] == 1 && $user['password'] == md5pass($userpass, $user['salt'])) { $this->CI->Data_model->editData(array('id' => $user['id']), array('logincount' => $user['logincount'] + 1, 'lasttime' => time())); $this->setLogin($user); return true; } else { return false; } }
public function save() { $this->Purview_model->checkPurviewAjax($this->tablefunc, 'save'); $post = $this->input->post(NULL, TRUE); $user = $this->Data_model->getSingle(array('id' => $this->session->userdata('uid')), 'user'); if ($user['password'] != md5pass($post['oldpassword'], $user['salt'])) { show_jsonmsg(array('status' => 207, 'remsg' => lang('user_oldpasserror'))); } if (trim($post['password']) != trim($post['password1'])) { show_jsonmsg(array('status' => 207, 'remsg' => lang('user_confirmerror'))); } $data = array('password' => md5pass(trim($post['password']), $user['salt']), 'updatetime' => time(), 'lastip' => $this->input->ip_address()); $this->Data_model->editData(array('id' => $this->session->userdata('uid')), $data, 'user'); show_jsonmsg(array('status' => 205)); }
/** * 根据UI层的密码生成用户密码 */ private function generate_user_pass($user_pass) { $this->load->helper('string'); $salt = random_string('alnum', 6); $password = md5pass($user_pass, $salt); return array('password' => $password, 'salt' => $salt); }
} $DatabasePath = '../application/config/database.php'; $ConfigPath = '../application/config/config.php'; $error = ''; $step = 1; if (isset($_POST['action']) && $_POST['action'] == 1) { $dbhost = trim($_POST['dbhost']); $dbuser = trim($_POST['dbuser']); $dbpwd = trim($_POST['dbpwd']); $dbname = trim($_POST['dbname']); $base_url = trim($_POST['base_url']); $admin_folder = trim($_POST['admin_folder']); $username = trim($_POST['username']); $userpass = trim($_POST['userpass']); $salt = random_string('alnum', 6); $userpass = md5pass($userpass, $salt); if (!empty($dbhost) && !empty($dbuser)) { if (!@mysql_connect($dbhost, $dbuser, $dbpwd)) { $error = $lang['dbconnecterror']; } else { if (!@mysql_select_db($dbname)) { $DATABASESQL = "DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"; if (!mysql_query("CREATE DATABASE `{$dbname}` " . $DATABASESQL)) { $error = $lang['dbcreateerror']; } } if (mysql_select_db($dbname)) { mysql_query("set names utf8"); $sql = file_get_contents('./db/install.sql'); $sql = str_replace('http://demo.x6cms.com/', $base_url, $sql); $sqlarr = explode(";\n", $sql);