use Facebook\FacebookRequest; use Facebook\FacebookResponse; use Facebook\FacebookSDKException; use Facebook\FacebookRequestException; use Facebook\FacebookAuthorizationException; use Facebook\GraphObject; use Facebook\GraphUser; use Facebook\Entities\AccessToken; use Facebook\HttpClients\FacebookCurlHttpClient; use Facebook\HttpClients\FacebookHttpable; FacebookSession::setDefaultApplication(\query\main::get_option('facebook_appID'), \query\main::get_option('facebook_secret')); $helper = new FacebookRedirectLoginHelper($GLOBALS['siteURL'] . '?plugin=' . $_GET['plugin']); try { $session = $helper->getSessionFromRedirect(); } catch (FacebookRequestException $ex) { echo $ex->getMessage(); } catch (Exception $ex) { echo $ex->getMessage(); } if (isset($session)) { $me = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className())->asArray(); if (!isset($me['email']) || !filter_var($me['email'], FILTER_VALIDATE_EMAIL)) { echo 'Your facebook account it\'s not associated with a valid email address.'; die; } header('Location: ' . $GLOBALS['siteURL'] . 'setSession.php?session=' . \user\main::insert_user(array('username' => $me['name'], 'email' => $me['email']), true, true)); } else { if (empty($_GET['code'])) { header('Location:' . $helper->getLoginUrl(array('scope' => 'email'))); } }
public static function register($post) { global $db, $LANG; $session = ''; $max_acc = (int) \query\main::get_option('accounts_per_ip'); if ($max_acc !== 0 && (int) \query\main::users(array('ip' => \site\utils::getIP())) >= $max_acc) { throw new \Exception($LANG['msg_error']); // administrator don't allow that manny accounts } else { if (\user\main::banned('registration')) { throw new \Exception($LANG['msg_banned']); } else { if (!isset($post['email']) || !filter_var($post['email'], FILTER_VALIDATE_EMAIL)) { throw new \Exception($LANG['register_usevalide']); } else { if (!isset($post['username'])) { throw new \Exception($LANG['register_complete_name']); } else { if (!preg_match('/(^[a-zA-Z0-9 ]{3,25}$)/', $post['username'])) { throw new \Exception($LANG['register_invalid_name']); } else { if (!isset($post['password']) || !isset($post['password2'])) { throw new \Exception($LANG['register_paswdreq']); } else { if (!preg_match('/(^[a-zA-Z0-9-_]{5,40}$)/', $post['password'])) { throw new \Exception($LANG['register_invalid_paswd']); } else { if ($post['password'] != $post['password2']) { throw new \Exception($LANG['register_passwdnm']); } else { if (!($session = \user\main::insert_user($post))) { throw new \Exception($LANG['register_accexists']); } return $session; } } } } } } } } }