1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | FacebookPlug - a Piwigo Plugin | |
---|
4 | // | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org | |
---|
5 | // +-----------------------------------------------------------------------+ |
---|
6 | // | This program is free software; you can redistribute it and/or modify | |
---|
7 | // | it under the terms of the GNU General Public License as published by | |
---|
8 | // | the Free Software Foundation | |
---|
9 | // | | |
---|
10 | // | This program is distributed in the hope that it will be useful, but | |
---|
11 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
12 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
13 | // | General Public License for more details. | |
---|
14 | // | | |
---|
15 | // | You should have received a copy of the GNU General Public License | |
---|
16 | // | along with this program; if not, write to the Free Software | |
---|
17 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
18 | // | USA. | |
---|
19 | // +-----------------------------------------------------------------------+ |
---|
20 | |
---|
21 | defined('FACEBOOKPLUG_ROOT_PATH') or trigger_error('Hacking attempt!', E_USER_ERROR); |
---|
22 | |
---|
23 | @set_magic_quotes_runtime(false); // Disable magic_quotes_runtime |
---|
24 | |
---|
25 | // |
---|
26 | // addslashes to vars if magic_quotes_gpc is off this is a security |
---|
27 | // precaution to prevent someone trying to break out of a SQL statement. |
---|
28 | // |
---|
29 | if( !@get_magic_quotes_gpc() ) |
---|
30 | { |
---|
31 | function sanitize_mysql_kv(&$v, $k) |
---|
32 | { |
---|
33 | $v = addslashes($v); |
---|
34 | } |
---|
35 | if( is_array( $_GET ) ) |
---|
36 | { |
---|
37 | array_walk_recursive( $_GET, 'sanitize_mysql_kv' ); |
---|
38 | } |
---|
39 | if( is_array( $_POST ) ) |
---|
40 | { |
---|
41 | array_walk_recursive( $_POST, 'sanitize_mysql_kv' ); |
---|
42 | } |
---|
43 | if( is_array( $_COOKIE ) ) |
---|
44 | { |
---|
45 | array_walk_recursive( $_COOKIE, 'sanitize_mysql_kv' ); |
---|
46 | } |
---|
47 | } |
---|
48 | if ( !empty($_SERVER["PATH_INFO"]) ) |
---|
49 | { |
---|
50 | $_SERVER["PATH_INFO"] = addslashes($_SERVER["PATH_INFO"]); |
---|
51 | } |
---|
52 | |
---|
53 | require_once(FACEBOOKPLUG_ROOT_PATH.'include/constants.php'); |
---|
54 | require_once(FACEBOOKPLUG_ROOT_PATH.'include/constants_secret.php'); |
---|
55 | require_once(FACEBOOKPLUG_ROOT_PATH.'include/facebook.php'); |
---|
56 | require_once(FACEBOOKPLUG_ROOT_PATH.'include/functions.php'); |
---|
57 | |
---|
58 | // Main global var |
---|
59 | $conf = array(); |
---|
60 | |
---|
61 | // Default config |
---|
62 | include(FACEBOOKPLUG_ROOT_PATH.'include/config_default.php'); |
---|
63 | |
---|
64 | // Log on db |
---|
65 | fbp_db_log(); |
---|
66 | |
---|
67 | // Init Facebook |
---|
68 | $facebook = new Facebook(array( |
---|
69 | 'appId' => FACEBOOK_APP_ID, |
---|
70 | 'secret' => FACEBOOK_SECRET, |
---|
71 | 'cookie' => true, // enable optional cookie support |
---|
72 | )); |
---|
73 | |
---|
74 | $session = $facebook->getSession(); |
---|
75 | //~ var_dump($session); |
---|
76 | // Session based graph API call. |
---|
77 | if (! $session) |
---|
78 | { |
---|
79 | // Redirect to facebook page reconnect |
---|
80 | $url = $facebook->getLoginUrl( |
---|
81 | array |
---|
82 | ( |
---|
83 | //ici on demande les permissions email, publication sur le mur, et changement du status |
---|
84 | //'req_perms' => 'email,publish_stream,status_update', |
---|
85 | 'req_perms' => 'publish_stream', |
---|
86 | 'display' => 'popup', |
---|
87 | 'cancel_url' => 'http://'.$_SERVER['HTTP_HOST'].'/'.FBP_VERSION.'/cancel.php' |
---|
88 | )); |
---|
89 | header( 'Request-URI: '.$url ); |
---|
90 | header( 'Content-Location: '.$url ); |
---|
91 | header( 'Location: '.$url ); |
---|
92 | exit(); |
---|
93 | } |
---|
94 | |
---|
95 | ?> |
---|