source: trunk/Modules/Meet/Import/MajkluvSvet.php

Last change on this file was 65, checked in by chronos, 3 years ago
  • Added: Meet items import from La Tropcial school.
  • Modified: Use explicit types for class fields.
  • Modified: Use utf8mb4 encoding for database.
  • Fixed: Spam items checking was inverted.
File size: 2.5 KB
Line 
1<?php
2
3class MeetSourceMajkluvSvet extends MeetSource
4{
5 function Import(): string
6 {
7 $Output = parent::Import();
8 $Content = file_get_contents($this->URL);
9
10 $BlockStart = "<th class='head_seznamka'>";
11 $BlockEnd = 'Celkem takových inzerátu:';
12 $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
13 if ($Content == '')
14 {
15 $Output .= 'Main block not isolated.</br>';
16 return $Output;
17 }
18
19 $ItemStart = "<tr class='click_row'";
20 $ItemEnd = "<div class='seznamka_spodek'></div>";
21 while (strpos($Content, $ItemStart) !== false)
22 {
23 $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
24 $MeetItem = new MeetItem();
25
26 $Gender = trim(GetTextBetween($Item, "<td class='bunka_seznamka linel' width='45' ><img src='/pages/images/", '.gif'));
27 if ($Gender == 'zena') $MeetItem->Gender = Gender::Male;
28 else $Gender = Gender::Female;
29 $MeetItem->Name = trim(GetTextBetween($Item, "<span class='seznamka_nadpis'><b>", '</b>'));
30 $MeetItem->Height = trim(GetTextBetween($Item, "výška:", 'cm'));
31 $MeetItem->Age = preg_replace("/[^0-9]/", "", trim(GetTextBetween($Item, "věk:", 'let')));
32 $MeetItem->Message = trim(GetTextBetween($Item, "display:block;text-align:justify;'>", '</span>'));
33 $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
34 $MeetItem->Location = trim(GetTextBetween($Item, "Lokalita:</b>", '</div>'));
35 $MeetItem->Phone = '';
36 $MeetItem->Email = trim(GetTextBetween($Item, "<tr><td colspan=2 class='maly_pravo'", '<br>'));
37 $MeetItem->Email = substr($MeetItem->Email, strpos($MeetItem->Email, '>') + 1);
38 $MeetItem->Email = str_replace("<img src='/pages/images/at_zluty.png' border='0' align='absmiddle'>", "@", $MeetItem->Email);
39 if (strpos($MeetItem->Email, '|') !== false)
40 {
41 $MeetItem->Phone = trim(substr($MeetItem->Email, 0, strpos($MeetItem->Email, '|') - 1));
42 $MeetItem->Email = trim(substr($MeetItem->Email, strpos($MeetItem->Email, '|') + 1));
43 } else $MeetItem->Phone = '';
44 $Time = trim(GetTextBetween($Item, "<span id='datum1", '</span>'));
45 $Time = substr($Time, strpos($Time, '>') + 1);
46 $MeetItem->Time = HumanDateTimeToTime($Time);
47 $MeetItem->Link = 'http://www.majkluvsvet.cz'.trim(GetTextBetween($Item, "<span class='linkk pravo'><a href='", "'>odkaz"));
48 $MeetItem->Database = $this->Database;
49 $MeetItem->Source = $this->Id;
50 $this->MeetItems[] = $MeetItem;
51 }
52 return $Output;
53 }
54}
55
Note: See TracBrowser for help on using the repository browser.