Jeg har lavet en backend.php der udtrækker nyheder til XML output. Den virker fint.
Jeg ønsker at lave en fil der ændrer output hvis man ændrer url'en. Feks. backend.php?lang=eng eller backend.php?lang=dan. Så den henter artikler med engelsk ved den ørste, og artikler på dansk ved den anden. Hvad gør jeg. Du behøver ikke lave hele filen for mig, men hvis du kan fortælle mig hvad jeg evt. kan gøre for at løse opgaven - så er jeg ligeså glad.
$backend_language = eng;
$xml_lang_code = 'en-us';
$headline_limit = 10;
$topiconly = 0;
$show_content = 0;
include 'includes/pnAPI.php';
pnInit();
header("Content-Type: text/xml");
$title = pnVarPrepForDisplay(pnConfigGetVar('sitename'));
$link = pnVarPrepForDisplay(pnGetBaseURL());
$description = pnVarPrepForDisplay(pnConfigGetVar('backend_title'));
$webmaster = pnVarPrepForDisplay(pnConfigGetVar('adminmail'));
$managingeditor = "" ;
$image_url = $link.'images/'.pnVarPrepForDisplay(pnConfigGetVar('site_logo'));
if (file_exists("images/".$backend_language."-".pnVarPrepForDisplay(pnConfigGetVar('site_logo')) )) {
$image_url = $link.'images/'.$backend_language.'-'.pnVarPrepForDisplay(pnConfigGetVar('site_logo')); }
$image_title = $title;
$image_link = $link;
$topicnameauth = "&pnDBGetTables()['topics_column'][topicname]";
if ($topiconly == 0) {
$query = "SELECT pn_sid, pn_title, pn_ihome, pn_hometext, pn_language FROM nuke_stories WHERE (pn_language = '$backend_language' or pn_language = '' ) AND pn_ihome = 0 ORDER BY pn_sid DESC";
} else {
$query = "SELECT pn_sid, pn_title, pn_ihome, pn_hometext, pn_language FROM nuke_stories WHERE (pn_language = '$backend_language' or pn_language = '' ) AND pn_topic = $topiconly ORDER BY pn_sid DESC";
}
$sql = $query;
$auth = pnSecAuthAction(0, 'Topics::Topic',"$topicnameauth::$tid",ACCESS_OVERVIEW);
$result = $dbconn->SelectLimit($sql,$headline_limit,$auth);
if ($result === false) {
echo "\n\n<font class=\"pn-normal\">An error occured</font>";
} else {
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";
echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//$xml_lang_code\"\n";
echo " \"
http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n";
echo "<rss version=\"0.91\">\n\n";
echo "<channel>\n";
echo "<title>$title</title>\n";
echo "<link>$link</link>\n";
echo "<description>$description</description>\n";
echo "<language>$xml_lang_code</language>\n";
echo "<image>\n";
echo " <title>$image_title</title>\n";
echo " <url>$image_url</url>\n";
echo " <link>$image_link</link>\n";
echo "</image>\n";
echo "<webMaster>$webmaster</webMaster>\n";
if ($managingeditor != "") {
echo "<managingEditor>$managingeditor</managingEditor>\n";
};
while(list($sid, $title,$ihome,$hometext, $language) = $result->fields) {
$title = pnVarPrepHTMLDisplay($title);
$storylang = pnVarPrepForDisplay($language);
$topicname = pnVarPrepForDisplay($topicname);
$link = pnVarPrepForDisplay(pnGetBaseURL() . "modules.php?op=modload&name=News&file=article&sid=$sid&newlang=$storylang");
$content = pnVarPrepForDisplay($hometext);
echo "<item>\n";
echo "<title>$title</title>\n";
echo "<link>$link</link>\n";
if ($show_content) {
echo "<description>\n";
echo "<textarea>".$content."</textarea>";
echo "</description>\n";
};
echo "</item>\n";
$result->MoveNext();
}
echo "</channel>\n";
echo "</rss>\n";
}