Example #1
1
 public static function copyFromUrl($url, $target)
 {
     if (!@copy($url, $target)) {
         $http = new JO_Http();
         $http->useCurl(true);
         if (($host = JO_Validate::validateHost($url)) !== false) {
             $http->setReferrer('http://' . $host);
         }
         $http->execute($url);
         if ($http->error) {
             return false;
         } else {
             $im = @ImageCreateFromString($http->result);
             if (!$im) {
                 return false;
             }
             return @file_put_contents($target, $im);
         }
     } else {
         return true;
     }
 }
Example #2
0
 public function countAction()
 {
     $request = $this->getRequest();
     $json = array('count' => 0);
     $url = urldecode($request->getQuery('url'));
     if ($url && JO_Validate::validateHost($url)) {
         $source_id = Model_Source::getSourceByUrl($url, false);
         if ($source_id) {
             $total_pins = Model_Pins::getTotalPinsLikes(array('filter_source_id' => $source_id, 'filter_from_md5' => md5($url)));
             $json['count'] = $total_pins;
         } else {
             $json['count'] = 0;
         }
     } else {
         $json['error'] = $this->translate('Invalid Url');
     }
     $json['url'] = $url;
     //		$json['count'] = 1212;
     //		$json['error'] = $this->translate('Invalid Url');
     if ($request->getQuery('callback')) {
         $response = $this->getResponse();
         $response->addHeader('Cache-Control: no-cache, must-revalidate');
         $response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         $response->addHeader('Content-type: application/json');
         echo 'receiveCount(' . JO_Json::encode($json) . ');';
         exit;
     } else {
         foreach ($json as $k => $v) {
             $this->view->{$k} = $v;
         }
         echo $this->renderScript('json');
     }
 }
Example #3
0
 public function pinmarkletAction()
 {
     $this->noLayout(true);
     $response = $this->getResponse();
     $response->addHeader('Cache-Control: no-cache, must-revalidate');
     $response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     $response->addHeader('Content-type: application/javascript; charset=utf-8');
     $request = $this->getRequest();
     $this->view->checkpoint = WM_Router::create($request->getBaseUrl() . '?controller=bookmarklet&action=urlinfo');
     $this->view->bookmarklet = WM_Router::create($request->getBaseUrl() . '?controller=bookmarklet');
     $this->view->imagefolder = $request->getBaseUrl() . 'data/images/';
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->domain = str_replace('.', '\\.', $request->getDomain(true));
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (Helper_Config::get('site_logo') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . Helper_Config::get('site_logo');
     }
     $this->view->blacksource = array();
     $checked_domain = $request->getQuery('d');
     if (($cleared = JO_Validate::validateHost($checked_domain)) !== false) {
         $cleared = preg_replace('/^www./i', '', $cleared);
         if (Model_Blacksources::is_exists($cleared)) {
             $this->view->blacksource = array('regexp' => '/^https?:\\/\\/.*?\\.?' . preg_quote($cleared) . '\\//', 'key' => 'blacksource', 'domain' => $cleared);
         }
     }
     $config_image_minimum_size = (int) Helper_Config::get('config_image_minimum_size');
     if (!$config_image_minimum_size) {
         $config_image_minimum_size = 80;
     }
     $this->view->config_image_minimum_size = $config_image_minimum_size;
 }
Example #4
0
 public static function edit($source_id, $data)
 {
     $data['source'] = preg_replace('/^www./i', '', JO_Validate::validateHost($data['source']));
     $data['source'] = mb_strtolower($data['source'], 'utf-8');
     if (!$data['source']) {
         return false;
     }
     if (!self::is_exists($data['source'], $source_id)) {
         $db = JO_Db::getDefaultAdapter();
         return $db->update('pins_sources_blocked', array('source' => $data['source']), array('source_id = ?' => $source_id));
     }
     return false;
 }
Example #5
0
 public function __construct($url, $insert = true)
 {
     $host = str_replace('www.', '', JO_Validate::validateHost($url));
     if (!$host) {
         return false;
     }
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pins_sources', 'source_id')->where('source = ?', $host)->limit(1);
     $sourse_id = $db->fetchOne($query);
     if (!$sourse_id && $insert) {
         $sourse = new Model_Sources_Create(array('source' => $host));
         $sourse_id = $sourse->source_id;
     }
     $this->source_id = $sourse_id;
 }
Example #6
0
 public function init()
 {
     if (JO_Session::get('user[user_id]')) {
         if (JO_Session::get('next') && JO_Validate::validateHost(JO_Session::get('next'))) {
             $next = JO_Session::get('next');
             if ($this->getRequest()->getQuery('code')) {
                 $next .= (strpos($next, '?') !== false ? '&code=' : '?code=') . $this->getRequest()->getQuery('code');
             }
             if ($this->getRequest()->getQuery('state')) {
                 $next .= (strpos($next, '?') !== false ? '&state=' : '?state=') . $this->getRequest()->getQuery('state');
             }
             JO_Session::clear('next');
             $this->redirect($next);
         }
     }
 }
