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(""); } }
function validate() { $this->db->where('nic', $this->input->post('username')); $this->db->where('pass', md5($this->input->post('password'))); //A checkbox to remember me after login $check_box = $this->input->post('rember_me'); $query = $this->db->get('user'); if ($query->num_rows == 1) { //Setup session foreach ($query->result() as $row) { //$user_level = $row->user_level; $username = $row->nic; $password = $row->pass; $id = $row->id; $first_name = $row->first; $last_name = $row->last; $data = array('username' => $username, 'id' => $id, 'name' => $name, 'user_level' => 1, 'is_logged_in' => true); $this->session->set_userdata($data); } //if statement for remember me if ($check_box == "accept") { $value = array('id' => $id, 'username' => $username); $value = serialize($value); $cookie = array('name' => 'loginuser', 'value' => $value, 'expire' => '2410000', 'domain' => 'mysocialnetwork.es', 'path' => '/', 'prefix' => '', 'secure' => false); set_cookie($cookie); } return true; } else { return false; } }
public function login() { if ($this->auth != NULL) { $this->cm_string->php_redirect("backend"); } if ($this->db->count_all_results('cm_user') == 0) { $this->cm_string->php_redirect("backend/auth/create_manager"); } $data['seo']['title'] = 'Color ME Admin'; $data['seo']['keywords'] = ''; $data['seo']['description'] = 'Login System of Color ME'; if ($this->input->post('login')) { $post_data = $this->input->post(); $data['post_data']['username'] = $post_data['username']; $data['post_data']['password'] = $post_data['password']; $this->form_validation->set_rules('username', 'Username', 'trim|required|regex_match[/^([a-z0-9_])+$/i]|callback__username_check'); $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[8]|callback__password_check[' . $post_data['username'] . ']'); if ($this->form_validation->run() == TRUE) { $user = $this->db->select('username,password,salt')->where(array('username' => $post_data['username']))->from('user')->get()->row_array(); set_cookie(md5(base_url()) . 'user_logged', $this->cm_string->encrypt_cookie(json_encode($user)), time() + 7 * 24 * 3600); $data = array('logined' => gmdate('Y-m-d H:i:s', time() + 7 * 3600), 'ip_logging' => $_SERVER['SERVER_ADDR']); $this->db->where(array('username' => $post_data['username']))->update('user', $data); // $this->cm_string->js_redirect('Login Success', base_url('backend/Auth/login')); $this->cm_string->php_redirect("backend/Auth/login"); } } $data['template'] = 'backend/auth/login'; $this->load->view('backend/layout/login', isset($data) ? $data : NULL); }
function center() { $file = $this->uri->rsegment(3, ''); $url = 'user/user_main/index'; if ($file == 'inbox') { $url = 'user/message/inbox'; } $rs = $this->comm->find("member", array('username' => $this->username, 'password' => $this->password), "", "userid,username,password,loginip,logintime,logintimes"); if ($rs) { $logintimes = intval($rs['logintimes']) + 1; $udata = array('loginip' => $_SERVER['REMOTE_ADDR'], 'logintime' => $_SERVER['REQUEST_TIME'], 'lastip' => $rs['loginip'], 'lasttime' => $rs['logintime'], 'logintimes' => $logintimes); $this->comm->update("member", array("userid" => $rs['userid']), $udata); $this->load->library('encrypt'); $hash_1 = $this->encrypt->sha1($rs['username'] . time()); $hash_2 = $this->encrypt->sha1($rs['password'] . time()); $username = $this->encrypt->encode($rs['username'], $hash_1); $password = $this->encrypt->encode($rs['password'], $hash_2); $this->load->helper('cookie'); $site = $this->config->item('site'); set_cookie('username', $username, 3600, ".{$site['site_url']}"); set_cookie('password', $password, 3600, ".{$site['site_url']}"); set_cookie('hash_1', $hash_1, 3600, ".{$site['site_url']}"); set_cookie('hash_2', $hash_2, 3600, ".{$site['site_url']}"); } redirect(main_url(site_url($url))); }
/** * login * * Phương thức đăng nhập * * @param type $arrOutput * @param type $arrInput * @param type $strRedirect * @param type $strMode */ function login(&$arrOutput = array(), $arrInput = array(), $strRedirect = '', $strMode = '') { // get the CI object $CI =& get_instance(); $CI->load->helper('cookie'); $CI->load->library('session'); $CI->load->model('common_model'); if ($strMode == 'account') { $CI->db->where('username', $arrInput['username']); $CI->db->where('password', $arrInput['password']); $CI->db->where('status', 1); $arrUserInfo = $CI->db->get('users')->row_array(); if ($arrUserInfo != null && count($arrUserInfo) > 0) { if ($this->checkAllowLogin($arrUserInfo['role_id'])) { if ($arrInput['remember'] == 1) { set_cookie('user_id', $arrUserInfo['id'], 86500); } else { $CI->session->set_userdata('user_id', $arrUserInfo['id']); } // Update last login $CI->db->where('id', $arrUserInfo['id']); $CI->db->update('users', array('lastlogin' => getCurrentDt())); // Redirect to admin panel redirect($strRedirect); } else { $arrOutput['errLogin'] = LTV0055; } } else { $arrOutput['errLogin'] = LTV0001; } } }
static function loginOut() { $user = self::getLoginUser(); $userID = MyDes::share()->encode($user->id, DES_KEY); self::delLoginInfo($userID); set_cookie(getC('LOGIN_KEY'), 0, -1); }
function loginFromDatabase($_uid) { global $mysql; $user = $mysql->query('select * from users where ID=' . $_uid)->fetch(); if (!$user) { return -1; } set_cookie($user['cookie']); if (isset($user['bduss'])) { //删除数据库里的无用列 $mysql->query('ALTER TABLE `users` DROP `bduss`'); } global $cookie_jar, $bduss; if (!isset($cookie_jar['BDUSS'])) { return false; } $bduss = $cookie_jar['BDUSS']; //原本想把bdstoken存进数据库,想到需要检验cookie是否合法,还是改成动态获取 global $bdstoken; $bdstoken = validateCookieAndGetBdstoken(); if (!$bdstoken) { $bduss = false; return false; } global $uid, $username, $md5; $uid = $_uid; $username = $user['username']; $md5 = $user['newmd5'] === '' ? false : $user['newmd5']; return true; }
function setFlow() { $this->load->database(); //存入cookie中 $this->load->helper('cookie'); $yk_id = get_cookie('id'); //获取游客id set_cookie('flow', '100M'); $count = $this->db->where('id', $yk_id)->from('user_session')->count_all_results(); //插入之前先查查游客表该游客是否被记录了 $session_data = array('id' => $yk_id, 'flow' => '100M'); if ($count > 0) { //游客已经存入表中,只是更新 unset($session_data['id']); $this->db->where('id', $yk_id)->update('user_session', $session_data); } else { $this->db->insert('user_session', $session_data); } $username = $this->session->userdata['username']; if ($username) { //如果用户已经注册,则还要存入用户表 $this->db->where('username', $username)->update('userinfo', array('flow' => '100M')); } echo 'success'; }
public function doLogin($uid) { //登录要写cookie,内容包含uid和在线id $onlineId = $this->save_online_info($uid); $cookieCont = $this->encode_cookie($uid, $onlineId); set_cookie($this->cookieName, $cookieCont, $this->CI->config->item('login_expire')); }
public function login() { $this->load->model('user_model', 'User'); $this->load->model('application_model', 'Application'); if (get_cookie("eventribe-remember-token") != "") { $login = $this->User->get_user_from_token(get_cookie("eventribe-remember-token")); $this->session->set_userdata("user", $login); redirect(base_url() . 'router/org_picker/' . $login); } else { $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[250]'); $this->form_validation->set_rules('password', 'Password', 'required|min_length[5]|max_length[250]'); //run validation if ($this->form_validation->run() == FALSE) { $this->session->set_flashdata('errors', validation_errors()); redirect(base_url()); } else { $login = $this->User->login($this->input->post('username'), $this->input->post('password')); if ($login != "" && $login != "invalid login parameters") { $this->session->set_userdata("user", $login); $this->session->set_userdata("username", $this->input->post("username")); $this->session->set_userdata("password", $this->input->post("password")); if ($this->input->post("remember") == 1) { $token = $this->User->set_remember_me($this->input->post("username"), $this->input->post("password")); $expire = time() + 2678400; $cookie = array('name' => 'eventribe-remember-token', 'value' => $token, 'expire' => $expire, 'secure' => TRUE); set_cookie($cookie); } redirect(base_url() . 'router/org_picker/' . $login); } else { $this->session->set_flashdata('errors', $login); redirect(base_url()); } } } }
public function logout() { $this->load->helper('cookie'); set_cookie('menu_url', '', time() - 3600); $this->session->sess_destroy(); successRedirct('backend/user/login', "退出成功!"); }
public function space_count() { $uid = (int) $this->input->get('uid'); if ($this->uid && $uid && $this->uid != $uid) { // 记录访客信息 $name = 'space-count-' . $this->uid . '-' . $uid; if (get_cookie($name)) { // 缓存期 } else { // 查询今天是否访问过 if ($this->db->where('uid', $this->uid)->where('spaceid', $uid)->where('DATEDIFF(from_unixtime(inputtime),now())=0')->count_all_results('space_access')) { $this->db->where('uid', $this->uid)->where('spaceid', $uid)->update('space_access', array('inputtime' => SYS_TIME)); } else { $this->db->insert('space_access', array('uid' => $this->uid, 'spaceid' => $uid, 'content' => '', 'username' => $this->member['username'], 'inputtime' => SYS_TIME)); } set_cookie($name, SYSTIME, 300); // 5分钟统计一次 } } // 验证空间权限 if ($this->_space_show($uid)) { $callback = isset($_GET['callback']) ? $_GET['callback'] : 'callback'; exit($callback . '(' . json_encode(array('url' => dr_member_url('api/access', array('uid' => $uid)))) . ')'); } exit(''); }
public function skins() { $skin = $this->input->get_post('skin', TRUE); $skin = $skin ? $skin : 'green'; set_cookie('skin', $skin, 120000); die('{"status":200,"msg":"success"}'); }
public function login() { $username = $this->input->post('username'); $password = $this->input->post('password'); $remember_check = $this->input->post('remember_check'); if (isset($remember_check)) { set_cookie('ck_username', $username, time() + 60); set_cookie('ck_password', $password, time() + 60); set_cookie('ck_remember', $remember_check, time() + 60); } else { delete_cookie('ck_username'); delete_cookie('ck_password'); delete_cookie('ck_remember'); } $salt = '$2a$04$123456789123456789123$'; $hashed_password = crypt($password, $salt); $where_arr = array('admin_name' => $username, 'admin_pass' => $hashed_password); $query = $this->db->get_where("tbl_admin", $where_arr); $row = $query->row_array(); //คิวรี่ข้อมูลมาแสดงแค่รายการเดียว if (isset($row)) { $newdata = array('ses_admin_id' => $row['admin_id'], 'ses_admin_name' => $row['admin_name']); $this->session->set_userdata($newdata); // อัพเดทข้อมูลการล็อกอินของ admin เช่น ล็อกอินล่าสุด $update_data = array('admin_lastlogin ' => date("Y-m-d H:i:s")); $this->db->update('tbl_admin', $update_data, array('admin_id' => $row['admin_id'])); } redirect('admin'); // ไปหน้า admin }
function mobile_detect() { if (!INSTALL_MODULE_DONE) { return false; } $CI =& get_instance(); $CI->load->helper('cookie'); $mobile_detect = filter_input(INPUT_GET, 'mobile_detect'); if (empty($mobile_detect)) { $mobile_detect = filter_input(INPUT_COOKIE, 'mobile_detect'); } elseif ('denied' === $mobile_detect) { // Back from the mobapp set_cookie(array('name' => 'mobile_detect', 'value' => 'denied', 'expire' => time() + '86500', 'domain' => COOKIE_SITE_SERVER, 'path' => '/' . SITE_SUBFOLDER)); return false; } if ('denied' === $mobile_detect || !$CI->pg_module->is_module_installed('mobile') || $CI->router->is_api_class || !$CI->pg_module->get_module_config('mobile', 'use_mobile_detect')) { return false; } else { $CI->load->library('mobile_detect'); if ($CI->mobile_detect->isMobile()) { set_cookie(array('name' => 'mobile_detect', 'value' => 'ask', 'expire' => time() + '86500', 'domain' => COOKIE_SITE_SERVER, 'path' => '/' . SITE_SUBFOLDER)); redirect($CI->pg_module->get_module_config('mobile', 'app_url') . '/#!/redirect'); } return true; } }
function dsession() { $this->obj = new Memcache(); include DT_ROOT . '/file/config/memcache.inc.php'; $num = count($MemServer); if ($num == 1) { $key = 0; } else { $key = get_cookie('memcache'); if ($key == -1) { $key = 0; } else { if (!isset($MemServer[$key])) { $key = array_rand($MemServer); set_cookie('memcache', $key ? $key : -1); } } } $this->obj->connect($MemServer[$key]['host'], $MemServer[$key]['port'], 2); if (DT_DOMAIN) { @ini_set('session.cookie_domain', '.' . DT_DOMAIN); } session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc')); session_cache_limiter('private, must-revalidate'); session_start(); header("cache-control: private"); }
public function sCookie($usn, $accountID) { $this->load->helper('cookie'); $cookie = array('name' => 'MemberInfo', 'value' => json_encode(array('accountID' => $accountID, 'usn' => $usn)), 'expire' => '86500', 'prefix' => 'codingclub_', 'domain' => CKDOMAIN); set_cookie($cookie); return; }
/** * Login method * @functionality will check username and password to make user logged * */ public function login() { if ($this->data['auth']) { redirect(base_url($this->data['lang'])); } $data = ['email' => $this->input->post('email'), 'password' => md5($this->input->post('password'))]; $user = $this->user_model->login($data)[0]; if (!$user) { $this->session->set_flashdata('error', 'Invalid email address or password'); redirect(base_url($this->data['lang'])); } else { if ($user->email_verified != 1) { $this->load->helper('cookie'); set_cookie('user_id', $user->id, '300'); set_cookie('user_email', $user->email, '300'); $this->session->set_flashdata('error', 'Sorry your email address is not verified. Please go to your inbox messages and follow to instruction or click <a href="' . $this->data['lang'] . '/action/register/registered">Send again</a>'); redirect(base_url($this->data['lang'])); } else { $user_info = $this->user_model->get_where(['user_id' => $user->id], '*', 'user_info')[0]; $this->session->set_userdata(['user_info' => $user_info, 'user' => $user, 'is_logged_in' => true]); $this->user_model->set_table('users'); redirect(base_url($this->data['lang'] . '/user/profile')); } } }
/** * 执行任务和队列 */ public function index() { // 第三方执行队列时,非命令行不执行 if (SYS_CRON_QUEUE && !(PHP_SAPI === 'cli' || defined('STDIN'))) { exit; } // 自动更新模块缓存(3小时一次) $file = FCPATH . 'cache/auto.log'; $auto = is_file($file) ? (int) file_get_contents($file) : 0; if (!$auto || $auto <= SYS_TIME - 10800) { $this->clear_cache('module'); file_put_contents($file, SYS_TIME); } // 未到发送时间 if (get_cookie('cron')) { exit; } // 一次执行的任务数量 $pernum = defined('SYS_CRON_NUMS') && SYS_CRON_NUMS ? SYS_CRON_NUMS : 10; // 用户每多少秒调用本程序 set_cookie('cron', 1, SYS_CRON_TIME); // 查询所有队列记录 $queue = $this->db->order_by('status ASC,id ASC')->limit($pernum)->get('cron_queue')->result_array(); if (!$queue) { // 所有任务执行完毕 $this->db->query('TRUNCATE `' . $this->db->dbprefix('cron_queue') . '`'); exit; } foreach ($queue as $data) { $this->cron_model->execute($data); } // 本次任务执行完毕 exit; }
public function ajax() { $data = $this->input->post('data', TRUE); $uid = $this->member_model->admin_login($data['username'], $data['password']); if ($uid > 0) { set_cookie('finecms-admin-login', $data['username'], 999999); exit(dr_json(1, 1, 1)); } if ($uid == -1) { $error = lang('043'); exit(dr_json(0, $error, 'username')); } elseif ($uid == -2) { $error = lang('044'); exit(dr_json(0, $error, 'password')); } elseif ($uid == -3) { $error = lang('045'); exit(dr_json(0, $error, 'username')); } elseif ($uid == -4) { $error = lang('046'); exit(dr_json(0, $error, 'username')); } else { $error = lang('047'); exit(dr_json(0, $error, 'username')); } }
function in() { $this->load->library('form_validation'); $this->form_validation->set_rules(array(array('field' => 'mb_id', 'label' => '아이디', 'rules' => 'trim|required|min_length[3]|max_length[20]|alpha_dash|xss_clean'), array('field' => 'mb_password', 'label' => '비밀번호', 'rules' => 'trim|required|md5'))); if ($this->form_validation->run() !== FALSE) { $this->load->library('encrypt'); $mb = $this->Basic_model->get_member($this->input->post('mb_id'), 'mb_id, mb_password, mb_email, mb_leave_date, mb_email_certify'); if (!$mb || $this->input->post('mb_password') !== $this->encrypt->decode($mb['mb_password'])) { goto_url('member/login/qry/1'); } if ($mb['mb_leave_date'] && $mb['mb_leave_date'] <= date('Ymd', time())) { $date = preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})/", "\\1년 \\2월 \\3일", $mb['mb_leave_date']); alert("탈퇴한 아이디이므로 접근하실 수 없습니다.\\n\\n탈퇴일 : " . $date); } if ($this->config->item('cf_use_email_certify') && !preg_match("/[1-9]/", $mb['mb_email_certify'])) { alert("메일인증을 받으셔야 로그인 하실 수 있습니다.\\n\\n회원님의 메일주소는 " . $mb['mb_email'] . " 입니다."); } $this->session->set_userdata('ss_mb_id', $mb['mb_id']); if ($this->input->post('reId')) { $cookie = array('name' => 'ck_mb_id', 'value' => $mb['mb_id'], 'expire' => 86400 * 30, 'domain' => $this->config->item('cookie_domain')); set_cookie($cookie); } else { if (get_cookie('ck_mb_id')) { delete_cookie('ck_mb_id'); } } goto_url($this->input->post('url')); } goto_url('/'); }
public function ajaxLogin() { $lang = $this->input->post('lang'); $params['username'] = $this->input->post('username'); $params['password'] = $this->input->post('password'); $params['lang'] = $lang; $params['login_type'] = 2; $this->load->model('admin/admin_model', 'am'); $response = $this->am->admin_login($params); // $response = $this->post(BASE_API_URL.'account/account/admin_login' , $params); $output = $response->getOutput(); if ($response->isOK()) { $results = $output->results; $this->session->set_userdata('token', $results['token']); $this->session->set_userdata('admin_name', $results['name']); set_cookie('name', $lang); $out['method'] = 'redirect'; $out['message'] = $output->message; $out['url'] = site_url('dashboard'); $this->output->set_content_type('application/json')->set_output(json_encode($out)); return; } else { $results = $output->results; $out['method'] = 'alert'; $out['message'] = $output->message; $this->output->set_content_type('application/json')->set_output(json_encode($out)); return; } }
function u_remember_me_set($remember_me = '') { //get obj $CI =& get_instance(); $CI->load->helper('cookie'); //get $kuki_name = DEFAULT_REMEMBER_ME_COOKIE_NAME; $kuki_max = DEFAULT_REMEMBER_ME_COOKIE_MAX; $raw = get_cookie($kuki_name); $ip = $_SERVER['REMOTE_ADDR']; delete_cookie($kuki_name); //set $res = $remember_me; //We must be setting the remember me setting $cookie = array('name' => $kuki_name, 'value' => $res, 'expire' => 60 * 60 * 24 * $kuki_max); log_message("INFO", "u_remember_me_set({$ip}) : set-info#{$res} [ {$remember_me} : {$raw} ]"); $dmp = @var_export($_COOKIE, true); log_message("INFO", "u_remember_me_set({$ip}) : pre-info# [ {$dmp} ]"); //set it ;-) set_cookie($cookie); $dmp = @var_export($_COOKIE, true); log_message("INFO", "u_remember_me_set({$ip}) : post-info# [ {$dmp} ]"); //give it back ;-) return true; }
public function index() { $this->load->library('form_validation'); // Получаем меню для сайдбара $this->load->model('commerce/commerce_m'); $data['subcategory'] = $this->commerce_m->get_all_subcategories(); $data['category'] = $this->commerce_m->get_all_categories(); /* Блок авторизации */ $data['auth_form'] = $this->load->module('auth')->auth_block_generator(); $this->load->helper('captcha'); $string_for_captcha = random_string('numeric', 6); $vals = array('word' => $string_for_captcha, 'img_path' => './img/captcha/', 'img_url' => base_url() . 'img/captcha/', 'font_path' => './system/fonts/texb.ttf', 'img_width' => '150', 'img_height' => '50', 'expiration' => '50'); $cap = create_captcha($vals); $cap['random_string_for_captcha'] = $string_for_captcha; $cookie = array('name' => 'captcha', 'value' => $string_for_captcha, 'expire' => '7200'); set_cookie($cookie); if ($this->input->post('submit_contacts')) { } else { } $data['contacts'] = $this->load->view('contacts/contacts_v.php', $cap, true); /* Метатэги */ $data['seo_title'] = 'Контакты '; $data['seo_description'] = 'Контакты seo_description'; $data['seo_keywords'] = 'Контакты seo_keywords'; $this->load->view('main/index_v', $data); }
/** * Update unique token * * @access private */ private function _csrf_refresh() { // Only refresh if it was posted if (!($sent = $this->input->get_post('act_s'))) { $this->load->helper('cookie'); // Work out transaction signature for this uri $random = ']rnu<^hdgg%y|\\T$w?lva$~U3+hM0Jp{HOr!<,qSdxM-!fEE07q_IwRO"B1=5.~'; $csrf_token = md5($_SERVER['PATH_INFO'] . $this->input->user_agent() . $random . $this->input->ip_address()); // Store relevant data set_cookie('act_s', $csrf_token, 2 * 60 * 60); $this->session->set_userdata('token_time', $this->config->item('request_time')); } else { // Keep the current one $csrf_token = $this->input->cookie('act_s'); } // Set response data $this->javascript->set_constant('act_s', $csrf_token); $this->javascript->add_response('act_s', $csrf_token); // Add user information if ($this->access->logged_in()) { $user_js = current_user('js'); $this->javascript->set_constant('user', $user_js['user']); $this->javascript->set_constant('interface', $user_js['interface']); } }
/** * 首页 */ public function index() { $siteconfigs = $this->siteconfigs; $seo_title = $siteconfigs['sitename']; $seo_keywords = $siteconfigs['seo_keywords']; $seo_description = $siteconfigs['seo_description']; $categorys = get_cache('category', 'content'); $city = substr(rtrim($_SERVER["REQUEST_URI"], '/'), 6); $hotcity = hotcity(0); if (empty($city)) { $cityid = get_cookie('cityid'); $city = $categorys[$cityid]['catdir']; //$table, $where = '', $field = '*', $startid = 0, $pagesize $category_result = $this->db->get_list('category', array('modelid' => 3), '*', 0, 1000); include T('city', 'index', TPLID); } else { foreach ($categorys as $cid => $rs) { if ($rs['catdir'] == $city) { $cityid = $cid; set_cookie('cityname', $rs['name'], SYS_TIME + 86400 * 7); set_cookie('cityid', $cityid, SYS_TIME + 86400 * 7); $cityname = $rs['name']; break; } } //header("Location:http://www.h1jk.cn/list-69/"); include T('content', 'index-city', TPLID); } }
function login($username = '', $password = '', $sessionName = '', $redirect = FALSE, $remember = FALSE) { // set default session if (!$sessionName) { $sessionName = $this->sessionName; } // set default redirect if (!$redirect && $this->redirect) { $redirect = $this->redirect; } // check if already logged in if ($this->CI->session->userdata($sessionName) == $sessionName) { return $redirect ? redirect($redirect) : TRUE; } // create account if ($this->do_login($username, $password, $sessionName)) { // check if remember is set if ($remember) { // set cookie $cookie = array('name' => 'halogy', 'value' => $this->CI->core->encode(serialize(array($username, $password, $sessionName))), 'expire' => '604800'); set_cookie($cookie); } return $redirect ? redirect($redirect) : TRUE; } }
public function trylog() { $username = $_POST["usernanme"]; $password = $_POST["password"]; $remember = $this->input->post("remember"); $this->load->model("mod_login"); $try = $this->mod_login->attemp($username, $password); $try = $try->result_array(); if (count($try) == 1) { $uid = $try[0]["id"]; $fname = $try[0]["fullname"]; $token = uniqid($try[0]["id"], true); $usersession = array("user_id" => $uid, "user_fullname" => $fname); $this->session->set_userdata($usersession); if (isset($remember)) { $addtoken = $this->mod_login->addtoken($uid, $token); $usercookie = array("name" => "mjq_user_token", "value" => $token, "expire" => 2592000, "path" => "/", "prefix" => "", "secure" => FALSE); set_cookie($usercookie); } redirect('/admin/home', 'refresh'); } else { $this->session->set_flashdata('attemp', 'fail'); redirect('/login/index', 'refresh'); } }
function do_login($username, $password, $jenis_kantor, $tgl, $dt, $nama_kantor) { $username = strtoupper($username); $password = strtoupper($password); $nama_lkm = $nama_kantor; $tgl = $tgl; $dt = $dt; // cek di database, ada ga? $this->CI->db->from('nasabah'); $this->CI->db->where('nasabah_id', $username); $result = $this->CI->db->get(); if ($result->num_rows() == 1) { $hasil = $result->result(); foreach ($hasil as $row) { $arr = array('usr' => $row->nasabah_id, 'namaNasabah' => $row->nama_nasabah, 'pwd' => $row->password); } $m = ''; $split_password = str_split($arr['pwd']); foreach ($split_password as $value) { $x = ord($value); $x = $x - 5; $x = chr($x); $m = $m . $x; } //$m = passowor dr sql if ($password == $m) { if ($m == '111111') { $this->CI->load->helper('cookie'); $cookie1 = array('name' => 'userId', 'value' => $arr['usr'], 'expire' => time() + 86500); set_cookie($cookie1); $cookie2 = array('name' => 'namaUser', 'value' => $arr['namaNasabah'], 'expire' => time() + 86500); set_cookie($cookie1); $cookie3 = array('name' => 'namaLKM', 'value' => $nama_lkm, 'expire' => time() + 86500); $cookie4 = array('name' => 'tglD', 'value' => $tgl, 'expire' => time() + 86500); $cookie5 = array('name' => 'tglY', 'value' => $dt, 'expire' => time() + 86500); set_cookie($cookie1); set_cookie($cookie2); set_cookie($cookie3); set_cookie($cookie4); set_cookie($cookie5); redirect('main/vResetPassword'); } else { // end if $m=='111111' $session_data = array('user_id' => $arr['usr'], 'nama' => $arr['namaNasabah'], 'level' => 2, 'tglD' => $tgl, 'tglY' => $dt, 'nama_lkm' => $nama_lkm); // buat session $this->CI->session->set_userdata($session_data); $data_auth = array('pesan' => "Anda berhasil login.", 'bool' => true); return $data_auth; } } else { //if($password==$m){ $data_auth = array('pesan' => "Password anda salah.", 'bool' => false); return $data_auth; // die("Maaf, Anda tidak berhak untuk mengakses halaman ini."); } } else { //end if($result->num_rows() == 1){ return false; } }
function del() { set_cookie('cart', '', $this->time + 30 * 86400); if ($this->userid) { $this->db->query("DELETE FROM {$this->table} WHERE userid={$this->userid}"); } }