Changeset 3 for trunk/index.php


Ignore:
Timestamp:
Aug 4, 2018, 10:03:34 PM (6 years ago)
Author:
chronos
Message:
  • Added: Parse meet items from 4 webs.
  • Added: Allow filtering by age and height using jquery.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r2 r3  
    44include_once('Config.php');
    55include_once('Meet.php');
     6
     7session_start();
    68
    79function HumanDate($Time)
     
    107109  }
    108110
     111  function ShowMeetUpdate()
     112  {
     113    $MeetSources = new MeetSources();
     114    $MeetSources->Database = $this->Database;
     115    $MeetSources->ParseAll();
     116  }
     117 
    109118  function ShowMeetList()
    110119  {
    111     $Meet = new Meet();
    112     $Meet->Id = 1;
    113     $Meet->URL = 'https://www.tanecniskola.cz/seznamka/';
    114     $Meet->Database = $this->Database;
    115     $Meet->Parse();
     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    }
    116189   
    117     $Gender = array('Muž', 'Žena');
    118    
    119     $Output = '<h4 style="text-align: center;">Inzeráty:</h4>';
    120     $Output .= '<table class="WideTable">';
    121     $Output .= '<tr><th>Datum</th><th>Jméno</th><th>Výška</th><th>Věk</th><th>Email</th><th>Telefon</th><th>Pohlaví</th><th>Zpráva</th><th>Zdroj</th>';
     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>';
    122204    $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';
    123212    $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
    124       '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', '1 ORDER BY `Date` DESC');
     213      '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', $Where.' ORDER BY `Date` DESC');
    125214    while($MeetItem = $DbResult->fetch_assoc())
    126215    {
     
    130219        '<td>'.$MeetItem['Height'].'</td>'.
    131220        '<td>'.$MeetItem['Age'].'</td>'.
    132         '<td>'.$MeetItem['Email'].'</td>'.
    133         '<td>'.$MeetItem['Phone'].'</td>'.
     221        '<td>'.$MeetItem['Weight'].'</td>'.
     222        //'<td>'.$MeetItem['Email'].'</td>'.
     223        //'<td>'.$MeetItem['Phone'].'</td>'.
    134224        '<td>'.$Gender[$MeetItem['Gender']].'</td>'.
    135225        '<td>'.$MeetItem['Message'].'</td>'.
     
    137227      $Output .= '</tr>';
    138228    }
    139     $Output .= '</table>';   
     229    $Output .= '</table></div>';
    140230
    141231    return($Output);
     
    147237      '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
    148238      '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'.
    149       '<head><link rel="stylesheet" href="'.$this->Link('/style.css').'" type="text/css" media="all" />'.
     239      '<head>'.
     240      '<link rel="stylesheet" href="'.$this->Link('/style.css').'" type="text/css" media="all" />'.
    150241      '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Config['Encoding'].'" />'.
    151        '<title>Tance</title>'.
     242      '<script src="jquery.js"></script>'.
     243      '<title>Tance</title>'.
    152244      '</head><body>';
    153245    $Output .= $Content;
     
    168260    $this->PathItems = $this->ProcessURL();
    169261
    170     $Output = '';
    171     $Output .= $this->ShowMenu();
     262    $Output = '';   
    172263
    173264    if(count($this->PathItems) > 0) {
     
    175266      else if($this->PathItems[0] == 'tance') $Output .= $this->ShowDanceList();
    176267      else if($this->PathItems[0] == 'seznamka') $Output .= $this->ShowMeetList();
     268      else if($this->PathItems[0] == 'seznamka-aktualizace') $Output .= $this->ShowMeetUpdate();
    177269      else $Output .= $this->ShowDanceList();
    178270    } else $Output .= $this->ShowDanceList();
    179     echo($this->ShowPage($Output));
     271    if (!$this->NoFullPage) {
     272      $Output = $this->ShowMenu().$Output;
     273      echo($this->ShowPage($Output));
     274    } else echo($Output);
    180275  }
    181276}
Note: See TracChangeset for help on using the changeset viewer.