Beispiel #1
0
 public function indexAction()
 {
     $this->getLayout()->meta_title = $this->translate('Contacts');
     $this->getLayout()->meta_description = $this->translate('Contacts');
     $request = $this->getRequest();
     if (JO_Session::issetKey('msg_success')) {
         $this->view->is_send = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     } elseif (JO_Session::issetKey('msg_error')) {
         $this->view->error = JO_Session::get('msg_error');
         $this->view->user = JO_Session::get('data');
         JO_Session::clear('msg_error');
         JO_Session::clear('data');
     }
     $this->view->categories = array();
     $categories = Model_Contactscategories::getCategories();
     if ($categories) {
         foreach ($categories as $category) {
             $this->view->categories[$category['id']] = array('id' => $category['id'], 'name' => $category['name'], 'text' => html_entity_decode($category['text'], ENT_QUOTES, 'utf-8'));
         }
     }
     if (empty($this->view->user['username'])) {
         $this->view->user['username'] = JO_Session::get('username');
     }
     if (empty($this->view->user['email'])) {
         $this->view->user['email'] = JO_Session::get('email');
     }
     $this->view->contact_link = WM_Router::create($request->getBaseUrl() . '?controller=contacts&action=send_mail');
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
 private function loginInit($id)
 {
     $user_data = WM_Users::checkLoginFacebookTwitter($id, 'instagram_profile');
     if ($user_data) {
         JO_Session::set(array('user' => $user_data));
         if ($this->instagram) {
             WM_Users::edit2(JO_Session::get('user[user_id]'), array('instagram_token' => $this->instagram->getAccessToken()));
         }
         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()));
         }
     }
     return $user_data;
 }
 public function loginAction()
 {
     $request = $this->getRequest();
     if ($request->getQuery('verify')) {
         $user_data = new Model_Users_User($request->getParam('user_id'));
         $error = false;
         if ($user_data->count() && $user_data['new_email_key'] == $request->getQuery('verify')) {
             $result = new Model_Users_Edit($user_data['user_id'], array('new_email_key' => '', 'email' => $user_data['new_email']));
             if ($result->affected_rows) {
                 JO_Session::set('user', array());
                 JO_Session::set('successful', $this->translate('You verifying your email. Now you can access with the data from e-mail!'));
                 $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
             } else {
                 $error = true;
             }
         } else {
             $error = true;
         }
         if ($error) {
             $this->view->error = $this->translate('There was a problem with the record. Please try again!');
         }
     } else {
         if (!$request->getParam('user_id') || !$request->getQuery('key')) {
             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]')));
             }
         }
     }
     $this->view->successful = false;
     if (JO_Session::get('successful')) {
         $this->view->successful = JO_Session::get('successful');
         JO_Session::clear('successful');
     }
     $this->view->error = false;
     if ($request->getParam('user_id') && $request->getQuery('key')) {
         $user_data = new Model_Users_User($request->getParam('user_id'));
         $error = false;
         if ($user_data->count() && $user_data['new_password_key'] == $request->getQuery('key')) {
             $result = new Model_Users_Edit($user_data['user_id'], array('password' => new JO_Db_Expr('`new_password`'), 'new_password' => '', 'new_password_key' => ''));
             if ($result->affected_rows) {
                 JO_Session::set('user', array());
                 JO_Session::set('successful', $this->translate('You verifying forgotten password. Now you can access with the data from e-mail!'));
                 $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
             } else {
                 $error = true;
             }
         } else {
             $error = true;
         }
         if ($error) {
             $this->view->error = $this->translate('There was a problem with the record. Please try again!');
         }
     }
     $referer = $request->getServer('HTTP_REFERER');
     $this->view->next = urlencode($request->getBaseUrl());
     if ($referer) {
         $data = parse_url($referer);
         if (isset($data['host'])) {
             if (str_replace('www.', '', $data['host']) == $request->getDomain()) {
                 $this->view->next = urlencode($referer);
             }
         }
     }
     if ($request->issetPost('next')) {
         $this->view->next = html_entity_decode($request->getPost('next'));
     } elseif ($request->getQuery('popup') == 'true' && $request->issetQuery('next')) {
         $this->view->next = urlencode(html_entity_decode($request->getQuery('next')));
     }
     $this->view->is_forgot_password = (int) $request->getPost('forgot_password');
     if (JO_Session::issetKey('forgot_password')) {
         $this->view->is_forgot_password = JO_Session::get('forgot_password');
         JO_Session::clear('forgot_password');
     }
     if ($request->isPost() && $request->issetPost('login')) {
         $validate = new Helper_Validate();
         $validate->_set_rules($request->getPost('email'), $this->translate('Email Address'), 'not_empty;min_length[5];max_length[100];email');
         if ($request->getPost('forgot_password') != 1) {
             $validate->_set_rules($request->getPost('password'), $this->translate('Password'), 'not_empty;min_length[4];max_length[30]');
         }
         if ($validate->_valid_form()) {
             if ($request->getPost('forgot_password') == 1) {
                 $result = new Model_Users_UserByEmail($request->getPost('email'));
                 if ($result->count()) {
                     if ($result['status']) {
                         $new_password = JO_Rand::generateRandumString(8);
                         $key_forgot = md5($result['user_id'] . md5($new_password));
                         $add_new_pass = new Model_Users_Edit($result['user_id'], array('new_password' => $new_password, 'new_password_key' => $key_forgot));
                         if ($add_new_pass->affected_rows) {
                             $template = Model_Notification::getTemplate('send_forgot_password_request');
                             if ($template) {
                                 $template_data = array('user_id' => $result['user_id'], 'user_firstname' => $result['firstname'], 'user_lastname' => $result['lastname'], 'user_fullname' => $result['fullname'], 'user_username' => $result['username'], 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'forgot_password_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . $result['user_id'] . '&key=' . $key_forgot), 'new_password' => $new_password, 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
                                 if (!$template['title']) {
                                     $template['title'] = $this->translate('Your new password in') . ' ${site_name}';
                                 }
                                 $template['title'] = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data);
                                 $template['template'] = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data);
                                 $result_send = Model_Email::send($result['email'], Helper_Config::get('noreply_mail'), $template['title'], $template['template']);
                                 if ($result_send) {
                                     JO_Session::set('forgot_password', $this->view->is_forgot_password);
                                     JO_Session::set('successful', $this->translate('Was sent the e-mail with instructions for the new password!'));
                                     $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
                                 } else {
                                     $this->view->error = $this->translate('There was an error. Please try again later!');
                                 }
                             } else {
                                 $this->view->error = $this->translate('There was an error. Please try again later!');
                             }
                         } else {
                             $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                         }
                     } else {
                         $this->view->error = $this->translate('This profile is not active.');
                     }
                 } else {
                     $this->view->error = $this->translate('E-mail address was not found!');
                 }
             } else {
                 $result = new Model_Users_Login($request->getPost('email'), $request->getPost('password'));
                 if ($result->count()) {
                     if ($result['status']) {
                         //@setcookie('csrftoken_', md5($result['user_id'] . $request->getDomain() . $result['date_added'] ), (time() + ((86400*366)*5)), '/', '.'.$request->getDomain());
                         JO_Session::set(array('user' => $result->toArray()));
                         $this->redirect(urldecode($this->view->next));
                     } else {
                         $this->view->error = $this->translate('This profile is not active.');
                     }
                 } else {
                     $this->view->error = $this->translate('E-mail address and password do not match');
                 }
             }
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
     }
     $this->view->login_login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     //extensions
     $this->view->user_login_buttons = array();
     $user_login_buttons = Model_Extensions::getByMethod('user_login');
     foreach ($user_login_buttons as $id => $login) {
         $this->view->user_login_buttons[] = array('html' => $this->view->callChildren('modules_' . $login . '_loginbutton', $this->view->next), 'view' => $this->view->callChildrenView('modules_' . $login . '_loginbutton', $this->view->next), 'key' => $login);
     }
     if ($request->getQuery('popup') == 'true') {
         $this->view->site_name = Helper_Config::get('site_name');
         $this->view->meta_title = Helper_Config::get('meta_title');
         $this->view->popup = true;
         $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->setViewChange('loginPopup');
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     } else {
         $this->view->loginPopup = $this->view->render('loginPopup', 'users');
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
 }
