dev.stuconnolly.com / svn / serve

  1. <?php
  2.  
  3. /*
  4.  *  $Id: serve-login.php 16 2008-09-04 21:45:49Z stuart $
  5.  *  
  6.  *  Serve
  7.  *  http://stuconnolly.com/projects/serve/
  8.  *
  9.  *  Copyright (c) 2008 Stuart Connolly. All rights reserved.
  10.  *
  11.  *  This program is free software: you can redistribute it and/or modify
  12.  *  it under the terms of the GNU General Public License as published by
  13.  *  the Free Software Foundation, either version 3 of the License, or
  14.  *  (at your option) any later version.
  15.  *
  16.  *  This program is distributed in the hope that it will be useful,
  17.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  *  GNU General Public License for more details.
  20.  *
  21.  *  You should have received a copy of the GNU General Public License
  22.  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  23.  */
  24.  
  25. require_once('serve-includes/serve-db.php');
  26. require_once('serve-admin/login-functions.php');
  27. require_once('serve-includes/page-template.php');
  28.  
  29. $url = siteinfo('url');
  30.  
  31. if (isset($_GET['action']))
  32. {
  33.     switch ($_GET['action'])
  34.     {
  35.         case 'login':
  36.             login($_POST['username'], $_POST['password']);
  37.             break;
  38.         case 'accessdenied':
  39.             $show_message = 1;
  40.             break;
  41.         case 'logout':
  42.             logout();
  43.             break;
  44.         case 'retrievepassword':
  45.             retrieve_password_email($servedb->get_var("SELECT ID FROM serve_users WHERE user_name = '" . $_POST['username'] . "'"));
  46.             break;
  47.     }
  48. }
  49.  
  50. check_session();
  51.  
  52. header('Content-Type: text/html; charset=UTF-8');
  53. echo('<?xml version="1.0" encoding="UTF-8" ?>'); ?>
  54.  
  55. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  56. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en:GB">
  57.  
  58. <head>
  59.     <meta name="developer" content="Stuart Connolly" />
  60.     <meta name="generator" content="Serve <?php echo siteinfo('version'); ?>" />
  61.    
  62.     <title><?php if (isset($_GET['lostpassword'])) echo 'Lost Password'; else echo 'Serve Login'; ?></title>
  63.    
  64.     <style type="text/css" media="screen">
  65.     <!--
  66.    
  67.     * {
  68.         margin: 0;
  69.         padding: 0;
  70.     }
  71.  
  72.     body {
  73.         background-color: #EEEEEE;
  74.         color: #666666;
  75.         text-align: center;
  76.     }
  77.  
  78.     #bodycontainer {
  79.         text-align: center;
  80.         font-family: Verdana, Arial, Helvetica, sans-serif;
  81.         line-height: 1.6em;
  82.         font-size: 11px;
  83.         padding-top: 20px;
  84.         width: 425px;
  85.         margin: 0 auto;
  86.         background-color: #EEEEEE;
  87.     }
  88.    
  89.     a {
  90.         outline: none;
  91.     }
  92.  
  93.     a:link {
  94.         color: #40659B;
  95.         text-decoration: none;
  96.         border-bottom: 1px dotted #bbb;
  97.     }
  98.    
  99.     a:visited {
  100.         color: #8EA4C2;
  101.         text-decoration: none;
  102.         border-bottom: 1px dotted #bbb;
  103.     }
  104.    
  105.     a:hover, a:active {
  106.         color: #036;
  107.         border-bottom-style: solid;
  108.     }
  109.    
  110.     #container {
  111.         margin: 15px;
  112.         padding: 5%;
  113.         border: 1px solid #D4D4D4;
  114.         background-color: #FFFFFF;
  115.     }
  116.    
  117.     #logincontainer {
  118.         text-align: center;
  119.         padding: 8px 0 8px 0;
  120.         margin: 5px;
  121.         border: 1px solid #ECECEC;
  122.     }
  123.    
  124.     #login #username, #login #password {
  125.         width: 150px;
  126.         color: #999999;
  127.         font-size: 12px;
  128.         border: 1px solid #CFCFCF;
  129.         font-family: Verdana, Sans-serif;
  130.     }
  131.    
  132.     #login #username:focus, #login #password:focus {
  133.         color: #666666;
  134.         border: 1px solid #BABABA;
  135.     }
  136.    
  137.     #login #username {
  138.         margin-left: 10px;
  139.     }
  140.    
  141.     #login #password {
  142.         margin-left: 13px;
  143.     }
  144.    
  145.     #login label {
  146.         text-transform: lowercase;
  147.         cursor: pointer;
  148.     }
  149.    
  150.     #login label span {
  151.         font-weight: bold;
  152.         font-style: italic;
  153.     }
  154.    
  155.     #denied {
  156.         text-align: center;
  157.         font-size: 10px;
  158.     }
  159.    
  160.     #login #submit {
  161.         text-align: right;
  162.     }
  163.    
  164.     #login #logmein {
  165.         width: 80px;
  166.         color: #666666;
  167.         font-size: 11px;
  168.         margin: 5px 5px 0 63px;
  169.         font-family: Verdana, Sans-serif;
  170.     }
  171.    
  172.     #login #retrievepassword {
  173.         width: 130px;
  174.         margin: 5px 5px 0 100px;
  175.     }
  176.    
  177.     #login #rememberme {
  178.         margin: 0 5px 0 18px;
  179.     }
  180.    
  181.     #login #links {
  182.         margin: 0 0 0 5px;
  183.     }
  184.    
  185.     p {
  186.         margin: 1em 0;
  187.     }
  188.    
  189.     -->
  190.     </style>
  191. </head>
  192.  
  193. <body>
  194.     <div id="bodycontainer">
  195.         <div id="container">
  196.         <?php if (isset($_GET['lostpassword'])) : ?>
  197.             <form method="post" action="<?php echo $url; ?>serve-login.php?action=retrievepassword" id="login">
  198.                 <p>Please enter your username and a new password will be emailed to you.</p>
  199.                
  200.                 <div id="logincontainer">
  201.                     <p><label for="username">User<span>name</span></label><input type="text" id="username" name="username" /></p>
  202.                 </div>
  203.                    
  204.                 <p><span id="links"><a href="<?php echo $url; ?>">&#8592; View site</a> | <a href="<?php echo $url; ?>serve-login.php">Login</a></span><input type="submit" name="retrievepassword" id="retrievepassword" value="Retrieve Password" /></p>
  205.             </form>
  206.         <?php else :
  207.             if ($show_message) : ?><p><strong>Access denied:</strong> Incorrect login details.</p><?php endif; ?>
  208.            
  209.             <form method="post" action="<?php echo $url; ?>serve-login.php?action=login" id="login">
  210.                 <div id="logincontainer">
  211.                     <p><label for="username">User<span>name</span></label><input type="text" id="username" name="username" /></p>
  212.                            
  213.                     <p><label for="password"><span>Pass</span>word</label><input type="password" id="password" name="password" /></p>
  214.                
  215.                     <p><input type="checkbox" name="rememberme" id="rememberme" /><label for="rememberme">Remember me</label></p>
  216.                 </div>
  217.                    
  218.                 <p><span id="links"><a href="<?php echo $url; ?>">&#8592; View site</a> | <a href="<?php echo $url; ?>serve-login.php?lostpassword=true">Lost your password?</a></span><input type="submit" name="logmein" id="logmein" value="Login" /></p>
  219.             </form>
  220.         <?php endif; ?>
  221.         </div>
  222.     </div>
  223. </body>
  224. </html>