-
Notifications
You must be signed in to change notification settings - Fork 1
/
auth.php
182 lines (157 loc) · 4.3 KB
/
auth.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
<?php
include('app/app.php');
include('rest/EBSCOAPI.php');
$query = isset($_REQUEST['query'])?$_REQUEST['query']:'';
$fieldCode = isset($_REQUEST['fieldcode'])?$_REQUEST['fieldcode']:'';
$db = isset($_REQUEST['db'])?$_REQUEST['db']:'';
$an = isset($_REQUEST['an'])?$_REQUEST['an']:'';
$highlight = isset($_REQUEST['highlight'])?$_REQUEST['highlight']:'';
$resultId = isset($_REQUEST['resultId'])?$_REQUEST['resultId']:'';
$recordCount = isset($_REQUEST['recordCount'])?$_REQUEST['recordCount']:'';
$userid = $_REQUEST['userId'];
$password = $_REQUEST['password'];
$flag = FALSE; // set flag to identify the login status
$profile = "";
$UserId = '';
$xml ="Config.xml";
$dom=simplexml_load_file($xml);
foreach($dom->ClientCredentials->User as $user){
$UserId = (string)$user ->UserId;
$Password = (string)$user->Password;
if($userid == $UserId && $password == $Password){
$flag = $UserId;
break;
}
}
// Log in fail will redrect user to login page with the fail parameter as y
// all the functions below are used to track the page which the user visited
// and after successfully login will return the that page with loged in status
if($flag==FALSE){
$path = $_REQUEST['path'];
if($path=="record"){
$params = array(
'path'=>'record',
'db'=>$db,
'an'=>$an,
'highlight'=>$highlight,
'query'=>$query,
'fieldcode'=>$fieldCode,
'resultId'=>$resultId,
'recordCount'=>$recordCount,
'fail'=>'y'
);
$params = http_build_query($params);
header("location: login.php?$params");
}
else
if($path=="PDF"){
$params = array(
'path'=>'PDF',
'db'=>$db,
'an'=>$an,
'fail'=>'y'
);
$params = http_build_query($params);
header("location: login.php?$params");
}
else
if($path=="HTML"){
$params = array(
'path'=>'HTML',
'db'=>$db,
'an'=>$an,
'highlight'=>$highlight,
'query'=>$query,
'fieldcode'=>$fieldCode,
'resultId'=>$resultId,
'recordCount'=>$recordCount,
'fail'=>'y'
);
$params = http_build_query($params);
header("location: login.php?$params");
}
else
if($_REQUEST['path']=="results"){
$params = array(
'path'=>'results',
'query'=>$query,
'fieldcode'=>$fieldCode,
'fail'=>'y'
);
$params = http_build_query($params);
header("location: login.php?".$params);
}
else
{
header("location: login.php?path=index&fail=y");
}
}
else
{
foreach($dom->EDSCredentials->User as $user){
$userType = (string)$user->ClientUser;
$userId = (string)$user->ClientUser;
$profile = (string)$user->EDSProfile;
}
$api = new EBSCOAPI();
$newSessionToken = $api->apiSessionToken($api->getAuthToken(), 'n');
var_dump($newSessionToken);
$_SESSION['sessionToken']=$newSessionToken;
$_SESSION['login']=0;
if(isset($_SESSION['Guest'])){
$_SESSION['Guest']=time()-3600;
}
$path = $_REQUEST['path'];
if($path=="record"){
$params = array(
'db'=>$db,
'an'=>$an,
'highlight'=>$highlight,
'query'=>$query,
'fieldcode'=>$fieldCode,
'resultId'=>$resultId,
'recordCount'=>$recordCount,
);
$params = http_build_query($params);
header("location: $path.php?$params");
}
else
if($path=="PDF"){
$params = array(
'db'=>$db,
'an'=>$an
);
$params = http_build_query($params);
header("location: $path.php?$params");
}
else
if($path=="HTML"){
$params = array(
'db'=>$db,
'an'=>$an,
'highlight'=>$highlight,
'query'=>$query,
'fieldcode'=>$fieldCode,
'resultId'=>$resultId,
'recordCount'=>$recordCount,
);
$params = http_build_query($params);
header("location: record.php?$params#html");
}
else
if($_REQUEST['path']=="results"){
$params = array(
'login'=>'y',
'query'=>$query,
'fieldcode'=>$fieldCode
);
$params = http_build_query($params);
$queryStringUrl =$_SESSION['results']['queryString'];
header("location: results.php?$params&$queryStringUrl");
}
else
{
header("location: index.php");
}
}
?>