<?php
//Stylegala news feed
error_reporting(E_NONE);
@include_once(
$_SERVER["DOCUMENT_ROOT"]."/shortstat/inc.stats.php");
$url 'http://www.stylegala.com/news/';
require(
$_SERVER['DOCUMENT_ROOT'].'/inc/curl.php');
$contents open_url($url);
$contents iconv("windows-1252""utf-8"$contents);
header("Content-type: application/xml; encoding=utf-8");

print 
'<?xml version="1.0" encoding="utf-8"?>' "\n";
?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
    <title>StyleGala | News</title>
    <link rel="alternate" type="text/html" href="http://www.stylegala.com/news/" />
    <modified><?php print date("Y-m-d\TH:i:s\Z"?></modified>
    <tagline type="text/html" mode="escaped" xml:lang="en">StyleGala | News (Provided by &lt;a href=&quot;http://www.brunotorres.net/&quot;&gt; Bruno Torres&lt;/a&gt;, while they don't publish the official feed).</tagline>
    <id>tag:www.stylegala.com,<?php print date("Y-m-d"); ?>:/</id>
<?php
    $contents 
str_replace("\r"""$contents);
    
$contents str_replace("\n"""$contents);
    
$contents str_replace("<h4>""\n<h4>"$contents);
    
$contents str_replace("</h4>""</h4>\n<content>"$contents);
    
$contents str_replace('<p class="sub">'"</content>\n<p class=\"sub\">"$contents);
  
$contents str_replace('</p></div>'"</p>\n</div>"$contents);
//print $contents; exit;
    
preg_match_all("/<h4><a href=\"([^\"]+)?\">([^<]+)<\/a><\/h4>/"$contents$headings);
    
preg_match_all("/<content><p>(.+)<\/p><\/content>/"$contents$summaries);
    
//preg_match_all("/<p class=\"sub\">([0-9][0-9]) ([a-z][a-z][a-z]) at ([0-9][0-9]:[0-9][0-9]) by (<a href=\"([^\"]+)\" rel=\"external\">)?([^<]+)(<\/a>)?<\/p>/", $contents, $bylines);
preg_match_all("/<p class=\"sub\"><a href=\"(.+)\"><img src=\"(.+)\" alt=\"permanent link\" title=\"Permanent link\" width=\"9\" height=\"9\" \/><\/a> ((\d\d) (\w\w\w)? (at) (\d\d:\d\d)) by (<a href=\"(.+)\" rel=\"external\">)?([^<]+)(<\/a>)?<\/p>/"$contents$bylines);
//print_r($bylines); exit;
for ($i=0$i<sizeof($headings[1])-2$i++){
?>
    <entry>
        <title><?php print $headings[2][$i]; ?></title>
        <link rel="alternate" type="text/html" href="<?php if($headings[1][$i]=='#') print 'http://www/stylegala.com/news/'; else print $headings[1][$i]; ?>" />
    <?php 
      $date_f 
date("Y-m-d\TH:i:s\Z"strtotime(date("M").' '.$bylines[4][$i].' 2005 '.$bylines[7][$i].':00')); 
      
$date_id date("Y-m-d"strtotime(date("M").' '.$bylines[4][$i].' 2005 '.$bylines[7][$i].':00')); 
    
?>
        <modified><?php print $date_f?></modified>
        <issued><?php print $date_f?></issued>
        <id>tag:stylegala.com,<?php print $date_id.':'.(time()*$i?></id>
        <summary type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.stylegala.com/">
        <![CDATA[ <?php print $summaries[1][$i]; ?>]]>
        </summary>
        <author>
            <name><?php if (empty($bylines[10][$i])) print 'Stylegala'; else print $bylines[10][$i?></name>
      <?php if (!empty($bylines[9][$i])) print '      <uri>'.$bylines[9][$i]."</uri>\n"?>
        </author>
    </entry>
<?php
}
?>
</feed>