Example #1
0
 function getFeed($params)
 {
     // module params
     $rssurl = $params->get('rssurl', '');
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $rssurl;
     if ($params->get('cache')) {
         $options['cache_time'] = $params->get('cache_time', 15);
         $options['cache_time'] *= 60;
     } else {
         $options['cache_time'] = null;
     }
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     $feed = new stdclass();
     if ($rssDoc != false) {
         // channel header and link
         $feed->title = $rssDoc->get_title();
         $feed->link = $rssDoc->get_link();
         $feed->description = $rssDoc->get_description();
         // channel image if exists
         $feed->image->url = $rssDoc->get_image_url();
         $feed->image->title = $rssDoc->get_image_title();
         // items
         $items = $rssDoc->get_items();
         // feed elements
         $feed->items = array_slice($items, 0, $params->get('rssitems', 5));
     } else {
         $feed = false;
     }
     return $feed;
 }
 function getRssFeeds($rssfeedlink, $rssitems)
 {
     $rssIds = array();
     $rssIds = explode(',', $rssfeedlink);
     //  get RSS parsed object
     $options = array();
     $options['cache_time'] = null;
     $lists = array();
     foreach ($rssIds as $rssId) {
         $options['rssUrl'] = $rssId;
         $rssDoc =& JFactory::getXMLparser('RSS', $options);
         $feed = new stdclass();
         if ($rssDoc != false) {
             // channel header and link
             $feed->title = $rssDoc->get_title();
             $feed->link = $rssDoc->get_link();
             $feed->description = $rssDoc->get_description();
             // channel image if exists
             $feed->image->url = $rssDoc->get_image_url();
             $feed->image->title = $rssDoc->get_image_title();
             // items
             $items = $rssDoc->get_items();
             // feed elements
             $feed->items = array_slice($items, 0, $rssitems);
             $lists[] = $feed;
         }
     }
     //var_dump($lists);
     //echo 'getRssFeeds lists<pre>',print_r($lists,true),'</pre><br>';
     return $lists;
 }
Example #3
0
 function getFeed()
 {
     $sefConfig =& SEFConfig::getConfig();
     if (!$sefConfig->artioFeedDisplay) {
         return '';
     }
     $options = array();
     $options['rssUrl'] = $sefConfig->artioFeedUrl;
     $options['cache_time'] = null;
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         return JText::_('Error connecting to RSS feed.');
     }
     $items = $rssDoc->get_items();
     if (count($items) == 0) {
         return JText::_('No items to display.');
     }
     $txt = '';
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $item =& $items[$i];
         $title = $item->get_title();
         $link = $item->get_link();
         $desc = $item->get_description();
         $date = $item->get_date('j. F Y');
         $author = $item->get_author();
         $txt .= '<div class="feed-item">';
         $txt .= '<div class="feed-title"><a href="' . $link . '" target="_blank">' . $title . '</a></div>';
         $txt .= '<div class="feed-text">' . $desc . '</div>';
         $txt .= '</div>';
     }
     return $txt;
 }
Example #4
0
 /**
  * Display module contents
  * 
  * @return  void
  */
 public function display()
 {
     // Module params
     $limit = (int) $this->params->get('rssitems', 5);
     // Get RSS parsed object
     $options = array('rssUrl' => $this->params->get('rssurl', ''), 'cache_time' => null);
     if (!$options['rssUrl']) {
         echo '<p class="warning">' . Lang::txt('MOD_FEED_YOUTUBE_ERROR_NO_URL') . '</p>';
         return;
     }
     $rssDoc = \JFactory::getXMLparser('RSS', $options);
     $this->feed = new stdclass();
     if ($rssDoc != false) {
         // Channel header and link
         $this->feed->title = $rssDoc->get_title();
         $this->feed->link = $rssDoc->get_link();
         $this->feed->description = $rssDoc->get_description();
         // Channel image if exists
         $this->feed->image = new stdClass();
         $this->feed->image->url = $rssDoc->get_image_url();
         $this->feed->image->title = $rssDoc->get_image_title();
         // Items
         $items = $rssDoc->get_items();
         // Feed elements
         if ($this->params->get('pick_random', 0)) {
             // Randomize items
             shuffle($items);
         }
         $this->feed->items = array_slice($items, 0, $limit);
     } else {
         $this->feed = false;
     }
     require $this->getLayoutPath();
 }
 function getFeed($params)
 {
     // module params
     $account = $params->get('account', '');
     $hashtag = $params->get('hashtag', '');
     $query = null;
     if (!empty($account)) {
         $query .= 'from:' . $account;
         if (!empty($hashtag)) {
             $query .= '+' . $hashtag;
         }
     }
     $rssurl = 'http://search.twitter.com/search.atom?q=' . $query;
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $rssurl;
     if ($params->get('cache')) {
         $options['cache_time'] = $params->get('cache_time', 15);
         $options['cache_time'] *= 60;
     } else {
         $options['cache_time'] = null;
     }
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     $feed = new stdclass();
     if ($rssDoc != false) {
         // items
         $items = $rssDoc->get_items();
         // feed elements
         $feed->items = array_slice($items, 0, $params->get('rssitems', 5));
     } else {
         $feed = false;
     }
     return $feed;
 }
Example #6
0
 function display($tpl = null)
 {
     global $mainframe;
     // check if cache directory is writeable
     $cacheDir = JPATH_BASE . DS . 'cache' . DS;
     if (!is_writable($cacheDir)) {
         echo JText::_('Cache Directory Unwritable');
         return;
     }
     // Get some objects from the JApplication
     $pathway =& $mainframe->getPathway();
     $document =& JFactory::getDocument();
     // Get the current menu item
     $menus =& JSite::getMenu();
     $menu = $menus->getActive();
     $params =& $mainframe->getParams();
     //get the newsfeed
     $newsfeed =& $this->get('data');
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $newsfeed->link;
     $options['cache_time'] = $newsfeed->cache_time;
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $msg = JText::_('Error: Feed not retrieved');
         $mainframe->redirect('index.php?option=com_newsfeeds&view=category&id=' . $newsfeed->catslug, $msg);
         return;
     }
     $lists = array();
     // channel header and link
     $newsfeed->channel['title'] = $rssDoc->get_title();
     $newsfeed->channel['link'] = $rssDoc->get_link();
     $newsfeed->channel['description'] = $rssDoc->get_description();
     $newsfeed->channel['language'] = $rssDoc->get_language();
     // channel image if exists
     $newsfeed->image['url'] = $rssDoc->get_image_url();
     $newsfeed->image['title'] = $rssDoc->get_image_title();
     $newsfeed->image['link'] = $rssDoc->get_image_link();
     $newsfeed->image['height'] = $rssDoc->get_image_height();
     $newsfeed->image['width'] = $rssDoc->get_image_width();
     // items
     $newsfeed->items = $rssDoc->get_items();
     // feed elements
     $newsfeed->items = array_slice($newsfeed->items, 0, $newsfeed->numarticles);
     // Set page title per category
     $document->setTitle($newsfeed->name . ' - ' . $params->get('page_title'));
     //set breadcrumbs
     $viewname = JRequest::getString('view');
     if ($viewname == 'categories') {
         $pathway->addItem($newsfeed->category, 'index.php?view=category&id=' . $newsfeed->catslug);
     }
     $pathway->addItem($newsfeed->name, '');
     $this->assignRef('params', $params);
     $this->assignRef('newsfeed', $newsfeed);
     parent::display($tpl);
 }
