Can anyone give me some assistance with the changes to get this working with sql5. I do not want to upgrade to another version as I am running 1.2.5 and have made many customisations. I have the main shop running withsql5 now, but require to get the froogle feed working again.
Here is the code that is causing the error. can someone give me some clues as to what needs changing for sql5 compatability. I think it is to do with the from and join statements
Thanks Laurie
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | license AT zen-cart DOT com so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: froogle.php 12-02-2005 dave AT open-operations DOT com
//
require("includes/application_top.php");
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$OutFile = "froogle/"; //"CHANGEME-full-path-to-file-with-777-dir-and-file-permissions.fr-outfile.txt";
if (is_dir($OutFile)) {
if (!is_writeable($OutFile)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
} else {
$messageStack->add(ERROR_FROOGLE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
$OutFile .= FROOGLE_OUTPUT_FILENAME;
$destination_file = FROOGLE_OUTPUT_FILENAME;
$source_file = $OutFile;
$imageURL = DIR_WS_CATALOG_IMAGES;
$productURLstart = zen_catalog_href_link();
$productURLend.= '_info¤cy=';
$productURLend .= FROOGLE_CURRENCY;
$productURLend .= '&products_id=';
$already_sent = array();
$ftp_directory = ""; // leave blank for froogle
$taxCalc = (FROOGLE_TAX_RATE/100) + 1; //Do not edit
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
<!--
function init()
{
cssjsmenu('navbar');
if (document.getElementById)
{
var kill = document.getElementById('hoverJS');
kill.disabled = true;
}
if (typeof _editor_url == "string") HTMLArea.replaceAll();
}
// -->
</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
</tr>
<tr>
<td><?php echo '<a href="' . zen_href_link(FILENAME_FROOGLE, 'generate') . '"><b>' . IMAGE_FROOGLE_GENERATE . '</b></a>';?></td>
</tr>
<tr>
<td><?php if (isset($_GET['generate'])) { echo '<a href="' . zen_href_link(FILENAME_FROOGLE, 'ftp') . '"><b>' . IMAGE_FROOGLE_FTP . '</a></b>'; } ?></td>
</tr>
<?php
if (isset($_GET['generate'])) {
// Start TIMER
$stimer = explode( ' ', microtime() );
$stimer = $stimer[1] + $stimer[0];
// -----------
$sql = "
SELECT concat( '" . $productURLstart . "',pt.type_handler,'" . $productURLend . "' ,p.products_id) AS product_url,
p.products_model AS prodModel, p.products_weight, p.products_type,
m.manufacturers_name AS mfgName,
m.manufacturers_id,
p.products_id AS id,
pd.products_name AS name,
pd.products_description AS description,
p.products_status AS prodStatus,
FORMAT( IFNULL(s.specials_new_products_price, p.products_price),2) AS price,
p.products_image AS image_url,
pc.categories_id AS prodCatID,
c.parent_id AS catParentID,
cd.categories_name AS catName
FROM " . TABLE_CATEGORIES . " c,
" . TABLE_CATEGORIES_DESCRIPTION . " cd,
" . TABLE_PRODUCTS . " p,
" . TABLE_PRODUCTS_DESCRIPTION . " pd,
" . TABLE_PRODUCTS_TO_CATEGORIES . " pc
left join " . TABLE_MANUFACTURERS . " m on ( m.manufacturers_id = p.manufacturers_id )
left join " . TABLE_SPECIALS . " s on ( s.products_id = p.products_id AND ( (s.expires_date > CURRENT_DATE) OR (s.expires_date = 0) ) )
left join " . TABLE_PRODUCT_TYPES . " pt on p.products_type = pt.type_id
WHERE p.products_price > 0
AND p.products_id=pd.products_id
AND p.products_id=pc.products_id
AND pc.categories_id=c.categories_id
AND c.categories_id=cd.categories_id
ORDER BY
p.products_id ASC
";
$catInfo = "
SELECT
c.categories_id AS curCatID,
c.parent_id AS parentCatID,
cd.categories_name AS catName
FROM
" . TABLE_CATEGORIES . " c,
" . TABLE_CATEGORIES_DESCRIPTION . " cd
WHERE c.categories_id = cd.categories_id
";
function findCat($curID, $catTempPar, $catTempDes, $catIndex)
{
if( (isset($catTempPar[$curID])) && ($catTempPar[$curID] != 0) )
{
if(isset($catIndex[$catTempPar[$curID]]))
{
$temp=$catIndex[$catTempPar[$curID]];
}
else
{
$catIndex = findCat($catTempPar[$curID], $catTempPar, $catTempDes, $catIndex);
$temp = $catIndex[$catTempPar[$curID]];
}
}
if( (isset($catTempPar[$curID])) && (isset($catTempDes[$curID])) && ($catTempPar[$curID] == 0) )
{
$catIndex[$curID] = $catTempDes[$curID];
}
else
{
$catIndex[$curID] = $temp . " > " . $catTempDes[$curID];
}
return $catIndex;
}
$catIndex = array();
$catTempDes = array();
$catTempPar = array();
$processCat = mysql_query( $catInfo )or die( $FunctionName . ": SQL error " . mysql_error() . "| catInfo = " . htmlentities($catInfo) );
while ( $catRow = mysql_fetch_object( $processCat ) )
{
$catKey = $catRow->curCatID;
$catName = $catRow->catName;
$catParID = $catRow->parentCatID;
if($catName != "")
{
$catTempDes[$catKey]=$catName;
$catTempPar[$catKey]=$catParID;
}
}
foreach($catTempDes as $curID=>$des) //don't need the $des
{
$catIndex = findCat($curID, $catTempPar, $catTempDes, $catIndex);
}
$_strip_search = array(
"![\t ]+$|^[\t ]+!m", // remove leading/trailing space chars
'%[\r\n]+%m'); // remove CRs and newlines
$_strip_replace = array(
'',
'');
$_cleaner_array = array(">" => "> ", "®" => "", "®" => "", "™" => "", "™" => "");
if ( file_exists( $OutFile ) )
unlink( $OutFile );
$output = "product_url \t name \t description \t price \t image_url \t category";
if(FROOGLE_OFFER_ID == 'true')
$output .= "\t offer_id ";
if(FROOGLE_IN_STOCK == 'true')
$output .= "\t instock ";
if(FROOGLE_SHIPPING == 'true')
$output .= "\t shipping ";
if(FROOGLE_MANUFACTURER == 'true')
$output .= "\t brand ";
if(FROOGLE_PRODUCT_TYPE_SHOW == 'true')
$output .= "\t product_type ";
if(FROOGLE_FEED_LANGUAGE_DISPLAY == 'true')
$output .= "\t language ";
if(FROOGLE_SHIP_TO_DISPLAY == 'true')
$output .= "\t ship_to ";
if(FROOGLE_SHIP_FROM_DISPLAY == 'true')
$output .= "\t ship_from ";
$output .= "\n";
$result=mysql_query( $sql )or die( $FunctionName . ": SQL error " . mysql_error() . "| sql = " . htmlentities($sql) );
$loop_counter = 0;
while( $row = mysql_fetch_object( $result ) )
{
$final_price = "";
$original_price = zen_get_products_base_price($row->id, false);
$priced_by_attributes = zen_get_products_price_is_priced_by_attributes($row->id, false);
if ( $priced_by_attributes == "" ) { $final_price = $original_price; } else { $final_price = $priced_by_attributes; }
$specials_price = zen_get_products_special_price($row->id, false);
if ( $specials_price == "" ) { $final_price = $original_price; } else { $final_price = $specials_price; }
$final_price = zen_round($final_price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
$final_price_with_tax = $final_price*(FROOGLE_TAX_RATE/100);
$row->price = $final_price+$final_price_with_tax;
if (isset($already_sent[$row->id])) continue; // if we've sent this one, skip the rest of the while loop
if( $row->prodStatus == 1 || (FROOGLE_IN_STOCK == 'true') )
{
// check for a large image else use medium else use small
$products_image = $row->image_url;
$products_image_extention = substr($products_image, strrpos($products_image, '.'));
$products_image_base = ereg_replace($products_image_extention . '$', '', $products_image);
$products_image_medium = $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extention;
$products_image_large = $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extention;
if (!file_exists(DIR_FS_CATALOG_IMAGES . 'large/' . $products_image_large)) {
if (!file_exists(DIR_FS_CATALOG_IMAGES . 'medium/' . $products_image_medium)) {
$image_url = (($products_image == '') ? '' : $imageURL . $products_image);
} else {
$image_url = $imageURL . 'medium/' . $products_image_medium;
}
} else {
$image_url = $imageURL . 'large/' . $products_image_large;
}
$output .= linkencode($row->product_url) . "\t" .
preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->name, $_cleaner_array) ) ) . "\t" .
preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->description, $_cleaner_array) ) ) . "\t" .
preg_replace($_strip_search, $_strip_replace, strip_tags( strtr($row->price, $_cleaner_array) ) ) . "\t" .
linkencode($image_url) . "\t" .
$catIndex[$row->prodCatID];
if(FROOGLE_OFFER_ID == 'true')
$output .= " \t " . $row->id;
if(FROOGLE_IN_STOCK == 'true')
{ if($row->prodStatus == 1) { $prodStatusOut = "Y"; } else { $prodStatusOut = "N"; } $output .= " \t " . $prodStatusOut; }
if(FROOGLE_SHIPPING == 'true')
$output .= " \t " . FROOGLE_SHIPPING_LOW;
if(FROOGLE_MANUFACTURER == 'true')
$output .= " \t " . $row->mfgName;
if(FROOGLE_PRODUCT_TYPE_SHOW == 'true')
$output .= " \t " . FROOGLE_PRODUCT_TYPE;
if(FROOGLE_FEED_LANGUAGE_DISPLAY == 'true')
$output .= " \t " . FROOGLE_FEED_LANGUAGE;
if(FROOGLE_SHIP_TO_DISPLAY == 'true')
$output .= " \t " . FROOGLE_SHIP_TO;
if(FROOGLE_SHIP_FROM_DISPLAY == 'true')
$output .= " \t " . FROOGLE_SHIP_FROM;
$output .= " \n";
}
$already_sent[$row->id] = 1;
$loop_counter++;
if ($loop_counter>750) {
$fp = fopen( $OutFile , "a" );
$fout = fwrite( $fp , $output );
fclose( $fp );
$loop_counter = 0;
$output = "";
}
}
$fp = fopen( $OutFile , "a" );
$fout = fwrite( $fp , $output );
fclose( $fp );
chmod($OutFile, 0777);
$etimer = explode( ' ', microtime() );
$etimer = $etimer[1] + $etimer[0];
?>
<tr>
<td class="smallText"><?php echo FROOGLE_FILE_COMPLETE . ' ' . FROOGLE_TIME_TAKEN; ?><?php printf(" <b>%f</b> " . FROOGLE_SCRIPT_SECONDS, ($etimer-$stimer) ); ?></td>
</tr>
<tr>
<td class="smallText"><?php echo FROOGLE_VIEW_FILE . ' ' . '<a href="' . $OutFile . '" target="_new"><b>' . $destination_file . '</b></a>'; ?>
</tr>
<?php
}
if (isset($_GET['ftp'])) {
//Start FTP to Froogle
function ftp_file( $ftpservername, $ftpusername, $ftppassword, $ftpsourcefile, $ftpdirectory, $ftpdestinationfile )
{
// set up basic connection
$conn_id = ftp_connect($ftpservername);
if ( $conn_id == false )
{
?>
<tr>
<td class="main"><?PHP echo FROOGLE_CONNECTION_FAILED . $ftpservername; ?></td>
</tr>
<?php
return false;
}



