Esempio n. 1
0
 private function getReserved()
 {
     $array = array();
     $array['admin'] = 'admin';
     $array['default'] = 'default';
     $front = JO_Front::getInstance()->getModuleDirectoryWithDefault('default/controllers');
     foreach (WM_Modules::getControllersWithFolders($front) as $controller) {
         $controllerName = JO_Front::getInstance()->formatControllerName($controller);
         $array[$controller] = $controller;
         $array = array_merge($array, WM_Modules::getControllerActions($controllerName, $front));
     }
     $array = JO_Utf8::array_change_key_case_unicode($array);
     return $array;
 }
Esempio n. 2
0
 public static function uploadPin($image, $title = '', $id = 0)
 {
     try {
         if ($title && mb_strlen($title, 'utf-8') > 60) {
             $title = JO_Utf8::splitText($title, 60, '');
         }
         if ($title && mb_strlen($title, 'utf-8') > 60) {
             $title = mb_substr($title, 0, 60, 'utf8');
         }
         $date_added = WM_Date::format(time(), 'yy-mm-dd H:i:s');
         $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 (($imageinfo = @getimagesize($image)) !== false) {
             $ext = JO_File_Ext::getExtFromMime($imageinfo['mime']);
             $ext = '.' . $ext;
             if ($title) {
                 $name = self::translateImage($title) . '_' . md5($image) . '_' . $id . $ext;
             } else {
                 $name = md5($image) . '_' . $id . $ext;
             }
             $image_path = '/pins/' . WM_Date::format($date_added, 'yy/mm/');
             if (!file_exists(BASE_PATH . '/uploads' . $image_path) || !is_dir(BASE_PATH . '/uploads' . $image_path)) {
                 @mkdir(BASE_PATH . '/uploads' . $image_path, 0777, true);
             }
             $name = self::rename_if_exists($image_path, $name);
             // 				Helper_Images::copyFromUrl($image, BASE_PATH . '/uploads' . $image_path . $name);
             if (@copy($image, BASE_PATH . '/uploads' . $image_path . $name)) {
                 ini_set('user_agent', $user_agent);
                 if (file_exists(BASE_PATH . '/uploads' . $image_path . $name)) {
                     return array('store' => 'Model_Upload_Locale', 'image' => $image_path . $name, 'width' => 0, 'height' => 0);
                 } else {
                     self::$error = 'File not found';
                     return false;
                 }
             } else {
                 self::$error = 'Error upload';
                 return false;
             }
         } else {
             self::$error = 'Not valid image';
             return false;
         }
     } catch (JO_Exception $e) {
         self::$error = $e->getMessage();
         return false;
     }
     return false;
 }
Esempio n. 3
0
 public function renameIfExist($uniqueSlug)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('url_alias', array('keyword', 'keyword'))->where('keyword = ?', $uniqueSlug)->orWhere('keyword LIKE ?', $uniqueSlug . '-%');
     $array = $db->fetchPairs($query);
     foreach (WM_Modules::getControllersWithFolders() as $controller) {
         $controllerName = JO_Front::getInstance()->formatControllerName($controller);
         $array[$controller] = $controller;
         $array = array_merge($array, WM_Modules::getControllerActions($controllerName));
     }
     $array['admin'] = 'admin';
     $array['default'] = 'default';
     $array['board'] = 'board';
     $array = JO_Utf8::array_change_key_case_unicode($array);
     return $this->rename_if_exists($array, mb_strtolower($uniqueSlug, 'utf-8'));
 }
Esempio n. 4
0
 public function getTotalKey($keyword)
 {
     $db = JO_Db::getDefaultAdapter();
     $array = array();
     $array['admin'] = 'admin';
     $array['default'] = 'default';
     $front = JO_Front::getInstance()->getModuleDirectoryWithDefault('default/controllers');
     foreach (WM_Modules::getControllersWithFolders($front) as $controller) {
         $controllerName = JO_Front::getInstance()->formatControllerName($controller);
         $array[$controller] = $controller;
         $array = array_merge($array, WM_Modules::getControllerActions($controllerName, $front));
     }
     $array = JO_Utf8::array_change_key_case_unicode($array);
     if (isset($array[mb_strtolower($keyword, 'utf-8')])) {
         return 1;
     }
     $query = $db->select()->from('url_alias', new JO_Db_Expr('COUNT(url_alias_id)'))->where("LOWER(keyword) = ?", (string) mb_strtolower($keyword, 'utf-8'));
     return $db->fetchOne($query);
 }
Esempio n. 5
0
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     //select default pin data
     $query = self::getListPinsQuery();
     if (isset($data['filter_description']) && trim($data['filter_description'])) {
         $words = JO_Utf8::str_word_split(mb_strtolower($data['filter_description'], 'utf-8'), self::$searchWordLenght);
         if (count($words) > 0) {
             $sub = "SELECT `dic_id`, `dic_id` FROM `pins_dictionary` `d` WHERE ( ";
             foreach ($words as $key => $word) {
                 if ($key) {
                     $sub .= ' OR ';
                 }
                 $sub .= "`d`.`word` = " . $db->quote($word) . " OR `d`.`word` LIKE " . $db->quote('%' . $word . '%') . "";
             }
             $sub .= ')';
             $dicts = $db->fetchPairs($sub);
             $tmp_dic_ids = array();
             if (COUNT($dicts) > 0) {
                 $query->joinLeft('pins_invert', 'pins.pin_id = pins_invert.pin_id', 'dic_id')->where('pins_invert.`dic_id` IN (' . implode(',', $dicts) . ')')->group('pins.pin_id');
             } else {
                 $query->where('pins.pin_id = 0');
             }
         } else {
             $query->where('pins.pin_id = 0');
         }
     } else {
         $query->where('pins.pin_id = 0');
     }
     //v2.2
     if (Helper_Config::get('config_enable_follow_private_profile')) {
         $query = self::filterFriend($query);
     }
     //sort and limit add to query from Model_Pins_Abstract
     $query = self::sortOrderLimit($query, $data);
     $this->data = $db->fetchAll($query);
     // 		parent::__construct($db->fetchAll($query));
 }
