-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
100 lines (84 loc) · 2.93 KB
/
login.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
require_once( "include/page_elements.php" );
/* Short and sweet */
define('WP_USE_THEMES', false);
require_once('wp-backend/wp-blog-header.php');
http_response_code(200); // override wp
// Form submitted
$referrer = $_SERVER[ 'HTTP_REFERER' ];
if(isset($_REQUEST['r'])) {
$referrer = $_REQUEST['r'];
}
if ( isset( $_GET['logout'] ) ) {
wp_logout();
header( "Location: $referrer" );
exit();
}
if ( isset( $_POST[ 'login' ] ) ) {
$username = $_POST[ 'username' ];
$parm = array(
'user_login' => $username,
'user_password' => $_POST[ 'password' ],
);
if ( $_POST[ 'rememberme' ] == 'on' ) $parm[ 'remember' ] = true;
$res = wp_signon( $parm, false );
if ( is_wp_error( $res ) )
{
$message = "ERROR: The password you entered for the username '$username' is incorrect.";
}
else
{
$dest = $_POST[ 'redirect_to' ];
if ( empty( $dest ) || preg_match( '/login/', $dest ) ) $dest = '/';
header( "Location: $dest" );
exit();
}
}
?>
<!DOCTYPE html>
<html>
<?php page_head( "Login" ); ?>
<body>
<div id="header-ghost" ></div>
<div class="container no-side-padding">
<div class="col-xs-12 no-side-padding">
<?php
output_header();
output_navbar();
?>
<div class="page-body">
<div class="row side-margins bottom-margin"> </div>
<div class="row side-margins bottom-margin">
<div class="col-sm-4 col-sm-offset-4 col-xs-10 col-xs-offset-1">
<?php
if ( ! empty( $message ) )
{
echo '<div class="alert alert-danger"><strong>' . $message . '</strong></div>' . "\n";
}
?>
<form role="form" action="/login.php" method="post">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" class="form-control" name="username" id="username" value="" />
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" name="password" id="password" class="form-control" value="" />
</div>
<div class="checkbox">
<label><input name="rememberme" type="checkbox" id="rememberme" value="on" />Remember me</label>
</div>
<input type="submit" name="login" id="login" class="btn btn-default" value="Log In" />
<input type="hidden" name="redirect_to" value="<?php echo $referrer; ?>" />
</form>
<br/>
Team members (students, parents and mentors) may register <a href="/register.php">here.</a>
</div>
</div>
<?php output_footer(); ?>
</div>
</div>
</div>
<?php page_foot(); ?>
</body>
</html>