Example #7
0
 public static function getSourceByUrl($url, $insert = true)
 {
     static $result = array();
     if (isset($result[$url])) {
         return $result[$url];
     }
     $host = str_replace('www.', '', JO_Validate::validateHost($url));
     if (!$host) {
         return false;
     }
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pins_sources', 'source_id')->where('source = ?', $host)->limit(1);
     $sourse_id = $db->fetchOne($query);
     if (!$sourse_id && $insert) {
         $db->insert('pins_sources', array('source' => $host));
         $sourse_id = $db->lastInsertId();
         if (!$sourse_id) {
             return false;
         }
         self::generateSourceQuery($sourse_id);
     }
     $result[$url] = $sourse_id;
     return $result[$url];
 }
Example #8
0
 private function validateForm()
 {
     $request = $this->getRequest();
     $html = trim(strip_tags(html_entity_decode($request->getPost('html'), ENT_QUOTES, 'utf-8')));
     if (!trim($request->getPost('name'))) {
         $this->error['name'] = $this->translate('Please enter a name');
     }
     if (!trim($request->getPost('url')) && !$html) {
         $this->error['url'] = $this->translate('Please enter url and photo or html');
     } elseif (trim($request->getPost('url')) && !trim($request->getPost('photo')) && !$html) {
         $this->error['url'] = $this->translate('Please enter url and photo or html');
     } elseif (!trim($request->getPost('url')) && trim($request->getPost('photo')) && !$html) {
         $this->error['url'] = $this->translate('Please enter url and photo or html');
     }
     if (trim($request->getPost('url')) && !JO_Validate::validateHost(trim($request->getPost('url')))) {
         $this->error['url1'] = $this->translate('Please enter valid url');
     }
     if ($this->error) {
         return false;
     } else {
         return true;
     }
 }
Example #9
0
 public static function editeSource($source_id, $data)
 {
     if (($data['source'] = JO_Validate::validateHost($data['source'])) === false) {
         return false;
     }
     return Helper_Db::update('pins_sources', array('source' => $data['source']), array('source_id = ?' => $source_id)) === false ? false : true;
 }
Example #10
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'));
     }
 }
Example #11
0
 public function indexAction()
 {
     if ($this->session->get('successfu_edite')) {
         $this->view->successfu_edite = true;
         $this->session->clear('successfu_edite');
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $single_sign_on = $this->getRequest()->getPost('single_sign_on');
         $results = array();
         if (is_array($single_sign_on)) {
             foreach ($single_sign_on as $row => $value) {
                 if ($value['url'] && ($url = JO_Validate::validateHost($value['url']))) {
                     $value['url'] = str_replace('www.', '', $url);
                     $results[] = $value;
                 }
             }
         }
         Model_Settings::updateAll(array('single_sign_on' => $results, 'singlesignon' => $request->getPost('singlesignon')));
         if (file_exists(BASE_PATH . '/cache/extensions/singlesignon/')) {
             self::unlink(BASE_PATH . '/cache/extensions/singlesignon/');
         }
         $this->session->set('successfu_edite', true);
         $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/extensions/edit/?extension=singlesignon');
     }
     $this->view->dbuser = JO_Db::getDefaultAdapter()->getConfig('username');
     $image_model = new Model_Images();
     $this->view->single_sign_on = array();
     $single_sign_on = Model_Settings::getSettingsPairs(array('filter_group' => 'single_sign_on'));
     $sort_order = array();
     foreach ($single_sign_on as $row => $data) {
         $sort_order[$row] = isset($data['sort_order']) ? $data['sort_order'] : 0;
         $data['preview'] = $image_model->resize($data['site_logo'], 100, 100);
         $this->view->single_sign_on[$row] = $data;
     }
     array_multisort($sort_order, SORT_ASC, $this->view->single_sign_on);
     $this->view->preview = $image_model->resize(JO_Registry::get('no_image'), 100, 100);
     if (!$this->view->preview) {
         $this->view->preview = $image_model->resize('/no_image.png', 100, 100);
     }
     if ($request->isPost()) {
         $this->view->singlesignon_status = $request->getPost('singlesignon[singlesignon_status]');
     } else {
         $this->view->singlesignon_status = JO_Registry::get('singlesignon_status');
     }
     if ($request->isPost()) {
         $this->view->singlesignon_enable_login = $request->getPost('singlesignon[singlesignon_enable_login]');
     } else {
         $this->view->singlesignon_enable_login = JO_Registry::get('singlesignon_enable_login');
     }
     if ($request->isPost()) {
         $this->view->singlesignon_enable_dropdown = $request->getPost('singlesignon[singlesignon_enable_dropdown]');
     } else {
         $this->view->singlesignon_enable_dropdown = JO_Registry::get('singlesignon_enable_dropdown');
     }
     if ($request->isPost()) {
         $this->view->singlesignon_db_users = $request->getPost('singlesignon[singlesignon_db_users]');
     } else {
         $this->view->singlesignon_db_users = JO_Registry::get('singlesignon_db_users');
     }
 }
