Data feed file integration price comparison shopping script

Documentation Wiki - DataFeedFile.com - Online merchant datafeed integration for affiliates : DFFyoucustomnoimg

HomePage | Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Home Affiliate FAQ Merchant FAQ Examples Merchants Networks & Programs Forum Blog Wiki Knowledge Base Login

Revision [255]

This is an old revision of DFFyoucustomnoimg made by admin on 2008-07-17 13:56:59.
 

How to use your own customized No Image File


<?php

// DFF_custom_noimg.php
//
// DETECT DFF_PRODUCT SKU IMAGE AVAILABILITY.
// IF AVAIL, OUTPUTS THE ACTUAL IMAGE FROM DFF.
// IF NOT AVAIL, OUTPUT YOUR OWN CUSTOM NO IMAGE FILE
//
// Usage:
// 1. You need to create your own custom 80x80 no image file (gif/jpeg/png)
// 2. You need to specify your own unique etag (entity tag) identifier:
//       etag can be any alphanumeric (no space), preferably less than 30 characters.
//       Using your abreviated site name like: womenaweekshopping is good enough.
// 3. Specify both $your_custom_noimg_pathfile and $your_etag variables values.
// 4. place this PHP file in your PHP web server and point the SRC of IMG tag to this file with sku=<<<DFF_SKU>>> query string parameter.
//
// Example:
// <img src="DFF_custom_noimg.php?sku=_________">
//

// DFF PREDEFINED VARIABLE
$DFF_img_url = 'http://df9.us/c?c=';

// SKU $_GET VARIABLE
$DFF_SKU = FALSE;
if($_GET['sku']!='') $DFF_SKU = intval($_GET['sku']);
if($DFF_SKU==FALSE && $_GET['dff_sku']!='') $DFF_SKU = intval($_GET['dff_sku']);
if($DFF_SKU==FALSE) die('Need to specify sku # into GET query string / URL');

// VARIABLES YOUR NEED TO CUSTOMIZE
$your_custom_noimg_pathfile = '/path/to/your/noimage.gif';
$your_etag = 'mysitecode_noimg80';

$image_content = file_get_contents($DFF_img_url.$DFF_SKU);
$response_headers = $http_response_header;
//echo "<pre>".print_r($response_headers,TRUE)."</pre><br>"; exit;

if(strpos($response_headers[15],'dff-noimg')!==FALSE){
    // SHOW YOUR CUSTOM NO IMAGE FILE HERE (80x80 pixels)
    $noimg_filesize = @filesize($your_custom_noimg_pathfile);
    $noimg_filedate = @filemtime($your_custom_noimg_pathfile);
    if($noimg_filesize==FALSE || $noimg_filedate==FALSE) die('Invalid custom no image file.');
    $request_headers = apache_request_headers();
    if((strpos($request_headers['If-None-Match'],$your_etag)) &&
       (gmstrftime("%a, %d %b %Y %T %Z",$noimg_filedate) == $request_headers['If-Modified-Since'])){
        //STILL THE SAME - USE CACHE
        header('HTTP/1.1 304 Not Modified');
        header('Cache-Control:private');
        header('Pragma:');
        header('Expires:');
        header('Content-Type:');
        header('ETag:"'.$your_etag.'"');
    } else {
        header('Content-Type: image/jpeg');
        header('Content-Transfer-Encoding: binary');
        header('Content-Length:'.$noimg_filesize);
        header('Cache-Control:private');
       header('Pragma:');
       header('Expires:'.gmdate('D, d M Y H:i:s', time() + 30240000).' GMT');
        header('Last-Modified:'.gmdate('D, d M Y H:i:s',$noimg_filedate).' GMT');
        header('ETag:"'.$your_etag.'"');
        readfile($your_custom_noimg_pathfile);
    }
    exit;
} else {
    // IMAGE EXISTS - DELIVER DFF'S PRODUCT IMAGE
    for($i=0; $i<count($response_headers); $i++) if(strpos($response_headers[$i],'200 OK')!==FALSE) break;
    for(; $i<count($response_headers); $i++){
        header($response_headers[$i]);
        echo $image_content;
    }
}

?>

There are no comments on this page. [Add comment]

Integrate price comparison shopping data feed file from thousands of online merchant product data feeds | Valid CSS

Page was generated in 0.1342 seconds