Example #7
0
 function &getRssFeed()
 {
     // Disabled
     $params =& JComponentHelper::getParams('com_linkr');
     if (!$params->get('rss', 1)) {
         $false = false;
         return $false;
     }
     // Return feeds
     return JFactory::getXMLparser('RSS', array('rssUrl' => 'http://feeds.feedburner.com/JoomlaLinkr'));
 }
Example #8
0
 function getImageShowRSS()
 {
     $rssUrl = 'http://feeds.feedburner.com/joomlashine';
     $options = array();
     $rssitems = 1;
     $options['rssUrl'] = $rssUrl;
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     if ($rssDoc != false) {
         $items = $rssDoc->get_items();
         $items = array_slice($items, 0, $rssitems);
         return $items;
     }
     return false;
 }
Example #9
0
 /**
  * Prepare params and return the result
  *
  * @param  object $params - the params of RSS
  *
  * @return array - the array of RSS items
  * @since  1.0
  */
 public static function loadFeed($params)
 {
     // module params
     $filter = JFilterInput::getInstance();
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $params->rssurl;
     $options['cache_time'] = 0;
     $parser = @JFactory::getXMLparser('RSS', $options);
     if ($parser) {
         return RssfeedHelper::_parse($parser, $params);
     } else {
         return false;
     }
 }
Example #10
0
 /**
  * Get fabrikar.com rss feed
  *
  * @return string
  */
 public function getRSSFeed()
 {
     //  Get RSS parsed object - Turn off error reporting as SimplePie creates strict error notices.
     $origError = error_reporting();
     error_reporting(0);
     $version = new JVersion();
     if ($version->RELEASE == 2.5) {
         //  get RSS parsed object
         $options = array();
         $options['rssUrl'] = 'http://feeds.feedburner.com/fabrik';
         $options['cache_time'] = 86400;
         $rssDoc = JFactory::getXMLparser('RSS', $options);
     } else {
         $rssDoc = JSimplepieFactory::getFeedParser('http://feeds.feedburner.com/fabrik', 86400);
     }
     if ($rssDoc == false) {
         $output = FText::_('Error: Feed not retrieved');
     } else {
         // Channel header and link
         $title = $rssDoc->get_title();
         $link = $rssDoc->get_link();
         $output = '<table class="adminlist">';
         $output .= '<tr><th colspan="3"><a href="' . $link . '" target="_blank">' . FText::_($title) . '</th></tr>';
         $items = array_slice($rssDoc->get_items(), 0, 3);
         $numItems = count($items);
         if ($numItems == 0) {
             $output .= '<tr><th>' . FText::_('No news items found') . '</th></tr>';
         } else {
             $k = 0;
             for ($j = 0; $j < $numItems; $j++) {
                 $item = $items[$j];
                 $output .= '<tr><td class="row' . $k . '">';
                 $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>';
                 $output .= '<br />' . $item->get_date('Y-m-d');
                 if ($item->get_description()) {
                     $description = FabrikString::truncate($item->get_description(), array('wordcount' => 50));
                     $output .= '<br />' . $description;
                 }
                 $output .= '</td></tr>';
                 $k = 1 - $k;
             }
         }
         $output .= '</table>';
     }
     error_reporting($origError);
     return $output;
 }
Example #11
0
 /**
  * render News feed from Faboba-Falang portal
  */
 protected function renderJFNews()
 {
     $output = '';
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = '';
     $options['cache_time'] = 86400;
     $rssDoc = JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $output = JText::_('Error: Feed not retrieved');
     } else {
         // channel header and link
         $title = $rssDoc->get_title();
         $link = $rssDoc->get_link();
         $output = '<table class="adminlist">';
         $output .= '<tr><th colspan="3"><a href="' . $link . '" target="_blank">' . JText::_($title) . '</th></tr>';
         $output .= '<tr><td colspan="3">' . JText::_('NEWS_INTRODUCTION') . '</td></tr>';
         $items = array_slice($rssDoc->get_items(), 0, 3);
         $numItems = count($items);
         if ($numItems == 0) {
             $output .= '<tr><th>' . JText::_('No news items found') . '</th></tr>';
         } else {
             $k = 0;
             for ($j = 0; $j < $numItems; $j++) {
                 $item = $items[$j];
                 $output .= '<tr><td class="row' . $k . '">';
                 $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>';
                 if ($item->get_description()) {
                     $description = $this->limitText($item->get_description(), 50);
                     $output .= '<br />' . $description;
                 }
                 $output .= '</td></tr>';
             }
         }
         $k = 1 - $k;
         $output .= '</table>';
     }
     return $output;
 }
 /**
  * render News feed from JEvents portal
  */
 function renderJEventsNews()
 {
     $output = '';
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = 'http://www.jevents.net/jevnews?format=feed&type=rss';
     $options['cache_time'] = 86400;
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $output = JText::_('Error: Feed not retrieved');
     } else {
         // channel header and link
         $title = str_replace(" ", "_", $rssDoc->get_title());
         $link = $rssDoc->get_link();
         $output = '<table class="adminlist">';
         $output .= '<tr><th><a href="' . $link . '" target="_blank">' . JText::_($title) . '</th></tr>';
         $items = array_slice($rssDoc->get_items(), 0, 3);
         $numItems = count($items);
         if ($numItems == 0) {
             $output .= '<tr><th>' . JText::_('JEV_No_news') . '</th></tr>';
         } else {
             $k = 0;
             for ($j = 0; $j < $numItems; $j++) {
                 $item = $items[$j];
                 $output .= '<tr><td class="row' . $k . '">';
                 $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>';
                 if ($item->get_description()) {
                     $description = $this->limitText($item->get_description(), 50);
                     $output .= '<br />' . $description;
                 }
                 $output .= '</td></tr>';
                 $k = 1 - $k;
             }
         }
         $output .= '</table>';
     }
     return $output;
 }
Example #13
0
 /**
  * get fabrikar.com rss feed
  * @return string
  */
 function getRSSFeed()
 {
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = 'http://feeds.feedburner.com/fabrik';
     $options['cache_time'] = 86400;
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $output = JText::_('Error: Feed not retrieved');
     } else {
         // channel header and link
         $title = $rssDoc->get_title();
         $link = $rssDoc->get_link();
         $output = '<table class="adminlist">';
         $output .= '<tr><th colspan="3"><a href="' . $link . '" target="_blank">' . JText::_($title) . '</th></tr>';
         $items = array_slice($rssDoc->get_items(), 0, 3);
         $numItems = count($items);
         if ($numItems == 0) {
             $output .= '<tr><th>' . JText::_('No news items found') . '</th></tr>';
         } else {
             $k = 0;
             for ($j = 0; $j < $numItems; $j++) {
                 $item = $items[$j];
                 $output .= '<tr><td class="row' . $k . '">';
                 $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>';
                 $output .= '<br />' . $item->get_date('Y-m-d');
                 if ($item->get_description()) {
                     $description = FabrikString::truncate($item->get_description(), array('wordcount' => 50));
                     $output .= '<br />' . $description;
                 }
                 $output .= '</td></tr>';
             }
         }
         $k = 1 - $k;
         $output .= '</table>';
     }
     return $output;
 }
