forked from flatpressblog/flatpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
executable file
·130 lines (83 loc) · 2.41 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
// Example of use
require_once 'defaults.php';
require_once (INCLUDES_DIR.'includes.php');
require(SMARTY_DIR . 'SmartyValidate.class.php');
$tpl = 'default.tpl';
function login_validate() {
global $smarty, $lang;
$user = trim(@$_POST['user']);
$pass = trim(@$_POST['pass']);
$error = array();
$lerr =& $lang['login']['error'];
if (!$user) {
$error['user'] = $lerr['user'];
}
if (!$pass) {
$error['pass'] = $lerr['pass'];
}
if (!$error && !user_login($user, $pass)) {
$error['match'] = $lerr['match'];
}
if ($error) {
$smarty->assign('error', $error);
return 0;
}
return 1;
}
function main() {
global $lang, $smarty;
if (user_loggedin()) {
if(isset($_GET['do']) && ($_GET['do']=='logout')) {
user_logout();
function myredirect() {
login_redirect('index.php');
}
add_filter('wp_head', 'myredirect');
$content = (SHARED_TPLS . 'login_success.tpl');
} elseif (user_loggedin()) {
function myredirect() {
login_redirect('index.php');
}
add_filter('wp_head', 'myredirect');
$content = (SHARED_TPLS . 'login_success.tpl');
} else {
utils_redirect();
}
} elseif (sess_remove('logout_done')) {
function myredirect() {
login_redirect('index.php');
}
add_filter('wp_head', 'myredirect');
$content = (SHARED_TPLS . 'login_success.tpl');
} elseif(empty($_POST)) {
$content = (SHARED_TPLS . 'login.tpl');
} else {
// validate after a POST
if(login_validate()) {
utils_redirect('login.php');
} else {
$smarty->assign($_POST);
$content = (SHARED_TPLS . 'login.tpl');
}
}
// Set page title and content
// first parameter is Title, second is content.
// Content can be both a shared tpl or raw html content; in this last case
// you have to set the third optional parameter to true
$smarty->assign('subject', $lang['login']['head']);
$smarty->assign('content', $content);
}
function login_redirect($url, $secs=5){
echo '<meta http-equiv="refresh" content="'."$secs;url=$url".'" />';
}
function login_title($title, $sep) {
global $lang;
return $title = "$title $sep {$lang['login']['head']}";
}
add_filter('wp_title', 'login_title', 10, 2);
system_init();
main();
theme_init($smarty);
$smarty->display('default.tpl');
?>