示例#1
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $settings = Model_Extensions::getSettingsPairs('facebook');
     if (!isset($settings['facebook_login_with_facebook']) || !$settings['facebook_login_with_facebook']) {
         $this->forward('error', 'error404');
     } elseif (!isset($settings['facebook_module_status_enable']) || !$settings['facebook_module_status_enable']) {
         $this->forward('error', 'error404');
     }
     $facebook = new Helper_Modules_Facebook();
     $user_data = $facebook->getUser(true);
     if ($user_data) {
         $modelLogin = new Model_Facebook_Login($user_data['id']);
         $error = true;
         if ($modelLogin->row) {
             $userObject = new Model_Users_User($modelLogin->row['user_id']);
             if ($userObject->count()) {
                 if (JO_Session::get('user[user_id]')) {
                     if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) {
                         JO_Session::set('user', $userObject->toArray());
                     }
                 } else {
                     JO_Session::set('user', $userObject->toArray());
                 }
                 new Model_Users_Edit($modelLogin->row['user_id'], array('last_login' => new JO_Db_Expr('NOW()')));
                 $modelLogin->facebook = $facebook;
                 $modelLogin->update($user_data);
                 if ($request->getQuery('next')) {
                     $this->redirect(urldecode($request->getQuery('next')));
                 } else {
                     $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                 }
             }
         } elseif (Helper_Config::get('enable_free_registration')) {
             $this->forward('modules_facebook_register');
         } elseif (JO_Session::get('user[user_id]')) {
             $this->redirect($request->getBaseUrl());
         }
         $this->setViewChange('no_account');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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 {
         //not session
         $this->setViewChange('error_login');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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']));
         }
     }
 }
 public function indexAction($user_data = null)
 {
     $request = $this->getRequest();
     if (!Helper_Config::get('enable_free_registration')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing'));
     }
     if (JO_Session::get('user[user_id]')) {
         $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
     }
     $settings = Model_Extensions::getSettingsPairs('instagram');
     if (!isset($settings['instagram_register_with_instagram']) || !$settings['instagram_register_with_instagram']) {
         $this->forward('error', 'error404');
     } elseif (!isset($settings['instagram_module_status_enable']) || !$settings['instagram_module_status_enable']) {
         $this->forward('error', 'error404');
     }
     $InstagramAccessToken = JO_Session::get('InstagramAccessToken');
     $user_data = $user_data ? $user_data : JO_Session::get('instagram_user_data');
     if ($user_data && isset($user_data['id']) && $user_data['id']) {
         $modelLogin = new Model_Instagram_Login($user_data['id']);
         if ($modelLogin->row) {
             $userObject = new Model_Users_User($modelLogin->row['user_id']);
             if ($userObject->count()) {
                 if (JO_Session::get('user[user_id]')) {
                     if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) {
                         JO_Session::set('user', $userObject->toArray());
                     }
                 } else {
                     JO_Session::set('user', $userObject->toArray());
                 }
                 $up = $modelLogin->update(array('access_token' => $InstagramAccessToken, 'username' => $user_data['username']));
                 $next = JO_Session::get('instagram_next');
                 if ($next) {
                     $this->redirect(urldecode($next));
                 } else {
                     $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                 }
             }
         }
         if (isset($user_data['profile_picture']) && @getimagesize($user_data['profile_picture'])) {
             $image = $user_data['profile_picture'];
             $user_data['avatar'] = $image;
         } else {
             $image = 'uploads' . Helper_Config::get('no_image');
             $user_data['avatar'];
         }
         $names = explode(' ', $user_data['full_name']);
         $user_data['first_name'] = array_shift($names);
         $user_data['last_name'] = implode(' ', $names);
         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('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]');
             if ($validate->_valid_form()) {
                 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()) {
                 $result = new Model_Users_Create(array('avatar' => $user_data['avatar'], 'website' => isset($user_data['website']) ? $user_data['website'] : '', 'username' => $request->getPost('username'), 'firstname' => isset($user_data['first_name']) ? $user_data['first_name'] : '', 'lastname' => isset($user_data['last_name']) ? $user_data['last_name'] : '', 'email' => $request->getPost('email'), 'password' => $request->getPost('password')));
                 if (!$result->error) {
                     $userObject = new Model_Users_User($result->user_id);
                     JO_Session::set('user', $userObject->toArray());
                     $modelObject = new Model_Instagram_Login();
                     $modelObject->insert(array('username' => $user_data['username'], 'user_id' => $result->user_id, 'oauth_uid' => $user_data['id'], 'access_token' => JO_Session::get('InstagramAccessToken')));
                     $next = JO_Session::get('instagram_next');
                     JO_Session::clear('instagram_user_data');
                     JO_Session::clear('instagram_next');
                     JO_Session::clear('instagram_fnc');
                     if ($next) {
                         $this->redirect(urldecode($next));
                     } else {
                         $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                     }
                 } else {
                     $this->view->error = implode('<br />', $result->error);
                     //$this->translate('There was a problem with the record. Please try again!');
                 }
             } else {
                 $this->view->error = $validate->_get_error_messages();
             }
         }
         $this->view->avatar = $image;
         $this->view->baseUrl = $request->getBaseUrl();
         if ($request->issetPost('email')) {
             $this->view->email = $request->getPost('email');
         } else {
             if (isset($user_data['email'])) {
                 $this->view->email = $user_data['email'];
             } else {
                 $this->view->email = '';
             }
         }
         if ($request->issetPost('username')) {
             $this->view->username = $request->getPost('username');
         } else {
             if (isset($user_data['username'])) {
                 $this->view->username = $user_data['username'];
             } else {
                 $this->view->username = '';
             }
         }
         $this->view->password = $request->getPost('password');
     } else {
         //not session
         $this->setViewChange('../login/error_login');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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']));
         }
     }
     if ($this->getLayout()->meta_title) {
         $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . Helper_Config::get('meta_title'));
     } else {
         $this->getLayout()->placeholder('title', Helper_Config::get('meta_title'));
     }
     if ($this->getLayout()->meta_description) {
         $this->getLayout()->placeholder('description', $this->getLayout()->meta_description);
     } else {
         $this->getLayout()->placeholder('description', Helper_Config::get('meta_description'));
     }
     if ($this->getLayout()->meta_keywords) {
         $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords);
     } else {
         $this->getLayout()->placeholder('keywords', Helper_Config::get('meta_keywords'));
     }
     $this->getLayout()->placeholder('site_name', Helper_Config::get('site_name'));
     $this->view->site_name = Helper_Config::get('site_name');
     $this->view->meta_title = Helper_Config::get('meta_title');
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(Helper_Config::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (Helper_Config::get('site_logo') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . Helper_Config::get('site_logo');
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     $this->view->check_username = WM_Router::create($request->getBaseUrl() . '?controller=modules_instagram_register&action=check_username');
     $this->view->check_email = WM_Router::create($request->getBaseUrl() . '?controller=modules_instagram_register&action=check_email');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#3
0
 public function registerAction()
 {
     $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]')));
     }
     $shared_content = null;
     if (!Helper_Config::get('enable_free_registration')) {
         $invateObject = new Model_Users_Invate();
         $shared_content = $invateObject->isInvated($request->getParam('key'), $request->getParam('user_id'));
         if (!$shared_content) {
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing'));
         }
     }
     $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 ($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()) {
             $result = new Model_Users_Create(array('username' => $request->getPost('username'), 'firstname' => $request->getPost('firstname'), 'lastname' => $request->getPost('lastname'), 'email' => $request->getPost('email'), 'password' => $request->getPost('password')));
             if ($result->user_id) {
                 $user_data = new Model_Users_User($result->user_id);
                 if ($user_data) {
                     if ($shared_content) {
                         $follow = new Model_Users_Follow($result->user_id, $shared_content['user_id']);
                         if (!$follow->is_follow) {
                             $follow->followUser();
                         }
                         $follow = new Model_Users_Follow($shared_content['user_id'], $result->user_id);
                         if (!$follow->is_follow) {
                             $follow->followUser();
                         }
                     }
                     JO_Session::set(array('user' => $user_data->toArray()));
                     $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                 } else {
                     $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                 }
             } 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');
     //extensions
     $this->view->user_login_buttons = array();
     $user_login_buttons = Model_Extensions::getByMethod('user_register');
     foreach ($user_login_buttons as $id => $login) {
         $this->view->user_login_buttons[] = array('html' => $this->view->callChildren('modules_' . $login . '_registerbutton', WM_Router::create($request->getBaseUrl() . '?controller=modules_' . $login . '_register')), 'view' => $this->view->callChildrenView('modules_' . $login . '_registerbutton', WM_Router::create($request->getBaseUrl() . '?controller=modules_' . $login . '_register')), 'key' => $login);
     }
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#4
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $settings = Model_Extensions::getSettingsPairs('instagram');
     if (!isset($settings['instagram_login_with_instagram']) || !$settings['instagram_login_with_instagram']) {
         $this->forward('error', 'error404');
     } elseif (!isset($settings['instagram_module_status_enable']) || !$settings['instagram_module_status_enable']) {
         $this->forward('error', 'error404');
     }
     $instagramoauth = null;
     $this->initInstagram($instagramoauth);
     $InstagramAccessToken = JO_Session::get('InstagramAccessToken');
     $user_data = $this->user_data;
     $settings = Model_Extensions::getSettingsPairs('instagram');
     if (!isset($settings['instagram_login_with_instagram']) || !$settings['instagram_login_with_instagram']) {
         $this->forward('error', 'error404');
     }
     if ($user_data && isset($user_data['id']) && $user_data['id']) {
         $modelLogin = new Model_Instagram_Login($user_data['id']);
         if ($modelLogin->row) {
             $userObject = new Model_Users_User($modelLogin->row['user_id']);
             if ($userObject->count()) {
                 if (JO_Session::get('user[user_id]')) {
                     if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) {
                         JO_Session::set('user', $userObject->toArray());
                     }
                 } else {
                     JO_Session::set('user', $userObject->toArray());
                 }
                 new Model_Users_Edit($modelLogin->row['user_id'], array('last_login' => new JO_Db_Expr('NOW()')));
                 $up = $modelLogin->update(array('access_token' => $InstagramAccessToken, 'username' => $user_data['username']));
                 $next = JO_Session::get('instagram_next');
                 // 					JO_Session::clear('instagram_user_data');
                 // 					JO_Session::clear('instagram_next');
                 // 					JO_Session::clear('instagram_fnc');
                 if ($next) {
                     $this->redirect(urldecode($next));
                 } else {
                     $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                 }
             }
         }
         if ((Helper_Config::get('enable_free_registration') || JO_Session::get('instagram_fnc') == 'connect') && JO_Session::get('instagram_next') && JO_Session::get('instagram_fnc')) {
             $this->redirect(urldecode(JO_Session::get('instagram_next')));
         }
         if (Helper_Config::get('enable_free_registration')) {
             $this->forward('modules_instagram_register', 'index', $user_data);
         }
         $this->setViewChange('no_account');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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 {
         if (JO_Session::get('instagram_fnc') == 'connect' && JO_Session::get('instagram_next')) {
             $this->redirect(urldecode(JO_Session::get('instagram_next')));
         } elseif (Helper_Config::get('enable_free_registration')) {
             $this->forward('modules_instagram_register');
         }
         //not session
         $this->setViewChange('error_login');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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']));
         }
     }
 }
