Changeset 581 for trunk/Modules/News/RSS.php
- Timestamp:
- Sep 12, 2013, 9:14:38 PM (11 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/RSS.php
r578 r581 1 1 <?php 2 2 3 $InitSystem = true; 4 include_once('includes/global.php'); 5 6 $Items = array(); 7 if($_GET['channel'] == 'news') 8 { 9 $DbResult = $System->Database->query('SELECT UNIX_TIMESTAMP(`News`.`Time`) AS `UnixTime`, '. 10 '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text` '. 11 'FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10'); 12 while($DbRow = $DbResult->fetch_assoc()) 13 { 14 $Items[] = array 15 ( 16 'Title' => $DbRow['Title'], 17 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 18 'Description' => $DbRow['Text'].' ('.$DbRow['Name'].')', 19 'Time' => $DbRow['UnixTime'], 20 ); 21 } 22 echo(GenerateRSS(array 23 ( 24 'Title' => 'WoW překlad - Změny systému', 25 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 26 'Description' => 'Překlad textů WoW', 27 'WebmasterEmail' => $Config['Web']['AdminEmail'], 28 'Items' => $Items, 29 ))); 30 } else 31 if($_GET['channel'] == 'translation') 32 { 33 $DbResult = $System->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100'); 34 while($DbRow = $DbResult->fetch_assoc()) 35 { 36 $Items[] = array 37 ( 38 'Title' => strip_tags($DbRow['Text'].' ('.$DbRow['UserName'].')'), 39 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 40 'Description' => $DbRow['Text'], 41 'Time' => $DbRow['Date'], 42 ); 43 } 44 echo(GenerateRSS(array 45 ( 46 'Title' => 'WoW překlad - Poslední překlady', 47 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 48 'Description' => 'Překlad textů WoW', 49 'WebmasterEmail' => $Config['Web']['AdminEmail'], 50 'Items' => $Items, 51 ))); 52 } else 53 if($_GET['channel'] == 'shoutbox') 54 { 55 $TitleLength = 50; 56 mb_internal_encoding('utf-8'); 57 $DbResult = $System->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `UnixDate`, `User`, `UserName`, `Text` FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20'); 58 while($DbRow = $DbResult->fetch_assoc()) 59 { 60 $Title = mb_substr($DbRow['Text'], 0, $TitleLength); 61 if(mb_strlen($Title) == $TitleLength) $Title .= '...'; 62 $Items[] = array 63 ( 64 'Title' => $DbRow['UserName'].': '.$Title, 65 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 66 'Description' => $DbRow['Text'], 67 'Time' => $DbRow['UnixDate'], 68 ); 69 } 70 echo(GenerateRSS(array 71 ( 72 'Title' => 'WoW překlad - Shoutbox', 73 'Link' => 'http://'.$Config['Web']['Host'].$System->Link('/'), 74 'Description' => 'Překlad textů WoW', 75 'WebmasterEmail' => $Config['Web']['AdminEmail'], 76 'Items' => $Items, 77 ))); 78 } else echo('Nezadán žádný kanál'); 3 function GenerateRSS($Data) 4 { 5 global $Config; 6 7 $Result = '<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'" ?>'."\n". //<? 8 '<rss version="2.0">'."\n". 9 " <channel>\n". 10 " <title>".$Data['Title']."</title>\n". 11 " <link>".$Data['Link']."</link>\n". 12 " <description>".$Data['Description']."</description>\n". 13 " <language>cs</language>\n". 14 " <webMaster>".$Data['WebmasterEmail']."</webMaster>\n". 15 " <pubDate>".date('r')."</pubDate>\n". 16 " <ttl>20</ttl>\n"; 17 foreach($Data['Items'] as $Item) 18 { 19 $Result .= " <item>\n". 20 ' <title>'.htmlspecialchars($Item['Title'])."</title>\n". 21 ' <description>'.htmlspecialchars($Item['Description'])."</description>\n". 22 ' <pubDate>'.date('r',$Item['Time'])."</pubDate>\n". 23 ' <link>'.$Item['Link']."</link>\n". 24 " </item>\n"; 25 } 26 $Result .= " </channel>\n". 27 "</rss>"; 28 return($Result); 29 } 30 31 class PageRSS extends Page 32 { 33 function Show() 34 { 35 $this->RawPage = true; 36 37 if(array_key_exists($_GET['channel'], $this->System->ModuleManager->Modules['News']->RSSChannels)) 38 { 39 $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$_GET['channel']]; 40 if($this->System->User->Licence($Channel['Permission'])) 41 { 42 if(is_string($Channel['Callback'][0])) 43 { 44 $Class = new $Channel['Callback'][0]($this->System); 45 $Output = $Class->$Channel['Callback'][1](); 46 } else $Output = call_user_func($Channel['Callback']); 47 } else $Output = 'Nemáte oprávnění'; 48 } else $Output = 'Nezadán žádný kanál'; 49 return($Output); 50 } 51 }
Note:
See TracChangeset
for help on using the changeset viewer.