Esempio n. 1
0
 public function connectAction()
 {
     $request = $this->getRequest();
     $this->noLayout(true);
     $this->view->close_box = false;
     if (JO_Session::get('user[user_id]')) {
         $facebookObject = new Helper_Modules_Facebook();
         if ($request->getQuery('scope')) {
             $facebookObject->scope = $request->getQuery('scope');
         }
         $user_data = $facebookObject->getUser(true);
         $connectObject = new Model_Facebook_Login();
         $connectObject->facebook = $facebookObject->facebook;
         $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
         if ($user_data) {
             $connectObjectCheck = new Model_Facebook_Login($user_data['id']);
             if ($connectObjectCheck->row) {
                 if ($connectObjectCheck->row['user_id'] == JO_Session::get('user[user_id]')) {
                     $enable_action = true;
                 } else {
                     $is_user = new Model_Users_User($connectObjectCheck->row['user_id']);
                     if (!$is_user->count()) {
                         $enable_action = true;
                         $connectObject->deleteDataByUserId($connectObjectCheck->row['user_id']);
                     } else {
                         $enable_action = $this->translate('There is another profile that is associated with your facebook account');
                     }
                 }
             } else {
                 $enable_action = true;
             }
             if ($enable_action === true) {
                 if ($user_info) {
                     if ($connectObject->deleteDataByUserId(JO_Session::get('user[user_id]'))) {
                         $this->view->close_box = true;
                     } else {
                         $this->view->close_box = true;
                     }
                 } else {
                     $res = $connectObject->insert(array('email' => isset($user_data['email']) ? $user_data['email'] : '', 'user_id' => JO_Session::get('user[user_id]'), 'oauth_uid' => $user_data['id'], 'access_token' => $facebookObject->facebook->getAccessToken()));
                     if ($res) {
                         $this->view->close_box = true;
                     } else {
                         $this->view->close_box = true;
                     }
                 }
             } else {
                 JO_Session::set('connect_error', $enable_action);
                 $this->view->close_box = true;
             }
         } else {
             $redirect = $facebookObject->getLoginUrl(WM_Router::create($request->getBaseUrl() . '?controller=settings'), 'modules_facebook_connect&action=connect');
             $this->redirect($redirect);
         }
     } else {
         $this->view->close_box = true;
     }
 }
Esempio n. 2
0
 public function __construct($user_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $user_info = new Model_Users_User($user_id);
     if ($user_info->count()) {
         $config_private_boards = Helper_Config::get('config_private_boards');
         Helper_Db::update('users', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE user_id = users.user_id ' . ($config_private_boards ? ' AND (public = 1 OR user_id = users.user_id)' : '') . ')'), 'boards' => new JO_Db_Expr('(SELECT COUNT(DISTINCT board_id) FROM boards WHERE user_id = users.user_id ' . ($config_private_boards ? ' AND (public = 1 OR user_id = users.user_id)' : '') . ')'), 'likes' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins_likes WHERE user_id = users.user_id)'), 'following' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT following_id) FROM users_following_user WHERE user_id = users.user_id AND following_id != users.user_id LIMIT 1) + (SELECT COUNT(DISTINCT following_id) FROM users_following WHERE user_id = users.user_id AND following_id != users.user_id LIMIT 1) )'), 'followers' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = users.user_id AND user_id != users.user_id LIMIT 1) + (SELECT COUNT(DISTINCT user_id) FROM users_following WHERE following_id = users.user_id AND user_id != users.user_id LIMIT 1) )'), 'latest_pins' => new JO_Db_Expr('( SUBSTRING_INDEX( (SELECT GROUP_CONCAT(pin_id ORDER BY `pin_id` DESC) FROM `pins` WHERE user_id = users.user_id), \',\', 15 ) )')), array('user_id = ?' => $user_id));
     }
 }
