Changeset 21 for trunk/www/global.php
- Timestamp:
- Jun 12, 2009, 7:26:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/global.php
r17 r21 263 263 } 264 264 265 function GetRemoteAddress() 266 { 267 if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ; 268 else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 269 else $IP = '0.0.0.0'; 270 return($IP); 271 } 272 273 function RemoveDiacritic($Text) 274 { 275 return(str_replace( 276 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'), 277 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'), 278 $Text)); 279 } 280 281 function NotBlank($Text) 282 { 283 if($Text == '') return(' '); else return($Text); 284 } 285 286 function MakeLink($Target, $Title) 287 { 288 return('<a href="'.$Target.'">'.$Title.'</a>'); 289 } 290 291 function Table($Table, $Class) 292 { 293 $Result = '<table class="'.$Class.'">'; 294 if(array_key_exists('Header', $Table)) 295 { 296 $Result .= '<tr>'; 297 foreach($Table['Header'] as $Item) 298 $Result .= '<th>'.$Item.'</th>'; 299 $Result .= '</tr>'; 300 } 301 foreach($Table['Rows'] as $Row) 302 { 303 $Result .= '<tr>'; 304 foreach($Row as $Index => $Item) 305 { 306 if($Index == 0) $Class = ' class="Header"'; else $Class = ''; 307 $Result .= '<td'.$Class.'>'.$Item.'</td>'; 308 } 309 $Result .= '</tr>'; 310 } 311 $Result .= '</table>'; 312 return($Result); 313 } 314 315 function GetQueryStringArray() 316 { 317 $Result = array(); 318 $Parts = explode('&', $_SERVER['QUERY_STRING']); 319 foreach($Parts as $Part) 320 { 321 if($Part != '') 322 { 323 $Item = explode('=', $Part); 324 $Result[$Item[0]] = $Item[1]; 325 } 326 } 327 return($Result); 328 } 329 330 function SetQueryStringArray($QueryStringArray) 331 { 332 $Parts = array(); 333 foreach($QueryStringArray as $Index => $Item) 334 { 335 $Parts[] = $Index.'='.$Item; 336 } 337 return(implode('&', $Parts)); 338 } 339 265 340 // Zobrazení číselný seznamu stránek 266 function PagesList($URL, $Page, $TotalCount, $CountPerPage, $Around = 10) 267 { 341 function PageList($QueryStringVar, $Page, $TotalCount, $CountPerPage, $Around = 10) 342 { 343 $QueryStringArray = GetQueryStringArray(); 268 344 $Count = ceil($TotalCount / $CountPerPage); 269 345 $Result = ''; … … 272 348 if($Page > 0) 273 349 { 274 $Result .= '<a href="'.$URL.'0"><<</a> '; 275 $Result .= '<a href="'.$URL.($Page - 1).'"><</a> '; 350 $QueryStringArray[$QueryStringVar] = 0; 351 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'"><<</a> '; 352 $QueryStringArray[$QueryStringVar] = $Page - 1; 353 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'"><</a> '; 276 354 } 277 355 $PagesMax = $Count - 1; … … 286 364 { 287 365 if($i == $Page) $Result .= '<strong>'; 288 $Result .= '<a href="'.$URL.$i.'">'.($i + 1).'</a> '; 366 $QueryStringArray[$QueryStringVar] = $i; 367 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">'.($i + 1).'</a> '; 289 368 if($i == $Page) $Result .= '</strong>'; 290 369 } … … 292 371 if($Page < ($Count - 1)) 293 372 { 294 $Result .= '<a href="'.$URL.($Page + 1).'">></a> '; 295 $Result .= '<a href="'.$URL.($Count - 1).'">>></a>'; 373 $QueryStringArray[$QueryStringVar] = $Page + 1; 374 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">></a> '; 375 $QueryStringArray[$QueryStringVar] = $Count - 1; 376 $Result .= '<a href="?'.SetQueryStringArray($QueryStringArray).'">>></a>'; 296 377 } 297 378 } … … 299 380 } 300 381 301 function GetRemoteAddress()302 {303 if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;304 else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];305 else $IP = '0.0.0.0';306 return($IP);307 }308 309 function RemoveDiacritic($Text)310 {311 return(str_replace(312 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'),313 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'),314 $Text));315 }316 317 function NotBlank($Text)318 {319 if($Text == '') return(' '); else return($Text);320 }321 322 function MakeLink($Target, $Title)323 {324 return('<a href="'.$Target.'">'.$Title.'</a>');325 }326 327 function Table($Table, $Class)328 {329 $Result = '<table class="'.$Class.'">';330 if(array_key_exists('Header', $Table))331 {332 $Result .= '<tr>';333 foreach($Table['Header'] as $Item)334 $Result .= '<th>'.$Item.'</th>';335 $Result .= '</tr>';336 }337 foreach($Table['Rows'] as $Row)338 {339 $Result .= '<tr>';340 foreach($Row as $Index => $Item)341 {342 if($Index == 0) $Class = ' class="Header"'; else $Class = '';343 $Result .= '<td'.$Class.'>'.$Item.'</td>';344 }345 $Result .= '</tr>';346 }347 $Result .= '</table>';348 return($Result);349 }350 351 382 ?>
Note:
See TracChangeset
for help on using the changeset viewer.