$v){ $_GET[$k] = rawurldecode(strip_tags($v)); } //------------------------------------------------------------------------------ // Extract product attributes from $_GET if available //------------------------------------------------------------------------------ if(isset($_GET["linkto"])) $linkto = $_GET['linkto']; if(isset($_GET["productid"])) $productid = $_GET['productid']; if(isset($_GET["product"])) $product = $_GET['product']; if(isset($_GET["tmbn_url"])) $tmbn_url = $_GET['tmbn_url']; //------------------------------------------------------------------------------ // Identify page to link // // If the linkto file is a physical ".html" file in the root directory use the linkto URL. // Otherwise try to find the best matching ".html" file in the root // If all else fails link to the home page. // //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // Setup working elements //------------------------------------------------------------------------------ $root = getenv('DOCUMENT_ROOT'); if($root[strlen($root)-1]!=="/") $root.="/"; $host = "http://".$_SERVER["HTTP_HOST"]."/"; $url_info = parse_url($linkto); $img_info = parse_url($tmbn_url); //------------------------------------------------------------------------------ // If the linkto file is a physical ".html" file in the root directory use the linkto URL. //------------------------------------------------------------------------------ if((strpos($linkto,".html")!==false)){ if(is_file($root.$url_info["path"])) $link_URL = $host.$url_info["path"]; } //------------------------------------------------------------------------------ // If not found try a URL based on the product ID and product name //------------------------------------------------------------------------------ if($link_URL==""){ $product_url = str_replace(" ","-",$product); preg_replace("/[^0-9a-zA-Z_-]/","",$product_url); $product_url .= "-p-$productid.html"; if(is_file($host.$product_url)) $link_URL = $host.$product_url; } //------------------------------------------------------------------------------ // If not found search for an HTML file using the product ID only //------------------------------------------------------------------------------ if(($link_URL=="")&&($productid!=="")){ $d = dir($root); $search = $productid.".html"; while (false !== ($entry = $d->read())) { if(strpos($entry, $search)!==false) $url_list[]=$entry; } $d->close(); if(count($url_list)>0) $link_URL = $host.$url_list[0]; } //------------------------------------------------------------------------------ // If not found link to the referring page //------------------------------------------------------------------------------ if($link_URL=="") $link_URL = $linkto; //------------------------------------------------------------------------------ // Last resort: If not found link to the home page //------------------------------------------------------------------------------ if($link_URL=="") $link_URL = $host; //------------------------------------------------------------------------------ // Check that thumbnail image exists if defined in $_GET //------------------------------------------------------------------------------ if(isset($tmbn_url)){ if(is_file($root.$img_info["path"])) $image_URL = $tmbn_url; } //------------------------------------------------------------------------------ // Load target page and parse out product name and thumbnail if required //------------------------------------------------------------------------------ if(($product=="")||($image_URL=="")){ ob_start(); include ( $link_URL ); $html = ob_get_contents(); ob_end_clean(); } if($product==""){ // Extract product name preg_match("/
"; $output .= "$product
"; $output .= "Available from Link to this
"; ?>
\n\n "; */ ?>Option 1: Link for Email or IM
Option 2: Copy and paste HTML
Option 3: Image URL