Advertisement
Guest User

Utilisation de preg_replace

a guest
Sep 9th, 2010
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.51 KB | None | 0 0
  1. <?PHP
  2. define ('IN_SITE', 1);
  3. include_once ('../includes/global.php');
  4. $start = intval($_GET["start"]);
  5. $limit = intval($_GET["limit"]);
  6. $results = $db->query("SELECT a.auction_id, a.name,  a.description, a.max_bid,
  7.     a.currency, a.buyout_price, a.start_price, a.max_bid, am.media_url, u.city, u.country, u.zip_code, c.name as country_name
  8.     FROM " . DB_PREFIX . "auctions a
  9.     LEFT JOIN " . DB_PREFIX . "auction_media am ON a.auction_id=am.auction_id AND am.media_type=1 AND am.upload_in_progress=0
  10.     LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=a.owner_id
  11.     LEFT JOIN " . DB_PREFIX . "countries c ON u.country=c.id
  12.     WHERE a.closed=0 AND a.active=1 AND a.approved=1 AND a.deleted=0
  13.     GROUP BY a.auction_id
  14.     ORDER BY a.auction_id LIMIT " . $start . ", " . $limit);
  15. $xml_output = '<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
  16. <!DOCTYPE yakaz SYSTEM "http://www.yakaz.com/yakaz.dtd" >
  17.      <yakaz version="1.0">
  18.      <ad-miscellaneous category="miscellaneous"> <!-- pour chaque autre annonce -->';
  19. while ($row=@mysql_fetch_assoc($results)) {
  20.    $auction_link = process_link('auction_details', array('name' => $row['name'], 'auction_id' => $row['auction_id']));
  21.    if (!empty($row['media_url'])) {
  22.       $picpath = '<img src="' . SITE_PATH . 'thumbnail.php?pic=' . $row['media_url'] . '&w=100">';
  23.    }
  24.    $description = preg_replace('!<[^>]+>!Us', '', html_entity_decode($row['description']));
  25.    $xml_output .= '<what>
  26.     <title>'.($row['name']).'</title>
  27.                <description><![CDATA['.$description.']]></description>
  28.                <ad-url>'.htmlentities($auction_link).'</ad-url>
  29.                <picture-url>'.htmlentities($picpath).'</picture-url>
  30.         <!-- logos proscrits - optionnel -->
  31.                <price unit="euro">'.(($row['max_bid']>0)?$fees->display_amount($row['max_bid'], $row['currency']):$fees->display_amount($row['start_price'], $row['currency'])).'</price>
  32.                <!-- caracteres collés, virgule pour décimales - si pas de prix, mettre 0 - optionnel -->
  33.            </what>
  34.             <where>
  35.                <!-- optionnel -->
  36.                <city-name>'.$db->add_special_chars($row['city']).'</city-name>
  37.                <zip-code>'.$db->add_special_chars($row['zip_code']).'</zip-code>
  38.                <country>'.$db->add_special_chars($row["country_name"]).'</country>
  39.                <!-- code pays : FR pour la France -->
  40.            </where>';
  41.    }
  42.    $xml_output .= '</ad-miscellaneous>
  43.   </yakaz>';
  44. file_put_contents ('monfichier.xml', $xml_output);  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement