1 | <?php
|
---|
2 |
|
---|
3 | include_once('Database.php');
|
---|
4 | include_once('Config.php');
|
---|
5 | include_once('Meet.php');
|
---|
6 |
|
---|
7 | session_start();
|
---|
8 |
|
---|
9 | function HumanDate($Time)
|
---|
10 | {
|
---|
11 | return(date('j.n.Y', $Time));
|
---|
12 | }
|
---|
13 |
|
---|
14 | class Application
|
---|
15 | {
|
---|
16 | function Link($URL)
|
---|
17 | {
|
---|
18 | if(substr($URL, 0, 1) == '/') return($this->Config['BaseURL'].substr($URL, 1));
|
---|
19 | else return($URL);
|
---|
20 | }
|
---|
21 |
|
---|
22 | function Run()
|
---|
23 | {
|
---|
24 |
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | class MyApplication extends Application
|
---|
29 | {
|
---|
30 | var $Database;
|
---|
31 | var $Config;
|
---|
32 |
|
---|
33 | function __construct()
|
---|
34 | {
|
---|
35 | }
|
---|
36 |
|
---|
37 | function ShowMenu()
|
---|
38 | {
|
---|
39 | $Output = '<div>'.
|
---|
40 | '<a href="'.$this->Link('/tance/').'">Tance</a> '.
|
---|
41 | '<a href="'.$this->Link('/skoly/').'">Školy</a> '.
|
---|
42 | '<a href="'.$this->Link('/seznamka/').'">Seznamka</a> '.
|
---|
43 | '</div>';
|
---|
44 | return($Output);
|
---|
45 | }
|
---|
46 |
|
---|
47 | function ProcessURL()
|
---|
48 | {
|
---|
49 | if(array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
|
---|
50 | $PathString = $_SERVER['REDIRECT_QUERY_STRING'];
|
---|
51 | else $PathString = '';
|
---|
52 | if(substr($PathString, -1, 1) == '/') $PathString = substr($PathString, 0, -1);
|
---|
53 | $PathItems = explode('/', $PathString);
|
---|
54 | if(array_key_exists('REQUEST_URI', $_SERVER) and (strpos($_SERVER['REQUEST_URI'], '?') !== false))
|
---|
55 | $_SERVER['QUERY_STRING'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?') + 1);
|
---|
56 | else $_SERVER['QUERY_STRING'] = '';
|
---|
57 | parse_str($_SERVER['QUERY_STRING'], $_GET);
|
---|
58 | return($PathItems);
|
---|
59 | }
|
---|
60 |
|
---|
61 | function ShowDanceList()
|
---|
62 | {
|
---|
63 | $Output = '<h4 style="text-align: center;">Tance:</h4>';
|
---|
64 | $Output .= '<table class="WideTable">';
|
---|
65 | $Output .= '<tr><th>Název</th><th>Skupina</th>';
|
---|
66 | $DbResult2 = $this->Database->select('ResourceGroup', '*');
|
---|
67 | while($ResourceGroup = $DbResult2->fetch_assoc())
|
---|
68 | {
|
---|
69 | $Output .= '<th>'.$ResourceGroup['Name'].'</th>';
|
---|
70 | }
|
---|
71 | $Output .= '</tr>';
|
---|
72 | $DbResult = $this->Database->select('Dance', '*, (SELECT Name FROM DanceGroup WHERE DanceGroup.Id=Dance.Group) AS GroupName', '1 ORDER BY `Name`');
|
---|
73 | while($Dance = $DbResult->fetch_assoc())
|
---|
74 | {
|
---|
75 | $Output .= '<tr><td>'.$Dance['Name'].'</th><td>'.$Dance['GroupName'].'</td>';
|
---|
76 | $DbResult2 = $this->Database->select('ResourceGroup', '*');
|
---|
77 | while($ResourceGroup = $DbResult2->fetch_assoc())
|
---|
78 | {
|
---|
79 | $Output .= '<td>';
|
---|
80 | $DbResult3 = $this->Database->select('Resource', '*', '(`Dance`='.$Dance['Id'].') AND (`Group`='.$ResourceGroup['Id'].')');
|
---|
81 | while($Resource = $DbResult3->fetch_assoc())
|
---|
82 | {
|
---|
83 | $Output .= '<a href="'.$Resource['URL'].'">'.$Resource['Name'].'</a> ';
|
---|
84 | }
|
---|
85 | $Output .= '</td>';
|
---|
86 | }
|
---|
87 | $Output .= '</tr>';
|
---|
88 | }
|
---|
89 | $Output .= '</table>';
|
---|
90 |
|
---|
91 | return($Output);
|
---|
92 | }
|
---|
93 |
|
---|
94 | function ShowSchoolList()
|
---|
95 | {
|
---|
96 | $Output = '<h4 style="text-align: center;">Taneční školy:</h4>';
|
---|
97 | $Output .= '<table class="WideTable">';
|
---|
98 | $Output .= '<tr><th>Název</th><th>Adresa</th>';
|
---|
99 | $Output .= '</tr>';
|
---|
100 | $DbResult = $this->Database->select('School', '*', '1 ORDER BY `Name`');
|
---|
101 | while($School = $DbResult->fetch_assoc())
|
---|
102 | {
|
---|
103 | $Output .= '<tr><td><a href="'.$this->Link($School['URL']).'">'.$School['Name'].'</a></th><td>'.$School['Address'].'</td>';
|
---|
104 | $Output .= '</tr>';
|
---|
105 | }
|
---|
106 | $Output .= '</table>';
|
---|
107 |
|
---|
108 | return($Output);
|
---|
109 | }
|
---|
110 |
|
---|
111 | function ShowMeetUpdate()
|
---|
112 | {
|
---|
113 | $MeetSources = new MeetSources();
|
---|
114 | $MeetSources->Database = $this->Database;
|
---|
115 | $MeetSources->ParseAll();
|
---|
116 | }
|
---|
117 |
|
---|
118 | function ShowMeetList()
|
---|
119 | {
|
---|
120 | if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
|
---|
121 | {
|
---|
122 | $this->NoFullPage = true;
|
---|
123 | if (array_key_exists('vekod', $_GET) ) $_SESSION['vekod'] = $_GET['vekod'];
|
---|
124 | if (array_key_exists('vekdo', $_GET) ) $_SESSION['vekdo'] = $_GET['vekdo'];
|
---|
125 | if (array_key_exists('vyskaod', $_GET) ) $_SESSION['vyskaod'] = $_GET['vyskaod'];
|
---|
126 | if (array_key_exists('vyskado', $_GET) ) $_SESSION['vyskado'] = $_GET['vyskado'];
|
---|
127 | } else {
|
---|
128 | $Output = '';
|
---|
129 | $Output .= '<script>function reloadlist(){ $(\'#meetlist\').load(document.URL + \' #meetlist\');}'.
|
---|
130 | ' var load_timer = 100;
|
---|
131 | var ltimer = null;
|
---|
132 |
|
---|
133 | function checkOut(kc,obj){
|
---|
134 | if(kc==13) $(obj).blur();
|
---|
135 | }
|
---|
136 | function initLTimer(tm){
|
---|
137 | if(ltimer) clearTimeout(ltimer);
|
---|
138 | ltimer = setTimeout("freloader()",tm);
|
---|
139 | }
|
---|
140 | function stopLTimer(){
|
---|
141 | if(ltimer) clearTimeout(ltimer);
|
---|
142 | ltimer = null;
|
---|
143 | }
|
---|
144 |
|
---|
145 | var cf = {pohlavi:\'2\'};
|
---|
146 |
|
---|
147 | function setupc(key,val){
|
---|
148 | //console.log(\'setup-control-\'+key+\' = \'+val);
|
---|
149 | if(key==\'vekod\' || key==\'vekdo\' || key==\'vyskaod\' || key==\'vyskado\' || key==\'vahaod\' || key==\'vahado\') {
|
---|
150 | var ccv = $(\'#\'+key).val();
|
---|
151 | if(ccv!=val) $(\'#\'+key).val(val==0?\'\':val);
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | function upf(key,val,lonreload){
|
---|
156 | if(key!=\'first\') cf[\'first\']=0; else st();
|
---|
157 | setupc(key,val);
|
---|
158 | cf[key]=val;
|
---|
159 | if(lonreload) initLTimer(1000); else initLTimer(100);
|
---|
160 | }
|
---|
161 |
|
---|
162 | function freloader(){
|
---|
163 | ltimer = null;
|
---|
164 | var qp = jQuery.param( cf );
|
---|
165 | $(\'#list_content\').html(\'\'); $(\'#list_loading\').show();
|
---|
166 | $.get(\'\\seznamka?lvm=seznam&\'+qp,function(data){$(\'#list_loading\').hide();$(\'#list_content\').html(data);htip()})
|
---|
167 | }'.
|
---|
168 | '</script>';
|
---|
169 | $Output .= '<div class="filter-num-box">'.
|
---|
170 | '<div class="label-box">Věk</div>'.
|
---|
171 | '<input value="" onkeyup="if(event.keyCode!=9) upf(\'vekod\',$(this).val(),(event.keyCode==13?0:1)); '.
|
---|
172 | '" id="vekod" autocomplete="off" type="text">'.
|
---|
173 | '<div class="label-box">-</div>'.
|
---|
174 | '<input value="" onkeyup="'.
|
---|
175 | 'if(event.keyCode!=9) upf(\'vekdo\',$(this).val(),(event.keyCode==13?0:1));" '.
|
---|
176 | 'id="vekdo" autocomplete="off" type="text"><div class="label-box">let</div></div>'.
|
---|
177 | '</div> '.
|
---|
178 | '<div class="filter-num-box">'.
|
---|
179 | '<div class="label-box">Výška</div>'.
|
---|
180 | '<input value="" onkeyup="if(event.keyCode!=9) upf(\'vyskaod\',$(this).val(),(event.keyCode==13?0:1)); '.
|
---|
181 | '" id="vyskaod" autocomplete="off" type="text">'.
|
---|
182 | '<div class="label-box">-</div>'.
|
---|
183 | '<input value="" onkeyup="'.
|
---|
184 | 'if(event.keyCode!=9) upf(\'vyskado\',$(this).val(),(event.keyCode==13?0:1));" '.
|
---|
185 | 'id="vyskado" autocomplete="off" type="text"><div class="label-box">cm</div></div>'.
|
---|
186 | '</div>';
|
---|
187 | $Output .= '<h4 style="text-align: center;">Inzeráty:</h4>';
|
---|
188 | }
|
---|
189 |
|
---|
190 | $Gender = array('', 'Muž', 'Žena');
|
---|
191 | $Output .= '<div id="list_content">'.
|
---|
192 | '<table class="WideTable">';
|
---|
193 | $Output .= '<tr>'.
|
---|
194 | '<th>Datum</th>'.
|
---|
195 | '<th>Jméno</th>'.
|
---|
196 | '<th>Výška</th>'.
|
---|
197 | '<th>Věk</th>'.
|
---|
198 | '<th>Váha</th>'.
|
---|
199 | //'<th>Email</th>'.
|
---|
200 | //'<th>Telefon</th>'.
|
---|
201 | '<th>Pohlaví</th>'.
|
---|
202 | '<th>Zpráva</th>'.
|
---|
203 | '<th>Zdroj</th>';
|
---|
204 | $Output .= '</tr>';
|
---|
205 | $Where = '';
|
---|
206 | if (array_key_exists('vekod', $_SESSION) and ($_SESSION['vekod'] != '')) $Where .= ' AND (Age >= '.$_SESSION['vekod'].')';
|
---|
207 | if (array_key_exists('vekdo', $_SESSION) and ($_SESSION['vekdo'] != '')) $Where .= ' AND (Age <= '.$_SESSION['vekdo'].')';
|
---|
208 | if (array_key_exists('vyskaod', $_SESSION) and ($_SESSION['vyskaod'] != '')) $Where .= ' AND (Height >= '.$_SESSION['vyskaod'].')';
|
---|
209 | if (array_key_exists('vyskado', $_SESSION) and ($_SESSION['vyskado'] != '')) $Where .= ' AND (Height <= '.$_SESSION['vyskado'].')';
|
---|
210 | if (substr($Where, 0, 4) == ' AND') $Where = substr($Where, 4);
|
---|
211 | if ($Where == '') $Where = '1';
|
---|
212 | $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
|
---|
213 | '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', $Where.' ORDER BY `Date` DESC');
|
---|
214 | while($MeetItem = $DbResult->fetch_assoc())
|
---|
215 | {
|
---|
216 | $Output .= '<tr>'.
|
---|
217 | '<td>'.HumanDate(MysqlDateToTime($MeetItem['Date'])).'</td>'.
|
---|
218 | '<td>'.$MeetItem['Name'].'</td>'.
|
---|
219 | '<td>'.$MeetItem['Height'].'</td>'.
|
---|
220 | '<td>'.$MeetItem['Age'].'</td>'.
|
---|
221 | '<td>'.$MeetItem['Weight'].'</td>'.
|
---|
222 | //'<td>'.$MeetItem['Email'].'</td>'.
|
---|
223 | //'<td>'.$MeetItem['Phone'].'</td>'.
|
---|
224 | '<td>'.$Gender[$MeetItem['Gender']].'</td>'.
|
---|
225 | '<td>'.$MeetItem['Message'].'</td>'.
|
---|
226 | '<td><a href="'.$this->Link($MeetItem['SourceURL']).'">'.$MeetItem['SourceName'].'</a></td>';
|
---|
227 | $Output .= '</tr>';
|
---|
228 | }
|
---|
229 | $Output .= '</table></div>';
|
---|
230 |
|
---|
231 | return($Output);
|
---|
232 | }
|
---|
233 |
|
---|
234 | function ShowPage($Content)
|
---|
235 | {
|
---|
236 | $Output = '<?xml version="1.0" encoding="'.$this->Config['Encoding'].'"?>'."\n".
|
---|
237 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
|
---|
238 | '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
|
---|
239 | '<head>'.
|
---|
240 | '<link rel="stylesheet" href="'.$this->Link('/style.css').'" type="text/css" media="all" />'.
|
---|
241 | '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Config['Encoding'].'" />'.
|
---|
242 | '<script src="jquery.js"></script>'.
|
---|
243 | '<title>Tance</title>'.
|
---|
244 | '</head><body>';
|
---|
245 | $Output .= $Content;
|
---|
246 | $Output .= '</body></html>';
|
---|
247 | return($Output);
|
---|
248 | }
|
---|
249 |
|
---|
250 | function Run()
|
---|
251 | {
|
---|
252 | global $Config;
|
---|
253 |
|
---|
254 | $this->Config = $Config;
|
---|
255 | $this->Database = new Database();
|
---|
256 | $this->Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'],
|
---|
257 | $this->Config['Database']['Password'], $this->Config['Database']['Database']);
|
---|
258 | $this->Database->Prefix = $this->Config['Database']['Prefix'];
|
---|
259 | $this->Database->charset($this->Config['Database']['Charset']);
|
---|
260 | $this->PathItems = $this->ProcessURL();
|
---|
261 |
|
---|
262 | $Output = '';
|
---|
263 |
|
---|
264 | if(count($this->PathItems) > 0) {
|
---|
265 | if($this->PathItems[0] == 'skoly') $Output .= $this->ShowSchoolList();
|
---|
266 | else if($this->PathItems[0] == 'tance') $Output .= $this->ShowDanceList();
|
---|
267 | else if($this->PathItems[0] == 'seznamka') $Output .= $this->ShowMeetList();
|
---|
268 | else if($this->PathItems[0] == 'seznamka-aktualizace') $Output .= $this->ShowMeetUpdate();
|
---|
269 | else $Output .= $this->ShowDanceList();
|
---|
270 | } else $Output .= $this->ShowDanceList();
|
---|
271 | if (!$this->NoFullPage) {
|
---|
272 | $Output = $this->ShowMenu().$Output;
|
---|
273 | echo($this->ShowPage($Output));
|
---|
274 | } else echo($Output);
|
---|
275 | }
|
---|
276 | }
|
---|
277 |
|
---|
278 | $Application = new MyApplication();
|
---|
279 | $Application->Run();
|
---|