root/branches/dsss-smi/menu.php

Revision 103, 2.7 kB (checked in by Gregor, 2 years ago)

DSSS SMI Initial import.

Line 
1 <?PHP
2 /*
3  *  Copyright (c) 2006  Gregor Richards
4  * 
5  *  Permission is hereby granted, free of charge, to any person obtaining a
6  *  copy of this software and associated documentation files (the "Software"),
7  *  to deal in the Software without restriction, including without limitation
8  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  *  and/or sell copies of the Software, and to permit persons to whom the
10  *  Software is furnished to do so, subject to the following conditions:
11  * 
12  *  The above copyright notice and this permission notice shall be included in
13  *  all copies or substantial portions of the Software.
14  * 
15  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  *  DEALINGS IN THE SOFTWARE.
22  */
23
24 require("chkpw.php");
25 require("config.php");
26
27 $valid = false;
28 $un = "";
29
30 // check for valid login
31 if (isset($_POST['un']) &&
32     isset($_POST['pw'])) {
33     if (chkpw($_POST['un'], $_POST['pw'])) {
34         $valid = true;
35         $un = $_POST['un'];
36        
37         // generate a hashed login
38         $keyhash = genkeyhash($_POST['un'], $_POST['pw']);
39         setcookie("DSSS_SMI_UN", $_POST['un']);
40         setcookie("DSSS_SMI_KEY", $keyhash[0]);
41         setcookie("DSSS_SMI_HASH", $keyhash[1]);
42     }
43 } else if (isset($_COOKIE['DSSS_SMI_UN']) &&
44            isset($_COOKIE['DSSS_SMI_KEY']) &&
45            isset($_COOKIE['DSSS_SMI_HASH'])) {
46     if (chkkeyhash($_COOKIE['DSSS_SMI_UN'],
47                    $_COOKIE['DSSS_SMI_KEY'],
48                    $_COOKIE['DSSS_SMI_HASH'])) {
49         $un = $_COOKIE['DSSS_SMI_UN'];
50         $valid = true;
51     }
52 }
53
54 if (!$valid) {
55     if (isset($_POST['pw'])) {
56         ?>
57 Incorrect username or password.
58 <?PHP
59         exit();
60     } else {
61         ?>
62 Invalid session. Perhaps your session has expired.
63 <?PHP
64         exit();
65     }
66 }
67
68 // OK, valid login, display the options
69 ?>
70 <HTML><head><title>DSSS Source Management Interface - Menu</title></head><body>
71 <h2>Edit:</h2>
72 <form action='edit.php' method='post'>
73 <?PHP
74 // display edit options for each editable package
75
76 if (isset($privileges[$un])) {
77     foreach ($privileges[$un] as $pkg) {
78         // show a submit button
79         print "<input type='submit' name='pkg' value='" . $pkg . "'><br>\n";
80     }
81 }
82 ?>
83 </form>
84 <hr>
85 <a href="changepw.php">Change your password</a>
86 </body></HTML>
Note: See TracBrowser for help on using the browser.