Changeset 4
Legend:
- Unmodified
- Added
- Removed
-
trunk/Meet.php
r3 r4 148 148 $Result = GetNumberBeforeText($Text, 'let'); 149 149 if ($Result == '') $Result = GetNumberAfterText($Text, 'Je mi'); 150 if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[0]; 150 151 return $Result; 151 152 } … … 155 156 $Result = GetNumberBeforeText($Text, 'cm'); 156 157 if ($Result == '') $Result = GetNumberBeforeText($Text, 'bez podpatků'); 158 if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[1]; 157 159 return $Result; 158 160 } … … 161 163 { 162 164 $Result = GetNumberBeforeText($Text, 'kg'); 165 if ($Result == '') $Result = GetAgeHeightWeightFromText($Text)[2]; 166 return $Result; 167 } 168 169 function GetAgeHeightWeightFromText($Text) 170 { 171 $Result = array('', '', ''); 172 $Pattern = '/[0-9]+\/[0-9]+\/[0-9]+/i'; 173 if (preg_match_all($Pattern, $Text, $Matches)) 174 { 175 $Result = explode('/', $Matches[0][0]); 176 } else 177 { 178 $Pattern = '/[0-9]+\/[0-9]+/i'; 179 if (preg_match_all($Pattern, $Text, $Matches)) 180 { 181 $Result = explode('/', $Matches[0][0]); 182 $Result[] = ''; 183 } 184 } 163 185 return $Result; 164 186 } … … 282 304 if (strpos($MeetItem->Date, 'dnes v') !== false) 283 305 $MeetItem->Date = str_replace('dnes v', HumanDate(time()), $MeetItem->Date); 306 if (strpos($MeetItem->Date, 'včera v') !== false) 307 $MeetItem->Date = str_replace('včera v', HumanDate(strtotime('-1 day', time())), $MeetItem->Date); 284 308 $MeetItem->Date = HumanDateTimeToTime($MeetItem->Date); 285 309 $MeetItem->Name = trim(GetTextBetween($Item, '<div class="comment-name">', '</div>')); … … 293 317 $MeetItem->Database = $this->Database; 294 318 $MeetItem->Source = $this->Id; 319 //print_r($MeetItem); 295 320 $MeetItem->AddIfNotExist(); 296 321 } … … 338 363 function ParseHes() 339 364 { 365 $HeightRange = array( 366 '< 120 cm' => 120, 367 '120 cm - 130 cm' => 125, 368 '125 cm - 135 cm' => 130, 369 '130 cm - 140 cm' => 135, 370 '135 cm - 145 cm' => 140, 371 '140 cm - 150 cm' => 145, 372 '145 cm - 155 cm' => 150, 373 '150 cm - 160 cm' => 155, 374 '155 cm - 165 cm' => 160, 375 '160 cm - 170 cm' => 165, 376 '165 cm - 175 cm' => 170, 377 '170 cm - 180 cm' => 175, 378 '175 cm - 185 cm' => 180, 379 '180 cm - 190 cm' => 185, 380 '185 cm - 195 cm' => 190, 381 '190 cm - 200 cm' => 195, 382 '195 cm - 205 cm' => 200, 383 '200 cm <' => 205, 384 ); 385 340 386 echo('Parsing '.$this->Name.'...</br>'); 341 387 $Content = file_get_contents($this->URL); … … 358 404 if ($Item != '') 359 405 { 360 $MeetItem = new MeetItem(); 361 $MeetItem->Date = HumanDateToTime(trim(GetTextBetween($Item, '<h3>', '</h3>'))); 362 if ($MeetItem->Date != null) 363 { 364 $PreviousTime = $MeetItem->Date; 365 } else $MeetItem->Date = $PreviousTime; 366 367 $Part = GetTextBetween($Item, '</strong>', '<strong>'); 368 $Part = explode(',', $Part); 369 if (count($Part) > 0) $MeetItem->Name = trim($Part[0]); 370 if (count($Part) > 1) $MeetItem->Height = trim($Part[1]); 371 if (strpos($MeetItem->Height, '(') !== false) 372 { 373 $MeetItem->Age = substr($MeetItem->Height, strpos($MeetItem->Height, '(') + 1); 374 $MeetItem->Age = substr($MeetItem->Age, 0, strpos($MeetItem->Age, ')')); 375 $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age)); 376 $MeetItem->Height = substr($MeetItem->Height, 0, strpos($MeetItem->Height, '(')); 377 } else $MeetItem->Age = ''; 378 $MeetItem->Weight = GetWeightFromText($MeetItem->Message); 379 $MeetItem->Email = trim(GetTextBetween($Item, '">', '</a>')); 380 $MeetItem->Phone = trim(GetTextBetween($Item, 'tel.:', '<br />')); 381 $Gender = trim(GetTextBetween($Item, '</strong>', '<strong>')); 382 if ($Gender == 'partnera,') $MeetItem->Gender = Gender::Female; 383 else if ($Gender == 'partnerku,') $MeetItem->Gender = Gender::Male; 384 else $MeetItem->Gender = Gender::Undefined; 385 $MeetItem->Message = trim(GetTextBetween($Item, '<p class="message">', '</p>')); 386 $MessageAge = GetAgeFromText($MeetItem->Message); 387 if ($MessageAge != '') $MeetItem->Age = $MessageAge; 388 $MessageHeight = GetHeightFromText($MeetItem->Message); 389 if ($MessageHeight != '') $MeetItem->Height = $MessageHeight; 390 $MeetItem->Database = $this->Database; 391 $MeetItem->Source = $this->Id; 392 $MeetItem->AddIfNotExist(); 406 $MeetItem = new MeetItem(); 407 $MeetItem->Date = HumanDateToTime(trim(GetTextBetween($Item, '<h3>', '</h3>'))); 408 if ($MeetItem->Date != null) 409 { 410 $PreviousTime = $MeetItem->Date; 411 } else $MeetItem->Date = $PreviousTime; 412 413 $Part = GetTextBetween($Item, '</strong>', '<strong>'); 414 $Part = explode(',', $Part); 415 if (count($Part) > 0) $MeetItem->Name = trim($Part[0]); 416 if (count($Part) > 1) $MeetItem->Height = trim($Part[1]); 417 if (strpos($MeetItem->Height, '(') !== false) 418 { 419 $MeetItem->Age = substr($MeetItem->Height, strpos($MeetItem->Height, '(') + 1); 420 $MeetItem->Age = substr($MeetItem->Age, 0, strpos($MeetItem->Age, ')')); 421 $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age)); 422 $MeetItem->Height = trim(substr($MeetItem->Height, 0, strpos($MeetItem->Height, '('))); 423 } else $MeetItem->Age = ''; 424 while (strpos($MeetItem->Height, ' ') !== false) 425 { 426 $MeetItem->Height = str_replace(' ', ' ', $MeetItem->Height); 427 } 428 if (array_key_exists($MeetItem->Height, $HeightRange)) 429 $MeetItem->Height = $HeightRange[$MeetItem->Height]; 430 $MeetItem->Weight = GetWeightFromText($MeetItem->Message); 431 $MeetItem->Email = trim(GetTextBetween($Item, '">', '</a>')); 432 $MeetItem->Phone = trim(GetTextBetween($Item, 'tel.:', '<br />')); 433 $Gender = trim(GetTextBetween($Item, '</strong>', '<strong>')); 434 if ($Gender == 'partnera,') $MeetItem->Gender = Gender::Female; 435 else if ($Gender == 'partnerku,') $MeetItem->Gender = Gender::Male; 436 else $MeetItem->Gender = Gender::Undefined; 437 $MeetItem->Message = trim(GetTextBetween($Item, '<p class="message">', '</p>')); 438 $MessageAge = GetAgeFromText($MeetItem->Message); 439 if ($MessageAge != '') $MeetItem->Age = $MessageAge; 440 $MessageHeight = GetHeightFromText($MeetItem->Message); 441 if ($MessageHeight != '') $MeetItem->Height = $MessageHeight; 442 $MeetItem->Database = $this->Database; 443 $MeetItem->Source = $this->Id; 444 $MeetItem->AddIfNotExist(); 393 445 } 394 446 } -
trunk/index.php
r3 r4 4 4 include_once('Config.php'); 5 5 include_once('Meet.php'); 6 include_once('RSS.php'); 7 include_once('Global.php'); 6 8 7 9 session_start(); 8 10 9 function HumanDate($Time)10 {11 return(date('j.n.Y', $Time));12 }13 14 11 class Application 15 12 { 13 var $NoFullPage = false; 14 16 15 function Link($URL) 17 16 { … … 69 68 $Output .= '<th>'.$ResourceGroup['Name'].'</th>'; 70 69 } 71 $Output .= '</tr>'; 70 $Output .= '</tr>'; 72 71 $DbResult = $this->Database->select('Dance', '*, (SELECT Name FROM DanceGroup WHERE DanceGroup.Id=Dance.Group) AS GroupName', '1 ORDER BY `Name`'); 73 72 while($Dance = $DbResult->fetch_assoc()) … … 118 117 function ShowMeetList() 119 118 { 119 $Output = ''; 120 //print_r($_GET); 120 121 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 121 122 { … … 125 126 if (array_key_exists('vyskaod', $_GET) ) $_SESSION['vyskaod'] = $_GET['vyskaod']; 126 127 if (array_key_exists('vyskado', $_GET) ) $_SESSION['vyskado'] = $_GET['vyskado']; 128 if (array_key_exists('vahaod', $_GET) ) $_SESSION['vahaod'] = $_GET['vahaod']; 129 if (array_key_exists('vahado', $_GET) ) $_SESSION['vahado'] = $_GET['vahado']; 130 if (array_key_exists('pohlavi', $_GET) ) { 131 if ($_GET['pohlavi'] > 0) $_SESSION['pohlavi'] = $_GET['pohlavi']; 132 else unset($_SESSION['pohlavi']); 133 } 127 134 } else { 128 $Output = '';129 135 $Output .= '<script>function reloadlist(){ $(\'#meetlist\').load(document.URL + \' #meetlist\');}'. 130 136 ' var load_timer = 100; … … 143 149 } 144 150 145 var cf = { pohlavi:\'2\'};151 var cf = {}; 146 152 147 153 function setupc(key,val){ … … 150 156 var ccv = $(\'#\'+key).val(); 151 157 if(ccv!=val) $(\'#\'+key).val(val==0?\'\':val); 158 } 159 if(key==\'pohlavi\') { 160 $(\'.c\'+key).removeClass(\'active\'); 161 $(\'#\'+key+val).addClass(\'active\'); 152 162 } 153 163 } … … 167 177 }'. 168 178 '</script>'; 179 $Output .= '<h4 style="text-align: center;">Inzeráty:</h4>'; 180 $Output .= '<div class="btn-group ma3">'. 181 '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',0)" id="pohlavi0" data-toggle="tooltip" '. 182 'data-placement="top" title="Obě pohlaví"><span class="icon-both"></span></button>'. 183 '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',1)" id="pohlavi1" data-toggle="tooltip" '. 184 'data-placement="top" title="Jen muži"><span class="icon-man"></span></button>'. 185 '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',2)" id="pohlavi2" data-toggle="tooltip" '. 186 'data-placement="top" title="Jen ženy"><span class="icon-woman"></span></button>'. 187 '</div>'; 169 188 $Output .= '<div class="filter-num-box">'. 170 189 '<div class="label-box">Věk</div>'. 171 '<input value=" " onkeyup="if(event.keyCode!=9) upf(\'vekod\',$(this).val(),(event.keyCode==13?0:1)); '.190 '<input value="'.$_SESSION['vekod'].'" onkeyup="if(event.keyCode!=9) upf(\'vekod\',$(this).val(),(event.keyCode==13?0:1)); '. 172 191 '" id="vekod" autocomplete="off" type="text">'. 173 192 '<div class="label-box">-</div>'. 174 '<input value=" " onkeyup="'.193 '<input value="'.$_SESSION['vekdo'].'" onkeyup="'. 175 194 'if(event.keyCode!=9) upf(\'vekdo\',$(this).val(),(event.keyCode==13?0:1));" '. 176 195 'id="vekdo" autocomplete="off" type="text"><div class="label-box">let</div></div>'. 177 '</div> ' .178 196 '</div> '; 197 $Output .= '<div class="filter-num-box">'. 179 198 '<div class="label-box">Výška</div>'. 180 '<input value=" " onkeyup="if(event.keyCode!=9) upf(\'vyskaod\',$(this).val(),(event.keyCode==13?0:1)); '.199 '<input value="'.$_SESSION['vyskaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vyskaod\',$(this).val(),(event.keyCode==13?0:1)); '. 181 200 '" id="vyskaod" autocomplete="off" type="text">'. 182 201 '<div class="label-box">-</div>'. 183 '<input value=" " onkeyup="'.202 '<input value="'.$_SESSION['vyskado'].'" onkeyup="'. 184 203 'if(event.keyCode!=9) upf(\'vyskado\',$(this).val(),(event.keyCode==13?0:1));" '. 185 204 'id="vyskado" autocomplete="off" type="text"><div class="label-box">cm</div></div>'. 205 '</div> '; 206 $Output .= '<div class="filter-num-box">'. 207 '<div class="label-box">Váha</div>'. 208 '<input value="'.$_SESSION['vahaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vahaod\',$(this).val(),(event.keyCode==13?0:1)); '. 209 '" id="vahaod" autocomplete="off" type="text">'. 210 '<div class="label-box">-</div>'. 211 '<input value="'.$_SESSION['vahado'].'" onkeyup="'. 212 'if(event.keyCode!=9) upf(\'vahado\',$(this).val(),(event.keyCode==13?0:1));" '. 213 'id="vahado" autocomplete="off" type="text"><div class="label-box">cm</div></div>'. 186 214 '</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>'; 215 } 216 205 217 $Where = ''; 206 218 if (array_key_exists('vekod', $_SESSION) and ($_SESSION['vekod'] != '')) $Where .= ' AND (Age >= '.$_SESSION['vekod'].')'; … … 208 220 if (array_key_exists('vyskaod', $_SESSION) and ($_SESSION['vyskaod'] != '')) $Where .= ' AND (Height >= '.$_SESSION['vyskaod'].')'; 209 221 if (array_key_exists('vyskado', $_SESSION) and ($_SESSION['vyskado'] != '')) $Where .= ' AND (Height <= '.$_SESSION['vyskado'].')'; 222 if (array_key_exists('vahaod', $_SESSION) and ($_SESSION['vahaod'] != '')) $Where .= ' AND (Weight >= '.$_SESSION['vahaod'].')'; 223 if (array_key_exists('vahado', $_SESSION) and ($_SESSION['vahado'] != '')) $Where .= ' AND (Weight <= '.$_SESSION['vahado'].')'; 224 if (array_key_exists('pohlavi', $_SESSION) and ($_SESSION['pohlavi'] != '')) $Where .= ' AND (Gender = '.$_SESSION['pohlavi'].')'; 210 225 if (substr($Where, 0, 4) == ' AND') $Where = substr($Where, 4); 211 if ($Where == '') $Where = '1'; 226 if ($Where == '') $Where = '1'; 227 228 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `MeetItem` WHERE '.$Where); 229 $DbRow = $DbResult->fetch_row(); 230 $PageList = GetPageList($DbRow[0]); 231 232 $Gender = array('', 'Muž', 'Žena'); 233 $Output .= '<div id="list_content">'; 234 $Output .= $PageList['Output']; 235 $TableColumns = array( 236 array('Name' => 'Date', 'Title' => 'Datum'), 237 array('Name' => 'Name', 'Title' => 'Jméno'), 238 array('Name' => 'Height', 'Title' => 'Výška'), 239 array('Name' => 'Age', 'Title' => 'Věk'), 240 array('Name' => 'Weight', 'Title' => 'Váha'), 241 array('Name' => 'Gender', 'Title' => 'Pohlaví'), 242 array('Name' => 'Message', 'Title' => 'Zpráva'), 243 array('Name' => 'Source', 'Title' => 'Zdroj'), 244 ); 245 $Order = GetOrderTableHeader($TableColumns, 'Date', 1); 246 $Output .= '<table class="WideTable">'; 247 $Output .= $Order['Output']; 212 248 $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');249 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', $Where.$Order['SQL'].$PageList['SQLLimit']); 214 250 while($MeetItem = $DbResult->fetch_assoc()) 215 251 { … … 227 263 $Output .= '</tr>'; 228 264 } 229 $Output .= '</table></div>'; 230 231 return($Output); 265 $Output .= '</table>'; 266 $Output .= $PageList['Output']; 267 $Output .= '</div>'; 268 269 return($Output); 270 } 271 272 function ShowMeetListRss() 273 { 274 global $Config; 275 276 $this->NoFullPage = true; 277 $RSS = new RSS(); 278 $RSS->Title = 'Taneční seznamka'; 279 $RSS->Description = ''; 280 $RSS->Link = $Config['BaseURL'].'seznamka'; 281 282 $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '. 283 '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', '1 ORDER BY `Date` DESC LIMIT 30'); 284 while($MeetItem = $DbResult->fetch_assoc()) 285 { 286 $Title = $MeetItem['Name']; 287 if ($MeetItem['Age'] != '') $Title .= ', '.$MeetItem['Age'].' let'; 288 if ($MeetItem['Weight'] != '') $Title .= ', '.$MeetItem['Height'].' cm'; 289 $Description = $MeetItem['Message']; 290 if ($MeetItem['Email'] != '') $Description .= '<br/>Email: '.$MeetItem['Email']; 291 if ($MeetItem['Phone'] != '') $Description .= '<br/>Telefon: '.$MeetItem['Phone']; 292 $Description .= '<br/>Škola: <a href="'.$this->Link($MeetItem['SourceURL']).'">'.$MeetItem['SourceName'].'</a>'; 293 $RSS->Items[] = array( 294 'Title' => $Title, 295 'Description' => $Description, 296 'Time' => MysqlDateTimeToTime($MeetItem['Date']), 297 'Link' => $Config['BaseURL'].'seznamka', 298 ); 299 $Output .= '<tr>'. 300 '<td>'.HumanDate(MysqlDateToTime($MeetItem['Date'])).'</td>'. 301 '<td>'.$MeetItem['Name'].'</td>'. 302 '<td>'.$MeetItem['Height'].'</td>'. 303 '<td>'.$MeetItem['Age'].'</td>'. 304 '<td>'.$MeetItem['Weight'].'</td>'. 305 //'<td>'.$MeetItem['Email'].'</td>'. 306 //'<td>'.$MeetItem['Phone'].'</td>'. 307 '<td>'.$Gender[$MeetItem['Gender']].'</td>'. 308 '<td>'.$MeetItem['Message'].'</td>'. 309 '<td></td>'; 310 $Output .= '</tr>'; 311 } 312 313 return $RSS->Generate(); 232 314 } 233 315 … … 240 322 '<link rel="stylesheet" href="'.$this->Link('/style.css').'" type="text/css" media="all" />'. 241 323 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Config['Encoding'].'" />'. 242 '<script src="jquery.js"></script>'. 243 '<title>Tance</title>'. 324 '<script src="jquery.js"></script>'; 325 $Output .= '<link rel="alternate" title="Taneční seznamka" href="'. 326 $this->Config['BaseURL'].'seznamka-rss" type="application/rss+xml" />'; 327 $Output .= '<title>Tance</title>'. 244 328 '</head><body>'; 245 329 $Output .= $Content; … … 266 350 else if($this->PathItems[0] == 'tance') $Output .= $this->ShowDanceList(); 267 351 else if($this->PathItems[0] == 'seznamka') $Output .= $this->ShowMeetList(); 352 else if($this->PathItems[0] == 'seznamka-rss') $Output .= $this->ShowMeetListRss(); 268 353 else if($this->PathItems[0] == 'seznamka-aktualizace') $Output .= $this->ShowMeetUpdate(); 269 354 else $Output .= $this->ShowDanceList(); -
trunk/style.css
r3 r4 1 body,td{font-size:14px;font-family:Arial} 2 1 3 .WideTable 2 4 { … … 48 50 .filter-num-box div.dropdown .btn{background:#fff;margin:0;border:0;padding:0 8px;line-height:28px;font-size:13px;border-radius: 0} 49 51 .filter-num-box div.dropdown-menu a.dropdown-item{line-height:20px;font-size:13px} 52 53 .icon-both:before { 54 content: "Obě"; 55 color: black; 56 } 57 .icon-woman:before { 58 content: "Ženy"; 59 color: black; 60 } 61 .icon-man:before { 62 content: "Muži"; 63 color: black; 64 }
Note:
See TracChangeset
for help on using the changeset viewer.