This repository has been archived by the owner on Nov 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
176 lines (134 loc) · 3.67 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
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
<?php
require(dirname(__FILE__).'/includes/common.php');
/*Automatically redirects to home.php if logged in.*/
if(LOGGED_IN == true){
header("Location: home.php");
exit;
}
/*Automatically redirects to install.php, if not installed*/
if (INSTALLED_DB == false){
header("Location: install.php");
exit;
}
loadHeader("Welcome!");
?>
<script type="text/javascript">
$(document).ready(function(){
$('#login').hide();
$('#register').hide();
// kn
// handle login
$('#login-form').submit(function() {
$.jqDialog.notify("Please wait..");
$.post('login.php', { username : $('#login-user').val(), password : $('#login-password').val() }, function(response){
if(response == '1') { // success
document.location.href = 'home.php';
} else {
$.jqDialog.notify("Invalid username or password", 3);
}
});
return false;
});
// handle signup
$('#reg-form').submit(function(){
var reg_user = $('#reg-u').val();
var reg_pass = $('#reg-p').val();
if( reg_user.length >= 4 && reg_pass.length >= 6 ){
$.jqDialog.notify("Please wait..");
$.post('register.php',{ reg_user : $('#reg-u').val(), reg_password : $('#reg-p').val() }, function(response){
if(response == '1'){
document.location.href = 'home.php';
} else {
$.jqDialog.notify(response, 5);
}
});
}
else{
$.jqDialog.notify("Please choose a valid username (minimum 4 chars) and password (minimum 6 chars)", 5);
}
return false;
});
$('#reg-u').keyup(function(){
var reg_user = $(this).val();
if(reg_user.length >= 4){
$.post('register.php', {reg_user: $('#reg-u').val()}, function(response){
$('#availability').html(response);
});
}
else{
$('#availability').html('');
}
});
var clicked=0;
$('#login_box').click(function(){
//$('.home_container');
if( clicked == 0 ){
clicked=1;
$('.home_buttons').fadeOut(200);
$(this).fadeOut(200,
function(){
$('#login').fadeIn(function(){ clicked=0;});
});
}
});
$('#reg_box').click(function(){
//$('.home_container');
if( clicked == 0 ){
clicked=1;
$('.home_buttons').fadeOut(200);
$(this).fadeOut(200,
function(){
$('#register').fadeIn(function(){ clicked=0;});
});
}
});
});
</script>
<div class="home_container">
<h1>Simple To-do List</h1>
<div class="home_buttons">
<div class="home_box" id="login_box">Login</div>
<div class="home_box" id="reg_box">Register</div>
<div class="clear"> </div>
<?php if(TWITTER_KEY && TWITTER_SECRET) { ?>
<p><a href="twitter_login.php"><img src="images/twitter_sign.png" alt="Twitter Sign In"/></a></p>
<?php } ?>
</div>
<div id="login">
<form method="post" action="login.php" id="login-form">
<p>
<label>Username</label>
<input type="text" name="username" id="login-user" />
</p>
<p>
<label>Password</label>
<input type="password" name="password" id="login-password" />
</p>
<p>
<input type="submit" value="Login" class="button" />
</p>
</table>
</form>
</div>
<div id="register">
<form method="post" id="reg-form">
<p>
<label>Choose a Username</label>
<input type="text" name="reg_user" id="reg-u"/> <span id="availability"></span>
</p>
<p>
<label>Choose a Password</label>
<label><input type="password" name="reg_pass" id="reg-p"/></label>
</p>
<p>
<input type="submit" value="Register" class="button" />
</p>
</table>
</form>
</div>
<div class="clear"> </div>
<p class="credit"><a href="">Simple ToDo List</a> By, Kamaleshwar </p>
</div>
<?php
loadFooter();
?>