forked from Celesta-IITP/celesta18-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch.php
209 lines (192 loc) · 7.68 KB
/
switch.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
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
<?php
session_start();
if(isset($_GET['act'])){
if($_GET['act']=='logout'){
$_SESSION['uid']=null;
$_SESSION['name']=null;
session_destroy();
header( "refresh:0; url=http://celesta.org.in" );
}
}
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Celesta2k18 Login</title>
<style>
a:visited
{
color:#fff ;
}
#logout{
/*display: none;*/
}
body{
color:#FFFFFF;
background: #000000 url("images/bg_login.png") no-repeat center fixed;
background-size: 100% auto;
}
// ------------------ Media Queries ---------------------------------
// ------------------------------------------------------------------
</style>
<link rel='stylesheet prefetch' href='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="style.css">
<script type="text/javascript">
function goHome(){
window.location="http://celesta.org.in";
}
$(document).ready(function () {
<?php
/* if(isset($_SESSION['uid'])){
//echo"$('.login_title').html('Logged In as ".$_SESSION['name']."-".$_SESSION['uid'].".<br><a style=\'color:#FFFFFF\' href=\'login.php?act=logout\' id=\'logout\'>Logout here</a>'); $('#logout').fadeIn();";
}*/
?>
function check(value, pattern){
if(value.match(pattern)){
return true;
} else {
return false;
}
}
function validate(id,pass){
$("#errorBanner").fadeOut();
var idRegex = '^[Cc][Ll][Ss][Tt]([0-9]{4})$';
bid = check(id,idRegex);
if(!bid){
$("#errorBanner").fadeIn();
$("#errorBanner").text("Invalid ID");
return false;
}
return true;
}
$("#submit").click(function(e) {
$("#loader_gif").fadeIn();
// validate and process form here
console.log("clicked");
e.preventDefault();
var id = $("#email").val().trim();
var pass = $("#pass").val().trim();
if (validate( id,pass)) {
$.post("//<?php echo $_SERVER['HTTP_HOST']; ?>/apiLe/switchtoCA",
{
username: id,
password: pass
},
function(data, status){
console.log("Response");
console.log("Data: " + data + "\nStatus: " + status);
if(status=='success'){//$("#myloader").fadeOut();
$("#loader_gif").fadeOut();
console.log(data);
if(data["status"]=="200"){
$('.success').show();
$(".success").fadeIn();
$(".success").html('<h2>Switching Account Successful</h2><p>Welcome back,<b>CA Registration Successfully completed</b><br>Your Campus Ambassador referral ID is "'+data['ID']+'". You can ask people to register using this four digit code as the CA referral code when they register for Celesta.<br>Redirecting...</p>')
setTimeout(function(){goHome();},1000);
// $("#greet").css('background','#5FAB22');
$(".login_fields").fadeOut();
}else if(data["status"]=="403"){
$("#errorBanner").fadeIn();
$("#errorBanner").html('<center><b>Invalid Credentials<br>');
}else{
console.log("err");
$("#loader_gif").fadeOut();
$("#errorBanner").fadeIn();
$("#errorBanner").html('<center><b>Error occured<br>'+data["message"]+'</center>');
}
// $('html, body').animate({
// scrollTop: $("#header").offset().top
// }, 500);
}else{//$("#myloader").fadeOut();
$("#errorBanner").fadeIn();
$("#loader_gif").fadeOut();
$("#errorBanner").fadeIn();
$("#errorBanner").html('An error occured.<br> Please try again.');
console.log("Failed "+data);
}
},"json");
}else{
$("#loader_gif").fadeOut();
}
});
});
</script>
</head>
<body>
<div class="cross" style="z-index: 50; position: absolute;top: 10px; right: 0px;margin-right: 10px;text-decoration: none;" >
<a class="cross_me" href="//celesta.org.in" >
<i class="fa fa-window-close fa-4x" aria-hidden="false"></i>
</a>
</div>
<div class='login'>
<div style="text-align: center;" class='login_title'>
<span><h2 style="margin-bottom: -1px;">Switch Your regular account to CA(Campus Ambassador)</h2></span>
</div>
<br>
<div class='login_fields'>
<div class='login_fields__user'>
<span style="color: #FFFFFF; width:100%; text-align: center; transform: translateX(-50%); left: 10%; position: relative;">Celesta Id:</span><br>
<!-- <div class='icon'>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/user_icon_copy.png'>
</div>Email
--><input style="margin-top: 2px;" autocomplete="off" placeholder='ID: CLST1234' id="email" type='text'>
<div class='validation'>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/tick.png'>
</div>
</input>
</div>
<div class='login_fields__password'>
<span style="color: #FFFFFF;width:100%;text-align: center;transform: translateX(-50%);left: 10%;position: relative;">Password:</span>
<input style="margin-top: 2px;" autocomplete="off" id="pass" placeholder='Password' type='password'>
<div class='validation'>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/tick.png'>
</div>
</div>
<div class='login_fields__submit'>
<div id="errorBanner" style="color: #FF0000">
</div>
<input id="submit" type='submit' value='Switch'><img id="loader_gif" style="display: none;" src="http://<?php echo $_SERVER['HTTP_HOST']; ?>/Gallery/loading.gif" alt="" height="60">
<div class='forgot'>
<a href='reset.php' style="font-size: 1.4em; color: white;">Forgot Password?</a>
</div>
<div class="create_accnt" style="padding-top: 10px; color: pink;">
Dont have an account? <a style="color: white;" href="register.php">Create Account</a>
</div>
</div>
</div>
<div class='success'>
</div>
<div class='authent'>
<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/217233/puff.svg'>
<p>Switching...</p>
</div>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js'></script>
<script>
$("#email").focus(function(){
$("#email").css("color","white");
$("#email").css("transition-property","background");
$("#email").css("transition","0.6s");
$("#email").css("background","black");
});
$("#email").focusout(function(){
$("#email").css("color","#a9a9a9");
$("#email").css("background","#32364a url('input.jpg') no-repeat center fixed");
});
$("#pass").focus(function(){
$("#pass").css("color","white");
$("#pass").css("transition-property","background");
$("#pass").css("transition","0.6s");
$("#pass").css("background","black");
});
$("#pass").focusout(function(){
$("#pass").css("color","#a9a9a9");
$("#pass").css("background","#32364a url('input.jpg') no-repeat center fixed");
});
</script>
</div>
</body>
</html>