Changeset 196 for trunk/aktuality/index.php
- Timestamp:
- Apr 27, 2009, 8:00:50 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/aktuality/index.php
r189 r196 16 16 if(array_key_exists('category', $_GET)) $Category = $_GET['category'] * 1; 17 17 if(array_key_exists('category', $_POST)) $Category = $_POST['category'] * 1; 18 $DbResult = $this->Database->select(' news_category', '*', 'id='.$Category);18 $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$Category); 19 19 if($DbResult->num_rows > 0) 20 20 { 21 21 $Row = $DbResult->fetch_array(); 22 $CategoryName = $Row[' caption'];22 $CategoryName = $Row['Caption']; 23 23 } 24 24 … … 31 31 { 32 32 if(array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1; 33 $DbResult = $this->Database->query('SELECT ` news`.*, `User`.`Name` FROM `news` LEFT JOIN `User` ON `User`.`Id`=`news`.`User` WHERE `news`.`id`='.$Id);33 $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id); 34 34 if($DbResult->num_rows > 0) 35 35 { 36 36 $Row = $DbResult->fetch_array(); 37 if($Row['Name'] == '') $Author = $Row[' author'];37 if($Row['Name'] == '') $Author = $Row['Author']; 38 38 else $Author = $Row['Name']; 39 $Output .= '<div style="border: thin dotted #97ADFF; background: #F6F7FF; margin-top: 5px; padding: 0px 5px 5px 5px;"><div style="padding-bottom: 1px; border-bottom-width: 1; border-bottom-style: solid; border-bottom-color: silver;"><strong>'.$Row[' title'].' ('.HumanDate($Row['date']).', '.$Author.')</strong>';39 $Output .= '<div style="border: thin dotted #97ADFF; background: #F6F7FF; margin-top: 5px; padding: 0px 5px 5px 5px;"><div style="padding-bottom: 1px; border-bottom-width: 1; border-bottom-style: solid; border-bottom-color: silver;"><strong>'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')</strong>'; 40 40 if($this->System->Modules['User']->User['Id'] == $Row['User']) 41 41 { 42 $Output .= ' <a href="index.php?action=del&category='.$Category.'&id='.$Row[' id'].'">Smazat</a>';43 $Output .= ' <a href="index.php?action=edit&category='.$Category.'&id='.$Row[' id'].'">Editovat</a>';44 } 45 $Output .= '</div>'.$Row[' content'].'<br />';46 if($Row[' enclosure'] != '')42 $Output .= ' <a href="index.php?action=del&category='.$Category.'&id='.$Row['Id'].'">Smazat</a>'; 43 $Output .= ' <a href="index.php?action=edit&category='.$Category.'&id='.$Row['Id'].'">Editovat</a>'; 44 } 45 $Output .= '</div>'.$Row['Content'].'<br />'; 46 if($Row['Enclosure'] != '') 47 47 { 48 48 $Output .= '<br />Přílohy: '; 49 $Enclosures = explode(';', $Row[' enclosure']);49 $Enclosures = explode(';', $Row['Enclosure']); 50 50 foreach($Enclosures as $Enclosure) 51 51 { … … 62 62 $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'. 63 63 'Kategorie: <select name="category">'; 64 $DbResult = $this->Database->select(' news_category', '*');64 $DbResult = $this->Database->select('NewsCategory', '*'); 65 65 while($DbRow = $DbResult->fetch_array()) 66 66 { 67 if($this->System->Modules['User']->CheckPermission('News', 'Insert', 'Group', $DbRow[' id']))68 { 69 if($DbRow[' id'] == $Category) $Selected = ' selected="1"'; else $Selected = '';70 $Output .= '<option value="'.$DbRow[' id'].'"'.$Selected.'>'.$DbRow['caption'].'</option>';67 if($this->System->Modules['User']->CheckPermission('News', 'Insert', 'Group', $DbRow['Id'])) 68 { 69 if($DbRow['Id'] == $Category) $Selected = ' selected="1"'; else $Selected = ''; 70 $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>'; 71 71 } 72 72 } … … 105 105 106 106 $_POST['content'] = str_replace("\n",'<br />',$_POST['content']); 107 $this->Database->insert(' news',array('category' => $Category, 'title' => $_POST['title'], 'content' => $_POST['content'], 'date' => 'NOW()', 'ip' => $RemoteAddr, 'enclosure' => $Enclosures, 'author' => $this->System->Modules['User']->User['Name'], 'User' => $this->System->Modules['User']->User['Id']));107 $this->Database->insert('News',array('Category' => $Category, 'Title' => $_POST['title'], 'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr, 'Enclosure' => $Enclosures, 'Author' => $this->System->Modules['User']->User['Name'], 'User' => $this->System->Modules['User']->User['Id'])); 108 108 $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 />'; 109 109 $Output .= '<a href="index.php?category='.$_POST['category'].'">Zpět na seznam aktualit</a>'; … … 112 112 break; 113 113 case 'edit': 114 $DbResult = $this->Database->query('SELECT * FROM news WHERE id='.$_GET['id']);114 $DbResult = $this->Database->query('SELECT * FROM News WHERE Id='.$_GET['id']); 115 115 $Row = $DbResult->fetch_array(); 116 116 if($this->System->Modules['User']->User['Id'] == $Row['User']) 117 117 { 118 $Row[' content'] = str_replace('<br />', "", $Row['content']);118 $Row['Content'] = str_replace('<br />', '', $Row['Content']); 119 119 $Output .= '<strong>Editace aktuality v kategorii '.$CategoryName.':</strong><br />'; 120 120 $Output .= '<form action="index.php?action=update" method="post">'. 121 121 '<input type="hidden" value="'.$_GET['id'].'" name="id">'. 122 'Nadpis:<br /><input type="text" size="54" name="title" value="'.$Row[' title'].'"><br />'.123 'Obsah:<br /><textarea name="content" rows="20" cols="40">'.$Row[' content'].'</textarea><br />'.122 'Nadpis:<br /><input type="text" size="54" name="title" value="'.$Row['Title'].'"><br />'. 123 'Obsah:<br /><textarea name="content" rows="20" cols="40">'.$Row['Content'].'</textarea><br />'. 124 124 '<input type="hidden" name="category" value="'.$Category.'"><br />'. 125 125 '<input type="submit" value="Uložit">'. … … 130 130 $RemoteAddr = GetRemoteAddress(); 131 131 $_POST['id'] = $_POST['id'] * 1; 132 $DbResult = $this->Database->select(' news', '*', 'id='.$_POST['id']);132 $DbResult = $this->Database->select('News', '*', 'Id='.$_POST['id']); 133 133 if($DbResult->num_rows > 0) 134 134 { … … 136 136 if($this->System->Modules['User']->User['Id'] == $Row['User']) 137 137 { 138 $_POST['content'] = str_replace("\n", '<br />',$_POST['content']);139 $this->Database->update(' news', 'id='.$_POST['id'], array('title' => $_POST['title'], 'content' => $_POST['content']));138 $_POST['content'] = str_replace("\n", '<br />', $_POST['content']); 139 $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 'Content' => $_POST['content'])); 140 140 $Output .= 'Aktualita uložena!<br />'; 141 141 $Output .= '<a href="index.php?category='.$Category.'">Zpět na seznam aktualit</a>'; … … 144 144 break; 145 145 case 'del': 146 $DbResult = $this->Database->query('SELECT * FROM news WHERE id='.$_GET['id']);146 $DbResult = $this->Database->query('SELECT * FROM News WHERE Id='.$_GET['id']); 147 147 $Row = $DbResult->fetch_array(); 148 148 if($this->System->Modules['User']->User['Id'] == $Row['User']) 149 149 { 150 if($Row[' enclosure'] != '')150 if($Row['Enclosure'] != '') 151 151 { 152 152 $Output .= '<br />Přílohy: '; 153 $Enclosures = explode(';', $Row[' enclosure']);153 $Enclosures = explode(';', $Row['Enclosure']); 154 154 foreach($Enclosures as $Enclosure) 155 155 { … … 157 157 } 158 158 } 159 $this->Database->query('DELETE FROM news WHERE id='.$_GET['id']);159 $this->Database->query('DELETE FROM News WHERE Id='.$_GET['id']); 160 160 $Output .= 'Aktualita smazána!<br /><a href="index.php?category='.$Category.'">Zpět na seznam aktualit</a>'; 161 161 } else $Output .= 'Nemáte oprávnění.'; … … 165 165 { 166 166 $PerPage = 20; 167 $DbResult = $this->Database->select(' news', 'COUNT(*)', ' category='.$Category);167 $DbResult = $this->Database->select('News', 'COUNT(*)', ' Category='.$Category); 168 168 $RowTotal = $DbResult->fetch_array(); 169 169 $PageMax = $RowTotal[0]; 170 if(array_key_exists('page', $_GET)) $Page = $_GET['page']; else $Page = 0; //round($PageMax/$PerPage); 170 if(array_key_exists('page', $_GET)) $Page = $_GET['page']; 171 else $Page = 0; //round($PageMax/$PerPage); 171 172 $Output .= '<strong>Seznam aktualit kategorie '.$CategoryName.':</strong><div style="font-size: small;">'; 172 $Output .= PagesList('?category='.$Category.'&page=', $Page,$PageMax,$PerPage);173 $Output .= PagesList('?category='.$Category.'&page=', $Page, $PageMax, $PerPage); 173 174 174 175 //echo(GetRemoteAddress().','.$_SERVER['HTTP_X_FORWARDED_FOR'].'<br />'); 175 $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);176 $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); 176 177 while($Row = $DbResult->fetch_array()) 177 178 { 178 if($Row['Name'] == '') $Author = $Row[' author'];179 if($Row['Name'] == '') $Author = $Row['Author']; 179 180 else $Author = $Row['Name']; 180 $Output .= '<div style="border: thin dotted #97ADFF; background: #F6F7FF; margin-top: 5px; padding: 0px 5px 5px 5px;"><div style="padding-bottom: 1px; border-bottom-width: 1; border-bottom-style: solid; border-bottom-color: silver;"><strong><a href="?action=view&id='.$Row[' id'].'">'.$Row['title'].'</a> ('.HumanDate($Row['date']).', '.$Author.')</strong>';181 $Output .= '<div style="border: thin dotted #97ADFF; background: #F6F7FF; margin-top: 5px; padding: 0px 5px 5px 5px;"><div style="padding-bottom: 1px; border-bottom-width: 1; border-bottom-style: solid; border-bottom-color: silver;"><strong><a href="?action=view&id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')</strong>'; 181 182 if($this->System->Modules['User']->User['Id'] == $Row['User']) 182 183 { 183 $Output .= ' <a href="index.php?action=del&category='.$Category.'&id='.$Row[' id'].'">Smazat</a>';184 $Output .= ' <a href="index.php?action=edit&category='.$Category.'&id='.$Row[' id'].'">Editovat</a>';185 } 186 $Output .= '</div>'.$Row[' content'].'<br />';187 if($Row[' enclosure'] != '')184 $Output .= ' <a href="index.php?action=del&category='.$Category.'&id='.$Row['Id'].'">Smazat</a>'; 185 $Output .= ' <a href="index.php?action=edit&category='.$Category.'&id='.$Row['Id'].'">Editovat</a>'; 186 } 187 $Output .= '</div>'.$Row['Content'].'<br />'; 188 if($Row['Enclosure'] != '') 188 189 { 189 190 $Output .= '<br />Přílohy: '; 190 $Enclosures = explode(';', $Row[' enclosure']);191 $Enclosures = explode(';', $Row['Enclosure']); 191 192 foreach($Enclosures as $Enclosure) 192 193 {
Note:
See TracChangeset
for help on using the changeset viewer.