Changeset 65


Ignore:
Timestamp:
Apr 19, 2022, 10:25:41 PM (3 years ago)
Author:
chronos
Message:
  • 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.
Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Meet/Import/AstraPraha.php

    r63 r65  
    2323      $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
    2424      $MeetItem = new MeetItem();
    25       $MeetItem->Time = trim(GetTextBetween($Item, 'Vloženo:', '</p>'));
    26       $MeetItem->Time = HumanDateToTime($MeetItem->Time);
     25      $Time = trim(GetTextBetween($Item, 'Vloženo:', '</p>'));
     26      $MeetItem->Time = HumanDateToTime($Time);
    2727
    28       $MeetItem->Gender = trim(GetTextBetween($Item, '<h3 class=\'dating-heading\'>', '</h3>'));
    29       if ($MeetItem->Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male;
     28      $Gender = trim(GetTextBetween($Item, '<h3 class=\'dating-heading\'>', '</h3>'));
     29      if ($Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male;
    3030        else $MeetItem->Gender = Gender::Female;
    3131      $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, '<p class=\'last-element\'>', '</p>')));
  • trunk/Modules/Meet/Import/Csts.php

    r63 r65  
    2424      $MeetItem = new MeetItem();
    2525
    26       $MeetItem->Gender = trim(html_entity_decode(GetTextBetween($Item, 'class="kategorie">', '<div')));
    27       if ($MeetItem->Gender == 'Hledám partnera') $MeetItem->Gender = Gender::Female;
    28         else if ($MeetItem->Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male;
     26      $Gender = trim(html_entity_decode(GetTextBetween($Item, 'class="kategorie">', '<div')));
     27      if ($Gender == 'Hledám partnera') $MeetItem->Gender = Gender::Female;
     28        else if ($Gender == 'Hledám partnerku') $MeetItem->Gender = Gender::Male;
    2929        else $MeetItem->Gender = Gender::Undefined;
    3030      $MeetItem->Name = trim(html_entity_decode(GetTextBetween($Item, 'Vložil/a', ',')));
    31       $MeetItem->Time = trim(GetTextBetween($Item, ' ', '</th>'));
    32       $MeetItem->Time = HumanDateTimeToTime($MeetItem->Time);
     31      $Time = trim(GetTextBetween($Item, ' ', '</th>'));
     32      $MeetItem->Time = HumanDateTimeToTime($Time);
    3333      $MeetItem->Height = trim(GetTextBetween($Item, "výška:", 'cm'));
    3434      $MeetItem->Message = trim(html_entity_decode(strip_tags(GetTextBetween($Item, '<td colspan="3">', '</td>'))));
  • trunk/Modules/Meet/Import/Eso.php

    r63 r65  
    2626
    2727      $MeetItem->Name = trim(GetTextBetween($Item, '<h3 class="panel-title tucne">', '/'));
    28       $MeetItem->Gender = trim(GetTextBetween($Item, ' ', '</h3'));
    29       if (strpos($MeetItem->Gender, 'partnerku') !== false) $MeetItem->Gender = Gender::Male;
    30         else if (strpos($MeetItem->Gender, 'partnera') !== false) $MeetItem->Gender = Gender::Female;
     28      $Gender = trim(GetTextBetween($Item, ' ', '</h3'));
     29      if (strpos($Gender, 'partnerku') !== false) $MeetItem->Gender = Gender::Male;
     30        else if (strpos($Gender, 'partnera') !== false) $MeetItem->Gender = Gender::Female;
    3131        else $MeetItem->Gender = Gender::Undefined;
    3232      $Small = GetTextBetween($Item, '<small>', '</small>');
     
    3636        $Small = substr($Small, strpos($Small, '/') + 1);
    3737      }
    38       $MeetItem->Time = trim($Small);
    39       $MeetItem->Time = HumanDateToTime($MeetItem->Time);
     38      $Time = trim($Small);
     39      $MeetItem->Time = HumanDateToTime($Time);
    4040      $MeetItem->Message = trim(GetTextBetween($Item, '<p class="lead">', '</p>'));
    4141      $MeetItem->Age = GetAgeFromText($MeetItem->Message);
     
    5555  }
    5656}
    57 
  • trunk/Modules/Meet/Import/MajkluvSvet.php

    r63 r65  
    2424      $MeetItem = new MeetItem();
    2525
    26       $MeetItem->Gender = trim(GetTextBetween($Item, "<td class='bunka_seznamka linel' width='45' ><img src='/pages/images/", '.gif'));
    27       if ($MeetItem->Gender == 'zena') $MeetItem->Gender = Gender::Male;
    28         else $MeetItem->Gender = Gender::Female;
     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;
    2929      $MeetItem->Name = trim(GetTextBetween($Item, "<span class='seznamka_nadpis'><b>", '</b>'));
    3030      $MeetItem->Height = trim(GetTextBetween($Item, "výška:", 'cm'));
     
    4242        $MeetItem->Email = trim(substr($MeetItem->Email, strpos($MeetItem->Email, '|') + 1));
    4343      } else $MeetItem->Phone = '';
    44       $MeetItem->Time = trim(GetTextBetween($Item, "<span id='datum1", '</span>'));
    45       $MeetItem->Time = substr($MeetItem->Time, strpos($MeetItem->Time, '>') + 1);
    46       $MeetItem->Time = HumanDateTimeToTime($MeetItem->Time);
     44      $Time = trim(GetTextBetween($Item, "<span id='datum1", '</span>'));
     45      $Time = substr($Time, strpos($Time, '>') + 1);
     46      $MeetItem->Time = HumanDateTimeToTime($Time);
    4747      $MeetItem->Link = 'http://www.majkluvsvet.cz'.trim(GetTextBetween($Item, "<span class='linkk pravo'><a href='", "'>odkaz"));
    4848      $MeetItem->Database = $this->Database;
  • trunk/Modules/Meet/Import/SalsaDance.php

    r63 r65  
    2222      $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
    2323      $MeetItem = new MeetItem();
    24       $MeetItem->Time = trim(GetTextBetween($Item, '<span class="created">', '</span>'));
    25       $MeetItem->Time = str_replace('. ', '.', $MeetItem->Time);
    26       if (strpos($MeetItem->Time, 'dnes v') !== false)
    27         $MeetItem->Time = str_replace('dnes v', HumanDate(time()), $MeetItem->Time);
    28       if (strpos($MeetItem->Time, 'včera v') !== false)
    29         $MeetItem->Time = str_replace('včera v', HumanDate(strtotime('-1 day', time())), $MeetItem->Time);
     24      $Time = trim(GetTextBetween($Item, '<span class="created">', '</span>'));
     25      $Time = str_replace('. ', '.', $Time);
     26      if (strpos($Time, 'dnes v') !== false)
     27        $Time = str_replace('dnes v', HumanDate(time()), $Time);
     28      if (strpos($Time, 'včera v') !== false)
     29        $Time = str_replace('včera v', HumanDate(strtotime('-1 day', time())), $Time);
    3030      $MeetItem->Time = HumanDateTimeToTime($MeetItem->Time);
    3131      $MeetItem->Name = trim(GetTextBetween($Item, '<div class="comment-name">', '</div>'));
  • trunk/Modules/Meet/Import/Seznamka.php

    r63 r65  
    2525      $MeetItem = new MeetItem();
    2626      //$MeetItem->Image = trim(GetTextBetween($Item, '<div', '</div>'));
    27       $MeetItem->Gender = trim(GetTextBetween($Item, "<span class=\"ipoh ", "\""));
    28       if ($MeetItem->Gender == 'zena') $MeetItem->Gender = Gender::Female;
    29         else if ($MeetItem->Gender == 'muz') $MeetItem->Gender = Gender::Male;
    30         else $MeetItem->Gender = Gender::Undefined;
     27      $Gender = trim(GetTextBetween($Item, "<span class=\"ipoh ", "\""));
     28      if ($Gender == 'zena') $MeetItem->Gender = Gender::Female;
     29        else if ($Gender == 'muz') $MeetItem->Gender = Gender::Male;
     30        else $Gender = Gender::Undefined;
    3131      $MeetItem->Name = trim(GetTextBetween($Item, '>', '</span>'));
    3232      $MeetItem->Name = trim(strip_tags($MeetItem->Name));
     
    3535      $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age));
    3636      $MeetItem->Location = trim(strip_tags(GetTextBetween($Item, '<span class=\'imesto\'>', '</span>')));
    37       $MeetItem->Time = trim(html_entity_decode(str_replace('&nbsp;', '', GetTextBetween($Item, 'TOP</a>', '</span>'))));
    38       if ($MeetItem->Time == 'Včera') $MeetItem->Time = HumanDate(time() - 60*60*24);
    39         else if ($MeetItem->Time == 'Dnes') $MeetItem->Time = HumanDate(time());
    40       $MeetItem->Time = HumanDateToTime($MeetItem->Time);
     37      $Time = trim(html_entity_decode(str_replace('&nbsp;', '', GetTextBetween($Item, 'TOP</a>', '</span>'))));
     38      if ($Time == 'Včera') $Time = HumanDate(time() - 60*60*24);
     39        else if ($Time == 'Dnes') $Time = HumanDate(time());
     40      $MeetItem->Time = HumanDateToTime($Time);
    4141      $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, '<p>', '</p>')));
    4242      $MeetItem->Link = GetTextBetween($Item, "<a href='", "'");
  • trunk/Modules/Meet/Import/Vavruska.php

    r63 r65  
    2525      $MeetItem = new MeetItem();
    2626
    27       $MeetItem->Gender = GetTextBetween($Item, '<h5 class="', '"');
    28       if ($MeetItem->Gender == 'muz') $MeetItem->Gender = Gender::Male;
    29       else if ($MeetItem->Gender == 'zena') $MeetItem->Gender = Gender::Female;
    30       else $MeetItem->Gender = Gender::Undefined;
     27      $Gender = GetTextBetween($Item, '<h5 class="', '"');
     28      if ($Gender == 'muz') $MeetItem->Gender = Gender::Male;
     29      else if ($Gender == 'zena') $MeetItem->Gender = Gender::Female;
     30      else $Gender = Gender::Undefined;
    3131      $MeetItem->Name = GetTextBetween($Item, '>', '<');
    3232      $MeetItem->Email = GetTextBetween($Item, '<p>', '</p>');
  • trunk/Modules/Meet/Meet.php

    r64 r65  
    1313include_once(dirname(__FILE__).'/Import/Ella.php');
    1414include_once(dirname(__FILE__).'/Import/MgDance.php');
     15include_once(dirname(__FILE__).'/Import/LaTropical.php');
    1516
    1617abstract class Gender
     
    3839  $DateTime = str_replace('. ', '.', $DateTime);
    3940  $Parts = explode(' ', $DateTime);
    40   $DateParts = explode('.', $Parts[0]);
    41   if (count($Parts) > 1) {
     41  if (count($Parts) > 0)
     42  {
     43    $DateParts = explode('.', $Parts[0]);
     44  }
     45  if (count($Parts) > 1)
     46  {
    4247    $TimeParts = explode(':', $Parts[1]);
    4348    if (count($TimeParts) == 1) $TimeParts[1] = '0';
     
    260265  }
    261266  return $Result;
     267}
     268
     269function GetNameFromText(string $Text): string
     270{
     271  return '';
    262272}
    263273
     
    334344class MeetSources
    335345{
    336   public $Database;
     346  public Database $Database;
    337347
    338348  function Parse(?int $Id = null): string
    339349  {
    340350    $Output = '';
    341     $Where = '(Enabled=1)';
     351    $Where = '1';
    342352    if (($Id != null) and is_numeric($Id)) $Where .= ' AND (Id='.$Id.')';
    343353    $DbResult = $this->Database->select('MeetSource', '*', $Where);
    344354    while ($DbRow = $DbResult->fetch_assoc())
    345355    {
    346       $Method = $DbRow['Method'];
    347       if ($Method == 'hes') $Source = new MeetSourceTanecniSkola();
    348       else if ($Method == 'vavruska') $Source = new MeetSourceVavruska();
    349       else if ($Method == 'salsadance') $Source = new MeetSourceSalsaDance();
    350       else if ($Method == 'astra') $Source = new MeetSourceAstraPraha();
    351       else if ($Method == 'seznamka') $Source = new MeetSourceSeznamka();
    352       else if ($Method == 'amblar') $Source = new MeetSourceAmblar();
    353       else if ($Method == 'majkluvsvet') $Source = new MeetSourceMajkluvSvet();
    354       else if ($Method == 'csts') $Source = new MeetSourceCsts();
    355       else if ($Method == 'facebook') $Source = new MeetSourceFacebook();
    356       else if ($Method == 'eso') $Source = new MeetSourceEso();
    357       else if ($Method == 'ella') $Source = new MeetSourceElla();
    358       else if ($Method == 'mgdance') $Source = new MeetSourceMgDance();
    359       else {
    360         $Output .= 'Unsupported parse method: '.$Method.'<br/>';
    361         continue;
    362       }
    363       $Source->Database = $this->Database;
    364       $Source->Id = $DbRow['Id'];
    365       $Source->URL = $DbRow['URL'];
    366       $Source->Method = $Method;
    367       $Source->Name = $DbRow['Name'];
    368       $this->Items[] = $Source;
    369       $Output .= $Source->DoImport();
     356      if ($DbRow['Enabled'] == 1)
     357      {
     358        $Method = $DbRow['Method'];
     359        if ($Method == 'hes') $Source = new MeetSourceTanecniSkola();
     360        else if ($Method == 'vavruska') $Source = new MeetSourceVavruska();
     361        else if ($Method == 'salsadance') $Source = new MeetSourceSalsaDance();
     362        else if ($Method == 'astra') $Source = new MeetSourceAstraPraha();
     363        else if ($Method == 'seznamka') $Source = new MeetSourceSeznamka();
     364        else if ($Method == 'amblar') $Source = new MeetSourceAmblar();
     365        else if ($Method == 'majkluvsvet') $Source = new MeetSourceMajkluvSvet();
     366        else if ($Method == 'csts') $Source = new MeetSourceCsts();
     367        else if ($Method == 'facebook') $Source = new MeetSourceFacebook();
     368        else if ($Method == 'eso') $Source = new MeetSourceEso();
     369        else if ($Method == 'ella') $Source = new MeetSourceElla();
     370        else if ($Method == 'mgdance') $Source = new MeetSourceMgDance();
     371        else if ($Method == 'latropical') $Source = new MeetSourceLaTropical();
     372        else {
     373          $Output .= 'Unsupported parse method: '.$Method.'<br/>';
     374          continue;
     375        }
     376        $Source->Database = $this->Database;
     377        $Source->Id = $DbRow['Id'];
     378        $Source->URL = $DbRow['URL'];
     379        $Source->Method = $Method;
     380        $Source->Name = $DbRow['Name'];
     381        $this->Items[] = $Source;
     382        $Output .= $Source->DoImport();
     383      } else $Output .= 'Parser '.$DbRow['Name'].' (#'.$DbRow['Id'].') disabled.<br/>'."\n";
    370384    }
    371385    return $Output;
     
    375389class MeetSource
    376390{
    377   public $Name;
    378   public $URL;
    379   public $Method;
    380   public $Id;
    381   public $Database;
    382   public $MeetItems;
    383   public $AddCompareTime;
    384   public $AddCompareRemoteId;
    385   public $AddTimeInterval;
    386   public $AddedCount;
     391  public string $Name;
     392  public string $URL;
     393  public string $Method;
     394  public string $Id;
     395  public Database $Database;
     396  public array $MeetItems;
     397  public bool $AddCompareTime;
     398  public bool $AddCompareRemoteId;
     399  public int $AddTimeInterval;
     400  public int $AddedCount;
    387401
    388402  function __construct()
     
    420434class MeetItem
    421435{
    422   var $Database;
    423   var $Name = '';
    424   var $Message = '';
    425   var $Time = '';
    426   var $Gender = Gender::Undefined;
    427   var $Phone = '';
    428   var $Email = '';
    429   var $Age = '';
    430   var $Height = '';
    431   var $Source = 0;
    432   var $Weight = '';
    433   var $Location = '';
    434   var $Image = '';
    435   var $Link = '';
    436   var $Title = '';
    437   var $Level = '';
    438   var $RemoteId = '';
     436  public Database $Database;
     437  public string $Name = '';
     438  public string $Message = '';
     439  public ?int $Time = 0;
     440  public int $Gender = Gender::Undefined;
     441  public string $Phone = '';
     442  public string $Email = '';
     443  public string $Age = '';
     444  public string $Height = '';
     445  public int $Source = 0;
     446  public string $Weight = '';
     447  public string $Location = '';
     448  public string $Image = '';
     449  public string $Link = '';
     450  public string $Title = '';
     451  public string $Level = '';
     452  public string $RemoteId = '';
    439453
    440454  function AddIfNotExist(int $TimeInterval = 0, bool $CompareTime = true, bool $CompareRemoteId = false): int
     
    485499      if (strpos($this->Message, $Keyword) !== false)
    486500      {
    487         return false;
     501        return true;
    488502      }
    489503    }
    490     return true;
    491   }
    492 }
     504    return false;
     505  }
     506}
  • trunk/SQL/Update.php

    r57 r65  
    8484
    8585ALTER TABLE `MeetSource` ADD `Enabled` int(11) NOT NULL DEFAULT 1;
     86
     87-- rev 65
     88ALTER TABLE `Dance` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     89ALTER TABLE `DanceFigure` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     90ALTER TABLE `DanceGroup` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     91ALTER TABLE `Event` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     92ALTER TABLE `EventSource` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     93ALTER TABLE `MeetItem` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     94ALTER TABLE `MeetSource` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     95ALTER TABLE `Movie` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     96ALTER TABLE `Music` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     97ALTER TABLE `Resource` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     98ALTER TABLE `ResourceGroup` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     99ALTER TABLE `School` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Note: See TracChangeset for help on using the changeset viewer.