Code:
<?php
// Title: Froogle Data Feeder 1.62
// Author: Calvin K
// Contact: calvink@conceptulanetworking.com
// Organization: Conceptual Networking
// Last Update: 12/21/05
//
// This feeder has been revised to work with Ultimate SEO URLs 2.1d (
//http://www.oscommerce.com/community/contributions,2823)
//
// Change to 'false' to disable the use of SEO
define('SEO_ENABLED','false');
if(SEO_ENABLED=='true'){
//********************
// Modification for SEO
// Since the ultimate SEO was only installed on the public side, we will include our files from there.
require_once('../includes/configure.php');
require_once('../includes/filenames.php');
require_once('../includes/database_tables.php');
$languages_id = 1; // CHANGEME - Change this to the id of your language. BY default 1 is english
include_once('../' .DIR_WS_CLASSES . 'seo.class.php');
$seo_urls = new SEO_URL($languages_id);
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
global $seo_urls;
return $seo_urls->href_link($page, $parameters, $connection, $add_session_id);
}
}
//********************
// Start TIMER
// -----------
$stimer = explode( ' ', microtime() );
$stimer = $stimer[1] + $stimer[0];
// -----------
$OutFile = "../feeds/paquins_s7_dion_ne_jp.txt"; //"CHANGEME-full-path-to-file-with-777-dir-and-file-permissions.fr-outfile.txt";
$destination_file = "paquins_s7_dion_ne_jp.txt"; //"CHANGEME-filename-to-upload-to-froogle.txt" ;
$source_file = $OutFile;
$imageURL = 'http://www.fukuokafishingadventures.com/tsurishopjapan/images/';
if(SEO_ENABLED=='true'){
$productURL = 'product_info.php'; // ***** Revised for SEO
$productParam = "products_id="; // ***** Added for SEO
}else{
$productURL = 'http://www.fukuokafishingadventures.com/tsurishopjapan/product_info.php ?products_id=';
}
$already_sent = array();
if(SEO_ENABLED=='true'){
$home = localhost; // ****** revised these because we can....
$user=fukuokaf_XXXX;
$pass=XXXXXX;
$base=fukuokaf_Nigel ;
}else{
$home = "localhost" ;
$user="fukuokaf_Nigel ";
$pass="XXXXX";
$base="fukuokaf_XXXX ";
}
$ftp_server = "hedwig.google.com" ;
$ftp_user_name = "tsurishopjapan";
$ftp_user_pass = "XXXXXXXX";
$ftp_directory = ""; // leave blank for froogle
$taxRate = 0; //default = 0 (e.g. for 17.5% tax use "$taxRate = 17.5;")
$taxCalc = ($taxRate/100) + 1; //Do not edit
$convertCur = true; //default = false
$curType = "USD"; // Converts Currency to any defined currency (eg. USD, EUR, GBP)
if($convertCur)
{
if(SEO_ENABLED=='true'){
$productParam="currency=" . $curType . "&products_id=";
}else{
$productURL = "http://www.fukuokafishingadventures.com/tsurishopjapan/product_info.php ?currency=" . $curType . "&products_id="; //where CURTYPE is your currency type (eg. USD, EUR, GBP)
}
}
//START Advance Optional Values
//(0=False 1=True) (optional_sec must be enabled to use any options)
$optional_sec = 0;
$instock = 0;
$shipping = 0;
$lowestShipping = "4.95"; //this is not binary.
$brand = 0;
$upc = 0; //Not supported by default osC
$manufacturer_id = 0; //Not supported by default osC
$product_type = 0;
$currency = 0;
$default_currency = "USD"; //this is not binary.
$feed_language = 0;
$default_feed_language = "en"; //this is not binary.
$ship_to = 0;
$default_ship_to = "ALL"; //this is not binary, not supported by default osC for individual products.
$ship_from = 0;
$default_ship_from = "JPN"; //this is not binary, not supported by default osC for individual products.
//END of Advance Optional Values
if (!($link=mysql_connect($home,$user,$pass)))
{
echo "Error when connecting itself to the data base";
exit();
}
if (!mysql_select_db( $base , $link ))
{
echo "Error the data base does not exist";
exit();
}
$sql = "
SELECT concat( '" . $productURL . "' ,products.products_id) AS product_url,
products_model AS prodModel, products_weight,
manufacturers.manufacturers_name AS mfgName,
manufacturers.manufacturers_id,
products.products_id AS id,
products_description.products_name AS name,
products_description.products_description AS description,
products.products_quantity AS quantity,
products.products_status AS prodStatus,
FORMAT( IFNULL(specials.specials_new_products_price, products.products_price) * " . $taxCalc . ",2) AS price,
CONCAT( '" . $imageURL . "' ,products.products_image) AS image_url,
products_to_categories.categories_id AS prodCatID,
categories.parent_id AS catParentID,
categories_description.categories_name AS catName
FROM categories,
categories_description,
products,
products_description,
products_to_categories
left join manufacturers on ( manufacturers.manufacturers_id = products.manufacturers_id )
left join specials on ( specials.products_id = products.products_id AND ( ( (specials.expires_date > CURRENT_DATE) OR (specials.expires_date = 0) ) AND ( specials.status = 1 ) ) )
WHERE products.products_id=products_description.products_id
AND products.products_id=products_to_categories.products_id
AND products_to_categories.categories_id=categories.categories_id
AND categories.categories_id=categories_description.categories_id
ORDER BY
products.products_id ASC
";
$catInfo = "
SELECT
categories.categories_id AS curCatID,
categories.parent_id AS parentCatID,
categories_description.categories_name AS catName
FROM
categories,
categories_description
WHERE categories.categories_id = categories_description.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(">" => "> ", "®" => "", "®" => "", "™" => "", "™" => "", "\t" => "", " " => "");
if ( file_exists( $OutFile ) )
unlink( $OutFile );
$output = "product_url \t name \t description \t price \t image_url \t category \t offer_id";
//create optional section
if($optional_sec == 1)
{
if($instock == 1)
$output .= "\t instock ";
if($shipping == 1)
$output .= "\t shipping ";
if($brand == 1)
$output .= "\t brand ";
if($upc == 1)
$output .= "\t upc ";
if($manufacturer_id == 1)
$output .= "\t manufacturer_id ";
if($product_type == 1)
$output .= "\t product_type ";
if($currency == 1)
$output .= "\t currency ";
if($feed_language == 1)
$output .= "\t language ";
if($ship_to == 1)
$output .= "\t ship_to ";
if($ship_from == 1)
$output .= "\t ship_from ";
}
$output .= "\n";
$result=mysql_query( $sql )or die( $FunctionName . ": SQL error " . mysql_error() . "| sql = " . htmlentities($sql) );