Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function loggedIn() {
- if(isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
- if(verify($_COOKIE['username'], $_COOKIE['password'])) {
- return true;
- } else {
- return false;
- }
- }
- }
- function verify($user, $pass) {
- if($user == "haykuro") {
- if($pass == "mypass") {
- return true;
- } else {
- return false;
- }
- } else if($user == "s0cket") {
- if($pass == "+h25stN%") {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- if(loggedIn()) {
- if(isset($_GET['page'])) {
- $page = htmlentities($_GET['page']);
- if($page == "logout") {
- setcookie("username", "", time() - 3600);
- setcookie("password", "", time() - 3600);
- $output = "Successfully logged out! <a href=\"admin.php\">Please click here to continue!</a><br />";
- } else {
- $output = "Please choose an option from above!";
- }
- } else {
- $output = "Please choose an option from above!";
- }
- $username = htmlentities($_COOKIE['username']);
- echo "Welcome to the admin panel, <strong>{$username}</strong><br />";
- echo "<a href=\"admin.php?page=logout\">Logout</a><br />";
- if(isset($output)) { echo $output; }
- } else {
- if(isset($_POST['dologin']) && isset($_POST['username']) && isset($_POST['password'])) {
- if(verify($_POST['username'], $_POST['password'])) {
- if(setcookie("username", $_POST['username'])) {
- if(setcookie("password", $_POST['password'])) {
- echo "Successfully logged in.<br /><a href=\"admin.php\">Please click here to continue.</a>";
- } else {
- echo "Sorry, failed to login.";
- }
- } else {
- echo "Sorry, failed to login.";
- }
- } else {
- echo "Sorry, invalid credentials provided.";
- }
- } else {
- ?>
- <form action="" method="post">
- Username: <input type="text" name="username" /><br />
- Password: <input type="password" name="password" /><br />
- <input type="submit" value="Login" name="dologin" />
- </form>
- <?php
- }
- }
- ?>
Add Comment
Please, Sign In to add comment