query('SELECT `id` FROM `operators` WHERE `username`="'.$_SESSION['hcl_username'].'" AND `password`="'.$_SESSION['hcl_password'].'"')) { $this->username = $_SESSION['hcl_username']; $this->password = $_SESSION['hcl_password']; return true; } else { return false; } } else { return false; } } else { if ($username !== '' && $password !== '') { if ($GLOBALS['db']->query('SELECT `id` FROM `operators` WHERE `username`="'.$username.'" AND `password`="'.md5($password).'"')) { return true; } else { return false; } } elseif ($username !== '' && $password == '') { if ($GLOBALS['db']->query('SELECT `id` FROM `operators` WHERE `username`="'.$username.'"')) { return true; } else { return false; } } else { return false; } } } function admin() { if (isset($_SESSION['hcl_username']) && isset($_SESSION['hcl_password'])) { if ($this->result = $GLOBALS['db']->query('SELECT `level` FROM `operators` WHERE `username`="'.$_SESSION['hcl_username'].'" AND `password`="'.$_SESSION['hcl_password'].'"')) { if ($this->result[0]['level'] == '0') { return true; } else { return false; } } else { return false; } } else { return false; } } function login($username, $password, $arg = '') { if ($arg == '') { if ($login = $GLOBALS['db']->query('SELECT `id` FROM `operators` WHERE `username`="'.$username.'" AND `password`="'.md5($password).'"')) { $_SESSION['hcl_username'] = $username; $_SESSION['hcl_password'] = md5($password); return true; } else { return false; } } else { switch($arg) { case 'no_md5': if ($GLOBALS['db']->query('SELECT `id` FROM `operators` WHERE `username`="'.$username.'" AND `password`="'.$password.'"')) { $_SESSION['hcl_username'] = $username; $_SESSION['hcl_password'] = $password; return true; } else { return false; } break; default: return false; } } } function logout() { unset($_SESSION['hcl_username']); unset($_SESSION['hcl_password']); if (!isset($_SESSION['hcl_username']) && !isset($_SESSION['hcl_password'])) { return true; } else { return false; } } function check_login() { if ($this->operator()) { header('Location: '.$GLOBALS['conf']['url'].'/admin/index.php'); } } function check_logout() { if (!$this->operator()) { header('Location: '.$GLOBALS['conf']['url'].'/admin/login.php'); exit; } } } ?>