1 | <?php
|
---|
2 |
|
---|
3 | session_start();
|
---|
4 | include('config.php');
|
---|
5 | include('database.php');
|
---|
6 | include('error.php');
|
---|
7 | $Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
|
---|
8 | $Database->Prefix = $Config['Database']['Prefix'];
|
---|
9 | $Database->charset($Config['Database']['Charset']);
|
---|
10 |
|
---|
11 | // SQL injection hack protection
|
---|
12 | foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
|
---|
13 | foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
|
---|
14 |
|
---|
15 | $MonthNames = array('','Leden','Únor','Březen','Duben','Květen','Červen','Červenec','Srpen','Září','Říjen','Listopad','Prosinec');
|
---|
16 |
|
---|
17 | function GetMicrotime()
|
---|
18 | {
|
---|
19 | list($Usec, $Sec) = explode(" ",microtime());
|
---|
20 | return ((float)$Usec + (float)$Sec);
|
---|
21 | }
|
---|
22 |
|
---|
23 | function ShowArray($Pole)
|
---|
24 | {
|
---|
25 | echo('<pre style="font-size: 8pt;">');
|
---|
26 | print_r($Pole);
|
---|
27 | echo('</pre>');
|
---|
28 | }
|
---|
29 |
|
---|
30 | function ToVpnIp($Host)
|
---|
31 | {
|
---|
32 | if($Host['external_ip'] == '')
|
---|
33 | {
|
---|
34 | $Parts = explode('.', $Host['IP']);
|
---|
35 | return('10.0.'.$Parts[2].'.'.$Parts[3]);
|
---|
36 | } else
|
---|
37 | {
|
---|
38 | return($Host['external_ip']);
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | function HumanDate($Date)
|
---|
43 | {
|
---|
44 | $Parts = explode('-',$Date);
|
---|
45 | if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);
|
---|
46 | else return(' ');
|
---|
47 | }
|
---|
48 |
|
---|
49 | // Zobrazení číselný seznamu stránek
|
---|
50 | function PagesList($URL,$Page,$TotalCount,$CountPerPage)
|
---|
51 | {
|
---|
52 | $Count = ceil($TotalCount/$CountPerPage);
|
---|
53 | $Around = 10;
|
---|
54 | $Result = '';
|
---|
55 | if($Count>1)
|
---|
56 | {
|
---|
57 | if($Page>0)
|
---|
58 | {
|
---|
59 | $Result.= '<a href="'.$URL.'0"><<</a> ';
|
---|
60 | $Result.= '<a href="'.$URL.($Page-1).'"><</a> ';
|
---|
61 | }
|
---|
62 | $PagesMax = $Count-1;
|
---|
63 | $PagesMin = 0;
|
---|
64 | if($PagesMax>($Page+$Around)) $PagesMax = $Page+$Around;
|
---|
65 | if($PagesMin<($Page-$Around))
|
---|
66 | {
|
---|
67 | $Result.= ' .. ';
|
---|
68 | $PagesMin = $Page-$Around;
|
---|
69 | }
|
---|
70 | for($i=$PagesMin;$i<=$PagesMax;$i++)
|
---|
71 | {
|
---|
72 | if($i==$Page) $Result.= '<strong>';
|
---|
73 | $Result.= '<a href="'.$URL.$i.'">'.($i+1).'</a> ';
|
---|
74 | if($i==$Page) $Result.= '</strong>';
|
---|
75 | }
|
---|
76 | if($PagesMax<($Count-1)) $Result .= ' .. ';
|
---|
77 | if($Page<($Count-1))
|
---|
78 | {
|
---|
79 | $Result.= '<a href="'.$URL.($Page+1).'">></a> ';
|
---|
80 | $Result.= '<a href="'.$URL.($Count-1).'">>></a>';
|
---|
81 | }
|
---|
82 | }
|
---|
83 | return($Result);
|
---|
84 | }
|
---|
85 |
|
---|
86 | function GetRemoteAddress()
|
---|
87 | {
|
---|
88 | if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
|
---|
89 | else $IP = $_SERVER['REMOTE_ADDR'];
|
---|
90 | //if($IP == '127.0.0.1')
|
---|
91 | return($IP);
|
---|
92 | }
|
---|
93 |
|
---|
94 | function IsInternetAddr()
|
---|
95 | {
|
---|
96 | $RemoteAddr = GetRemoteAddress();
|
---|
97 | $RemoteAddr = explode('.', $RemoteAddr);
|
---|
98 | return(!(($RemoteAddr[0] == 192) and ($RemoteAddr[1] == 168)));
|
---|
99 | }
|
---|
100 |
|
---|
101 | // Funkce formatovani vystupu
|
---|
102 | function FormatOutput($s)
|
---|
103 | {
|
---|
104 | $out = '';
|
---|
105 | $nn = 0;
|
---|
106 | $n = 0;
|
---|
107 | while($s!='')
|
---|
108 | {
|
---|
109 | $start = strpos($s,'<');
|
---|
110 | $end = strpos($s,'>');
|
---|
111 | if($start != 0)
|
---|
112 | {
|
---|
113 | $end = $start-1;
|
---|
114 | $start = 0;
|
---|
115 | }
|
---|
116 | $line = trim(substr($s,$start,$end+1));
|
---|
117 | if(strlen($line)>0)
|
---|
118 | if($line[0] == '<')
|
---|
119 | {
|
---|
120 | if($s[$start+1] == '/')
|
---|
121 | {
|
---|
122 | $n = $n - 2;
|
---|
123 | $nn = $n;
|
---|
124 | } else
|
---|
125 | {
|
---|
126 | if(strpos($line,' ')) $cmd = substr($line,1,strpos($line,' ')-1);
|
---|
127 | else $cmd = substr($line,1,strlen($line)-2);
|
---|
128 | //echo('['.$cmd.']');
|
---|
129 | if(strpos($s,'</'.$cmd.'>')) $n = $n + 2;
|
---|
130 | }
|
---|
131 | }// else $line = '['.$line.']';
|
---|
132 | //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
|
---|
133 | if($line != '') $out .= (str_repeat(' ',$nn).$line."\n");
|
---|
134 | $s = substr($s,$end+1,strlen($s));
|
---|
135 | $nn = $n;
|
---|
136 | }
|
---|
137 | return($out);
|
---|
138 | }
|
---|
139 |
|
---|
140 | ?>
|
---|