lang['E_SCRIPT_ERROR']); } return $text; } function validate($text) { /* dlugosc pobranego z bazy tekstu */ if (($len = (isset($_GET['len']) ? intval($_GET['len']) : 255)) > 500) { $len = 500; } if ( ord($text[$len -1]) > 127 ) { while ( ord($text[$len -1]) > 127 ) { $text = substr($text, 0, $len -1); --$len; } } else { $text = substr($text, 0, $len - 1); } return $text; } $codepage = isset($_GET['cp']) ? trim($_GET['cp']) : 'UTF-8'; /* wysylamy naglowek */ header('Content-type: application/xml; charset='. $codepage); /* prolog XML */ echo "\n"; /* wersja RSS_TABLE */ echo "\n"; echo "\n"; // while ( list($key, $value) = each($rss_info) ) { /* wypisanie znacznikow XML */ echo "<$key>$value\n"; } /* ponizsze instrukcje w zaleznosci od wybranej opcji umozliwiaja pobranie 20 ostatnich wpisow w danej tabeli. Pobrane dane sa "ubarwiane" w znaczniki XML i wyswietlane */ switch ( $_GET['rss'] ) { default: case 'article': case 'news': case 'faq': case 'download': case 'text': // echo "$config[SITE_TITLE]"; $sql = 'SELECT a.article_id, a.article_subject, a.article_title, a.short_text, a.image, a.date, a.subdomain, c.category_name, c.subject, u.user_name FROM ' . ARTICLE_TABLE . ' as a LEFT JOIN ' . ARTICLE_CATEGORY . ' as c ON c.category_id=a.category_id LEFT JOIN ' . USER_TABLE .' as u ON u.user_id = a.user_id WHERE a.subdomain<>\'\' ORDER BY a.article_id DESC LIMIT 20'; $result = $db->sql_query($sql); while ( $row = $db->sql_fetch($result) ) { $row['text_content'] = validate($row['text_content']); $path = $row['article_subject']; echo ''."\r\n"; echo ' ' . change_codepage(htmlspecialchars(stripslashes(unstrip($row['article_title']))), $codepage) . ''."\r\n"; echo ' ' . $config['SITE_URL'] . $row['subdomain'].'/'.$path . ''."\r\n"; echo ' ' . change_codepage(htmlspecialchars(strip_tags(stripslashes($row['short_text']))), $codepage) . ''."\r\n"; echo ' '.$row['category_name'].''."\r\n"; $tag_query = "SELECT tn.tid, td.name, td.subject from trendz_term_node as tn left join trendz_term_data as td on tn.tid=td.tid where tn.nid=".$row['article_id']; $tag_result = $db->sql_query($tag_query); while ($tag = $db->sql_fetch($tag_result) ) { echo ' '.htmlspecialchars($tag['name']).''."\r\n"; } echo ' '."\r\n"; echo ' ' . strftime('%a,%d %b %Y %H:%M:%S +0100', $row['date']) . ''."\r\n"; echo ' '.$row['user_name'].''."\r\n"; echo ' '.$row['article_id'].' at '.$config['SITE_URL'].''."\r\n"; echo ''."\r\n"; } break; ////////////////////////////////////////////////////////////////////////////////// case 'topic': echo "$config[SITE_TITLE] - Forum"; $useraccess = $user->get_access(); if ( $_GET['f'] ) { $sql_forum = 'AND topic_forum = ' . intval($_GET['f']); } $sql = 'SELECT t.topic_id, t.topic_subject, p.post_time, p.post_forum, p.post_post FROM (' . TOPIC_TABLE . ' t, ' . POST_TABLE . ' p) LEFT JOIN ' . FORUM_TABLE . ' f ON f.forum_id = t.topic_forum WHERE p.post_id = t.topic_first_post_id ' . $sql_forum . ' AND p.post_time >= ' . $notolder . ' AND f.forum_lock != 1 ORDER BY t.topic_id DESC LIMIT 20'; $db->sql_query($sql); while ( $row = $db->sql_fetch() ) { if ( isset($useraccess[$row['post_forum']]) ) { if ( $useraccess[$row['post_forum']] == NO ) { continue; } } $row['text_text'] = validate($row['text_text']); echo ''; echo ' ' . change_codepage(strip_tags(stripslashes($row['topic_subject'])), $codepage) . ''; echo ' ' . $config['FORUM_URL'] . 'viewtopic.' . $phpEx . '?id=' . $row['topic_id'] . ''; echo ' ' . change_codepage(htmlspecialchars(strip_tags(stripslashes($row['post_post']))), $codepage) . ''; echo ' ' . strftime('%a,%d %b %Y %H:%M:%S +0100', $row['post_time']) . ''; echo ''; } break; ////////////////////////////////////////////////////////////////////////////// } echo "\n"; echo "\n"; ?>