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'); }
public function facebook_connect_avatarAction() { $request = $this->getRequest(); if (!$request->isXmlHttpRequest() || !JO_Session::get('user[user_id]')) { exit('[]'); } $session = JO_Registry::get('facebookapi')->getUser(); if ($session) { $fbData = $this->facebook->api('/me'); if ($fbData) { $ph = new WM_Facebook_Photo(); $image = $ph->getRealUrl('http://graph.facebook.com/' . $fbData['id'] . '/picture?type=large'); $image_info = @getimagesize($image); if ($image_info) { $image_data = @file_get_contents($image); if ($image_data) { JO_Session::set('upload_avatar', array('name' => basename($image), 'type' => $image_info['mime'], 'data' => $image_data)); $this->view->success = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=temporary_avatar&hash=' . microtime(true)); } } } else { $this->view->error = $this->translate('There is no established connection with facebook!'); } } else { $this->view->error = $this->translate('There is no established connection with facebook!'); } echo $this->renderScript('json'); }
public function indexAction() { $request = $this->getRequest(); $invate = Model_Users::checkInvateFacebook($request->getQuery('code')); if (!$invate) { $this->setViewChange('../facebook/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->facebook->setNextUrl( WM_Router::create( $request->getBaseUrl() . '?controller=facebook&action=login&next='.urlencode('/').'&code=' . $request->getQuery('code') ) ); // $this->view->facebook_login_url = $this->facebook->getLoginUrl(); $this->view->facebook_login_url = $this->facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($request->getBaseUrl() . '?controller=facebook&action=login&next=' . urlencode('/') . '&code=' . $request->getQuery('code')), 'req_perms' => 'email,user_birthday,status_update,user_videos,user_status,user_photos,offline_access,read_friendlists')); } $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; }
public function registerAction() { $request = $this->getRequest(); $_SESSION["deportes_url"] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register'); $this->view->deportes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=deportes'); //////////// Categories //////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_status' => 1)); foreach ($categories as $category) { $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']); $this->view->categories[] = $category; } //////////// User Type //////////// $this->view->user_types = array(); $user_types = Model_Users::getUserType(array('filter_status' => 1)); foreach ($user_types as $user_type) { $user_type['subuser_types'] = Model_Users::getSubUserType($user_type['user_type_id']); $this->view->user_types[] = $user_type; } $this->view->user_sports = array(); $users_sports = Model_Users::getUserSports(0); $i = 0; foreach ($users_sports as $user_sports) { if ($user_sports['sport_category'] != 1) { if (!Model_Boards::isCategoryParent($user_sports['sport_category'])) { $this->view->user_sports[] = Model_Boards::getCategoryTitle($user_sports['sport_category']); $i++; } } } //$this->view->sportcounter = $i; 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]'))); } $shared_content = Model_Users::checkSharedContent($request->getParam('key'), $request->getParam('user_id')); if (!JO_Registry::get('enable_free_registration')) { if (!$shared_content) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing')); } } else { $this->view->fb_register = null; $fb_ses = JO_Registry::get('facebookapi'); $session = $fb_ses->getUser(); if (JO_Registry::get('oauth_fb_key') && JO_Registry::get('oauth_fb_secret')) { $this->view->fb_register = $this->facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($request->getBaseUrl() . '?controller=facebook&action=login'), 'req_perms' => 'email,user_birthday,status_update,user_videos,user_status,user_photos,offline_access,read_friendlists')); } } if (JO_Registry::get('oauth_in_key')) { $this->view->instagram_register = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=instagram&action=register&next=' . urlencode(WM_Router::create($request->getBaseUrl() . '?controller=instagram&action=register'))); } $this->view->error = false; if ($request->isPost()) { $validate = new Helper_Validate(); $validate->_set_rules($request->getPost('username'), $this->translate('Username'), 'not_empty;min_length[3];max_length[100];username'); $validate->_set_rules($request->getPost('firstname'), $this->translate('First name'), 'not_empty;min_length[3];max_length[100]'); //$validate->_set_rules($request->getPost('lastname'), $this->translate('Last name'), 'not_empty;min_length[3];max_length[100]'); $validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email'); $validate->_set_rules($request->getPost('password'), $this->translate('Password'), 'not_empty;min_length[4];max_length[30]'); $validate->_set_rules($request->getPost('password2'), $this->translate('Confirm password'), 'not_empty;min_length[4];max_length[30]'); if (!isset($_SESSION['token'])) { if ($request->issetPost('type_user')) { if ($request->getPost('type_user') != 1 && $request->getPost('type_user') != 5 && $request->getPost('type_user') != 12) { $validate->_set_rules($request->getPost('location'), $this->translate('Location'), 'not_empty;min_length[3];max_length[100]'); } } //is_nan() sino /* if($request->getPost('sport_category_1') == "" && $request->getPost('sport_category_2') == "" && $request->getPost('sport_category_3') == "") { $validate->_set_rules($request->getPost('sport_category'), $this->translate('Category_id'), 'not_empty;min_length[3];max_length[100]'); } */ $validate->_set_rules($request->getPost('sports'), $this->translate('Category_id1'), 'not_empty;min_length[3];max_length[100]'); //$validate->_set_rules($request->getPost('sport_category_2'), $this->translate('Category_id2'), 'not_empty;min_length[3];max_length[100]'); //$validate->_set_rules($request->getPost('sport_category_3'), $this->translate('Category_id3'), 'not_empty;min_length[3];max_length[100]'); $validate->_set_rules($request->getPost('type_user'), $this->translate('User_type_id'), 'not_empty;min_length[1];max_length[100]'); } if ($validate->_valid_form()) { if (md5($request->getPost('password')) != md5($request->getPost('password2'))) { $validate->_set_form_errors($this->translate('Password and Confirm Password should be the same')); $validate->_set_valid_form(false); } if (Model_Users::isExistEmail($request->getPost('email'))) { $validate->_set_form_errors($this->translate('This e-mail address is already used')); $validate->_set_valid_form(false); } if (Model_Users::isExistUsername($request->getPost('username'))) { $validate->_set_form_errors($this->translate('This username is already used')); $validate->_set_valid_form(false); } } if ($validate->_valid_form()) { $reg_key = sha1($request->getPost('email') . $request->getPost('username')); $lat = $request->getPost('lat'); $len = $request->getPost('len'); /* while (Model_Users::getUsersLatLen($lat, $len)) { $posLat = strpos($lat, "."); $longLat = strlen(substr((string) $lat, $posLat)); $cantLat = 0; for ($i = 0; $i < ($longLat - 4); $i++) { if ($i == 0) { $cantLat .= ".0"; } else { $cantLat .= "0"; } } $cantLat .= "1"; $lat = $lat + $cantLat; $posLen = strpos($len, "."); $longLen = strlen(substr((string) $len, $posLen)); $cantLen = 0; for ($i = 0; $i < ($longLen - 4); $i++) { if ($i == 0) { $cantLen .= ".0"; } else { $cantLen .= "0"; } } $cantLen .= "1"; $len = $len + $cantLen; } */ $result = Model_Users::create(array('username' => $request->getPost('username'), 'firstname' => $request->getPost('firstname'), 'lastname' => $request->getPost('lastname'), 'email' => $request->getPost('email'), 'password' => $request->getPost('password'), 'delete_email' => isset($shared_content['email']) ? $shared_content['email'] : '', 'delete_code' => isset($shared_content['if_id']) ? $shared_content['if_id'] : '', 'following_user' => isset($shared_content['user_id']) ? $shared_content['user_id'] : '', 'facebook_id' => isset($shared_content['facebook_id']) ? $shared_content['facebook_id'] : 0, 'location' => $request->getPost('location') != "Introduce una ubicación" ? $request->getPost('location') : "", 'sport_category_1' => $request->getPost('sport_category_1'), 'sport_category_2' => $request->getPost('sport_category_2'), 'sport_category_3' => $request->getPost('sport_category_3'), 'type_user' => $request->getPost('type_user'), 'lat' => $lat, 'len' => $len, 'confirmed' => '0', 'regkey' => $reg_key)); if ($result) { for ($i = 0; $i <= $request->getPost('locationcounter'); $i++) { $location = 'location' . $i; $lat = 'lat' . $i; $len = 'len' . $i; if ($request->issetPost($location)) { if ($request->getPost($location) != "") { $lat = $request->getPost($lat); $len = $request->getPost($len); /* while (Model_Users::getLocationUsersLatLen($lat, $len)) { $posLat = strpos($lat, "."); $longLat = strlen(substr((string) $lat, $posLat)); $cantLat = 0; for ($x = 0; $x < ($longLat - 4); $x++) { if ($x == 0) { $cantLat .= ".0"; } else { $cantLat .= "0"; } } $cantLat .= "1"; $lat = $lat + $cantLat; $posLen = strpos($len, "."); $longLen = strlen(substr((string) $len, $posLen)); $cantLen = 0; for ($y = 0; $y < ($longLen - 4); $y++) { if ($y == 0) { $cantLen .= ".0"; } else { $cantLen .= "0"; } } $cantLen .= "1"; $len = $len + $cantLen; } */ if (Model_Users::createUsersLocation($result, $request->getPost($location), $lat, $len)) { } } } } if (Model_Users::editUserSports($result)) { } if (self::sendMail($result)) { self::loginInit($result); } } else { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } else { $this->view->error = $validate->_get_error_messages(); } } $this->view->baseUrl = $request->getBaseUrl(); if ($request->issetPost('email')) { $this->view->email = $request->getPost('email'); } else { if (isset($shared_content['email'])) { $this->view->email = $shared_content['email']; } else { $this->view->email = ''; } } if ($request->issetPost('firstname')) { $this->view->firstname = $request->getPost('firstname'); } else { $this->view->firstname = ''; } if ($request->issetPost('lastname')) { $this->view->lastname = $request->getPost('lastname'); } else { $this->view->lastname = ''; } if ($request->issetPost('username')) { $this->view->username = $request->getPost('username'); } else { $this->view->username = ''; } $this->view->password = $request->getPost('password'); $this->view->password2 = $request->getPost('password2'); $this->view->location = ''; if ($request->issetPost('location')) { $this->view->location = $request->getPost('location'); } else { $this->view->location = ''; } //lat $this->view->lat = ''; if ($request->issetPost('lat')) { $this->view->lat = $request->getPost('lat'); } else { $this->view->lat = ''; } //len $this->view->len = ''; if ($request->issetPost('len')) { $this->view->len = $request->getPost('len'); } else { $this->view->len = ''; } $this->view->cat_title1 = ''; $this->view->sport_category_1 = ''; if ($request->issetPost('sport_category_1')) { $this->view->sport_category_1 = $request->getPost('sport_category_1'); if ($request->getPost('sport_category_1') != "") { if ($request->getPost('sport_category_1') == 1) { $this->view->cat_title1 = "Todo"; } else { $this->view->cat_title1 = Model_Boards::getCategoryTitle($request->getPost('sport_category_1')); } } } else { $this->view->sport_category_1 = ''; } $this->view->cat_title2 = ''; $this->view->sport_category_2 = ''; if ($request->issetPost('sport_category_2')) { $this->view->sport_category_2 = $request->getPost('sport_category_2'); if ($request->getPost('sport_category_2') != "") { if ($request->getPost('sport_category_2') == 1) { $this->view->cat_title2 = "Todo"; } else { $this->view->cat_title2 = Model_Boards::getCategoryTitle($request->getPost('sport_category_2')); } } } else { $this->view->sport_category_2 = ''; } $this->view->cat_title3 = ''; $this->view->sport_category_3 = ''; if ($request->issetPost('sport_category_3')) { $this->view->sport_category_3 = $request->getPost('sport_category_3'); if ($request->getPost('sport_category_3') != "") { if ($request->getPost('sport_category_3') == 1) { $this->view->cat_title3 = "Todo"; } else { $this->view->cat_title3 = Model_Boards::getCategoryTitle($request->getPost('sport_category_3')); } } } else { $this->view->sport_category_3 = ''; } $this->view->usertype_title = ''; $this->view->type_user = ''; if ($request->issetPost('type_user')) { $this->view->type_user = $request->getPost('type_user'); if ($request->getPost('type_user') != "") { $this->view->usertype_title = Model_Users::getUserTypeTitle($request->getPost('type_user')); } } else { $this->view->type_user = ''; } //////////// User location //////////// $this->view->user_location = array(); $this->view->locationcounter = 0; if ($request->issetPost('location1')) { $user_location = array(); for ($i = 1; $i <= $request->getPost('locationcounter'); $i++) { $location = 'location' . $i; $lat = 'lat' . $i; $len = 'len' . $i; if ($request->issetPost($location)) { if ($request->getPost($location) != "") { $user_location[] = $request->getPost($location); } } } $this->view->user_location = $user_location; $this->view->locationcounter = $request->getPost('locationcounter'); } else { $this->view->locationcounter = 0; } // si llama a los deportes if (isset($_SESSION["email"])) { $this->view->email = $_SESSION["email"]; $_SESSION["email"] = null; } if (isset($_SESSION["firstname"])) { $this->view->firstname = $_SESSION["firstname"]; $_SESSION["firstname"] = null; } if (isset($_SESSION["username"])) { $this->view->username = $_SESSION["username"]; $_SESSION["username"] = null; } if (isset($_SESSION["password"])) { $this->view->password = $_SESSION["password"]; $_SESSION["password"] = null; } if (isset($_SESSION["password2"])) { $this->view->password2 = $_SESSION["password2"]; $_SESSION["password2"] = null; } if (isset($_SESSION["location"])) { $this->view->location = $_SESSION["location"]; $_SESSION["location"] = null; } if (isset($_SESSION["lat"])) { $this->view->lat = $_SESSION["lat"]; $_SESSION["lat"] = null; } if (isset($_SESSION["len"])) { $this->view->len = $_SESSION["len"]; $_SESSION["len"] = null; } if (isset($_SESSION["type_user"])) { if ($_SESSION["type_user"] != "") { $this->view->type_user = $_SESSION["type_user"]; $this->view->usertype_title = Model_Users::getUserTypeTitle($_SESSION["type_user"]); } $_SESSION["type_user"] = null; } if (isset($_SESSION["location1"])) { $user_location = array(); for ($i = 1; $i <= $_SESSION['locationcounter']; $i++) { $location = 'location' . $i; $lat = 'lat' . $i; $len = 'len' . $i; if (isset($_SESSION[$location])) { if ($_SESSION[$location] != "") { $user_location[] = $_SESSION[$location]; $_SESSION[$location] = null; } } } $this->view->user_location = $user_location; $this->view->locationcounter = $_SESSION['locationcounter']; $_SESSION['locationcounter'] = null; } $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); }