/**
  * Validates login status on external service and logs in vBulletin
  */
 public function login()
 {
     global $vbulletin;
     $vbulletin->session = NULL;
     // Get and store vbnexus-id and vbnexus-srv
     $vBNexus = vBNexus::getInstance();
     $vbnexus_service = $vBNexus->getConfig('vbnexus_service');
     $vbnexus_userid = $vBNexus->getConfig('vbnexus_userid');
     if (!$vbnexus_userid) {
         $vbnexus_userid = $this->getUserOnline();
         $vBNexus->setConfig('vbnexus_userid', $vbnexus_userid);
     }
     // Returning null if authentication from service failed (unexpected error)
     // If this happens, there's likely cookies issues on the server or the
     // applications config is wrong/incomplete in fb or gfc
     if (!$vbnexus_userid) {
         return NULL;
     }
     // Get all available information on this user
     $sql = "SELECT `u`.`usergroupid`,\r\n                       `u`.`username`,\r\n                       `u`.`email`,\r\n                       `n`.*\r\n                FROM " . TABLE_PREFIX . "vbnexus_user `n`\r\n                LEFT JOIN " . TABLE_PREFIX . "user `u` USING (`userid`)\r\n                WHERE `n`.`service` = '{$vbnexus_service}'\r\n                AND `n`.`nonvbid` = '{$vbnexus_userid}'";
     $res = $vbulletin->db->query_first($sql);
     // Returning false if user not registered yet with this external account
     if (!$res || !$res['userid']) {
         return false;
     }
     /************* Starts: fix proxied emails from vBNexus3 ***************/
     $oldemails = array('fb' => '/@proxymail\\.facebook\\.com$/', 'gfc' => "/apps\\+|{$vbnexus_userid}[@\\.]/");
     if (preg_match($oldemails[$vbnexus_service], $res['email'])) {
         $this->fixOldEmail($res, $vbnexus_userid);
     } elseif ($vbnexus_service == 'gfc' && !$res['associated']) {
         $this->associateAccount($res, $vbnexus_userid);
     }
     /********** Ends: ask for a valid password for GFC accounts ***********/
     // Process vBulletin login
     require_once DIR . '/includes/functions_login.php';
     $vbulletin->userinfo = fetch_userinfo($res['userid']);
     $vbulletin->session->created = false;
     process_new_login('', false, '');
     // On login, store a cookie with vbnexus params
     if ($vbulletin->session->created) {
         $vBNexusInfo = array('userid' => $res['userid'], 'service' => $vbnexus_service, 'nexusid' => $vbnexus_userid, 'can_publish' => $this->canPublish());
         setcookie(COOKIE_PREFIX . 'vbnexus', serialize($vBNexusInfo));
     }
     return !!$vbulletin->session->created;
 }
示例#2
0
 public function getUserData()
 {
     $appId = vBNexus::getInstance()->getConfig('gfc_key');
     $cookie = $_COOKIE["fcauth{$appId}"];
     if (!$cookie) {
         return array();
     }
     $ch = curl_init("http://www.google.com/friendconnect/api/people/@viewer/@self?fcauth={$cookie}");
     $options = array(CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 10, CURLOPT_MAXREDIRS => 3);
     curl_setopt_array($ch, $options);
     $content = curl_exec($ch);
     if (curl_error($ch) || !$content) {
         return array();
     }
     $profile = @json_decode($content)->entry;
     if (!$profile) {
         return array();
     }
     // $content wasn't a valid json string
     // The returned array needs to have certain keys to make it compatible
     // with other connection services like gfc's (Twitter, Yahoo, etc)
     $data = array('service' => 'Google Friend Connect', 'profile_url' => NULL, 'userid' => $profile->id, 'avatar' => $profile->thumbnailUrl, 'name' => $profile->displayName, 'gender' => NULL, 'email' => NULL, 'timezone' => NULL, 'locale' => NULL);
     return $data;
 }
