<?php

/* -----------------------------------------------------------------
 * 	$Id: rss_reader.php 704 2013-11-01 19:00:49Z akausch $
 * 	Copyright (c) 2011-2021 commerce:SEO by Webdesign Erfurt
 * 	http://www.commerce-seo.de
 * ------------------------------------------------------------------
 * 	based on:
 * 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
 * 	(c) 2002-2003 osCommerce - www.oscommerce.com
 * 	(c) 2003     nextcommerce - www.nextcommerce.org
 * 	(c) 2005     xt:Commerce - www.xt-commerce.com
 * 	Released under the GNU General Public License
 * --------------------------------------------------------------- */


$module_smarty = new Smarty;
$module_smarty->assign('tpl_path', 'templates/' . CURRENT_TEMPLATE . '/');

//get the q parameter from URL
// $q=$_GET["q"];
//find out which feed was selected
// if($q=="Google")
// {
// $xml=("http://news.google.com/news?ned=us&topic=h&output=rss");
// }
// elseif($q=="MSNBC")
// {
// $xml=("http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml");
// }

$xml = ("http://www.commerce-seo.de/blog_rss.php");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

//get elements from "<channel>"
$channel = $xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;

//output elements from "<channel>"
$rss_channel = "<p><a target=\"_blank\" href='" . $channel_link . "'>" . $channel_title . "</a>";
$rss_channel .= "<br>";
$rss_channel .= $channel_desc . "</p>";

//get and output "<item>" elements
$x = $xmlDoc->getElementsByTagName('item');
for ($i = 0; $i <= 2; $i++) {
    $item_title = $x->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;
    $item_link = $x->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;
    $item_desc = $x->item($i)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;

    $rss_feed .= "<p><h3><a target=\"_blank\" href='" . $item_link . "?refID=youvision'>" . $item_title . "</a></h3>";
    $rss_feed .= "<br>";
    $rss_feed .= $item_desc . "</p>";
    $rss_feed .= "<br>";
}

// $default_smarty->assign('rssfeed', $rss_feed);
// $default_smarty->assign('rss_channel', $rss_channel);
// if (sizeof($items) >= 1) {
$module_smarty->assign('language', $_SESSION['language']);
$module_smarty->assign('rss_feed', $rss_feed);
$module_smarty->assign('rss_channel', $rss_channel);
$module_smarty->assign('DEVMODE', USE_TEMPLATE_DEVMODE);

// set cache ID
if (!CacheCheck()) {
    $module_smarty->caching = false;
    $module = $module_smarty->fetch(cseo_get_usermod(CURRENT_TEMPLATE . '/module/main_feed.html', USE_TEMPLATE_DEVMODE));
} else {
    $module_smarty->caching = true;
    $module_smarty->cache_lifetime = CACHE_LIFETIME;
    $module_smarty->cache_modified_check = CACHE_CHECK;
    $cache_id = $new_products_category_id . $_SESSION['language'] . $_SESSION['customers_status']['customers_status_name'] . $_SESSION['currency'];
    $module = $module_smarty->fetch(cseo_get_usermod(CURRENT_TEMPLATE . '/module/main_feed.html', USE_TEMPLATE_DEVMODE), $cache_id);
}
$default_smarty->assign('MODULE_main_feed', $module);
// }


