-
Notifications
You must be signed in to change notification settings - Fork 0
/
deauth.php
50 lines (42 loc) · 1.45 KB
/
deauth.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
<?php require_once 'defines.inc.php'?>
<?php
if(isset($_POST['signed_request']))
{
require_once 'instagram/signed.inc.php';
$instagram = verify($_POST['signed_request']);
if($instagram !== NULL)
{
try {
$sql = "SELECT `id` FROM `accountlist` WHERE `instagram`=?";
$stmt = $dbh->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param("i", $instagram);
$stmt->execute();
$row = $stmt->get_result()->fetch_assoc();
if($row !== NULL)
echo json_encode(array('success'=>true, 'url'=>HTTP."instagram/deletion/".hash("crc32", $row['id']), 'confirmation_code'=>hash("crc32", $row['id'])));
else
{
trigger_error("Instagram account not found in the database: $instagram", E_USER_NOTICE);
echo json_encode(array('success'=>false, 'error'=>"Instagram account not found in the database"));
}
} catch (mysqli_sql_exception $exception) {
$driver->logexc($exception);
switch($exception->getTrace()[0]['function'])
{
case 'prepare':
echo json_encode(array('success'=>false, 'error'=>"Error connecting to the server"));
break;
default:
echo json_encode(array('success'=>false, 'error'=>"Unknown error"));
break;
}
}
}
else
{
trigger_error("Invalid instagram authentication: ".$_POST['signed_request'], E_USER_NOTICE);
echo json_encode(array('success'=>false, 'error'=>"Invalid instagram authentication"));
}
} else
header("Location: " . HTTP . "?error=403");