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:
2 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/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}
Note: See TracChangeset for help on using the changeset viewer.