function setVars(&$vars) { global $wgUser; $vars['js'] = HtmlSnips::makeUrlTags('js', array('fblink.js'), '/extensions/wikihow/fblogin', true); $vars['css'] = HtmlSnips::makeUrlTags('css', array('fblink.css'), '/extensions/wikihow/fblogin', true); $facebook = $this->facebook; $result = $facebook->api('/me'); $vars['fbName'] = $this->truncate($result['name']); $vars['fbEmployer'] = $this->truncate($result['work'][0]['employer']['name']); $vars['fbSchool'] = $this->truncate($result['education'][0]['school']['name']); $vars['fbEmail'] = $this->truncate($result['email']); $vars['fbLocation'] = $this->truncate($result['location']['name']); $vars['fbPicUrl'] = FBLogin::getPicUrl($result['id'], 'normal'); $vars['newAcct'] = $wgUser->getName(); $vars['whPicUrl'] = wfGetPad(Avatar::getAvatarURL($wgUser->getName())); $whId = $this->isAlreadyLinked($result['id']); $vars['showWarning'] = $whId ? true : false; $vars['oldAcct'] = $this->getUsername($whId); }
/** * add user via facebook * @param int $id user facebook id. * @param string $token token from facebook. * @param string $sign string from facebook. * @param string $firstname user firstname. * @param string $lastname user lastname. * @param string $email user email */ public function addFacebookUser($id, $token, $sign, $firstname, $lastname, $email) { $arr = $this->escapeString(array($token, $sign, $firstname, $lastname, $email, $id)); $t = $arr[0]; $s = $arr[1]; $f = $arr[2]; $l = $arr[3]; $e = $arr[4]; $i = $arr[5]; $p = md5($arr[5]); // Password is md5(facebook id) $fb = new FBLogin(); $res = $fb->createSession($t, $s); if ($res) { $query = "INSERT INTO users (`user_email`, `user_password`, `user_firstname`, `user_lastname`) \n\t\t\t\t\t\tVALUES ('{$e}', '{$p}', '{$f}', '{$l}')"; if ($this->_db->query($query)) { $user_id = $this->_db->insert_id; $query = "INSERT INTO fb_users (`user_id`, `user_fb_uid`) \n\t\t\t\t\t\tVALUES ('{$user_id}', '{$i}')"; if ($this->_db->query($query)) { Config::$USER_VARIFIED = true; $arr = array(); $arr['success'] = true; $this->activateUser($e); $arr['auth'] = Config::$USER_AUTH; $this->_db->close(); return $arr; } $this->_db->close(); apiConf::$ERROR = 'facebook registary failed'; } $this->_db->close(); apiConf::$ERROR = 'regular facebook registration failed'; } $this->_db->close(); apiConf::$ERROR = 'facebook validation failed'; }