Esempio n. 6
0
 public static function uploadEventImage($image, $title = '', $user_id = 0)
 {
     try {
         if ($title && mb_strlen($title, 'utf-8') > 60) {
             $title = JO_Utf8::splitText($title, 60, '');
         }
         $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');
         $date_added = WM_Date::format(time(), 'yy-mm-dd H:i:s');
         $s3 = new JO_Api_Amazon(JO_Registry::get('awsAccessKey'), JO_Registry::get('awsSecretKey'));
         $s3->putBucket(JO_Registry::get('bucklet'), JO_Api_Amazon::ACL_PUBLIC_READ);
         if ($s3->getBucketLogging(JO_Registry::get('bucklet'))) {
             if (($imageinfo = getimagesize($image)) !== false) {
                 $pos = strpos($image, "?");
                 // Nótese el uso de ===. Puesto que == simple no funcionará como se espera
                 // porque la posición de 'a' está en el 1° (primer) caracter.
                 if ($pos === false) {
                     // no tiene ? en el nombre de la imagen
                 } else {
                     $pieces = explode("?", $image);
                     $image = $pieces[0];
                 }
                 $ext = strtolower(strrchr($image, "."));
                 if (!$ext) {
                     $mime_ext = explode('/', $imageinfo['mime']);
                     if (isset($mime_ext[1])) {
                         $ext = '.' . $mime_ext[1];
                     }
                 }
                 if ($title) {
                     $name = self::translateImage($title) . '_' . $user_id . $ext;
                 } else {
                     $name = md5($image) . '_' . $user_id . $ext;
                 }
                 $image_path = 'events/' . WM_Date::format($date_added, 'yy/mm/');
                 //					$name = self::rename_if_exists_amazon($image_path, $name);
                 if (!file_exists(BASE_PATH . '/uploads/cache_events/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_events/' . $image_path)) {
                     @mkdir(BASE_PATH . '/uploads/cache_events/' . $image_path, 0777, true);
                 }
                 // 					Helper_Images::copyFromUrl($image, BASE_PATH . '/uploads/cache_events/' . $image_path . $name);
                 @copy($image, BASE_PATH . '/uploads/cache_events/' . $image_path . $name);
                 ini_set('user_agent', $user_agent);
                 //if ( self::uploatToServer(BASE_PATH . '/uploads/cache_events/' . $image_path . $name, $image_path . $name) ) {
                 if (self::uploatToServer(BASE_PATH . '/uploads/cache_events/' . $image_path . $name, $image_path . $name)) {
                     $model_images = new Helper_Images();
                     $temp_width = 0;
                     $temp_height = 0;
                     $sizes = self::pinThumbSizes();
                     if ($sizes) {
                         foreach ($sizes as $size => $prefix) {
                             $sizes = explode('x', $size);
                             $width = (int) isset($sizes[0]) ? $sizes[0] : 0;
                             $height = (int) isset($sizes[1]) ? $sizes[1] : 0;
                             $name_pref = basename($name, $ext) . $prefix . $ext;
                             if ($width && $height) {
                                 $thumb_a = $model_images->resize('/cache_events/' . $image_path . $name, $width, $height, true);
                             } else {
                                 if ($width && !$height) {
                                     $thumb_a = $model_images->resizeWidth('/cache_events/' . $image_path . $name, $width);
                                 } else {
                                     if ($height && !$width) {
                                         $thumb_a = $model_images->resizeHeight('/cache_events/' . $image_path . $name, $height);
                                     }
                                 }
                             }
                             if ($prefix == '_B') {
                                 $temp_width = $model_images->getSizes('width');
                                 $temp_height = $model_images->getSizes('height');
                             }
                             $thumb_a1 = explode('/uploads/', $thumb_a);
                             if ($thumb_a1 && isset($thumb_a1[1])) {
                                 if (!self::uploatToServer(BASE_PATH . '/uploads/' . $thumb_a1[1], $image_path . $name_pref)) {
                                     return false;
                                 }
                             }
                         }
                     }
                     //$model_images->deleteImages('/cache_events/' . $image_path . $name);
                     if ($temp_width) {
                         return array('store' => 'amazons3', 'image' => $image_path . $name, 'width' => $temp_width, 'height' => $temp_height);
                     } else {
                         return false;
                     }
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         }
     } catch (JO_Exception $e) {
         return false;
     }
     return false;
 }
Esempio n. 7
0
 /**
  * @param JO_Db_Select $query
  * @param array $data
  * @return JO_Db_Select
  */
 private static function FilterBuilder(JO_Db_Select $query, $data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     if (isset($data['filter_pin_id']) && $data['filter_pin_id']) {
         $query->where('p.pin_id = ?', (string) $data['filter_pin_id']);
     }
     if (isset($data['filter_user_id']) && $data['filter_user_id']) {
         $query->where('p.user_id = ?', (string) $data['filter_user_id']);
     }
     if (isset($data['filter_fullname']) && $data['filter_fullname']) {
         $query->where('u.firstname LIKE ? OR u.lastname LIKE ?', '%' . $data['filter_fullname'] . '%');
     }
     if (isset($data['filter_username']) && $data['filter_username']) {
         $query->where('u.username LIKE ?', '%' . $data['filter_username'] . '%');
     }
     if (isset($data['filter_board']) && $data['filter_board']) {
         $query->where('b.title LIKE ?', '%' . $data['filter_board'] . '%');
     }
     if (isset($data['filter_board_id']) && !is_null($data['filter_board_id'])) {
         $query->where('p.board_id = ?', (string) $data['filter_board_id']);
     }
     if (isset($data['filter_description']) && $data['filter_description']) {
         $words = JO_Utf8::str_word_split(mb_strtolower($data['filter_description'], 'utf-8'), self::$searchWordLenght);
         if (count($words) > 0) {
             $sub = "SELECT `dic_id`, `dic_id` FROM `pins_dictionary` `d` WHERE ( ";
             foreach ($words as $key => $word) {
                 if ($key) {
                     $sub .= ' OR ';
                 }
                 $sub .= "`d`.`word` = " . $db->quote($word) . " OR MATCH(`d`.`word`) AGAINST (" . $db->quote($word) . ")";
             }
             $sub .= ')';
             $dicts = $db->fetchPairs($sub);
             $tmp_dic_ids = array();
             if (COUNT($dicts) > 0) {
                 $query->joinLeft('pins_invert', 'p.pin_id = pins_invert.pin_id', 'dic_id')->where('pins_invert.`dic_id` IN (' . implode(',', $dicts) . ')')->group('p.pin_id');
             } else {
                 $query->where('p.pin_id = 0');
             }
         } else {
             $query->where('p.pin_id = 0');
         }
     }
     return $query;
 }
Esempio n. 8
0
 public function indexAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user[user_id]')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&popup=true&next=' . urlencode($request->getFullUrl())));
     }
     $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
     $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'order' => 'boards.sort_order', 'sort' => 'ASC', 'friendly' => JO_Session::get('user[user_id]')));
     $this->view->boards = array();
     if ($boards) {
         foreach ($boards as $board) {
             $this->view->boards[] = array('board_id' => $board['board_id'], 'title' => $board['title']);
         }
     }
     //////////// Categories ////////////
     $this->view->categories = array();
     $categories = Model_Categories::getCategories(array('filter_status' => 1));
     foreach ($categories as $category) {
         $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']);
         $this->view->categories[] = $category;
     }
     $this->view->title = JO_Utf8::convertToUtf8($request->getQuery('title'));
     $this->view->url = JO_Utf8::convertToUtf8(urldecode($request->getQuery('url')));
     $this->view->media = JO_Utf8::convertToUtf8($request->getQuery('media'));
     $this->view->is_video = JO_Utf8::convertToUtf8($request->getQuery('is_video'));
     $this->view->description = JO_Utf8::convertToUtf8($request->getQuery('description'));
     $this->view->charset = JO_Utf8::convertToUtf8($request->getQuery('charset'));
     if (!trim($this->view->description)) {
         $this->view->description = $this->view->title;
     }
     if (JO_Session::get('success_added')) {
         $this->view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . JO_Session::get('success_added'));
         $this->setViewChange('success');
         JO_Session::clear('success_added');
     } else {
         if ($request->isPost()) {
             $result = Model_Pins::create(array('title' => $this->view->title, 'from' => $this->view->url, 'image' => $this->view->media, 'is_video' => $this->view->is_video, 'description' => $request->getPost('message'), 'price' => $request->getPost('price'), 'board_id' => $request->getPost('board_id'), 'pinmarklet' => 1));
             if ($result) {
                 Model_History::addHistory(0, Model_History::ADDPIN, $result);
                 $session_user = JO_Session::get('user[user_id]');
                 $group = Model_Boards::isGroupBoard($request->getPost('board_id'));
                 if ($group) {
                     $users = explode(',', $group);
                     foreach ($users as $user_id) {
                         if ($user_id != $session_user) {
                             $user_data = Model_Users::getUser($user_id);
                             if ($user_data && $user_data['email_interval'] == 1 && $user_data['groups_pin_email']) {
                                 $this->view->user_info = $user_data;
                                 $this->view->profile_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
                                 $this->view->full_name = JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]');
                                 $this->view->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result);
                                 $board_info = Model_Boards::getBoard($request->getPost('board_id'));
                                 if ($board_info) {
                                     $this->view->board_title = $board_info['title'];
                                     $this->view->board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                                 }
                                 Model_Email::send($user_data['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('added new pin to a group board'), $this->view->render('group_board', 'mail'));
                             }
                         }
                     }
                 }
                 JO_Session::set('success_added', $result);
                 $this->redirect($request->getBaseUrl() . '?controller=bookmarklet');
             }
         }
     }
 }
Esempio n. 9
0
 public function getActivityAction($user_data = array(), $return_data = false)
 {
     if (!$user_data) {
         $this->forward('error', 'error404');
     }
     $request = $this->getRequest();
     $response = $this->getResponse();
     $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);
     $history = new Model_History_Activity($data, 'from_user_id', $user_data['user_id']);
     $return = array();
     $formatObject = new Helper_Format();
     if ($history->count()) {
         foreach ($history as $key => $row) {
             $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $row['to_user_id']);
             if ($row['history_action'] == Model_History_Abstract::REPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate('Repinned to %s via %s.'), '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>', '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_repin';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::ADDPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate('Pinned to %s.'), '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['activity_class'] = 'a_addpin';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::LIKEPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Liked %s's pin on %s."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_like';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::UNLIKEPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Unliked %s's pin on %s."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', '<a href="' . $row_data['board_url'] . '">' . $row_data['text_board'] . '</a>');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_unlike';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::COMMENTPIN) {
                 $row_data = $formatObject->fromatList($row);
                 $row_data['set_activity_title'] = sprintf($this->translate("Commented on %s's pin and said \"%s\"."), '<a href="' . $via_href . '">' . $row['user_fullname'] . '</a>', JO_Utf8::splitText($row['comment'], 60, '...'));
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_comment';
                 $return[] = $row_data;
             } elseif ($row['history_action'] == Model_History_Abstract::ADDBOARD) {
                 $row['user_user_id'] = $row['from_user_id'];
                 $row_data = $formatObject->fromatListBoard($row);
                 $row_data['set_activity_title'] = $this->translate('Created');
                 $row_data['history_id'] = $row['history_id'];
                 $row_data['activity_class'] = 'a_addboard';
                 $return[] = $row_data;
             } else {
                 if ($row['history_action'] == Model_History_Abstract::FOLLOW_USER) {
                     $row_data = $formatObject->fromatUserFollow($row);
                     $row_data['activity_class'] = 'a_follow_user';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::UNFOLLOW_USER) {
                     $row_data = $formatObject->fromatUserFollow($row);
                     $row_data['activity_class'] = 'a_unfollow_user';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::FOLLOW) {
                     $row['user_user_id'] = $row['from_user_id'];
                     $row_data = $formatObject->fromatListBoard($row);
                     $row_data['set_activity_title'] = $this->translate('Follow');
                     $row_data['history_id'] = $row['history_id'];
                     $row_data['activity_class'] = 'a_follow_board';
                     $return[] = $row_data;
                 } elseif ($row['history_action'] == Model_History_Abstract::UNFOLLOW) {
                     $row['user_user_id'] = $row['from_user_id'];
                     $row_data = $formatObject->fromatListBoard($row);
                     $row_data['set_activity_title'] = $this->translate('Unfollow');
                     $row_data['history_id'] = $row['history_id'];
                     $row_data['activity_class'] = 'a_unfollow_board';
                     $return[] = $row_data;
                 }
             }
         }
     } else {
         if ($page == 1) {
             $message = $this->translate('No activity!');
         } else {
             $message = $this->translate('No more activity!');
         }
         $return[] = $formatObject->fromatListNoResults($message);
     }
     if ($return_data) {
         return $return;
     }
     $formatObject->responseJsonCallback($return);
     $this->noViewRenderer(true);
 }