Esempio n. 3
0
 public function connectAction()
 {
     $request = $this->getRequest();
     $this->noLayout(true);
     $this->view->close_box = false;
     if (JO_Session::get('user[user_id]')) {
         $instagramoauth = null;
         $this->initInstagram($instagramoauth);
         $user_data = $this->user_data;
         $connectObject = new Model_Instagram_Login();
         $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
         if ($user_data) {
             $connectObjectCheck = new Model_Instagram_Login($user_data['id']);
             if ($connectObjectCheck->row) {
                 if ($connectObjectCheck->row['user_id'] == JO_Session::get('user[user_id]')) {
                     $enable_action = true;
                 } else {
                     $is_user = new Model_Users_User($connectObjectCheck->row['user_id']);
                     if (!$is_user->count()) {
                         $enable_action = true;
                         $connectObject->deleteDataByUserId($connectObjectCheck->row['user_id']);
                     } else {
                         $enable_action = $this->translate('There is another profile that is associated with your instagram account');
                     }
                 }
             } else {
                 $enable_action = true;
             }
             if ($enable_action === true) {
                 if ($user_info) {
                     if ($connectObject->deleteDataByUserId(JO_Session::get('user[user_id]'))) {
                         $this->view->close_box = true;
                     } else {
                         $this->view->close_box = true;
                     }
                 } else {
                     $res = $connectObject->insert(array('username' => $user_data['username'], 'user_id' => JO_Session::get('user[user_id]'), 'oauth_uid' => $user_data['id'], 'access_token' => JO_Session::get('InstagramAccessToken')));
                     if ($res) {
                         $this->view->close_box = true;
                     } else {
                         $this->view->close_box = true;
                     }
                 }
             } else {
                 JO_Session::set('connect_error', $enable_action);
                 $this->view->close_box = true;
             }
         } else {
             $instagramoauth->openAuthorizationUrl();
         }
     }
     $this->view->close_box = true;
 }
Esempio n. 4
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']));
         }
     }
 }
Esempio n. 5
0
 public function __construct($user_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $user_info = new Model_Users_User($user_id);
     if (!$user_info->count()) {
         return $this;
     }
     if (($cleared = trim($this->clear($user_info['username']))) != '') {
         $slug = $uniqueSlug = $cleared;
     } else {
         $slug = $uniqueSlug = 'user';
     }
     Helper_Db::delete('url_alias', array('query = ?' => 'user_id=' . $user_id));
     $uniqueSlug = $this->renameIfExist($uniqueSlug);
     $res = Helper_Db::insert('url_alias', array('query' => 'user_id=' . (int) $user_id, 'keyword' => $uniqueSlug, 'path' => $uniqueSlug, 'route' => 'users/profile'));
     $this->affected_rows = $res;
 }
Esempio n. 6
0
 public function __construct($user_id, $user_id2 = null)
 {
     if ($user_id2 === null) {
         if (!(string) JO_Session::get('user[user_id]') || (string) JO_Session::get('user[user_id]') == $user_id) {
             return $this;
         }
         $user_id2 = JO_Session::get('user[user_id]');
     }
     $this->user_id2 = $user_id2;
     $user_info = new Model_Users_User($user_id);
     if (!$user_info->count()) {
         return $this;
     }
     $this->user_id = $user_id;
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', (string) $this->user_id2)->where('following_id = ?', (string) $user_id)->limit(1);
     $is_follow = $db->fetchOne($query);
     if (!$is_follow) {
         $query = $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', (string) $this->user_id2)->where('following_id = ?', (string) $user_id)->limit(1);
         $is_follow = $db->fetchOne($query);
     }
     $this->is_follow = $is_follow ? true : false;
 }