Example #14
0
    function render($params)
    {
        // module params
        $rssurl = $params->get('rssurl', '');
        $rssitems = $params->get('rssitems', 5);
        $rssdesc = $params->get('rssdesc', 1);
        $rssimage = $params->get('rssimage', 1);
        $rssitemdesc = $params->get('rssitemdesc', 1);
        $words = $params->def('word_count', 0);
        $rsstitle = $params->get('rsstitle', 1);
        $rssrtl = $params->get('rssrtl', 0);
        $moduleclass_sfx = $params->get('moduleclass_sfx', '');
        //  get RSS parsed object
        $options = array();
        $options['rssUrl'] = $rssurl;
        if ($params->get('cache')) {
            $options['cache_time'] = $params->get('cache_time', 15);
            $options['cache_time'] *= 60;
        } else {
            $options['cache_time'] = null;
        }
        $rssDoc =& JFactory::getXMLparser('RSS', $options);
        if ($rssDoc != false) {
            // channel header and link
            $channel['title'] = $rssDoc->get_title();
            $channel['link'] = $rssDoc->get_link();
            $channel['description'] = $rssDoc->get_description();
            // channel image if exists
            $image['url'] = $rssDoc->get_image_url();
            $image['title'] = $rssDoc->get_image_title();
            //image handling
            $iUrl = isset($image['url']) ? $image['url'] : null;
            $iTitle = isset($image['title']) ? $image['title'] : null;
            // items
            $items = $rssDoc->get_items();
            // feed elements
            $items = array_slice($items, 0, $rssitems);
            ?>
			<table cellpadding="0" cellspacing="0" class="moduletable<?php 
            echo $params->get('moduleclass_sfx');
            ?>
">
			<?php 
            // feed description
            if (!is_null($channel['title']) && $rsstitle) {
                ?>
				<tr>
				<td>
					<strong>
						<a href="<?php 
                echo str_replace('&', '&amp;', $channel['link']);
                ?>
" target="_blank">
						<?php 
                echo $channel['title'];
                ?>
</a>
					</strong>
				</td>
				</tr>
			<?php 
            }
            // feed description
            if ($rssdesc) {
                ?>
				<tr>
					<td>
						<?php 
                echo $channel['description'];
                ?>
					</td>
				</tr>
			<?php 
            }
            // feed image
            if ($rssimage && $iUrl) {
                ?>
				<tr>
					<td align="center">
						<image src="<?php 
                echo $iUrl;
                ?>
" alt="<?php 
                echo @$iTitle;
                ?>
"/>
					</td>
				</tr>
			<?php 
            }
            $actualItems = count($items);
            $setItems = $rssitems;
            if ($setItems > $actualItems) {
                $totalItems = $actualItems;
            } else {
                $totalItems = $setItems;
            }
            ?>
			<tr>
			<td>
				<ul class="newsfeed<?php 
            echo $moduleclass_sfx;
            ?>
"  >
				<?php 
            for ($j = 0; $j < $totalItems; $j++) {
                $currItem =& $items[$j];
                // item title
                ?>
					<li>
					<?php 
                if (!is_null($currItem->get_link())) {
                    ?>
						<a href="<?php 
                    echo $currItem->get_link();
                    ?>
" target="_child">
						<?php 
                    echo $currItem->get_title();
                    ?>
</a>
					<?php 
                }
                // item description
                if ($rssitemdesc) {
                    // item description
                    $text = html_entity_decode($currItem->get_description());
                    $text = str_replace('&apos;', "'", $text);
                    // word limit check
                    if ($words) {
                        $texts = explode(' ', $text);
                        $count = count($texts);
                        if ($count > $words) {
                            $text = '';
                            for ($i = 0; $i < $words; $i++) {
                                $text .= ' ' . $texts[$i];
                            }
                            $text .= '...';
                        }
                    }
                    ?>
						<div style="text-align: <?php 
                    echo $rssrtl ? 'right' : 'left';
                    ?>
 ! important">
							<?php 
                    echo $text;
                    ?>
						</div>
						<?php 
                }
                ?>
					</li>
					<?php 
            }
            ?>
				</ul>
			</td>
			</tr>
		</table>
		<?php 
        }
    }
Example #15
0
 /**
  * render News feed from Joom!Fish portal
  */
 protected function renderJFNews()
 {
     $output = '';
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = 'http://www.joomfish.net/news?format=feed&type=rss&utm_source=jf-core&utm_medium=newsfeed&utm_campaign=jf21';
     $options['cache_time'] = 86400;
     $rssDoc = JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $output = JText::_('ERROR_FEED_NOT_RETRIEVED');
     } else {
         // channel header and link
         $title = $rssDoc->get_title();
         $link = $rssDoc->get_link();
         $output = '<table class="adminlist">';
         $output .= '<tr><th colspan="3"><a href="' . $link . '" target="_blank">' . JText::_($title) . '</th></tr>';
         $output .= '<tr><td colspan="3">' . JText::_('NEWS_INTRODUCTION') . '</td></tr>';
         $items = array_slice($rssDoc->get_items(), 0, 3);
         $numItems = count($items);
         $k = 0;
         if ($numItems == 0) {
             $output .= '<tr><th>' . JText::_('NO_NEWS_ITEMS_FOUND') . '</th></tr>';
         } else {
             for ($j = 0; $j < $numItems; $j++) {
                 $item = $items[$j];
                 $output .= '<tr><td class="row' . $k . '">';
                 $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>';
                 if ($item->get_description()) {
                     $description = $this->limitText($item->get_description(), 50);
                     $output .= '<br />' . $description;
                 }
                 $output .= '</td></tr>';
             }
         }
         $k = 1 - $k;
         $output .= '</table>';
     }
     return $output;
 }
Example #16
0
 /**
  * get list from RSS resouce, it's legacy help to run old version
  *
  * @params JParam $params
  * @return Object xml. or boolean
  */
 function getList($params)
 {
     if (trim($params->get('taccount')) == '') {
         return false;
     }
     $rssUrl = "http://api.twitter.com/1/statuses/user_timeline/" . $params->get('taccount') . ".rss?count=" . $params->get('show_limit');
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $rssUrl;
     if ($params->get('enable_cache')) {
         $options['cache_time'] = $params->get('cache_time');
         $options['cache_time'] *= 60;
     } else {
         $options['cache_time'] = null;
     }
     $rssDoc = JFactory::getXMLparser('RSS', $options);
     if ($rssDoc != false) {
         $items = $rssDoc->get_items();
         return $items;
     } else {
         return false;
     }
 }
