Changeset 63 for trunk/Modules/Meet


Ignore:
Timestamp:
Aug 3, 2021, 11:20:41 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Used explicit types where possible for better error reporting.
  • Modified: Updated Common packaged to newer version.
  • Modified: Simplified pages title.
  • Added: Simple keyword based spam filter for meet items.
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 nbproject
        2 Config.php
        31.settings
        42.project
        53.buildpath
         4.htaccess
  • trunk/Modules/Meet/Import/Amblar.php

    r57 r63  
    2626class MeetSourceAmblar extends MeetSource
    2727{
    28   function Import()
     28  function Import(): string
    2929  {
    3030    $Output = parent::Import();
     
    7979  }
    8080
    81   function ImportItem(&$MeetItem)
     81  function ImportItem(MeetItem &$MeetItem): string
    8282  {
    8383    global $HeightTags, $AgeTags, $LevelTags;
     
    9292    {
    9393      $Output .= 'Main block not isolated.</br>';
    94       return;
     94      return $Output;
    9595    }
    9696
  • trunk/Modules/Meet/Import/AstraPraha.php

    r57 r63  
    33class MeetSourceAstraPraha extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/Csts.php

    r57 r63  
    33class MeetSourceCsts extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/Ella.php

    r57 r63  
    33class MeetSourceElla extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/Eso.php

    r57 r63  
    33class MeetSourceEso extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/Facebook.php

    r57 r63  
    33class MeetSourceFacebook extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    7     return;
     7    return '';
    88    $Output = parent::Import();
    99    $Content = file_get_contents($this->URL);
  • trunk/Modules/Meet/Import/MajkluvSvet.php

    r57 r63  
    33class MeetSourceMajkluvSvet extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/SalsaDance.php

    r57 r63  
    33class MeetSourceSalsaDance extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/Seznamka.php

    r58 r63  
    33class MeetSourceSeznamka extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/TanecniSkola.php

    r60 r63  
    33class MeetSourceTanecniSkola extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Import/Vavruska.php

    r57 r63  
    33class MeetSourceVavruska extends MeetSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/Meet/Meet.php

    r61 r63  
    2020}
    2121
    22 function GetTextBetween(&$Text, $Start, $End)
     22function GetTextBetween(string &$Text, string $Start, string $End): string
    2323{
    2424  $Result = '';
     
    3232}
    3333
    34 function HumanDateTimeToTime($DateTime)
     34function HumanDateTimeToTime(string $DateTime): ?int
    3535{
    3636  if ($DateTime == '') return NULL;
     
    4747}
    4848
    49 function HumanDateToTime($Date)
     49function HumanDateToTime(string $Date): ?int
    5050{
    5151  if ($Date == '') return NULL;
     
    5353}
    5454
    55 function DecodeHtmlEnt($str)
     55function DecodeHtmlEnt(string $str): string
    5656{
    5757  $prefix = '&#';
     
    9090}
    9191
    92 function RemoveHtmlComments($Content)
     92function RemoveHtmlComments(string $Content): string
    9393{
    9494  $Result = '';
     
    103103}
    104104
    105 function is_alpha($Char)
     105function is_alpha(string $Char): bool
    106106{
    107107  return (($Char >= 'a') and ($Char <= 'z')) or (($Char >= 'A') and ($Char <= 'Z'));
    108108}
    109109
    110 function is_white_space($Char)
     110function is_white_space(string $Char): bool
    111111{
    112112  return ($Char == ' ') or ($Char == "\t");
    113113}
    114114
    115 function GetDefaultMeetFilter($Table = '')
     115function GetDefaultMeetFilter(string $Table = ''): string
    116116{
    117117  global $Config;
     
    119119  if ($Table != '') $Table = $Table.'.';
    120120
    121   return '('.$Table.'Hidden=0) AND ('.$Table.'Time > "'.TimeToMysqlDateTime(time() - $Config['MeetInterval']).'")';
    122 }
    123 
    124 function GetNumberBeforeText($Text, $Needle)
     121  return '('.$Table.'Hidden=0) AND ('.$Table.'Time > "'.TimeToMysqlDateTime(time() - (int)$Config['MeetInterval']).'")';
     122}
     123
     124function GetNumberBeforeText(string $Text, string $Needle): string
    125125{
    126126  $Result = '';
     
    148148}
    149149
    150 function GetNumberAfterText($Text, $Needle)
     150function GetNumberAfterText(string $Text, string $Needle): string
    151151{
    152152  $Result = '';
     
    175175}
    176176
    177 function GetAgeFromText($Text)
     177function GetAgeFromText(string $Text): string
    178178{
    179179  $Text = strtolower($Text);
     
    212212}
    213213
    214 function GetHeightFromText($Text)
     214function GetHeightFromText(string $Text): string
    215215{
    216216  $Text = strtolower($Text);
     
    228228}
    229229
    230 function GetWeightFromText($Text)
     230function GetWeightFromText(string $Text): string
    231231{
    232232  $Text = strtolower($Text);
     
    238238}
    239239
    240 function GetAgeHeightWeightFromText($Text)
     240function GetAgeHeightWeightFromText(string $Text): array
    241241{
    242242  $Result = array('', '', '');
     
    261261}
    262262
    263 function GetEmailFromText($Text)
     263function GetEmailFromText(string $Text): string
    264264{
    265265  $Result = '';
     
    302302);
    303303
    304 function GetLocationFromText($Text)
     304function GetLocationFromText(string $Text): string
    305305{
    306306  global $Locations;
     
    315315}
    316316
    317 function GetGenderFromName($Text)
     317function GetGenderFromName(string $Text): string
    318318{
    319319  $Gender = Gender::Male;
     
    334334  public $Database;
    335335
    336   function Parse($Id = null)
     336  function Parse(?int $Id = null): string
    337337  {
    338338    $Output = '';
     
    392392  }
    393393
    394   function Import()
     394  function Import(): string
    395395  {
    396396    return '';
    397397  }
    398398
    399   function DoImport()
     399  function DoImport(): string
    400400  {
    401401    $this->MeetItems = array();
     
    406406    foreach ($this->MeetItems as $MeetItem)
    407407    {
     408      if ($MeetItem->IsSpam()) continue;
    408409      $this->AddedCount += $MeetItem->AddIfNotExist($this->AddTimeInterval, $this->AddCompareTime, $this->AddCompareRemoteId);
    409410    }
     
    434435  var $RemoteId = '';
    435436
    436   function AddIfNotExist($TimeInterval = 0, $CompareTime = true, $CompareRemoteId = false)
     437  function AddIfNotExist(int $TimeInterval = 0, bool $CompareTime = true, bool $CompareRemoteId = false): int
    437438  {
    438439    $Where = '(`Message` = "'.$this->Database->real_escape_string($this->Message).'") AND '.
     
    473474    return $Result;
    474475  }
    475 }
     476
     477  function IsSpam(): bool
     478  {
     479    $Keywords = array('půjčk', 'úvěr');
     480    foreach ($Keywords as $Keyword)
     481    {
     482      if (strpos($this->Message, $Keyword) !== false)
     483      {
     484        return false;
     485      }
     486    }
     487    return true;
     488  }
     489}
  • trunk/Modules/Meet/MeetPage.php

    r62 r63  
    11<?php
    22
    3 class ModuleMeet extends AppModule
     3class ModuleMeet extends Module
    44{
    55  function __construct($System)
     
    1515  }
    1616
    17   function Start()
    18   {
    19     $this->System->RegisterPage('seznamka', 'PageMeetList');
    20     $this->System->RegisterPage(array('seznamka', 'inzerat'), 'PageMeetItem');
    21     $this->System->RegisterPage(array('seznamka', 'aktualizace'), 'PageMeetUpdate');
    22     $this->System->RegisterPage(array('seznamka', 'rss'), 'PageMeetRss');
    23     $this->System->RegisterMenuItem('/seznamka', 'Seznamka');
     17  function Start(): void
     18  {
     19    $this->System->RegisterPage(['seznamka'], 'PageMeetList');
     20    $this->System->RegisterPage(['seznamka', 'inzerat'], 'PageMeetItem');
     21    $this->System->RegisterPage(['seznamka', 'aktualizace'], 'PageMeetUpdate');
     22    $this->System->RegisterPage(['seznamka', 'rss'], 'PageMeetRss');
     23    Core::Cast($this->System)->RegisterMenuItem('/seznamka', 'Seznamka');
    2424  }
    2525}
     
    3030  {
    3131    parent::__construct($System);
    32     $this->FullTitle = 'Taneční seznamka';
    33     $this->ShortTitle = 'Seznamka';
    34   }
    35 
    36   function Show()
     32    $this->Title = 'Seznamka';
     33    $this->Description = 'Taneční seznamka';
     34  }
     35
     36  function Show(): string
    3737  {
    3838    global $Config;
     
    5252
    5353    $Output = '';
    54     $this->Title = 'Seznamka - '.$this->Title;
    5554    if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
    5655      $this->RawPage = true;
     
    121120  {
    122121    parent::__construct($System);
    123     $this->FullTitle = 'Aktualizace taneční seznamky';
    124     $this->ShortTitle = 'Aktualizace seznamky';
    125   }
    126 
    127   function Show()
     122    $this->Title = 'Aktualizace seznamky';
     123    $this->Description = 'Aktualizace taneční seznamky';
     124  }
     125
     126  function Show(): string
    128127  {
    129128    $MeetSources = new MeetSources();
     
    140139  {
    141140    parent::__construct($System);
    142     $this->FullTitle = 'Inzerát taneční seznamky';
    143     $this->ShortTitle = 'Inzerát seznamky';
    144   }
    145 
    146   function Show()
    147   {
    148     $this->Title = 'Inzerát - Seznamka - '.$this->Title;
     141    $this->Title = 'Inzerát';
     142    $this->Description = 'Inzerát taneční seznamky';
     143  }
     144
     145  function Show(): string
     146  {
    149147    $Output = '';
    150148    if (count($this->System->PathItems) > 2)
     
    152150      $id = $this->System->PathItems[2] * 1;
    153151    } else return 'Položka nenalezena';
    154     if ($this->System->IsAdmin())
     152    if (Core::Cast($this->System)->IsAdmin())
    155153    {
    156154      if (array_key_exists('hide', $_GET)) $this->Database->update('MeetItem', 'Id='.$id, array('Hidden' => 1));
     
    165163    {
    166164      $MeetItem = $DbResult->fetch_assoc();
    167       if (($MeetItem['Filter'] == '0') and !$this->System->IsAdmin())
     165      if (($MeetItem['Filter'] == '0') and !Core::Cast($this->System)->IsAdmin())
    168166        return 'Položka nenalezena';
    169167      if ($MeetItem['Link'] != '') $Link = '<a href="'.$MeetItem['Link'].'">Odkaz</a>';
     
    183181        '<tr><th>Zdroj importu</th><td><a href="'.$MeetItem['SourceURL'].'">'.$MeetItem['SourceName'].'</a></td></tr>';
    184182      $Output .= '</table>';
    185       if ($this->System->IsAdmin()) {
     183      if (Core::Cast($this->System)->IsAdmin()) {
    186184        if ($MeetItem['Hidden'] == '1')
    187185          $Output .= '<div>Skrytá položka <a href="?unhide">Zviditelnit</a></div>';
     
    198196  {
    199197    parent::__construct($System);
    200     $this->FullTitle = 'RSS kanál taneční seznamky';
    201     $this->ShortTitle = 'RSS inzeráty seznamky';
    202   }
    203 
    204   function Show()
     198    $this->Title = 'RSS inzeráty seznamky';
     199    $this->Description = 'RSS kanál taneční seznamky';
     200  }
     201
     202  function Show(): string
    205203  {
    206204    global $Config;
Note: See TracChangeset for help on using the changeset viewer.