Esempio n. 10
0
 public function get_imagesAction()
 {
     $request = $this->getRequest();
     $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=get_images');
     $this->view->total_images = 0;
     if ($request->isGet() && $request->getQuery('url')) {
         $http = new JO_Http();
         $http->setUseragent('Amatteur bot v' . JO_Registry::get('system_version'));
         $http->useCurl(true);
         $http->execute($request->getQuery('url'), $request->getBaseUrl(), 'GET');
         $video_url = $request->getQuery('url');
         if (isset($http->headers['location']) && $http->headers['location']) {
             $new_url = $http->headers['location'];
             $http = new JO_Http();
             $http->setUseragent('Amatteur bot v' . JO_Registry::get('system_version'));
             $http->useCurl(true);
             $http->execute($new_url, $request->getBaseUrl(), 'GET');
             $video_url = $new_url;
         }
         $video_url = trim($video_url);
         if (strpos($video_url, 'http') === false) {
             $video_url = 'http://' . $video_url;
         }
         $this->view->from = $video_url;
         if ($http->error) {
             $this->view->error = $http->error;
         } elseif (($imagesize = $this->getimagesize2($video_url)) !== false) {
             $this->view->images[] = array('src' => $video_url, 'width' => $imagesize[0], 'height' => $imagesize[1]);
             $this->view->total_images = 1;
             $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=fromurl');
             $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
             $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'order' => 'boards.sort_order', 'sort' => 'ASC', 'friendly' => JO_Session::get('user[user_id]')));
             $this->view->boards = array();
             if ($boards) {
                 foreach ($boards as $board) {
                     $this->view->boards[] = array('board_id' => $board['board_id'], 'title' => $board['title']);
                 }
             }
             $this->view->is_video = 'false';
             $this->view->title = basename($video_url);
             $this->view->popup_main_box = $this->view->render('from_url', 'addpin');
         } else {
             $html = JO_Utf8::convertToUtf8($http->result);
             $dom = new JO_Dom_Query($html);
             $title = $dom->query('title');
             $this->view->title = '';
             if ($title->innerHtml()) {
                 $this->view->title = trim($title->innerHtml());
             }
             $this->view->images = array();
             $meta_image = $dom->query('meta[property="og:image"]');
             // 				$meta_image_src_dom = $meta_image->rewind();//->getAttribute('content');
             $meta_image_src = null;
             if ($meta_image->count()) {
                 $meta_image_src = $meta_image->rewind()->getAttribute('content');
             }
             if ($meta_image_src) {
                 if (($imagesize = $this->getimagesize2($meta_image_src)) !== false) {
                     if ($imagesize && $imagesize[0] >= 80 && $imagesize[1] >= 80) {
                         $this->view->images[] = array('src' => $meta_image_src, 'width' => $imagesize[0], 'height' => $imagesize[1]);
                     }
                 }
             }
             $images = $dom->query('img');
             if ($images->count() > 0) {
                 $images_array = array();
                 for ($i = 0; $i < $images->count(); $i++) {
                     $src = $images->getItem($i)->getAttribute('src');
                     $image_full = JO_Url_Relativetoabsolute::toAbsolute($request->getQuery('url'), $src);
                     $images_array[$image_full] = $image_full;
                 }
                 foreach ($images_array as $image_full) {
                     $imagesize = $this->getimagesize2($image_full);
                     if ($imagesize && $imagesize[0] >= 80 && $imagesize[1] >= 80) {
                         $this->view->images[] = array('src' => $image_full, 'width' => $imagesize[0], 'height' => $imagesize[1]);
                     }
                 }
             }
             $this->view->total_images = count($this->view->images);
             $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=fromurl');
             $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
             $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'order' => 'boards.sort_order', 'sort' => 'ASC', 'friendly' => JO_Session::get('user[user_id]')));
             $this->view->boards = array();
             if ($boards) {
                 foreach ($boards as $board) {
                     $this->view->boards[] = array('board_id' => $board['board_id'], 'title' => $board['title']);
                 }
             }
             //////////// Categories ////////////
             $this->view->categories = array();
             $categories = Model_Categories::getCategories(array('filter_status' => 1));
             foreach ($categories as $category) {
                 $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']);
                 $this->view->categories[] = $category;
             }
             $this->view->is_video = 'false';
             $help_video = new Helper_AutoEmbed();
             if ($help_video->parseUrl($video_url)) {
                 $this->view->is_video = 'true';
                 if (!count($this->view->images)) {
                     $img = $help_video->getImageURL();
                     $image_full = null;
                     if ($img) {
                         $image_full = $img;
                     } elseif (preg_match('~http://(?:www\\.)?vimeo\\.com/([0-9]{1,12})~imu', $video_url, $match)) {
                         $url = 'http://vimeo.com/api/v2/video/' . $match[1] . '.json?callback=';
                         $http = new JO_Http();
                         $http->setUseragent('Amatteur bot v' . JO_Registry::get('system_version'));
                         $http->useCurl(true);
                         $http->execute($url, $request->getBaseUrl(), 'GET');
                         if ($http->error) {
                             $this->view->error = $http->error;
                         } else {
                             $meta_image = $dom->query('meta[property="og:image"]');
                             $meta_image_src = $meta_image->rewind()->getAttribute('content');
                             if ($meta_image_src && @getimagesize($meta_image->content)) {
                                 $image_full = $meta_image_src;
                             } else {
                                 $data = JO_Json::decode($http->result, true);
                                 if (isset($data[0]['thumbnail_large'])) {
                                     $image_full = $data[0]['thumbnail_large'];
                                 } elseif (isset($data[0]['thumbnail_medium'])) {
                                     $image_full = $data[0]['thumbnail_medium'];
                                 } elseif (isset($data[0]['thumbnail_small'])) {
                                     $image_full = $data[0]['thumbnail_small'];
                                 }
                             }
                         }
                     }
                     if ($image_full && ($imagesize = @getimagesize($image_full))) {
                         if ($imagesize && $imagesize[0] >= 80 && $imagesize[1] >= 80) {
                             $this->view->images[] = array('src' => $image_full, 'width' => $imagesize[0], 'height' => $imagesize[1]);
                         }
                     }
                     $this->view->total_images = count($this->view->images);
                 }
             }
             $this->view->popup_main_box = $this->view->render('from_url', 'addpin');
         }
         if (count($this->view->images) == 0) {
             $this->view->error_total_images = 1;
             $this->view->popup_main_box = $this->view->render('fromurl', 'addpin');
         }
         $this->setViewChange('index');
         if ($request->isXmlHttpRequest()) {
             $this->noViewRenderer(true);
             echo $this->view->popup_main_box;
             //$this->renderScript('json');
         } else {
             $this->view->is_popup = false;
             $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'layout/left_part');
         }
     } else {
         $this->forward('error', 'error404');
     }
 }
Esempio n. 11
0
File: Items.php Progetto: noikiy/PD
 public static function returnViewIndex($item, $view_name = 'index')
 {
     if (!isset($item['module']) || !$item['module']) {
         return;
     }
     $view = JO_View::getInstance();
     if (!isset($item['no_items'])) {
         static $results = array();
         $model_images = new Helper_Images();
         $request = JO_Request::getInstance();
         if (mb_strlen($item['name'], 'UTF-8') > 35) {
             $item['name'] = JO_Utf8::mb_cut_text($item['name'], 0, 35, ' ');
         }
         $item['price'] = WM_Currency::format($item['price']);
         switch ($view_name) {
             case 'category':
                 $height = JO_Registry::forceGet($item['module'] . '_items_preview_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
                 /* CATEGORIES */
                 $cats = array();
                 $categories = Model_Categories::getCategoriesByIds($item['categories']);
                 foreach ($categories as $v) {
                     $cats[] = array('name' => $v['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=categories&category_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name'])));
                 }
                 $item['categories'] = $cats;
                 break;
             case 'downloads':
                 $height = JO_Registry::forceGet($item['module'] . '_items_preview_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width'));
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
                 $item['rate'] = Model_Items::isRate($item['id']);
                 break;
             default:
                 $height = JO_Registry::forceGet($item['module'] . '_items_thumb_height');
                 $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_thumb_width'), $height);
                 if (!empty($item['thumbnail'])) {
                     $thumb_size = getimagesize($item['thumbnail']);
                     if ($thumb_size[1] > $height) {
                         $image = new JO_GDThumb($item['thumbnail']);
                         $image->crop(0, 0, $thumb_size[0], $height);
                         $image->save($item['thumbnail']);
                     }
                 }
         }
         $item['href'] = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']));
         $item['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']));
     }
     $view->item = $item;
     return $view->renderByModule('single_items/' . $view_name, 'items', $item['module']);
 }
Esempio n. 12
0
 public static function uploadPin($image, $title = '', $id = 0)
 {
     try {
         if (($imageinfo = getimagesize($image)) !== false) {
             if (!file_exists(BASE_PATH . '/uploads/cache_pins/' . $id) || !is_dir(BASE_PATH . '/uploads/cache_pins/' . $id)) {
                 @mkdir(BASE_PATH . '/uploads/cache_pins/' . $id, 0777, true);
             }
             $ext = strtolower(strrchr($image, "."));
             if (!$ext) {
                 $mime_ext = explode('/', $imageinfo['mime']);
                 if (isset($mime_ext[1])) {
                     $ext = '.' . $mime_ext[1];
                 }
             }
             if (trim($title) && mb_strlen($title, 'utf-8') > 60) {
                 $title = JO_Utf8::splitText($title, 60, '');
             }
             if (trim($title)) {
                 $name = self::translateImage($title) . '_' . $id . $ext;
             } else {
                 $name = md5($image) . '_' . $id . $ext;
             }
             if (@copy($image, BASE_PATH . '/uploads/cache_pins/' . $id . '/' . $name)) {
                 $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');
                 $container = 'amatteur_pins';
                 $auth = new JO_Api_Rackspace_Authentication(JO_Registry::get('rsUsername'), JO_Registry::get('rsApiKey'));
                 if ($auth->authenticate()) {
                     $conn = new JO_Api_Rackspace_Connection($auth);
                     $contaners = $conn->list_public_containers();
                     if (!in_array($container, $contaners)) {
                         $conn->create_container($container);
                         $contaners[] = $container;
                     }
                     if ($contaners && in_array($container, $contaners)) {
                         $images = $conn->get_container($container);
                         $images->make_public(86400 * 365);
                         $images = $conn->get_container($container);
                         if (!$images->cdn_uri) {
                             return false;
                         }
                         $object = $images->create_object($name);
                         $object->load_from_filename(BASE_PATH . '/uploads/cache_pins/' . $id . '/' . $name);
                         $image_info = $images->get_object($name);
                         if (!$image_info->name) {
                             return false;
                         }
                         $model_images = new Helper_Images();
                         $temp_width = 0;
                         $temp_height = 0;
                         $sizes = self::pinThumbSizes();
                         if ($sizes) {
                             foreach ($sizes as $size => $prefix) {
                                 $sizes = explode('x', $size);
                                 $width = (int) isset($sizes[0]) ? $sizes[0] : 0;
                                 $height = (int) isset($sizes[1]) ? $sizes[1] : 0;
                                 $name_pref = basename($name, $ext) . $prefix . $ext;
                                 if ($width && $height) {
                                     $thumb_a = $model_images->resize('/cache_pins/' . $id . '/' . $name, $width, $height, true);
                                 } else {
                                     if ($width && !$height) {
                                         $thumb_a = $model_images->resizeWidth('/cache_pins/' . $id . '/' . $name, $width);
                                     } else {
                                         if ($height && !$width) {
                                             $thumb_a = $model_images->resizeHeight('/cache_pins/' . $id . '/' . $name, $height);
                                         }
                                     }
                                 }
                                 if ($prefix == '_B') {
                                     $temp_width = $model_images->getSizes('width');
                                     $temp_height = $model_images->getSizes('height');
                                 }
                                 $thumb_a1 = explode('/uploads/', $thumb_a);
                                 if ($thumb_a1 && isset($thumb_a1[1])) {
                                     $object = $images->create_object($name_pref);
                                     $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_a1[1]);
                                 }
                             }
                         }
                         self::recursiveDelete(BASE_PATH . '/uploads/cache_pins/' . $id . '/');
                         self::recursiveDelete(BASE_PATH . '/uploads/cache/cache_pins/' . $id . '/');
                         if ($temp_width) {
                             return array('store' => 'rackspace', 'image' => $images->cdn_uri . '/' . $image_info->name, 'width' => $temp_width, 'height' => $temp_height);
                         }
                     }
                 }
             }
         }
         return false;
     } catch (JO_Exception $e) {
         return false;
     }
     return false;
 }