Esempio n. 7
0
 public static function uploadUserAvatar($avatar, $user_id = 0)
 {
     try {
         $added_date = time();
         $username = md5($user_id);
         $user_info = new Model_Users_User($user_id);
         if ($user_info->count()) {
             $added_date = $user_info['date_added'];
             $username = $user_info['username'];
         }
         if (($imageinfo = @getimagesize($avatar)) !== false) {
             $ext = JO_File_Ext::getExtFromMime($imageinfo['mime']);
             $name = $username . '_' . $user_id . '.' . $ext;
             $image_path = '/users/' . WM_Date::format($added_date, 'yy/mm/');
             //$name = self::rename_if_exists($image_path, $name);
             if (!file_exists(BASE_PATH . '/uploads' . $image_path) || !is_dir(BASE_PATH . '/uploads' . $image_path)) {
                 mkdir(BASE_PATH . '/uploads' . $image_path, 0777, true);
             }
             if (copy($avatar, BASE_PATH . '/uploads' . $image_path . $name)) {
                 if (file_exists(BASE_PATH . '/uploads' . $image_path . $name)) {
                     return array('store' => 'Model_Upload_Locale', 'image' => $image_path . $name, 'width' => 0, 'height' => 0);
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } catch (JO_Exception $e) {
         self::$error = $e->getMessage();
         return false;
     }
     return false;
 }
Esempio n. 8
0
 public function feedAction()
 {
     $request = $this->getRequest();
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $pp = (int) Helper_Config::get('config_front_limit');
     if (!(int) $pp) {
         $pp = 50;
     }
     if ((int) $request->getRequest('per_page') > 0 && (int) $request->getRequest('per_page') < 300) {
         $pp = (int) $request->getRequest('per_page');
     }
     $data = array('start' => $pp * $page - $pp, 'limit' => $pp, 'filter_user_id' => $request->getRequest('user_id'));
     $user_data = new Model_Users_User($request->getRequest('user_id'));
     if ($user_data->count()) {
         JO_Registry::set('meta_title', $user_data['fullname'] . ' - ' . Helper_Config::get('meta_title'));
         if ($user_data['pins']) {
             $pins = new Model_Pins_Users($data);
             $this->view->item = array();
             if ($pins->count()) {
                 $formatObject = new Helper_Format();
                 foreach ($pins->data as $pin) {
                     $pin = $formatObject->fromatList($pin);
                     $category_info = Model_Categories::getCategory($pin['category_id']);
                     if ($category_info) {
                         $pin['text_board'] = $category_info['title'] . ' >> ' . $pin['text_board'];
                     }
                     $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $pin['images']['thumb_image_b'], 'description' => $pin['description'], 'title' => JO_Utf8::splitText($pin['description'], 60, '...'), 'link' => $pin['pin_url'], 'author' => $pin['author_profile']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['text_board']);
                 }
             }
         }
     }
     echo $this->renderScript('rss');
 }
Esempio n. 9
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']));
         }
     }
 }
Esempio n. 10
0
 public function connectAction()
 {
     $request = $this->getRequest();
     $this->noLayout(true);
     $this->view->close_box = false;
     if (JO_Session::get('user[user_id]')) {
         $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 || $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');
         }
         $connectObject = new Model_Twitter_Login();
         $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
         if ($user_data) {
             $connectObjectCheck = new Model_Twitter_Login($user_data->id);
             if ($connectObjectCheck->row) {
                 if ($connectObjectCheck->row['user_id'] == JO_Session::get('user[user_id]')) {
                     $enable_action = true;
                 } else {
                     $is_user = new Model_Users_User($connectObjectCheck->row['user_id']);
                     if (!$is_user->count()) {
                         $enable_action = true;
                         $connectObject->deleteDataByUserId($connectObjectCheck->row['user_id']);
                     } else {
                         $enable_action = $this->translate('There is another profile that is associated with your twitter account');
                     }
                 }
             } else {
                 $enable_action = true;
             }
             if ($enable_action === true) {
                 if ($user_info) {
                     if ($connectObject->deleteDataByUserId(JO_Session::get('user[user_id]'))) {
                         $this->view->close_box = true;
                     } else {
                         $this->view->close_box = true;
                     }
                 } else {
                     $res = $connectObject->insert(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, 'user_id' => JO_Session::get('user[user_id]'), 'oauth_uid' => $user_data->id));
                     if ($res) {
                         $this->view->close_box = true;
                     } else {
                         $this->view->close_box = true;
                     }
                 }
             } else {
                 JO_Session::set('connect_error', $enable_action);
                 $this->view->close_box = true;
             }
         } else {
             $twitteroauth = new Helper_Modules_Twitter();
             $next = WM_Router::create($request->getBaseUrl() . '?controller=modules_twitter_connect&action=connect');
             $request_token = $twitteroauth->getRequestToken(WM_Router::create($request->getBaseUrl() . '?controller=modules_twitter_login&action=forward&twitter_fnc=connect&next=' . $next));
             $request_token_url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
             if ($twitteroauth->http_code == 200) {
                 if (isset($request_token['oauth_token']) && $request_token['oauth_token_secret']) {
                     JO_Session::set('twitter_oauth', $request_token);
                     $this->redirect($request_token_url);
                 }
             }
         }
     }
     $this->view->close_box = true;
 }
Esempio n. 11
0
 public static function uploadUserAvatar($image, $user_id = 0)
 {
     if (($imageinfo = getimagesize($image)) !== false) {
         self::init();
         if (self::$error) {
             return false;
         }
         $added_date = time();
         $username = md5($user_id);
         $user_info = new Model_Users_User($user_id);
         if ($user_info->count()) {
             $added_date = $user_info['date_added'];
             $username = $user_info['username'];
         }
         $ext = strtolower(strrchr($image, "."));
         if (!$ext) {
             $mime_ext = explode('/', $imageinfo['mime']);
             if (isset($mime_ext[1])) {
                 $ext = '.' . $mime_ext[1];
             }
         }
         $name = $username . '_' . $user_id . $ext;
         $image_path = 'avatars/' . WM_Date::format($added_date, 'yy/mm/');
         if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $image_path)) {
             @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $image_path, 0777, true);
         }
         $user_agent = ini_get('user_agent');
         ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
         if (!@copy($image, BASE_PATH . '/uploads/cache_avatars/' . $image_path . $name)) {
             self::$error = self::translate('Unable to upload to the local server!');
             return false;
         }
         ini_set('user_agent', $user_agent);
         $max_width = 0;
         $sizes = self::userThumbSizes();
         $pin_sizes = array();
         if ($sizes) {
             $model_images = new Helper_Images();
             foreach ($sizes as $size => $prefix) {
                 $sizes = explode('x', $size);
                 $pin_sizes[] = array((int) isset($sizes[0]) ? $sizes[0] : 0, (int) isset($sizes[1]) ? $sizes[1] : 0, basename($name, $ext) . $prefix . $ext);
                 $max_width = max($max_width, (int) isset($sizes[0]) ? $sizes[0] : 0);
             }
             if ($max_width) {
                 $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $image_path . $name, $max_width);
                 $thumb_a1 = explode('/uploads/', $thumb_a);
                 if ($thumb_a1 && isset($thumb_a1[1]) && $thumb_a1[1]) {
                     self::upload(BASE_PATH . '/uploads/' . $thumb_a1[1], $image_path . $name);
                     if (self::$error) {
                         return false;
                     }
                     foreach ($pin_sizes as $s) {
                         if (self::$error) {
                             return false;
                         }
                         $thumb_b = '';
                         if ($s[0] && $s[1]) {
                             $thumb_b = $model_images->resize('/' . $thumb_a1[1], $s[0], $s[1], true);
                         } else {
                             if ($s[0] && !$s[1]) {
                                 $thumb_b = $model_images->resizeWidth('/' . $thumb_a1[1], $s[0]);
                             } else {
                                 if (!$s[0] && $s[1]) {
                                     $thumb_b = $model_images->resizeHeight('/' . $thumb_a1[1], $s[1]);
                                 }
                             }
                         }
                         $thumb_b1 = explode('/uploads/', $thumb_b);
                         if ($thumb_b1 && isset($thumb_b1[1]) && $thumb_b1[1]) {
                             self::upload(BASE_PATH . '/uploads/' . $thumb_b1[1], $image_path . $s[2]);
                             if (self::$error) {
                                 return false;
                             }
                         } else {
                             self::$error = self::translate('Unable to upload to the local server!');
                             return false;
                         }
                     }
                     $model_images->deleteImages('/' . $thumb_a1[1]);
                     $model_images->deleteImages('/cache_avatars/' . $image_path . $name);
                     return array('store' => 'Model_Upload_Amazons3', 'image' => $image_path . $name, 'width' => 0, 'height' => 0);
                 } else {
                     self::$error = self::translate('Unable to upload to the local server!');
                     return false;
                 }
             } else {
                 self::$error = self::translate('Missing images sizes!');
                 return false;
             }
         } else {
             self::$error = self::translate('Missing images sizes!');
             return false;
         }
     } else {
         self::$error = self::translate('Image format is not valid!');
         return false;
     }
     self::$error = self::translate('Unknown server error!');
     return false;
 }