Example #17
0
 public function _doCheck()
 {
     // if not set to auto check and not forced to do so
     // when user click on "check updates" button
     // we don't actually try to get updates info
     $sefConfig =& Sh404sefFactory::getConfig();
     // prepare a default response object
     $response = new stdClass();
     $response->status = true;
     $response->statusMessage = JText::_('COM_SH404SEF_CLICK_TO_CHECK_UPDATES');
     $response->current = 0;
     $response->note = '';
     $response->changelogLink = '';
     $response->minVersionToUpgrade = 0;
     $response->maxVersionToUpgrade = 0;
     $response->shouldUpdate = false;
     $response->excludes = array();
     // check if allowed to auto check, w/o user clicking on button
     if (!$sefConfig->autoCheckNewVersion && empty(self::$_forced['updates'])) {
         return $response;
     }
     // get an http client
     require_once JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_sh404sef' . DS . 'lib' . DS . 'Zend' . DS . 'Http' . DS . 'Client.php';
     $hClient = new Sh_Zend_Http_Client();
     $hClient->setConfig(array('maxredirects' => 0, 'timeout' => 10));
     // find where to call ...
     $remoteConfig = Sh404sefHelperUpdates::getRemoteConfig($forced = false);
     // hardcoded default update server
     $defaultServers = array(array('url' => self::$_endPoint . '/' . self::$_updateFile));
     // try to read from remote, central, configuration file
     $remoteServers = empty($remoteConfig->config['updateservers']) ? array() : $remoteConfig->config['updateservers'];
     // merge default and remote
     $servers = array_merge($remoteServers, $defaultServers);
     // check for urls in both defaults and remote
     $serverList = array();
     foreach ($servers as $server) {
         $serverList[] = $server['url'];
     }
     $serverList = array_unique($serverList);
     // now iterate over server list, until we find one that responds
     foreach ($serverList as $server) {
         $response->status = true;
         // actually place a call to find about available updates
         try {
             $hClient->setUri($server);
         } catch (Exception $e) {
             //  move to next update server in list
             $response->status = false;
             continue;
         }
         // request file content
         $adapters = array('Sh_Zend_Http_Client_Adapter_Curl', 'Sh_Zend_Http_Client_Adapter_Socket');
         $rawResponse = null;
         foreach ($adapters as $adapter) {
             try {
                 $hClient->setAdapter($adapter);
                 $rawResponse = $hClient->request();
                 break;
             } catch (Exception $e) {
                 // need that to be Exception, so as to catche Sh_Zend_Exceptions.. as well
                 // we failed, let's try another method
             }
         }
         // (un)set flag if we have a response
         if (empty($rawResponse)) {
             $response->status = false;
             $msg = 'unknown code';
             $response->statusMessage = JText::sprintf('COM_SH404SEF_COULD_NOT_CHECK_FOR_NEW_VERSION', $msg);
         } else {
             if (!is_object($rawResponse) || $rawResponse->isError()) {
                 $response->status = false;
                 $msg = method_exists($rawResponse, 'getStatus') ? $rawResponse->getStatus() : 'unknown code';
                 $response->statusMessage = JText::sprintf('COM_SH404SEF_COULD_NOT_CHECK_FOR_NEW_VERSION', $msg);
             } else {
                 // communication was fine, check the file type
                 $type = $rawResponse->getHeader('Content-type');
                 if (strtolower($type) != 'text/xml' && strtolower($type) != 'application/xml') {
                     $response->status = false;
                     $response->statusMessage = JText::sprintf('COM_SH404SEF_COULD_NOT_CHECK_FOR_NEW_VERSION', $rawResponse->getStatus());
                 }
             }
         }
         // if there was a valid response, break out of
         // loop over available update servers
         if ($response->status) {
             break;
         }
     }
     // if we were not able to contact any update server
     // return this
     if (!$response->status) {
         return $response;
     }
     // get an xml object and parse the response
     $xml =& JFactory::getXMLparser('Simple');
     $xml->loadString($rawResponse->getBody());
     // into our response object
     // first version of version check used an xml file that could only hold one
     // version data set. So we only iterate over the "update" group if it exists
     if (empty($xml->document->update)) {
         $response = self::_readUpdateInformation($xml->document, $response);
     } else {
         foreach ($xml->document->update as $updateRecord) {
             $product = $updateRecord->product[0]->data();
             // only use if this update record is for us
             if ($product == self::$_product) {
                 $response = self::_readUpdateInformation($updateRecord, $response);
                 // find if user should update
                 $response = Sh404sefHelperUpdates::_updateRequired($response);
                 // if found an update, break out
                 if ($response->shouldUpdate) {
                     break;
                 }
             }
         }
     }
     // check if this is a valid information file
     return $response;
 }
Example #18
0
 /**
  * @since	1.6
  */
 function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     // Get view related request variables.
     $print = JRequest::getBool('print');
     // Get model data.
     $state = $this->get('State');
     $item = $this->get('Item');
     if ($item) {
         // Get Category Model data
         $categoryModel = JModel::getInstance('Category', 'NewsfeedsModel', array('ignore_request' => true));
         $categoryModel->setState('category.id', $item->catid);
         $categoryModel->setState('list.ordering', 'a.name');
         $categoryModel->setState('list.direction', 'asc');
         $items = $categoryModel->getItems();
     }
     // Check for errors.
     // @TODO Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Add router helpers.
     $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
     $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
     $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
     // check if cache directory is writeable
     $cacheDir = JPATH_CACHE . DS;
     if (!is_writable($cacheDir)) {
         JError::raiseNotice('0', JText::_('COM_NEWSFEEDS_CACHE_DIRECTORY_UNWRITABLE'));
         return;
     }
     // Merge newsfeed params. If this is single-newsfeed view, menu params override newsfeed params
     // Otherwise, newsfeed params override menu item params
     $params = $state->get('params');
     $newsfeed_params = clone $item->params;
     $active = $app->getMenu()->getActive();
     $temp = clone $params;
     // Check to see which parameters should take priority
     if ($active) {
         $currentLink = $active->link;
         // If the current view is the active item and an newsfeed view for this feed, then the menu item params take priority
         if (strpos($currentLink, 'view=newsfeed') && strpos($currentLink, '&id=' . (string) $item->id)) {
             // $item->params are the newsfeed params, $temp are the menu item params
             // Merge so that the menu item params take priority
             $newsfeed_params->merge($temp);
             $item->params = $newsfeed_params;
             // Load layout from active query (in case it is an alternative menu item)
             if (isset($active->query['layout'])) {
                 $this->setLayout($active->query['layout']);
             }
         } else {
             // Current view is not a single newsfeed, so the newsfeed params take priority here
             // Merge the menu item params with the newsfeed params so that the newsfeed params take priority
             $temp->merge($newsfeed_params);
             $item->params = $temp;
             // Check for alternative layouts (since we are not in a single-newsfeed menu item)
             if ($layout = $item->params->get('newsfeed_layout')) {
                 $this->setLayout($layout);
             }
         }
     } else {
         // Merge so that newsfeed params take priority
         $temp->merge($newsfeed_params);
         $item->params = $temp;
         // Check for alternative layouts (since we are not in a single-newsfeed menu item)
         if ($layout = $item->params->get('newsfeed_layout')) {
             $this->setLayout($layout);
         }
     }
     $offset = $state->get('list.offset');
     // Check the access to the newsfeed
     $levels = $user->getAuthorisedViewLevels();
     if (!in_array($item->access, $levels) or in_array($item->access, $levels) and !in_array($item->category_access, $levels)) {
         JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return;
     }
     // Get the current menu item
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $params = $app->getParams();
     // Get the newsfeed
     $newsfeed = $item;
     $temp = new JRegistry();
     $temp->loadJSON($item->params);
     $params->merge($temp);
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $newsfeed->link;
     $options['cache_time'] = $newsfeed->cache_time;
     $rssDoc = JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
         $app->redirect(NewsFeedsHelperRoute::getCategoryRoute($newsfeed->catslug), $msg);
         return;
     }
     $lists = array();
     // channel header and link
     $newsfeed->channel['title'] = $rssDoc->get_title();
     $newsfeed->channel['link'] = $rssDoc->get_link();
     $newsfeed->channel['description'] = $rssDoc->get_description();
     $newsfeed->channel['language'] = $rssDoc->get_language();
     // channel image if exists
     $newsfeed->image['url'] = $rssDoc->get_image_url();
     $newsfeed->image['title'] = $rssDoc->get_image_title();
     $newsfeed->image['link'] = $rssDoc->get_image_link();
     $newsfeed->image['height'] = $rssDoc->get_image_height();
     $newsfeed->image['width'] = $rssDoc->get_image_width();
     // items
     $newsfeed->items = $rssDoc->get_items();
     // feed elements
     $newsfeed->items = array_slice($newsfeed->items, 0, $newsfeed->numarticles);
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('params', $params);
     $this->assignRef('newsfeed', $newsfeed);
     $this->assignRef('state', $state);
     $this->assignRef('item', $item);
     $this->assignRef('user', $user);
     $this->assign('print', $print);
     $this->_prepareDocument();
     parent::display($tpl);
 }
