-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
54 lines (49 loc) · 1.8 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
<?php
ini_set('display_errors',2);
error_reporting(E_ALL);
include_once("config.php");
$count = 0;
if ( $_POST['user'] == " " || $_POST['user'] == NULL ) {
echo "Please enter a valid username <br />";
$count =$count + 1;
}
if ( $_POST['pass'] == " " || $_POST['pass'] == NULL ) {
echo "Please enter a valid password <br />";
$count = $count + 1;
}
if ( $count > 0 ) exit();
$temp = SERVICE_URL.'?section=user&request=activated&username='.$_POST['user'];
$temp1 = file_get_contents($temp,0,null,null);
$userActivated = json_decode($temp1, true);
if (!$userActivated['userActivated']){
echo "Please activate your account before signing in <br />";
exit();
}
//include("interact/curl.php");
// setup CURL cookies when first logging in
$loginAuth = SERVICE_URL.'?section=user&request=auth&username='.$_POST['user'].'&password='.$_POST['pass'];
$temp = file_get_contents($loginAuth, 0,null,null);//bv_download($loginAuth);
$loginAuthOutput = json_decode($temp, true);
if ( !($loginAuthOutput['authenticationSuccess']) ){
// echo $loginAuthOutput['authenticationSuccess'];
echo "Username or password is invalid, Please try again <br />";
exit();
}
else {
session_start();
$_SESSION['uid'] = session_id();
$_SESSION['username'] = $_POST['user'];
$_SESSION['token'] = $loginAuthOutput['token'];
$_SESSION['logged'] = true;
// this next line is for debugging only and should be removed
$_SESSION['size'] = $loginAuthOutput['size'];
// grab the user's type
$userRequest = SERVICE_URL.'?section=user&request=getlevel&username='.$_SESSION['username'];
$userJSON = file_get_contents($userRequest,0,null,null);//download($userRequest);
$userOutput = json_decode($userJSON, true);
$_SESSION['userType'] = $userOutput['userType'];
if (isset($_POST['rememberMe'])){
setcookie("token",$_SESSION['token'],time() + 3600 );
}
}
?>