-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_ok.php
More file actions
64 lines (48 loc) · 1.62 KB
/
auth_ok.php
File metadata and controls
64 lines (48 loc) · 1.62 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
<?php
/**
* @file auth_ok.php
* @author jc <jean-charles.le-goff@epitech.eu>
* @date Thu Mar 10 18:33:35 2011
*
* @brief
*
*
*/
session_start();
include_once 'config/config.php';
include_once 'utils/common.php';
include_once 'classes/Db.class.php';
include_once 'classes/Renderer.class.php';
$content = '';
$tokens = $_SESSION['oauth_tokens'];
$url = 'http://api.dropbox.com/0/oauth/access_token?oauth_consumer_key=' . $consumerKey . '&oauth_token=' . $tokens['oauth_token'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$data = curl_exec($ch);
curl_close($ch);
if (strpos($data, 'error') !== FALSE) {
$content .= 'Oops, it seems you are not associated with your dropbox account :(';
$content .= '<br /><a href="auth.php">Click here to retry</a>';
}
else {
if (!isset($_SESSION['u'])) {
parse_str($data, $tokens);
$_SESSION['oauth_tokens'] = $tokens;
$_SESSION['u'] = random_string();
$db = Db::getInstance();
if (!$db->connect($conf['sql']['host'], $conf['sql']['user'], $conf['sql']['password'], $conf['sql']['db'])) {
echo 'can\'t connect to db';
return;
}
insert_form($_SESSION['u'], $tokens['oauth_token'], $tokens['oauth_token_secret']);
$db->close();
}
$url_form = $conf['url'] . 'up.php?u=' . $_SESSION['u'];
$content .= 'Cool, you are associated. Here is the link to your upload form: <br />
<a href="' . $url_form . '" target="_blank">' . $url_form . '</a>
<br />You can give this link to your friends ^^';
}
$renderer = new Renderer();
$renderer->setContent($content);
$renderer->render();
?>