-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathclaimasset.php
64 lines (57 loc) · 1.53 KB
/
claimasset.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
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");
header("Cache-Control: no-cache");
require_once('config.php');
$okaytodownload = false;
header('P3P: CP="CAO PSA OUR"'); // IE privacy policy fix
session_start();
if (isset($_GET['approot'])) {
$returnurl = $_GET['approot'];
} else {
$returnurl = '/';
}
if ($_SESSION['fb_reports_liked']) {
redirectToAsset();
} else {
if ($_SESSION['fb_reports_liked'] !== false) {
require_once('./lib/facebook.php');
// initialize the facebook API with your application API Key and Secret
$facebook = new Facebook(array(
'appId' => FACEBOOK_APPID,
'secret' => FACEBOOK_SECRET,
'cookie' => true
));
$session = $facebook->getSession();
$fb_user = $session['uid'];
try {
$testLikeStatus = $facebook->api(array(
'method' => 'pages.isfan',
'uid' => $fb_user,
'page_id' => FACEBOOK_FANPAGE_ID
));
if ($testLikeStatus) {
redirectToAsset();
} else {
header('Location: '.$returnurl.'?logout=1');
}
} catch (FacebookApiException $e) {
echo "There seems to be an error on the Facebook servers.";
}
}
}
function redirectToAsset() {
if (SECURE_DOWNLOAD) {
// use S3 secured download:
require_once('./lib/S3.php');
if (!defined('AMAZONS3_KEY') || !defined('AMAZONS3_SECRET')) {
header('Location: ./');
}
$s3 = new S3(AMAZONS3_KEY, AMAZONS3_SECRET);
header("Location: " . S3::getAuthenticatedURL(AMAZONS3_BUCKET, DOWNLOAD_URI, 120));
} else {
// simple redirect:
header('Location: ' . DOWNLOAD_URI);
}
}
?>