-
Notifications
You must be signed in to change notification settings - Fork 0
/
login_callback_rpst.php
97 lines (94 loc) · 3.39 KB
/
login_callback_rpst.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
<?php
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<link rel="stylesheet" href="assets/sweetalert/sweetalert2.min.css">
<script src="assets/sweetalert/sweetalert2.min.js"></script>
<script src="assets/sweetalert/sweetalert.script.min.js"></script>
<style>
*:focus {
outline: none;
}
</style>
<?php
require_once("LoginLib_new.php");
$line = new LineLogin();
$get = $_GET;
$code = $get['code'];
$state = $get['state'];
$token = $line->token($code, $state);
if (property_exists($token, 'error')) {
header('location: index.php');
}
if ($token->id_token) {
$profile = $line->profileFormIdToken($token);
$_SESSION['profile'] = $profile;
$result_profile_line = $line->profile($profile->access_token);
$email = $profile->email;
$line_id = $result_profile_line->userId;
include "connectDB.php";
$sql = "select * from member where email='$email' or id_line='$line_id'";
$result = $mysqli->query($sql);
$row = mysqli_fetch_array($result);
if ($row['email'] != "") {
$level = $row['level'];
switch($level) {
case "pcu":
$_SESSION['level_pcu'] = $level;
$_SESSION['pcu'] = $row['hospcode'];
$_SESSION['email'] = $row['email'];
$_SESSION['id_line'] = $row['id_line'];
$_SESSION['statusUser'] = $statusUser=="a";
$_SESSION['levelx'] = $level;
$_SESSION['pcu'] = $row['hospcode'];
header("Location: alert.php");
break;
case "pmj":
$_SESSION['level_pmj'] = $level;
$_SESSION['levelx'] = $level;
$_SESSION['statusUser'] = $statusUser=="a";
$_SESSION['email'] = $row['email'];
$_SESSION['id_line'] = $row['id_line'];
Header("Location: alert.php");
break;
case "opt":
$_SESSION['level_opt'] = $level;
$_SESSION['levelx'] = $level;
$_SESSION['level'] = $row['opt'];
$_SESSION['statusUser'] = $statusUser=="a";
$_SESSION['email'] = $row['email'];
$_SESSION['id_line'] = $row['id_line'];
Header("Location: alert.php");
break;
case "etc":
$_SESSION['level_etc'] = $level;
$_SESSION['levelx'] = $level;
$_SESSION['level'] = $row['etc'];
$_SESSION['email'] = $row['email'];
$_SESSION['id_line'] = $row['id_line'];
$_SESSION['provinces']=$row['provinces'];
Header("Location: alert.php");
break;
// default:
// echo "<script>alert('สถานะของคุณไม่ถูกต้อง');</script>";
// Header ("Location: page-login.php");
// break;
}
echo '<script>
setTimeout(function() {
swal({
title: "User ID ของท่านได้ลงทะเบียนแล้ว",
text: "",
type: "success"
}, function() {
window.close();
});
}, 1000);
</script>';
} else {
header('location: register_rpst_form.php');
}
}
?>