示例#5
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $settings = Model_Extensions::getSettingsPairs('twitter');
     if (!isset($settings['twitter_login_with_twitter']) || !$settings['twitter_login_with_twitter']) {
         $this->forward('error', 'error404');
     } elseif (!isset($settings['twitter_module_status_enable']) || !$settings['twitter_module_status_enable']) {
         $this->forward('error', 'error404');
     }
     $twitteroauth = new Helper_Modules_Twitter(null, null, JO_Session::get('twitter_oauth[oauth_token]'), JO_Session::get('twitter_oauth[oauth_token_secret]'));
     $user_data = JO_Session::get('user_info_twitteroauth');
     if (!$user_data || isset($user_data->errors) && $user_data->errors) {
         $access_token = $twitteroauth->getAccessToken($request->getQuery('oauth_verifier'));
         $user_data = $twitteroauth->get('account/verify_credentials');
         JO_Session::set('user_info_twitteroauth', $user_data);
         JO_Session::set('access_token_twitteroauth', $access_token);
     } else {
         $user_data = JO_Session::get('user_info_twitteroauth');
     }
     if ((!isset($user_data->error) || !$user_data->error) && $user_data->id) {
         $modelLogin = new Model_Twitter_Login($user_data->id);
         if ($modelLogin->row) {
             $userObject = new Model_Users_User($modelLogin->row['user_id']);
             if ($userObject->count()) {
                 if (JO_Session::get('user[user_id]')) {
                     if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) {
                         JO_Session::set('user', $userObject->toArray());
                     }
                 } else {
                     JO_Session::set('user', $userObject->toArray());
                 }
                 new Model_Users_Edit($modelLogin->row['user_id'], array('last_login' => new JO_Db_Expr('NOW()')));
                 $up = $modelLogin->update(array('twitter_oauth_token' => JO_Session::get('twitter_oauth[oauth_token]'), 'twitter_oauth_token_secret' => JO_Session::get('twitter_oauth[oauth_token_secret]'), 'username' => $user_data->screen_name));
                 //JO_Session::clear('user_info_twitteroauth');
                 //JO_Session::clear('access_token_twitteroauth');
                 //JO_Session::get('twitter_oauth');
                 if ($request->getQuery('next')) {
                     $this->redirect(urldecode($request->getQuery('next')));
                 } else {
                     $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                 }
             }
         }
         if ((Helper_Config::get('enable_free_registration') || $request->getQuery('twitter_fnc') == 'connect') && $request->getQuery('next')) {
             $full = html_entity_decode($request->getFullUrl());
             $next = parse_url(urldecode($full));
             if (isset($next['query'])) {
                 parse_str($next['query'], $query);
                 if (isset($query['next']) && $query['next'] && isset($query['twitter_fnc']) && $query['twitter_fnc']) {
                     $this->redirect($query['next']);
                 } elseif (Helper_Config::get('enable_free_registration')) {
                     $this->forward('modules_twitter_register');
                 }
             }
         }
         $this->setViewChange('no_account');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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 {
         if ($request->getQuery('twitter_fnc') == 'connect' && $request->getQuery('next')) {
             $full = html_entity_decode($request->getFullUrl());
             $next = parse_url(urldecode($full));
             if (isset($next['query'])) {
                 parse_str($next['query'], $query);
                 if (isset($query['next']) && $query['next'] && isset($query['twitter_fnc']) && $query['twitter_fnc']) {
                     $this->redirect($query['next']);
                 }
             }
         }
         //not session
         $this->setViewChange('error_login');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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']));
         }
     }
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     if (!Helper_Config::get('enable_free_registration')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing'));
     }
     if (JO_Session::get('user[user_id]')) {
         $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
     }
     $settings = Model_Extensions::getSettingsPairs('facebook');
     if (!isset($settings['facebook_register_with_facebook']) || !$settings['facebook_register_with_facebook']) {
         $this->forward('error', 'error404');
     } elseif (!isset($settings['facebook_module_status_enable']) || !$settings['facebook_module_status_enable']) {
         $this->forward('error', 'error404');
     }
     $user_data = JO_Session::get('facebook_user_data_register');
     if (!$user_data) {
         $facebook = new Helper_Modules_Facebook();
         $user_data = $facebook->getUser(true);
         if ($user_data) {
             $user_data['access_token'] = $facebook->facebook->getAccessToken();
         }
     }
     if ($user_data) {
         $modelObject = new Model_Facebook_Login($user_data['id']);
         if ($modelObject->row) {
             $userObject = new Model_Users_User($modelObject->row['user_id']);
             if ($userObject->count()) {
                 if (JO_Session::get('user[user_id]')) {
                     if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) {
                         JO_Session::set('user', $userObject->toArray());
                     }
                 } else {
                     JO_Session::set('user', $userObject->toArray());
                 }
                 $modelObject->facebook = $facebook;
                 $modelObject->update($user_data);
                 if ($request->getQuery('next')) {
                     $this->redirect(urldecode($request->getQuery('next')));
                 } else {
                     $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                 }
             }
         }
         $shared_content = false;
         if (!Helper_Config::get('enable_free_registration')) {
             $shared_content = $modelObject->checkInvateFacebookID($user_data['id']);
             if (!$shared_content) {
                 $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing'));
             }
         }
         $this->view->avatar = 'uploads' . Helper_Config::get('no_image');
         if (!isset($user_data['avatarimage'])) {
             $ph = new WM_Facebook_Photo();
             $user_data['avatar'] = $ph->getRealUrl('http://graph.facebook.com/' . $user_data['id'] . '/picture?type=large');
             if (!@getimagesize($user_data['avatar'])) {
                 $user_data['avatar'] = '';
             } else {
                 $this->view->avatar = $user_data['avatar'];
             }
         }
         JO_Session::set('facebook_user_data_register', $user_data);
         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('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]');
             if ($validate->_valid_form()) {
                 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()) {
                 $result = new Model_Users_Create(array('gender' => isset($user_data['gender']) ? $user_data['gender'] : '', 'avatar' => $user_data['avatar'], 'location' => isset($user_data['hometown']['name']) ? $user_data['hometown']['name'] : '', 'website' => isset($user_data['website']) ? $user_data['website'] : '', 'username' => $request->getPost('username'), 'firstname' => isset($user_data['first_name']) ? $user_data['first_name'] : '', 'lastname' => isset($user_data['last_name']) ? $user_data['last_name'] : '', 'email' => $request->getPost('email'), 'password' => $request->getPost('password')));
                 if (!$result->error) {
                     $userObject = new Model_Users_User($result->user_id);
                     JO_Session::set('user', $userObject->toArray());
                     $modelObject->insert(array('email' => isset($user_data['email']) ? $user_data['email'] : '', 'user_id' => $result->user_id, 'oauth_uid' => $user_data['id'], 'access_token' => $user_data['access_token']));
                     if ($shared_content) {
                         $modelObject->setInvate(array('self_id' => $result->user_id, 'user_id' => $shared_content['user_id'], 'if_id' => $shared_content['if_id']));
                     }
                     JO_Session::clear('facebook_user_data_register');
                     if (JO_Session::issetKey('next') && JO_Session::get('next')) {
                         $this->redirect(urldecode(JO_Session::get('next')));
                     } else {
                         $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                     }
                 } else {
                     $this->view->error = implode('<br />', $result->error);
                     //$this->translate('There was a problem with the record. Please try again!');
                 }
             } else {
                 $this->view->error = $validate->_get_error_messages();
             }
         }
         $this->view->user_id_fb = $user_data['id'];
         $this->view->baseUrl = $request->getBaseUrl();
         if ($request->issetPost('email')) {
             $this->view->email = $request->getPost('email');
         } else {
             if (isset($user_data['email'])) {
                 $this->view->email = $user_data['email'];
             } else {
                 $this->view->email = '';
             }
         }
         if ($request->issetPost('username')) {
             $this->view->username = $request->getPost('username');
         } else {
             if (isset($user_data['username'])) {
                 $this->view->username = $user_data['username'];
             } else {
                 $this->view->username = '';
             }
         }
         $this->view->password = $request->getPost('password');
     } else {
         //not session
         $this->setViewChange('../login/error_login');
         $page_login_trouble = Model_Pages::getPage(Helper_Config::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']));
         }
     }
     if ($this->getLayout()->meta_title) {
         $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . Helper_Config::get('meta_title'));
     } else {
         $this->getLayout()->placeholder('title', Helper_Config::get('meta_title'));
     }
     if ($this->getLayout()->meta_description) {
         $this->getLayout()->placeholder('description', $this->getLayout()->meta_description);
     } else {
         $this->getLayout()->placeholder('description', Helper_Config::get('meta_description'));
     }
     if ($this->getLayout()->meta_keywords) {
         $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords);
     } else {
         $this->getLayout()->placeholder('keywords', Helper_Config::get('meta_keywords'));
     }
     $this->getLayout()->placeholder('site_name', Helper_Config::get('site_name'));
     $this->view->site_name = Helper_Config::get('site_name');
     $this->view->meta_title = Helper_Config::get('meta_title');
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(Helper_Config::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (Helper_Config::get('site_logo') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . Helper_Config::get('site_logo');
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     $this->view->check_username = WM_Router::create($request->getBaseUrl() . '?controller=modules_facebook_register&action=check_username');
     $this->view->check_email = WM_Router::create($request->getBaseUrl() . '?controller=modules_facebook_register&action=check_email');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
示例#7
0
 public function cronfirstAction()
 {
     set_time_limit(0);
     ignore_user_abort(true);
     $max_id = $this->getRequest()->getParam('max_id');
     $ud = new Model_Users_User($this->getRequest()->getParam('user'));
     if (!$ud->count()) {
         exit;
     }
     JO_Session::set('user', $ud->toArray());
     $connectObject = new Model_Instagram_Login();
     $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
     $InstagramAccessToken = $user_info['access_token'];
     $user_id = $ud['user_id'];
     $instagram_id = $user_info['oauth_uid'];
     // 		$this->initInstagram();
     $params = array('access_token' => $InstagramAccessToken, 'count' => 60, 'max_id' => $max_id ? $max_id : '');
     $result = $this->getMediaData($instagram_id, 300, $params);
     if (isset($result['meta']['code']) && $result['meta']['code'] == 200) {
         $return = (array) $result['data'];
         if ($return) {
             foreach ($return as $img) {
                 list($instagram_media_id, $instagram_profile_id) = explode('_', $img['id']);
                 Model_Instagram_Media::addMedia(array('user_id' => $user_id, 'instagram_media_id' => $instagram_media_id, 'width' => $img['images']['standard_resolution']['width'], 'from' => $img['link'], 'height' => $img['images']['standard_resolution']['height'], 'media' => $img['images']['standard_resolution']['url'], 'instagram_profile_id' => $instagram_profile_id, 'md5key' => md5($img['id']), 'title' => (string) (isset($img['caption']['text']) ? $img['caption']['text'] : $img['user']['username']), 'pin_id' => $this->checkDisabled($img['images']['standard_resolution']['url']) ? '0' : '-1'));
             }
             if (array_key_exists('next_url', $result['pagination'])) {
                 $curl = new JO_Http();
                 $curl->initialize(array('target' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=modules_instagram_media&action=cronfirst&user='******'&user_id=' . $user_id . '&max_id=' . $result['pagination']['next_max_id']), 'method' => 'GET', 'timeout' => 10));
                 $curl->useCurl(true);
                 $curl->execute();
             }
         }
     }
     exit;
 }