Beispiel #4
0
 public function loginAction()
 {
     if (JO_Session::get('user_id')) {
         $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=dashboard'));
     }
     if (JO_Session::issetKey('msg_error')) {
         $this->view->check_error = JO_Session::get('msg_error');
         $this->view->user = JO_Session::get('data');
         JO_Session::clear('msg_error');
         JO_Session::clear('data');
     }
     $this->view->usersCount = Model_Users::countUsers();
     $this->view->itemsCount = Model_Items::countItems();
     $this->getLayout()->meta_title = $this->translate('Login');
     $this->getLayout()->meta_description = $this->translate('Login');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $result = Model_Users::checkLogin($request->getPost('username'), $request->getPost('password'));
         if ($result) {
             $result['following'] = Model_Users::getFollowers($result['user_id']);
             $groups = unserialize($result['groups']);
             if (is_array($groups) and count($groups) > 1) {
                 unset($result['groups']);
                 $fetch_all = Model_Users::getGroups($groups);
                 $result['access'] = array();
                 if ($fetch_all) {
                     foreach ($fetch_all as $row) {
                         $modules = unserialize($row['rights']);
                         if (is_array($modules)) {
                             foreach ($modules as $module => $ison) {
                                 $result['access'][$module] = $module;
                             }
                         }
                     }
                 }
             }
             if (isset($result['access']) && count($result['access'])) {
                 $result['is_admin'] = true;
             }
             JO_Session::set($result);
             if (JO_Session::get('redirect')) {
                 $this->redirect(JO_Session::get('redirect'));
             } elseif ($request->getServer('HTTP_REFERER')) {
                 $this->redirect($request->getServer('HTTP_REFERER'));
             } else {
                 $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=dashboard'));
             }
         } else {
             JO_Session::set('msg_error', $this->translate('Invalid username or password or the account is not activated.'));
             $request->setParams('username', $request->getPost('username'));
             JO_Session::set('data', $request->getParams());
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
         }
     }
     if ($request->getRequest('command') == 'activate' and $request->getRequest('user') and $request->getRequest('key')) {
         if (Model_Users::checkActivation($request->getRequest('user'), $request->getRequest('key'))) {
             Model_Users::Activate($request->getRequest('user'));
             $result = Model_Users::getByUsername($request->getRequest('user'));
             if ($result) {
                 $groups = unserialize($result['groups']);
                 if (is_array($groups) and count($groups) > 1) {
                     unset($result['groups']);
                     $fetch_all = Model_Users::getGroups($groups);
                     $result['access'] = array();
                     if ($fetch_all) {
                         foreach ($fetch_all as $row) {
                             $modules = unserialize($row['rights']);
                             if (is_array($modules)) {
                                 foreach ($modules as $module => $ison) {
                                     $result['access'][$module] = $module;
                                 }
                             }
                         }
                     }
                 }
                 if (isset($result['access']) && count($result['access'])) {
                     $result['is_admin'] = true;
                 }
                 JO_Session::set($result);
             }
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=verify/completed/yes'));
         }
     }
     $facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret')));
     $this->view->facebook_link = $facebook->getLoginUrl(array('redirect_uri' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=callback_facebook'), 'req_perms' => JO_Registry::forceGet('facebook_req_perms'), 'scope' => JO_Registry::forceGet('facebook_req_perms')));
     $this->view->lost_username = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=lost_username');
     $this->view->reset_password = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=reset_password');
     $this->view->registration = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=registration');
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
Beispiel #5
0
 private function loginInit($id, $session = null)
 {
     $user_data = WM_Users::checkLoginFacebookTwitter($id, 'twitter', $session);
     if ($user_data) {
         JO_Session::set(array('user' => $user_data));
         JO_Session::clear('user_info_twitteroauth');
         JO_Session::clear('access_token_twitteroauth');
         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()));
         }
     }
     return $user_data;
 }
 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('twitter');
     if (!isset($settings['twitter_register_with_twitter']) || !$settings['twitter_register_with_twitter']) {
         $this->forward('error', 'error404');
     } elseif (!isset($settings['twitter_module_status_enable']) || !$settings['twitter_module_status_enable']) {
         $this->forward('error', 'error404');
     }
     $user_data = JO_Session::get('user_info_twitteroauth');
     if ((!isset($user_data->error) || !$user_data->error) && $user_data->id) {
         //check if user is exists
         $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());
                 }
                 $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));
                 if ($request->getQuery('next')) {
                     $this->redirect(urldecode($request->getQuery('next')));
                 } else {
                     $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
                 }
             }
         }
         if (isset($user_data->profile_image_url) && @getimagesize($user_data->profile_image_url)) {
             $image = str_replace('_normal.', '.', $user_data->profile_image_url);
             if (!@getimagesize($image)) {
                 $image = $user_data->profile_image_url;
             }
             $user_data->avatar = $image;
         } else {
             $image = 'uploads' . Helper_Config::get('no_image');
             $user_data->avatar = '';
         }
         $names = explode(' ', $user_data->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, 'location' => isset($user_data->location) ? $user_data->location : '', 'website' => isset($user_data->url) ? $user_data->url : '', '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_Twitter_Login();
                     $modelObject->insert(array('username' => $user_data->screen_name, 'user_id' => $result->user_id, 'oauth_uid' => $user_data->id, 'twitter_oauth_token' => JO_Session::get('twitter_oauth[oauth_token]'), 'twitter_oauth_token_secret' => JO_Session::get('twitter_oauth[oauth_token_secret]')));
                     JO_Session::clear('user_info_twitteroauth');
                     JO_Session::clear('access_token_twitteroauth');
                     JO_Session::get('twitter_oauth');
                     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->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->screen_name)) {
                 $this->view->username = $user_data->screen_name;
             } 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_twitter_register&action=check_username');
     $this->view->check_email = WM_Router::create($request->getBaseUrl() . '?controller=modules_twitter_register&action=check_email');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
 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');
 }
