PHP Code:
<?php
require('includes/application_top.php');
header('Content-Type: application/rss+xml;charset=UTF-8');
ob_end_clean();
function encodeIfNeeded($text) {
if('utf-8' != strtolower(CHARSET)) {
$text = iconv(CHARSET, 'UTF-8', $text);
}
return $text;
}
function replace_problem_characters($text) {
$formattags = array("&");
$replacevals = array("&");
$text = str_replace($formattags, $replacevals, $text);
$in[] = '@&(amp|#038);@i'; $out[] = '&';
$in[] = '@&(#036);@i'; $out[] = '$';
$in[] = '@&(quot);@i'; $out[] = '"';
$in[] = '@&(#039);@i'; $out[] = '\'';
$in[] = '@&(nbsp|#160);@i'; $out[] = ' ';
$in[] = '@&(hellip|#8230);@i'; $out[] = '...';
$in[] = '@&(copy|#169);@i'; $out[] = '(c)';
$in[] = '@&(trade|#129);@i'; $out[] = '(tm)';
$in[] = '@&(lt|#60);@i'; $out[] = '<';
$in[] = '@&(gt|#62);@i'; $out[] = '>';
$in[] = '@&(laquo);@i'; $out[] = '«';
$in[] = '@&(raquo);@i'; $out[] = '»';
$in[] = '@&(deg);@i'; $out[] = '°';
$in[] = '@&(mdash);@i'; $out[] = '—';
$in[] = '@&(reg);@i'; $out[] = '®';
$in[] = '@&(–);@i'; $out[] = '-';
$text = preg_replace($in, $out, $text);
return $text;
}
function strip_html_tags($str) {
// $document should contain an HTML document.
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent.
$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<[/!]*?[^<>]*?>'si", // Strip out HTML tags
//"'([rn])[s]+'", // Strip out white space
"'&(quot|#34);'i", // Replace HTML entities
// "'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(d+);'e"); // evaluate as php
$replace = array ("",
"",
//"\1",
"\"",
"&",
"<",
">",
" ",
chr(160),
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\1)");
return preg_replace($search, $replace, $str);
}
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<?php
echo '<title>Catalog Feed</title>'. "\n";
// $store=mysqli_fetch_assoc(mysqli_query($db->link,"select * from ".DB_PREFIX."configuration where configuration_key='STORE_NAME'")); // in this "section" of code, $store is not even used and therefore there is no need to perform this query. If it was needed, then:
// $store=$db->Execute("select * from ".TABLE_CONFIGURATION." where configuration_key='STORE_NAME'"); // or if just need the value associated to that key:
// $store = zen_get_configuration_key_value('STORE_NAME');
?><link><?php echo zen_href_link(FILENAME_DEFAULT); ?></link>
<description>Catalog Feed generated by StoreYa.com 2.1</description>
<?php
// * NOTICE OF LICENSE
// *
// * This source file is the property of StoreYa Feed LTD. and a part of its patent pending technology.
// * Using this file is allowed only for the purpose of importing web stores onto Facebook using the service of StoreYa Feed LTD.
// * Do NOT copy/edit/change this file or use it to any service other than the above.
//$admin=mysqli_fetch_assoc(mysqli_query($db->link, "select * from ".DB_PREFIX."admin limit 0,1")); // The variable $admin is also not used in this "section" of code and reveals/provides access to information about the first admin record (admin_id, admin_name, admin_email, the encrypted password(s), etc... and could help lead to a security problem down the line.
// $admin= $db->Execute("select * from ".TABLE_ADMIN." limit 0,1");
?><lastBuildDate><?php echo date('m/d/Y H:is'); ?></lastBuildDate>
<?php
//echo '<copyright>Copyright '.date('Y').', '.$_SERVER['HTTP_HOST'].'</copyright>'. "\n";
if (isset($_GET['language_id'])) {
$lng = new language();
if (isset($_GET['language_id']) && zen_not_null($_GET['language_id'])) {
$lng->language['id'] = (int)$_GET['language_id'];
} else {
if (LANGUAGE_DEFAULT_SELECTOR=='Browser') {
$lng->get_browser_language();
} else {
$lng->set_language(DEFAULT_LANGUAGE);
}
}
$language_id = (zen_not_null($lng->language['id']) ? $lng->language['id'] : 1);
} else {
$language_id = $_SESSION['languages_id'];
}
$prdqry= $db->Execute("select p.products_id,p.products_price,p.products_price_sorter,p.products_image,pd.products_name,pd.products_description,pd.products_url from ".TABLE_PRODUCTS." p,".TABLE_PRODUCTS_DESCRIPTION." pd where p.products_status='1' and p.products_id=pd.products_id and pd.language_id=".(int)$language_id." order by p.products_id ");
while(!$prdqry->EOF)
{
$row = $prdqry->fields;
?><item>
<title><?php echo strip_html_tags(replace_problem_characters(encodeIfNeeded($row['products_name']))); ?></title>
<link><?php echo htmlentities(zen_href_link(zen_get_info_page((int)$row['products_id']), 'products_id='.(int)$row['products_id'])); ?></link>
<description><?php echo htmlspecialchars(strip_html_tags(replace_problem_characters(encodeIfNeeded($row['products_description'])))); ?></description> <g:image_link><?php echo HTTP_SERVER.DIR_WS_IMAGES.$row['products_image']; ?></g:image_link>
<g:id><?php echo $row['products_id']; ?></g:id>
<g:price><?php echo $row['products_price']; ?></g:price>
<g:sale_price><?php echo $row['products_price_sorter']; ?></g:sale_price>
<?php
$catqry=$db->Execute("select categories_name from ".TABLE_CATEGORIES_DESCRIPTION ." cd,".TABLE_PRODUCTS_TO_CATEGORIES." ptc where cd.language_id=".(int)$language_id." and ptc.categories_id=cd.categories_id and ptc.products_id=".(int)$row['products_id']);
while(!$catqry->EOF)
{
$catrow=$catqry->fields;
?> <g:product_type><?php echo strip_html_tags(replace_problem_characters(encodeIfNeeded($catrow['categories_name']))); ?></g:product_type>
<?php
$catqry->MoveNext();
}
?></item>
<?php
$prdqry->MoveNext();
}
?></channel>
</rss>
Bookmarks