I need to "fetch" my product descriptions from my suppliers web site. I found a script to do in with regular information, but does anyone know how to do it using the db and Smarty?
Code:
<?php
$theLocation="http://www.site.com/bc/display.product.asp?product=0684837277";
$startingpoint = "Overview: </font>[/b]</td>";
$endingpoint = "";
// - "Don't touch this part..."
preg_match("/^(https?:\/\/)?([^\/]*)(.*)/i", "$theLocation", $matches);
$theDomain = "http://" . $matches[2];
$page = $matches[3];
$fd = fopen($theDomain.$page, "r"); // can change to "rb", on NT/2000 servers, if problems.
$value = "";
while(!feof($fd)){
$value .= fread($fd, 4096);
}
fclose($fd);
$start= strpos($value, "$startingpoint");
$finish= strpos($value, "$endingpoint");
$length= $finish-$start;
$value=substr($value, $start, $length);
// end "don't touch this part"
$value = eregi_replace( "<IMG alt=[^>]*>", "", $value );
$value = eregi_replace( "<class[^>]*>", "", $value );
$value = eregi_replace( "<table[^>]*>", "", $value );
$value = eregi_replace( "<tr[^>]*>", "", $value );
$value = eregi_replace( "<td[^>]*>", "", $value );
$value = str_replace( "</font>", "", $value ); // Remove closing </font> tags.
$value = str_replace( "</table>", "", $value ); // Remove closing </table> tags.
$value = str_replace( "</tr>", "", $value ); // Remove closing </tr> tags.
$value = str_replace( "</td>", "", $value ); // Remove closing </td> tags.
$value = str_replace( "<center>", "", $value ); // Remove <center> tag...
$value = str_replace( "</center>", "", $value ); // ...alignment calls.
$value = str_replace( "", "", $value ); // Remove tags.
$value = str_replace( "", "", $value ); // Remove closing tags...
$value = str_replace( "Overview: [/b]", "", $value ); // Remove Overview:...
$FinalOutput = preg_replace("/(href=\"?)(\/[^\"\/]+)/", "\\1" . $theDomain . "\\2", $value);
echo $FinalOutput; //prints it to your page
flush (); //force output to your page faster
?>
However, this is extremely slow and I have no clue how I would integrate it to work with x-cart and smarty. Any help is greatly appreciated.