-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.php
46 lines (40 loc) · 1.5 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
$section = 'xyzzy'; // This is the magic word that allows a non-logged-in user to see this content.
require_once( 'session.php' );
require_once( 'user.php' );
$util::logDebug( 'index.php 0' );
if( is_null( $user ) ) $user = new USER();
$util::logDebug( 'index.php 1' );
if( $user->isLoggedIn() ){
$util::logDebug( 'index.php 2' );
// Do NOT let already logged in user stay here
header( 'Location: dashboard' );
// exit();
exit( '<meta http-equiv="refresh" content="0;url=dashboard" />' );
}
$util::logDebug( 'index.php 3' );
// Standard page top owns the form whose action sends user to this code.
if( isset( $_POST[ 'btn-login' ] ) ){
$util::logDebug( 'index.php 4' );
$uname = strip_tags( $_POST[ 'txt_uname' ] );
$upass = strip_tags( $_POST[ 'txt_password' ] );
$expiration_date = date( 'Y-m-d H:i:s', strtotime( '+' . MAX_SESSION_LENGTH . ' day' ) );
if( $user->doLogin( $uname, $upass, $expiration_date ) ){
$util::logDebug( 'index.php 5' );
$util::logDebug( "index.php: user $uname succesfully logged in. Cookie set to expire in " . $util::secondsToTime( ini_get( 'session.cookie_lifetime' ) ) );
header( 'Location: dashboard' );
// exit();
exit( '<meta http-equiv="refresh" content="0;url=dashboard" />' );
}
else{
$util::logDebug( 'index.php 6' );
$error = 'Wrong Details!';
}
}
$util::logDebug( 'index.php 7' );
require_once( 'standard_page_top.php' );
?>
If you were logged in, you'd see some really cool stuff right here.
<?php
require_once( 'standard_page_foot.php' );
?>