-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch.txt
210 lines (127 loc) · 6.66 KB
/
switch.txt
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
// This file could be used instead of index.php to perform authentication.
// The list of usernames/passwords are hard coded below. (search for 'sarah')
require("config.php");
/**
*
* Login page, self posts to become management page
*
* @author Patrick Lockley
* @version 1.0
* @copyright Copyright (c) 2008,2009 University of Nottingham
* @package
*/
include $xerte_toolkits_site->php_library_path . "login_library.php";
include $xerte_toolkits_site->php_library_path . "display_library.php";
/**
* Check to see if anything has been posted to distinguish between log in attempts
*/
if((!isset($_POST["login"]))&&(!isset($_POST["password"]))){
$buffer = login_page_format_top(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_top"));
$buffer .= $form_string;
$buffer .= login_page_format_bottom(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_bottom"));
echo $buffer;
}
/*
* Some data has bee posted, interpret as attempt to login
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
/**
* Username and password left empty
*/
if(($_POST["login"]=="")&&($_POST["password"]=="")){
$buffer = login_page_format_top(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_top"));
$buffer .= "<p>Please enter your username and password</p>";
$buffer .= login_page_format_bottom(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_bottom"));
echo $buffer;
/*
* Username left empty
*/
}else if($_POST["login"]==""){
$buffer = login_page_format_top(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_top"));
$buffer .= "<p>Please enter your username</p>";
$buffer .= login_page_format_bottom(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_bottom"));
echo $buffer;
/*
* Password left empty
*/
}else if($_POST["password"]==""){
$buffer = login_page_format_top(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_top"));
$buffer .= "<p>Please enter your password</p>";
$buffer .= login_page_format_bottom(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_bottom"));
echo $buffer;
/*
* Password and username provided, so try to authenticate
*/
}else if(($_POST["login"]!="")&&($_POST["password"]!="")){
/*
* See if the submitted values are valid logins
*/
$authenticated = false;
function set_user_details($firstname, $surname){
$_SESSION['toolkits_firstname'] = $firstname;
$_SESSION['toolkits_surname'] = $surname;
}
switch($_POST["login"]){
case "pat": if($_POST["password"]=="patpassword"){ $authenticated = true; set_user_details("Pat","Blair");}; break;
case "john": if($_POST["password"]=="johnpassword"){ $authenticated = true; set_user_details("John","Obama"); }; break;
case "bob": if($_POST["password"]=="bobpassword"){ $authenticated = true; set_user_details("Bob","Putin"); }; break;
case "sarah": if($_POST["password"]=="sarahpassword"){ $authenticated = true; set_user_details("Sarah","Sarkozy"); }; break;
default: $authenticated = false; break;
}
if($authenticated){
/*
* Give the session its own session id
*/
$_SESSION['toolkits_sessionid'] = $session_id;
include $xerte_toolkits_site->php_library_path . "database_library.php";
include $xerte_toolkits_site->php_library_path . "user_library.php";
$mysql_id=database_connect("index.php database connect success","index.php database connect fail");
$_SESSION['toolkits_logon_username'] = $_POST["login"];
/*
* Check to see if this is a users' first time on the site
*/
if(check_if_first_time($_SESSION['toolkits_logon_username'])){
/*
* create the user a new id
*/
$_SESSION['toolkits_logon_id'] = create_user_id($_SESSION['toolkits_logon_username'], $_SESSION['toolkits_firstname'], $_SESSION['toolkits_surname']);
/*
* create a virtual root folder for this user
*/
create_a_virtual_root_folder();
}else{
/*
* User exists so update the user settings
*/
$_SESSION['toolkits_logon_id'] = get_user_id();
update_user_logon_time();
}
recycle_bin();
/*
* Output the main page, including the user's and blank templates
*/
echo file_get_contents($xerte_toolkits_site->website_code_path . "management_headers");
echo "<script type=\"text/javascript\"> // JAVASCRIPT library for fixed variables\n // management of javascript is set up here\n // SITE SETTINGS\n";
echo "var site_url = \"" . $xerte_toolkits_site->site_url . "\";\n";
echo "var site_apache = \"" . $xerte_toolkits_site->apache . "\";\n";
echo "var properties_ajax_php_path = \"website_code/php/properties/\";\n var management_ajax_php_path = \"website_code/php/management/\";\n var ajax_php_path = \"website_code/php/\";\n";
echo file_get_contents($xerte_toolkits_site->website_code_path . "management_top");
list_users_projects("data_down");
echo logged_in_page_format_middle(file_get_contents($xerte_toolkits_site->website_code_path . "management_middle"));
list_blank_templates();
echo file_get_contents($xerte_toolkits_site->website_code_path . "management_bottom");
}else{
/*
* login has failed
*/
$buffer = login_page_format_top(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_top"));
$buffer .= "<p>Sorry that password combination was not correct</p>";
$buffer .= login_page_format_bottom(file_get_contents($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->website_code_path . "login_bottom"));
echo $buffer;
}
}
}
?>
</body>
</html>