Example #19
0
 public function velnotice()
 {
     $descriptionhit = array();
     $cacheDir = JPATH_BASE . DS . 'cache' . DS;
     if (!is_writable($cacheDir)) {
         echo JText::_('CACHE_DIRECTORY_UNWRITABLE');
         return;
     }
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM #__velnotice';
     $db->setQuery($query);
     $veldata = $db->loadObject();
     $registry = new JRegistry();
     $registry->loadJSON($veldata->params);
     $params = $registry;
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $params->get('feed');
     $options['cache_time'] = '60';
     $rssDoc = JFactory::getXMLparser('RSS', $options);
     if (!$rssDoc) {
         $this->setRedirect('index.php?option=com_velnotice&view=vel', JText::_('VEL_FEED_PROBLEM'));
     } else {
         $vel = new stdclass();
         $vel->channel['title'] = $rssDoc->get_title();
         $vel->channel['link'] = $rssDoc->get_link();
         $vel->channel['description'] = $rssDoc->get_description();
         $vel->channel['language'] = $rssDoc->get_language();
         // channel image if exists
         $vel->image['url'] = $rssDoc->get_image_url();
         $vel->image['title'] = $rssDoc->get_image_title();
         $vel->image['link'] = $rssDoc->get_image_link();
         $vel->image['height'] = $rssDoc->get_image_height();
         $vel->image['width'] = $rssDoc->get_image_width();
         // items
         $vel->items = $rssDoc->get_items();
         // feed elements
         $vel->items = array_slice($vel->items, 0);
         $db = JFactory::getDBO();
         $query = 'SELECT * FROM #__extensions';
         $db->setQuery($query);
         $extensions = $db->loadObjectList();
         //  print_r($extensions);
         echo '<br /><br />';
         //  print_r ($vel->items);
         //Create an array of the items on the ignore list
         $query2 = 'SELECT published, extension_number FROM #__velnotice_ignorelist WHERE published = 1';
         $db->setQuery($query2);
         $db->query();
         $ignorelist = $db->loadObjectList();
         $vellist = array();
         foreach ($extensions as &$extension) {
             foreach ($vel->items as $feed) {
                 set_time_limit(60);
                 $link = $feed->get_link();
                 $description = $feed->get_description();
                 $description = str_replace('&apos;', "'", $description);
                 $description = '<table><tr>' . $description . '</tr></table>';
                 $text = $feed->get_title();
                 $hit1 = substr_count($text, $extension->name);
                 $hit2 = substr_count(strtolower($text), strtolower($extension->name));
                 $usedescription = JRequest::getInt('usedesc', 0, 'get');
                 $hit3 = substr_count(strtolower($description), strtolower($extension->name));
                 if ($hit3) {
                     $descriptionhit[] = 1;
                 }
                 $continue = 0;
                 if ($hit1 || $hit2) {
                     $continue = 1;
                 }
                 if ($usedescription == 1 && $hit3) {
                     $continue = 1;
                 }
                 if ($continue) {
                     //print_r($extensionnumber);
                     //Check for version match
                     if ($extension->manifest_cache) {
                         $version = substr_count($extension->manifest_cache, '"version"');
                         if ($version) {
                             $manifestvariable = json_decode($extension->manifest_cache);
                             if (is_object($manifestvariable)) {
                                 $versiontext2 = $manifestvariable->version;
                                 $versiontext = preg_replace('/[^\\d\\s]/', '', $manifestvariable->version);
                             } else {
                                 $versionfind = strpos($extension->manifest_cache, '"version"');
                                 $versionstart = $versionfind + 15;
                                 $versionend = strpos($extension->manifest_cache, '"', $versionstart);
                                 $versionlength = $versionend - $versionstart;
                                 $versiontext = substr($extension->manifest_cache, $versionstart, $versionlength);
                                 $versiontext2 = $versiontext;
                                 $versiontext = preg_replace('/[^\\d\\s]/', '', $versiontext);
                             }
                         }
                     }
                     $reportedversion = @substr_count(strtolower($description), $version);
                     $reportedversion = preg_replace('/[^\\d\\s]/', '', $reportedversion);
                     if ($reportedversion == $versiontext) {
                         $image = 'red';
                     } else {
                         $image = 'yellow';
                     }
                     $vellist2 = array('title' => $extension->name, 'description' => $description, 'image' => $image, 'link' => $link, 'version' => $versiontext2, 'extension_number' => $extension->extension_id);
                     $vellist[] = $vellist2;
                 }
             }
         }
         //Go through the array and remove items from the ignore list
         foreach ($vellist as $i => $velitem) {
             //print_r($velitem['extension_number']);
             if ($ignorelist) {
                 foreach ($ignorelist as $key => $extensionignore) {
                     foreach ($extensionignore as $key => $value) {
                         if ($velitem['extension_number'] == $value) {
                             unset($vellist[$i]);
                         }
                     }
                 }
             }
         }
         $velarray = JRequest::setVar('velarray', $vellist, 'get');
         $done = JRequest::setVar('veldone', 1, 'get');
         if ($ignorelist) {
             $ignoretrue = JRequest::setVar('ignoretrue', 1, 'get');
         }
         if (in_array('1', $descriptionhit)) {
             JRequest::setVar('descriptiontrue', 1, 'get');
         }
     }
     // end of else - if the feed is not false
 }
Example #20
0
 /**
  * get  list of items from rss list and process caching.
  *
  * @param JParameter $params.
  * @return array list of articles
  */
 function dataFromRSS($params)
 {
     $data = array();
     if (trim($params->get('rss_link')) == '') {
         return $data;
     }
     $rssUrl = $params->get('rss_link');
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $rssUrl;
     if ($params->get('enable_cache')) {
         $options['cache_time'] = $params->get('cache_time', '30');
         $options['cache_time'] *= 60;
     } else {
         $options['cache_time'] = null;
     }
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     if ($rssDoc != false) {
         $items = $rssDoc->get_items();
         if ($items != null) {
             $tmp = array();
             foreach ($items as $item) {
                 $obj = new stdClass();
                 $obj->title = $item->get_title();
                 $obj->link = $item->get_link();
                 $obj->introtext = $item->get_description();
                 $tmp[] = $obj;
             }
             $data = $tmp;
         }
     }
     return $data;
 }
Example #21
0
$_DOCMAN->loadLanguage('modules');
require_once $_DOCMAN->getPath('classes', 'utils');
$mainframe = JFactory::getApplication();
$imgpath = JURI::root(true) . DS . 'administrator' . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'images' . DS;
$limit = $params->get('limit', 5);
$desc_truncate = $params->get('desc_truncate', 200);
// check if cache directory is writeable
$cacheDir = JPATH_BASE . DS . 'cache' . DS;
if (!is_writable($cacheDir)) {
    echo JText::_('Cache Directory Unwritable');
    return;
}
$options = array();
$options['rssUrl'] = $params->get('feed_url', _DM_DEFAULT_FEED_URL);
$options['cache_time'] = $params->get('cachetime', 86400);
$rss =& JFactory::getXMLparser('RSS', $options);
if ($rss == false) {
    echo JText::_('Error: Feed not retrieved');
    echo '<br />';
    echo JText::_('This happens when no connection can be made to the server. Try updating to the latest DOCman version. Alternatively, you can disable this module in the module manager.');
    return;
}
?>

<table class="adminlist cpanelmodule">
<tbody>
  	<tr><th>
  		<a href="<?php 
