public function loginAction() { $request = $this->getRequest(); // if( JO_Session::get('user[user_id]') ) { // $this->redirect( WM_Router::create( $request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]') ) ); // } /*if($request->getQuery('session')) { $session = JO_Json::decode( html_entity_decode($request->getQuery('session')), true ); if($session) { $this->facebook->setSession($session); if($request->getQuery('next')) { JO_Session::set('next', $request->getQuery('next')); } } }*/ $session = $this->facebook->getUser(); $fbData = null; if ($session) { $fbData = $this->facebook->api('/me'); } if ($fbData) { if (!isset($fbData['email'])) { $fbData['email'] = ''; } if (!self::loginInit($fbData['id'], $session)) { //if(!self::loginInit($fbData['email'], $session, 'email')) { if (JO_Registry::get('enable_free_registration')) { $this->forward('facebook', 'register', array('fbData' => $fbData, 'session' => $session, 'shared_content' => array())); } $shared_content = Model_Users::checkInvateFacebookID($fbData['id']); if ($shared_content) { $this->forward('facebook', 'register', array('fbData' => $fbData, 'session' => $session, 'shared_content' => $shared_content)); } else { $this->setViewChange('no_account'); $page_login_trouble = Model_Pages::getPage(JO_Registry::get('page_login_trouble')); if ($page_login_trouble) { $this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id'])); } } //} } } else { $this->setViewChange('error_login'); $page_login_trouble = Model_Pages::getPage(JO_Registry::get('page_login_trouble')); if ($page_login_trouble) { $this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id'])); } } $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); }
private function getFriends() { static $results_array = null; if ($results_array !== null) { return $results_array; } // $session = $this->facebook->getSession(); // echo '<pre>';var_dump($session); exit; // echo '<pre>'; // var_dump($session , WM_Date::format($session['expires'],'dd.mm.yy H:i:s'),$session['expires'] < time(), !($me = $this->facebook->api('/me') )); exit; // var_dump( date('d.m.Y H:i:s'), WM_Date::format($session['expires'],'dd.mm.yy H:i:s') ); exit; // if(isset($_REQUEST["code"])) { // //// exit; // } // if($session && $session['expires'] < time()) { // $next = WM_Router::create( $this->getRequest()->getBaseUrl() . '?controller=invites&action=facebook' ); // $this->facebook->setNextUrl( WM_Router::create( $this->getRequest()->getBaseUrl() . '?controller=facebook&action=login&next=' . urlencode($next) ) ); // $url = $this->facebook->getLoginUrl(array('req_perms' => 'user_status,user_photos,offline_access,read_friendlists')); // $this->redirect($url); // } // $this->facebook->setSession($session); $session = $this->facebook->getUser(); // $url = 'https://www.facebook.com/dialog/oauth?access_token='.$session['access_token'].'&client_id='.JO_Registry::get('oauth_fb_key') . '&redirect_uri=' . urlencode(WM_Router::create($this->getRequest()->getBaseUrl() . '?redirect=settings')) . '&scope=user_status,publish_stream,user_photos,offline_access,read_friendlists&state=' . md5(uniqid(rand(), TRUE)); if (!($me = $this->facebook->api('/me'))) { $url = $this->facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=invites&action=facebook'), 'req_perms' => 'email,user_birthday,status_update,user_videos,user_status,user_photos,offline_access,read_friendlists')); $this->redirect($url); } $fbData = null; if ($session) { $fbData = $this->facebook->api('/me/friends?limit=300'); } $results_array = array(); if (isset($fbData['data']) && $fbData['data']) { $results_array = $fbData['data']; } $has_others = true; $pages = 1; while ($has_others) { if ($pages > 10) { $has_others = false; break; } if (isset($fbData['paging']['next'])) { $results = @file_get_contents($fbData['paging']['next'] . '&access_token=' . $session['access_token']); if ($results) { $fbData = json_decode($results, true); if (isset($fbData['data']) && $fbData['data']) { $results_array = array_merge($results_array, $fbData['data']); } else { $fbData = null; $has_others = false; } } else { $fbData = null; $has_others = false; } } else { $fbData = null; $has_others = false; } } return $results_array; }