80 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			80 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
|  | <?php | |||
|  | if(!defined('DATALIFEENGINE')){die("Hacking attempt!");} | |||
|  | 
 | |||
|  | $rss_content = <<<XML | |||
|  | <?xml version="1.0" encoding="{$config['charset']}"?>
 | |||
|  | <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"> | |||
|  | <channel> | |||
|  | <title>{$config['home_title']}</title> | |||
|  | <link>{$config['http_home_url']}</link> | |||
|  | <language>ru</language> | |||
|  | <description>{$config['description']}</description> | |||
|  | <generator>Files-Sib.NET</generator> | |||
|  | XML; | |||
|  | 
 | |||
|  | if($doaction=="comments"){ | |||
|  | 	if($id = intval($_GET['news'])){ | |||
|  |     	$where = "AND post_id = '".intval($id)."'"; | |||
|  | 	}else{$where = "";} | |||
|  | 
 | |||
|  | 	$sql_comments = "SELECT c.autor, c.text, c.post_id, c.autor, p.alt_name FROM " . PREFIX . "_comments c, " . PREFIX . "_post p WHERE c.post_id=p.id $where order by c.date desc limit 0,". $config['rss_comm_number']; | |||
|  | 	$sql_result  = $db->query ($sql_comments); | |||
|  | 	$i = 0; | |||
|  | 
 | |||
|  |     while ($row = $db->get_row ($sql_result)){ | |||
|  |     	$i++; | |||
|  |     	$author = "<a href=\"".$config['http_home_url']."user/".urlencode($row['autor'])."/\">".$row['autor']."</a>"; | |||
|  |     	$row['text'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#is", "Текст только для зарегистрированных", $row['text'] ); | |||
|  |     	$full_link = $config['http_home_url'] . $row['post_id'] . "-" . $row['alt_name'] . ".html"; | |||
|  | 
 | |||
|  | $rss_content .= <<<XML | |||
|  | <item> | |||
|  | <title>#{$i}</title>
 | |||
|  | <link>{$full_link}</link> | |||
|  | <description><![CDATA[{$row['text']}<br><br><b><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:</b> {$author}]]></description> | |||
|  | <author>{$row['autor']}</author> | |||
|  | </item> | |||
|  | XML; | |||
|  | 
 | |||
|  | 	} | |||
|  | } elseif ($doaction=="news") { | |||
|  | 	if($category_id = get_ID ( $cat_info, $_GET['category'])){ | |||
|  | 		$get_cats = get_sub_cats ( $category_id ); | |||
|  | 		if ($config['allow_multi_category']) { | |||
|  | 			$where_category = "AND category regexp '[[:<:]](" . $get_cats . ")[[:>:]]'"; | |||
|  | 		} else { | |||
|  | 					$get_cats = str_replace ( "|", "','", $get_cats ); | |||
|  | 					$where_category = "AND category IN ('" . $get_cats . "')"; | |||
|  | 		} | |||
|  | 	} else $where_category = ""; | |||
|  | 	$sql_select = "SELECT id, autor, date, short_story, title, category, alt_name, remote_addr FROM cms_post WHERE approve {$where_category}"; | |||
|  | 	 | |||
|  | 	if ($config['rss_mtype']) $sql_select .= " AND allow_main=1"; | |||
|  | 	$sql_select .= " ORDER BY " . $config['news_sort'] . " " . $config['news_msort'] . " LIMIT 0," . $config['rss_number']; | |||
|  | 
 | |||
|  | 	$sql_results = $db->query($sql_select); | |||
|  | 	$i = 0; | |||
|  | 	while($row = $db->get_row($sql_results)){ | |||
|  | 		$i++; | |||
|  | 		$date = date( $row['date'] ); | |||
|  | 		if( $row['remote_addr'] != "" ) {$full_link = $config['http_home_url'] . "out.php?url=" . rawurlencode( base64_encode( $row['remote_addr'] ) ); | |||
|  |         } else {$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";} | |||
|  | 
 | |||
|  | $rss_content .= <<<XML | |||
|  | <item> | |||
|  | <title>{$row['title']}</title> | |||
|  | <guid isPermaLink="true">{$full_link}</guid> | |||
|  | <link>{$full_link}</link> | |||
|  | <description><![CDATA[{$row['short_story']}]]></description> | |||
|  | <category><![CDATA[{category}]]></category> | |||
|  | <dc:creator>{$row['autor']}</dc:creator> | |||
|  | <pubDate>{$date}</pubDate> | |||
|  | </item> | |||
|  | XML; | |||
|  | 
 | |||
|  | 	} | |||
|  | } | |||
|  | $rss_content .= '</channel></rss>'; | |||
|  | header( 'Content-type: application/xml' ); | |||
|  | die($rss_content); | |||
|  | ?>
 |