-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathset_policy.php
More file actions
executable file
·427 lines (385 loc) · 11.8 KB
/
set_policy.php
File metadata and controls
executable file
·427 lines (385 loc) · 11.8 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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
<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" width="750px">
<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; ?>set_policy.php">at RESTful API Level</a>
</td>
<td class="PageTitleLink">
<a href="<?php echo $facebook_canvas_page_url; ?>set_policy_transform.php">Network Transformation</a>
(<font style="padding-left: 5px; padding-right: 5px;">
<a href="<?php echo $facebook_canvas_page_url; ?>set_policy_transform_add.php">Add</a></font>
<font style="padding-left: 5px; padding-right: 5px;">
<a href="<?php echo $facebook_canvas_page_url; ?>set_policy_transform_remove.php">Hide</a></font>)
(<font style="padding-left: 5px; padding-right: 5px;">
<a href="<?php echo $facebook_canvas_page_url; ?>set_policy_transform_accepted_request.php">Confirmed Requests</a></font>)
</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="0" width="100%">
<tr>
<td width="5%"></td>
<td width="90%" style="padding-top: 20px;font-weight: bolder;font-size: 10pt;font-family: Verdana, Arial;line-height: 45px;text-align: left;">
at RESTful API Level
</td>
<td width="5%"></td>
</tr>
<tr>
<td width="5%"></td>
<td width="90%" style="padding-bottom: 15px;font-size: 8pt;font-family: Verdana, Arial;line-height: 15px;text-align: left;border-bottom: #AAAAAA 1px solid;">
The Facebook RESTful API uses a REST-like interface. The Facebook method calls are made over the internet by sending HTTP GET or POST requests to the Facebook API REST server.
Nearly any computer language can be used to communicate over HTTP with the REST server, and it is one of the main methods Facebook applications use to retrieve user information from Facebook.
You can disable any Facebook API to prevent the applications from retrieving your information.
</td>
<td width="5%"></td>
</tr>
<tr>
<td width="5%"></td>
<td width="90%">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="35%" style="border-right: #AAAAAA 1px solid;height: 350px;vertical-align:top;">
<table cellpadding="0" cellspacing="10" width="100%">
<?php
require_once 'vars.php';
require_once 'facebook.php';
try
{
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();
mysqlSetup($db);
if(!isset($_GET['api_id']))
{
$results = mysql_query("SELECT id,
name
from restapi_field
where display = 1", $db);
while($row = mysql_fetch_array($results))
{
$id = $row['id'];
$name = $row['name'];
if($_GET['field'] == $id)
{
get_restapi_field_table_contents($id,
$name,
true);
}
else
{
get_restapi_field_table_contents($id,
$name,
false);
}
}
}
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
</table>
</td>
<td width="65%" style="vertical-align:top;">
<table cellpadding="0" cellspacing="10" width="100%">
<?php
try
{
if(isset($_GET['field']) && strlen($_GET['field']) > 0)
{
if(isset($_POST['status']) && $_POST['status'] == 'block')
{
$api_id = $_POST['ApiID'];
$query = sprintf("INSERT INTO user_disable_api (uid, restapi_id) VALUES( '%s', '%s')", $user_id, $api_id);
if(!mysql_query($query))
{
echo '<div class="fberrorbox">
Failed to block the selected API!
</div><br />';
exit();
}
else
{
$Count_Num = '1';
echo '<div class="fbbluebox">
You have successfully blocked the selected API!
</div><br />';
}
}
else if(isset($_POST['status']) && $_POST['status'] == 'unblock')
{
$api_id = $_POST['ApiID'];
$commit = "commit";
mysql_query("begin", $db);
$query = "DELETE FROM user_disable_api_app
WHERE user_disable_api_app.uid = $user_id AND
user_disable_api_app.restapi_id = $api_id;";
if(!mysql_query($query, $db))
{
$commit = "rollback";
$querylog .= "error in query: " . $query . " : " . mysql_error($db) . "<br /><br />";
}
$query = "DELETE FROM user_disable_api where uid = $user_id AND
restapi_id = $api_id;";
if(!mysql_query($query, $db))
{
$commit = "rollback";
$querylog .= "error in query: " . $query . " : " . mysql_error($db) . "<br /><br />";
}
if($commit == "rollback")
{
$querylog .= "ERROR IN TRANSACTION<br /><br />transaction rolled back<br /><br />";
}
$remove_rule_results = mysql_query($commit);
if(!$remove_rule_results)
{
echo '<div class="fberrorbox">
Failed to unblock the selected API!
</div><br />';
}
else
{
echo '<div class="fbbluebox">
You have successfully unblocked the selected API!
</div><br />';
}
/*$api_id = $_POST['ApiID'];
$query = sprintf("DELETE FROM user_disable_api where uid = " . $user_id . " AND restapi_id = $api_id");
if(!mysql_query($query))
{
echo '<div class="fberrorbox">
Failed to unblock the selected API!
</div><br />';
exit();
}
else
{
$Count_Num = '0';
echo '<div class="fbbluebox">
You have successfully unblocked the selected API!
</div><br />';
}*/
}
$field = $_GET['field'];
$api_results = mysql_query("SELECT id,
name,
facebook_description,
Supported,
(SELECT Count(*) as Count_Num from user_disable_api
where user_disable_api.uid = " . $user_id . " AND user_disable_api.restapi_id = restapi.id) AS blocked
from restapi
where display=1 AND restapi_field_id = $field", $db);
$div_counter = 0;
while($api_row = mysql_fetch_array($api_results))
{
$api_id = $api_row['id'];
$api_name = $api_row['name'];
$api_facebook_description = $api_row['facebook_description'];
$api_Supported = $api_row['Supported'];
$blocked = $api_row['blocked'];
get_restapi_table_contents($user_id,
$api_id,
$api_name,
$api_facebook_description,
$api_Supported,
$field,
$blocked,
$div_counter);
$div_counter++;
}
}
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
</table>
</td>
</tr>
</table>
</td>
<td width="5%"></td>
</tr>
</table>
</td>
</tr>
<?php
function get_restapi_field_table_contents($id,
$name,
$select)
{
GLOBAL $facebook_canvas_page_url;
$color = '#3b5998';
if($select)
{
$color = '#dd3c10';
}
echo
'<tr>
<td style="background-color: '.$color.';text-align: center;line-height: 30px;">
<a style="color: #ffffff;font-weight: bold;font-family: Verdana, Arial;font-size: 8pt;"
href="'.$facebook_canvas_page_url.'set_policy.php?field=' . $id . '">' . $name . '</a>
</td>
</tr>';
}
function get_restapi_table_contents($user_id,
$api_id,
$api_name,
$api_facebook_description,
$api_Supported,
$field,
$blocked,
$div_counter)
{
$exclude_list_html = '';
$block_html = '';
if($blocked > 0)
{
$block_html =
'<form style="display: inline;" name="set_policy_form'.$api_id.'" id="set_policy_form'.$api_id.'"
action="set_policy.php?field=' . $field . '" method="post">
<INPUT type="hidden" name="ApiID" VALUE="'.$api_id.'">
<INPUT type="hidden" name="status" VALUE="unblock">
<a style="color: #dd3c10;font-weight: bold;text-decoration: underline;"
href="#" onclick="document.getElementById('."'set_policy_form".$api_id."'".').submit();">unblock this API</a>
</form>';
$exclude_list_html =
'<tr>
<td colspan="2" style="padding-top: 5px;">
NOT apply to
<font style="padding-right: 10px;">
Applications (<a href="set_policy_not_app.php?api_id='.$api_id.'">
Edit
</a>
| <a href="#" onclick="do_ajax_show_details('."'ip_infor_Div".$div_counter."'".',6,'."'$user_id'".','."'$api_id'".','."'loading_img".$div_counter."'".');">
Details
</a>)
</font>
<img style="display:none;" id="loading_img'.$div_counter.'" src="'.$source_server_url.'image/ajax-loader.gif" />
</td>
</tr>
<tr>
<td colspan="2">
<div style="background-color: #eceff6;" id="ip_infor_Div'.$div_counter.'"></div>
</td>
</tr>';
}
else
{
$block_html =
'<form style="display: inline;" name="set_policy_form'.$api_id.'" id="set_policy_form'.$api_id.'"
action="set_policy.php?field=' . $field . '" method="post">
<INPUT type="hidden" name="ApiID" VALUE="'.$api_id.'">
<INPUT type="hidden" name="status" VALUE="block">
<a style="font-weight: bold;text-decoration: underline;"
href="#" onclick="document.getElementById('."'set_policy_form".$api_id."'".').submit();">block this API</a>
</form>';
}
echo
'
<tr>
<td width="70%" style="font-weight: bold;font-family: Verdana, Arial;font-size: 9pt;">
' . $api_name . '
</td>
<td width="30%" style="text-align: right;">
'.$block_html.'
</td>
</tr>
<tr>
<td colspan="2">' . $api_facebook_description . '</td>
</tr>
'.$exclude_list_html.'
<tr>
<td colspan="2" style="border-bottom: #CCCCCC 1px solid;"></td>
</tr>';
}
?>
<tr>
<td height="20px"></td>
</tr>
<script type="text/javascript">
<!--
function do_ajax_show_details(div,val,user_id,api_id,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',"api_id":api_id,"user_id":user_id};
ajax.post('<?=$set_policy_transform_callbackurl?>?t='+val,params);
}
//-->
</script>
</table>
</td>
</tr>
</table>
</html>
<?php
/*
<font style="padding-left: 10px; padding-right: 10px;">
Friends (<a href="set_policy_not_fri.php?api_id='.$api_id.'">
Edit
</a>
| <a href="#" onclick="do_ajax_show_details('."'ip_infor_Div".$div_counter."'".',5,'."'$user_id'".','."'$api_id'".','."'loading_img".$div_counter."'".');">
Details
</a>)
</font>
*/
?>