Esempio n. 13
0
 public function activityAction()
 {
     $request = $this->getRequest();
     $user_data = $this->profileHelp();
     $this->setViewChange('profile');
     $this->view->active = 'activity';
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $this->view->boards = '';
     $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'sort' => 'DESC', 'order' => 'history_id');
     $history = Model_History::getHistory($data, 'from_user_id', $user_data['user_id']);
     if ($history) {
         $view = JO_View::getInstance();
         $view->loged = JO_Session::get('user[user_id]');
         $model_images = new Helper_Images();
         foreach ($history as $key => $data) {
             if ($data['history_action'] == Model_History::REPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'repin-box';
                     $userdata = Model_Users::getUser($data['to_user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate('Repinned to %s via %s.'), '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>', '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::ADDPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'addpin-box';
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $view->set_activity_title = sprintf($this->translate('Pinned to %s.'), '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::LIKEPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'likepin-box';
                     $userdata = Model_Users::getUser($pin_data['user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate("Liked %s's pin on %s."), '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>', '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::UNLIKEPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'unlikepin-box';
                     $userdata = Model_Users::getUser($pin_data['user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate("Unliked %s's pin on %s."), '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>', '<a href="' . $board_href . '">' . $pin_data['board'] . '</a>');
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::COMMENTPIN) {
                 $pin_data = Model_Pins::getPin($data['pin_id']);
                 if ($pin_data) {
                     $pin_data['history_id'] = $data['history_id'];
                     $pin_data['history_action'] = 'commentpin-box';
                     $userdata = Model_Users::getUser($pin_data['user_id']);
                     $board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_data['user_id'] . '&board_id=' . $pin_data['board_id']);
                     $via_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $userdata['user_id']);
                     $view->set_activity_title = sprintf($this->translate("Commented on %s's pin and said \"%s\"."), '<a href="' . $via_href . '">' . $userdata['fullname'] . '</a>', JO_Utf8::splitText($data['comment'], 60, '...'));
                     $view->date_dif = $data['date_dif'];
                     $this->view->boards .= Helper_Pin::returnHtml($pin_data);
                 }
             } elseif ($data['history_action'] == Model_History::ADDBOARD) {
                 $board = Model_Boards::getBoard($data['board_id']);
                 if ($board) {
                     $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $user_data['user_id'] . '&board_id=' . $board['board_id']);
                     $board['thumbs'] = array();
                     /* for( $i = 0; $i < min(9, count($board['pins_array'])); $i ++) {
                        $image = isset( $board['pins_array'][$i] ) ? $board['pins_array'][$i]['image'] : false;
                        $board['thumbs'][] = $model_images->resize($image, 60, 60, true);
                        } */
                     $get_big = false;
                     for ($i = 0; $i < 5; $i++) {
                         $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false;
                         if ($image) {
                             if ($get_big) {
                                 $size = '_A';
                             } else {
                                 $size = '_C';
                                 $get_big = true;
                             }
                             $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size);
                             if ($data_img) {
                                 $board['thumbs'][] = $data_img['image'];
                             } else {
                                 $board['thumbs'][] = false;
                             }
                         } else {
                             $board['thumbs'][] = false;
                         }
                     }
                     $board['edit'] = false;
                     if ($board['user_id'] == JO_Session::get('user[user_id]')) {
                         $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $user_data['user_id'] . '&board_id=' . $board['board_id']);
                     }
                     $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id']));
                     $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]');
                     $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $user_data['user_id'] . '&board_id=' . $board['board_id']);
                     $board['history_action'] = 'addboard-box';
                     $view->board = $board;
                     $view->set_activity_title = $this->translate('Created');
                     $this->view->boards .= $view->render('box', 'boards');
                 }
             } else {
                 $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $data['to_user_id']);
                 $avatar = Helper_Uploadimages::avatar($data['user'], '_B');
                 $data['thumb'] = $avatar['image'];
                 $data['thumb_width'] = $avatar['width'];
                 $data['thumb_height'] = $avatar['height'];
                 if (!@getimagesize($data['thumb'])) {
                     $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                     $data['thumb_width'] = $model_images->getSizes('width');
                     $data['thumb_height'] = $model_images->getSizes('height');
                 }
                 $view->history = $data;
                 if ($data['history_action'] == Model_History::FOLLOW_USER) {
                     $view->history['userIsFollow'] = Model_Users::isFollowUser($view->history['to_user_id']);
                     $view->history['follow_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $view->history['to_user_id']);
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $this->view->boards .= $view->render('history/follow_user', 'users');
                 } elseif ($data['history_action'] == Model_History::UNFOLLOW_USER) {
                     $view->history['userIsFollow'] = Model_Users::isFollowUser($view->history['to_user_id']);
                     $view->history['follow_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $view->history['to_user_id']);
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $this->view->boards .= $view->render('history/unfollow_user', 'users');
                 } elseif ($data['history_action'] == Model_History::FOLLOW) {
                     $board_info = Model_Boards::getBoard($data['board_id']);
                     if ($board_info) {
                         $board_info['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board_info['board_id']));
                         $board_info['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $board_info['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $view->history['fullname'] = $data['user']['fullname'];
                         $view->history['avatar'] = $avatar['image'];
                         $view->history['board'] = $board_info;
                         $this->view->boards .= $view->render('history/follow_board', 'users');
                     }
                 } elseif ($data['history_action'] == Model_History::UNFOLLOW) {
                     $board_info = Model_Boards::getBoard($data['board_id']);
                     if ($board_info) {
                         $board_info['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board_info['board_id']));
                         $board_info['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $board_info['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']);
                         $view->history['fullname'] = $data['user']['fullname'];
                         $view->history['avatar'] = $avatar['image'];
                         $view->history['board'] = $board_info;
                         $this->view->boards .= $view->render('history/unfollow_board', 'users');
                     }
                 } elseif ($data['history_action'] == Model_History::LIKEUSER) {
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['userIsLike'] = Model_Users::isLikeUser($view->history['to_user_id']);
                     $view->history['like_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id']);
                     $this->view->boards .= $view->render('history/like_user', 'users');
                 } elseif ($data['history_action'] == Model_History::UNLIKEUSER) {
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['userIsLike'] = Model_Users::isLikeUser($view->history['to_user_id']);
                     $view->history['like_user'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id']);
                     $this->view->boards .= $view->render('history/unlike_user', 'users');
                 } elseif ($data['history_action'] == Model_History::COMMENTUSER) {
                     $view->history['href'] = $data['href'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['text_type'] = $data['text_type'];
                     $view->history['comment'] = $data['comment'];
                     $view->history['date_added'] = $data['date_added'];
                     $view->history['value'] = $data['date_dif']['value'];
                     $view->history['key'] = $data['date_dif']['key'];
                     $this->view->boards .= $view->render('history/history', 'users');
                     //$view->history['comment_user'] = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id'] );
                     //$this->view->boards .= $view->render('history/comment_user', 'users');
                 } elseif ($data['history_action'] == Model_History::MESSAGEUSER) {
                     $view->history['href'] = $data['href'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['text_type'] = $data['text_type'];
                     $view->history['comment'] = $data['comment'];
                     $view->history['date_added'] = $data['date_added'];
                     $view->history['value'] = $data['date_dif']['value'];
                     $view->history['key'] = $data['date_dif']['key'];
                     $this->view->boards .= $view->render('history/history', 'users');
                     //$view->history['messageUser'] = Model_Users::isLikeUser($view->history['to_user_id']);
                     //$view->history['message_user'] = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id'] );
                     //$this->view->boards .= $view->render('history/message_user', 'users');
                 } elseif ($data['history_action'] == Model_History::UNMESSAGEUSER) {
                     $view->history['href'] = $data['href'];
                     $view->history['avatar'] = $avatar['image'];
                     $view->history['fullname'] = $data['user']['fullname'];
                     $view->history['text_type'] = $data['text_type'];
                     $view->history['comment'] = $data['comment'];
                     $view->history['date_added'] = $data['date_added'];
                     $view->history['value'] = $data['date_dif']['value'];
                     $view->history['key'] = $data['date_dif']['key'];
                     $this->view->boards .= $view->render('history/history', 'users');
                     //$view->history['unmessage_user'] = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=likeUser&user_id=' . $view->history['to_user_id'] );
                     //$this->view->boards .= $view->render('history/unmessage_user', 'users');
                 } elseif ($data['history_action'] == Model_History::FOLLOW_EVENT) {
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsFollow'] = Model_Events::isFollowEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['follow_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=follow&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/follow_event', 'users');
                 } elseif ($data['history_action'] == Model_History::UNFOLLOW_EVENT) {
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsFollow'] = Model_Events::isFollowEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['follow_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=follow&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/unfollow_event', 'users');
                 } elseif ($data['history_action'] == Model_History::LIKE_EVENT) {
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsLike'] = Model_Events::isLikeEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['like_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=like&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/like_event', 'users');
                 } elseif ($data['history_action'] == Model_History::UNLIKE_EVENT) {
                     $events = Model_Events::getEvent($dataEvents);
                     $avatar = Helper_Uploadimages::avatar($events, '_B');
                     $events['avatar'] = $avatar['image'];
                     $data['thumb'] = $avatar['image'];
                     $data['thumb_width'] = $avatar['width'];
                     $data['thumb_height'] = $avatar['height'];
                     if (!@getimagesize($data['thumb'])) {
                         $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180);
                         $data['thumb_width'] = $model_images->getSizes('width');
                         $data['thumb_height'] = $model_images->getSizes('height');
                     }
                     $view->history = $data;
                     $view->history['eventIsLike'] = Model_Events::isLikeEvent($view->history['pin_id'], $view->history['to_user_id']);
                     $view->history['like_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=like&userio_id=' . $view->history['to_user_id'] . '&event_id=' . $view->history['pin_id']);
                     $dataEvents = array('filter_event_id' => $view->history['pin_id']);
                     $view->history['fullname'] = $events['eventname'];
                     $view->history['avatar'] = $events['avatar'];
                     $this->view->boards .= $view->render('history/unlike_event', 'users');
                 }
             }
         }
     }
     $agendas = Model_Users::getUserAgenda(array('filter_user_id' => $user_data['user_id']));
     $this->view->has_agendas = false;
     $this->view->agendas_users = "";
     if ($agendas) {
         $this->view->has_agendas = true;
         foreach ($agendas as $agenda) {
             $agenda['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopupDelete&agenda_id=' . $agenda['agenda_id'] . '&user_id=' . $user_data['user_id']);
             $this->view->agenda = $agenda;
             $this->view->agendas_users .= $this->view->render('agenda', 'users');
         }
     }
     $session_user = JO_Session::get('user[user_id]');
     $this->view->popup_agenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopup&user_id=' . $user_data['user_id']);
     //no mover de esta ubicación
     $messages = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => 0));
     $this->view->has_messages = false;
     $this->view->messages_users = "";
     if ($messages) {
         $this->view->has_messages = true;
         foreach ($messages as $message) {
             $avatar = Helper_Uploadimages::avatar($message, '_A');
             $message['avatar'] = $avatar['image'];
             $message['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $message['user_id']);
             $message['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $message['message_id'] . '&user_id=' . $user_data['user_id']);
             $message['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $message['message_id']);
             $this->view->message = $message;
             $this->view->messages_users .= $this->view->render('message', 'users');
             //ahora vamos a consultar las respuestas a este:
             $messagesHijos = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => $message['message_id']));
             if ($messagesHijos) {
                 foreach ($messagesHijos as $messageHijo) {
                     $avatar = Helper_Uploadimages::avatar($messageHijo, '_A');
                     $messageHijo['avatar'] = $avatar['image'];
                     $messageHijo['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $messageHijo['user_id']);
                     $messageHijo['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $messageHijo['message_id'] . '&user_id=' . $user_data['user_id']);
                     $messageHijo['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $messageHijo['message_id']);
                     $this->view->message = $messageHijo;
                     $this->view->messages_users .= $this->view->render('message', 'users');
                 }
             }
         }
     }
     $session_user = JO_Session::get('user[user_id]');
     $this->view->popup_messages = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=0');
     //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activatePopup'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0'  );
     //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activateDetail'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0'  );
     $_SESSION["activate_url"] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
     $this->view->popup_activate = WM_Router::create($request->getBaseUrl() . '?controller=users&action=activate');
     $this->view->search_url = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=activate');
     //$this->view->deportes = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=deportes');
     $this->view->addMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=create');
     $this->view->stateMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=state');
     $this->view->viewMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=view');
     $activate = Model_Users::getActivateUser(JO_Session::get('user[user_id]'));
     if ($activate) {
         $this->view->userIsActivate = $activate["activate"];
     }
     if ($user_data['type_user']) {
         $this->view->userCanActivate = Model_Users::getUserTypeNotOthers($user_data['type_user']);
     }
     if (JO_Registry::get('isMobile')) {
         $this->view->urlagenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agenda&user_id=' . $user_data['user_id']);
         $this->view->urlmensajes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=mensajes&user_id=' . $user_data['user_id']);
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->view->boards;
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
 }
Esempio n. 14
0
 public function steptwoAction()
 {
     $this->noLayout(true);
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]')) {
         $this->view->images = array();
         if ($request->isGet() && $request->getQuery('url')) {
             $cleared = preg_replace('/^www./i', '', JO_Validate::validateHost($request->getQuery('url')));
             $cleared = mb_strtolower($cleared, 'utf-8');
             if (Model_Blacksources::is_exists($cleared)) {
                 $this->view->error = sprintf($this->translate('Source %s is blocked!'), $cleared);
                 $this->setViewChange('stepone');
             } else {
                 $video_url = $request->getQuery('url');
                 $video_url = trim($video_url);
                 if (strpos($video_url, 'http') === false) {
                     $video_url = 'http://' . $video_url;
                 }
                 $http = new JO_Http();
                 $http->setUseragent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
                 $http->setReferrer($video_url);
                 $http->useCurl(true);
                 $http->execute($video_url, $request->getBaseUrl(), 'GET');
                 $http->setMaxredirect(5);
                 /*if(isset($http->headers['location']) && $http->headers['location']) {
                 			$new_url = $http->headers['location'];
                 			$http = new JO_Http();
                 			$http->setUseragent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
                 			$http->setReferrer($video_url);
                 			$http->useCurl(true);
                 			$http->execute($new_url, $request->getBaseUrl(), 'GET');
                 			if(is_array($new_url)) {
                 				$video_url = array_shift($new_url);
                 			} else if($new_url) {
                 				$video_url = $new_url;
                 			}
                 		}*/
                 $videoObject = new Helper_AutoEmbed();
                 $parsedVideo = $videoObject->parseUrl($video_url);
                 $video_image = false;
                 if ($parsedVideo) {
                     $video_image = $videoObject->getImageURL();
                 }
                 $config_image_minimum_size = (int) Helper_Config::get('config_image_minimum_size');
                 if (!$config_image_minimum_size) {
                     $config_image_minimum_size = 80;
                 }
                 if ($http->error) {
                     $this->view->error = str_replace("'", "\\'", $http->error);
                 } elseif ($video_url && ($imagesize = @getimagesize($video_url)) !== false) {
                     if ($imagesize && $imagesize[0] >= $config_image_minimum_size && $imagesize[1] >= $config_image_minimum_size) {
                         $this->view->images[] = array('src' => $video_url, 'width' => $imagesize[0], 'height' => $imagesize[1]);
                     }
                 } elseif ($video_image && ($imagesize = @getimagesize($video_image)) !== false) {
                     if ($imagesize && $imagesize[0] >= $config_image_minimum_size && $imagesize[1] >= $config_image_minimum_size) {
                         $this->view->images[] = array('src' => $video_image, 'width' => $imagesize[0], 'height' => $imagesize[1]);
                     }
                 } else {
                     $html = $http->result;
                     $dom = new JO_Dom_Query($html);
                     $meta = $dom->query('meta');
                     $charset = false;
                     if ($meta->count()) {
                         for ($i = 0; $i < $meta->count(); $i++) {
                             $content = $meta->getItem($i)->getAttribute('content');
                             if (preg_match('/charset=([^\\"\']+)/', $content, $match)) {
                                 $charset = trim($match[1]);
                             }
                         }
                     }
                     if ($charset) {
                         $html = iconv($charset, "UTF-8", $html);
                     } else {
                         $html = JO_Utf8::convertToUtf8($http->result);
                     }
                     $this->view->title = '';
                     if (preg_match('/<title>(.*)<\\/title>/sim', $html, $match)) {
                         $this->view->title = $match[1];
                     }
                     $meta_image = $dom->query('meta[property="og:image"]');
                     $meta_image_src = null;
                     if ($meta_image->count()) {
                         $meta_image_src = $meta_image->rewind()->getAttribute('content');
                     }
                     if ($meta_image_src) {
                         if (($imagesize = @getimagesize($meta_image_src)) !== false) {
                             if ($imagesize && $imagesize[0] >= $config_image_minimum_size && $imagesize[1] >= $config_image_minimum_size) {
                                 $this->view->images[] = array('src' => $meta_image_src, 'width' => $imagesize[0], 'height' => $imagesize[1]);
                             }
                         }
                     }
                     $images = $dom->query('img');
                     if ($images->count() > 0) {
                         $images_array = array();
                         for ($i = 0; $i < $images->count(); $i++) {
                             $src = $images->getItem($i)->getAttribute('src');
                             $image_full = JO_Url_Relativetoabsolute::toAbsolute($request->getQuery('url'), $src);
                             $images_array[$image_full] = $image_full;
                         }
                         foreach ($images_array as $image_full) {
                             $imagesize = @getimagesize($image_full);
                             if ($imagesize && $imagesize[0] >= $config_image_minimum_size && $imagesize[1] >= $config_image_minimum_size) {
                                 $this->view->images[] = array('src' => $image_full, 'width' => $imagesize[0], 'height' => $imagesize[1]);
                             }
                         }
                     }
                 }
                 $this->view->from = $video_url;
             }
         }
         $this->view->total_images = count($this->view->images);
         if ($this->view->total_images < 1) {
             $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin_fromurl&action=steptwo');
             $this->view->error_total_images = true;
             $this->setViewChange('stepone');
         } else {
             $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=createboardwithoutcategory');
             $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=createpin');
             $boards = new Model_Boards_BoardsWithShared(array('filter_user_id' => JO_Session::get('user[user_id]')));
             $this->view->boards = array();
             if ($boards->count()) {
                 foreach ($boards as $board) {
                     $this->view->boards[] = array('board_id' => $board['board_board_id'], 'title' => $board['board_title']);
                 }
             }
             ///////////////// Extension on create //////////////////
             $this->view->form_extensions = array();
             $extensions = Model_Extensions::getByMethod('pin_oncreateform');
             if ($extensions) {
                 $front = JO_Front::getInstance();
                 foreach ($extensions as $id => $ext) {
                     $this->view->form_extensions[] = array('html' => $this->view->callChildren('modules_' . $ext . '_oncreateform'), 'view' => $this->view->callChildrenView('modules_' . $ext . '_oncreateform'), 'key' => $ext);
                 }
             }
         }
     } else {
         // 			$this->view->redirect = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=login' );
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
 }
Esempio n. 15
0
 public function __construct($pin_id, $data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     try {
         $db->beginTransaction();
         $pin_info = new Model_Pins_Pin($pin_id);
         if (!$pin_info->count()) {
             return $this;
         }
         $pin_info = $pin_info->data;
         if (isset($data['board_id'])) {
             $board_info = new Model_Boards_Board($data['board_id']);
             if ($board_info->count()) {
                 $data['board_id'] = $board_info['board_board_id'];
                 $data['category_id'] = $board_info['board_category_id'];
                 $data['public'] = $board_info['board_public'];
             } else {
                 $data['board_id'] = 0;
             }
         }
         $data['likes'] = new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM pins_likes WHERE pin_id = pins.pin_id)');
         $data['comments'] = new JO_Db_Expr('(SELECT COUNT(DISTINCT comment_id) FROM pins_comments WHERE pin_id = pins.pin_id)');
         $data['date_modified'] = WM_Date::format(time(), 'yy-mm-dd H:i:s');
         $data['source_id'] = 0;
         //sorce
         if (isset($data['from']) && $data['from']) {
             $source = new Model_Sources_GetSourceByUrl($data['from']);
             if ($source->source_id) {
                 $data['source_id'] = $source->source_id;
             }
         }
         $data['from_md5'] = md5(isset($data['from']) ? $data['from'] : time());
         /* price */
         //$data['price'] = 0;
         if (isset($data['price']) && $data['price']) {
             $currencies = WM_Currency::getCurrencies();
             $price_left = array();
             $price_right = array();
             if ($currencies) {
                 foreach ($currencies as $currency) {
                     if (trim($currency['symbol_left'])) {
                         $price_left[] = preg_quote(trim($currency['symbol_left']));
                     }
                     if (trim($currency['symbol_right'])) {
                         $price_right[] = preg_quote(trim($currency['symbol_right']));
                     }
                 }
                 if ($price_left) {
                     if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) {
                         $price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
                         $currency = self::getCurrencyBySimbol(trim($match[1]));
                         if ($currency) {
                             $data['price'] = round($price_tmp / $currency, 4);
                         }
                     }
                 }
                 if (!$data['price'] && $price_right) {
                     if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) {
                         $price_tmp = trim(str_replace(trim($match[2]), '', $match[0]));
                         $currency = self::getCurrencyBySimbol(trim($match[2]));
                         if ($currency) {
                             $data['price'] = round($price_tmp / $currency, 4);
                         }
                     }
                 }
             }
         }
         /* end price */
         $from = isset($data['from']) ? $data['from'] : time();
         $data['is_video'] = isset($data['is_video']) && $data['is_video'] == 'true' ? 1 : 0;
         if (!$data['is_video']) {
             $auto = new Helper_AutoEmbed();
             if ($auto->parseUrl($from)) {
                 $data['is_video'] = 1;
             }
         }
         /* is video */
         ///////////////// Event onComplete /////////////////////
         $on_add_call = Helper_Config::get('pin_onbefore_edit');
         if ($on_add_call) {
             foreach ($on_add_call as $call) {
                 call_user_func($call, $data);
             }
         }
         //edit pin
         $result = Helper_Db::update('pins', $data, array('pin_id = ?' => $pin_id));
         ///////////////// update latest pins for board /////////////////////
         if (isset($data['board_id']) && $data['board_id'] && $pin_info['pin_board_id'] != $data['board_id']) {
             new Model_Boards_UpdateLatestPins($data['board_id']);
             new Model_Boards_UpdateLatestPins($pin_info['pin_board_id']);
             $board_info = new Model_Boards_Board($data['board_id']);
             if ($board_info->count()) {
                 if ($board_info['board_cover'] == $pin_id) {
                     $res = Helper_Db::update('boards', array('cover' => 0), array('board_id = >' => $pin_info['pin_board_id']));
                     if (!$result && $res) {
                         $result = $res;
                     }
                 }
             }
         }
         ///////////////// update latest pins for user /////////////////////
         new Model_Users_UpdateLatestPins($pin_info['pin_user_id']);
         ///////////////// Word for search index's /////////////////////
         $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght);
         $words = array();
         foreach ($spl as $word) {
             $word = mb_strtolower($word, 'utf-8');
             if (!in_array($word, self::blackWordsDictionary()) && $word[0] . $word[1] != '&#') {
                 $words[$word] = $word;
             }
         }
         ///////////////// Word for search index's insert /////////////////////
         Helper_Db::delete('pins_invert', array('pin_id = ?' => $pin_id));
         foreach ($words as $word => $data1) {
             $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word));
             if (!$dic_id) {
                 $dic_id = Helper_Db::insert('pins_dictionary', array('word' => $word));
             }
             if ($dic_id) {
                 $res = Helper_Db::insert('pins_invert', array('pin_id' => $pin_id, 'dic_id' => $dic_id));
                 if (!$result && $res) {
                     $result = $res;
                 }
             }
         }
         ///////////////// Extension on edit //////////////////
         $extensions = Model_Extensions::getByMethod('pin_onedit');
         if ($extensions) {
             $front = JO_Front::getInstance();
             foreach ($extensions as $id => $ext) {
                 $pin_data_ext = call_user_func(array($front->formatModuleName('model_' . $ext . '_pin'), 'onedit'), $pin_id, $data);
                 if ($pin_data_ext && is_array($pin_data_ext)) {
                     $data = array_merge(data, $pin_data_ext);
                 }
             }
         }
         ///////////////// Event onComplete /////////////////////
         $trigger = new Helper_Triggers_PinOnEdit();
         $trigger->bind($pin_id);
         $this->affected_rows = $result;
         $db->commit();
     } catch (JO_Exception $e) {
         echo $e;
         exit;
         $db->rollBack();
     }
 }
Esempio n. 16
0
 public function __construct($data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     $data['category_id'] = 0;
     $data['public'] = 1;
     if (isset($data['board_id'])) {
         $board_info = new Model_Boards_Board($data['board_id']);
         if ($board_info->count()) {
             $data['board_id'] = $board_info['board_board_id'];
             $data['category_id'] = $board_info['board_category_id'];
             $data['public'] = $board_info['board_public'];
         } else {
             $data['board_id'] = 0;
         }
     } else {
         $data['board_id'] = 0;
     }
     $data['date_added'] = WM_Date::format(time(), 'yy-mm-dd H:i:s');
     $data['date_modified'] = $data['date_added'];
     $data['user_id'] = isset($data['user_id']) ? $data['user_id'] : (string) JO_Session::get('user[user_id]');
     $data['store'] = Helper_Config::get('file_upload_method') ? Helper_Config::get('file_upload_method') : 'Model_Upload_Locale';
     $data['source_id'] = 0;
     //sorce
     if (isset($data['from']) && $data['from']) {
         $source = new Model_Sources_GetSourceByUrl($data['from']);
         if ($source->source_id) {
             $data['source_id'] = $source->source_id;
         }
     }
     $data['from_md5'] = md5(isset($data['from']) ? $data['from'] : time());
     /* price */
     //$data['price'] = 0;
     if (isset($data['price']) && $data['price']) {
         $currencies = WM_Currency::getCurrencies();
         $price_left = array();
         $price_right = array();
         if ($currencies) {
             foreach ($currencies as $currency) {
                 if (trim($currency['symbol_left'])) {
                     $price_left[] = preg_quote(trim($currency['symbol_left']));
                 }
                 if (trim($currency['symbol_right'])) {
                     $price_right[] = preg_quote(trim($currency['symbol_right']));
                 }
             }
             if ($price_left) {
                 if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) {
                     $price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
                     $currency = self::getCurrencyBySimbol(trim($match[1]));
                     if ($currency) {
                         $data['price'] = round($price_tmp / $currency, 4);
                     }
                 }
             }
             if (!$data['price'] && $price_right) {
                 if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) {
                     $price_tmp = trim(str_replace(trim($match[2]), '', $match[0]));
                     $currency = self::getCurrencyBySimbol(trim($match[2]));
                     if ($currency) {
                         $data['price'] = round($price_tmp / $currency, 4);
                     }
                 }
             }
         }
     }
     /* end price */
     $from = isset($data['from']) ? $data['from'] : time();
     $data['is_video'] = isset($data['is_video']) && $data['is_video'] == 'true' ? 1 : 0;
     if (!$data['is_video']) {
         $auto = new Helper_AutoEmbed();
         if ($auto->parseUrl($from)) {
             $data['is_video'] = 1;
         }
     }
     /* is video */
     ///////////////// Event onComplete /////////////////////
     $on_add_call = Helper_Config::get('pin_onbefore_create');
     if ($on_add_call) {
         foreach ($on_add_call as $call) {
             call_user_func($call, $data);
         }
     }
     ///////////////// upload image /////////////////////
     $image = false;
     if (isset($data['media']) && !isset($data['image'])) {
         $image = $data['media'];
     } else {
         if (isset($data['image'])) {
             $image = $data['image'];
         }
     }
     if (!isset($data['gallery']) && !$image) {
         return $this;
     }
     $data['image'] = '';
     //create pin
     $data['pin_id'] = Helper_Db::insert('pins', $data);
     if (!$data['pin_id']) {
         return $this;
     }
     if (isset($data['gallery'])) {
         if (is_array($data['gallery']) && count($data['gallery']) > 0) {
             $method_for_upload = Helper_Config::get('file_upload_method');
             if ($method_for_upload) {
                 foreach ($data['gallery'] as $row => $image_get) {
                     if ($this->error) {
                         return $this;
                     }
                     $image = call_user_func(array($method_for_upload, 'uploadPin'), $image_get, isset($data['title']) && $data['title'] ? $data['title'] : $data['description'], $data['pin_id']);
                     $this->error = call_user_func(array($method_for_upload, 'getError'));
                     if ($image && isset($image['image'])) {
                         if ($row == 0) {
                             Helper_Db::update('pins', array('image' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('pin_id = ?' => (string) $data['pin_id']));
                         } else {
                             $gal_id = Helper_Db::insert('pins_gallery', array('image' => $image['image'], 'store' => $image['store'], 'pin_id' => $data['pin_id'], 'sort_order' => $row));
                             if (!$gal_id) {
                                 return $this;
                             }
                         }
                     } else {
                         return $this;
                     }
                 }
             } else {
                 Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
                 return $this;
             }
         } else {
             Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
             return $this;
         }
     } else {
         $method_for_upload = Helper_Config::get('file_upload_method');
         if ($method_for_upload && $image) {
             $image = call_user_func(array($method_for_upload, 'uploadPin'), $image, isset($data['title']) && $data['title'] ? $data['title'] : $data['description'], $data['pin_id']);
             $this->error = call_user_func(array($method_for_upload, 'getError'));
             if ($image && isset($image['image'])) {
                 Helper_Db::update('pins', array('image' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('pin_id = ?' => (string) $data['pin_id']));
             } else {
                 Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
                 return $this;
             }
         } else {
             Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id']));
             return $this;
         }
     }
     ///////////////// update latest pins for board /////////////////////
     if (isset($data['board_id']) && $data['board_id']) {
         new Model_Boards_UpdateLatestPins($data['board_id']);
     }
     ///////////////// update latest pins for user /////////////////////
     new Model_Users_UpdateLatestPins($data['user_id']);
     ///////////////// Pin total repins /////////////////////
     if (isset($data['repin_from']) && $data['repin_from']) {
         $pin_repin = new Model_Pins_Pin($data['repin_from']);
         if ($pin_repin->count()) {
             Helper_Db::update('pins', array('repins' => $db->fetchOne($db->select()->from('pins', 'COUNT(pin_id)')->where('repin_from = ?', $data['repin_from'])->limit(1))), array('pin_id = ?' => $data['repin_from']));
         }
     }
     ///////////////// Word for search index's /////////////////////
     $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght);
     $words = array();
     foreach ($spl as $word) {
         $word = mb_strtolower($word, 'utf-8');
         if (!in_array($word, self::blackWordsDictionary()) && $word[0] . $word[1] != '&#') {
             $words[$word] = $word;
         }
     }
     ///////////////// Word for search index's insert /////////////////////
     foreach ($words as $word => $data1) {
         $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word));
         if (!$dic_id) {
             $db->insert('pins_dictionary', array('word' => $word));
             $dic_id = $db->lastInsertId();
         }
         if ($dic_id) {
             $db->insert('pins_invert', array('pin_id' => $data['pin_id'], 'dic_id' => $dic_id));
         }
     }
     Helper_Db::delete('pins_images', array('pin_id = ?' => $data['pin_id']));
     ///////////////// Extension on create //////////////////
     $extensions = Model_Extensions::getByMethod('pin_oncreate');
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $pin_data_ext = call_user_func(array($front->formatModuleName('model_' . $ext . '_pin'), 'oncreate'), $data['pin_id'], $data);
             if ($pin_data_ext && is_array($pin_data_ext)) {
                 $data = array_merge(data, $pin_data_ext);
             }
         }
     }
     ///////////////// Event onComplete /////////////////////
     $trigger = new Helper_Triggers_PinOnCreate();
     $trigger->bind($data['pin_id']);
     $this->data = $data;
     // 		parent::__construct($data);
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user[user_id]')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&popup=true&next=' . urlencode($request->getFullUrl())));
     }
     $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
     $boards = new Model_Boards_BoardsWithShared(array('filter_user_id' => JO_Session::get('user[user_id]')));
     $this->view->boards = array();
     if ($boards->count()) {
         foreach ($boards as $board) {
             $this->view->boards[] = array('board_id' => $board['board_board_id'], 'title' => $board['board_title']);
         }
     }
     ///////////////// Extension on create //////////////////
     $this->view->form_extensions = array();
     $extensions = Model_Extensions::getByMethod('pin_oncreateform');
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $this->view->form_extensions[] = array('html' => $this->view->callChildren('modules_' . $ext . '_oncreateform'), 'view' => $this->view->callChildrenView('modules_' . $ext . '_oncreateform'), 'key' => $ext);
         }
     }
     $this->view->title = JO_Utf8::convertToUtf8($request->getQuery('title'));
     $this->view->url = JO_Utf8::convertToUtf8(urldecode($request->getQuery('url')));
     $this->view->media = JO_Utf8::convertToUtf8($request->getQuery('media'));
     $this->view->is_video = JO_Utf8::convertToUtf8($request->getQuery('is_video'));
     $this->view->description = JO_Utf8::convertToUtf8($request->getQuery('description'));
     $this->view->charset = JO_Utf8::convertToUtf8($request->getQuery('charset'));
     if (is_array($request->getPost())) {
         foreach ($request->getPost() as $k => $v) {
             $this->view->{$k} = $v;
         }
     }
     if (!trim($this->view->description)) {
         $this->view->description = $this->view->title;
     }
     if (JO_Session::get('success_added')) {
         return $this->success();
     } else {
         if ($request->isPost()) {
             $validate = new Helper_Validate();
             $validate->_set_rules($request->getPost('description'), $this->translate('Description'), 'not_empty;min_length[1];max_length[500]');
             $validate->_set_rules($request->getPost('board_id'), $this->translate('Board'), 'not_empty;');
             if ($validate->_valid_form()) {
                 $result = new Model_Pins_Create($request->getPost());
                 if ($result->count()) {
                     $result = $result->data;
                     ///add history
                     new Model_History_AddHistory(JO_Session::get('user[user_id]'), Model_History_Abstract::ADDPIN, $result['pin_id']);
                     //send notification
                     $users = new Model_Users_GroupBoardUsers($request->getPost('board_id'));
                     if ($users->count()) {
                         $template = Model_Notification::getTemplate('group_board');
                         if ($template) {
                             $pin_info = new Model_Pins_Pin($result['pin_id']);
                             if ($pin_info->count()) {
                                 $mail_footer = html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8');
                                 foreach ($users as $user) {
                                     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=' . $pin_info['user_user_id']), 'author_fullname' => $pin_info['user_fullname'], 'board_url' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_info['user_user_id'] . '&board_id=' . $pin_info['board_board_id']), 'board_name' => $pin_info['board_title'], 'pin_url' => WM_Router::pinAction($result['pin_id']), 'mail_footer' => $mail_footer);
                                         if (!$template['title']) {
                                             $template['title'] = '${author_fullname} ' . $this->translate('added new pin to a group board');
                                         }
                                         $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);
                                     }
                                 }
                             }
                         }
                     }
                     JO_Session::set('success_added', $result['pin_id']);
                     $this->redirect($request->getBaseUrl() . '?controller=bookmarklet');
                 } else {
                     if ($result->error) {
                         $this->view->error = $result->error;
                     } else {
                         $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                     }
                 }
             } else {
                 $this->view->error = $validate->_get_error_messages();
             }
         }
     }
 }
