Changeset 811


Ignore:
Timestamp:
May 28, 2014, 11:00:26 PM (10 years ago)
Author:
chronos
Message:
  • Added: Better handling of repeater false referrer links. Now use manual BlackList table for checking which IP source is blocked.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Export/ProcessTask.php

    r805 r811  
    66include_once(dirname(__FILE__).'/../../includes/zip.lib.php');
    77
    8 include_once('Export.php');   
    9 include_once('ExportOutput.php');   
     8include_once('Export.php');
     9include_once('ExportOutput.php');
    1010
    1111//LoadCommandLineParameters();
     
    2525        {
    2626          $Dir = opendir($deldir.'/') ;
    27           while(($File = readdir($Dir)) !== false) 
     27          while(($File = readdir($Dir)) !== false)
    2828          {
    2929            if(($File != '..') and ($File != '.') and (!is_dir("$File"))) unlink($deldir.'/'.$File);
     
    3838  if (file_exists($dst)) DeleteOldFiles($dst);
    3939  if (is_dir($src)) {
    40     if (!file_exists($dst)) mkdir($dst, 0777, true); 
     40    if (!file_exists($dst)) mkdir($dst, 0777, true);
    4141    $files = scandir($src);
    4242    foreach ($files as $file)
    43     if ($file != "." && $file != ".." and (!is_dir("$src/$file"))) rcopy("$src/$file", "$dst/$file"); 
     43    if ($file != "." && $file != ".." and (!is_dir("$src/$file"))) rcopy("$src/$file", "$dst/$file");
    4444  }
    4545  else if (file_exists($src)) copy($src, $dst);
     
    5151  $patch = 'Z:'.$patch;
    5252  return $patch;
    53 }     
     53}
    5454
    5555function MPQPack($packdir) {
     
    5858  {
    5959    $Dir = opendir($packdir.DIRECTORY_SEPARATOR) ;
    60     while(($File = readdir($Dir)) !== false) 
    61     {
    62       if(($File != '..') and ($File != '.')) {           
     60    while(($File = readdir($Dir)) !== false)
     61    {
     62      if(($File != '..') and ($File != '.')) {
    6363        $File = str_replace('/',DIRECTORY_SEPARATOR,$File);
    6464        $InDir = '';
     
    7878            $InDir = 'Interface\\\\GlueXML\\\\';
    7979        }
    80        
     80
    8181        if (DIRECTORY_SEPARATOR == '/') // linux
    8282          echo exec('wine cmd /C mpq.exe "'.GetWinZPatch($packdir.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR).'patch-5.MPQ" '.$InDir.basename($File).' "'.GetWinZPatch($packdir.DIRECTORY_SEPARATOR).$File.'" ');
    83  
     83
    8484        if (DIRECTORY_SEPARATOR == '\\') // windows
    8585          echo exec('mpq.exe "'.$packdir.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'patch-5.MPQ" '.$InDir.basename($File).' "'.$packdir.DIRECTORY_SEPARATOR.$File.'" ');
    86  
     86
    8787        echo "\n";
    8888      }
     
    9797  $DbResult = $System->Database->query('SELECT `ExportTask`.`Export`, `Export`.`Id` AS `ExportId` FROM `ExportTask`'.
    9898    ' LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE `Export`.`OutputType` = 9 AND `ExportTask`.`TimeFinish` IS NULL');
    99   while($DbRow = $DbResult->fetch_assoc()) 
     99  while($DbRow = $DbResult->fetch_assoc())
    100100  {
    101101    echo(StrFTime("%d/%m/%Y %H:%M:%S", time()).': Generování DBC souborů pro export '.$DbRow['ExportId'].'.. '."\n");
    102     if($DbRow['ExportId'] != '') 
    103     {     
    104       try 
     102    if($DbRow['ExportId'] != '')
     103    {
     104      try
    105105      {
    106106        $Export = new Export($System);
     
    111111
    112112        echo('Mazání starých souborů...'."\n");
    113        
     113
    114114        // Delete old files
    115115        DeleteOldFiles($Export->TempDir.'dbc');
     
    117117
    118118        SetProgress($Export,20);
    119         if(function_exists('gzcompress')) 
     119        if(function_exists('gzcompress'))
    120120        {
    121121          $Export->ExportToDBC();
     
    126126        } else echo('Funkce pro tvorbu Zip souboru není podporována!'."\n");
    127127        $System->Database->query('UPDATE `ExportTask` SET `TimeFinish`=NOW() WHERE `Export`='.$Export->Id);
    128       } catch (Exception $e) 
     128      } catch (Exception $e)
    129129      {
    130130        echo 'Caught exception: ',  $e->getMessage(), "\n";
     
    141141  $DbResult = $System->Database->query('SELECT `ExportTask`.`Export`, `Export`.`Id` AS `ExportId` FROM `ExportTask`'.
    142142    ' LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE `Export`.`OutputType` = 10 AND `ExportTask`.`TimeFinish` IS NULL');
    143   while($DbRow = $DbResult->fetch_assoc()) 
     143  while($DbRow = $DbResult->fetch_assoc())
    144144  {
    145145    echo(StrFTime("%d/%m/%Y %H:%M:%S", time()).': Generování EXE souboru pro export '.$DbRow['ExportId'].'.. '."\n");
    146     if($DbRow['ExportId'] != '') 
    147     {     
    148       try 
     146    if($DbRow['ExportId'] != '')
     147    {
     148      try
    149149      {
    150150     // echo shell_exec('"'.dirname(__FILE__).'./client_cz_export.sh" '.$DbRow['ExportId'].'');
     
    157157
    158158        $nsifile = 'install.nsi';
    159        
     159
    160160        // Delete old files
    161161        SetProgress($Export,1);
     
    164164        DeleteOldFiles($Export->TempDir.'lua');
    165165        DeleteOldFiles($Export->TempDir.'CzWoW');
    166        
     166
    167167        //copy need files
    168168        SetProgress($Export,5);
     
    173173        rcopy('files/'.$Export->ClientVersion['Version'].'/CzWoW/', $Export->TempDir.'CzWoW/');
    174174        rcopy('files/WoW.ico', $Export->TempDir.'WoW.ico');
    175         rcopy('files/Fonts/', $Export->TempDir.'Fonts/');       
    176              
     175        rcopy('files/Fonts/', $Export->TempDir.'Fonts/');
     176
    177177        SetProgress($Export,10);
    178178        echo('Export lua...'."\n");
     
    184184        echo('Export dbc...'."\n");
    185185        $Export->ExportToDBC();
    186      
     186
    187187        echo('Create readme...'."\n");
    188188        SetProgress($Export,60);
     
    191191        $File->WriteLine($Export->GetReadme());
    192192        unset($File);
    193        
     193
    194194        echo('Packing files...'."\n");
    195195        SetProgress($Export,70);
     
    203203        if (DIRECTORY_SEPARATOR == '/') // linux
    204204          echo exec('makensis '.$workdir.$nsifile);
    205  
     205
    206206        if (DIRECTORY_SEPARATOR == '\\') // windows
    207           echo exec('"'.$workdir.$nsifile.'" '); //"c:\Program Files (x86)\NSIS\makensisw.exe" /Xscriptcmd 
     207          echo exec('"'.$workdir.$nsifile.'" '); //"c:\Program Files (x86)\NSIS\makensisw.exe" /Xscriptcmd
    208208
    209209        SetProgress($Export,100);
    210210        echo ("\n"."Hotovo"."\n");
    211211        $System->Database->query('UPDATE `ExportTask` SET `TimeFinish`=NOW() WHERE `Export`='.$DbRow['Export']);
    212       } catch (Exception $e) 
     212      } catch (Exception $e)
    213213      {
    214214        echo 'Caught exception: ',  $e->getMessage(), "\n";
  • trunk/Modules/Referrer/Referrer.php

    r805 r811  
    4141      {
    4242        $IP = GetRemoteAddress();
    43        
    44         // Check if client IP is not blocked as spam source
    45         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `Referrer` WHERE `LastIP` = "'.$IP.'" AND (`Visible` = 0)');
     43
     44        // Check if client IP is not blaclisted as spam source. If yes then add new referrer as invisible
     45        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `BlackList` WHERE `IP` = "'.$IP.'"');
    4646        $DbRow = $DbResult->fetch_row();
    47         if($DbRow[0] == 0) $Visible = '1';
    48           else $Visible = '0';
     47        if($DbRow[0] == 0)
     48        {
     49          $Visible = '1';
     50          $Description = '';
     51        } else
     52        {
     53          $Visible = '0';
     54          $Description = 'Spam';
     55        }
    4956
    5057        // Check if host name is already stored and need just to update hit counter
     
    5562          $this->System->Database->query('UPDATE `Referrer` SET `Hits` = `Hits` + 1, `DateLast` = NOW(), `LastURL` = "'.
    5663           addslashes($Referrer).'", `LastIP` = "'.$IP.'" WHERE `Id` = '.$DbRow['Id']);
    57         } else $this->System->Database->query('INSERT INTO `Referrer` (`Web`, `DateFirst`, `DateLast`, `LastURL`, `Hits`, `LastIP`, `Visible`) '.
    58                   'VALUES ("'.$HostName.'", NOW(), NOW( ), "'.addslashes($Referrer).'", 1, "'.$IP.'", '.$Visible.')');
     64        } else
     65        {
     66          $this->System->Database->query('INSERT INTO `Referrer` (`Web`, `DateFirst`, `DateLast`, `LastURL`, `Hits`, `LastIP`, `Visible`, `Description`) '.
     67                  'VALUES ("'.$HostName.'", NOW(), NOW( ), "'.addslashes($Referrer).'", 1, "'.$IP.'", '.$Visible.', "'.$Description.'")');
     68        }
    5969      }
    6070    }
     
    177187          $Item = $DbResult->fetch_assoc();
    178188          $this->Database->update('Referrer', 'Id='.$_GET['id'], array('Visible' => 0, 'Description' => 'Spam'));
     189          $DbResult2 = $this->Database->select('BlackList', '*', 'IP="'.$Item['LastIP'].'"');
     190          if($DbResult2->num_rows == 0)
     191          {
     192            $this->Database->insert('BlackList', array('Time' => 'NOW()', 'IP' => $Item['LastIP']));
     193          }
    179194          $Output = ShowMessage(T('Set as spam'), MESSAGE_CRITICAL);
    180195          $Output .= $this->ShowList();
  • trunk/admin/UpdateTrace.php

    r803 r811  
    28062806}
    28072807
     2808function UpdateTo811($Manager)
     2809{
     2810  $Manager->Execute('CREATE TABLE IF NOT EXISTS `BlackList` (
     2811  `Id` int(11) NOT NULL AUTO_INCREMENT,
     2812  `Time` datetime NOT NULL,
     2813  `IP` varchar(255) NOT NULL,
     2814  PRIMARY KEY (`Id`)
     2815  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     2816}
     2817
    28082818$Updates = array(
    28092819        498 => array('Revision' => 506, 'Function' => 'UpdateTo506'),
     
    28332843  748 => array('Revision' => 787, 'Function' => 'UpdateTo787'),
    28342844  787 => array('Revision' => 803, 'Function' => 'UpdateTo803'),
     2845  803 => array('Revision' => 811, 'Function' => 'UpdateTo811'),
    28352846);
  • trunk/includes/Version.php

    r810 r811  
    66// and system will need database update.
    77
    8 $Revision = 810; // Subversion revision
    9 $DatabaseRevision = 803; // Database structure revision
    10 $ReleaseTime = '2014-05-25';
     8$Revision = 811; // Subversion revision
     9$DatabaseRevision = 811; // Database structure revision
     10$ReleaseTime = '2014-05-28';
  • trunk/includes/system.php

    r809 r811  
    250250  and method_exists($this->OnPageNotFound[0], $this->OnPageNotFound[1]))
    251251          $Output = $this->BaseView->ShowPage(call_user_func_array($this->OnPageNotFound, array()));
    252                 else 
     252                else
    253253                {
    254254                        $Output = $this->PageNotFound();
     
    452452        {
    453453                $Output = $this->ShowHeader().$Content.$this->ShowFooter();
    454                 if($this->System->Config['Web']['FormatOutput']) 
     454                if($this->System->Config['Web']['FormatOutput'])
    455455              $Output = $this->FormatOutput($Output);
    456456                return($Output);
Note: See TracChangeset for help on using the changeset viewer.