Changeset 350 for trunk/Modules/News/rss.php
- Timestamp:
- Jan 18, 2012, 7:44:38 AM (13 years ago)
- Location:
- trunk/Modules/News
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/rss.php
r196 r350 1 1 <?php 2 2 3 Header('Content-Type: text/xml');4 5 include_once('../global.php');6 include_once('rss_generator.php');7 8 $NewsCount = 15;9 10 $Items = array();11 $Category = '';12 $CategoryOption = '';13 $CategoryOptionURL = '';14 $CategoryName = '';15 16 // Prepare WHERE condition17 if(array_key_exists('select', $_GET))18 {19 $Where = '';20 $Parts = explode('-', $_GET['select']);21 foreach($Parts as $Part)22 {23 $Where .= 'OR (category='.($Part * 1).')';24 }25 $Where = substr($Where, 2);26 } else $Where = 1;27 28 // Get category names29 $Categories = array();30 $DbResult = $Database->select('NewsCategory', '*');31 while($Category = $DbResult->fetch_array())32 {33 $Categories[$Category['Id']] = $Category['Caption'];34 }35 36 // Update news from discussion forum37 /*38 $ForumCategory = 4;39 $Database->select_db('forum');40 $DbResult = $Database->query('SELECT posts.post_time, posts_text.post_subject, posts_text.post_text, users.username, topics.topic_title FROM posts JOIN posts_text ON posts.post_id = posts_text.post_id JOIN users ON users.user_id = posts.poster_id JOIN topics ON topics.topic_id= posts.topic_id ORDER BY post_time DESC LIMIT '.$NewsCount);41 $Index = 0;42 //echo(DB_NumRows().',');43 while($Row = $DbResult->fetch_array())44 {45 $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");46 $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']);47 $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");48 $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");49 $Index = $Index + 1;50 51 $Title = $Row['topic_title'].'-'.$Row['post_subject'];52 $Content = $Row['post_text'];53 $Date = date('Y-m-d H:i:s', $Row['post_time']);54 $Author = $Row['username'];55 $Database->select_db('is');56 //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');57 $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');58 if($DbResult2->num_rows == 0) //echo('.'); else echo('x');59 $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));60 //echo($Date);61 $Database->select_db('forum');62 }63 $Database->select_db('is');64 */65 66 // Get news from database by selected categories67 $UploadedFilesFolder = 'uploads/';68 $DbResult = $Database->query('SELECT *, UNIX_TIMESTAMP(Date) FROM News LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount);69 while($Row = $DbResult->fetch_assoc())70 {71 $EnclosuresText = '';72 if($Row['Enclosure'] != '')73 {74 $EnclosuresText .= '<br />Přílohy: ';75 $Enclosures = explode(';', $Row['Enclosure']);76 foreach($Enclosures as $Enclosure)77 {78 if(file_exists($UploadedFilesFolder.$Enclosure)) $EnclosuresText .= ' <a href="http://centrala.zdechov.net/aktuality/'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>';79 }80 }81 if($Row['Name'] == '') $Author = $Row['Author'];82 else $Author = $Row['Name'];83 $Items[] = array(84 'Title' => $Categories[$Row['Category']].' - '.$Row['Title'],85 'Link' => 'http://centrala.zdechov.net/aktuality/index.php?category='.$Row['Category'],86 'Description' => $Row['Content'].' ('.$Author.')'.$EnclosuresText,87 'Time' => $Row['UNIX_TIMESTAMP(Date)'],88 );89 }90 91 echo(GenerateRSS(array(92 'Title' => $Config['Web']['Title'].' - Aktuality',93 'Link' => 'http://'.$Config['Web']['Host'].'/',94 'Description' => 'Aktuality komunitní počítačové sítě ZděchovNET',95 'WebmasterEmail' => $Config['Web']['AdminEmail'],96 'Items' => $Items)));97 3 98 4 ?>
Note:
See TracChangeset
for help on using the changeset viewer.