attributes = $childText; break; default: foreach($childText as $childNodeName => $childNodeText){ $nodes[$node_count]->insertChildNode(getNewNode($childNodeName,$childNodeText)); } } }else{ switch($nodeName){ case 'guid': $nodes[$node_count]->attributes=array('isPermaLink' => 'true'); break; } $nodes[$node_count]->insertChildText(htmlspecialchars($childText)); } return $nodes[$node_count]; } $cdb=mysql_get_cx(); $sql=" select MAX(v.validato) from jpuzzles.puzzles p join jpuzzles.validation v on v.puzz_id = p.puzz_id where 1 and p.partner='@' and v.status = 'VALIDATED' and v.lang ='{$lang}' "; $res=mysql_get_result($sql,$cdb); list($pub_date) = mysql_fetch_row($res); $rssNode = new TreeNode('rss'); $rssNode->attributes = array('version' => '2.0', 'xmlns:atom' => "http://www.w3.org/2005/Atom", 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/'); $channelNode = new TreeNode('channel'); $atomLink = getNewNode('atom:link'); $atomLink->attributes = array('href' => "http://" . $_SERVER['HTTP_HOST'] . "/export/rss/" . $trans['rss.page.url'] . ".xml", 'rel' => "self", 'type' => "application/rss+xml"); $channelNode->insertChildNode($atomLink); $nodesDefinition=array( 'title' => $trans['rss.page.title'], 'link' => $trans['rss.page.link'], 'image' => array( 'url' => $trans['rss.page.image.url'], 'link' => $trans['rss.page.image.link'], 'width' => 144, 'height' => intval($trans['rss.page.image.height']*144/225), 'title' => $trans['rss.page.title'], ), 'description' => $trans['rss.page.description'], 'language' => $trans['rss.page.language'], 'copyright' => 'Copyright '.date("Y").' '.$trans['rss.page.copyright'], 'webMaster' => $trans['rss.page.webmaster'].' (Lal)', 'pubDate' => date("r", max(mktime(0,0,0,date("m"),date("d"),date("Y")), strtotime($pub_date))), 'lastBuildDate' => date("r", strtotime($pub_date)), 'category' => $trans['rss.page.category'], 'generator' => 'PHP '.phpversion().' / xml2tree 0.2', 'ttl' => '60', ); foreach($nodesDefinition as $nodeName => $childText){ $channelNode->insertChildNode(getNewNode($nodeName,$childText)); } $sql=" select * from jpuzzles.puzzles p join jpuzzles.validation v on v.puzz_id = p.puzz_id where 1 and p.partner='@' and v.status = 'VALIDATED' and v.lang ='{$lang}' order by p.pub_date desc limit 0, 25 "; $res=mysql_get_result($sql,$cdb); while($puzzle_set = mysql_fetch_object($res)){ $link = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $trans['your_puzzles.page_prefix'] . '-1,1,1,' . $puzzle_set->puzz_id . '.html'; if($puzzle_set->disposition == 'h'){ $category = $trans['admin.puzzle.format.label']['landscape_standard']; } else if($puzzle_set->disposition == 'v'){ $category = $trans['admin.puzzle.format.label']['portrait_standard']; } else if($puzzle_set->disposition == '#' && $puzzle_set->img_w >= $puzzle_set->img_h){ $category = $trans['admin.puzzle.format.label']['landscape_large']; } else if($puzzle_set->disposition == '#' && $puzzle_set->img_w < $puzzle_set->img_h){ $category = $trans['admin.puzzle.format.label']['portrait_large']; } else { $category = $trans['admin.puzzle.format.label']['other']; } $itemNodes=array( 'title' => strtr($puzzle_set->title, array(' ' => ' ')), 'link' => $link, 'enclosure' => array( 'url' => 'http://' . $_SERVER['HTTP_HOST'] . '/jpuzzles/' . $reductions_dir . '/' . $puzzle_set->filename . '.jpg', 'length' => @filesize('../../jpuzzles/' . $reductions_dir . '/' . $puzzle_set->filename . '.jpg'), 'type' => 'image/jpeg', ), 'description' => '', 'guid' => $link, 'category' => $category, 'pubDate' => date("r", strtotime($puzzle_set->validato)), 'comments' => $link, ); $channelNode->insertChildNode(getNewNode('item',$itemNodes)); } @mysql_close($cdb); $rssNode->insertChildNode($channelNode); $xml_tree="\n"; $xml_tree.="\n"; $rssNode->printOut($xml_tree); header('Content-Type: application/xml'); echo $xml_tree;