query('SET NAMES CP1251;', __FILE__, __LINE__, $db->error()); // Get the forum config $result = $db->query('SELECT * FROM '.$db->prefix.'config') or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error()); while ($cur_config_item = $db->fetch_row($result)) $pun_config[$cur_config_item[0]] = $cur_config_item[1]; // Make sure we (guests) have permission to read the forums $result = $db->query('SELECT g_read_board FROM '.$db->prefix.'groups WHERE g_id=3') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); if ($db->result($result) == '0') exit('No permission'); // Attempt to load the common language file @include PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/common.php'; if (!isset($lang_common)) exit('There is no valid language pack \''.$pun_config['o_default_lang'].'\' installed. Please reinstall a language of that name.'); // parse RSS ob_start(); // make feed if (!empty($_GET["cid"])) { $where = " AND c.id = '".intval($_GET['cid'])."'"; $title = 'cid'; } else if (!empty($_GET["fid"])) { $where = " AND f.id = '".intval($_GET['fid'])."'"; $title = 'fid'; } else if (!empty($_GET["tid"])) { $where = " AND t.id = '".intval($_GET['tid'])."'"; $title = 'tid'; } else { $where = ''; $title = ''; } $result = $db->query(" SELECT p.id AS id, p.message AS message, p.posted AS postposted, t.subject AS subject, f.forum_name, c.cat_name, p.poster FROM ".$db->prefix."posts p LEFT JOIN ".$db->prefix."topics t ON p.topic_id=t.id INNER JOIN ".$db->prefix."forums AS f ON f.id=t.forum_id LEFT JOIN ".$db->prefix."categories AS c ON f.cat_id = c.id LEFT JOIN ".$db->prefix."forum_perms AS fp ON ( fp.forum_id=f.id AND fp.group_id=3 ) WHERE ( fp.read_forum IS NULL OR fp.read_forum=1 ) $where ORDER BY postposted DESC LIMIT 0,15 ") or error('Unable to fetch forum posts', __FILE__, __LINE__, $db->error());; $i = 0; while ($cur = $db->fetch_assoc($result)) { if ($i == 0) { putHeader($cur, $title); $i++; } putPost($cur); } echo ""; // get feed into $feed $feed = ob_get_contents(); ob_end_clean(); // create ETAG (hash of feed) $eTag = '"'.md5($feed).'"'; header('Etag: '.$eTag); // compare Etag to what we got if ($eTag == $_SERVER['HTTP_IF_NONE_MATCH']) { header("HTTP/1.0 304 Not Modified"); header('Content-Length: 0'); } else { // dump feed header ("Content-type: text/xml"); echo $feed; } function putHeader($cur, $title) { switch ($title) { case "cid": $title = ' : '.$cur['cat_name']; break; case "fid": $title = ' : '.$cur['cat_name'].' : '.$cur['forum_name']; break; case "tid": $title = ' : '.$cur['cat_name'].' : '.$cur['forum_name'].' : '.$cur['subject']; break; default: $title = ''; break; } global $lang_common,$pun_config; echo '<'.'?xml version="1.0" encoding="'.$lang_common['lang_encoding'].'"?'.'>'."\n"; echo "\n"; echo "\n"; //echo "".entity_to_decimal_value(htmlspecialchars($pun_config['o_board_title'].$title))."\n"; echo "".htmlspecialchars($pun_config['o_board_title'].$title)."\n"; echo "".$pun_config['o_base_url']."\n"; //echo "".entity_to_decimal_value(htmlspecialchars($rss_description.' '.$pun_config['o_board_title']))."\n"; echo "".htmlspecialchars($rss_description.' '.$pun_config['o_board_title'])."\n"; //echo "en\n"; echo "http://backend.userland.com/rss\n"; } function putPost($cur) { global $lang_common, $pun_config; echo "\n"; //echo "".entity_to_decimal_value(htmlspecialchars($cur['cat_name'].' :: '.$cur['forum_name'].' :: '.$cur['subject']))."\n"; echo "".htmlspecialchars($cur['cat_name'].' :: '.$cur['forum_name'].' :: '.$cur['subject'])."\n"; echo "".$cur['poster'].""; $link = $pun_config['o_base_url'].'/viewtopic.php?pid='.strval($cur['id']).'#p'.strval($cur['id']); //echo "".entity_to_decimal_value(htmlspecialchars($link))."\n"; echo "".htmlspecialchars($link)."\n"; echo ''.strval($cur['id']).'@'.$pun_config['o_base_url'].''."\n"; //$data = "Topic: ".parse_message($cur['subject'],0)."\n\nMessage: ".parse_message($cur['message'],0); $data = parse_message($cur['message'],0); //echo "".$data=entity_to_decimal_value(htmlspecialchars($data, ENT_NOQUOTES, $lang_common['lang_encoding']))."\n"; echo "".htmlspecialchars($data, ENT_NOQUOTES, $lang_common['lang_encoding'])."\n"; // echo "\n"; echo "".strval(date("r",$cur['postposted']))."\n"; echo "\n"; } ?>