echo $rss->get_link();
?>
" target="_blank"><?php 
Example #22
0
	/**
	 * Method to check if third party plugin/module/component is here and in which version.
	 *
	 * @return	string
	 * @since	1.6
	 */
	protected function _checkThirdPartyVersion($namephp, $namexml, $namedetailled, $path, $plggroup=null, $components=0, $module=0, $plugin=0) {
	// need update
		if ($components) {
		if ( JFile::exists(JPATH_SITE.'/'.$path.'/'.$namephp.'.php') ) {
			if ( JFile::exists(JPATH_ADMINISTRATOR.'/'.$path.'/'.$namexml.'.xml') ) {
				$xml_com = JFactory::getXMLparser('Simple');
				$xml_com->loadFile(JPATH_ADMINISTRATOR.'/'.$path.'/'.$namexml.'.xml');
				$com_version = $xml_com->document->version[0];
				$com_version = '[u]'.$namedetailled.':[/u] Installed (Version : '.$com_version->data().')';
			} else {
				$com_version = '[u]'.$namedetailled.'[/u] The file doesn\'t exist '.$namexml.'.xml !';
			}
		} else {
			$com_version = '';
		}
		return $com_version;
	} elseif ($module) {
		if ( JModuleHelper::isEnabled($namephp) && JFile::exists(JPATH_SITE.'/'.$path.'/'.$namephp.'.php') ) {
			if ( JFile::exists(JPATH_SITE.'/'.$path.'/'.$namexml.'.xml') ) {
				$xml_mod = JFactory::getXMLparser('Simple');
				$xml_mod->loadFile(JPATH_SITE.'/'.$path.'/'.$namexml.'.xml');
				$mod_version = $xml_mod->document->version[0];
				$mod_version = '[u]'.$namedetailled.':[/u] Enabled (Version : '.$mod_version->data().')';
			} else {
				$mod_version = '[u]'.$namedetailled.'[/u] The file doesn\'t exist '.$namexml.'.xml !';
			}
		} else {
			$mod_version = '';
		}
		return $mod_version;
	} elseif ($plugin) {
		$jversion = new JVersion ();
		if ($jversion->RELEASE == '1.5') {
			$pathphp = JPATH_SITE.'/'.$path.'/'.$namephp;
			$pathxml = JPATH_SITE.'/'.$path.'/'.$namexml;
		} else {
			$pathphp = JPATH_SITE.'/'.$path.'/'.$namephp.'/'.$namephp;
			$pathxml =JPATH_SITE.'/'.$path.'/'.$namephp.'/'.$namexml;
		}
		if ( JPluginHelper::isEnabled($plggroup, $namephp) && JFile::exists($pathphp.'.php') ) {
			if ( JFile::exists($pathxml.'.xml') ) {
				$xml_plg = JFactory::getXMLparser('Simple');
				$xml_plg->loadFile($pathxml.'.xml');
				$plg_version = $xml_plg->document->version[0];
				$plg_version = '[u]'.$namedetailled.'[/u] '.$plg_version->data();
			}	else {
				$plg_version = '[u]'.$namedetailled.':[/u] The file doesn\'t exist '.$namexml.'.xml !';
			}
		} else {
			$plg_version = '';
		}
		return $plg_version;
	}
}
    function showTipOfDay()
    {
        global $mainframe;
        $rssurl = 'http://www.chronoengine.com/tips-and-hints/33-chronoforms-tips.html?format=feed&type=rss';
        //  get RSS parsed object
        $options = array();
        $options['rssUrl'] = $rssurl;
        $options['cache_time'] = '100';
        $rssDoc =& JFactory::getXMLparser('RSS', $options);
        $feed = new stdclass();
        if ($rssDoc != false) {
            // channel header and link
            $feed->title = $rssDoc->get_title();
            $feed->link = $rssDoc->get_link();
            $feed->description = $rssDoc->get_description();
            // channel image if exists
            $feed->image->url = $rssDoc->get_image_url();
            $feed->image->title = $rssDoc->get_image_title();
            // items
            $items = $rssDoc->get_items();
            // feed elements
            shuffle($items);
            $feed->items = array_slice($items, 0, 1);
        } else {
            $feed = false;
        }
        if ($feed != false) {
            //image handling
            $iUrl = isset($feed->image->url) ? $feed->image->url : null;
            $iTitle = isset($feed->image->title) ? $feed->image->title : null;
            ?>
			<table cellpadding="0" cellspacing="0" class="adminlist">
            	<tr>
            		<td>
                    <table class="adminheading">
                        <tr>
                        <th>ChronoEngine's Tip Of the Day</th>
                        </tr>
                    </table>
                    </td>
                </tr>
			<?php 
            // feed description
            if (false) {
                ?>
				<tr>
					<td>
						<strong>
							<a href="<?php 
                echo str_replace('&', '&amp', $feed->link);
                ?>
" target="_blank">
								<?php 
                echo $feed->title;
                ?>
</a>
						</strong>
					</td>
				</tr>
				<?php 
            }
            // feed description
            if (false) {
                ?>
				<tr>
					<td><?php 
                echo $feed->description;
                ?>
</td>
				</tr>
				<?php 
                // feed image
                ?>
				<tr>
					<td><img src="<?php 
                echo $iUrl;
                ?>
" alt="<?php 
                echo @$iTitle;
                ?>
"/></td>
				</tr>
			<?php 
            }
            $actualItems = count($feed->items);
            $setItems = 3;
            if ($setItems > $actualItems) {
                $totalItems = $actualItems;
            } else {
                $totalItems = $setItems;
            }
            ?>
			<tr>
				<td>
					<ul class="newsfeed"  >
					<?php 
            $words = 100;
            for ($j = 0; $j < $totalItems; $j++) {
                $currItem =& $feed->items[$j];
                // item title
                ?>
						<li>
						<?php 
                if (!is_null($currItem->get_link())) {
                    ?>
							<a href="<?php 
                    echo $currItem->get_link();
                    ?>
" target="_blank">
							<?php 
                    echo $currItem->get_title();
                    ?>
</a>
						<?php 
                }
                // item description
                if (true) {
                    // item description
                    $text = $currItem->get_description();
                    $text = str_replace('&apos;', "'", $text);
                    // word limit check
                    if ($words) {
                        $texts = explode(' ', $text);
                        $count = count($texts);
                        if ($count > $words) {
                            $text = '';
                            for ($i = 0; $i < $words; $i++) {
                                $text .= ' ' . $texts[$i];
                            }
                            $text .= '...';
                        }
                    }
                    ?>
							<div style="text-align: left ! important" class="newsfeed_item"  >
								<?php 
                    echo $text;
                    ?>
							</div>
							<?php 
                }
                ?>
						</li>
						<?php 
            }
            ?>
					</ul>
				</td>
				</tr>
			</table>
		<?php 
        }
    }
