Bonjour à tous,

J'espère avoir poster dans le bon forum. A defaut si un modo pouvait le déplacer dans une rubrique plus adaptée. Merci.

Je tente de mettre en place un flux RSS via un script php en include.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//global $database, $mainframe, $my, $Itemid;

$now = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 );

$menu= new mosMenu( $database );
$menu->load( 1 );
$params = mosParseParams( $menu->params );



$count = isset( $params->count ) ? $params->count : 10;
$orderby = @$params->orderby;

switch (strtolower( $orderby )) {
	case 'Most recent ads first':
		$orderby = "date_created DESC";
		break;
	case 'Most viewed ads first':
		$orderby = "views DESC";
		break;
	default:
		$orderby = "date_created DESC";
		break;
}

//$description = $params->get( 'description' );
 $description = isset( $params->description ) ? $params->description : "";   
 $title = isset( $params->title ) ? $params->title : "";  
	
$sql = "SELECT id, ad_headline, ad_text, date_created, views FROM #__adsmanager_ads "
		. "\nWHERE published='1' "
	  . "\nORDER BY ".$orderby
    . ($count ? " LIMIT $count" : "");
	
$database->setQuery( $sql );

$rows = $database->loadObjectList();

header('Content-type: application/xml');
$encoding = split("=", _ISO);
echo "<?xml version=\"1.0\" encoding=\"".$encoding[1]."\"?>"; ?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<title><?php echo htmlspecialchars($mosConfig_sitename); ?></title>
<link><?php echo $mosConfig_live_site; ?></link>
<description><?php echo $description ?></description>
<language>en-us</language>
<lastBuildDate><?php $date = date("r"); echo "$date";?></lastBuildDate>
	<image>
	<title><?php echo $title ?></title>
	<url><?php echo $mosConfig_live_site; ?>/modules/mod_adsmanager_rssfeed/rss.png</url>
	<link><?php echo $mosConfig_live_site; ?></link>
	<width>88</width>
	</image>
<?php
foreach ($rows as $row) {
	echo ("<item>");
	echo ("<title>".htmlspecialchars($row->ad_headline)."</title>"."\n");
	echo "<link>";
	if ($mosConfig_sef == "1"){
		echo sefRelToAbs("index.php?option=com_adsmanager&amp;page=show_ad&amp;adid=".$row->id);
	} else {
		echo $mosConfig_live_site . "/index.php?option=com_adsmanager&amp;page=show_ad&amp;adid=" . $row->id;
	}
	echo "</link>\n";
	$words = $row->ad_text;
	$words = preg_replace("'<script[^>]*>.*?</script>'si","",$words);
	$words = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2 (\1)', $words);
	$words = preg_replace('/<!--.+?-->/','',$words);
	$words = preg_replace('/{.+?}/','',$words);
	$words = preg_replace('/&nbsp;/',' ',$words);
	$words = preg_replace('/&amp;/',' ',$words);
	$words = preg_replace('/&quot;/',' ',$words);
	$words = strip_tags($words);
	$words = htmlspecialchars($words);
	echo ("<description>".substr($words,0,100)."...</description>"."\n");
	echo ("</item>"."\n");
}
?>
</channel>
</rss>
Le navigateur me retourne ce message d'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
Erreur d'analyse XML : instruction de traitement XML pas au début d'une entité externe
Emplacement : http://www.arkenia.com/test/index2.php?option=com_adsmanager&page=rss&no_html=1
Numéro de ligne 2, Colonne 1 :<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">
^
La source de ce message d'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<title>OccasionPhoto.fr</title>
<link>http://www.arkenia.com/test</link>
<description></description>
<language>en-us</language>
<lastBuildDate>Sun, 25 Nov 2007 15:05:39 +0100</lastBuildDate>
	<image>
	<title></title>

	<url>http://www.arkenia.com/test/modules/mod_adsmanager_rssfeed/rss.png</url>
	<link>http://www.arkenia.com/test</link>
	<width>88</width>
	</image>
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/www/arkenia/www/test/modules/mod_adsmanager_rssfeed/rss.adsmanager.php</b> on line <b>61</b><br />

</channel>
</rss>
Aperçu ci-dessous

-http://www.arkenia.com/test/index2.php?option=com_adsmanager&page=rss&no_html=1

P"tit coup main please.

Merci.