You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ***/ // Provides access to app specific values such as your app id and app secret. // Defined in 'AppInfo.php' require_once 'AppInfo.php'; // Enforce https on production if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') { header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit; } require_once 'classes.php'; require_once 'utils.php'; require_once 'database.php'; require_once 'sdk/src/facebook.php'; $db = new Database(new PDO(AppInfo::getDatabaseDSN(), null, null, array(PDO::ATTR_PERSISTENT => true))); $facebook = new Facebook(array('appId' => AppInfo::appID(), 'secret' => AppInfo::appSecret())); $user_id = $facebook->getUser(); if ($user_id) { try { // Fetch the viewer's basic information $myfb = $facebook->api('/me'); } catch (FacebookApiException $e) { // If the call fails we check if we still have a user. The user will be // cleared if the error is because of an invalid accesstoken if (!$facebook->getUser()) { header('Location: ' . AppInfo::getUrl($_SERVER['REQUEST_URI'])); exit; } } $authenticated = true;