Your IP : 216.73.216.240


Current Path : /home/juvelize/www/administrator/components/com_myrssreader/js/
Upload File :
Current File : /home/juvelize/www/administrator/components/com_myrssreader/js/info_checker.php

<?php
/**
* @package      My RSS Reader
* @copyright    Copyright (C) 2010 FalsinSoft. All rights reserved.
* @license      GNU/GPL
* @website      http://falsinsoft-joomla.blogspot.com
* @email        falsinsoft@gmail.com
* 
*/

function MakeJSONString($sp)
{
	$forb_char  = array(chr(34),chr(92),chr(47),chr(8),chr(12),chr(10),chr(13),chr(9));
	$allow_char = array('\"','\\','\/','','','','','\t');
	
	$title   	 = $sp->get_title();
	$web_url	 = $sp->get_link();
	$rss_url 	 = $sp->subscribe_url();
	$description = $sp->get_description();
		
	$title		 = preg_replace("/<.*?>/", "", $title);
	$title 	   	 = str_replace($forb_char, $allow_char, $title);
	$description = preg_replace("/<.*?>/", "", $description);
	$description = str_replace($forb_char, $allow_char, $description);

	$json = '{'
			.'  "title": "'.$title.'"'
			.', "web_url": "'.$web_url.'"'
			.', "rss_url": "'.$rss_url.'"'
			.', "description": "'.$description.'"'
			.'}';	
			
	return $json;
}

if(!isset($_GET['web_url'])
|| !isset($_GET['rand']))
{
    return;
}
$web_url = strval($_GET['web_url']);

$joomla_base_path = dirname(__FILE__);
$pos = strrpos($joomla_base_path, 'administrator');
if($pos === false) return;
$joomla_base_path = substr($joomla_base_path, 0, $pos-1);

define('_JEXEC', 1);
define('JPATH_BASE', $joomla_base_path);
define('DS', DIRECTORY_SEPARATOR);

require_once(JPATH_BASE.DS.'components'.DS.'com_myrssreader'.DS.'simplepie'.DS.'autoloader.php');
require_once(JPATH_BASE.DS.'components'.DS.'com_myrssreader'.DS.'simplepie'.DS.'idn'.DS.'idna_convert.class.php');

$sp = new SimplePie();

$sp->enable_cache(false);
$sp->set_timeout(10);
$sp->set_feed_url($web_url);		
$sp->init();
$sp->handle_content_type();

if($sp->error() == false)
{
	$feeds = $sp->get_all_discovered_feeds();

	$json = '{ "rss": ['.MakeJSONString($sp);
	
	for($n = count($feeds), $i = 1; $i < $n; $i++)
	{
		$sp->set_feed_url($feeds[$i]->url);		
		$sp->init();
		$sp->handle_content_type();
		
		if($sp->error() == false)
		{
			$json .= ','.MakeJSONString($sp);
		}
	}
	
	$json .= ']}';
		
	echo $json;
}

$sp->__destruct();
unset($sp);

?>