Esempio n. 18
0
 /**
  * @param JO_Db_Select $query
  * @param array $data
  * @return JO_Db_Select
  */
 private static function FilterBuilder(JO_Db_Select $query, $data = array())
 {
     $db = JO_Db::getDefaultAdapter();
     $ignore_in = false;
     $query->where('pins.store != ""');
     if (isset($data['filter_likes']) && $data['filter_likes']) {
         $ignore_in = true;
     }
     //		if(isset($data['filter_likes']) && $data['filter_likes'] ) {
     ////			$query->where("pins.pin_id IN ( SELECT DISTINCT pin_id FROM pins_likes WHERE user_id = '".$data['filter_likes']."' )");
     //			$query->joinLeft('pins_likes', 'pins.pin_id = pins_likes.pin_id', array())
     //					->where('pins_likes.user_id = ?', $data['filter_likes'])
     //					/*->group('pins.pin_id')*/;
     //			$ignore_in = true;
     //		}
     if (isset($data['filter_pin_id']) && $data['filter_pin_id']) {
         $query->where('pins.pin_id = ?', (string) $data['filter_pin_id']);
     }
     if (isset($data['filter_like_repin_comment']) && $data['filter_like_repin_comment'] === true) {
         $query->where('pins.likes > 0')->where('pins.repins > 0')->where('pins.comments > 0');
     }
     if (isset($data['delete_request']) && $data['delete_request'] === true) {
         $query->where('pins.delete_request = 1');
     }
     if (isset($data['filter_price_from']) && (int) $data['filter_price_from']) {
         $query->where('pins.price >= ?', (int) $data['filter_price_from']);
         $ignore_in = true;
     } elseif (isset($data['allow_gifts'])) {
         $query->where('pins.price > 0.0000');
         $ignore_in = true;
     }
     if (isset($data['filter_id_in']) && $data['filter_id_in']) {
         $query->where('pins.pin_id IN (?)', new JO_Db_Expr($data['filter_id_in']));
         $ignore_in = true;
     }
     if (isset($data['filter_id_not']) && $data['filter_id_not']) {
         $query->where('pins.pin_id NOT IN (?)', new JO_Db_Expr($data['filter_id_not']));
         $ignore_in = true;
     }
     if (isset($data['filter_price_to']) && (int) $data['filter_price_to']) {
         $query->where('pins.price <= ?', (int) $data['filter_price_to']);
         $ignore_in = true;
     }
     if (isset($data['filter_marker']) && (string) $data['filter_marker']) {
         $query->where('pins.pin_id <= ?', (string) $data['filter_marker']);
         $ignore_in = true;
     }
     if (isset($data['filter_repin_from']) && !is_null($data['filter_repin_from'])) {
         $query->where('pins.repin_from = ?', (string) $data['filter_repin_from']);
         $ignore_in = true;
     }
     if (isset($data['filter_source_id']) && !is_null($data['filter_source_id'])) {
         $query->where('pins.source_id = ?', (string) $data['filter_source_id']);
         $ignore_in = true;
     }
     if (isset($data['filter_from']) && !is_null($data['filter_from'])) {
         $query->where('pins.from = ?', $data['filter_from']);
         $ignore_in = true;
     }
     if (isset($data['filter_from_md5']) && !is_null($data['filter_from_md5'])) {
         $query->where('pins.from_md5 = ?', $data['filter_from_md5']);
         $ignore_in = true;
     }
     if (isset($data['filter_category_id']) && !is_null($data['filter_category_id'])) {
         $query->where('pins.category_id = ?', (string) $data['filter_category_id']);
         $ignore_in = true;
     }
     if (isset($data['filter_is_video']) && !is_null($data['filter_is_video'])) {
         $query->where('pins.is_video = ?', (int) $data['filter_is_video']);
         $ignore_in = true;
     }
     if (isset($data['filter_board_id']) && !is_null($data['filter_board_id'])) {
         $query->where('pins.board_id = ?', (string) $data['filter_board_id']);
         $ignore_in = true;
     }
     //		if(isset($data['filter_ub_id']) && !is_null($data['filter_ub_id'])) {
     //			$query->where('pins.ub_id = ?', (string)$data['filter_ub_id']);
     //			$ignore_in = true;
     //		}
     if (isset($data['filter_user_id']) && !is_null($data['filter_user_id'])) {
         $query->where('pins.user_id = ?', (string) $data['filter_user_id']);
         $ignore_in = true;
     }
     if (isset($data['filter_description'])) {
         $words = JO_Utf8::str_word_split(mb_strtolower($data['filter_description'], 'utf-8'), self::$searchWordLenght);
         if (count($words) > 0) {
             /*$sub = "SELECT `i`.`pin_id` FROM `pins_invert` `i`, `pins_dictionary` `d` WHERE `i`.`dic_id` = `d`.`dic_id` AND ( ";
             		foreach($words AS $key => $word) {
             			if($key) {
             				$sub .= ' OR ';
             			}
             			$sub .= "`d`.`word` = " . $db->quote($word) . " OR MATCH(`d`.`word`) AGAINST (" . $db->quote($word) . ")";
             		}
             		$sub .= ')';
             		
             		$query->where('pins.pin_id IN (' . $sub . ')');
             		
             		$sub = "SELECT `dic_id`, `dic_id` FROM `pins_dictionary` `d` WHERE ( ";
             		foreach($words AS $key => $word) {
             			if($key) {
             				$sub .= ' OR ';
             			}
             			$sub .= "`d`.`word` = " . $db->quote($word) . " OR MATCH(`d`.`word`) AGAINST (" . $db->quote($word) . ")";
             		}
             		$sub .= ')';
             		
             		$dicts = $db->fetchPairs($sub);
             		
             		$tmp_dic_ids = array();
             		if(COUNT($dicts) > 0) { 
             			
             			$pins = $db->fetchPairs("SELECT `pin_id`, `pin_id` FROM `pins_invert` `i` WHERE `i`.`dic_id` IN (" . implode(',', $dicts) . ")");
             			
             			if(count($pins) > 0) {
             				$query->where('pins.pin_id IN (' . implode(',', $pins) . ')');
             			} else {
             				$query->where('pins.pin_id = 0');
             			}
             		} else {
             			$query->where('pins.pin_id = 0');
             		}*/
             $sub = "SELECT `dic_id`, `dic_id` FROM `pins_dictionary` `d` WHERE ( ";
             foreach ($words as $key => $word) {
                 if ($key) {
                     $sub .= ' OR ';
                 }
                 $sub .= "`d`.`word` = " . $db->quote($word) . " OR MATCH(`d`.`word`) AGAINST (" . $db->quote($word) . ")";
             }
             $sub .= ')';
             $dicts = $db->fetchPairs($sub);
             $tmp_dic_ids = array();
             if (COUNT($dicts) > 0) {
                 //					$pins = $db->fetchPairs("SELECT `pin_id`, `pin_id` FROM `pins_invert` `i` WHERE `i`.`dic_id` IN (" . implode(',', $dicts) . ")");
                 //$query->where('pins.pin_id IN ( SELECT DISTINCT `pin_id` FROM `pins_invert` `i` WHERE `i`.`dic_id` IN (' . implode(',', $dicts) . ') )');
                 $query->joinLeft('pins_invert', 'pins.pin_id = pins_invert.pin_id', 'dic_id')->where('pins_invert.`dic_id` IN (' . implode(',', $dicts) . ')')->group('pins.pin_id');
                 $ignore_in = true;
             } else {
                 $query->where('pins.pin_id = 0');
             }
         } else {
             $query->where('pins.pin_id = 0');
         }
     }
     if (isset($data['following_users_from_user_id']) && (string) $data['following_users_from_user_id']) {
         if (JO_Session::get('user[following]')) {
             $sql1 = "SELECT following_id FROM users_following_user WHERE user_id = ?";
             $sql = "SELECT p.pin_id FROM `users_following` a, pins p WHERE a.following_id NOT IN(" . $sql1 . ") AND a.`board_id` = p.`board_id`";
             $query->where("((pins.pin_id IN (" . $sql . ") OR pins.user_id IN (" . $sql1 . ")) AND (`board_id` NOT IN (SELECT board_id FROM `users_following_ignore` WHERE following_id IN(" . $sql1 . ") AND user_id = ?))) OR pins.user_id = ?", (string) JO_Session::get('user[user_id]'));
         }
         /*$sql1 = "SELECT following_id FROM users_following_user WHERE user_id = ?";
         //			$sql = "SELECT p.pin_id FROM `users_following` a, `users_boards` b, pins p WHERE
         //					a.following_id NOT IN(" . $sql1 . ") AND a.`board_id`=b.`board_id` AND b.`public`=1 AND a.`board_id` = p.`board_id` AND
         //					(p.pin_id IN (SELECT pin_id FROM pins WHERE public = 1) OR p.user_id=".(string)JO_Session::get('user[user_id]').")";
         //			$sql = "SELECT p.pin_id FROM `users_following` a, `users_following_ignore` c, `boards` b, pins p WHERE
         //					a.following_id NOT IN(" . $sql1 . ") AND a.`board_id`=b.`board_id` AND b.`public`=1 AND a.`board_id` = p.`board_id` AND
         //					(p.pin_id IN (SELECT pin_id FROM pins WHERE public = 1) OR p.user_id=?)";
         			$sql = "SELECT p.pin_id FROM `users_following` a, pins p WHERE a.following_id NOT IN(" . $sql1 . ") AND a.`board_id` = p.`board_id`";
         			$query->where("((pins.pin_id IN (" . $sql . ") OR pins.user_id IN (" . $sql1 . ")) AND (`board_id` NOT IN (SELECT board_id FROM `users_following_ignore` WHERE following_id IN(" . $sql1 . ") AND user_id = ?))) OR pins.user_id = ?", (string)JO_Session::get('user[user_id]'));
         //			$query->where("pins.board_id IN (SELECT board_id FROM users_following WHERE user_id = '" . (string)$data['following_users_from_user_id'] . "')");
         //echo $query; exit;
          			
         			/*$sql = "SELECT board_id FROM users_boards WHERE (
         					  user_id IN (
         					    SELECT following_id FROM users_following_user WHERE user_id = ?
         					  ) 
         					OR
         					  board_id IN (
         					    SELECT board_id FROM users_following WHERE user_id = ?
         					  )
         					)
         					AND
         					board_id NOT IN (
         					  SELECT board_id FROM users_following_ignore WHERE user_id = ?
         					)";
         			$query->where("pins.board_id IN (" . $sql . ") OR pins.user_id = ?", (string)JO_Session::get('user[user_id]'));
         			*/
     } else {
         //			if($ignore_in) {
         //				if((string)JO_Session::get('user[user_id]')) {
         //					$query->where("(pins.public = 1 OR user_id = ".(string)JO_Session::get('user[user_id]').")");
         //				} else {
         //					$query->where("pins.public = 1");
         //				}
         //			} else {
         //				if((string)JO_Session::get('user[user_id]')) {
         //					$query->where("(pins.pin_id IN (SELECT pin_id FROM pins WHERE public = 1)) OR (pins.user_id IN (SELECT DISTINCT user_id FROM pins WHERE user_id = ".(string)JO_Session::get('user[user_id]')."))");
         //				} else {
         //					$query->where("pins.pin_id IN (SELECT pin_id FROM pins WHERE public = 1)");
         //				}
         //			}
     }
     //		echo $query; exit;
     return $query;
 }
