<?php
header("Content-type: text/xml");
$dbhost = 'localhost';
$dbuser = 'persona1_persona';
$dbpass = 'persona';
$dbname = 'persona1_personalphoto';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die
		('Could not Connect to Database - Bad host, user, or pass');
mysql_select_db($dbname);
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<atom:link href="http://www.personal-photo-organizer.com/rss.xml" rel="self" type="application/rss+xml" />
<title>Personal Photo Organizer</title>
<description>Personal Photo Organizer</description>
<link>http://www.personal-photo-organizer.com/</link>
<copyright>Personal Photo Organizer</copyright>

<?php
$q="SELECT blog_id,dealer_id,title,post,UNIX_TIMESTAMP(date) AS pubDate FROM dealer_blog Where validate = 1 and view = 0 ORDER BY date DESC LIMIT 0,40";
$doGet=mysql_query($q);

function convert_smart_quotes($string) 
{ 
    $search = array(chr(145), 
                    chr(146), 
                    chr(147), 
                    chr(148), 
                    chr(151)); 
 
    $replace = array("'", 
                     "'", 
                     '"', 
                     '"', 
                     '-'); 
 
    return str_replace($search, $replace, $string); 
} 

while($result = mysql_fetch_array($doGet)){
//$slug = preg_replace("/[^a-zA-Z0-9\s]/", "", $result[title]);
              $slug = str_replace("%","",$result[title]);
              $slug = str_replace("?","",$slug);
              $slug = str_replace(",","",$slug);
              $slug = str_replace("-","",$slug);
              $slug = str_replace(":","",$slug);
              $slug = str_replace(";","",$slug);
              $slug = str_replace(" ","-",$slug);
              $slug = strtolower($slug);
$title = $result[title];

$content = $result[post];
$content = str_replace("%", "%%", $content);
    //$body = htmlentities("$content",ENT_COMPAT,ISO-8859-15);
    $content = ereg_replace(128, "&euro;", $content); // Euro symbol
    $content = ereg_replace(133, "&#133;", $content); // ellipses
    $content = ereg_replace(8226, "&#8243;", $content); // double prime
    $content = ereg_replace(8216, "&#039;", $content); // left single quote
    $content = ereg_replace(145, "&#039;", $content); // left single quote
    $content = ereg_replace(8217, "&#039;", $content); // right single quote
    $content = ereg_replace(146, "&#039;", $content); // right single quote
    $content = ereg_replace(8220, "&#034;", $content); // left double quote
    $content = ereg_replace(147, "&#034;", $content); // left double quote
    $content = ereg_replace(8221, "&#034;", $content); // right double quote
    $content = ereg_replace(148, "&#034;", $content); // right double quote
    $content = ereg_replace(8226, "&#149;", $content); // bullet
    $content = ereg_replace(149, "&#149;", $content); // bullet
    $content = ereg_replace(8211, "&#150;", $content); // en dash
    $content = ereg_replace(150, "&#150;", $content); // en dash
    $content = ereg_replace(8212, "&#151;", $content); // em dash
    $content = ereg_replace(151, "&#151;", $content); // em dash
    $content = ereg_replace(8482, "&#153;", $content); // trademark
    $content = ereg_replace(153, "&#153;", $content); // trademark
    $content = ereg_replace(169, "&copy;", $content); // copyright mark
    $content = ereg_replace(174, "&reg;", $content); // registration mark
    $content = ereg_replace("&nbsp;", " ", $content); // registration mark    

// do it again to make it look right on the form
    //$final = htmlentities("$content",ENT_COMPAT,ISO-8859-15);
?>
     <item>
        <title><?php printf(htmlentities(strip_tags($title))); ?></title>
         <description><?php printf(strip_tags(stripslashes($content))); ?></description> 
        <?php
        printf ("<guid isPermaLink=\"true\">http://www.personal-photo-organizer.com/blog_view.php?organizer_id=".$result['dealer_id']."&amp;blog_id=".$result['blog_id']."</guid>");
        ?>
        <link>http://www.personal-photo-organizer.com/blog_view.php?organizer_id=<?php printf($result['dealer_id']);?>&amp;blog_id=<?php printf($result['blog_id']);?></link>
        
        <pubDate> <?php printf (strftime( "%a, %d %b %Y %H:%M:%S %z" , $result['pubDate'])); ?>
      </pubDate>
     </item>  
<?php } ?>  
</channel>
</rss>