Example #24
0
 /**
  * Fetch the version from the flexicontent.org server
  */
 static function getUpdateComponent()
 {
     // Read installation file
     $manifest_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_flexicontent' . DS . 'manifest.xml';
     $com_xml = JApplicationHelper::parseXMLInstallFile($manifest_path);
     // Version checking URL
     $url = 'http://www.flexicontent.org/flexicontent_update.xml';
     $data = '';
     $check = array();
     $check['connect'] = 0;
     $check['current_version'] = $com_xml['version'];
     //try to connect via cURL
     if (function_exists('curl_init') && function_exists('curl_exec')) {
         $ch = @curl_init();
         @curl_setopt($ch, CURLOPT_URL, $url);
         @curl_setopt($ch, CURLOPT_HEADER, 0);
         //http code is greater than or equal to 300 ->fail
         @curl_setopt($ch, CURLOPT_FAILONERROR, 1);
         @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         //timeout of 5s just in case
         @curl_setopt($ch, CURLOPT_TIMEOUT, 5);
         $data = @curl_exec($ch);
         @curl_close($ch);
     }
     //try to connect via fsockopen
     if (function_exists('fsockopen') && $data == '') {
         $errno = 0;
         $errstr = '';
         //timeout handling: 5s for the socket and 5s for the stream = 10s
         $fsock = @fsockopen("www.flexicontent.org", 80, $errno, $errstr, 5);
         //$fsock = @fsockopen("flexicontent.googlecode.com", 80, $errno, $errstr, 5);
         if ($fsock) {
             @fputs($fsock, "GET /flexicontent_update.xml HTTP/1.1\r\n");
             @fputs($fsock, "HOST: www.flexicontent.org\r\n");
             @fputs($fsock, "Connection: close\r\n\r\n");
             //force stream timeout...
             @stream_set_blocking($fsock, 1);
             @stream_set_timeout($fsock, 5);
             $get_info = false;
             while (!@feof($fsock)) {
                 if ($get_info) {
                     $data .= @fread($fsock, 1024);
                 } else {
                     if (@fgets($fsock, 1024) == "\r\n") {
                         $get_info = true;
                     }
                 }
             }
             @fclose($fsock);
             //need to check data cause http error codes aren't supported here
             if (!strstr($data, '<?xml version="1.0" encoding="utf-8"?><update>')) {
                 $data = '';
             }
         }
     }
     //try to connect via fopen
     if (function_exists('fopen') && ini_get('allow_url_fopen') && $data == '') {
         //set socket timeout
         ini_set('default_socket_timeout', 5);
         $handle = @fopen($url, 'r');
         //set stream timeout
         @stream_set_blocking($handle, 1);
         @stream_set_timeout($handle, 5);
         $data = @fread($handle, 1000);
         @fclose($handle);
     }
     if ($data && strstr($data, '<?xml version="1.0" encoding="utf-8"?><update>')) {
         if (!FLEXI_J16GE) {
             $xml = JFactory::getXMLparser('Simple');
             $xml->loadString($data);
             $version =& $xml->document->version[0];
             $check['version'] = $version->data();
             $released =& $xml->document->released[0];
             $check['released'] = $released->data();
             $check['connect'] = 1;
             $check['enabled'] = 1;
             $check['current'] = version_compare($check['current_version'], $check['version']);
         } else {
             $xml = JFactory::getXML($data, $isFile = false);
             $check['version'] = (string) $xml->version;
             $check['released'] = (string) $xml->released;
             $check['connect'] = 1;
             $check['enabled'] = 1;
             $check['current'] = version_compare($check['current_version'], $check['version']);
         }
     }
     return $check;
 }
Example #25
0
 /**
  * Method to get the default joomla template.
  *
  * @return	string
  * @since	1.6
  */
 protected function _getJoomlaTemplate()
 {
     $db = JFactory::getDBO();
     // Get Joomla! frontend assigned template
     if (version_compare(JVERSION, '1.6', '>')) {
         // Joomla 1.6+
         $query = "SELECT template FROM #__template_styles WHERE client_id=0 AND home=1";
     } else {
         // Joomla 1.5
         $query = "SELECT template FROM #__templates_menu WHERE client_id=0 AND menuid=0";
     }
     $db->setQuery($query);
     $template = $db->loadResult();
     if (KunenaError::checkDatabaseError()) {
         return;
     }
     $xml = JFactory::getXMLparser('Simple');
     $xml->loadFile(JPATH_SITE . '/templates/' . $template . '/templateDetails.xml');
     $templatedetails = new stdClass();
     $templatedetails->name = $template;
     $templatedetails->creationdate = $xml->document->creationDate[0]->data();
     $templatedetails->author = $xml->document->author[0]->data();
     $templatedetails->version = $xml->document->version[0]->data();
     return $templatedetails;
 }
Example #26
0
	public function getTemplateDetails() {
		$templatedetails = new stdClass();
		$xml_tmpl = JFactory::getXMLparser('Simple');
		$xml_tmpl->loadFile($this->xml_path);

		$templatedetails->creationDate = $xml_tmpl->document->creationDate[0]->data();
		$templatedetails->author = $xml_tmpl->document->author[0]->data();
		$templatedetails->version = $xml_tmpl->document->version[0]->data();
		$templatedetails->name = $xml_tmpl->document->name[0]->data();

		return $templatedetails;
	}
/**
 * returns all downloadable extensions developed by JoomGallery::ProjectTeam
 * with some additional information like the current version number or a
 * short description of the extension
 *
 * @return array two-dimensional array with extension information
 */
