static function vkd($vkid) { $_SESSION['wravkidamstor'] = $vkid; $_SESSION['wravkidamstor_second'] = md5(wra_fbu::getbrowser()); setcookie('wravkidamstor', $_SESSION['wravkidamstor'], time() + WRA_CONF::$remembertime, '/'); setcookie('wravkidamstor_second', $_SESSION['wravkidamstor_second'], time() + WRA_CONF::$remembertime, '/'); return true; }
function run() { parent::run(); if ($_REQUEST['oauth_token']) { $connection = new TwitterOAuth(WRA_CONF::$twiappid, WRA_CONF::$twiappsecret, $_REQUEST['oauth_token'], $_REQUEST['oauth_verifier']); $token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']); $connection = new TwitterOAuth(WRA_CONF::$twiappid, WRA_CONF::$twiappsecret, $token_credentials['oauth_token'], $token_credentials['oauth_token_secret']); $account = $connection->get('account/verify_credentials'); // WRA::debug($ctwe); if ($account) { // WRA::debug($user); $nu = new wra_twu(); $nu->display_name = htmlspecialchars($account->screen_name, ENT_QUOTES); //$user->name; $nu->regdate = WRA::getcurtime(); $nu->twuserid = $account->id; // $nu->userid = $usr; $nu->username = htmlspecialchars($account->name, ENT_QUOTES); $nu->usersurname = htmlspecialchars($user['last_name'], ENT_QUOTES); $nu->link = $account->url; //$user->link; $nu->user_agent = wra_fbu::getbrowser(); $nu->access_token = $token_credentials['oauth_token']; $nu->email = $token_credentials['oauth_token_secret']; $nu->photo = $account->profile_image_url; if ($account->notifications) { $nu->gender = 0; } else { $nu->gender = 1; } $nu->phone = ''; if (!empty($nu->twuserid)) { if (!wra_twu::istwexist($nu->twuserid)) { $nu->userid = $this->addUsr($nu->username, $nu->usersurname, $nu->phone, $nu->email, "asdf" . time(), $nu->photo); $nu->add(); } else { $nu->loadbytw($nu->twuserid); $nu->update(); } wra_twu::twd($nu->twuserid, $nu->userid); } if (empty($_SESSION['lastpage'])) { WRA::gotopage(WRA::base_url() . '?from=tw&show=no'); } else { WRA::gotopage(WRA::base_url() . $_SESSION['lastpage']); } $_SESSION['lastpage'] = ''; } } else { ?> <a href="<?php WRA::e(wra_twitter::loginLink()); ?> ">login</a><?php } }
static function twd($twid, $userid) { $_SESSION['wratwidraftingbug'] = $twid; $_SESSION['wratwidraftingbug_second'] = md5(wra_fbu::getbrowser()); setcookie('wratwidraftingbug', $_SESSION['wratwidraftingbug'], time() + WRA_CONF::$remembertime, '/'); setcookie('wratwidraftingbug_second', $_SESSION['wratwidraftingbug_second'], time() + WRA_CONF::$remembertime, '/'); $_SESSION['wrauserid'] = $userid; setcookie('wrauserid', $_SESSION['wrauserid'], time() + WRA_CONF::$remembertime, '/'); return true; }
function run() { parent::run(); $code = $_REQUEST["code"]; if (!empty($code)) { // WRA::debug("get fb data"); $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . WRA_CONF::$fbappid . "&redirect_uri=" . urlencode(WRA_CONF::$fbauthlink . '') . "&client_secret=" . WRA_CONF::$fbappsecret . "&code=" . $code; // $usr = $_REQUEST['state']; $response = @file_get_contents($token_url); // WRA::debug($response); $params = null; parse_str($response, $params); // WRA::debug($params); $graph_url = "https://graph.facebook.com/me?fields=id,picture,name,first_name,location,hometown,gender,last_name,link,email&type=large&access_token=" . $params['access_token']; // WRA::debug($graph_url); $user = @json_decode(@file_get_contents($graph_url)); // WRA::debug('asdasda'); // wra_fbu::fbd($user->id); $nu = new wra_fbu(); $nu->display_name = htmlspecialchars($user->name, ENT_QUOTES); $nu->regdate = WRA::getcurtime(); $nu->fbuserid = $user->id; // $nu->userid = $usr; $nu->username = htmlspecialchars($user->first_name, ENT_QUOTES); $nu->usersurname = htmlspecialchars($user->last_name, ENT_QUOTES); $nu->link = htmlspecialchars($user->link, ENT_QUOTES); $nu->user_agent = wra_fbu::getbrowser(); $nu->access_token = $params['access_token']; $nu->email = htmlspecialchars($user->email, ENT_QUOTES); $nu->photo = str_replace("_q", "_n", $user->picture->data->url); if ($user->gender == 'female') { $nu->gender = 1; } else { $nu->gender = 0; } $nu->phone = ''; if (isset($nu->hometown)) { $nu->adres = htmlspecialchars($nu->hometown->name, ENT_QUOTES); } if (isset($nu->location)) { $nu->adres = htmlspecialchars($nu->location->name, ENT_QUOTES); } // WRA::debug($nu);die(); if (!empty($nu->fbuserid)) { if (!wra_fbu::isfbexist($user->id)) { $nu->userid = $this->addUsr($nu->display_name, $nu->usersurname, $nu->phone, $nu->email, "asdf" . time(), $nu->photo); $nu->add(); } else { $nu->loadbyfb($nu->fbuserid); $nu->update(); } wra_fbu::fbd($nu->fbuserid, $nu->userid); // try{ // }catch(Exception $ex){} //print_r($fb); } } // if(empty($_SESSION['lastpage'])){ WRA::gotopage(WRA::base_url() . '?from=fb'); // }else{ // WRA::gotopage(WRA::base_url().$_SESSION['lastpage']); // } $_SESSION['lastpage'] = ''; }