function indexAction() { if ($this->isGet()) { $this->display(); } else { //表单验证 if (empty($_POST['username'])) { $this->json(lang('admin_user_empty'), 0); } if (empty($_POST['password'])) { $this->json(lang('admin_passwd_empty'), 0); } $map['username'] = $_POST['username']; $admin = new adminModel(); $adminInfo = $admin->getInfo($map); if (!$adminInfo) { $this->json(lang('admin_empty'), 0); } if (md5(md5($_POST['password']) . 'es') != $adminInfo['password']) { $this->json(lang('admin_passwd_error'), 0); } $admin->update(array('logintime' => time())); $_SESSION['admin'] = $adminInfo; $this->json(lang('admin_login_success'), 1); } }
public function authenticate() { if (isset($_POST['txt_username']) && isset($_POST['txt_password'])) { $username = $_POST['txt_username']; $password = $_POST['txt_password']; $adminModel = new adminModel(); $result = $adminModel->get_by_username_and_password($username, $password); if ($result) { $_SESSION['admin'] = $result; $view = new viewModel('admin/jobs'); } else { $view = new viewModel('admin/login'); } } }
public function setAdmin_login() { if ($_GET['username'] && $_GET['pwd']) { $admin = new adminModel(); $admin->username = $_GET['username']; $admin->pwd = md5($_GET['pwd']); //获取当前ip地址 $admin->last_ip = $_SERVER['REMOTE_ADDR']; $oneAdmin = $admin->getOneByNamePWD(); if ($oneAdmin) { //把登录的用户存在session中 $_SESSION['oneAdmin'] = $oneAdmin; $_SESSION['username'] = $_GET['username']; $admin->updateLogin(); exit("ok"); } else { exit("failed"); } } }
public function updateHitAction() { $adminModel = new adminModel(); $result = $adminModel->editHit($_POST); return $this->selectHitAction(); }