Esempio n. 19
0
 public function feedAction($data = array())
 {
     $request = $this->getRequest();
     if (!$data) {
         $this->forward('error', 'error404');
     } else {
         $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_board_id' => $request->getParam('board_id'));
         $pins = new Model_Pins_Boards($data);
         $formatObject = new Helper_Format();
         $this->view->item = array();
         if ($pins->count()) {
             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. 20
0
 public function feedAction()
 {
     $request = $this->getRequest();
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_marker' => $request->getRequest('marker'), 'filter_user_id' => $request->getRequest('user_id'));
     if ($request->getQuery('filter') == 'likes') {
         unset($data['filter_user_id']);
         $data['filter_likes'] = $request->getRequest('user_id');
         $this->view->active = 'likes';
     }
     $event_data = Model_Users::getUser($request->getRequest('user_id'));
     if ($event_data) {
         JO_Registry::set('meta_title', $event_data['fullname'] . ' - ' . JO_Registry::get('meta_title'));
         $events = Model_Events::getEvents($data);
         $this->view->item = array();
         if ($events) {
             $model_images = new Helper_Images();
             foreach ($events as $event) {
                 $data_img = Helper_Uploadimages::event($event, '_D');
                 if (!$data_img) {
                     continue;
                 }
                 $enclosure = $data_img['image'];
                 $category_info = Model_Categories::getCategory($event['category_id']);
                 if ($category_info) {
                     $event['sport_category'] = $category_info['title'] . ' >> ' . $event['sport_category'];
                 }
                 $this->view->item[] = array('guid' => $event['event_id'], 'enclosure' => $enclosure, 'description' => Helper_Pin::descriptionFix($event['description']), 'title' => Helper_Pin::descriptionFix(JO_Utf8::splitText($event['description'], 60, '...')), 'link' => WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']), 'author' => $event['user']['fullname'], 'pubDate' => WM_Date::format($event['date_added'], JO_Date::RSS_FULL), 'category' => $event['sport_category']);
             }
         }
     }
     echo $this->renderScript('rss');
 }
Esempio n. 21
0
 public static function uploadPin($image, $title = '', $id = 0)
 {
     if (($imageinfo = getimagesize($image)) !== false) {
         self::init();
         if (self::$error) {
             return false;
         }
         if ($title && mb_strlen($title, 'utf-8') > 60) {
             $title = JO_Utf8::splitText($title, 60, '');
         }
         if ($title && mb_strlen($title, 'utf-8') > 60) {
             $title = mb_substr($title, 0, 60, 'utf8');
         }
         $date_added = WM_Date::format(time(), 'yy-mm-dd H:i:s');
         $ext = strtolower(strrchr($image, "."));
         if (!$ext) {
             $mime_ext = explode('/', $imageinfo['mime']);
             if (isset($mime_ext[1])) {
                 $ext = '.' . $mime_ext[1];
             }
         }
         if ($title) {
             $name = self::translateImage($title) . '_' . md5($image) . '_' . $id . $ext;
         } else {
             $name = md5($image) . '_' . $id . $ext;
         }
         $image_path = 'pins/' . WM_Date::format($date_added, 'yy/mm/');
         if (!file_exists(BASE_PATH . '/uploads/cache_pins/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_pins/' . $image_path)) {
             @mkdir(BASE_PATH . '/uploads/cache_pins/' . $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_pins/' . $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::pinThumbSizes();
         $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_pins/' . $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_pins_contaners');
                     // 'pins_'.date('Y_m');
                     /*if(!in_array($container, self::$contaners)) {
                     			try {
                     				self::$connect->create_container($container);
                     				$contaners[] = $container;
                     			} catch (JO_Exception $e) {
                     				self::$error = $e->getMessage();
                     				return false;
                     			}
                     		}*/
                     //if(in_array($container, self::$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_pins_contaners_cdn'), '/') . '/' . $image_info->name, 'width' => 0, 'height' => 0);
                     } catch (JO_Exception $e) {
                         self::$error = $e->getMessage();
                         return false;
                     }
                     /*} else {
                     			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;
                 }
             } 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. 22
0
 public static function uploadPin($image, $title = '', $id = 0)
 {
     if (($imageinfo = getimagesize($image)) !== false) {
         self::init();
         if (self::$error) {
             return false;
         }
         if ($title && mb_strlen($title, 'utf-8') > 60) {
             $title = JO_Utf8::splitText($title, 60, '');
         }
         if ($title && mb_strlen($title, 'utf-8') > 60) {
             $title = mb_substr($title, 0, 60, 'utf8');
         }
         $date_added = WM_Date::format(time(), 'yy-mm-dd H:i:s');
         $ext = strtolower(strrchr($image, "."));
         if (!$ext) {
             $mime_ext = explode('/', $imageinfo['mime']);
             if (isset($mime_ext[1])) {
                 $ext = '.' . $mime_ext[1];
             }
         }
         if ($title) {
             $name = self::translateImage($title) . '_' . md5($image) . '_' . $id . $ext;
         } else {
             $name = md5($image) . '_' . $id . $ext;
         }
         $image_path = 'pins/' . WM_Date::format($date_added, 'yy/mm/');
         if (!file_exists(BASE_PATH . '/uploads/cache_pins/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_pins/' . $image_path)) {
             @mkdir(BASE_PATH . '/uploads/cache_pins/' . $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_pins/' . $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::pinThumbSizes();
         $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_pins/' . $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. 23
0
 function renameIfExist($uniqueSlug)
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('url_alias', array('keyword', 'keyword'))->where('keyword = ?', $uniqueSlug)->orWhere('keyword LIKE ?', $uniqueSlug . '-%');
     $array = $db->fetchPairs($query);
     foreach (WM_Modules::getControllers(APPLICATION_PATH . '/modules/default/controllers/') as $controller) {
         $array[$controller] = $controller;
     }
     $array['admin'] = 'admin';
     $array['default'] = 'default';
     $array = JO_Utf8::array_change_key_case_unicode($array);
     return self::rename_if_exists($array, mb_strtolower($uniqueSlug, 'utf-8'));
 }
Esempio n. 24
0
 public function feedAction($data = array())
 {
     $request = $this->getRequest();
     if (!$data) {
         $this->forward('error', 'error404');
     } else {
         $this->view->item = array();
         $model_images = new Helper_Images();
         foreach ($data['pins'] as $pin) {
             $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_D');
             if ($image) {
                 $enclosure = $image['image'];
             } else {
                 continue;
             }
             $category_info = Model_Categories::getCategory($pin['category_id']);
             if ($category_info) {
                 $pin['board'] = $category_info['title'] . ' >> ' . $pin['board'];
             }
             $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $enclosure, 'description' => Helper_Pin::descriptionFix($pin['description']), 'title' => Helper_Pin::descriptionFix(JO_Utf8::splitText($pin['description'], 60, '...')), 'link' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']), 'author' => $pin['user']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['board']);
         }
         echo $this->renderScript('rss');
     }
 }