<?xml version="1.0" encoding="ISO-8859-1"?>

 
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/">
 </rss>
<?php
  /*============================
    Required
  =============================*/

  // Place you affiliate id here.
  // You can see this in the upper right corner of moviedollars after you log in.
  $aff_id = '68855';
  
  // Place the url of the rss feed that you want to use.
  // Custom theaters include feeds to every niche and the most popular sections of the site.
  $rss_url = 'http://hotmovies.com/most_popular.php?ct=rss&title=Most%20Popular';


  /*==========================
    Optional
  ===========================*/

  // Change this variable to a 1 to turn on full descriptions
  // Or change to ) to hide full descriptions
  $show_descriptions = 0;

  // Include lastRSS library
  // IF last.rss is not in the same directory as this file, change the path below to it's location.
  include 'lastrss.php';
  
  
  // Set cache dir and cache time limit (10 minute) 
  // (don't forget to chmod cahce dir to 777 to allow writing) 
  // Un-comment the 2 lines below to turn on caching. Caching is highlu recommended.
  // $rss->cache_dir = './temp'; 
  // $rss->cache_time = 144000; // 10 minute




  /*====================================================
  You don't need to change anything below this line.
  ======================================================*/
  
  // Backup affiliate information guarentees sales tracking even if click tracking fails.
  $rss_url .= '&a='.$aff_id;
  
  // Create lastRSS object
  $rss = new lastRSS; 
  
  // Load some RSS file
  if ($rs = $rss->get($rss_url )) {
   
	// create affiliate tracking link for title
	$url_pieces = str_replace('http://','',$rs[link]);
	$url_pieces = str_replace('www.','',$rs[link]);
	$url_pieces = explode("/",$url_pieces);
	$domain=$url_pieces[0];
	
	$tacking_page='http://track.'.$domain.'?a='.$aff_id.'&page='.$rs[link];
	
    // Show clickable website title 
	echo '<div id="hm_rss">';
    echo '<big><b><a href="'.$tacking_page.'">'.$rs[title].'</a></b></big>'."\n"; 
    
	
	// Show last published articles (title, link, description) 
    echo "<ul>\n"; 
    foreach($rs['items'] as $item) { 
		$track_item = 'http://track.'.$domain.'?a='.$aff_id.'&page='.$item[link];
        echo "\t".'<li><a href="'.$track_item.'" class="title">'.$item['title'].'</a>'; 
		
		if($show_descriptions ==1 ){
			$clean_des = str_replace('<![CDATA[','',$item['description']);
			$clean_des = str_replace(']]>','',$clean_des);
			
			$str_text = $clean_des; 
			$pattern = '/(href)=[\'"]?([^\'" >]+)[\'" >]/'; 
			
			preg_match_all($pattern, $str_text, $matches); 

			foreach($matches[2] as $key=>$value){
				$affiliate_link = 'http://track.'.$domain.'?a='.$aff_id.'&page='.$value;
				$clean_des = str_replace($value,$affiliate_link,$clean_des );
			}
			echo '<br />'.$clean_des;
		}
		
		
		echo "</li>\n";
        } 
    echo "</ul>\n";
	echo "</div>"; 

  }
  else {
  	die ('RSS feed currently unavailable.');
  }
?>
