source: newwww/news/rss.php@ 3

Last change on this file since 3 was 3, checked in by george, 17 years ago

První pracovní verze nového webu.

  • Property svn:executable set to *
File size: 3.7 KB
Line 
1<?
2
3header("Content-Type: text/xml");
4
5include_once('../global.php');
6include_once('rss_generator.php');
7include_once('../is/db.php');
8DB_Init('localhost','root','','is');
9DB_Query('SET CHARACTER SET latin2');
10
11$NewsCount = 15;
12
13$Items = array();
14$Category = '';
15$CategoryOption = '';
16$CategoryOptionURL = '';
17$CategoryName = '';
18
19// Prepare WHERE condition
20$Where = '';
21if(array_key_exists('select', $_GET))
22{
23 $Parts = explode('-', addslashes($_GET['select']));
24 foreach($Parts as $Part)
25 {
26 $Where .= ' OR (category='.($Part*1).')';
27 }
28}
29
30// Get category names
31$Categories = array();
32DB_Select('news_category', '*');
33while($Category = DB_Row())
34{
35 $Categories[$Category['id']] = $Category['caption'];
36}
37
38// Update news from discussion forum
39$ForumCategory = 4;
40DB_Change('forum');
41DB_Query('SELECT * FROM posts WHERE 1 ORDER BY post_time DESC LIMIT 0,'.$NewsCount);
42$Index = 0;
43//echo(DB_NumRows().',');
44while($Row2 = DB_Row())
45{
46 DB_Save();
47 DB_Query('SELECT * FROM posts_text WHERE post_id='.$Row2['post_id']);
48 $Row = DB_Row();
49 $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
50 $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']);
51 $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
52 DB_Query('SELECT * FROM users WHERE user_id='.$Row2['poster_id']);
53 $Row3 = DB_Row();
54 DB_Query('SELECT * FROM topics WHERE topic_id='.$Row2['topic_id']);
55 $Row4 = DB_Row();
56 $Row4['topic_title'] = StrTr($Row4['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
57 $Index = $Index + 1;
58
59 $Title = $Row4['topic_title'].'-'.$Row['post_subject'];
60 $Content = $Row['post_text'];
61 $Date = date('Y-m-d H:i:s', $Row2['post_time']);
62 $Author = $Row3['username'];
63 DB_Change('is');
64 //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
65 DB_Select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
66 if(DB_NumRows() == 0) //echo('.'); else echo('x');
67 DB_Insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
68 //echo($Date);
69 DB_Change('forum');
70 DB_Load();
71}
72DB_Change('is');
73
74// Get news from database by selected categories
75$UploadedFilesFolder = 'uploads/';
76DB_Query('SELECT enclosure,category,title,content,UNIX_TIMESTAMP(date),author FROM news WHERE 1'.$Where.' ORDER BY date DESC LIMIT 0,'.$NewsCount);
77while($Row = DB_Row())
78{
79 $EnclosuresText = '';
80 if($Row['enclosure'] != '')
81 {
82 $EnclosuresText .= '<br>Pøílohy: ';
83 $Enclosures = explode(';', $Row['enclosure']);
84 foreach($Enclosures as $Enclosure)
85 {
86 if(file_exists($UploadedFilesFolder.$Enclosure)) $EnclosuresText .= ' <a href="http://centrala.zdechov.net/aktuality/'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>';
87 }
88 }
89 $Items[] = array(
90 'Title' => $Categories[$Row['category']].' - '.$Row['title'],
91 'Link' => 'http://centrala.zdechov.net/aktuality/index.php?category='.$Row['category'],
92 'Description' => $Row['content']." (".$Row['author'].")".$EnclosuresText,
93 'Time' => $Row['UNIX_TIMESTAMP(date)'],
94 );
95}
96
97echo(GenerateRSS(array(
98 'Title' => 'ZdìchovNET - Aktuality',
99 'Link' => 'http://centrala.zdechov.net/',
100 'Description' => 'Aktuality komunitní poèítaèové sítì ZdìchovNET',
101 'WebmasterEmail' => 'robie@centrum.cz',
102 'Items' => $Items)));
103?>
Note: See TracBrowser for help on using the repository browser.