| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | // SQL injection hack protection
|
|---|
| 4 | foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
|
|---|
| 5 | foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
|
|---|
| 6 |
|
|---|
| 7 | if(!isset($SessionDisable)) session_start();
|
|---|
| 8 | include('config.php');
|
|---|
| 9 | include('error.php');
|
|---|
| 10 | include('database.php');
|
|---|
| 11 | include('code.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 | $Database->ShowError = TRUE;
|
|---|
| 16 | include('module.php');
|
|---|
| 17 | include('page.php');
|
|---|
| 18 | include('forms.php');
|
|---|
| 19 | include('types/include.php');
|
|---|
| 20 | include('lists/include.php');
|
|---|
| 21 | include('base.php');
|
|---|
| 22 |
|
|---|
| 23 | class System extends Module
|
|---|
| 24 | {
|
|---|
| 25 | var $Modules = array();
|
|---|
| 26 |
|
|---|
| 27 | function ModulePresent($Name)
|
|---|
| 28 | {
|
|---|
| 29 | return(array_key_exists($Name, $this->Modules));
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | function AddModule($Module)
|
|---|
| 33 | {
|
|---|
| 34 | global $Database;
|
|---|
| 35 |
|
|---|
| 36 | //echo('Přidávám modul '.get_class($Module).'<br>');
|
|---|
| 37 | $Module->System = &$this;
|
|---|
| 38 | $Module->Database = &$Database;
|
|---|
| 39 | $this->Modules[get_class($Module)] = $Module;
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | $System = new System();
|
|---|
| 44 | $System->Config = $Config;
|
|---|
| 45 | include_once('database_list.php');
|
|---|
| 46 | $System->AddModule(new DatabaseList());
|
|---|
| 47 | include_once('log.php');
|
|---|
| 48 | $System->AddModule(new Log());
|
|---|
| 49 | include_once('user.php');
|
|---|
| 50 | $System->AddModule(new User());
|
|---|
| 51 | $System->Modules['User']->Check();
|
|---|
| 52 |
|
|---|
| 53 | $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
|
|---|
| 54 |
|
|---|
| 55 | function GetMicrotime()
|
|---|
| 56 | {
|
|---|
| 57 | list($Usec, $Sec) = explode(" ", microtime());
|
|---|
| 58 | return ((float)$Usec + (float)$Sec);
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | function ShowArray($Value)
|
|---|
| 62 | {
|
|---|
| 63 | echo('<pre style="font-size: 8pt;">');
|
|---|
| 64 | print_r($Value);
|
|---|
| 65 | echo('</pre>');
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | function TimeToMysqlDateTime($Time)
|
|---|
| 69 | {
|
|---|
| 70 | return(date('Y-m-d H:i:s', $Time));
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | function MysqlDateTimeToTime($Time)
|
|---|
| 74 | {
|
|---|
| 75 | $Parts = explode(' ', $Time);
|
|---|
| 76 | $DateParts = explode('-', $Parts[0]);
|
|---|
| 77 | $TimeParts = explode(':', $Parts[1]);
|
|---|
| 78 | $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
|
|---|
| 79 | return($Result);
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | function MysqlDateToTime($Time)
|
|---|
| 83 | {
|
|---|
| 84 | return(MysqlDateTimeToTime($Time.' 0:0:0'));
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | function HumanDate($Time)
|
|---|
| 88 | {
|
|---|
| 89 | $Date = explode(' ', $Time);
|
|---|
| 90 | $Parts = explode('-', $Date[0]);
|
|---|
| 91 | if($Date != '0000-00-00') return(($Parts[2] * 1).'.'.($Parts[1] * 1).'.'.$Parts[0]);
|
|---|
| 92 | else return(' ');
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | function PagesList($Page, $TotalCount)
|
|---|
| 96 | {
|
|---|
| 97 | global $Config;
|
|---|
| 98 |
|
|---|
| 99 | $URL = $_SERVER['QUERY_STRING'];
|
|---|
| 100 | $URLParts = explode('&', $URL);
|
|---|
| 101 | $URL = '';
|
|---|
| 102 | foreach($URLParts as $Index => $Item)
|
|---|
| 103 | {
|
|---|
| 104 | $ItemParts = explode('=', $Item);
|
|---|
| 105 | if($ItemParts[0] != 'Page') $URL .= $Item.'&';
|
|---|
| 106 | }
|
|---|
| 107 | $URL = '?'.$URL.'Page=';
|
|---|
| 108 | $Count = ceil($TotalCount / $Config['Web']['ItemsPerPage']);
|
|---|
| 109 |
|
|---|
| 110 | $Around = 10;
|
|---|
| 111 | $Result = '';
|
|---|
| 112 | if($Count > 1)
|
|---|
| 113 | {
|
|---|
| 114 | if($Page > 0)
|
|---|
| 115 | {
|
|---|
| 116 | $Result .= '<a href="'.$URL.'0"><<</a> ';
|
|---|
| 117 | $Result .= '<a href="'.$URL.($Page - 1).'"><</a> ';
|
|---|
| 118 | }
|
|---|
| 119 | $PagesMax = $Count - 1;
|
|---|
| 120 | $PagesMin = 0;
|
|---|
| 121 | if($PagesMax > ($Page + $Around)) $PagesMax = $Page + $Around;
|
|---|
| 122 | if($PagesMin < ($Page - $Around))
|
|---|
| 123 | {
|
|---|
| 124 | $Result .= ' .. ';
|
|---|
| 125 | $PagesMin = $Page - $Around;
|
|---|
| 126 | }
|
|---|
| 127 | for($i = $PagesMin; $i <= $PagesMax; $i++)
|
|---|
| 128 | {
|
|---|
| 129 | if($i == $Page) $Result .= '<strong>';
|
|---|
| 130 | $Result .= '<a href="'.$URL.$i.'">'.($i + 1).'</a> ';
|
|---|
| 131 | if($i == $Page) $Result .= '</strong>';
|
|---|
| 132 | }
|
|---|
| 133 | if($PagesMax < ($Count - 1)) $Result .= ' .. ';
|
|---|
| 134 | if($Page < ($Count - 1))
|
|---|
| 135 | {
|
|---|
| 136 | $Result .= '<a href="'.$URL.($Page + 1).'">></a> ';
|
|---|
| 137 | $Result .= '<a href="'.$URL.($Count - 1).'">>></a>';
|
|---|
| 138 | }
|
|---|
| 139 | }
|
|---|
| 140 | return($Result);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | function GetRemoteAddress()
|
|---|
| 144 | {
|
|---|
| 145 | if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
|
|---|
| 146 | else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
|
|---|
| 147 | else $IP = '0.0.0.0';
|
|---|
| 148 | return($IP);
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | function IsInternetAddr()
|
|---|
| 152 | {
|
|---|
| 153 | $RemoteAddr = GetRemoteAddress();
|
|---|
| 154 | $RemoteAddr = explode('.', $RemoteAddr);
|
|---|
| 155 | return(!(($RemoteAddr[0] == 192) and ($RemoteAddr[1] == 168)));
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB');
|
|---|
| 159 |
|
|---|
| 160 | function HumanSize($Value)
|
|---|
| 161 | {
|
|---|
| 162 | global $UnitNames;
|
|---|
| 163 |
|
|---|
| 164 | $UnitIndex = 0;
|
|---|
| 165 | while($Value > 1024)
|
|---|
| 166 | {
|
|---|
| 167 | $Value = round($Value / 1024, 3);
|
|---|
| 168 | $UnitIndex++;
|
|---|
| 169 | }
|
|---|
| 170 | return($Value.' '.$UnitNames[$UnitIndex]);
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | function SystemMessage($Title, $Text)
|
|---|
| 174 | {
|
|---|
| 175 | return('<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>');
|
|---|
| 176 | //ShowFooter();
|
|---|
| 177 | //die();
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 | ?>
|
|---|