Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // The master password.
- $password = "pass";
- // Used to get the filename
- $u = explode('/', $_SERVER["SCRIPT_NAME"]);
- $script = $u[count($u) - 1];
- // Used to tell if the user is logged in and whether or not they wish to logout.
- session_start();
- if(isset($_POST["password"]) && ($_POST["password"] == $password)) $_SESSION["authed"] = true;
- if(isset($_GET["action"]) && ($_GET["action"] == "logout")) { $_SESSION["authed"] = false; header("Location: " . $script); }
- if(!$_SESSION["authed"]):
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Login</title>
- <style type="text/css">
- *{margin:0;padding:0}html,body{height:100%;background-color:#eaeaea;font-family:Tahoma,Geneva,sans-serif;color:#333}input{border:1px solid #aaa;border-radius:4px;padding:4px;color:#aaa;width:192px}input:hover{border:1px solid #777;color:#333}input:focus{color:#333;outline:0;border:1px solid #5096e1;-webkit-box-shadow:0 0 4px rgba(80,150,225,0.5);-moz-box-shadow:0 0 4px rgba(80,150,225,0.5);box-shadow:0 0 4px rgba(80,150,225,0.5)}input[type="submit"]{width:200px;background-color:#fff}input[type="submit"]:active{-webkit-box-shadow:0 0 6px rgba(50,50,50,0.35);-moz-box-shadow:0 0 6px rgba(50,50,50,0.35);box-shadow:0 0 6px rgba(50,50,50,0.35)}.wrapper{height:100%;display:table;margin:0 auto;vertical-align:middle}.contentwrapper{display:table-cell;vertical-align:middle}.content{position:relative;border:1px solid #aaa;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;background-color:#fff;padding:20px;margin-top:14px;-webkit-box-shadow:0 0 20px rgba(50,50,50,0.35);-moz-box-shadow:0 0 20px rgba(50,50,50,0.35);box-shadow:0 0 20px rgba(50,50,50,0.35)}.header{position:absolute;width:96px;height:20px;top:-15px;left:50%;padding:4px;margin-left:-51px;text-align:center;background-color:#fff;border:1px solid #aaa;-webkit-border-radius:32px;-moz-border-radius:32px;border-radius:32px -webkit-box-shadow:0 0 2px rgba(50,50,50,0.35);-moz-box-shadow:0 0 2px rgba(50,50,50,0.35);box-shadow:0 0 2px rgba(50,50,50,0.35)}.section{margin-top:8px;text-align:center}.error,.success{margin-top:0;color:red;font-size:13px;max-width:200px}.success{color:green}
- </style>
- <!--[if lt IE 9]>
- <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- </head>
- <body onload="document.getElementById('password').focus()">
- <div class="wrapper">
- <div class="contentwrapper">
- <div class="content">
- <div class="header">Login</div>
- <form action="<?=$script?>" method="post">
- <div class="section"><input type="password" name="password" id="password" placeholder="Password"></div>
- <div class="section"><input type="submit" value="Login"></div>
- </form>
- </div>
- </div>
- </div>
- </body>
- </html>
- <?php else: ?>
- <!-- Your hidden content -->
- <!DOCTYPE html>
- <html>
- <head>
- <title>Title</title>
- </head>
- <body>
- <p>Content!</p>
- <!-- If you want to let the user logout, simply direct them to '?action=logout' with $script like so: -->
- <a href="<?=$script?>?action=logout"><input type="button" value="Logout"></a>
- </body>
- </html>
- <!-- End of your hidden content -->
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment