Ejemplo n.º 1
0
 public function get_avatarAction()
 {
     $this->noLayout(true);
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]')) {
         $connectObject = new Model_Facebook_Login();
         $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
         $user_id = 0;
         if ($user_info) {
             $user_id = $user_info['oauth_uid'];
         } else {
             $facebookObject = new Helper_Modules_Facebook();
             $user_data = $facebookObject->getUser(true);
             if ($user_data && isset($user_data['id'])) {
                 $user_id = $user_data['id'];
             }
         }
         if ($user_id) {
             $ph = new WM_Facebook_Photo();
             $image = $ph->getRealUrl('http://graph.facebook.com/' . $user_id . '/picture?type=large');
             $image_info = @getimagesize($image);
             if ($image_info) {
                 $image_data = @file_get_contents($image);
                 if ($image_data) {
                     JO_Session::set('upload_avatar', array('name' => basename($image), 'type' => $image_info['mime'], 'data' => $image_data));
                     $this->view->success = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=temporary_avatar&hash=' . microtime(true));
                 }
             }
         } else {
             $this->view->error = $this->translate('There is no established connection with facebook!');
         }
     }
     echo $this->renderScript('json');
 }
Ejemplo n.º 2
0
Archivo: Users.php Proyecto: noikiy/PD
 public static function initSession($user_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from(self::getPrefixDB() . 'users')->where('user_id = ?', (int) $user_id)->limit(1, 0);
     $user_data = $db->fetchRow($query);
     if ($user_data && $user_data['status'] == 'activate') {
         $groups = unserialize($user_data['groups']);
         if (is_array($groups) && count($groups) > 0) {
             $query_group = $db->select()->from(self::getPrefixDB() . 'user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups))));
             $fetch_all = $db->fetchAll($query_group);
             $user_data['access'] = array();
             if ($fetch_all) {
                 foreach ($fetch_all as $row) {
                     $modules = unserialize($row['rights']);
                     if (is_array($modules)) {
                         foreach ($modules as $module => $ison) {
                             $user_data['access'][$module] = $module;
                         }
                     }
                 }
             }
         }
         if (isset($user_data['access']) && count($user_data['access'])) {
             $user_data['is_admin'] = true;
         }
         $db->update(self::getPrefixDB() . 'users', array('last_login_datetime' => new JO_Db_Expr('NOW()'), 'ip_address' => JO_Request::getInstance()->getClientIp()), array('user_id = ?' => (int) $user_id));
         JO_Session::set($user_data);
     }
     return $user_data;
 }
Ejemplo n.º 3
0
 public function logoutAction()
 {
     $this->setInvokeArg('noViewRenderer', true);
     @setcookie('csrftoken_', md5(JO_Session::get('user[user_id]') . $this->getRequest()->getDomain() . JO_Session::get('user[date_added]')), time() - 100, '/', '.' . $this->getRequest()->getDomain());
     JO_Session::set(array('user' => false));
     $this->redirect(JO_Request::getInstance()->getBaseUrl());
 }
Ejemplo n.º 4
0
 public function __construct($to, $type, $pin_id = 0, $board_id = 0, $comment = '')
 {
     if ($to == JO_Session::get('user[user_id]')) {
         return;
     } else {
         if (!JO_Session::get('user[user_id]')) {
             return;
         }
     }
     $history_id = Helper_Db::insert('users_history', array('date_added' => new JO_Db_Expr('NOW()'), 'from_user_id' => (string) JO_Session::get('user[user_id]'), 'to_user_id' => (string) $to, 'history_action' => (int) $type, 'pin_id' => (string) $pin_id, 'board_id' => (string) $board_id, 'comment' => $comment));
     if ($history_id) {
         if (self::FOLLOW == $type) {
             Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::UNFOLLOW, 'board_id = ?' => (string) $board_id));
         } elseif (self::UNFOLLOW == $type) {
             Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::FOLLOW, 'board_id = ?' => (string) $board_id));
         } elseif (self::FOLLOW_USER == $type) {
             Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::UNFOLLOW_USER));
         } elseif (self::UNFOLLOW_USER == $type) {
             Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::FOLLOW_USER));
         } elseif (self::LIKEPIN == $type) {
             Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::UNLIKEPIN, 'pin_id = ?' => (string) $pin_id));
         } elseif (self::UNLIKEPIN == $type) {
             Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::LIKEPIN, 'pin_id = ?' => (string) $pin_id));
         }
     }
 }
Ejemplo n.º 5
0
 public function __construct($pin_id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = self::getListPinsQuery();
     //$query->columns(array('pin_next'=>new JO_Db_Expr('('.$db->select()->from(array('next'=>'pins'),'pin_id')->where('pin_id > ?', (string)$pin_id)->order('pin_id ASC')->limit(1).')')));
     //$query->columns(array('pin_prev'=>new JO_Db_Expr('('.$db->select()->from(array('prev'=>'pins'),'pin_id')->where('pin_id < ?', (string)$pin_id)->order('pin_id DESC')->limit(1).')')));
     if (JO_Session::get('user[user_id]')) {
         $query->columns(array('following_board' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . ')-(' . $db->select()->from('users_following_ignore', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . '))')));
         $query->columns(array('following_user' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . '))')));
         $query->columns(array('following_via' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.via')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.via')->where('board_id = pins.board_id')->limit(1) . '))')));
     } else {
         $query->columns(array('following_board' => new JO_Db_Expr("0")));
         $query->columns(array('following_user' => new JO_Db_Expr("0")));
         $query->columns(array('following_via' => new JO_Db_Expr("0")));
     }
     $rows_source = self::describeTable('pins_sources', 'source_');
     $query->joinLeft('pins_sources', 'pins.source_id = pins_sources.source_id', $rows_source);
     $query->where('pins.pin_id = ?', (string) $pin_id);
     //v2.2
     if (Helper_Config::get('config_enable_follow_private_profile')) {
         $query = self::filterFriend($query);
     }
     $response = $db->fetchRow($query);
     $response = is_array($response) ? $response : array();
     $this->data = $response;
     // 		parent::__construct($response);
 }
Ejemplo n.º 6
0
Archivo: Pages.php Proyecto: noikiy/PD
 public static function getPageParents($id)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pages')->joinLeft('pages_description', 'pages_description.id = pages.id AND pages_description.lid = \'' . JO_Session::get('language_id') . '\'', array('lid', 'name', 'text'))->where('visible = ?', 'true')->order('sub_of DESC');
     $results = $db->fetchAll($query);
     $return = array();
     $cnt = count($results);
     for ($i = 0; $i < $cnt; $i++) {
         if ($results[$i]['id'] == $id) {
             $return[] = $results[$i];
             $sub_of = $results[$i]['sub_of'];
             break;
         }
     }
     $i--;
     while ($sub_of > 0 && $i >= 0) {
         if ($sub_of == $results[$i]['id']) {
             $return[] = $results[$i];
             $sub_of = $results[$i]['sub_of'];
         }
         $i--;
     }
     $return = array_reverse($return);
     return $return;
 }
Ejemplo n.º 7
0
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     try {
         $db->beginTransaction();
         $data['user_id'] = isset($data['user_id']) ? $data['user_id'] : JO_Session::get('user[user_id]');
         $data['public'] = isset($data['public']) ? (int) $data['public'] : 1;
         $data['date_added'] = date('Y-m-d H:i:s');
         $board_id = Helper_Db::create('boards', $data);
         if (!$board_id) {
             return $this;
         }
         Helper_Db::insert('users_boards', array('user_id' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]'), 'board_id' => $board_id, 'is_author' => 1));
         if (isset($data['friends'])) {
             foreach ($data['friends'] as $fr) {
                 Helper_Db::insert('users_boards', array('user_id' => $fr, 'board_id' => $board_id));
             }
         }
         $config_private_boards = Helper_Config::get('config_private_boards');
         Helper_Db::update('users', array('boards' => new JO_Db_Expr("(SELECT COUNT(board_id) FROM boards WHERE user_id = '" . (isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]')) . "' " . ($config_private_boards ? ' AND public = 1' : '') . ")")), array('user_id = ?' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]')));
         ////autoseo
         new Model_Boards_Autoseo($board_id);
         $this->board_id = $board_id;
         $db->commit();
     } catch (JO_Exception $e) {
         $db->rollBack();
         $this->error = $e->getMessage();
     }
 }
Ejemplo n.º 8
0
 public function autocompleteAction()
 {
     $request = $this->getRequest();
     $this->view->items = array();
     if (JO_Session::get('user[user_id]') && $request->getPost('value')) {
         $methods = glob(dirname(__FILE__) . '/Search/*.php');
         if ($methods) {
             foreach ($methods as $file) {
                 $controller = basename($file, '.php');
                 $class_name = 'Search_' . $controller;
                 if (!class_exists($class_name, false)) {
                     JO_Loader::loadFile($file);
                 }
                 $class = new $class_name();
                 if (method_exists($class, 'autocomplete')) {
                     $this->view->items = array_merge($this->view->items, $class->autocomplete($request->getPost('value')));
                 }
             }
         }
     }
     $this->view->items[] = array('template' => 'global', 'label' => sprintf($this->translate('Search for %s'), $request->getPost('value')), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=search&q=' . $request->getPost('value')));
     if ($request->isXmlHttpRequest()) {
         echo $this->renderScript('json');
     } else {
         $this->forward('error', 'error404');
     }
 }
Ejemplo n.º 9
0
 public static function replyMail($data)
 {
     $db = JO_Db::getDefaultAdapter();
     $db->insert('users_mails', array('from_user_id' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]'), 'date_mail' => new JO_Db_Expr('NOW()'), 'text_mail' => (string) $data['text'], 'parent_mail_id' => isset($data['parent']) ? (string) $data['parent'] : 0));
     $mail_id = $db->lastInsertId();
     if (!$mail_id) {
         return false;
     }
     $replies = self::getReplyConversation($data['parent']);
     $recipients = "";
     foreach ($replies as $reply) {
         if ($reply["from_user_id"] != JO_Session::get('user[user_id]')) {
             $pos = strpos($recipients, $reply["from_user_id"] . ",");
             if ($pos === false) {
                 $recipients .= $reply["from_user_id"] . ",";
                 $db->insert('users_mails_to', array('user_id' => $reply["from_user_id"], 'mail_id' => $mail_id));
             }
         }
         if ($reply["user_id"] != JO_Session::get('user[user_id]')) {
             $pos = strpos($recipients, $reply["user_id"] . ",");
             if ($pos === false) {
                 $recipients .= $reply["user_id"] . ",";
                 $db->insert('users_mails_to', array('user_id' => $reply["user_id"], 'mail_id' => $mail_id));
             }
         }
     }
     return array('status' => "OK");
 }
Ejemplo n.º 10
0
 public function resetAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user[user_id]')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
     $done = $request->issetQuery('done');
     if ($done) {
         $this->forward('password', 'done');
     }
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         $validate->_set_rules($request->getPost('email'), $this->translate('E-mail'), 'not_empty;min_length[5];max_length[100];email');
         if ($validate->_valid_form()) {
             $result = Model_Users::forgotPassword($request->getPost('email'));
             if ($result) {
                 if ($result['status']) {
                     $new_password = Model_Users::generatePassword(8);
                     $key_forgot = md5($result['user_id'] . md5($new_password));
                     $add_new_pass = Model_Users::edit($result['user_id'], array('new_password' => $new_password, 'new_password_key' => $key_forgot));
                     if ($add_new_pass) {
                         $is_mail_smtp = JO_Registry::forceGet('config_mail_smtp');
                         $mail = new JO_Mail();
                         if ($is_mail_smtp) {
                             $mail->setSMTPParams(JO_Registry::forceGet('config_mail_smtp_host'), JO_Registry::forceGet('config_mail_smtp_port'), JO_Registry::forceGet('config_mail_smtp_user'), JO_Registry::forceGet('config_mail_smtp_password'));
                         }
                         $this->view->new_password = $new_password;
                         $this->view->user_info = $result;
                         $this->view->forgot_password_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . $result['user_id'] . '&key=' . $key_forgot);
                         $this->view->header_title = JO_Registry::get('site_name');
                         $this->view->base_href = WM_Router::create($request->getBaseUrl());
                         $mail->setFrom(JO_Registry::get('noreply_mail'));
                         $mail->setReturnPath(JO_Registry::get('noreply_mail'));
                         $mail->setSubject($this->translate('Request for forgotten password') . ' ' . JO_Registry::get('site_name'));
                         $mail->setHTML($this->view->render('send_forgot_password_request', 'mail'));
                         $result_send = (int) $mail->send(array($result['email']), $is_mail_smtp ? 'smtp' : 'mail');
                         if ($result_send) {
                             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=password&action=reset&done='));
                         } 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 {
             $this->view->error = $validate->_get_error_messages();
         }
     }
     $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=password&action=reset');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
Ejemplo n.º 11
0
 public static function add($action, $transactionID, $userID = 0)
 {
     if ($userID == 0) {
         $userID = JO_Session::get('user_id');
     }
     $db = JO_Db::getDefaultAdapter();
     $db->insert(Model_Users::getPrefixDB() . 'history', array('user_id' => $userID, 'action' => $action, 'transaction_id' => $transactionID, 'datetime' => new JO_Db_Expr('NOW()')));
     return true;
 }
Ejemplo n.º 12
0
 public function bind($pin_id)
 {
     $req = new JO_Http_Async();
     $request = $this->getRequest();
     $user_login_buttons = $this->getByMethod('pin_oncomplete');
     foreach ($user_login_buttons as $id => $login) {
         $req->curl_get_async($request->getBaseUrl(), array('controller' => 'modules_' . $login . '_pinoncomplete', 'user' => JO_Session::get('user[user_id]'), 'pin' => $pin_id, 'type' => 'edit'));
     }
 }
Ejemplo n.º 13
0
 public static function getHistoryV2($data, $row = 'to_user_id', $user_id = 0)
 {
     $db = JO_Db::getDefaultAdapter();
     if (!$user_id) {
         $user_id = (string) JO_Session::get('user[user_id]');
     }
     $rows_history = self::describeTable('users_history', 'history_');
     $rows_users = self::describeTable('users', 'user_');
     switch (Helper_Config::get('config_user_view')) {
         case 'username':
             $rows_users['user_fullname'] = new JO_Db_Expr('users.username');
             break;
         case 'firstname':
             $rows_users['user_fullname'] = new JO_Db_Expr('users.firstname');
             break;
         case 'fullname':
         default:
             $rows_users['user_fullname'] = new JO_Db_Expr('CONCAT(users.firstname, " ", users.lastname)');
             break;
     }
     $query = $db->select()->from('users_history', $rows_history)->joinLeft('users', ($row == 'to_user_id' ? 'users_history.from_user_id' : 'users_history.to_user_id') . ' = users.user_id', $rows_users)->where($row . ' = ?', $user_id);
     if (isset($data['filter_history_action']) && (int) $data['filter_history_action']) {
         $query->where('users_history.history_action = ?', (int) $data['filter_history_action']);
     }
     if (isset($data['start']) && isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         $query->limit($data['limit'], $data['start']);
     }
     if (isset($data['sort']) && strtolower($data['sort']) == 'asc') {
         $sort = ' ASC';
     } else {
         $sort = ' DESC';
     }
     $allow_sort = array('history_id');
     if (isset($data['order']) && in_array($data['order'], $allow_sort)) {
         $query->order($data['order'] . $sort);
     } else {
         $query->order('history_id' . $sort);
     }
     $results = $db->fetchAll($query);
     $data = array();
     if ($results) {
         foreach ($results as $result) {
             $result['history_text_type'] = self::getType($result['history_history_action']);
             if ($result['history_text_type']) {
                 $result['history_date_dif'] = array_shift(WM_Date::dateDiff($result['history_date_added'], time()));
                 $data[] = $result;
             }
         }
     }
     return $data;
 }
Ejemplo n.º 14
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']));
         }
     }
 }
Ejemplo n.º 15
0
 public function autocomplete($query)
 {
     $request = $this->getRequest();
     $result = array();
     $has_friends = (int) JO_Session::get('user[following]') + (int) JO_Session::get('user[followers]');
     $users = $has_friends ? new Model_Users_SearchAutocomplete(array('filter_username' => $query, 'start' => 0, 'limit' => 100)) : new ArrayObject();
     if ($has_friends && $users->count()) {
         foreach ($users as $user) {
             $result[] = array('template' => 'user', 'avatars' => Helper_Uploadimages::userAvatars($user), 'fullname' => $user['fullname'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']));
         }
     }
     return $result;
 }
Ejemplo n.º 16
0
 public function __construct()
 {
     $request = JO_Request::getInstance();
     parent::__construct();
     if (Model_Allowips::getTotalWords()) {
         if (!Model_Allowips::getTotalWords(array('filete_ip' => $request->getClientIp()))) {
             if (!in_array($request->getController(), array('login', 'error'))) {
                 $this->forward('error', 'noPermission');
             }
         }
     }
     //set default timezone if is not set
     if (!ini_get('date.timezone')) {
         ini_set('date.timezone', 'UTC');
     }
     WM_Users::initSession(JO_Session::get('user[user_id]'));
     if (!JO_Session::get('user[user_id]')) {
         JO_Session::set('user', array('user_id' => 0));
     }
     //admin check login
     $login_page = $request->getController() != 'login';
     if (JO_Session::get('user[is_developer]')) {
         $login_page = false;
     } else {
         if (JO_Session::get('user[is_admin]')) {
             $login_page = false;
         }
     }
     if (in_array($request->getController(), array('login', 'error'))) {
         $login_page = false;
     }
     if ($login_page) {
         $this->forward('login', 'index');
     }
     //admin top menu
     Helper_Config::set('adminmenupermisions', WM_Users::initPermision());
     //no permisions
     $controller_name = JO_Front::getInstance()->formatControllerName($request->getController());
     if (!class_exists($controller_name, false)) {
         JO_Loader::loadFile(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($controller_name));
     }
     if (method_exists($controller_name, 'config')) {
         $data = call_user_func(array($controller_name, 'config'));
         if (isset($data['has_permision']) && $data['has_permision'] && !WM_Users::allow('read', $request->getController())) {
             $this->forward('error', 'noPermission');
         }
     }
     WM_Rebuild::getInformation();
     WM_Licensecheck::checkIt();
 }
Ejemplo n.º 17
0
Archivo: Items.php Proyecto: noikiy/PD
 public function getCategory($id)
 {
     static $result = array();
     if (isset($result[$id])) {
         return $result[$id];
     }
     $db = JO_Db::getDefaultAdapter();
     $query = 'SELECT c.*, cd.name
     		FROM categories c
     		JOIN categories_description cd ON cd.id = c.id AND cd.lid = ' . JO_Session::get('language_id') . '
     		WHERE c.id = ' . $db->quote($id);
     $result[$id] = $db->fetchRow($query);
     return $result[$id];
 }
Ejemplo n.º 18
0
 public function indexAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user_id')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
     if (JO_Session::get('msg_success')) {
         $this->view->msg_error = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     }
     if (JO_Session::get('msg_error')) {
         $this->view->msg_error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     $this->view->questions = $questions = Model_Quiz::getAllQuestions(0, 0, '', 'RAND()');
     $this->view->answers = $answers = Model_Quiz::getAllAnswers(0, 0, '', true);
     if ($request->isPost()) {
         $rightAnswers = 0;
         $user_answers = $request->getPost('answers');
         if (is_array($user_answers)) {
             foreach ($user_answers as $question => $answer) {
                 if (isset($answers[$question][$answer]) && $answers[$question][$answer]['right'] == 'true') {
                     $rightAnswers++;
                 }
             }
         }
         if ($rightAnswers > 0 && count($questions) == $rightAnswers) {
             $_SESSION['user']['quiz'] = 'true';
             JO_Session::set('quiz', 'true');
             Model_Users::updateQuiz(JO_Session::get('user_id'), 'true');
             JO_Session::set('msg_success', 'You have successfully completed the quiz');
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=upload'));
         } else {
             JO_Session::set('msg_error', 'You have to answer all questions correctly. You have ' . $rightAnswers . ' right answers from ' . $question . ' questions');
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=quiz'));
         }
     }
     $this->view->usersCount = Model_Users::countUsers();
     $this->view->itemsCount = Model_Items::countItems();
     $this->getLayout()->meta_title = $this->translate('Quiz');
     $this->getLayout()->meta_description = $this->translate('Quiz');
     $this->view->page_name = $this->translate('Quiz');
     /* CRUMBS */
     $this->view->crumbs = array();
     $this->view->crumbs[] = array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl());
     $this->view->children = array();
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }
Ejemplo n.º 19
0
 public function indexAction()
 {
     if (!WM_Users::allow('edit', 'modules')) {
         JO_Session::set('error_permision', $this->translate('You do not have permission to this action'));
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth/');
     }
     $request = $this->getRequest();
     if (JO_Session::get('successfu_edite')) {
         $this->view->successfu_edite = true;
         JO_Session::clear('successfu_edite');
     }
     if ($request->isPost()) {
         //validate app id
         $validate = new Helper_Modules_Facebook($request->getPost('facebook[facebook_oauth_key]'), $request->getPost('facebook[facebook_oauth_secret]'));
         if ($validate->checkValidAppId()) {
             Model_Settings::updateAll(array('facebook' => $request->getPost('facebook')));
             JO_Session::set('successfu_edite', true);
             $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth_facebook/');
         } else {
             $this->view->error = $this->translate('Invalid appID');
         }
     }
     $this->view->modules_url = $this->getRequest()->getModule() . '/modules';
     $this->view->modules_oauth_url = $this->getRequest()->getModule() . '/modules_oauth';
     $methods = $this->getClassResources();
     $this->view->methods = array();
     $ignore = array('index', 'error404', 'install', 'uninstall');
     foreach ($methods as $type => $mods) {
         foreach ($mods as $key => $value) {
             if (in_array($value, $ignore)) {
                 continue;
             }
             if ($type == 'actions') {
                 $this->view->methods[$type][] = array('title' => $this->translate($value), 'edit' => $this->getRequest()->getModule() . '/modules_oauth_facebook/' . strtolower($value));
             } elseif ($type == 'radio') {
                 $this->view->methods[$type][] = array('title' => $this->translate(str_replace('_', ' ', $value)), 'key' => 'facebook_' . strtolower($value));
             }
         }
     }
     $store_config = Model_Settings::getSettingsPairs(array('filter_group' => 'facebook'));
     foreach ($store_config as $key => $data) {
         if ($request->issetPost('facebook[' . $key . ']')) {
             $this->view->{$key} = $request->getPost('facebook[' . $key . ']');
         } else {
             $this->view->{$key} = $data;
         }
     }
 }
Ejemplo n.º 20
0
 private function getFollowing($query, $data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     $has_pins = 'pins.user_id = ?';
     if (JO_Session::get('user[following]')) {
         $has_pins .= ' OR pins.user_id IN (' . $db->select()->from('users_following', 'following_id')->where('user_id = ?')->where('users_following.board_id = pins.board_id') . ')';
         $has_pins .= ' OR pins.user_id IN (' . $db->select()->from('users_following_user', 'following_id')->where('user_id = ?') . ')';
     }
     $query->where(new JO_Db_Expr($has_pins), JO_Session::get('user[user_id]'));
     if (JO_Session::get('user[following]')) {
         $query->where('pins.board_id NOT IN (SELECT board_id FROM `users_following_ignore` WHERE user_id = ?)', JO_Session::get('user[user_id]'));
     }
     //sort and limit add to query from Model_Pins_Abstract
     $query = self::sortOrderLimit($query, $data);
     return $query;
 }
Ejemplo n.º 21
0
 public function indexAction()
 {
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $this->view->groups = array();
     $groups = Model_Usergroups::getGroups();
     if ($groups) {
         foreach ($groups as $group) {
             $group['description'] = html_entity_decode($group['description'], ENT_QUOTES, 'utf-8');
             $group['nodelete'] = array_key_exists($group['ug_id'], (array) unserialize(JO_Session::get('groups')));
             $this->view->groups[] = $group;
         }
     }
 }
Ejemplo n.º 22
0
 public static function getHistory($data, $row = 'to_user_id', $user_id = 0)
 {
     $db = JO_Db::getDefaultAdapter();
     if (!$user_id) {
         $user_id = (string) JO_Session::get('user[user_id]');
     }
     $query = $db->select()->from('users_history')->where($row . ' = ?', $user_id);
     if (isset($data['filter_history_action']) && (int) $data['filter_history_action']) {
         $query->where('history_action = ?', (int) $data['filter_history_action']);
     }
     if (isset($data['start']) && isset($data['limit'])) {
         if ($data['start'] < 0) {
             $data['start'] = 0;
         }
         $query->limit($data['limit'], $data['start']);
     }
     if (isset($data['sort']) && strtolower($data['sort']) == 'asc') {
         $sort = ' ASC';
     } else {
         $sort = ' DESC';
     }
     $allow_sort = array('history_id');
     if (isset($data['order']) && in_array($data['order'], $allow_sort)) {
         $query->order($data['order'] . $sort);
     } else {
         $query->order('history_id' . $sort);
     }
     //                error_log($query);
     $results = $db->fetchAll($query);
     $data = array();
     if ($results) {
         foreach ($results as $result) {
             $result['text_type'] = self::getType($result['history_action']);
             if ($result['text_type']) {
                 $result['date_dif'] = array_shift(WM_Date::dateDiff($result['date_added'], time()));
                 if ($row == 'to_user_id') {
                     $result['user'] = Model_Users::getUser($result['from_user_id']);
                 } else {
                     $result['user'] = Model_Users::getUser($result['to_user_id']);
                 }
                 $data[] = $result;
             }
         }
     }
     return $data;
 }
Ejemplo n.º 23
0
 public function __construct($ids = array(), $page = 1)
 {
     $db = JO_Db::getDefaultAdapter();
     try {
         $db->beginTransaction();
         $result = 0;
         $plus = (int) (Helper_Config::get('config_front_limit') * $page) - Helper_Config::get('config_front_limit');
         if (is_array($ids)) {
             foreach ($ids as $sort_order => $id) {
                 $result += Helper_Db::update('boards', array('sort_order' => (int) ($sort_order + $plus)), array('board_id = ?' => (string) $id, 'user_id = ?' => JO_Session::get('user[user_id]')));
             }
         }
         $this->affected_rows = $result;
         $db->commit();
     } catch (JO_Exception $e) {
         $db->rollBack();
     }
 }
Ejemplo n.º 24
0
 public function getUser($check = false)
 {
     $connectObject = new Model_Facebook_Login();
     $user_fb = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
     if ($user_fb && $user_fb['access_token']) {
         $this->facebook->setAccessToken($user_fb['access_token']);
     }
     $fbData = $this->facebook->api('/me');
     $this->facebook->setExtendedAccessToken();
     if (isset($fbData['id'])) {
         return $fbData;
     }
     $fbData = $this->facebook->api('/me');
     if (isset($fbData['id'])) {
         return $fbData;
     }
     return false;
 }
Ejemplo n.º 25
0
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     //select default pin data
     $query = self::getListBoardsQuery();
     //v2.2
     if (Helper_Config::get('config_enable_follow_private_profile')) {
         if (JO_Session::get('user[user_id]') && JO_Session::get('user[user_id]') == (string) $data['filter_user_id']) {
             $query->where('boards.user_id = ? OR boards.board_id IN (SELECT board_id FROM users_boards WHERE user_id = ? AND allow = 1 AND (SELECT user_id FROM users WHERE user_id = ? AND public = 1))', (string) JO_Session::get('user[user_id]'));
         } else {
             $query->where('(boards.user_id = ? AND users.public = 1) OR boards.board_id IN (SELECT board_id FROM users_boards WHERE user_id = ? AND allow = 1 AND (SELECT user_id FROM users WHERE user_id = ? AND public = 1))', (string) $data['filter_user_id']);
         }
     } else {
         $query->where('boards.user_id = ? OR boards.board_id IN (SELECT board_id FROM users_boards WHERE user_id = ? AND allow = 1)', (string) $data['filter_user_id']);
     }
     $query = self::sortOrderLimit($query, $data);
     parent::__construct($db->fetchAll($query));
 }
Ejemplo n.º 26
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $rows = array('groups_pin_email', 'comments_email', 'likes_email', 'repins_email', 'follows_email', 'email_interval', 'digest_email', 'news_email');
     $user_data = Model_Users::getUser(JO_Session::get('user[user_id]'));
     if ($request->isPost()) {
         $update = array();
         foreach ($rows as $row) {
             $update[$row] = (int) $request->getRequest($row);
         }
         //			var_dump($update);exit;
         Model_Users::edit(JO_Session::get('user[user_id]'), $update);
         JO_Session::set('successfu_edite', true);
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=settings'));
     }
     $this->view->user_data = $user_data;
     $this->view->settings_href = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
Ejemplo n.º 27
0
    public static function report($id)
    {
        if (!JO_Session::get('user_id')) {
            return false;
        }
        $info = self::get($id);
        if (!$info) {
            return;
        }
        $user = Model_Users::getUser($info['user_id']);
        if (!$user) {
            $user = array('username' => '');
        }
        $db = JO_Db::getDefaultAdapter();
        $db->update('items_comments', array('report_by' => JO_Session::get('user_id')), array('id = ?' => (int) $id));
        $request = JO_Request::getInstance();
        $domain = $request->getDomain();
        $translate = JO_Translate::getInstance();
        $mail = new JO_Mail();
        if (JO_Registry::get('mail_smtp')) {
            $mail->setSMTPParams(JO_Registry::forceGet('mail_smtp_host'), JO_Registry::forceGet('mail_smtp_port'), JO_Registry::forceGet('mail_smtp_user'), JO_Registry::forceGet('mail_smtp_password'));
        }
        $mail->setFrom('no-reply@' . $domain);
        $not_template = Model_Notification::getNotification('comment_report');
        $href = '<a href="' . WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $info['item_id'] . '&filter=' . ($info['reply_to'] ? $info['reply_to'] : $info['id'])) . '">' . $info['item_name'] . '</a>';
        if ($not_template) {
            $title = $not_template['title'];
            $html = html_entity_decode($not_template['template'], ENT_QUOTES, 'utf-8');
            $html = str_replace('{USERNAME}', $user['username'], $html);
            $html = str_replace('{REPORT}', JO_Session::get('username'), $html);
            $html = str_replace('{URL}', $href, $html);
        } else {
            $title = "[" . $domain . "] " . $translate->translate('Have new reported comment');
            $html = nl2br(JO_Session::get('username') . '
					
			 =======================================
			' . $translate->translate('Report about irregularity in comment.'));
        }
        $mail->setSubject($title);
        $mail->setHTML($html);
        $mail->send(array(JO_Registry::get('report_mail')), JO_Registry::get('mail_smtp') ? 'smtp' : 'mail');
        return true;
    }
Ejemplo n.º 28
0
 public function indexAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]')) {
         $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
     }
     if (Helper_Config::get('enable_free_registration')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=register'));
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     if (JO_Session::get('successfu_edite')) {
         $this->view->successfu_edite = true;
         JO_Session::clear('successfu_edite');
     }
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         $validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email');
         if ($validate->_valid_form()) {
             $shared_contentObject = new Model_Users_Invate();
             $shared_content = $shared_contentObject->isInvatedByEmail($request->getPost('email'));
             if ($shared_content == 1) {
                 $this->view->error = $this->translate('This e-mail address is already registered');
             } else {
                 if ($shared_content == 2) {
                     $this->view->error = $this->translate('This e-mail address is already registered');
                 } else {
                     if (($key = Model_Users::addSharedContent($request->getPost('email'))) !== false) {
                         JO_Session::set('successfu_edite', true);
                         if (Helper_Config::get('not_ri')) {
                             Model_Email::send(Helper_Config::get('report_mail'), Helper_Config::get('noreply_mail'), $this->translate('New invitation request'), $this->translate('Hello, there is new invitation request in ') . ' ' . Helper_Config::get('site_name'));
                         }
                         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing'));
                     } else {
                         $this->view->error = $this->translate('There was an error. Please try again later!');
                     }
                 }
             }
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
     }
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
Ejemplo n.º 29
0
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     //select default pin data
     $query = self::getListBoardsQueryLite();
     $query->where("(boards.user_id = ? OR boards.board_id IN (SELECT DISTINCT board_id FROM users_boards WHERE user_id = ? AND allow = 1))", (string) JO_Session::get('user[user_id]'));
     if (isset($data['filter_title']) && $data['filter_title']) {
         $data['filter_title'] = str_replace(' ', '%', $data['filter_title']);
         $data['filter_title'] = preg_replace('/([\\%]{2,})/', '%', $data['filter_title']);
         $query->where('boards.title LIKE ?', '%' . (string) $data['filter_title'] . '%');
     } else {
         $query->where('boards.board_id = 0');
     }
     //v2.2
     if (Helper_Config::get('config_enable_follow_private_profile')) {
         $query = self::filterFriend($query);
     }
     $query = self::sortOrderLimit($query, $data);
     parent::__construct($db->fetchAll($query));
 }
Ejemplo n.º 30
0
 public function unlike()
 {
     if ($this->pin && $this->total) {
         $db = JO_Db::getDefaultAdapter();
         try {
             $db->beginTransaction();
             $result = Helper_Db::delete('pins_likes', array('pin_id = ?' => (string) $this->pin['pin_pin_id'], 'user_id = ?' => (string) JO_Session::get('user[user_id]')));
             if ($result) {
                 $user_id = JO_Session::get('user[user_id]');
                 Helper_Db::update('pins', array('likes' => new JO_Db_Expr('(' . $db->select()->from('pins_likes', 'COUNT(like_id)')->where('pin_id = ?', (string) $this->pin['pin_pin_id'])->limit(1) . ')')), array('pin_id = ?' => (string) $this->pin['pin_pin_id']));
                 Helper_Db::update('users', array('likes' => new JO_Db_Expr('(' . $db->select()->from('pins_likes', 'COUNT(like_id)')->where('user_id = ?', (string) $user_id)->limit(1) . ')')), array('user_id = ?' => (string) $user_id));
             }
             $db->commit();
             return $result;
         } catch (JO_Exception $e) {
             $db->rollBack();
         }
     }
     return false;
 }