Changeset 37 for trunk/Modules/Meet


Ignore:
Timestamp:
May 5, 2019, 5:17:06 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Application made using classes System and Application.
  • Modified: Used Common package for better code reuse.
  • Modified: Application made modular. Web sections converted to application modules. They will register pages in main application object.
Location:
trunk/Modules
Files:
2 added
10 edited
2 moved

Legend:

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

    r32 r37  
    2828  function Import()
    2929  {
    30     parent::Import();
     30    $Output = parent::Import();
    3131    $Content = file_get_contents($this->URL);
    3232
     
    3737    if ($Content == '')
    3838    {
    39       echo('Main block not isolated.</br>');
    40       return;
     39      $Output .= 'Main block not isolated.</br>';
     40      return $Output;
    4141    }
    4242
     
    7272      $MeetItem->Database = $this->Database;
    7373      $MeetItem->Source = $this->Id;
    74       $this->ImportItem($MeetItem);
     74      $Output .= $this->ImportItem($MeetItem);
    7575      $this->AddedCount += $MeetItem->AddIfNotExist();
    7676    }
     77    return $Output;
    7778  }
    7879
     
    8182    global $HeightTags, $AgeTags, $LevelTags;
    8283
     84    $Output = '';
    8385    $Content = file_get_contents($MeetItem->Link);
    8486
     
    8890    if ($Content == '')
    8991    {
    90       echo('Main block not isolated.</br>');
     92      $Output .= 'Main block not isolated.</br>';
    9193      return;
    9294    }
     
    106108      if ($Tag == 'Praha') $MeetItem->Location = 'Praha';
    107109    }
     110    return $Output;
    108111  }
    109112}
  • trunk/Modules/Meet/Import/AstraPraha.php

    r32 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    99
     
    1313    if ($Content == '')
    1414    {
    15       echo('Main block not isolated.</br>');
    16       return;
     15      $Output .= 'Main block not isolated.</br>';
     16      return $Output;
    1717    }
    1818
     
    4141      $this->AddedCount += $MeetItem->AddIfNotExist();
    4242    }
     43    return $Output;
    4344  }
    4445}
  • trunk/Modules/Meet/Import/Csts.php

    r31 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    99
     
    1313    if ($Content == '')
    1414    {
    15       echo('Main block not isolated.</br>');
    16       return;
     15      $Output .= 'Main block not isolated.</br>';
     16      return $Output;
    1717    }
    1818
     
    4747      $this->AddedCount += $MeetItem->AddIfNotExist();
    4848    }
     49    return $Output;
    4950  }
    5051}
  • trunk/Modules/Meet/Import/Eso.php

    r32 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    99
     
    1313    if ($Content == '')
    1414    {
    15       echo('Main block not isolated.</br>');
    16       return;
     15      $Output .= 'Main block not isolated.</br>';
     16      return $Output;
    1717    }
    1818
     
    5151      $this->AddedCount += $MeetItem->AddIfNotExist();
    5252    }
     53    return $Output;
    5354  }
    5455}
  • trunk/Modules/Meet/Import/Facebook.php

    r31 r37  
    66  {
    77    return;   
    8     parent::Import();
     8    $Output = parent::Import();
    99    $Content = file_get_contents($this->URL);
    1010    echo($Content);
     
    1515    if ($Content == '')
    1616    {
    17       echo('Main block not isolated.</br>');
    18       return;
     17      $Output .= 'Main block not isolated.</br>';
     18      return $Output;
    1919    }
    2020
     
    5050      $this->AddedCount += $MeetItem->AddIfNotExist();
    5151    }
     52    return $Output;
    5253  }
    5354}
  • trunk/Modules/Meet/Import/MajkluvSvet.php

    r31 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    99
     
    1313    if ($Content == '')
    1414    {
    15       echo('Main block not isolated.</br>');
    16       return;
     15      $Output .= 'Main block not isolated.</br>';
     16      return $Output;
    1717    }
    1818
     
    2929      $MeetItem->Name = trim(GetTextBetween($Item, "<span class='seznamka_nadpis'><b>", '</b>'));
    3030      $MeetItem->Height = trim(GetTextBetween($Item, "výška:", 'cm'));
    31       $MeetItem->Age = trim(GetTextBetween($Item, "věk:", 'let'));
     31      $MeetItem->Age = preg_replace("/[^0-9]/", "", trim(GetTextBetween($Item, "věk:", 'let')));
    3232      $MeetItem->Message = trim(GetTextBetween($Item, "display:block;text-align:justify;'>", '</span>'));
    3333      $MeetItem->Weight = GetWeightFromText($MeetItem->Message);
     
    5050      $this->AddedCount += $MeetItem->AddIfNotExist();
    5151    }
     52    return $Output;
    5253  }
    5354}
  • trunk/Modules/Meet/Import/SalsaDance.php

    r31 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    99    $BlockStart = '<ul class="comments">';
     
    1212    if ($Content == '')
    1313    {
    14       echo('Main block not isolated.</br>');
    15       return;
     14      $Output .= 'Main block not isolated.</br>';
     15      return $Output;
    1616    }
    1717
     
    4242      $this->AddedCount += $MeetItem->AddIfNotExist();
    4343    }
     44    return $Output;
    4445  }
    4546}
  • trunk/Modules/Meet/Import/Seznamka.php

    r32 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    9     $BlockStart = 'Tanec ...</h1 class=\'nadpis\'>';
    10     $BlockEnd = '<!--';
     9    $BlockStart = '<h1>Tanec ... : Seznamka</h1>';
     10    $BlockEnd = '<h2>Doporučujeme</h2>';
    1111    //echo($Content);
    1212    $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
    1313    if ($Content == '')
    1414    {
    15       echo('Main block not isolated.</br>');
    16       return;
     15      $Output .= 'Main block not isolated.</br>';
     16      return $Output;
    1717    }
    1818
    19     $ItemStart = '<div class=\'inztop\'>';
     19    $ItemStart = '<div class=\'col-xs-12\'>';
    2020    $ItemEnd = 'Odpovědět</a></div></div></div>';
    2121    while (strpos($Content, $ItemStart) !== false)
    2222    {
    2323      $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
     24      if ($Item == '') break;
    2425      $MeetItem = new MeetItem();
    2526      //$MeetItem->Image = trim(GetTextBetween($Item, '<div', '</div>'));
    26       if (strpos($Item, "return false\" class='") !== false)
    27       {
    28         $MeetItem->Gender = trim(GetTextBetween($Item, "return false\" class='", "'"));
    29       } else
    30       {
    31         $MeetItem->Gender = trim(GetTextBetween($Item, '<span class="ipoh ', '"'));
    32       }
     27      $MeetItem->Gender = trim(GetTextBetween($Item, "<span class=\"ipoh ", "\""));
    3328      if ($MeetItem->Gender == 'zena') $MeetItem->Gender = Gender::Female;
    34       else if ($MeetItem->Gender == 'muz') $MeetItem->Gender = Gender::Male;
    35       else $MeetItem->Gender = Gender::Undefined;   
     29        else if ($MeetItem->Gender == 'muz') $MeetItem->Gender = Gender::Male;
     30        else $MeetItem->Gender = Gender::Undefined;   
    3631      $MeetItem->Name = trim(GetTextBetween($Item, '>', '</span>'));
    3732      $MeetItem->Name = trim(strip_tags($MeetItem->Name));
    38       $Category = trim(GetTextBetween($Item, ' rel="nofollow">', '</a></span>'));
    39       $MeetItem->Age = trim(GetTextBetween($Item, ' rel="nofollow">', '</a></span>'));
     33      $Category = trim(GetTextBetween($Item, '" >', '</a>'));
     34      $MeetItem->Age = trim(GetTextBetween($Item, '" >', '</a>'));
    4035      $MeetItem->Age = trim(str_replace('let', '', $MeetItem->Age));
    41       $MeetItem->Location = trim(GetTextBetween($Item, ' rel="nofollow">', '</a></span>'));
    42       $MeetItem->Time = HumanDateToTime(trim(GetTextBetween($Item, '> </a>', '</span>')));
    43       $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, 'margin-top:10px;\'>', '</div>')));
     36      $MeetItem->Location = trim(GetTextBetween($Item, '" >', '</a>'));
     37      $MeetItem->Time = trim(GetTextBetween($Item, 'TOP</a> &nbsp;', '</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);
     41      $MeetItem->Message = trim(strip_tags(GetTextBetween($Item, '<p>', '</p>')));
    4442      $MeetItem->Link = GetTextBetween($Item, "<a href='", "'");
    4543      while (substr($MeetItem->Link, 0, 3) == '../')
     
    5452      $this->AddedCount += $MeetItem->AddIfNotExist();
    5553    }
     54    return $Output;
    5655  }
    5756}
  • trunk/Modules/Meet/Import/TanecniSkola.php

    r32 r37  
    55  function Import()
    66  {
     7    $Output = '';
    78    $HeightRange = array(
    89      '< 120 cm' => 120,
     
    2627    );
    2728
    28     parent::Import();
     29    $Output = parent::Import();
    2930    $Content = file_get_contents($this->URL);
    3031
     
    3435    if ($Content == '')
    3536    {
    36       echo('Main block not isolated.</br>');
    37       return;
     37      $Output .= 'Main block not isolated.</br>';
     38      return $Output;
    3839    }
    3940
     
    9495      }
    9596    }
     97    return $Output;
    9698  }
    9799}
  • trunk/Modules/Meet/Import/Vavruska.php

    r31 r37  
    55  function Import()
    66  {
    7     parent::Import();
     7    $Output = parent::Import();
    88    $Content = file_get_contents($this->URL);
    99
     
    1313    if ($Content == '')
    1414    {
    15       echo('Main block not isolated.</br>');
    16       return;
     15      $Output .= 'Main block not isolated.</br>';
     16      return $Output;
    1717    }
    1818
     
    4141      $this->AddedCount += $MeetItem->AddIfNotExist();
    4242    }
     43    return $Output;
    4344  }
    4445}
  • trunk/Modules/Meet/Meet.php

    r36 r37  
    11<?php
    22
    3 include_once('Import/Seznamka.php');
    4 include_once('Import/TanecniSkola.php');
    5 include_once('Import/AstraPraha.php');
    6 include_once('Import/Vavruska.php');
    7 include_once('Import/SalsaDance.php');
    8 include_once('Import/Amblar.php');
    9 include_once('Import/MajkluvSvet.php');
    10 include_once('Import/Csts.php');
    11 include_once('Import/Facebook.php');
    12 include_once('Import/Eso.php');
     3include_once(dirname(__FILE__).'/Import/Seznamka.php');
     4include_once(dirname(__FILE__).'/Import/TanecniSkola.php');
     5include_once(dirname(__FILE__).'/Import/AstraPraha.php');
     6include_once(dirname(__FILE__).'/Import/Vavruska.php');
     7include_once(dirname(__FILE__).'/Import/SalsaDance.php');
     8include_once(dirname(__FILE__).'/Import/Amblar.php');
     9include_once(dirname(__FILE__).'/Import/MajkluvSvet.php');
     10include_once(dirname(__FILE__).'/Import/Csts.php');
     11include_once(dirname(__FILE__).'/Import/Facebook.php');
     12include_once(dirname(__FILE__).'/Import/Eso.php');
    1313
    1414abstract class Gender
     
    3737  $Parts = explode(' ', $DateTime);
    3838  $DateParts = explode('.', $Parts[0]);
    39   if (count($Parts) > 1) $TimeParts = explode(':', $Parts[1]);
    40     else $TimeParts = array(0, 0, 0);
     39  if (count($Parts) > 1) {
     40    $TimeParts = explode(':', $Parts[1]);
     41    if (count($TimeParts) == 1) $TimeParts[1] = '0';
     42    if (count($TimeParts) == 2) $TimeParts[2] = '0';
     43  } else $TimeParts = array(0, 0, 0);
    4144  $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[0], $DateParts[2]);
    4245  return($Result);
     
    277280  function Parse($Id = null)
    278281  {
     282    $Output = '';
    279283    if (($Id != null) and is_numeric($Id)) $Where = 'Id='.$Id;
    280284      else $Where = '1';
     
    294298      else if ($Method == 'eso') $Source = new MeetSourceEso();
    295299      else {
    296         echo('Unsupported parse method: '.$Method.'<br/>');
     300        $Output .= 'Unsupported parse method: '.$Method.'<br/>';
    297301        continue;
    298302      }
     
    303307      $Source->Name = $DbRow['Name'];
    304308      $this->Items[] = $Source;
    305       $Source->Import();
     309      $Output .= $Source->Import();
    306310    }
     311    return $Output;
    307312  }
    308313}
     
    319324  {
    320325    $this->AddedCount = 0;
    321     echo('Parsing '.$this->Name.' ('.$this->Id.')...</br>');
     326    $Output = 'Parsing '.$this->Name.' ('.$this->Id.')...</br>';
     327    return $Output;
    322328  }
    323329}
     
    347353      '(`Message` = "'.$this->Database->real_escape_string($this->Message).'") AND '.
    348354      '(`Email` = "'.$this->Database->real_escape_string($this->Email).'") AND '.
    349       '(DATE(`Time`) = "'.$this->Database->real_escape_string(TimeToMysqlDate($this->Time)).'")');
     355      '(`Time` = "'.$this->Database->real_escape_string(TimeToMysqlDateTime($this->Time)).'")');
    350356    if ($DbResult->num_rows == 0)
    351357    {
Note: See TracChangeset for help on using the changeset viewer.