示例#3
0
 public function register_feedoptions_hooks()
 {
     static $hooks;
     // Don't register these same hooks more than once
     if ($hooks) {
         return false;
     }
     $hooks = array('newthread' => 'newthread_form_complete', 'newpost' => 'newreply_form_complete', 'quickreply' => 'showthread_complete', 'newalbum' => 'album_album_edit', 'newphoto' => 'album_picture_add');
     foreach ($hooks as $hookid => $hook) {
         $vBNexus = vBNexus::getInstance();
         $phpcode = "if (vBNexus::getInstance()->hasFeedOptions())";
         $phpcode .= "vBNexus::getInstance()->addFeedOptions('{$hookid}');";
         $this->registerHook($hook, $phpcode);
     }
     return true;
 }
示例#4
0
 /**
  * Adds the HTML of publish options in the template named $template, by
  * calling preg_replace with the given parameters. $replacement must have
  * the string '$options' in it.
  *
  * @param string $template      Name of the template to write the options into
  * @param string $start         First parameter for preg_replace
  * @param string $replacement   Second parameter for preg_replace
  */
 public function addFeedOptions($event)
 {
     global $vbulletin, $vbphrase;
     switch ($event) {
         case 'newthread':
             // newthread_form_complete
             $template = 'newthread';
             $pattern = '/\\<\\!\\-\\- \\/ message area \\-\\-\\>/';
             $replacement = '\\0$options';
             break;
         case 'newpost':
             // newreply_form_complete
             $template = 'newreply';
             $pattern = '/\\<\\!\\-\\- \\/ message area \\-\\-\\>/';
             $replacement = '\\0$options';
             break;
         case 'quickreply':
             // showthread_complete
             $template = 'SHOWTHREAD';
             $pattern = '/\\<fieldset class=\\\\"fieldset\\\\"/';
             $replacement = '$options\\0';
             break;
         case 'newalbum':
             // album_album_edit
             $template = 'album_edit';
             $pattern = '/\\<\\/td\\>\\<\\/tr\\>\\<\\/table\\>/';
             $replacement = '$options\\0';
             break;
         case 'newphoto':
             // album_picture_add
             $template = 'album_picture_upload';
             $pattern = '/"\\.\\(\\(\\$show\\[\'limit_info\'\\]\\) \\? \\("/';
             $replacement = '$options\\0';
             break;
         default:
             return false;
     }
     // Whether to have checkbox checked by default or not
     // Override admin option if user already checked/unchecked the box
     // (page is reloading, most likely due to an error, i.e. message too short)
     if (!empty($_REQUEST['hdn_vbnexus_publish'])) {
         $checked = $_REQUEST['vbnexus_publish'] ? 'checked="checked"' : '';
     } elseif (vBNexus::getInstance()->getOption('postsfeeds_checked')) {
         $checked = 'checked="checked"';
     }
     // Turn $options in $replacement into the options HTML
     eval('$options = "' . fetch_template('vbnexus_fb_publish_options') . '";');
     $replacement = str_replace('$options', addslashes($options), $replacement);
     $subject = $vbulletin->templatecache[$template];
     $vbulletin->templatecache[$template] = preg_replace($pattern, $replacement, $subject);
     return true;
 }
示例#5
0
 // removed as of ACP-399
 // assign user to usergroup 3 if email needs verification
 //if ($vbulletin->options['verifyemail']){
 //	$newusergroupid = 3;
 //}
 //else
 if ($vbulletin->options['moderatenewmembers'] or $vbulletin->GPC['coppauser']) {
     $newusergroupid = 4;
 } else {
     $newusergroupid = 2;
 }
 if ($fbID) {
     /**
      * ************VBNEXUS************************
      */
     $vBNexus = new vBNexus();
     $vBNexus->init();
     $vBNexus->setConfig('vbnexus_service', "fb");
     $vBNexus->setConfig('vbnexus_userid', $fbID);
     $email = $vbulletin->db->escape_string($vbulletin->GPC['email']);
     $username = $vbulletin->GPC['username'];
     $time = time();
     $publish = $vbulletin->GPC['vbnexus_fb_publish'];
     if (isset($vbulletin->GPC['birthdate'])) {
         $birthday = str_replace("/", "-", $birthday);
     }
     $data = array('type' => "new", 'service' => "fb", 'userid' => $fbID, 'username' => $username, 'password' => md5(time()), 'email' => $email, 'coded_email' => $email, 'default_email' => $email, 'publish' => $publish);
     if (isset($vbulletin->GPC['birthdate'])) {
         $data['birthday'] = $birthday;
     }
     $result = $vBNexus->register($data);