Example #12
0
 public function indexAction()
 {
     $this->noViewRenderer(true);
     $request = $this->getRequest();
     if ($request->getQuery('openId') && strlen($request->getQuery('openId')) == 32 && $request->getServer('HTTP_REFERER')) {
         $referer = str_replace('www.', '', JO_Validate::validateHost($request->getServer('HTTP_REFERER')));
         $domain = $request->getDomain();
         if ($referer && $referer != $domain && self::allowledReferal($referer)) {
             //check user
             if ($result = Model_Extensions_Singlesignon::checkUser($referer, $domain, $request->getQuery('openId'))) {
                 if ($result && $result['status'] == 'activate') {
                     $groups = unserialize($result['groups']);
                     if (is_array($groups) and count($groups) > 1) {
                         unset($result['groups']);
                         $fetch_all = Model_Users::getGroups($groups);
                         $result['access'] = array();
                         if ($fetch_all) {
                             foreach ($fetch_all as $row) {
                                 $modules = unserialize($row['rights']);
                                 if (is_array($modules)) {
                                     foreach ($modules as $module => $ison) {
                                         $result['access'][$module] = $module;
                                     }
                                 }
                             }
                         }
                     }
                     if (isset($result['access']) && count($result['access'])) {
                         $result['is_admin'] = true;
                     }
                     JO_Session::set($result);
                 }
             } elseif (!JO_Session::get('user_id')) {
                 $url = 'http://' . $referer . '/public/extensions_singlesignon/getUserData/?openId=' . $request->getQuery('openId') . '&referer=' . $referer . '&domain=' . $domain;
                 if (ini_get('allow_url_fopen')) {
                     $response = file_get_contents($url);
                 } elseif (function_exists('curl_init')) {
                     $response = $this->file_get_contents_curl($url);
                 }
                 if ($response) {
                     $response = JO_Json::decode(JO_Encrypt_Md5::decrypt($response, $domain), true);
                     //register user
                     if ($response && is_array($response)) {
                         if ($result = Model_Extensions_Singlesignon::createUser($response)) {
                             $groups = self::mb_unserialize($result['groups']);
                             if (is_array($groups) and count($groups) > 1) {
                                 unset($result['groups']);
                                 $fetch_all = Model_Users::getGroups($groups);
                                 $result['access'] = array();
                                 if ($fetch_all) {
                                     foreach ($fetch_all as $row) {
                                         $modules = self::mb_unserialize($row['rights']);
                                         if (is_array($modules)) {
                                             foreach ($modules as $module => $ison) {
                                                 $result['access'][$module] = $module;
                                             }
                                         }
                                     }
                                 }
                             }
                             if (isset($result['access']) && count($result['access'])) {
                                 $result['is_admin'] = true;
                             }
                             JO_Session::set($result);
                         }
                     }
                 }
             }
         }
         $this->redirect($request->getBaseUrl());
     }
     $this->view->single_sign_on = array();
     $single_sign_on = WM_Store::getSettingsPairs(array('filter_group' => 'single_sign_on'));
     $model_images = new Model_Images();
     $sort_order = array();
     foreach ($single_sign_on as $row => $data) {
         $sort_order[$row] = isset($data['sort_order']) ? $data['sort_order'] : 0;
         if ($data['site_logo'] && file_exists(BASE_PATH . '/uploads/' . $data['site_logo'])) {
             $data['preview'] = 'uploads/' . $data['site_logo'];
         } else {
             $data['preview'] = '';
         }
         $data['preview'] = $model_images->resize($data['site_logo'], 140, 30);
         $data['href'] = 'http://' . $data['url'] . '/public/';
         if (JO_Registry::get('singlesignon_enable_login') && JO_Session::get('user_id')) {
             $data['href'] .= '?openId=' . md5($request->getDomain() . $data['url'] . JO_Session::get('username') . JO_Session::get('email'));
         }
         $this->view->single_sign_on[$row] = $data;
     }
     array_multisort($sort_order, SORT_ASC, $this->view->single_sign_on);
     if (JO_Registry::get('singlesignon_enable_dropdown') && count($this->view->single_sign_on)) {
         $this->view->ext_css = WM_Router::create($request->getBaseUrl() . '?controller=cache&extension=singlesignon&action=css&setFile=css.css');
         $this->view->ext_js = WM_Router::create($request->getBaseUrl() . '?controller=cache&extension=singlesignon&action=js&setFile=js.js');
         $this->getLayout()->placeholder('singlesignon', $this->view->render('index', 'extensions_singlesignon'));
     }
 }