Changeset 37 for trunk/index.php
- Timestamp:
- May 5, 2019, 5:17:06 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/index.php
r36 r37 1 1 <?php 2 2 3 include_once('Database.php'); 4 include_once('Config.php'); 5 include_once('Meet.php'); 6 include_once('RSS.php'); 7 include_once('Global.php'); 8 9 session_start(); 10 11 class Application 12 { 13 var $NoFullPage = false; 14 15 function Link($URL) 16 { 17 return($this->Config['BaseURL'].$URL); 18 } 19 20 function AbsoluteLink($URL) 21 { 22 return($this->Config['HostName'].$this->Config['BaseURL'].$URL); 23 } 24 25 function Run() 26 { 27 28 } 29 } 30 31 class MyApplication extends Application 32 { 33 var $Database; 3 require_once('Config/Config.php'); 4 require_once('Global.php'); 5 require_once('Packages/Common/Common.php'); 6 require_once('View.php'); 7 8 9 require_once('Modules/Meet/Meet.php'); 10 require_once('Modules/Meet/MeetPage.php'); 11 require_once('Modules/Dance/Dance.php'); 12 require_once('Modules/Movie/Movie.php'); 13 require_once('Modules/School/School.php'); 14 require_once('Modules/Club/Club.php'); 15 16 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 17 18 class ApplicationTanec extends Application 19 { 34 20 var $Config; 35 21 var $Title; 22 var $Pages; 23 var $PathItems; 24 var $ShowPage; 25 var $MainMenu; 26 var $PageHeaders; 27 var $Bars; 36 28 37 29 function __construct() 38 30 { 31 parent::__construct(); 32 $this->ShowPage = true; 33 $this->MainMenu = array(); 34 $this->PageHeaders = array(); 35 $this->Bars = array(); 36 } 37 38 function Link($URL) 39 { 40 return($this->Config['BaseURL'].$URL); 41 } 42 43 function AbsoluteLink($URL) 44 { 45 return($this->Config['HostName'].$this->Config['BaseURL'].$URL); 39 46 } 40 47 41 48 function ShowMenu() 42 49 { 43 $Output = '<div>' .44 '<a href="'.$this->Link('/tance/').'">Tance</a> '.45 '<a href="'.$this->Link('/skoly/').'">Školy</a> '.46 '<a href="'.$this->Link('/seznamka/').'">Seznamka</a> '.47 '<a href="'.$this->Link('/filmy/').'">Filmy</a> '.48 50 $Output = '<div>'; 51 foreach($this->MainMenu as $MenuItem) 52 { 53 $Output .= '<a href="'.$this->Link($MenuItem['Link']).'">'.$MenuItem['Title'].'</a> '; 54 } 55 $Output .= '</div>'; 49 56 return($Output); 50 57 } … … 63 70 return($PathItems); 64 71 } 65 66 function ShowDanceList() 67 { 68 $this->Title = 'Tance - '.$this->Title; 69 $Output = '<div class="title">Tance</div>'; 70 $Output .= '<table class="WideTable">'; 71 $Output .= '<tr><th>Název</th><th>Skupina</th>'; 72 $DbResult2 = $this->Database->select('ResourceGroup', '*'); 73 while($ResourceGroup = $DbResult2->fetch_assoc()) 74 { 75 $Output .= '<th>'.$ResourceGroup['Name'].'</th>'; 76 } 77 $Output .= '</tr>'; 78 $DbResult = $this->Database->select('Dance', '*, (SELECT Name FROM DanceGroup WHERE DanceGroup.Id=Dance.Group) AS GroupName', '1 ORDER BY `Name`'); 79 while($Dance = $DbResult->fetch_assoc()) 80 { 81 $Output .= '<tr><td>'.$Dance['Name'].'</td><td>'.$Dance['GroupName'].'</td>'; 82 $DbResult2 = $this->Database->select('ResourceGroup', '*'); 83 while($ResourceGroup = $DbResult2->fetch_assoc()) 84 { 85 $Output .= '<td>'; 86 $DbResult3 = $this->Database->select('Resource', '*', '(`Dance`='.$Dance['Id'].') AND (`Group`='.$ResourceGroup['Id'].')'); 87 while($Resource = $DbResult3->fetch_assoc()) 88 { 89 $Output .= '<a href="'.$Resource['URL'].'">'.$Resource['Name'].'</a> '; 90 } 91 $Output .= '</td>'; 92 } 93 $Output .= '</tr>'; 94 } 95 $Output .= '</table>'; 96 97 return($Output); 98 } 99 100 function ShowSchoolList() 101 { 102 $this->Title = 'Taneční školy - '.$this->Title; 103 $Output = '<div class="title">Taneční školy</div>'; 104 $Output .= '<table class="WideTable">'; 105 $Output .= '<tr><th>Název</th><th>Webové stránky</th><th>Adresa</th>'; 106 $Output .= '</tr>'; 107 $DbResult = $this->Database->select('School', '*', '1 ORDER BY `Name`'); 108 while($School = $DbResult->fetch_assoc()) 109 { 110 $Output .= '<tr>'. 111 '<td>'.$School['Name'].'</td>'. 112 '<td><a href="'.$this->Link($School['URL']).'">'.$School['URL'].'</a></td>'. 113 '<td>'.$School['Address'].'</td>'. 114 '</tr>'; 115 } 116 $Output .= '</table>'; 117 118 return($Output); 119 } 120 121 function ShowMovieList() 122 { 123 $this->Title = 'Filmy - '.$this->Title; 124 $Output = '<div class="title">Filmy</div>'; 125 $Output .= '<table class="WideTable">'; 126 $Output .= '<tr><th>Rok</th><th>Český název</th><th>Anglický název</th><th>IMDb</th><th>ČSFD</th>'; 127 $Output .= '</tr>'; 128 $DbResult = $this->Database->select('Movie', '*', '1 ORDER BY `Year` DESC'); 129 while($Movie = $DbResult->fetch_assoc()) 130 { 131 $Output .= '<tr>'. 132 '<td>'.$Movie['Year'].'</td>'. 133 '<td>'.$Movie['NameCz'].'</td>'. 134 '<td>'.$Movie['NameEn'].'</td>'. 135 '<td><a href="'.$Movie['Imdb'].'">Otevřít</a></td>'. 136 '<td><a href="'.$Movie['Csfd'].'">Otevřít</a></td>'. 137 '</tr>'; 138 } 139 $Output .= '</table>'; 140 141 return($Output); 142 } 143 144 function ShowMeetUpdate() 145 { 146 $MeetSources = new MeetSources(); 147 $MeetSources->Database = $this->Database; 148 if (array_key_exists('i', $_GET)) $MeetSources->Parse($_GET['i']); 149 else $MeetSources->Parse(); 150 } 151 152 function ShowMeetList() 153 { 154 $this->Title = 'Seznamka - '.$this->Title; 155 $Output = ''; 156 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 157 { 158 $this->NoFullPage = true; 159 if (array_key_exists('name', $_GET) ) $_SESSION['name'] = $_GET['name']; 160 if (array_key_exists('location', $_GET) ) $_SESSION['location'] = $_GET['location']; 161 if (array_key_exists('message', $_GET) ) $_SESSION['message'] = $_GET['message']; 162 if (array_key_exists('vekod', $_GET) ) $_SESSION['vekod'] = $_GET['vekod']; 163 if (array_key_exists('vekdo', $_GET) ) $_SESSION['vekdo'] = $_GET['vekdo']; 164 if (array_key_exists('vyskaod', $_GET) ) $_SESSION['vyskaod'] = $_GET['vyskaod']; 165 if (array_key_exists('vyskado', $_GET) ) $_SESSION['vyskado'] = $_GET['vyskado']; 166 if (array_key_exists('vahaod', $_GET) ) $_SESSION['vahaod'] = $_GET['vahaod']; 167 if (array_key_exists('vahado', $_GET) ) $_SESSION['vahado'] = $_GET['vahado']; 168 if (array_key_exists('pohlavi', $_GET) ) { 169 if ($_GET['pohlavi'] > 0) $_SESSION['pohlavi'] = $_GET['pohlavi']; 170 else unset($_SESSION['pohlavi']); 171 } 172 } else { 173 $Output .= '<script type="text/javascript">function reloadlist(){ $(\'#meetlist\').load(document.URL + \' #meetlist\');}'. 174 ' var load_timer = 100; 175 var ltimer = null; 176 177 function checkOut(kc,obj){ 178 if(kc==13) $(obj).blur(); 179 } 180 function initLTimer(tm){ 181 if(ltimer) clearTimeout(ltimer); 182 ltimer = setTimeout("freloader()",tm); 183 } 184 function stopLTimer(){ 185 if(ltimer) clearTimeout(ltimer); 186 ltimer = null; 187 } 188 189 var cf = {}; 190 191 function setupc(key,val){ 192 //console.log(\'setup-control-\'+key+\' = \'+val); 193 if(key==\'vekod\' || key==\'vekdo\' || key==\'vyskaod\' || key==\'vyskado\' || key==\'vahaod\' || key==\'vahado\') { 194 var ccv = $(\'#\'+key).val(); 195 if(ccv!=val) $(\'#\'+key).val(val==0?\'\':val); 196 } 197 if(key==\'pohlavi\') { 198 $(\'.c\'+key).removeClass(\'active\'); 199 $(\'#\'+key+val).addClass(\'active\'); 200 } 201 } 202 203 function upf(key,val,lonreload){ 204 if(key!=\'first\') cf[\'first\']=0; else st(); 205 setupc(key,val); 206 cf[key]=val; 207 if(lonreload) initLTimer(1000); else initLTimer(100); 208 } 209 210 function freloader(){ 211 ltimer = null; 212 var qp = jQuery.param( cf ); 213 $(\'#list_content\').html(\'\'); $(\'#list_loading\').show(); 214 $.get(\''.$this->Link('/seznamka/').'?lvm=seznam&\'+qp,function(data){$(\'#list_loading\').hide();$(\'#list_content\').html(data);htip()}) 215 }'. 216 '</script>'; 217 $Output .= '<div class="title">Inzeráty</div>'; 218 $Output .= '<div class="btn-group ma3">'. 219 '<div class="label-box">Pohlaví</div>'. 220 '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',0)" id="pohlavi0" data-toggle="tooltip" '. 221 'data-placement="top" title="Obě"><span class="icon-both"></span></button>'. 222 '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',1)" id="pohlavi1" data-toggle="tooltip" '. 223 'data-placement="top" title="Muži"><span class="icon-man"></span></button>'. 224 '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',2)" id="pohlavi2" data-toggle="tooltip" '. 225 'data-placement="top" title="Ženy"><span class="icon-woman"></span></button>'. 226 '</div> '; 227 $Output .= '<div class="filter-num-box">'. 228 '<div class="label-box">Jméno</div>'. 229 '<input value="'.$_SESSION['name'].'" onkeyup="if(event.keyCode!=9) upf(\'name\',$(this).val(),(event.keyCode==13?0:1)); '. 230 '" id="name" autocomplete="off" type="text"/>'. 231 '</div> '; 232 $Output .= '<div class="filter-num-box">'. 233 '<div class="label-box">Věk</div>'. 234 '<input value="'.$_SESSION['vekod'].'" onkeyup="if(event.keyCode!=9) upf(\'vekod\',$(this).val(),(event.keyCode==13?0:1)); '. 235 '" id="vekod" autocomplete="off" type="text"/>'. 236 '<div class="label-box">-</div>'. 237 '<input value="'.$_SESSION['vekdo'].'" onkeyup="'. 238 'if(event.keyCode!=9) upf(\'vekdo\',$(this).val(),(event.keyCode==13?0:1));" '. 239 'id="vekdo" autocomplete="off" type="text"/>'. 240 '<div class="label-box">let</div>'. 241 '</div> '; 242 $Output .= '<div class="filter-num-box">'. 243 '<div class="label-box">Výška</div>'. 244 '<input value="'.$_SESSION['vyskaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vyskaod\',$(this).val(),(event.keyCode==13?0:1)); '. 245 '" id="vyskaod" autocomplete="off" type="text"/>'. 246 '<div class="label-box">-</div>'. 247 '<input value="'.$_SESSION['vyskado'].'" onkeyup="'. 248 'if(event.keyCode!=9) upf(\'vyskado\',$(this).val(),(event.keyCode==13?0:1));" '. 249 'id="vyskado" autocomplete="off" type="text"/>'. 250 '<div class="label-box">cm</div>'. 251 '</div> '; 252 $Output .= '<div class="filter-num-box">'. 253 '<div class="label-box">Váha</div>'. 254 '<input value="'.$_SESSION['vahaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vahaod\',$(this).val(),(event.keyCode==13?0:1)); '. 255 '" id="vahaod" autocomplete="off" type="text"/>'. 256 '<div class="label-box">-</div>'. 257 '<input value="'.$_SESSION['vahado'].'" onkeyup="'. 258 'if(event.keyCode!=9) upf(\'vahado\',$(this).val(),(event.keyCode==13?0:1));" '. 259 'id="vahado" autocomplete="off" type="text"/>'. 260 '<div class="label-box">Kg</div>'. 261 '</div> '; 262 $Output .= '<div class="filter-num-box">'. 263 '<div class="label-box">Umístění</div>'. 264 '<input value="'.$_SESSION['location'].'" onkeyup="if(event.keyCode!=9) upf(\'location\',$(this).val(),(event.keyCode==13?0:1)); '. 265 '" id="location" autocomplete="off" type="text"/>'. 266 '</div> '; 267 $Output .= '<div class="filter-num-box">'. 268 '<div class="label-box">Zpráva</div>'. 269 '<input value="'.$_SESSION['message'].'" onkeyup="if(event.keyCode!=9) upf(\'message\',$(this).val(),(event.keyCode==13?0:1)); '. 270 '" id="message" autocomplete="off" type="text"/>'. 271 '</div> '; 272 } 273 274 $Where = ''; 275 if (array_key_exists('name', $_SESSION) and ($_SESSION['name'] != '')) $Where .= ' AND (Name LIKE "%'.$this->Database->real_escape_string($_SESSION['name']).'%")'; 276 if (array_key_exists('location', $_SESSION) and ($_SESSION['location'] != '')) $Where .= ' AND (Location LIKE "%'.$this->Database->real_escape_string($_SESSION['location']).'%")'; 277 if (array_key_exists('message', $_SESSION) and ($_SESSION['message'] != '')) $Where .= ' AND (Message LIKE "%'.$this->Database->real_escape_string($_SESSION['message']).'%")'; 278 if (array_key_exists('vekod', $_SESSION) and ($_SESSION['vekod'] != '')) $Where .= ' AND (Age >= '.$this->Database->real_escape_string($_SESSION['vekod']).')'; 279 if (array_key_exists('vekdo', $_SESSION) and ($_SESSION['vekdo'] != '')) $Where .= ' AND (Age <= '.$this->Database->real_escape_string($_SESSION['vekdo']).')'; 280 if (array_key_exists('vyskaod', $_SESSION) and ($_SESSION['vyskaod'] != '')) $Where .= ' AND (Height >= '.$this->Database->real_escape_string($_SESSION['vyskaod']).')'; 281 if (array_key_exists('vyskado', $_SESSION) and ($_SESSION['vyskado'] != '')) $Where .= ' AND (Height <= '.$this->Database->real_escape_string($_SESSION['vyskado']).')'; 282 if (array_key_exists('vahaod', $_SESSION) and ($_SESSION['vahaod'] != '')) $Where .= ' AND (Weight >= '.$this->Database->real_escape_string($_SESSION['vahaod']).')'; 283 if (array_key_exists('vahado', $_SESSION) and ($_SESSION['vahado'] != '')) $Where .= ' AND (Weight <= '.$this->Database->real_escape_string($_SESSION['vahado']).')'; 284 if (array_key_exists('pohlavi', $_SESSION) and ($_SESSION['pohlavi'] != '')) $Where .= ' AND (Gender = '.$this->Database->real_escape_string($_SESSION['pohlavi']).')'; 285 if (substr($Where, 0, 4) == ' AND') $Where = substr($Where, 4); 286 if ($Where == '') $Where = '1'; 287 288 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `MeetItem` WHERE '.$Where); 289 $DbRow = $DbResult->fetch_row(); 290 $PageList = GetPageList($DbRow[0]); 291 292 $Gender = array('', 'Muž', 'Žena'); 293 $Output .= '<div id="list_content">'; 294 $Output .= $PageList['Output']; 295 $TableColumns = array( 296 array('Name' => 'Time', 'Title' => 'Čas'), 297 array('Name' => 'Name', 'Title' => 'Jméno'), 298 array('Name' => 'Height', 'Title' => 'Výška'), 299 array('Name' => 'Age', 'Title' => 'Věk'), 300 array('Name' => 'Weight', 'Title' => 'Váha'), 301 array('Name' => 'Location', 'Title' => 'Umístění'), 302 array('Name' => 'Gender', 'Title' => 'Pohlaví'), 303 array('Name' => 'Message', 'Title' => 'Zpráva'), 304 array('Name' => 'Source', 'Title' => 'Import'), 305 array('Name' => '', 'Title' => 'Detail'), 306 ); 307 $Order = GetOrderTableHeader($TableColumns, 'Time', 1); 308 $Output .= '<table class="WideTable">'; 309 $Output .= $Order['Output']; 310 $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '. 311 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', $Where.$Order['SQL'].$PageList['SQLLimit']); 312 while($MeetItem = $DbResult->fetch_assoc()) 313 { 314 $Output .= '<tr>'. 315 '<td>'.HumanDate(MysqlDateToTime($MeetItem['Time'])).'</td>'. 316 '<td>'.$MeetItem['Name'].'</td>'. 317 '<td>'.$MeetItem['Height'].'</td>'. 318 '<td>'.$MeetItem['Age'].'</td>'. 319 '<td>'.$MeetItem['Weight'].'</td>'. 320 '<td>'.$MeetItem['Location'].'</td>'. 321 //'<td>'.$MeetItem['Email'].'</td>'. 322 //'<td>'.$MeetItem['Phone'].'</td>'. 323 '<td>'.$Gender[$MeetItem['Gender']].'</td>'. 324 '<td>'.$MeetItem['Message'].'</td>'. 325 '<td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td>'. 326 '<td><a href="'.$this->Link('/seznamka/inzerat/'.$MeetItem['Id']).'">Ukázat</a></td>'; 327 $Output .= '</tr>'; 328 } 329 $Output .= '</table>'; 330 $Output .= $PageList['Output']; 331 $Output .= '</div>'; 332 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 333 { 334 } 335 else 336 { 337 $Output .= '<div><a href="'.$this->Link('/seznamka/rss/').'"><img src="'.$this->Link('/images/rss20.png').'" alt="rss20"/></a></div>'; 338 } 339 340 return($Output); 341 } 342 343 function ShowMeetItem() 344 { 345 $this->Title = 'Inzerát - Seznamka - '.$this->Title; 346 $Output = ''; 347 if(count($this->PathItems) > 2) 348 { 349 $id = $this->PathItems[2] * 1; 350 } else return 'Položka nenalezena'; 351 $Output .= '<div class="title">Inzerát</div>'; 352 $Gender = array('', 'Muž', 'Žena'); 353 $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '. 354 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', 'Id='.$id); 355 if ($DbResult->num_rows > 0) 356 { 357 $MeetItem = $DbResult->fetch_assoc(); 358 if ($MeetItem['Link'] != '') $Link = '<a href="'.$MeetItem['Link'].'">Odkaz</a>'; 359 else $Link = ''; 360 $Output .= '<table class="ItemTable">'. 361 '<tr><th>Čas</th><td>'.HumanDate(MysqlDateToTime($MeetItem['Time'])).'</td></tr>'. 362 '<tr><th>Pohlaví</th><td>'.$Gender[$MeetItem['Gender']].'</td></tr>'. 363 '<tr><th>Jméno</th><td>'.$MeetItem['Name'].'</td></tr>'. 364 '<tr><th>Výška</th><td>'.$MeetItem['Height'].'</td></tr>'. 365 '<tr><th>Věk</th><td>'.$MeetItem['Age'].'</td></tr>'. 366 '<tr><th>Váha</th><td>'.$MeetItem['Weight'].'</td></tr>'. 367 '<tr><th>Umístění</th><td>'.$MeetItem['Location'].'</td></tr>'. 368 '<tr><th>Email</th><td>'.$MeetItem['Email'].'</td></tr>'. 369 '<tr><th>Telefón</th><td>'.$MeetItem['Phone'].'</td></tr>'. 370 '<tr><th>Zpráva</th><td>'.$MeetItem['Message'].'</td></tr>'. 371 '<tr><th>Původní web</th><td>'.$Link.'</td></tr>'. 372 '<tr><th>Zdroj importu</th><td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td></tr>'; 373 $Output .= '</table>'; 374 } else $Output .= 'Položka nenalezena'; 375 return $Output; 376 } 377 378 function ShowMeetListRss() 379 { 380 global $Config; 381 382 $this->NoFullPage = true; 383 $RSS = new RSS(); 384 $RSS->Title = 'Taneční seznamka'; 385 $RSS->Description = ''; 386 $RSS->Link = $this->AbsoluteLink('/seznamka/'); 387 388 $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '. 389 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', '1 ORDER BY `Time` DESC LIMIT 30'); 390 while($MeetItem = $DbResult->fetch_assoc()) 391 { 392 $Title = $MeetItem['Name']; 393 if ($MeetItem['Age'] != '') $Title .= ', '.$MeetItem['Age'].' let'; 394 if ($MeetItem['Weight'] != '') $Title .= ', '.$MeetItem['Height'].' cm'; 395 if ($MeetItem['Location'] != '') $Title .= ', '.$MeetItem['Location']; 396 $Description = $MeetItem['Message']."<br/>\n"; 397 if ($MeetItem['Email'] != '') $Description .= '<br/>Email: '.$MeetItem['Email']; 398 if ($MeetItem['Phone'] != '') $Description .= '<br/>Telefon: '.$MeetItem['Phone']; 399 if ($MeetItem['Age'] != '') $Description .= '<br/>Věk: '.$MeetItem['Age'].' let'; 400 if ($MeetItem['Height'] != '') $Description .= '<br/>Výška: '.$MeetItem['Height'].' cm'; 401 if ($MeetItem['Weight'] != '') $Description .= '<br/>Váha: '.$MeetItem['Weight'].' kg'; 402 $Description .= '<br/>Zdroj importu: <a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a>'; 403 $Time = MysqlDateTimeToTime($MeetItem['Time']); 404 $TimeImport = MysqlDateTimeToTime($MeetItem['TimeImport']); 405 // Append time part of TimeImport time to item time so new items will appear in correct time order even if item doesn't have time part specified 406 if (TimeToMysqlTime($Time) == '00:00:00') 407 { 408 $Time = MysqlDateTimeToTime(TimeToMysqlDate($Time).' '.TimeToMysqlTime($TimeImport)); 409 } 410 $RSS->Items[] = array( 411 'Title' => $Title, 412 'Description' => $Description, 413 'Time' => $Time, 414 'Link' => $this->AbsoluteLink('/seznamka/inzerat/'.$MeetItem['Id'].'/'), 415 ); 416 } 417 418 return $RSS->Generate(); 419 } 420 421 function ShowPage($Content) 72 73 function GetOutput($Content) 422 74 { 423 75 global $Config; … … 429 81 '<link rel="stylesheet" href="'.$this->Link('/style.css').'" type="text/css" media="all" />'. 430 82 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Config['Encoding'].'" />'. 431 '<meta name="viewport" content="width=device-width, initial-scale=1">'.432 83 '<script type="text/javascript" src="'.$this->Link('/jquery.js').'"></script>'; 433 84 $Output .= '<link rel="alternate" title="Taneční seznamka" href="'. … … 440 91 $Output .= '</body></html>'; 441 92 return($Output); 442 } 443 444 function ShowRobots() 445 { 446 $this->NoFullPage = true; 93 } 94 95 function RegisterPage($Path, $Handler) 96 { 97 if(is_array($Path)) 98 { 99 $Page = &$this->Pages; 100 $LastKey = array_pop($Path); 101 foreach($Path as $PathItem) 102 { 103 $Page = &$Page[$PathItem]; 104 } 105 if(!is_array($Page)) $Page = array('' => $Page); 106 $Page[$LastKey] = $Handler; 107 } else $this->Pages[$Path] = $Handler; 108 } 109 110 function RegisterMenuItem($Link, $Title) 111 { 112 $this->MainMenu[] = array('Link' => $Link, 'Title' => $Title); 113 } 114 115 function RegisterPageHeader($Name, $Callback) 116 { 117 $this->PageHeaders[$Name] = $Callback; 118 } 119 120 function RegisterPageBar($Name) 121 { 122 $this->Bars[$Name] = array(); 123 } 124 125 function UnregisterPageBar($Name) 126 { 127 unset($this->Bars[$Name]); 128 } 129 130 function SearchPage($PathItems, $Pages) 131 { 132 if(count($PathItems) > 0) $PathItem = $PathItems[0]; 133 else $PathItem = ''; 134 if(array_key_exists($PathItem, $Pages)) 135 { 136 if(is_array($Pages[$PathItem])) 137 { 138 array_shift($PathItems); 139 return($this->SearchPage($PathItems, $Pages[$PathItem])); 140 } else return($Pages[$PathItem]); 141 } else return(''); 142 } 143 144 function PageNotFound() 145 { 146 return('Page '.implode('/', $this->PathItems).' not found.'); 147 } 148 149 function ShowPage() 150 { 151 $this->BaseView = new BaseView($this); 152 153 /* @var $Page Page */ 154 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 155 if($ClassName != '') 156 { 157 $Page = new $ClassName($this); 158 } else { 159 $Page = new PageMissing($this); 160 } 161 echo($this->BaseView->GetOutput($Page)); 162 } 163 164 function Run() 165 { 166 $this->RunCommon(); 167 if($this->ShowPage) 168 { 169 $this->PathItems = ProcessURL(); 170 $this->ShowPage(); 171 } 172 } 173 174 function RunCommon() 175 { 176 global $Config; 177 178 $this->Config = $Config; 179 $this->Database = new Database(); 180 $this->Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'], 181 $this->Config['Database']['Password'], $this->Config['Database']['Database']); 182 $this->Database->Prefix = $this->Config['Database']['Prefix']; 183 $this->Database->charset($this->Config['Database']['Charset']); 184 $this->Database->ShowSQLError = false; 185 $this->Database->ShowSQLQuery = false; 186 $this->PathItems = $this->ProcessURL(); 187 188 $this->RegisterPageBar('Top'); 189 $this->Title = 'Tanec'; 190 $Output = ''; 191 } 192 } 193 194 class PageMissing extends Page 195 { 196 var $FullTitle = 'Stránka nenalezena'; 197 var $ShortTitle = 'Stránka nenalezena'; 198 199 function __construct($System) 200 { 201 parent::__construct($System); 202 $this->ParentClass = 'PagePortal'; 203 } 204 205 function Show() 206 { 207 Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); 208 return('<h3 align="center">Požadovaná stránka neexistuje.</h3>'); 209 } 210 } 211 212 class PageRobots extends Page 213 { 214 function __construct($System) 215 { 216 parent::__construct($System); 217 } 218 219 function Show() 220 { 221 $this->ClearPage = true; 447 222 $Result = 'User-agent: *'."\n". 448 'Disallow: /*? *'."\n".449 'Sitemap: '.$this-> AbsoluteLink('/sitemap.xml');223 'Disallow: /*?'."\n". 224 'Sitemap: '.$this->System->AbsoluteLink('/sitemap.xml'); 450 225 return($Result); 451 226 } 452 453 function ShowSiteMap() 454 { 455 $this->NoFullPage = true; 227 } 228 229 class PageSiteMap extends Page 230 { 231 function Show() 232 { 233 $this->ClearPage = true; 456 234 $Urls = array( 457 235 '/seznamka/', … … 465 243 { 466 244 $Result .= '<url>'."\n". 467 ' <loc>'.$this-> AbsoluteLink($Url).'</loc>'."\n".245 ' <loc>'.$this->System->AbsoluteLink($Url).'</loc>'."\n". 468 246 //'<lastmod>'..'</lastmod>'."\n". 469 247 '</url>'."\n"; … … 476 254 $Time = MysqlDateTimeToTime($DbRow['Time']); 477 255 $Result .= '<url>'."\n". 478 ' <loc>'.$this-> AbsoluteLink($Url).'</loc>'."\n".256 ' <loc>'.$this->System->AbsoluteLink($Url).'</loc>'."\n". 479 257 ' <lastmod>'.date('c', $Time).'</lastmod>'."\n". 480 258 '</url>'."\n"; … … 484 262 return($Result); 485 263 } 486 487 function Run() 488 { 489 global $Config; 490 491 $this->Config = $Config; 492 $this->Database = new Database(); 493 $this->Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'], 494 $this->Config['Database']['Password'], $this->Config['Database']['Database']); 495 $this->Database->Prefix = $this->Config['Database']['Prefix']; 496 $this->Database->charset($this->Config['Database']['Charset']); 497 $this->Database->ShowSQLError = false; 498 $this->Database->ShowSQLQuery = false; 499 $this->PathItems = $this->ProcessURL(); 500 501 $this->Title = 'Tanec'; 502 $Output = ''; 503 504 if(count($this->PathItems) > 0) 505 { 506 if($this->PathItems[0] == 'robots.txt') $Output .= $this->ShowRobots(); 507 else if($this->PathItems[0] == 'sitemap.xml') $Output .= $this->ShowSiteMap(); 508 else if($this->PathItems[0] == 'skoly') $Output .= $this->ShowSchoolList(); 509 else if($this->PathItems[0] == 'tance') $Output .= $this->ShowDanceList(); 510 else if($this->PathItems[0] == 'filmy') $Output .= $this->ShowMovieList(); 511 else if($this->PathItems[0] == 'seznamka') { 512 if(count($this->PathItems) > 1) 513 { 514 if($this->PathItems[1] == 'rss') $Output .= $this->ShowMeetListRss(); 515 else if($this->PathItems[1] == 'aktualizace') $Output .= $this->ShowMeetUpdate(); 516 else if($this->PathItems[1] == 'inzerat') $Output .= $this->ShowMeetItem(); 517 } else $Output .= $this->ShowMeetList(); 518 } 519 else $Output .= $this->ShowDanceList(); 520 } else $Output .= $this->ShowDanceList(); 521 if (!$this->NoFullPage) 522 { 523 $Output = $this->ShowMenu().$Output; 524 echo($this->ShowPage($Output)); 525 } else echo($Output); 526 } 527 } 528 529 $Application = new MyApplication(); 264 } 265 266 267 $Revision = 36; // Subversion revision 268 $DatabaseRevision = 36; // SQL structure revision 269 $ReleaseTime = strtotime('2019-05-05'); 270 271 $Application = new ApplicationTanec(); 272 $Application->ModuleManager->LoadModulesFromDir(dirname(__FILE__).'/Modules'); 273 $Application->Modules = $Application->ModuleManager->Modules; 274 $Application->ModuleManager->InstallAll(); 275 $Application->ModuleManager->StartAll(); 276 $Application->RegisterPage('', 'PageDanceList'); 277 $Application->RegisterPage('robots.txt', 'PageRobots'); 278 $Application->RegisterPage('sitemap.xml', 'PageSiteMap'); 530 279 $Application->Run();
Note:
See TracChangeset
for help on using the changeset viewer.