- Timestamp:
- Apr 4, 2008, 8:11:34 AM (17 years ago)
- Location:
- www
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/index.php
r55 r64 6 6 7 7 $Database->select_db('share'); 8 9 function CategoryItemCompare($Item1, $Item2) 10 { 11 if ($Item1['Index'] == $Item2['Index']) return(0); 12 return ($Item1['Index'] > $Item2['Index']) ? -1 : 1; 13 } 14 15 // Process cookies 16 if(array_key_exists('Action', $_GET)) 17 { 18 if($_GET['Action'] == 'CustomizeNewsSave') 19 { 20 $Checkbox = array('' => 0, 'on' => 1); 21 // print_r($_POST); 22 $Setting = array(); 23 for($I = 0; $I < $_POST['NewsCategoryCount']; $I++) 24 { 25 if(($_POST['NewsCategoryDaysAgo'.$I]*1) < 0) $_POST['NewsCategoryIndex'.$I] = 0; 26 if(($_POST['NewsCategoryCount'.$I]*1) < 0) $_POST['NewsCategoryCount'.$I] = 0; 27 if(!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = ''; 28 $Setting[] = array('CategoryId' => $_POST['NewsCategoryId'.$I], 'Enabled' => $Checkbox[$_POST['NewsCategoryEnabled'.$I]], 'ItemCount' => ($_POST['NewsCategoryCount'.$I]*1), 'DaysAgo' => ($_POST['NewsCategoryDaysAgo'.$I]*1), 'Index' => ($_POST['NewsCategoryIndex'.$I]*1)); 29 } 30 // Sort indexes 31 usort($Setting, 'CategoryItemCompare'); 32 $Setting = array_reverse($Setting); 33 // Normalize indexes 34 foreach($Setting as $Index => $Item) 35 $Setting[$Index]['Index'] = $Index + 1; 36 37 // print_r($Setting); 38 39 // Store new cookie value 40 $_COOKIE['NewsSetting'] = serialize($Setting); 41 setcookie('NewsSetting', $_COOKIE['NewsSetting']); 42 } 43 } 8 44 9 45 ?> … … 142 178 143 179 // Zobrazení času běhu počítače 144 $Data = explode(' ',exec('uptime')); 145 $Data = array_slice($Data,3,-8); 146 $Uptime = ''; 147 foreach($Data as $Item) 148 { 149 if(strpos($Item,':')) $Uptime .= substr($Item,0,-1).' hodin'; 150 else $Uptime .= $Item.' '; 151 } 152 $Uptime = str_replace('2 days,','2 dny a',$Uptime); 153 $Uptime = str_replace('3 days,','3 dny a',$Uptime); 154 $Uptime = str_replace('4 days,','4 dny a',$Uptime); 155 $Uptime = str_replace('days,','dní a',$Uptime); 156 $Uptime = str_replace('day,','den a',$Uptime); 157 $Uptime = str_replace('min,','minut',$Uptime); 158 echo('Server běží '.$Uptime); 180 function GetServerUptime() 181 { 182 $Data = explode(' ',exec('uptime')); 183 $Data = array_slice($Data,3,-8); 184 $Uptime = ''; 185 foreach($Data as $Item) 186 { 187 if(strpos($Item,':')) $Uptime .= substr($Item,0,-1).' hodin'; 188 else $Uptime .= $Item.' '; 189 } 190 $Uptime = str_replace('2 days,','2 dny a',$Uptime); 191 $Uptime = str_replace('3 days,','3 dny a',$Uptime); 192 $Uptime = str_replace('4 days,','4 dny a',$Uptime); 193 $Uptime = str_replace('days,','dní a',$Uptime); 194 $Uptime = str_replace('day,','den a',$Uptime); 195 $Uptime = str_replace('min,','minut',$Uptime); 196 return('Server běží '.$Uptime); 197 } 198 199 echo(GetServerUptime()); 159 200 160 201 echo('</td><td width="50%" valign="top" style="font-size: smaller;">'); … … 169 210 170 211 echo('<table width="100%"><tr><td><strong>Aktuálně:</strong></td><td align="right"> 171 <img alt="Teplomer" width="10" height="18" src="images/teplomer3.png"><a href="statistic/trafficview2.php?type=temp">'.$Teplota 172 .'°C (mimo provoz)</a></td></tr></table>'); 173 174 $NewsCountPerCategory = 3; 212 <a href="?Action=CustomizeNews">Upravit</a></td></tr></table>'); 213 //<img alt="Teplomer" width="10" height="18" src="images/teplomer3.png"><a href="statistic/trafficview2.php?type=temp">'.$Teplota.'°C (mimo provoz)</a></td></tr></table>'); 214 175 215 $UploadedFilesFolder = 'aktuality/uploads/'; 176 216 217 // Initialize default news setting 218 $NewsSetting = array(); 219 $I = 1; 220 $DbResult = $Database->select('news_category', '*'); 221 while($NewsCategory = $DbResult->fetch_array()) 222 { 223 $NewsSetting[] = array('CategoryId' => $NewsCategory['id'], 'Index' => $I, 'Enabled' => 1, 'ItemCount' => 5, 'DaysAgo' => 14); 224 $I++; 225 } 226 // Merge defaults with user setting 227 if(array_key_exists('NewsSetting', $_COOKIE)) 228 { 229 $NewsSettingCookie = unserialize($_COOKIE['NewsSetting']); 230 foreach($NewsSetting as $Index => $NewSetting) 231 { 232 $NewsSetting[$Index] = array_merge($NewSetting, $NewsSettingCookie[$Index]); 233 } 234 } 235 236 if(array_key_exists('Action', $_GET)) 237 { 238 // Show news customize menu 239 if($_GET['Action'] == 'CustomizeNews') 240 { 241 echo('<form action="?Action=CustomizeNewsSave" method="post">'); 242 echo('<table width="100%" cellspacing="0" border="1"><tr><td><table cellspacing="0" width="100%">'); 243 echo('<tr><th>Kategorie</th><th>Pozice</th><th>Zobrazit</th><th>Max. počet</th><th>Posledních dnů</th></tr>'); 244 $I = 0; 245 foreach($NewsSetting as $SettingItem) 246 { 247 $DbResult = $Database->select('news_category', '*', 'id='.$SettingItem['CategoryId']); 248 $NewsCategory = $DbResult->fetch_array(); 249 echo('<tr><td>'.$NewsCategory['caption'].'</td><td align="center"><input type="text" size="1" name="NewsCategoryIndex'.$I.'" value="'.$SettingItem['Index'].'"></td><td align="center"><input type="checkbox" name="NewsCategoryEnabled'.$I.'"'); 250 if($SettingItem['Enabled'] == 1) echo(' CHECKED'); 251 echo('></td>'. 252 '<td align="center"><input type="text" size="1" name="NewsCategoryCount'.$I.'" value="'.$SettingItem['ItemCount'].'">'. 253 '<input type="hidden" name="NewsCategoryId'.$I.'" value="'.$SettingItem['CategoryId'].'"></td><td align="center"><input type="text" size="1" name="NewsCategoryDaysAgo'.$I.'" value="'.$SettingItem['DaysAgo'].'"></td></tr>'); 254 $I++; 255 } 256 echo('</table><input type="hidden" name="NewsCategoryCount" value="'.count($NewsSetting).'"><input type="submit" value="Uložit"></form></td></tr></table>'); 257 } 258 } 259 177 260 echo('<div onmouseout="skryj(predchozi)">'); 178 261 179 function ShowNews($Category )262 function ShowNews($Category, $ItemCount, $DaysAgo) 180 263 { 181 264 global $Database, $NewsCategoryNames, $NewsCountPerCategory, $UploadedFilesFolder; 182 265 266 $ItemCount = abs($ItemCount); 267 $DaysAgo = abs($DaysAgo); 183 268 $DbResult = $Database->select('news_category', '*', 'id='.$Category); 184 269 $Row = $DbResult->fetch_array(); … … 189 274 echo('</td></tr><tr><td colspan="2">'); 190 275 echo('<table cellspacing="0" width="100%" style="padding: 2px 2px 2px 2px; font-size: small; border-style: solid; border-color: red; border-width: 1; background-color: #FFF0F0;">'); 191 $DbResult = $Database->select('news', '*', 'category='.$Category.' ORDER BY date DESC LIMIT 0,'.$NewsCountPerCategory); 276 $DbResult = $Database->query('SELECT * FROM `news` WHERE (`category`='.$Category.') AND (DATE_SUB(NOW(), INTERVAL '.$DaysAgo.' DAY) < `date`) ORDER BY `date` DESC LIMIT 0,'.$ItemCount); 277 //echo($Database->error.'<br>'); 278 //echo($Database->LastQuery.'<br>'); 192 279 //echo('<table cellpadding="0" cellspacing="0" width="100%"><tr><td>'); 193 280 $Index = 0; 194 281 $FontSize = 12; 282 if($DbResult->num_rows > 0) 195 283 while($Row = $DbResult->fetch_array()) 196 284 { … … 212 300 echo('</div></td></tr>'); 213 301 $Index = $Index + 1; 214 $FontSize = $FontSize - 2;302 $FontSize = $FontSize - 1; 215 303 } 216 304 echo('</table></td></tr></table>'."\n\n"); 217 305 } 218 306 219 ShowNews(5); 220 ShowNews(3); 221 ShowNews(1); 222 ShowNews(2); 223 ShowNews(4); 224 ShowNews(6); 225 ShowNews(8); 226 ShowNews(9); 227 ShowNews(10); 307 foreach($NewsSetting as $SettingItem) 308 if($SettingItem['Enabled'] == 1) ShowNews($SettingItem['CategoryId'], $SettingItem['ItemCount'], $SettingItem['DaysAgo']); 228 309 229 310 echo('<a href="aktuality/subscription.php"><img style="margin: 0px 0px 0px 0px;" border="0" src="images/rss20.png" alt="Aktuality přes RSS"></a> <a href="aktuality/subscription.php">Automatické sledování novinek</a>');
Note:
See TracChangeset
for help on using the changeset viewer.