shuusei24123:拡張子偽装ファイルの共有を無効にする(idea by 2ndreal)

diff --dos -wurN 24122/handler.pas 24123/handler.pas
--- 24122/handler.pas	Sun Feb 09 02:15:38 2003
+++ 24123/handler.pas	Sun Feb 09 03:13:46 2003
@@ -2259,7 +2259,7 @@
 procedure Handler_Share(dir: String; valid_dir: Boolean);
 var
  rec: TShare;
- folder_name, str, filename, file_ext: String;
+ folder_name, str, filename, file_ext, ext_fake: String;
  i,j,mime: Integer;
  k,l,fsize: Int64;
  op_bitrate, op_freq, op_time: Integer;
@@ -2283,6 +2283,14 @@
    if shareinform and CanSendError(user,query) then
     local.Exec(MSG_SERVER_NOSUCH,'ファイル'+hlist.Strings[0]+'は共有されません。'
       +' : INCOMPLETEファイル');
+   exit;
+ end;
+ ext_fake:=ExtractFileExt(ChangeFileExt(hlist.Strings[0],''))+ExtractFileExt(hlist.Strings[0]);
+ if StrHash_FindString(fakeext_list,ext_fake,true) then
+ begin
+   if shareinform and CanSendError(user,query) then
+    local.Exec(MSG_SERVER_NOSUCH,'ファイル'+hlist.Strings[0]+'は共有されません。'
+      +' : 拡張子偽装ファイル');
    exit;
  end;
  tmp_pos:=291;
diff --dos -wurN 24122/mainform.pas 24123/mainform.pas
--- 24122/mainform.pas	Sun Feb 09 02:15:16 2003
+++ 24123/mainform.pas	Sun Feb 09 03:17:46 2003
@@ -1416,6 +1416,10 @@
   else wqfloodblock_method:=block;
   nocount_text:=ini.ReadBool('Other2','NoCountText',false);
   autoban_incomplete:=ini.ReadBool('Other2','AutoBanINCOMPLETE',false);
+  disable_fakeext:=ini.ReadBool('Other2','DisableFakeExt',false);
+  fakeext:=ini.ReadString('Other2','FakeExt','.zip.avi .zip.mpg');
+  StrHash_Reset(fakeext_list);
+  SplitString(AnsiLowerCase(fakeext),fakeext_list);
   // set up console
   LogStartup('mainform::loadconfig: setting up console user');
   cons_channels:=TMyList.Create;
@@ -1847,6 +1851,8 @@
   end;
   ini.WriteBool('Other2','NoCountText',nocount_text);
   ini.WriteBool('Other2','AutoBanINCOMPLETE',autoban_incomplete);
+  ini.WriteBool('Other2','DisableFakeExt',disable_fakeext);
+  ini.WriteString('Other2','FakeExt',fakeext);
   finally
   ini.Free;
  end;
diff --dos -wurN 24122/settings.dfm 24123/settings.dfm
--- 24122/settings.dfm	Sun Feb 09 02:17:46 2003
+++ 24123/settings.dfm	Sun Feb 09 03:17:22 2003
@@ -5925,6 +5925,24 @@
           Height = 17
           Caption = 'INCOMPLETEファイルの共有を無効にする'
           TabOrder = 5
+        end
+        object cb_disable_fakeext: TCheckBox
+          Left = 8
+          Top = 240
+          Width = 225
+          Height = 17
+          Caption = '拡張子偽装ファイルの共有を無効にする'
+          TabOrder = 6
+          OnClick = cb_disable_fakeextClick
+        end
+        object edit_fakeext: TEdit
+          Left = 240
+          Top = 238
+          Width = 113
+          Height = 20
+          TabOrder = 7
+          Text = '.zip.avi .zip.mpg'
+          Visible = False
         end
       end
     end
diff --dos -wurN 24122/settings.pas 24123/settings.pas
--- 24122/settings.pas	Sun Feb 09 02:15:30 2003
+++ 24123/settings.pas	Sun Feb 09 02:53:00 2003
@@ -569,6 +569,8 @@
     edit_wqfloodblock_bantime: TComboBox;
     cb_nocount_text: TCheckBox;
     cb_autoban_incomplete: TCheckBox;
+    cb_disable_fakeext: TCheckBox;
+    edit_fakeext: TEdit;
     procedure Panel3Resize(Sender: TObject);
     procedure headerPaint(Sender: TObject);
     procedure SetTopText(str: String);
@@ -644,6 +646,7 @@
     procedure rd_wqfloodblock_banClick(Sender: TObject);
     procedure rd_wqfloodblock_blockClick(Sender: TObject);
     procedure rd_wqfloodblock_leechClick(Sender: TObject);
+    procedure cb_disable_fakeextClick(Sender: TObject);
   private
     { Private declarations }
     procedure SetBanItems(control: TComboBox);
@@ -1465,6 +1468,9 @@
 
  cb_nocount_text.Checked:=nocount_text;
  cb_autoban_incomplete.Checked:=autoban_incomplete;
+ cb_disable_fakeext.Checked:=disable_fakeext;
+ edit_fakeext.Visible:=cb_disable_fakeext.Checked;
+ edit_fakeext.Text:=fakeext;
 end;
 
 procedure TSlavaNapSettings.sh_reportShow(Sender: TObject);
@@ -1991,6 +1997,8 @@
 
    nocount_text:=cb_nocount_text.Checked;
    autoban_incomplete:=cb_autoban_incomplete.Checked;
+   disable_fakeext:=cb_disable_fakeext.Checked;
+   fakeext:=edit_fakeext.Text;
   except
  end;
  btn_restoreClick(nil);
@@ -2403,6 +2411,11 @@
     else itemindex:=7;//1日
   end;
   Result:=itemindex;
+end;
+
+procedure TSlavaNapSettings.cb_disable_fakeextClick(Sender: TObject);
+begin
+  edit_fakeext.Visible:=cb_disable_fakeext.Checked;
 end;
 
 end.
diff --dos -wurN 24122/thread.pas 24123/thread.pas
--- 24122/thread.pas	Thu Feb 06 20:59:42 2003
+++ 24123/thread.pas	Sun Feb 09 03:13:38 2003
@@ -360,6 +360,7 @@
   StrHash_Clear(ext_image_list);
   StrHash_Clear(ext_app_list);
   StrHash_Clear(ext_cd_list);
+  StrHash_Clear(fakeext_list);
   {$I checksync.pas}
   FreeBlocks;
  DebugLog('ShutDown - 14',true);
@@ -685,6 +686,7 @@
                        SplitString(lowercase(ext_image),ext_image_list);
                        SplitString(lowercase(ext_app),ext_app_list);
                        SplitString(lowercase(ext_cd),ext_cd_list);
+                       SplitString(AnsiLowerCase(fakeext),fakeext_list);
                        tmp_pos:=1506;
                      end;
    MSG_CMD_GETMODE:  if running then
diff --dos -wurN 24122/vars.pas 24123/vars.pas
--- 24122/vars.pas	Sun Feb 09 02:14:58 2003
+++ 24123/vars.pas	Sun Feb 09 02:52:22 2003
@@ -311,6 +311,9 @@
  wqfloodblock_bantime: Cardinal;
  nocount_text: Boolean;
  autoban_incomplete: Boolean;
+ disable_fakeext: Boolean;
+ fakeext: String;
+ fakeext_list: TStringHash;
 implementation
 
 procedure CheckWindows;