equal
deleted
inserted
replaced
1 <? |
1 <? |
2 |
|
3 // +--------------------------------------------------------------------+ |
|
4 // | PowerAdmin | |
|
5 // +--------------------------------------------------------------------+ |
|
6 // | Copyright (c) 1997-2002 The PowerAdmin Team | |
|
7 // +--------------------------------------------------------------------+ |
|
8 // | This source file is subject to the license carried by the overal | |
|
9 // | program PowerAdmin as found on http://poweradmin.sf.net | |
|
10 // | The PowerAdmin program falls under the QPL License: | |
|
11 // | http://www.trolltech.com/developer/licensing/qpl.html | |
|
12 // +--------------------------------------------------------------------+ |
|
13 // | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl> | |
|
14 // | Sjeemz <sjeemz <AT> sjeemz <DOT> nl> | |
|
15 // +--------------------------------------------------------------------+ |
|
16 |
|
17 // Filename: auth.inc.php |
|
18 // Startdate: 26-10-2002 |
|
19 // Description: file is supposed to validate users and check whether they are authorized. |
|
20 // If they are authorized this code handles that they can access stuff. |
|
21 // |
|
22 // $Id: auth.inc.php,v 1.6 2003/01/13 22:08:52 azurazu Exp $ |
|
23 // |
|
24 |
2 |
25 session_start(); |
3 session_start(); |
26 |
4 |
27 if (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] == "logout") |
5 if (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] == "logout") |
28 { |
6 { |
37 } |
15 } |
38 |
16 |
39 // Check if the session hasnt expired yet. |
17 // Check if the session hasnt expired yet. |
40 if ((isset($_SESSION["userid"])) && ($_SESSION["lastmod"] != "") && ((time() - $_SESSION["lastmod"]) > $EXPIRE)) |
18 if ((isset($_SESSION["userid"])) && ($_SESSION["lastmod"] != "") && ((time() - $_SESSION["lastmod"]) > $EXPIRE)) |
41 { |
19 { |
42 logout( _('Session expired, please login again.') ); |
20 logout( _('Session expired, please login again.'),"error"); |
43 } |
21 } |
44 |
22 |
45 // If the session hasn't expired yet, give our session a fresh new timestamp. |
23 // If the session hasn't expired yet, give our session a fresh new timestamp. |
46 $_SESSION["lastmod"] = time(); |
24 $_SESSION["lastmod"] = time(); |
47 |
25 |
64 } |
42 } |
65 } |
43 } |
66 else |
44 else |
67 { |
45 { |
68 //Authentication failed, retry. |
46 //Authentication failed, retry. |
69 auth( _('Authentication failed!') ); |
47 auth( _('Authentication failed!'),"error"); |
70 } |
48 } |
71 } |
49 } |
72 else |
50 else |
73 { |
51 { |
74 //No username and password set, show auth form (again). |
52 //No username and password set, show auth form (again). |
77 |
55 |
78 /* |
56 /* |
79 * Print the login form. |
57 * Print the login form. |
80 */ |
58 */ |
81 |
59 |
82 function auth($msg="") |
60 function auth($msg="",$type="success") |
83 { |
61 { |
84 include_once('inc/header.inc.php'); |
62 include_once('inc/header.inc.php'); |
85 ?> |
63 if ( $msg ) |
86 <H2><? echo _('PowerAdmin for PowerDNS'); ?></H2><H3><? echo _('Please login'); ?>:</H3> |
|
87 <? |
|
88 if($msg) |
|
89 { |
64 { |
90 print "<font class=\"warning\">$msg</font>\n"; |
65 print "<div class=\"$type\">$msg</div>\n"; |
91 |
|
92 } |
66 } |
93 ?> |
67 ?> |
94 <FORM METHOD="post" ACTION="<?= $_SERVER["PHP_SELF"] ?>"> |
68 <h2><? echo _('Login'); ?></h2> |
95 <TABLE BORDER="0"> |
69 <? |
96 <TR><TD STYLE="background-color: #FCC229;"><? echo _('Login'); ?>:</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="text" CLASS="input" NAME="username"></TD></TR> |
70 ?> |
97 <TR><TD STYLE="background-color: #FCC229;"><? echo _('Password'); ?>:</TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="password" CLASS="input" NAME="password"></TD></TR> |
71 <form method="post" action="<? echo $_SERVER["PHP_SELF"] ?>"> |
98 <TR><TD STYLE="background-color: #FCC229;"> </TD><TD STYLE="background-color: #FCC229;"><INPUT TYPE="submit" NAME="authenticate" CLASS="button" VALUE=" <? echo _('Login'); ?> "></TD></TR> |
72 <table border="0"> |
99 </TABLE> |
73 <tr> |
|
74 <td class="n"><? echo _('Login'); ?>:</td> |
|
75 <td class="n"><input type="text" class="input" name="username"></td> |
|
76 </tr> |
|
77 <tr> |
|
78 <td class="n"><? echo _('Password'); ?>:</td> |
|
79 <td class="n"><input type="password" class="input" name="password"></td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td class="n"> </td> |
|
83 <td class="n"> |
|
84 <input type="submit" name="authenticate" class="button" value=" <? echo _('Login'); ?> "> |
|
85 </td> |
|
86 </tr> |
|
87 </table> |
|
88 </form> |
100 <? |
89 <? |
101 include_once('inc/footer.inc.php'); |
90 include_once('inc/footer.inc.php'); |
102 exit; |
91 exit; |
103 } |
92 } |
104 |
93 |
108 */ |
97 */ |
109 |
98 |
110 function logout($msg="") |
99 function logout($msg="") |
111 { |
100 { |
112 if ( $msg == "" ) { |
101 if ( $msg == "" ) { |
113 $msg=_('You have logged out.'); |
102 $msg = _('You have logged out.'); |
|
103 $type = "success"; |
114 }; |
104 }; |
115 session_destroy(); |
105 session_destroy(); |
116 session_write_close(); |
106 session_write_close(); |
117 auth($msg); |
107 auth($msg, $type); |
118 exit; |
108 exit; |
119 } |
109 } |
120 |
110 |
121 ?> |
111 ?> |