Ejemplo n.º 1
0
 public function steptwoAction()
 {
     $this->noLayout(true);
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]')) {
         if (JO_Session::get('upload_from_file') && file_exists(BASE_PATH . JO_Session::get('upload_from_file'))) {
             ///////////////// 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->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=createboardwithoutcategory');
             $temporary = '/cache/review/';
             $upload_folder = BASE_PATH . $temporary;
             $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']);
                 }
             }
             $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin_fromfile&action=upload_images');
             $this->view->upload_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin_fromfile&action=steptwo');
             $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=createpin');
             $this->view->file = JO_Session::get('upload_from_file_name');
             $this->view->full_path = $request->getBaseUrl() . JO_Session::get('upload_from_file');
         } else {
             $this->forward('addpin_fromfile', 'stepone', $this->translate('We couldn\'t find any images'));
         }
     } else {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
         // 			$this->view->redirect = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=login' );
     }
 }
Ejemplo n.º 2
0
 public function steptwoAction()
 {
     $request = $this->getRequest();
     $this->noLayout(true);
     if (JO_Session::get('user[user_id]')) {
         $files = JO_Session::get('gallery_upload_images');
         if ($files) {
             $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=createpin');
             $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=createboardwithoutcategory');
             $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']);
                 }
             }
             $imageObject = new Helper_Images();
             $this->view->images = array();
             foreach ($files as $file) {
                 $this->view->images[] = array('src' => $request->getBaseUrl() . $file['path'] . $file['tmp_name'], 'thumb' => $imageObject->resize('/../' . $file['path'] . $file['tmp_name'], 75, 75, true));
             }
             ///////////////// 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->forward('addpin_gallery', 'stepone', true);
         }
     } else {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
 }
Ejemplo n.º 3
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'));
     }
     $request = $this->getRequest();
     ///////////// boards
     $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=createboardwithoutcategory');
     $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']);
         }
     }
     /////// add media
     $this->view->add_media_href = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=modules_instagram_media&action=pinMediaCheck');
     //$this->initInstagram();
     $this->view->checkLoginInstagram = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=modules_instagram_media&action=isInstagramUser');
     $this->view->getMediaInstagramFirst = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=modules_instagram_media&action=getMedias&first=true');
     $this->view->getMediaInstagram = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=modules_instagram_media&action=getMedias');
     /////////////curl request to get instagram media's
     /*$curl = new JO_Http();
     		$curl->initialize(array(
     				'target' => WM_Router::create( $this->getRequest()->getBaseUrl() . '?controller=modules_instagram_media&action=cronfirst&user='******'user[user_id]') ),
     				'method' => 'GET',
     				'timeout' => 2
     		));
     		$curl->useCurl(true);
     		$curl->execute();*/
     $req = new JO_Http_Async();
     $req->curl_get_async($this->getRequest()->getBaseUrl(), array('controller' => 'modules_instagram_media', 'action' => 'cronfirst', 'user' => JO_Session::get('user[user_id]')));
     // 					var_dump($curl->result); exit;
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
Ejemplo n.º 4
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'));
     }
 }
Ejemplo n.º 5
0
 public function editAction()
 {
     //		var_dump( htmlspecialchars('⚐') );exit;
     $request = $this->getRequest();
     $pin_id = $request->getRequest('pin_id');
     // 		$pin_info = Model_Pins::getPin($pin_id);
     $pin_info = new Model_Pins_Pin($pin_id);
     if (!$pin_info->count() || $pin_info->data['pin_user_id'] != JO_Session::get('user[user_id]')) {
         $this->forward('error', 'error404');
     }
     $pin_info = $pin_info->data;
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         if ($pin_info['pin_from']) {
             $validate->_set_rules($request->getPost('from'), $this->translate('Link'), 'not_empty;min_length[3];domain');
         } else {
             if (trim($request->getPost('from'))) {
                 $validate->_set_rules($request->getPost('from'), $this->translate('Link'), 'not_empty;min_length[3];domain');
             }
         }
         $data = $request->getPost();
         if ($validate->_valid_form()) {
             $edit = new Model_Pins_Edit($pin_id, $request->getPost());
             $this->redirect(WM_Router::pinAction($pin_info['pin_pin_id']));
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
         foreach ($data as $k => $v) {
             if (isset($pin_info['pin_' . $k])) {
                 $pin_info['pin_' . $k] = $v;
             }
         }
     }
     $pin_info['images'] = Helper_Uploadimages::pinThumbs($pin_info);
     if ($pin_info['pin_gift']) {
         $pin_info['price_formated'] = WM_Currency::format($pin_info['pin_price']);
     } else {
         $pin_info['price_formated'] = '';
         $pin_info['pin_price'] = 0;
     }
     $pin_info['href'] = WM_Router::pinAction($pin_info['pin_pin_id']);
     $this->view->pin_info = $pin_info;
     $view->get_user_friends = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
     $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 edit //////////////////
     $this->view->form_extensions = array();
     $extensions = Model_Extensions::getByMethod('pin_oneditform');
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $this->view->form_extensions[] = array('html' => $this->view->callChildren('modules_' . $ext . '_oneditform'), 'view' => $this->view->callChildrenView('modules_' . $ext . '_oneditform'), 'key' => $ext);
         }
     }
     $this->view->pin_delete = WM_Router::pinAction($pin_id, 'delete');
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
Ejemplo n.º 6
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 = 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();
             }
         }
     }
 }