[4] | 1 | <?php
|
---|
[1] | 2 |
|
---|
[353] | 3 | include_once('Common/rss_generator.php');
|
---|
| 4 |
|
---|
[151] | 5 | class NewsPage extends Page
|
---|
| 6 | {
|
---|
| 7 | var $FullTitle = 'Aktualní informace';
|
---|
| 8 | var $ShortTitle = 'Aktuality';
|
---|
| 9 | var $UploadedFilesFolder = 'uploads/';
|
---|
[1] | 10 |
|
---|
[151] | 11 | function Show()
|
---|
[1] | 12 | {
|
---|
[350] | 13 | if(count($this->System->PathItems) > 1)
|
---|
| 14 | {
|
---|
| 15 | if($this->System->PathItems[1] == 'subscription') return($this->ShowSubscription());
|
---|
| 16 | else if($this->System->PathItems[1] == 'rss') return($this->ShowRSS());
|
---|
| 17 | else return(PAGE_NOT_FOUND);
|
---|
| 18 | } else return($this->ShowMain());
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | function ShowMain()
|
---|
| 22 | {
|
---|
[151] | 23 | $Output = '';
|
---|
| 24 | $Category = 1;
|
---|
| 25 | $CategoryName = '';
|
---|
| 26 | if(array_key_exists('category', $_GET)) $Category = $_GET['category'] * 1;
|
---|
| 27 | if(array_key_exists('category', $_POST)) $Category = $_POST['category'] * 1;
|
---|
[302] | 28 | $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$Category.' ORDER BY Sequence');
|
---|
[151] | 29 | if($DbResult->num_rows > 0)
|
---|
[1] | 30 | {
|
---|
[151] | 31 | $Row = $DbResult->fetch_array();
|
---|
[196] | 32 | $CategoryName = $Row['Caption'];
|
---|
[151] | 33 | }
|
---|
[1] | 34 |
|
---|
[151] | 35 | if(!array_key_exists('action',$_GET)) $_GET['action'] = '';
|
---|
| 36 | switch($_GET['action'])
|
---|
[1] | 37 | {
|
---|
[151] | 38 | case 'view':
|
---|
[343] | 39 | if(!$this->System->Models['User']->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
|
---|
[151] | 40 | else
|
---|
| 41 | {
|
---|
[350] | 42 | $News = new News($this->Database, $this->System);
|
---|
[151] | 43 | if(array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;
|
---|
[196] | 44 | $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id);
|
---|
[151] | 45 | if($DbResult->num_rows > 0)
|
---|
| 46 | {
|
---|
| 47 | $Row = $DbResult->fetch_array();
|
---|
[196] | 48 | if($Row['Name'] == '') $Author = $Row['Author'];
|
---|
[189] | 49 | else $Author = $Row['Name'];
|
---|
[252] | 50 | $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')';
|
---|
[343] | 51 | if($this->System->Models['User']->User['Id'] == $Row['User'])
|
---|
[151] | 52 | {
|
---|
[252] | 53 | $Output .= '<div class="Action">';
|
---|
[350] | 54 | $Output .= ' <a href="?action=del&category='.$Category.'&id='.$Row['Id'].'">Smazat</a>';
|
---|
| 55 | $Output .= ' <a href="?action=edit&category='.$Category.'&id='.$Row['Id'].'">Editovat</a>';
|
---|
[252] | 56 | $Output .= '</div>';
|
---|
[151] | 57 | }
|
---|
[252] | 58 | $Output .= '</div><div class="Content">'.$News->ModifyContent($Row['Content']).'<br />';
|
---|
[306] | 59 | if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
|
---|
[196] | 60 | if($Row['Enclosure'] != '')
|
---|
[151] | 61 | {
|
---|
| 62 | $Output .= '<br />Přílohy: ';
|
---|
[196] | 63 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
[236] | 64 | foreach($Enclosures as $Enclosure)
|
---|
| 65 | {
|
---|
| 66 | if(file_exists($this->UploadedFilesFolder.$Enclosure)) $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>';
|
---|
[151] | 67 | }
|
---|
| 68 | }
|
---|
[252] | 69 | $Output .= '</div></div>';
|
---|
[151] | 70 | } else $Output .= 'Položka nenalezena.';
|
---|
| 71 | }
|
---|
| 72 | break;
|
---|
| 73 | case 'add':
|
---|
[183] | 74 | $Output .= '<strong>Vložení nové aktuality:</strong><br />';
|
---|
| 75 | if($Category == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';
|
---|
| 76 | $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'.
|
---|
[151] | 77 | 'Kategorie: <select name="category">';
|
---|
[196] | 78 | $DbResult = $this->Database->select('NewsCategory', '*');
|
---|
[183] | 79 | while($DbRow = $DbResult->fetch_array())
|
---|
| 80 | {
|
---|
[343] | 81 | if($this->System->Models['User']->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
|
---|
[183] | 82 | {
|
---|
[196] | 83 | if($DbRow['Id'] == $Category) $Selected = ' selected="1"'; else $Selected = '';
|
---|
| 84 | $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>';
|
---|
[183] | 85 | }
|
---|
| 86 | }
|
---|
| 87 | $Output .= '</select><br />'.
|
---|
[151] | 88 | 'Nadpis:<br /><input type="text" size="54" name="title"><br />
|
---|
| 89 | Obsah:<br /><textarea name="content" rows="20" cols="40"></textarea><br />
|
---|
[306] | 90 | Odkaz:<br /><input type="text" size="54" name="link"><br />
|
---|
[151] | 91 | Přílohy (Max. velikost souboru 1 MB):<br /><input type="hidden" name="MAX_FILE_SIZE" value="1000000">
|
---|
| 92 | <input name="enclosure1" size="38" type="file"><br />
|
---|
| 93 | <input name="enclosure2" size="38" type="file"><br />
|
---|
| 94 | <input name="enclosure3" size="38" type="file"><br />
|
---|
| 95 | <input type="submit" value="Vložit">
|
---|
| 96 | </form>';
|
---|
| 97 | break;
|
---|
| 98 | case 'add2':
|
---|
| 99 | $RemoteAddr = GetRemoteAddress();
|
---|
[343] | 100 | if($this->System->Models['User']->CheckPermission('News', 'Insert', 'Group', $Category))
|
---|
[151] | 101 | {
|
---|
| 102 | //print_r($_FILES);
|
---|
| 103 | // Process uploaded file
|
---|
| 104 | $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3');
|
---|
| 105 | $Enclosures = '';
|
---|
| 106 | foreach($EnclosureFileNames as $EnclosureName)
|
---|
| 107 | if(array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
|
---|
| 108 | {
|
---|
| 109 | $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
|
---|
| 110 | if(move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
|
---|
| 111 | {
|
---|
[220] | 112 | $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />';
|
---|
[236] | 113 | $Enclosures = $Enclosures.';'.basename($_FILES[$EnclosureName]['name']);
|
---|
[151] | 114 | } else
|
---|
| 115 | {
|
---|
[220] | 116 | $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' se nepodařilo nahrát na server.<br />';
|
---|
[151] | 117 | }
|
---|
| 118 | }
|
---|
| 119 | $Enclosures = substr($Enclosures, 1);
|
---|
| 120 |
|
---|
| 121 | $_POST['content'] = str_replace("\n",'<br />',$_POST['content']);
|
---|
[343] | 122 | $this->Database->insert('News', array('Category' => $Category, 'Title' => $_POST['title'], 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 'Enclosure' => $Enclosures, 'Author' => $this->System->Models['User']->User['Name'], 'User' => $this->System->Models['User']->User['Id'], 'Link' => $_POST['link']));
|
---|
[151] | 123 | $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />';
|
---|
[350] | 124 | $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>';
|
---|
[151] | 125 | $this->System->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);
|
---|
| 126 | } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
|
---|
| 127 | break;
|
---|
| 128 | case 'edit':
|
---|
[196] | 129 | $DbResult = $this->Database->query('SELECT * FROM News WHERE Id='.$_GET['id']);
|
---|
[151] | 130 | $Row = $DbResult->fetch_array();
|
---|
[343] | 131 | if($this->System->Models['User']->User['Id'] == $Row['User'])
|
---|
[151] | 132 | {
|
---|
[196] | 133 | $Row['Content'] = str_replace('<br />', '', $Row['Content']);
|
---|
[151] | 134 | $Output .= '<strong>Editace aktuality v kategorii '.$CategoryName.':</strong><br />';
|
---|
[350] | 135 | $Output .= '<form action="?action=update" method="post">'.
|
---|
[151] | 136 | '<input type="hidden" value="'.$_GET['id'].'" name="id">'.
|
---|
[196] | 137 | 'Nadpis:<br /><input type="text" size="54" name="title" value="'.$Row['Title'].'"><br />'.
|
---|
| 138 | 'Obsah:<br /><textarea name="content" rows="20" cols="40">'.$Row['Content'].'</textarea><br />'.
|
---|
[306] | 139 | 'Odkaz:<br /><input type="text" size="54" name="link"><br />'.
|
---|
[151] | 140 | '<input type="hidden" name="category" value="'.$Category.'"><br />'.
|
---|
| 141 | '<input type="submit" value="Uložit">'.
|
---|
| 142 | '</form>';
|
---|
| 143 | } else $Output .= 'Nepovolená operace!';
|
---|
| 144 | break;
|
---|
| 145 | case 'update':
|
---|
| 146 | $RemoteAddr = GetRemoteAddress();
|
---|
| 147 | $_POST['id'] = $_POST['id'] * 1;
|
---|
[196] | 148 | $DbResult = $this->Database->select('News', '*', 'Id='.$_POST['id']);
|
---|
[151] | 149 | if($DbResult->num_rows > 0)
|
---|
| 150 | {
|
---|
| 151 | $Row = $DbResult->fetch_array();
|
---|
[343] | 152 | if($this->System->Models['User']->User['Id'] == $Row['User'])
|
---|
[151] | 153 | {
|
---|
[196] | 154 | $_POST['content'] = str_replace("\n", '<br />', $_POST['content']);
|
---|
| 155 | $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 'Content' => $_POST['content']));
|
---|
[151] | 156 | $Output .= 'Aktualita uložena!<br />';
|
---|
[236] | 157 | $Output .= '<a href="index.php?category='.$Category.'">Zpět na seznam aktualit</a>';
|
---|
[151] | 158 | } else $Output .= 'Nelze měnit cizí aktualitu!<br />';
|
---|
| 159 | } else $Output .= 'ID nenalezeno!';
|
---|
| 160 | break;
|
---|
| 161 | case 'del':
|
---|
[196] | 162 | $DbResult = $this->Database->query('SELECT * FROM News WHERE Id='.$_GET['id']);
|
---|
[151] | 163 | $Row = $DbResult->fetch_array();
|
---|
[343] | 164 | if($this->System->Models['User']->User['Id'] == $Row['User'])
|
---|
[151] | 165 | {
|
---|
[196] | 166 | if($Row['Enclosure'] != '')
|
---|
[151] | 167 | {
|
---|
| 168 | $Output .= '<br />Přílohy: ';
|
---|
[196] | 169 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
[236] | 170 | foreach($Enclosures as $Enclosure)
|
---|
| 171 | {
|
---|
| 172 | if(file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);
|
---|
| 173 | }
|
---|
[151] | 174 | }
|
---|
[196] | 175 | $this->Database->query('DELETE FROM News WHERE Id='.$_GET['id']);
|
---|
[350] | 176 | $Output .= 'Aktualita smazána!<br /><a href="?category='.$Category.'">Zpět na seznam aktualit</a>';
|
---|
[151] | 177 | } else $Output .= 'Nemáte oprávnění.';
|
---|
| 178 | break;
|
---|
| 179 | default:
|
---|
[343] | 180 | if($this->System->Models['User']->CheckPermission('News', 'Display', 'Group', $Category))
|
---|
[151] | 181 | {
|
---|
[350] | 182 | $News = new News($this->Database, $this->System);
|
---|
[151] | 183 | $PerPage = 20;
|
---|
[196] | 184 | $DbResult = $this->Database->select('News', 'COUNT(*)', ' Category='.$Category);
|
---|
[151] | 185 | $RowTotal = $DbResult->fetch_array();
|
---|
| 186 | $PageMax = $RowTotal[0];
|
---|
[196] | 187 | if(array_key_exists('page', $_GET)) $Page = $_GET['page'];
|
---|
| 188 | else $Page = 0; //round($PageMax/$PerPage);
|
---|
[151] | 189 | $Output .= '<strong>Seznam aktualit kategorie '.$CategoryName.':</strong><div style="font-size: small;">';
|
---|
[196] | 190 | $Output .= PagesList('?category='.$Category.'&page=', $Page, $PageMax, $PerPage);
|
---|
[151] | 191 |
|
---|
| 192 | //echo(GetRemoteAddress().','.$_SERVER['HTTP_X_FORWARDED_FOR'].'<br />');
|
---|
[196] | 193 | $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category.' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage);
|
---|
[151] | 194 | while($Row = $DbResult->fetch_array())
|
---|
| 195 | {
|
---|
[196] | 196 | if($Row['Name'] == '') $Author = $Row['Author'];
|
---|
[189] | 197 | else $Author = $Row['Name'];
|
---|
[252] | 198 | $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')';
|
---|
[343] | 199 | if($this->System->Models['User']->User['Id'] == $Row['User'])
|
---|
[151] | 200 | {
|
---|
[252] | 201 | $Output .= '<div class="Action">';
|
---|
[350] | 202 | $Output .= ' <a href="?action=del&category='.$Category.'&id='.$Row['Id'].'">Smazat</a>';
|
---|
| 203 | $Output .= ' <a href="?action=edit&category='.$Category.'&id='.$Row['Id'].'">Editovat</a>';
|
---|
[252] | 204 | $Output .= '</div>';
|
---|
[151] | 205 | }
|
---|
[252] | 206 | $Output .= '</div><div class="Content">'.$News->ModifyContent($Row['Content']).'<br />';
|
---|
[306] | 207 | if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
|
---|
[196] | 208 | if($Row['Enclosure'] != '')
|
---|
[151] | 209 | {
|
---|
| 210 | $Output .= '<br />Přílohy: ';
|
---|
[196] | 211 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
[236] | 212 | foreach($Enclosures as $Enclosure)
|
---|
| 213 | {
|
---|
[183] | 214 | if(file_exists($this->UploadedFilesFolder.$Enclosure)) $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>';
|
---|
[236] | 215 | }
|
---|
[151] | 216 | }
|
---|
[252] | 217 | $Output .= '</div></div>';
|
---|
[151] | 218 | }
|
---|
| 219 | $Output .= PagesList('?category='.$Category.'&page=', $Page, $PageMax, $PerPage);
|
---|
| 220 | $Output .= '</div>';
|
---|
| 221 | } else $Output .= 'Nemáte oprávnění.';
|
---|
[1] | 222 | }
|
---|
[151] | 223 | return($Output);
|
---|
| 224 | }
|
---|
[350] | 225 |
|
---|
| 226 | function ShowSubscription()
|
---|
| 227 | {
|
---|
| 228 | if(array_key_exists('build', $_GET))
|
---|
| 229 | {
|
---|
| 230 | $Select = '';
|
---|
| 231 | foreach($_POST as $Index => $Item)
|
---|
| 232 | {
|
---|
| 233 | if(substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);
|
---|
| 234 | }
|
---|
| 235 | $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1);
|
---|
| 236 | $Output = 'Výsledný RSS kanál: <a href="'.$Select.'">'.$Select.'</a>';
|
---|
| 237 | } else
|
---|
| 238 | {
|
---|
| 239 | $Output = 'Vytvořte si vlastní RSS kanál, díky kterému budete moci automaticky sledovat novinky pomocí vaší RSS čtečky. Informace o technologii RSS a programech pro čtení kanálů najdete např. <a href="http://www.lupa.cz/clanky/prehled-rss-ctecek/">zde</a><br />'.
|
---|
| 240 | '<br />Kategorie:<br />';
|
---|
| 241 | $Output .= '<form action="?build=1" method="post">';
|
---|
| 242 | $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY Caption');
|
---|
| 243 | while($Category = $DbResult->fetch_array())
|
---|
| 244 | {
|
---|
| 245 | $Output .= '<input type="checkbox" name="category'.$Category['Id'].'" />'.$Category['Caption'].'<br />';
|
---|
| 246 | }
|
---|
| 247 | $Output.= '<input type="submit" value="Sestavit " />'.
|
---|
| 248 | '</form>';
|
---|
| 249 | }
|
---|
| 250 | return($Output);
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | function ShowRSS()
|
---|
| 254 | {
|
---|
| 255 | $this->SimplePage = true;
|
---|
| 256 | $this->FormatHTML = false;
|
---|
| 257 | Header('Content-Type: text/xml');
|
---|
| 258 |
|
---|
[353] | 259 | $NewsCount = 15;
|
---|
[350] | 260 |
|
---|
[353] | 261 | $Items = array();
|
---|
| 262 | $Category = '';
|
---|
| 263 | $CategoryOption = '';
|
---|
| 264 | $CategoryOptionURL = '';
|
---|
| 265 | $CategoryName = '';
|
---|
[350] | 266 |
|
---|
[353] | 267 | // Prepare WHERE condition
|
---|
| 268 | if(array_key_exists('select', $_GET))
|
---|
| 269 | {
|
---|
| 270 | $Where = '';
|
---|
| 271 | $Parts = explode('-', $_GET['select']);
|
---|
| 272 | foreach($Parts as $Part)
|
---|
| 273 | {
|
---|
| 274 | $Where .= 'OR (category='.($Part * 1).')';
|
---|
| 275 | }
|
---|
| 276 | $Where = substr($Where, 2);
|
---|
| 277 | } else $Where = 1;
|
---|
[350] | 278 |
|
---|
[353] | 279 | // Get category names
|
---|
| 280 | $Categories = array();
|
---|
| 281 | $DbResult = $this->Database->select('NewsCategory', '*');
|
---|
| 282 | while($Category = $DbResult->fetch_array())
|
---|
| 283 | {
|
---|
| 284 | $Categories[$Category['Id']] = $Category['Caption'];
|
---|
| 285 | }
|
---|
[350] | 286 |
|
---|
[353] | 287 | // Update news from discussion forum
|
---|
| 288 | /*
|
---|
| 289 | $ForumCategory = 4;
|
---|
| 290 | $Database->select_db('forum');
|
---|
| 291 | $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);
|
---|
| 292 | $Index = 0;
|
---|
| 293 | //echo(DB_NumRows().',');
|
---|
| 294 | while($Row = $DbResult->fetch_array())
|
---|
| 295 | {
|
---|
| 296 | $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
|
---|
| 297 | $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']);
|
---|
| 298 | $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
|
---|
| 299 | $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
|
---|
| 300 | $Index = $Index + 1;
|
---|
| 301 |
|
---|
| 302 | $Title = $Row['topic_title'].'-'.$Row['post_subject'];
|
---|
| 303 | $Content = $Row['post_text'];
|
---|
| 304 | $Date = date('Y-m-d H:i:s', $Row['post_time']);
|
---|
| 305 | $Author = $Row['username'];
|
---|
| 306 | $Database->select_db('is');
|
---|
| 307 | //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
|
---|
| 308 | $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
|
---|
| 309 | if($DbResult2->num_rows == 0) //echo('.'); else echo('x');
|
---|
| 310 | $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
|
---|
| 311 | //echo($Date);
|
---|
| 312 | $Database->select_db('forum');
|
---|
| 313 | }
|
---|
| 314 | $Database->select_db('is');
|
---|
| 315 | */
|
---|
[151] | 316 |
|
---|
[353] | 317 | // Get news from database by selected categories
|
---|
| 318 | $UploadedFilesFolder = 'uploads/';
|
---|
| 319 | $DbResult = $this->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);
|
---|
| 320 | while($Row = $DbResult->fetch_assoc())
|
---|
[350] | 321 | {
|
---|
[353] | 322 | $EnclosuresText = '';
|
---|
| 323 | if($Row['Enclosure'] != '')
|
---|
| 324 | {
|
---|
| 325 | $EnclosuresText .= '<br />Přílohy: ';
|
---|
| 326 | $Enclosures = explode(';', $Row['Enclosure']);
|
---|
| 327 | foreach($Enclosures as $Enclosure)
|
---|
| 328 | {
|
---|
| 329 | if(file_exists($UploadedFilesFolder.$Enclosure)) $EnclosuresText .= ' <a href="http://centrala.zdechov.net/aktuality/'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>';
|
---|
| 330 | }
|
---|
| 331 | }
|
---|
| 332 | if($Row['Name'] == '') $Author = $Row['Author'];
|
---|
| 333 | else $Author = $Row['Name'];
|
---|
| 334 | $Items[] = array(
|
---|
| 335 | 'Title' => $Categories[$Row['Category']].' - '.$Row['Title'],
|
---|
| 336 | 'Link' => 'http://'.$this->System->Config['Web']['Host'].'/aktuality/index.php?category='.$Row['Category'],
|
---|
| 337 | 'Description' => $Row['Content'].' ('.$Author.')'.$EnclosuresText,
|
---|
| 338 | 'Time' => $Row['UNIX_TIMESTAMP(Date)'],
|
---|
| 339 | );
|
---|
[350] | 340 | }
|
---|
| 341 |
|
---|
[353] | 342 | return(GenerateRSS(array(
|
---|
| 343 | 'Title' => $this->System->Config['Web']['Title'].' - Aktuality',
|
---|
| 344 | 'Link' => 'http://'.$this->System->Config['Web']['Host'].'/',
|
---|
| 345 | 'Description' => 'Aktuality komunitní počítačové sítě ZděchovNET',
|
---|
| 346 | 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
|
---|
| 347 | 'Items' => $Items)));
|
---|
| 348 | }
|
---|
[350] | 349 | }
|
---|
| 350 |
|
---|
[358] | 351 | ?>
|
---|