Changeset 532
- Timestamp:
- Apr 24, 2013, 9:09:32 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/EmailQueue.php
r526 r532 1 1 <?php 2 2 3 class EmailQueue extends Module 4 { 5 function AddItem($To, $Subject, $Content, $From, $AttachmentFileId = '') 6 { 7 $Values = array('To' => $To, 8 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 9 'From' => $From); 10 if($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId; 11 $this->Database->insert('EmailQueue', $Values); 12 } 3 class EmailQueue extends Module 4 { 5 function AddItem($To, $Subject, $Content, $From, $AttachmentFileId = '') 6 { 7 $Values = array('To' => $To, 8 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 9 'From' => $From); 10 if($AttachmentFileId != '') $Values['AttachmentFile'] = $AttachmentFileId; 11 $this->Database->insert('EmailQueue', $Values); 12 } 13 14 function Process() 15 { 16 $Output = ''; 17 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 18 while($DbRow = $DbResult->fetch_assoc()) 19 { 20 $Mail = new Mail(); 21 $Mail->AddToCombined($DbRow['To']); 22 $Mail->Subject = $DbRow['Subject']; 23 $Mail->From = $DbRow['From']; 24 $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain'); 25 $Mail->AddBody($DbRow['Content'], 'text/html'); 26 if($DbRow['AttachmentFile'] != '') 27 { 28 $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']); 29 while($File = $DbResult2->fetch_assoc()) 30 $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']); 31 } 32 $Mail->Send(); 33 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 34 $this->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']); 35 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 36 } 37 return($Output); 38 } 39 } 13 40 14 function Process() 15 { 16 $Output = ''; 17 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 18 while($DbRow = $DbResult->fetch_assoc()) 19 { 20 $Mail = new Mail(); 21 $Mail->AddToCombined($DbRow['To']); 22 $Mail->Subject = $DbRow['Subject']; 23 $Mail->From = $DbRow['From']; 24 $Mail->AddBody(strip_tags($DbRow['Content']), 'text/plain'); 25 $Mail->AddBody($DbRow['Content'], 'text/html'); 26 if($DbRow['AttachmentFile'] != '') 27 { 28 $DbResult2 = $this->Database->select('File', '*', 'Id='.$DbRow['AttachmentFile']); 29 while($File = $DbResult2->fetch_assoc()) 30 $Mail->AttachFile($this->Config['Web']['FileRootFolder'].$File['DrivePath'], $File['MimeType']); 31 } 32 $Mail->Send(); 33 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 34 $this->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']); 35 $Output .= 'To: '.$DbRow['To'].' Subject: '.$DbRow['Subject'].'<br />'; 36 } 37 return($Output); 38 } 39 } 40 41 ?> 41 ?> -
trunk/Common/Global.php
r529 r532 150 150 } 151 151 152 // Zobrazení číselný seznamu stránek152 // Show page listing numbers 153 153 function PagesList($URL, $Page, $TotalCount, $CountPerPage) 154 154 { -
trunk/Common/Page.php
r529 r532 16 16 function __construct($System) 17 17 { 18 global $Config;19 20 18 parent::__construct($System); 21 19 22 $this->FormatHTML = $ Config['Web']['FormatHTML'];23 $this->ShowRuntimeInfo = $ Config['Web']['ShowRuntimeInfo'];20 $this->FormatHTML = $this->System->Config['Web']['FormatHTML']; 21 $this->ShowRuntimeInfo = $this->System->Config['Web']['ShowRuntimeInfo']; 24 22 } 25 23 … … 76 74 else $Output .= $this->System->User->User['Name'].' <a href="'.$this->System->Link('/?Action=Logout').'">Odhlásit</a>'; 77 75 } else $Output .= ' '; 78 // <a href="'.$this->System-> Config['Web']['RootFolder'].'/?Action=UserOptions">Nastavení</a>';76 // <a href="'.$this->System->Link('/?Action=UserOptions').'">Nastavení</a>'; 79 77 $Output .= '</div></div>'; 80 78 } … … 91 89 $Output .= '<div id="Footer"> 92 90 <i>| Správa webu: '.$this->System->Config['Web']['Admin'].' | e-mail: '.$this->System->Config['Web']['AdminEmail'].' |'; 93 if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time').' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |'; 91 if($this->ShowRuntimeInfo == true) $Output .= ' Doba generování: '.$Time.' s / '.ini_get('max_execution_time'). 92 ' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B |'; 94 93 $Output .= '</i></div>'; 95 94 } … … 99 98 100 99 function GetOutput() 101 { 102 $Output = $this->Show(); 100 { 101 try { 102 $Output = $this->Show(); 103 } catch (Exception $E) { 104 $Output = 'Chyba: '.$E->getMessage(); 105 } 103 106 if($this->ClearPage == false) 104 107 { … … 119 122 } 120 123 121 // Funkce formatovani vystupu124 // XML formating function 122 125 function FormatOutput($s) 123 126 { -
trunk/Common/RSS.php
r506 r532 16 16 } 17 17 18 function Generate( $Data)18 function Generate() 19 19 { 20 20 $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<? -
trunk/Common/Version.php
r531 r532 1 1 <?php 2 2 3 $Revision = 53 1; // Subversion revision3 $Revision = 532; // Subversion revision 4 4 $DatabaseRevision = 527; // SQL structure revision 5 $ReleaseTime = '2013-04-2 3';5 $ReleaseTime = '2013-04-24'; 6 6 7 7 ?> -
trunk/Modules/News/News.php
r524 r532 43 43 function ShowNews($Category, $ItemCount, $DaysAgo) 44 44 { 45 global $NewsCategoryNames, $NewsCountPerCategory, $UploadedFilesFolder;46 47 45 $ItemCount = abs($ItemCount); 48 46 $DaysAgo = abs($DaysAgo); … … 56 54 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE (`News`.`Category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `News`.`Date`) ORDER BY `News`.`Date` DESC LIMIT 0,'.$ItemCount); 57 55 58 //echo('<table cellpadding="0" cellspacing="0" width="100%"><tr><td>');59 56 $Index = 0; 60 57 $FontSize = 12; … … 79 76 foreach($Enclosures as $Enclosure) 80 77 { 81 if(file_exists($UploadedFilesFolder.$Enclosure)) $Output .= ' <a href="'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 78 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 79 $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 82 80 } 83 81 } … … 119 117 $Output = ''; 120 118 121 $UploadedFilesFolder = 'aktuality/uploads/';122 119 $this->LoadSettingsFromCookies(); 123 120 … … 224 221 $Result .= $Content; 225 222 return($Result); 226 } 227 223 } 228 224 } 229 225 -
trunk/Modules/News/NewsPage.php
r525 r532 20 20 } 21 21 22 function ShowMain() 23 { 24 $Output = ''; 25 $Category = 1; 26 $CategoryName = ''; 22 function ShowView() 23 { 24 $Output = ''; 25 if(!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 26 else 27 { 28 $Category = $this->GetCategory(); 29 if(array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1; 30 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 31 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id); 32 if($DbResult->num_rows > 0) 33 { 34 $Row = $DbResult->fetch_array(); 35 if($Row['Name'] == '') $Author = $Row['Author']; 36 else $Author = $Row['Name']; 37 $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')'; 38 if($this->System->User->User['Id'] == $Row['User']) 39 { 40 $Output .= '<div class="Action">'; 41 $Output .= ' <a href="?action=del&category='.$Category['Id'].'&id='.$Row['Id'].'">Smazat</a>'; 42 $Output .= ' <a href="?action=edit&category='.$Category['Id'].'&id='.$Row['Id'].'">Upravit</a>'; 43 $Output .= '</div>'; 44 } 45 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 46 if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 47 if($Row['Enclosure'] != '') 48 { 49 $Output .= '<br />Přílohy: '; 50 $Enclosures = explode(';', $Row['Enclosure']); 51 foreach($Enclosures as $Enclosure) 52 { 53 if(file_exists($this->UploadedFilesFolder.$Enclosure)) 54 $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 55 } 56 } 57 $Output .= '</div></div>'; 58 } else $Output .= 'Položka nenalezena.'; 59 } 60 return($Output); 61 } 62 63 function ShowAdd() 64 { 65 $Category = $this->GetCategory(); 66 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 67 { 68 $Output = '<strong>Vložení nové aktuality:</strong><br />'; 69 // TODO: Static reference to dynamic category item 70 if($Category['Id'] == 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.'; 71 $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'. 72 'Kategorie: <select name="category">'; 73 $DbResult = $this->Database->select('NewsCategory', '*'); 74 while($DbRow = $DbResult->fetch_array()) 75 { 76 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 77 { 78 if($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; 79 else $Selected = ''; 80 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>'; 81 } 82 } 83 $Output .= '</select><br />'. 84 'Nadpis:<br /><input type="text" size="54" name="title"><br />'. 85 'Obsah:<br /><textarea name="content" rows="20" cols="40"></textarea><br />'. 86 'Odkaz:<br /><input type="text" size="54" name="link"><br />'. 87 'Přílohy (Max. velikost souboru 1 MB):<br /><input type="hidden" name="MAX_FILE_SIZE" value="1000000">'. 88 '<input name="enclosure1" size="38" type="file"><br />'. 89 '<input name="enclosure2" size="38" type="file"><br />'. 90 '<input name="enclosure3" size="38" type="file"><br />'. 91 '<input type="submit" value="Vložit">'. 92 '</form>'; 93 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 94 return($Output); 95 } 96 97 function ShowAdd2() 98 { 99 $Output = ''; 100 $RemoteAddr = GetRemoteAddress(); 101 $Category = $this->GetCategory(); 102 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 103 { 104 // Process uploaded file 105 $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3'); 106 $Enclosures = ''; 107 foreach($EnclosureFileNames as $EnclosureName) 108 if(array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != '')) 109 { 110 $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']); 111 if(move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath)) 112 { 113 $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />'; 114 $Enclosures = $Enclosures.';'.basename($_FILES[$EnclosureName]['name']); 115 } else 116 { 117 $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' se nepodařilo nahrát na server.<br />'; 118 } 119 } 120 $Enclosures = substr($Enclosures, 1); 121 122 $_POST['content'] = str_replace("\n",'<br />',$_POST['content']); 123 $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'], 124 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 125 'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'], 126 'User' => $this->System->User->User['Id'], 'Link' => $_POST['link'])); 127 $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 />'; 128 $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>'; 129 $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id); 130 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 131 return($Output); 132 } 133 134 function ShowEdit() 135 { 136 $Output = ''; 137 $Category = $this->GetCategory(); 138 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 139 { 140 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 141 $Row = $DbResult->fetch_array(); 142 if(($this->System->User->User['Id'] == $Row['User'])) 143 { 144 $Row['Content'] = str_replace('<br />', '', $Row['Content']); 145 $Output .= '<strong>Editace aktuality v kategorii '.$Category['Caption'].':</strong><br />'; 146 $Output .= '<form action="?action=update" method="post">'. 147 '<input type="hidden" value="'.$_GET['id'].'" name="id">'. 148 'Nadpis:<br /><input type="text" size="54" name="title" value="'.$Row['Title'].'"><br />'. 149 'Obsah:<br /><textarea name="content" rows="20" cols="40">'.$Row['Content'].'</textarea><br />'. 150 'Odkaz:<br /><input type="text" size="54" name="link"><br />'. 151 '<input type="hidden" name="category" value="'.$Category['Id'].'"><br />'. 152 '<input type="submit" value="Uložit">'. 153 '</form>'; 154 } else $Output .= 'Nepovolená operace!'; 155 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 156 return($Output); 157 } 158 159 function ShowUpdate() 160 { 161 $Output = ''; 162 $RemoteAddr = GetRemoteAddress(); 163 $Category = $this->GetCategory(); 164 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 165 { 166 $_POST['id'] = $_POST['id'] * 1; 167 $DbResult = $this->Database->select('News', '*', '`Id`='.$_POST['id']); 168 if($DbResult->num_rows > 0) 169 { 170 $Row = $DbResult->fetch_array(); 171 if($this->System->User->User['Id'] == $Row['User']) 172 { 173 $_POST['content'] = str_replace("\n", '<br />', $_POST['content']); 174 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 175 'Content' => $_POST['content'], 'Link' => $_POST['link'])); 176 $Output .= 'Aktualita uložena!<br />'; 177 $Output .= '<a href="?category='.$Category['Id'].'">Zpět na seznam aktualit</a>'; 178 } else $Output .= 'Nelze měnit cizí aktualitu!<br />'; 179 } else $Output .= 'ID nenalezeno!'; 180 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 181 return($Output); 182 } 183 184 function ShowDelete() 185 { 186 $Output = ''; 187 $Category = $this->GetCategory(); 188 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])) 189 { 190 $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']); 191 $Row = $DbResult->fetch_array(); 192 if($this->System->User->User['Id'] == $Row['User']) 193 { 194 if($Row['Enclosure'] != '') 195 { 196 $Output .= '<br />Přílohy: '; 197 $Enclosures = explode(';', $Row['Enclosure']); 198 foreach($Enclosures as $Enclosure) 199 { 200 if(file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure); 201 } 202 } 203 $this->Database->query('DELETE FROM `News` WHERE `Id`='.$_GET['id']); 204 $Output .= 'Aktualita smazána!<br /><a href="?category='.$Category['Id'].'">Zpět na seznam aktualit</a>'; 205 } else $Output .= 'Nemáte oprávnění.'; 206 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 207 return($Output); 208 } 209 210 function ShowList() 211 { 212 $Output = ''; 213 $Category = $this->GetCategory(); 214 if($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id'])) 215 { 216 $PerPage = 20; 217 $DbResult = $this->Database->select('News', 'COUNT(*)', ' `Category`='.$Category['Id']); 218 $RowTotal = $DbResult->fetch_array(); 219 $PageMax = $RowTotal[0]; 220 if(array_key_exists('page', $_GET)) $Page = $_GET['page']; 221 else $Page = 0; //round($PageMax/$PerPage); 222 $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">'; 223 $Output .= PagesList('?category='.$Category['Id'].'&page=', $Page, $PageMax, $PerPage); 224 225 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '. 226 'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage); 227 while($Row = $DbResult->fetch_array()) 228 { 229 if($Row['Name'] == '') $Author = $Row['Author']; 230 else $Author = $Row['Name']; 231 $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')'; 232 if(($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))) 233 { 234 $Output .= '<div class="Action">'; 235 $Output .= ' <a href="?action=del&category='.$Category['Id'].'&id='.$Row['Id'].'">Smazat</a>'; 236 $Output .= ' <a href="?action=edit&category='.$Category['Id'].'&id='.$Row['Id'].'">Upravit</a>'; 237 $Output .= '</div>'; 238 } 239 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 240 if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 241 if($Row['Enclosure'] != '') 242 { 243 $Output .= '<br />Přílohy: '; 244 $Enclosures = explode(';', $Row['Enclosure']); 245 foreach($Enclosures as $Enclosure) 246 { 247 if(file_exists($this->UploadedFilesFolder.$Enclosure)) $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 248 } 249 } 250 $Output .= '</div></div>'; 251 } 252 $Output .= PagesList('?category='.$Category['Id'].'&page=', $Page, $PageMax, $PerPage); 253 $Output .= '</div>'; 254 } else $Output .= 'Nemáte oprávnění.'; 255 return($Output); 256 } 257 258 function GetCategory() 259 { 260 $Category = 1; // Default category 27 261 if(array_key_exists('category', $_GET)) $Category = $_GET['category'] * 1; 28 262 if(array_key_exists('category', $_POST)) $Category = $_POST['category'] * 1; 29 $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$Category.' ORDER BY Sequence'); 30 if($DbResult->num_rows > 0) 31 { 32 $Row = $DbResult->fetch_array(); 33 $CategoryName = $Row['Caption']; 263 if(is_null($Category)) throw new Exception('Kategorie neurčena'); 264 else 265 { 266 $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category.' ORDER BY `Sequence`'); 267 if($DbResult->num_rows > 0) $Category = $DbResult->fetch_array(); 268 else throw new Exception('Kategorie nenalezena'); 34 269 } 35 36 if(!array_key_exists('action',$_GET)) $_GET['action'] = ''; 37 switch($_GET['action']) 38 { 39 case 'view': 40 if(!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění'; 41 else 42 { 43 if(array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1; 44 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id); 45 if($DbResult->num_rows > 0) 46 { 47 $Row = $DbResult->fetch_array(); 48 if($Row['Name'] == '') $Author = $Row['Author']; 49 else $Author = $Row['Name']; 50 $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')'; 51 if($this->System->User->User['Id'] == $Row['User']) 52 { 53 $Output .= '<div class="Action">'; 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>'; 56 $Output .= '</div>'; 57 } 58 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 59 if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 60 if($Row['Enclosure'] != '') 61 { 62 $Output .= '<br />Přílohy: '; 63 $Enclosures = explode(';', $Row['Enclosure']); 64 foreach($Enclosures as $Enclosure) 65 { 66 if(file_exists($this->UploadedFilesFolder.$Enclosure)) $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 67 } 68 } 69 $Output .= '</div></div>'; 70 } else $Output .= 'Položka nenalezena.'; 71 } 72 break; 73 case 'add': 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">'. 77 'Kategorie: <select name="category">'; 78 $DbResult = $this->Database->select('NewsCategory', '*'); 79 while($DbRow = $DbResult->fetch_array()) 80 { 81 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 82 { 83 if($DbRow['Id'] == $Category) $Selected = ' selected="1"'; else $Selected = ''; 84 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>'; 85 } 86 } 87 $Output .= '</select><br />'. 88 'Nadpis:<br /><input type="text" size="54" name="title"><br /> 89 Obsah:<br /><textarea name="content" rows="20" cols="40"></textarea><br /> 90 Odkaz:<br /><input type="text" size="54" name="link"><br /> 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(); 100 if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category)) 101 { 102 // Process uploaded file 103 $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3'); 104 $Enclosures = ''; 105 foreach($EnclosureFileNames as $EnclosureName) 106 if(array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != '')) 107 { 108 $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']); 109 if(move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath)) 110 { 111 $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />'; 112 $Enclosures = $Enclosures.';'.basename($_FILES[$EnclosureName]['name']); 113 } else 114 { 115 $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' se nepodařilo nahrát na server.<br />'; 116 } 117 } 118 $Enclosures = substr($Enclosures, 1); 119 120 $_POST['content'] = str_replace("\n",'<br />',$_POST['content']); 121 $this->Database->insert('News', array('Category' => $Category, 'Title' => $_POST['title'], 122 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 123 'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'], 'User' => $this->System->User->User['Id'], 'Link' => $_POST['link'])); 124 $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 />'; 125 $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>'; 126 $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id); 127 } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!'; 128 break; 129 case 'edit': 130 $DbResult = $this->Database->query('SELECT * FROM News WHERE Id='.$_GET['id']); 131 $Row = $DbResult->fetch_array(); 132 if($this->System->User->User['Id'] == $Row['User']) 133 { 134 $Row['Content'] = str_replace('<br />', '', $Row['Content']); 135 $Output .= '<strong>Editace aktuality v kategorii '.$CategoryName.':</strong><br />'; 136 $Output .= '<form action="?action=update" method="post">'. 137 '<input type="hidden" value="'.$_GET['id'].'" name="id">'. 138 'Nadpis:<br /><input type="text" size="54" name="title" value="'.$Row['Title'].'"><br />'. 139 'Obsah:<br /><textarea name="content" rows="20" cols="40">'.$Row['Content'].'</textarea><br />'. 140 'Odkaz:<br /><input type="text" size="54" name="link"><br />'. 141 '<input type="hidden" name="category" value="'.$Category.'"><br />'. 142 '<input type="submit" value="Uložit">'. 143 '</form>'; 144 } else $Output .= 'Nepovolená operace!'; 145 break; 146 case 'update': 147 $RemoteAddr = GetRemoteAddress(); 148 $_POST['id'] = $_POST['id'] * 1; 149 $DbResult = $this->Database->select('News', '*', 'Id='.$_POST['id']); 150 if($DbResult->num_rows > 0) 151 { 152 $Row = $DbResult->fetch_array(); 153 if($this->System->User->User['Id'] == $Row['User']) 154 { 155 $_POST['content'] = str_replace("\n", '<br />', $_POST['content']); 156 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 'Content' => $_POST['content'])); 157 $Output .= 'Aktualita uložena!<br />'; 158 $Output .= '<a href="index.php?category='.$Category.'">Zpět na seznam aktualit</a>'; 159 } else $Output .= 'Nelze měnit cizí aktualitu!<br />'; 160 } else $Output .= 'ID nenalezeno!'; 161 break; 162 case 'del': 163 $DbResult = $this->Database->query('SELECT * FROM News WHERE Id='.$_GET['id']); 164 $Row = $DbResult->fetch_array(); 165 if($this->System->User->User['Id'] == $Row['User']) 166 { 167 if($Row['Enclosure'] != '') 168 { 169 $Output .= '<br />Přílohy: '; 170 $Enclosures = explode(';', $Row['Enclosure']); 171 foreach($Enclosures as $Enclosure) 172 { 173 if(file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure); 174 } 175 } 176 $this->Database->query('DELETE FROM News WHERE Id='.$_GET['id']); 177 $Output .= 'Aktualita smazána!<br /><a href="?category='.$Category.'">Zpět na seznam aktualit</a>'; 178 } else $Output .= 'Nemáte oprávnění.'; 179 break; 180 default: 181 if($this->System->User->CheckPermission('News', 'Display', 'Group', $Category)) 182 { 183 $PerPage = 20; 184 $DbResult = $this->Database->select('News', 'COUNT(*)', ' Category='.$Category); 185 $RowTotal = $DbResult->fetch_array(); 186 $PageMax = $RowTotal[0]; 187 if(array_key_exists('page', $_GET)) $Page = $_GET['page']; 188 else $Page = 0; //round($PageMax/$PerPage); 189 $Output .= '<strong>Seznam aktualit kategorie '.$CategoryName.':</strong><div style="font-size: small;">'; 190 $Output .= PagesList('?category='.$Category.'&page=', $Page, $PageMax, $PerPage); 191 192 //echo(GetRemoteAddress().','.$_SERVER['HTTP_X_FORWARDED_FOR'].'<br />'); 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); 194 while($Row = $DbResult->fetch_array()) 195 { 196 if($Row['Name'] == '') $Author = $Row['Author']; 197 else $Author = $Row['Name']; 198 $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')'; 199 if($this->System->User->User['Id'] == $Row['User']) 200 { 201 $Output .= '<div class="Action">'; 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>'; 204 $Output .= '</div>'; 205 } 206 $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />'; 207 if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>'; 208 if($Row['Enclosure'] != '') 209 { 210 $Output .= '<br />Přílohy: '; 211 $Enclosures = explode(';', $Row['Enclosure']); 212 foreach($Enclosures as $Enclosure) 213 { 214 if(file_exists($this->UploadedFilesFolder.$Enclosure)) $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 215 } 216 } 217 $Output .= '</div></div>'; 218 } 219 $Output .= PagesList('?category='.$Category.'&page=', $Page, $PageMax, $PerPage); 220 $Output .= '</div>'; 221 } else $Output .= 'Nemáte oprávnění.'; 222 } 270 return($Category); 271 } 272 273 function ShowMain() 274 { 275 $Output = ''; 276 if(array_key_exists('action',$_GET)) $Action = $_GET['action']; 277 else $Action = ''; 278 if($Action == 'view') $Output .= $this->ShowView(); 279 else if($Action == 'add') $Output .= $this->ShowAdd(); 280 else if($Action == 'add2') $Output .= $this->ShowAdd2(); 281 else if($Action == 'edit') $Output .= $this->ShowEdit(); 282 else if($Action == 'update') $Output .= $this->ShowUpdate(); 283 else if($Action == 'del') $Output .= $this->ShowDelete(); 284 else $Output .= $this->ShowList(); 223 285 return($Output); 224 286 } … … 240 302 '<br />Kategorie:<br />'; 241 303 $Output .= '<form action="?build=1" method="post">'; 242 $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY Caption');304 $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY `Caption`'); 243 305 while($Category = $DbResult->fetch_array()) 244 306 { 245 307 $Output .= '<input type="checkbox" name="category'.$Category['Id'].'" />'.$Category['Caption'].'<br />'; 246 308 } 247 $Output.= '<input type="submit" value="Sestavit "/>'.309 $Output.= '<input type="submit" value="Sestavit"/>'. 248 310 '</form>'; 249 311 } … … 272 334 foreach($Parts as $Part) 273 335 { 274 $Where .= 'OR ( category='.($Part * 1).')';336 $Where .= 'OR (`Category`='.($Part * 1).')'; 275 337 } 276 338 $Where = substr($Where, 2); … … 317 379 // Get news from database by selected categories 318 380 $UploadedFilesFolder = 'uploads/'; 319 $DbResult = $this->Database->query('SELECT *, UNIX_TIMESTAMP( Date) FROM NewsLEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount);381 $DbResult = $this->Database->query('SELECT *, UNIX_TIMESTAMP(`Date`) AS `UnixTime` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount); 320 382 while($Row = $DbResult->fetch_assoc()) 321 383 { … … 327 389 foreach($Enclosures as $Enclosure) 328 390 { 329 if(file_exists($UploadedFilesFolder.$Enclosure)) $EnclosuresText .= ' <a href="http://centrala.zdechov.net/aktuality/'.$UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>'; 391 if(file_exists($UploadedFilesFolder.$Enclosure)) 392 $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>'; 330 393 } 331 394 } … … 334 397 $Items[] = array( 335 398 'Title' => $Categories[$Row['Category']].' - '.$Row['Title'], 336 'Link' => 'http://'.$this->System->Config['Web']['Host'].'/aktuality/ index.php?category='.$Row['Category'],399 'Link' => 'http://'.$this->System->Config['Web']['Host'].'/aktuality/?category='.$Row['Category'], 337 400 'Description' => $Row['Content'].' ('.$Author.')'.$EnclosuresText, 338 'Time' => $Row['U NIX_TIMESTAMP(Date)'],401 'Time' => $Row['UnixTime'], 339 402 ); 340 403 } … … 343 406 $RSS->Title = $this->System->Config['Web']['Title'].' - Aktuality'; 344 407 $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/'; 345 $RSS->Description = 'Aktuality komunitní počítačové sítě ZděchovNET';408 $RSS->Description = 'Aktuality '.$this->System->Config['Web']['Description']; 346 409 $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 347 410 $RSS->Items = $Items;
Note:
See TracChangeset
for help on using the changeset viewer.