Esempio n. 12
0
 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');
 }
Esempio n. 13
0
 public function createAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]')) {
         if ($request->isPost()) {
             $validate = new Helper_Validate();
             $validate->_set_rules($request->getPost('newboard'), $this->translate('Board Name'), 'not_empty;min_length[3];max_length[100]');
             $validate->_set_rules($request->getPost('category_id'), $this->translate('Board Category'), 'not_empty');
             if ($validate->_valid_form()) {
                 $postData = array_merge($request->getPost(), array('title' => $request->getPost('newboard')));
                 if (Helper_Config::get('config_private_boards')) {
                     $postData['public'] = (int) (!$request->issetPost('public'));
                 }
                 $result = new Model_Boards_Create($postData);
                 if ($result->board_id) {
                     $this->view->redirect = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $result->board_id);
                     $this->view->created = true;
                     //send notifications
                     if (is_array($request->getPost('friends'))) {
                         $template = Model_Notification::getTemplate('board_invite');
                         if ($template) {
                             $mail_footer = html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8');
                             foreach ($request->getPost('friends') as $user_id) {
                                 $user = new Model_Users_User($user_id);
                                 if ($user->count()) {
                                     if ($user['email_interval'] == 1 && $user['groups_pin_email']) {
                                         $template_data = array('user_id' => $user['user_id'], 'user_firstname' => $user['firstname'], 'user_lastname' => $user['lastname'], 'user_fullname' => $user['fullname'], 'user_username' => $user['username'], 'author_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')), 'author_fullname' => JO_Session::get('user[fullname]'), 'board_url' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $result->board_id), 'board_name' => $request->getPost('newboard'), 'mail_footer' => $mail_footer);
                                         if (!$template['title']) {
                                             $template['title'] = '${author_fullname} ' . $this->translate('invited you to add pins');
                                         }
                                         $title = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data);
                                         $body = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data);
                                         Model_Email::send($user['email'], Helper_Config::get('noreply_mail'), $title, $body);
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                 }
             } else {
                 $this->view->error = $validate->_get_error_messages();
             }
             echo $this->renderScript('json');
         } else {
             $this->view->avatars = Helper_Uploadimages::userAvatars(JO_Session::get('user'));
             $this->view->fullname = JO_Session::get('user[fullname]');
             $this->view->userhref = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
             $this->view->friends_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
             $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
             $this->view->private = 1;
             /////private boards
             $this->view->enable_private_boards = Helper_Config::get('config_private_boards');
             $private_boards = Model_Pages::getPage(Helper_Config::get('page_private_boards'));
             if ($private_boards) {
                 $this->view->text_private_boards = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . Helper_Config::get('page_private_boards'));
             }
             //////////// Categories ////////////
             $this->view->categories = Model_Categories::getCategories(array('filter_status' => 1));
             $this->view->config_board_description_enable = Helper_Config::get('config_board_description_enable');
             $this->view->popup_main_box = $this->view->render('popup_form', 'boards');
             $this->setViewChange('form');
             if ($request->isXmlHttpRequest()) {
                 $this->view->popup = true;
                 echo $this->view->popup_main_box;
                 $this->noViewRenderer(true);
             } else {
                 $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'layout/left_part');
             }
         }
     } else {
         $this->view->redirect = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         // 			echo $this->renderScript('json');
         $this->setViewChange('redirect');
     }
 }
Esempio n. 14
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;
 }