function Joom_GetAvailableExtensions()
{
    static $extensions;
    if (isset($extensions)) {
        return $extensions;
    }
    $site = 'http://www.en.joomgallery.net';
    $site2 = 'http://en.joomgallery.net';
    $rssurl = $site . '/components/com_newversion/rss/extensions.rss';
    // get RSS parsed object
    $options = array();
    $options['rssUrl'] = $rssurl;
    $options['cache_time'] = 24 * 60 * 60;
    $rssDoc =& JFactory::getXMLparser('rss', $options);
    $extensions = array();
    if ($rssDoc != false) {
        $items = $rssDoc->get_items();
        foreach ($items as $item) {
            $name = $item->get_title();
            $category = $item->get_category();
            $type = $category->get_term();
            switch ($type) {
                case 'general':
                    $description = $item->get_description();
                    $link = $item->get_link();
                    if (!is_null($description) and $description != '') {
                        $extensions[$name]['description'] = $description;
                    }
                    if (!is_null($link) and $link != $site and $link != $site2) {
                        $extensions[$name]['downloadlink'] = $link;
                    }
                    break;
                case 'version':
                    $version = $item->get_description();
                    $link = $item->get_link();
                    if (!is_null($version) and $version != '') {
                        $extensions[$name]['version'] = $version;
                    }
                    if (!is_null($link) and $link != $site and $link != $site2) {
                        $extensions[$name]['releaselink'] = $link;
                    }
                    break;
                case 'autoupdate':
                    $xml = $item->get_description();
                    $link = $item->get_link();
                    if (!is_null($xml) and $xml != '') {
                        $extensions[$name]['xml'] = $xml;
                    }
                    if (!is_null($link) and $link != $site and $link != $site2) {
                        $extensions[$name]['updatelink'] = $link;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    return $extensions;
}
Example #28
0
 /**
  * render news feed from JoomlaPack site
  */
 function getNewsCell()
 {
     // Fix 2.1.1: News reader is disabled by default, because it causes JP to crash on systems w/ 8M of PHP Memory Limit
     $registry =& JoomlapackModelRegistry::getInstance();
     $enabled = $registry->get('showrss', false);
     if (!$enabled) {
         return JText::_('NEWS_DISABLED');
     }
     $output = '';
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = 'http://www.joomlapack.net/news/feed/rss.html';
     $options['cache_time'] = 86400;
     $rssDoc =& JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $output = JText::_('Error: Feed not retrieved');
     } else {
         // channel header and link
         $title = $rssDoc->get_title();
         $link = $rssDoc->get_link();
         $output = '<table class="adminlist">';
         $output .= '<tr><th colspan="3"><a href="' . $link . '" target="_blank">' . JText::_($title) . '</th></tr>';
         $output .= '<tr><td colspan="3">' . JText::_('NEWS_INTRODUCTION') . '</td></tr>';
         $items = array_slice($rssDoc->get_items(), 0, 3);
         $numItems = count($items);
         if ($numItems == 0) {
             $output .= '<tr><th>' . JText::_('No news items found') . '</th></tr>';
         } else {
             $k = 0;
             for ($j = 0; $j < $numItems; $j++) {
                 $item = $items[$j];
                 $output .= '<tr><td class="row' . $k . '">';
                 $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>';
                 if ($item->get_description()) {
                     $description = $this->limitText($item->get_description(), 50);
                     $output .= '<br />' . $description;
                 }
                 $output .= '</td></tr>';
             }
         }
         $k = 1 - $k;
         $output .= '</table>';
     }
     return $output;
 }
Example #29
0
	function getLatestKunenaVersion() {
		$app = JFactory::getApplication ();

		$url = 'http://update.kunena.org/kunena_update.xml';
		$data = '';
		$check = array();
		$check['connect'] = 0;

		$data = $app->getUserState('com_kunena.version_check', null);
		if ( empty($data) ) {
			//try to connect via cURL
			if(function_exists('curl_init') && function_exists('curl_exec')) {
				$ch = @curl_init();

				@curl_setopt($ch, CURLOPT_URL, $url);
				@curl_setopt($ch, CURLOPT_HEADER, 0);
				//http code is greater than or equal to 300 ->fail
				@curl_setopt($ch, CURLOPT_FAILONERROR, 1);
				@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
				//timeout of 5s just in case
				@curl_setopt($ch, CURLOPT_TIMEOUT, 5);
				$data = @curl_exec($ch);
				@curl_close($ch);
			}

			//try to connect via fsockopen
			if(function_exists('fsockopen') && $data == '') {

				$errno = 0;
				$errstr = '';

				//timeout handling: 5s for the socket and 5s for the stream = 10s
				$fsock = @fsockopen("update.kunena.org", 80, $errno, $errstr, 5);

				if ($fsock) {
					@fputs($fsock, "GET /kunena_update.xml HTTP/1.1\r\n");
					@fputs($fsock, "HOST: update.kunena.org\r\n");
					@fputs($fsock, "Connection: close\r\n\r\n");

					//force stream timeout...
					@stream_set_blocking($fsock, 1);
					@stream_set_timeout($fsock, 5);

					$get_info = false;
					while (!@feof($fsock)) {
						if ($get_info) {
							$data .= @fread($fsock, 1024);
						} else {
							if (@fgets($fsock, 1024) == "\r\n") {
								$get_info = true;
							}
						}
					}
					@fclose($fsock);

					//need to check data cause http error codes aren't supported here
					if(!strstr($data, '<?xml version="1.0" encoding="utf-8"?><update>')) {
						$data = '';
					}
				}
			}

			//try to connect via fopen
			if (function_exists('fopen') && ini_get('allow_url_fopen') && $data == '') {

			//set socket timeout
			ini_set('default_socket_timeout', 5);

			$handle = @fopen ($url, 'r');

			//set stream timeout
			@stream_set_blocking($handle, 1);
			@stream_set_timeout($handle, 5);

			$data	= @fread($handle, 1000);

			@fclose($handle);
		}

		return $data;

	}

	if( !empty($data) && strstr($data, '<?xml version="1.0" encoding="utf-8"?>') ) {
		$xml = JFactory::getXMLparser('Simple');
		$xml->loadString($data);
		$version 				= $xml->document->version[0];
		$check['latest_version'] = $version->data();
		$released 				= $xml->document->released[0];
		$check['released'] 		= $released->data();
		$check['connect'] 		= 1;
		$check['enabled'] 		= 1;
	}

	return $check;
	}
Example #30
0
File: vel.php Project: gokuale/vel
 public function getVelInfo($params, $extensions)
 {
     //  get RSS parsed object
     $options = array();
     if ($params->get('urltype') > 1) {
         $options['rssUrl'] = $params->get('feedurl', 'http://feeds.joomla.org/JoomlaSecurityVulnerableExtensions?format=xml');
     } else {
         $options['rssUrl'] = 'http://feeds.joomla.org/JoomlaSecurityVulnerableExtensions?format=xml';
     }
     $options['cache_time'] = '60';
     $rssDoc = JFactory::getXMLparser('RSS', $options);
     if (!$rssDoc) {
         return false;
     }
     $vel = new stdclass();
     $vel->channel['title'] = $rssDoc->get_title();
     $vel->channel['link'] = $rssDoc->get_link();
     $vel->channel['description'] = $rssDoc->get_description();
     $vel->channel['language'] = $rssDoc->get_language();
     // channel image if exists
     $vel->image['url'] = $rssDoc->get_image_url();
     $vel->image['title'] = $rssDoc->get_image_title();
     $vel->image['link'] = $rssDoc->get_image_link();
     $vel->image['height'] = $rssDoc->get_image_height();
     $vel->image['width'] = $rssDoc->get_image_width();
     // items
     $vel->items = $rssDoc->get_items();
     // feed elements
     $vel->items = array_slice($vel->items, 0);
     $vellist = array();
     $velnoticecomponent = 0;
     $ignorelist = $this->getIgnorelist();
     $usedescription = $params->get('usedescription', '0');
     foreach ($extensions as &$extension) {
         //Check to see if com_velnotice is installed
         if ($extension->name == 'com_velnotice') {
             $velnoticecomponent = 1;
         }
         foreach ($vel->items as $feed) {
             set_time_limit(60);
             $link = $feed->get_link();
             $description = $feed->get_description();
             $description = str_replace('&apos;', "'", $description);
             $description = '<table><tr>' . $description . '</tr></table>';
             $text = $feed->get_title();
             $hit1 = substr_count($text, $extension->name);
             $hit2 = substr_count(strtolower($text), strtolower($extension->name));
             $hit3 = substr_count(strtolower($description), strtolower($extension->name));
             // $ignorelistflag = 0;
             $continue = 0;
             if ($hit1 || $hit2) {
                 $continue = 1;
             }
             if ($usedescription == 1 && $hit3) {
                 $continue = 1;
             }
             if ($continue) {
                 //Check for version match
                 if ($extension->manifest_cache) {
                     $version = substr_count($extension->manifest_cache, '"version"');
                     if ($version) {
                         $manifestvariable = json_decode($extension->manifest_cache);
                         if (is_object($manifestvariable)) {
                             $versiontext2 = $manifestvariable->version;
                             $versiontext = preg_replace('/[^\\d\\s]/', '', $manifestvariable->version);
                         } else {
                             $versionfind = strpos($extension->manifest_cache, '"version"');
                             $versionstart = $versionfind + 15;
                             $versionend = strpos($extension->manifest_cache, '"', $versionstart);
                             $versionlength = $versionend - $versionstart;
                             $versiontext = substr($extension->manifest_cache, $versionstart, $versionlength);
                             $versiontext2 = $versiontext;
                             $versiontext = preg_replace('/[^\\d\\s]/', '', $versiontext);
                         }
                     }
                 }
                 $reportedversion = @substr_count(strtolower($description), $version);
                 $reportedversion = preg_replace('/[^\\d\\s]/', '', $reportedversion);
                 $vellist2 = array('title' => $extension->name, 'description' => $description, 'link' => $link, 'version' => $versiontext2, 'extension_number' => $extension->extension_id);
                 $vellist[] = $vellist2;
                 //  $vellist[] = $extension->name.' - '.$versiontext2.' - '.$description;
                 if (!empty($ignorelist)) {
                     foreach ($vellist as $i => $velitem) {
                         //print_r($velitem['extension_number']);
                         foreach ($ignorelist as $key => $extensionignore) {
                             foreach ($extensionignore as $key => $value) {
                                 if ($velitem['extension_number'] == $value && $params->get('useignorelist')) {
                                     unset($vellist[$i]);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $vellist;
 }