Beispiel #8
0
 /**
  * @return Ambigous <multitype, NULL>|string
  */
 public function isMobile()
 {
     if (JO_Session::issetKey('ismobile')) {
         return JO_Session::get('ismobile');
     }
     $is_mobile = false;
     if (preg_match('/(android|up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($this->getServer('HTTP_USER_AGENT')))) {
         $is_mobile = true;
     }
     if (strpos(strtolower($this->getServer('HTTP_ACCEPT')), 'application/vnd.wap.xhtml+xml') > 0 or ($this->issetServer('HTTP_X_WAP_PROFILE') or $this->issetServer('HTTP_PROFILE'))) {
         $is_mobile = true;
     }
     $mobile_ua = strtolower(substr($this->getServer('HTTP_USER_AGENT'), 0, 4));
     $mobile_agents = array('w3c ', 'acs-', 'alav', 'alca', 'amoi', 'andr', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'inno', 'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki', 'oper', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda', 'xda-');
     if (in_array($mobile_ua, $mobile_agents)) {
         $is_mobile = true;
     }
     if ($this->issetServer('ALL_HTTP')) {
         if (strpos(strtolower($this->getServer('ALL_HTTP')), 'OperaMini') > 0) {
             $is_mobile = true;
         }
     }
     if (strpos(strtolower($this->getServer('HTTP_USER_AGENT')), 'windows') > 0) {
         $is_mobile = false;
     }
     JO_Session::set('ismobile', $is_mobile);
     return $is_mobile;
 }