Ciao, ho un sistema di gestione di news al quale sto tentando di aggiungere un feed rss, inserendo la classe descritta qui:
> Creazione di un file rss
Questa è la parte di codice che inserisce i nuovi post nel database; dopo questo punto come si vede ho incluso il mio richiamo alla classe che crea il feed rss:
Codice PHP:
### Add a new news into DB
$subject = cn_htmltrans($_POST['subject'],'text');
$content = cn_htmltrans($_POST['content'],'text');
$content2 = cn_htmltrans($_POST['content2'],'text');
if(!isset($_POST[cat])) { $_POST[cat] = 0; }
if(empty($_POST[subject]) || empty($_POST[content])) { print E("You have not filled in a subject and/or content for your news post"); }
if(!in_array($_POST[cat], $ucats) && $useri[categories] != "all") { print E("You are not allowed to add news posts out of your category permisions"); }
$q[add] = mysql_query ("INSERT INTO $t_news (id, author, cat, subject, content, content2, sumstory, date, source, sourceurl) VALUES ('', '$useri[id]', '$_POST[cat]', '$subject', '$content', '$content2', '$_POST[sumstory]', '$now', '$_POST[source]', '$_POST[sourceurl]')", $link) or E("Could not insert news:
" . mysql_error());
### RSS PROVA 1.0
# $permalink = ('http://www.guardaqua.it/primapagina.php?a=',"$id");
include('../rss/classe.php'); $r = new MakeRSS('GuardaQua (news)', 'http://www.guardaqua.it', 'Sommario di tutti gli argomenti trattati');
$r->AddArticle($subject, $permalink, $content, $author);
$r->Output(true, '../rss.xml');
### FINE RSS
echo S("New news has been added");
exit;
}
Il mio problema sta nel permalink: così com'è impostata, la variabile $permalink (commentata qui), non crea correttamente l'url (anzi mi dice:
Parse error: parse error, unexpected ',' in /home/mhd-03/www.guardaqua.it/htdocs/news/index.php on line 22
Lo stesso programma, per generare questo url nell'output dei post lunghi, usa questo codice:
Codice PHP:
if($r[sumstory] == "on") {
$output = str_replace("{news}", "$content[size="1"]<a href=\"" . $_SERVER['PHP_SELF'] . "?a=$r[id]\">Leggi tutto...</a>[/size]", $output);
generando un link del tipo
http://www.guardaqua.it/primapagina.php?a=22 (essendo incluso nel file primapagina.php)
Come faccio a passargli l'url corretto come variabile da sindacare nel feed assieme alle altre ($subject, $news ecc)?