private function getvBUserWithForumList() { global $vbulletin; $arrayResponse = array(); if (is_facebookenabled() and vB_Facebook::instance()->userIsLoggedIn()) { $vbulletin->input->clean_array_gpc('r', array('facebookidList' => TYPE_STR, 'timestamp' => TYPE_INT)); // ensure list is only numbers and commas .. can't use intval() as fb uid can be 64bit and intval // will eat that on a 32bit system $cleanlist = preg_replace('#[^0-9,]#s', '', $vbulletin->GPC['facebookidList']); $arraylist = preg_split("#,#s", $cleanlist, -1, PREG_SPLIT_NO_EMPTY); if ($arraylist) { $timestamp = $vbulletin->GPC['timestamp'] ? $vbulletin->GPC['timestamp'] : 7 * 3600 * 24; $vBUserlist = $vbulletin->db->query_read_slave("\n\t\t\t\t\tSELECT user.userid, user.username, user.fbuserid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "userlist AS userlist\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = userlist.relationid)\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tuser.fbuserid IN (" . implode(',', $arraylist) . ")\n\t\t\t\t\t\tAND userlist.userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\t\t\t\tAND userlist.type = 'buddy'\n\t\t\t\t\t\tAND joindate >= {$timestamp}\n\t\t\t\t"); while ($vBUser = $vbulletin->db->fetch_array($vBUserlist)) { $arrayResponse[] = array('vBuserid' => $vBUser['userid'], 'vBusername' => $vBUser['username'], 'fbUserId' => $vBUser['fbuserid'], 'forums' => $this->getSubscribedForumsOfTheUser($vBUser['userid'])); } } if (!$arrayResponse) { $arrayResponse['response']['errormessage'][0] = 'no_users_in_facebook'; } } return $arrayResponse; }
function verify_facebook_authentication() { global $vbulletin; // get the userinfo associated with current logged in facebook user // return false if not logged in to fb, or there is no associated user record if (!$fb_userid = vB_Facebook::instance()->getLoggedInFbUserId()) { return false; } if (!$vbulletin->userinfo = $vbulletin->db->query_first(" SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE fbuserid = '$fb_userid' ")) { return false; } // facebook login successful, fetch hook and return true $return_value = true; ($hook = vBulletinHook::fetch_hook('login_verify_success')) ? eval($hook) : false; return $return_value; }
$optiontitle = $vbphrase["{$timezonephrase}"]; $optionselected = iif($optionvalue == $timezonesel, 'selected="selected"', ''); $timezoneoptions .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass); } $templater = vB_Template::create('modifyoptions_timezone'); $templater->register('selectdst', $selectdst); $templater->register('timezoneoptions', $timezoneoptions); $timezoneoptions = $templater->render(); // if applicable, set up some facebook data if (is_facebookenabled()) { // if users are allowed to import info from facebook, generate the form if (vB_Facebook::instance()->userIsLoggedIn()) { $fbimportform = construct_fbimportform(); } // populate form fields with information from facebook if its available $fb_userinfo = vB_Facebook::instance()->getFbUserInfo(); if (!empty($fb_userinfo)) { $show['fb_email'] = !empty($fb_userinfo['contact_email']) ? true : false; $email = !empty($fb_userinfo['contact_email']) ? $fb_userinfo['contact_email'] : $email; $emailconfirm = !empty($fb_userinfo['contact_email']) ? $fb_userinfo['contact_email'] : $emailconfirm; } } $navbits['register.php' . $vbulletin->session->vars['sessionurl_q']] = $vbphrase['register']; $navbar = render_navbar_template($navbits); ($hook = vBulletinHook::fetch_hook('register_form_complete')) ? eval($hook) : false; $templater = vB_Template::create('register'); $templater->register_page_templates(); $templater->register('navbar', $navbar); $templater->register('birthdayfields', $birthdayfields); $templater->register('checkedoff', $checkedoff); $templater->register('customfields_option', $customfields_option);
// ######################### REQUIRE BACK-END ############################ require_once './global.php'; require_once DIR . '/includes/functions_login.php'; // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $vbulletin->input->clean_gpc('r', 'a', TYPE_STR); if (empty($_REQUEST['do']) and empty($vbulletin->GPC['a'])) { exec_header_redirect($vbulletin->options['forumhome'] . '.php'); } // ############################### start logout ############################### if ($_REQUEST['do'] == 'logout') { // if user is logged into facebook, process facebook logout first if ($vbulletin->options['enablefacebookconnect'] and vB_Facebook::instance()->userIsLoggedIn()) { // go to facebook site to logout, then redirect back here to complete logout process vB_Facebook::instance()->doLogoutFbUser(create_full_url($vbulletin->reloadurl)); } define('NOPMPOPUP', true); $vbulletin->input->clean_gpc('r', 'logouthash', TYPE_STR); if ($vbulletin->userinfo['userid'] != 0 and !verify_security_token($vbulletin->GPC['logouthash'], $vbulletin->userinfo['securitytoken_raw'])) { eval(standard_error(fetch_error('logout_error', $vbulletin->session->vars['sessionurl'], $vbulletin->userinfo['securitytoken']))); } process_logout(); $vbulletin->url = fetch_replaced_session_url($vbulletin->url); if (strpos($vbulletin->url, 'do=logout') !== false) { $vbulletin->url = $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q']; } $show['member'] = false; eval(standard_error(fetch_error('cookieclear', create_full_url($vbulletin->url), $vbulletin->options['forumhome'], $vbulletin->session->vars['sessionurl_q']), '', false)); } // ############################### start do login ###############################
/** * Logs the user out of Facebook Connect, but not out of Facebook.com */ function do_facebooklogout() { global $show; $show['facebookuser'] = false; vB_Facebook::instance()->doLogoutFbUser(); }
/** * Check if facebook is enabled, and perform appropriate action based on * authentication state (fb and vb) of the user */ public function load_facebook() { global $vbulletin, $show; // check if facebook and session is enabled if (is_facebookenabled()) { // is user is logged into facebook? if ($show['facebookuser'] = vB_Facebook::instance()->userIsLoggedIn()) { // is user logged into vB? if (!empty($vbulletin->userinfo['userid'])) { // if vb user is not associated with the current facebook account (or no facebook account at all), // redirect to the register association page, if doing facebook redirect if ($vbulletin->userinfo['fbuserid'] != vB_Facebook::instance()->getLoggedInFbUserId()) { if (do_facebook_redirect()) { exec_header_redirect('register.php' . $vbulletin->session->vars['sessionurl_q']); } // if not doing facebook redirect and not on the reg page, // pretend the user is not logged into facebook at all so user can browse else if (THIS_SCRIPT != 'register') { $show['facebookuser'] = false; } } } // user is not logged into vb, but logged into facebook else { // check if there is an associated vb account, if so attempt to log that user in if (vB_Facebook::instance()->getVbUseridFromFbUserid()) { // make sure user is trying to login if (do_facebook_redirect()) { // need to load the style here to display // the login welcome message properly $this->load_style(); require_once(DIR . '/includes/functions_login.php'); if (verify_facebook_authentication()) { // create new session process_new_login('fbauto', false, ''); // do redirect do_login_redirect(); } } // if user is not trying to login with FB connect, // pretend like the user is not logged in to FB else if (THIS_SCRIPT != 'register') { $show['facebookuser'] = false; } } // otherwise, fb account is not associated with any vb user else { // redirect to the registration page to create a vb account if (do_facebook_redirect()) { exec_header_redirect('register.php' . $vbulletin->session->vars['sessionurl_q']); } // if not doing redirect and not trying to register, // pretend user is not logged into facebook so they can still browse the site else if (THIS_SCRIPT != 'register') { $show['facebookuser'] = false; } } } } } }
/** * Returns the login_facebook instance of the facebook client api object * * @return vB_Facebook */ public static function login_facebook_instance() { global $vbulletin; if (!isset(self::$login_facebook_instance)) { // boot up the facebook api self::$login_facebook_instance = new vB_Facebook($vbulletin->options['facebookappid'], $vbulletin->options['facebooksecret']); } return self::$login_facebook_instance; }
/** * Returns an instance of the facebook client api object * * @return vB_Facebook */ public static function instance() { if (!isset(self::$instance)) { // boot up the facebook api self::$instance = new vB_Facebook(); } return self::$instance; }
/** * Check if facebook is enabled, and perform appropriate action based on * authentication state (fb and vb) of the user */ public function load_facebook() { global $vbulletin, $show; $vbulletin->input->clean_array_gpc('r', array('dofbredirect' => TYPE_BOOL)); $dofbredirect = ($vbulletin->GPC_exists['dofbredirect'] and $vbulletin->GPC['dofbredirect'] == 1); // check if facebook and session is enabled if (is_facebookenabled()) { // is user is logged into facebook? if ($show['facebookuser'] = vB_Facebook::instance()->userIsLoggedIn()) { // is user logged into vB? if (!empty($vbulletin->userinfo['userid'])) { // if vb user is not associated with the current facebook account (or no facebook account at all), // redirect to the register association page, if doing facebook redirect if ($vbulletin->userinfo['fbuserid'] != vB_Facebook::instance()->getLoggedInFbUserId()) { if (do_facebook_redirect()) { exec_header_redirect('register.php' . $vbulletin->session->vars['sessionurl_q']); } else { if (THIS_SCRIPT != 'register') { $show['facebookuser'] = false; if ($dofbredirect) { standard_error(fetch_error('facebook_connect_fail')); } } } } } else { // check if there is an associated vb account, if so attempt to log that user in if (vB_Facebook::instance()->getVbUseridFromFbUserid()) { // make sure user is trying to login if (do_facebook_redirect()) { // need to load the style here to display // the login welcome message properly $this->load_style(); require_once DIR . '/includes/functions_login.php'; if (verify_facebook_authentication()) { // create new session process_new_login('fbauto', false, ''); // do redirect do_login_redirect(); } } else { if (THIS_SCRIPT != 'register') { $show['facebookuser'] = false; if ($dofbredirect) { standard_error(fetch_error('facebook_connect_fail')); } } } } else { // redirect to the registration page to create a vb account if (do_facebook_redirect()) { exec_header_redirect('register.php' . $vbulletin->session->vars['sessionurl_q']); } else { if (THIS_SCRIPT != 'register') { $show['facebookuser'] = false; if ($dofbredirect) { standard_error(fetch_error('facebook_connect_fail')); } } } } } } } }