| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | $TimeStart = time();
|
|---|
| 4 |
|
|---|
| 5 | // SQL injection hack protection
|
|---|
| 6 | foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
|
|---|
| 7 | foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
|
|---|
| 8 |
|
|---|
| 9 | session_start();
|
|---|
| 10 | include('config.php');
|
|---|
| 11 | include('database.php');
|
|---|
| 12 | //$Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
|
|---|
| 13 | //$Database->Prefix = $Config['Database']['Prefix'];
|
|---|
| 14 | //$Database->charset($Config['Database']['Charset']);
|
|---|
| 15 |
|
|---|
| 16 | $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
|
|---|
| 17 |
|
|---|
| 18 | function GetMicrotime()
|
|---|
| 19 | {
|
|---|
| 20 | list($Usec, $Sec) = explode(" ", microtime());
|
|---|
| 21 | return ((float)$Usec + (float)$Sec);
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | function ShowArray($Pole)
|
|---|
| 25 | {
|
|---|
| 26 | echo('<pre style="font-size: 8pt;">');
|
|---|
| 27 | print_r($Pole);
|
|---|
| 28 | echo('</pre>');
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | function TimeToMysqlDateTime($Time)
|
|---|
| 32 | {
|
|---|
| 33 | return(date('Y-m-d H:i:s', $Time));
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | function MysqlDateTimeToTime($Time)
|
|---|
| 37 | {
|
|---|
| 38 | $Parts = explode(' ', $Time);
|
|---|
| 39 | $DateParts = explode('-', $Parts[0]);
|
|---|
| 40 | $TimeParts = explode(':', $Parts[1]);
|
|---|
| 41 | $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
|
|---|
| 42 | return($Result);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | function MysqlDateToTime($Time)
|
|---|
| 46 | {
|
|---|
| 47 | return(MysqlDateTimeToTime($Time.' 0:0:0'));
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | function HumanDate($Time)
|
|---|
| 51 | {
|
|---|
| 52 | $Date = explode(' ', $Time);
|
|---|
| 53 | $Parts = explode('-', $Date[0]);
|
|---|
| 54 | if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
|
|---|
| 55 | else return(' ');
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | // Zobrazení číselný seznamu stránek
|
|---|
| 59 | function PagesList($URL,$Page,$TotalCount,$CountPerPage)
|
|---|
| 60 | {
|
|---|
| 61 | $Count = ceil($TotalCount/$CountPerPage);
|
|---|
| 62 | $Around = 10;
|
|---|
| 63 | $Result = '';
|
|---|
| 64 | if($Count>1)
|
|---|
| 65 | {
|
|---|
| 66 | if($Page>0)
|
|---|
| 67 | {
|
|---|
| 68 | $Result.= '<a href="'.$URL.'0"><<</a> ';
|
|---|
| 69 | $Result.= '<a href="'.$URL.($Page-1).'"><</a> ';
|
|---|
| 70 | }
|
|---|
| 71 | $PagesMax = $Count-1;
|
|---|
| 72 | $PagesMin = 0;
|
|---|
| 73 | if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
|
|---|
| 74 | if($PagesMin<($Page-$Around))
|
|---|
| 75 | {
|
|---|
| 76 | $Result.= ' .. ';
|
|---|
| 77 | $PagesMin = $Page-$Around;
|
|---|
| 78 | }
|
|---|
| 79 | for($i=$PagesMin;$i<=$PagesMax;$i++)
|
|---|
| 80 | {
|
|---|
| 81 | if($i==$Page) $Result.= '<strong>';
|
|---|
| 82 | $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
|
|---|
| 83 | if($i==$Page) $Result.= '</strong>';
|
|---|
| 84 | }
|
|---|
| 85 | if($PagesMax<($Count-1)) $Result .= ' .. ';
|
|---|
| 86 | if($Page<($Count-1))
|
|---|
| 87 | {
|
|---|
| 88 | $Result.= '<a href="'.$URL.($Page+1).'">></a> ';
|
|---|
| 89 | $Result.= '<a href="'.$URL.($Count-1).'">>></a>';
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 | return($Result);
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | function GetRemoteAddress()
|
|---|
| 96 | {
|
|---|
| 97 | if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
|
|---|
| 98 | else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
|
|---|
| 99 | else $IP = '0.0.0.0';
|
|---|
| 100 | return($IP);
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | function IsInternetAddr()
|
|---|
| 104 | {
|
|---|
| 105 | $RemoteAddr = GetRemoteAddress();
|
|---|
| 106 | $RemoteAddr = explode('.', $RemoteAddr);
|
|---|
| 107 | return(!(($RemoteAddr[0] == 192) and ($RemoteAddr[1] == 168)));
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | function ShowPage($Title, $Content)
|
|---|
| 111 | {
|
|---|
| 112 | global $Config, $TimeStart;
|
|---|
| 113 |
|
|---|
| 114 | $Output = '<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'"?>'."\n".
|
|---|
| 115 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n".
|
|---|
| 116 | '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'."\n".
|
|---|
| 117 | '<head><link rel="stylesheet" href="'.$Config['Web']['RootFolder'].'style.css" type="text/css" media="all" />'."\n".
|
|---|
| 118 | '<script type="text/javascript" src="'.$Config['Web']['RootFolder'].'global.js"></script>'."\n".
|
|---|
| 119 | '<title>'.$Config['Web']['Title'].' - '.$Title.'</title>'."\n".
|
|---|
| 120 | '</head><body>'."\n";
|
|---|
| 121 | //'<div id="Title">'.$Title.'</div>';
|
|---|
| 122 | $Time = floor((GetMicrotime() - $TimeStart) * 100) / 100;
|
|---|
| 123 | $Output .= $Content.'<div id="Footer">
|
|---|
| 124 | <i>| Správa webu: Jiří Hajda | e-mail: robie@centrum.cz | Vygenerováno za '.$Time.' s | Použitá paměť: '.HumanSize(memory_get_peak_usage(FALSE)).' |</i>
|
|---|
| 125 | </div>';
|
|---|
| 126 | //ShowArray($GLOBALS);
|
|---|
| 127 | $Output .= '</body></html>';
|
|---|
| 128 | echo($Output);
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB');
|
|---|
| 132 |
|
|---|
| 133 | function HumanSize($Value)
|
|---|
| 134 | {
|
|---|
| 135 | global $UnitNames;
|
|---|
| 136 |
|
|---|
| 137 | $UnitIndex = 0;
|
|---|
| 138 | while($Value > 1024)
|
|---|
| 139 | {
|
|---|
| 140 | $Value = round($Value / 1024, 3);
|
|---|
| 141 | $UnitIndex++;
|
|---|
| 142 | }
|
|---|
| 143 | return($Value.' '.$UnitNames[$UnitIndex]);
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | ?>
|
|---|