<?

//  Must put following line in the directory's .htaccess file for this script to parse XML correctly:
//     AddType application/x-httpd-php .xml

//  Validate RSS/XMS feed at:  http://feedvalidator.org/



$adfilelines = file('http://www.1mall.com/db/mallads.db');
$number_of_rows_in_adfilelines = count($adfilelines); 


srand((double)microtime()*1000000); 
$pick_one = rand(0,$number_of_rows_in_adfilelines);
$chosen_one = $adfilelines[$pick_one];
$chosen_one = preg_replace("/\&/i", "and", $chosen_one);
$chosen_one = preg_replace("/\"/i", "'", $chosen_one);
$pieces = explode("|", $chosen_one);
$title1 = $pieces[1];         // Site Name
$description1 = $pieces[14];  // Description
$link1 = $pieces[3];          // URL
   $title1 = strip_tags($title1);
   $title1 = htmlspecialchars($title1);   
   $description1 = strip_tags($description1);
   $description1 = htmlspecialchars($description1);
   $link1 = strip_tags($link1);
   $link1 = htmlspecialchars($link1);


srand((double)microtime()*1000000); 
$pick_one = rand(0,$number_of_rows_in_adfilelines);
$chosen_one = $adfilelines[$pick_one];
$chosen_one = preg_replace("/\&/i", "and", $chosen_one);
$chosen_one = preg_replace("/\"/i", "'", $chosen_one);
$pieces = explode("|", $chosen_one);
$title2 = $pieces[1];         // Site Name
$description2 = $pieces[14];  // Description
$link2 = $pieces[3];          // URL
   $title2 = strip_tags($title2);
   $title2 = htmlspecialchars($title2);   
   $description2 = strip_tags($description2);
   $description2 = htmlspecialchars($description2);
   $link2 = strip_tags($link2);
   $link2 = htmlspecialchars($link2);


srand((double)microtime()*1000000); 
$pick_one = rand(0,$number_of_rows_in_adfilelines);
$chosen_one = $adfilelines[$pick_one];
$chosen_one = preg_replace("/\&/i", "and", $chosen_one);
$chosen_one = preg_replace("/\"/i", "'", $chosen_one);
$pieces = explode("|", $chosen_one);
$title3 = $pieces[1];         // Site Name
$description3 = $pieces[14];  // Description
$link3 = $pieces[3];          // URL
   $title3 = strip_tags($title3);
   $title3 = htmlspecialchars($title3);   
   $description3 = strip_tags($description3);
   $description3 = htmlspecialchars($description3);
   $link3 = strip_tags($link3);
   $link3 = htmlspecialchars($link3);


srand((double)microtime()*1000000); 
$pick_one = rand(0,$number_of_rows_in_adfilelines);
$chosen_one = $adfilelines[$pick_one];
$chosen_one = preg_replace("/\&/i", "and", $chosen_one);
$chosen_one = preg_replace("/\"/i", "'", $chosen_one);
$pieces = explode("|", $chosen_one);
$title4 = $pieces[1];         // Site Name
$description4 = $pieces[14];  // Description
$link4 = $pieces[3];          // URL
   $title4 = strip_tags($title4);
   $title4 = htmlspecialchars($title4);   
   $description4 = strip_tags($description4);
   $description4 = htmlspecialchars($description4);
   $link4 = strip_tags($link4);
   $link4 = htmlspecialchars($link4);


srand((double)microtime()*1000000); 
$pick_one = rand(0,$number_of_rows_in_adfilelines);
$chosen_one = $adfilelines[$pick_one];
$chosen_one = preg_replace("/\&/i", "and", $chosen_one);
$chosen_one = preg_replace("/\"/i", "'", $chosen_one);
$pieces = explode("|", $chosen_one);
$title5 = $pieces[1];         // Site Name
$description5 = $pieces[14];  // Description
$link5 = $pieces[3];          // URL
   $title5 = strip_tags($title5);
   $title5 = htmlspecialchars($title5);   
   $description5 = strip_tags($description5);
   $description5 = htmlspecialchars($description5);
   $link5 = strip_tags($link5);
   $link5 = htmlspecialchars($link5);


$title = "Testing";

$url = "http://www.1mall.com/ODP" . $rsspath;
if (!$rsspath) { $url = "http://www.1mall.com/"; }
if ($shopcat) { $url = "http://www.1mall.com" . $shopcat; }  // Allow for shopping category pages, home page

header("Content-type: application/rss+xml");

print "<?xml version='1.0' ?>\n";

print <<<EOF


<rss version='2.0'>
<channel>
<title>@InterMall Web Directory - $rsspath $shopcat</title>
<link>$url</link>
<description>@InterMall is for shopping and business services. Add your site today to generate traffic!</description>
<language>en-us</language>
<docs>http://www.1mall.com/rss_master.xml</docs>



<item>
<title>$title1</title>
<link>$url</link>
<description>$description1</description>
</item>


<item>
<title>$title2</title>
<link>$url</link>
<description>$description2</description>
</item>


<item>
<title>$title3</title>
<link>$url</link>
<description>$description3</description>
</item>


<item>
<title>$title4</title>
<link>$url</link>
<description>$description4</description>
</item>


<item>
<title>$title5</title>
<link>$url</link>
<description>$description5</description>
</item>



</channel>
</rss>

EOF;

				// Log hits to this XML file to see if being spidered
				//
        // $file = "/home/httpd/vhosts/iaswww.com/httpdocs/-hitlogs/rss_master_xml_hits.txt";     // Tracking path and filename        
        // $datetime = date("m/d/y|H:i:s");
        // $referer = $QUERY_STRING;
        // $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
        // $browser = $HTTP_USER_AGENT;
        // if ($referer == "(none)") { $referer = ""; }
        // $page_visited = $_SERVER["HTTP_HOST"] . $REQUEST_URI;
        // $a = fopen($file, "a");
        // fputs($a, "$datetime|$REMOTE_ADDR|$hostname|$page_visited\n"); //->
        // fclose($a);

?>