Esempio n. 15
0
 public static function uploadUserAvatar($image, $user_id = 0)
 {
     if (($imageinfo = getimagesize($image)) !== false) {
         self::init();
         if (self::$error) {
             return false;
         }
         $added_date = time();
         $username = md5($user_id);
         $user_info = new Model_Users_User($user_id);
         if ($user_info->count()) {
             $added_date = $user_info['date_added'];
             $username = $user_info['username'];
         }
         $ext = strtolower(strrchr($image, "."));
         if (!$ext) {
             $mime_ext = explode('/', $imageinfo['mime']);
             if (isset($mime_ext[1])) {
                 $ext = '.' . $mime_ext[1];
             }
         }
         $name = $username . '_' . $user_id . $ext;
         $image_path = 'avatars/' . WM_Date::format($added_date, 'yy/mm/');
         if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $image_path)) {
             @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $image_path, 0777, true);
         }
         $user_agent = ini_get('user_agent');
         ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
         if (!@copy($image, BASE_PATH . '/uploads/cache_avatars/' . $image_path . $name)) {
             self::$error = self::translate('Unable to upload to the local server!');
             return false;
         }
         ini_set('user_agent', $user_agent);
         $max_width = 0;
         $sizes = self::userThumbSizes();
         $pin_sizes = array();
         if ($sizes) {
             $model_images = new Helper_Images();
             foreach ($sizes as $size => $prefix) {
                 $sizes = explode('x', $size);
                 $pin_sizes[] = array((int) isset($sizes[0]) ? $sizes[0] : 0, (int) isset($sizes[1]) ? $sizes[1] : 0, basename($name, $ext) . $prefix . $ext);
                 $max_width = max($max_width, (int) isset($sizes[0]) ? $sizes[0] : 0);
             }
             if ($max_width) {
                 $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $image_path . $name, $max_width);
                 $thumb_a1 = explode('/uploads/', $thumb_a);
                 if ($thumb_a1 && isset($thumb_a1[1]) && $thumb_a1[1]) {
                     $container = Helper_Config::get('rackspace_users_contaners');
                     try {
                         $images = self::$connect->get_container($container);
                         //$images->make_public(86400*365);
                         //$images = self::$connect->get_container($container);
                         //if(!$images->cdn_uri) {
                         //	self::$error = self::translate("Authentication response did not indicate CDN availability");
                         //	return false;
                         //}
                         $object = $images->create_object($name);
                         $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_a1[1]);
                         $image_info = $images->get_object($name);
                         if (!$image_info->name) {
                             self::$error = self::translate('Unable to upload to the server!');
                             return false;
                         }
                         foreach ($pin_sizes as $s) {
                             $thumb_b = '';
                             if ($s[0] && $s[1]) {
                                 $thumb_b = $model_images->resize('/' . $thumb_a1[1], $s[0], $s[1], true);
                             } else {
                                 if ($s[0] && !$s[1]) {
                                     $thumb_b = $model_images->resizeWidth('/' . $thumb_a1[1], $s[0]);
                                 } else {
                                     if (!$s[0] && $s[1]) {
                                         $thumb_b = $model_images->resizeHeight('/' . $thumb_a1[1], $s[1]);
                                     }
                                 }
                             }
                             $thumb_b1 = explode('/uploads/', $thumb_b);
                             if ($thumb_b1 && isset($thumb_b1[1]) && $thumb_b1[1]) {
                                 $object = $images->create_object($s[2]);
                                 $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_b1[1]);
                                 $image_info1 = $images->get_object($s[2]);
                                 if (!$image_info1->name) {
                                     self::$error = self::translate('Unable to upload to the server!');
                                     return false;
                                 }
                             } else {
                                 self::$error = self::translate('Unable to upload to the local server!');
                                 return false;
                             }
                         }
                         return array('store' => 'Model_Upload_Rackspace', 'image' => trim(Helper_Config::get('rackspace_users_contaners_cdn'), '/') . '/' . $image_info->name, 'width' => 0, 'height' => 0);
                     } catch (JO_Exception $e) {
                         self::$error = $e->getMessage();
                         return false;
                     }
                     $model_images->deleteImages('/' . $thumb_a1[1]);
                     $model_images->deleteImages('/cache_avatars/' . $image_path . $name);
                     return array('store' => 'Model_Upload_Amazons3', 'image' => $image_path . $name, 'width' => 0, 'height' => 0);
                 } else {
                     self::$error = self::translate('Unable to upload to the local server!');
                     return false;
                 }
             } else {
                 self::$error = self::translate('Missing images sizes!');
                 return false;
             }
         } else {
             self::$error = self::translate('Missing images sizes!');
             return false;
         }
     } else {
         self::$error = self::translate('Image format is not valid!');
         return false;
     }
     self::$error = self::translate('Unknown server error!');
     return false;
 }
Esempio n. 16
0
 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');
 }
Esempio n. 17
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']));
         }
     }
 }