-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathview_history_api.php
More file actions
executable file
·362 lines (327 loc) · 9.72 KB
/
view_history_api.php
File metadata and controls
executable file
·362 lines (327 loc) · 9.72 KB
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Welcome to DSL FAITH </title>
<style type="text/css">
<?php echo htmlentities(file_get_contents('faith_style.css', true)); ?>
</style>
</head>
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<?php
require_once 'func.php';
require_once 'vars.php';
require_once 'facebook.php';
try
{
mysqlSetup($db);
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();
$results = mysql_query("SELECT transform_add.transform_add_id,
transform_add.add_uid_a,
transform_add.add_time,
transform_add.social_path,
transform_add.status
from transform_add
where transform_add.add_uid_b = $user_id AND
transform_add.status = 0
order by transform_add.add_time DESC", $db);
$div_counter = 0;
while($row = mysql_fetch_array($results))
{
$div_counter++;
}
display_header_links($div_counter, $user_id);
}
catch (Exception $e)
{
echo 'Caught database exception: ', $e->getMessage(), "\n";
}
?>
</td>
</tr>
<tr>
<td height="10px"></td>
</tr>
<tr>
<td>
<table>
<tr>
<td class="PageTitleLink">
<a href="<?php echo $facebook_canvas_page_url; ?>view_history_url.php">URL Log by Time</a>
</td>
<td class="PageTitleLink">
<a href="<?php echo $facebook_canvas_page_url; ?>view_history.php">API Log by Time</a>
</td>
<td class="PageTitleLink">
<a href="<?php echo $facebook_canvas_page_url; ?>view_history_api.php">API Log by RESTful API</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 650px;vertical-align:top;border-right: #3b5998 3px solid;border-top: #3b5998 3px solid;border-left: #3b5998 3px solid;border-bottom: #3b5998 3px solid;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<table cellpadding="0" cellspacing="10" width="100%">
<tr><td width="50px"></td>
<td class="FAITHHomeDescription">
<br />
<h4>View Access History by RESTful API :</h4>
last 100 accesses of the RESTful API made by applications.
</td>
<td width="50px"></td></tr>
</table>
</td>
</tr>
<?php
require_once 'vars.php';
require_once 'facebook.php';
try
{
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();
try
{
mysqlSetup($db);
if(isset($_POST['restapi_select']) && strlen($_POST['restapi_select']) > 0)
{
$api_id = $_POST['restapi_select'];
$results = mysql_query("SELECT restapi.name as name,
facebook_application.app_name as app_name,
facebook_application.default_page as default_page,
facebook_application.id as app_id,
access_log.allowed,
access_log.access_time,
access_log.logID,
INET_NTOA(access_log.app_ip_addr) AS app_ip_addr,
INET_NTOA(access_log.user_ip_addr) AS user_ip_addr,
restapi_field.id as restapi_field_id,
restapi.id as restapi_id
from access_log INNER JOIN facebook_application
ON facebook_application.id = access_log.app_id
INNER JOIN restapi
ON restapi.id = access_log.api_id
INNER JOIN restapi_field
ON restapi.restapi_field_id = restapi_field.id
where access_log.uid = $user_id AND
access_log.api_id = $api_id
order by access_log.access_time DESC
LIMIT 100", $db);
$display_any = false;
$div_counter = 0;
while($row = mysql_fetch_array($results))
{
$display_any = true;
$name = $row['name'];
$app_name = $row['app_name'];
$allowed = $row['allowed'];
$access_time = $row['access_time'];
$logID = $row['logID'];
$restapi_field_id = $row['restapi_field_id'];
$restapi_id = $row['restapi_id'];
$default_page = $row['default_page'];
$app_id = $row['app_id'];
$app_ip_addr = $row['app_ip_addr'];
$user_ip_addr = $row['user_ip_addr'];
if($allowed == '1')
{
$allowed = 'Access Allowed';
}
else
{
$allowed = '<font color="red">Access Denied</font>';
}
get_access_log_contents($name,
$app_name,
$allowed,
$access_time,
$logID,
$restapi_field_id,
$restapi_id,
$default_page,
$app_id,
$app_ip_addr,
$user_ip_addr,
$div_counter);
$div_counter++;
}
if(!$display_any)
{
echo '<tr><td>
<table width="100%">
<tr>
<td width="50px"></td>
<td>
<label>
No applications have called this API.
</label>
</td>
</tr>
</table>
</td></tr>';
}
}
else
{
$results = mysql_query("SELECT id,
name
from restapi_field
where display = 1", $db);
echo '<tr><td>
<table width="100%">
<tr>
<td width="70px" style="text-align: center;">
<img style="display:none;" id="apifield_loading_img" src="'.$source_server_url.'image/ajax-loader.gif" />
</td>
<td>
<select style="width: 300px;" name="restapi_field_select" id="restapi_field_select"
onchange="do_ajax('."'live_search_Div'".',1, '.$user_id.', '."'apifield_loading_img'".');">';
while($row = mysql_fetch_array($results))
{
$id = $row['id'];
$name = $row['name'];
echo '<option value="'.$id.'" selected>'.$name.'</option>';
}
echo '</select> Please select a method
</td>
</tr>
<tr>
<td width="70px"></td>
<td>
<div id="live_search_Div"></div>
</td>
</tr>
</table>
</td></tr>';
}
}
catch (Exception $e)
{
echo 'Caught database exception: ', $e->getMessage(), "\n";
}
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
<?php
function get_access_log_contents($name,
$app_name,
$allowed,
$access_time,
$logID,
$restapi_field_id,
$restapi_id,
$default_page,
$app_id,
$app_ip_addr,
$user_ip_addr,
$div_counter)
{
GLOBAL $source_server_url;
GLOBAL $facebook_canvas_page_url;
$app_server_html ='';
$client_server_html = '';
if(isset($app_ip_addr) && strlen($app_ip_addr) > 0)
{
$app_server_html .=
'Application Server IP :
<a href="#" onclick="do_ajax_ip('."'ip_infor_Div".$div_counter."'".',2,'."'$app_ip_addr'".','."'loading_img".$div_counter."'".');">' . $app_ip_addr . '</a>';
}
if(isset($user_ip_addr) && strlen($user_ip_addr) > 0)
{
$client_server_html .=
'Client IP :
<a href="#" onclick="do_ajax_ip('."'ip_infor_Div".$div_counter."'".',2,'."'$user_ip_addr'".','."'loading_img".$div_counter."'".');">' . $user_ip_addr . '</a>';
}
$detail_message = '<a href="#" onclick="do_ajax_ip('."'ip_infor_Div".$div_counter."'".',3,'."'$logID'".','."'loading_img".$div_counter."'".');">details</a>';
echo
'<tr><td>
<table width="100%" style="padding-top: 5px;">
<tr>
<td width="5%"></td>
<td width="40%">
<a href="'.$facebook_canvas_page_url.'set_policy.php?field=' . $restapi_field_id . '">' . $name . '</a>
</td>
<td width="10%">called by:</td>
<td width="40%">
<a href="'.$facebook_canvas_page_url.'index.php?ffile=' . $default_page . '&fpro=' . $app_id .'">' . $app_name . '</a>
</td>
<td width="5%"></td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="3" width="90%">
<font style="padding-left: 10px; padding-right: 10px; border-right: #AAAAAA 1px solid;">'. $access_time .
'</font>
<font style="padding-left: 10px; padding-right: 10px; border-right: #AAAAAA 1px solid;">' . $allowed .
' </font>
<font style="padding-left: 10px; padding-right: 10px; border-right: #AAAAAA 1px solid;">' . $app_server_html .
' </font>
<font style="padding-left: 10px; padding-right: 10px; border-right: #AAAAAA 1px solid;">' . $client_server_html .
' </font>
<font style="padding-left: 10px;">' . $detail_message .
' </font>
</td>
</td>
<td width="5%" style="text-align: center;vertical-align:top;">
<img style="display:none;" id="loading_img'.$div_counter.'" src="'.$source_server_url.'image/ajax-loader.gif" />
</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="3" width="90%">
<table style="border-bottom: #CCCCCC 1px solid; padding-bottom: 5px;" width="100%">
<tr>
<td width="100%">
<div style="background-color: #eceff6;" id="ip_infor_Div'.$div_counter.'"></div>
</td>
</tr>
</table>
</td>
<td width="5%"></td>
</tr>
</table>
</td></tr>';
}
?>
<script type="text/javascript">
<!--
function do_ajax(div,val,uid,img) {
document.getElementById(img).setStyle('display', 'inline');
var ajax = new Ajax();
ajax.responseType = Ajax.FBML;
ajax.ondone = function(data)
{
document.getElementById(img).setStyle('display', 'none');
document.getElementById(div).setInnerFBML(data);
}
var params={"action":'select',"option":val,"searchwords":document.getElementById('restapi_field_select').getValue(),"otherval":uid};
ajax.post('<?=$view_history_callbackurl?>?t='+val,params);
}
function do_ajax_ip(div,val,ip,img) {
document.getElementById(img).setStyle('display', 'inline');
var ajax = new Ajax();
ajax.responseType = Ajax.FBML;
ajax.ondone = function(data)
{
document.getElementById(img).setStyle('display', 'none');
document.getElementById(div).setInnerFBML(data);
}
var params={"action":'select',"option":val,"searchwords":'none',"ipaddr":ip};
ajax.post('<?=$view_history_callbackurl?>?t='+val,params);
}
//-->
</script>
<tr>
<td height="80px"></td>
</tr>
</table>
</td>
</tr>
</table>
</html>