X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Need Help w/Smarty & Fetching (https://forum.x-cart.com/showthread.php?t=1397)

ATKOgirl 02-04-2003 11:04 PM

Need Help w/Smarty & Fetching
 
Hi,

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?

The script I have looks like this:

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.

ATKOgirl

B00MER 02-06-2003 11:07 PM

ATKOGirl, you'll need to learn Regular Expressions, as it seems the page is fetched, then the content is stripped, and spit out to where ever you want.

How I learned:
:arrow: http://www.evolt.org/article/Regular_Expression_Basics/20/22700/index.html?format=print

;)


All times are GMT -8. The time now is 02:16 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.