2003.04.13 (日) 21:27:43 <u*j*2*6*> アイドル状態というのは、ユーザーが一定時間コマンドを送信していない状態のことをさしています
2003.04.13 (日) 21:29:41 <u*j*2*6*> ただし、214番コマンド(統計情報)は自動的に送信されるケースがおおいので、これが送られててもアイドル状態ということにしてます
2003.04.13 (日) 21:32:03 <u*j*2*6*> この修正では「一定時間」というのが固定になってますが、そのうちアドミンが変えられるようになると思います
2003.04.13 (日) 21:33:45 <u*j*2*6*> あ。。この修正だと「一定時間」というのが1分になってますね。みじかすぎかも。各自で変更してください
2003.04.14 (月) 19:13:10 <Heracules> さすがに1分じゃ短いね。
shuusei24161:アイドル状態のユーザーを切断(idea by oyakata)

diff --dos -ur 24160/constants.pas 24161/constants.pas
--- 24160/constants.pas	Sat Apr 12 05:08:40 2003
+++ 24161/constants.pas	Sun Apr 13 15:15:58 2003
@@ -27,8 +27,8 @@
  SLAVANAP_VERSION             = '2.4.1';
  SLAVANAP_BUILD               = '108';
  SLAVANAP_BUILD_DATE          = '24 January 2003';
- SLAVANAP_SHUUSEI             = '60';
- SLAVANAP_SHUUSEI_DATE        = '12 April 2003';
+ SLAVANAP_SHUUSEI             = '61';
+ SLAVANAP_SHUUSEI_DATE        = '13 April 2003';
  SLAVANAP_VERSION_SHORT       = SLAVANAP_TITLE+' '+SLAVANAP_VERSION;
  SLAVANAP_FULL                = SLAVANAP_TITLE+' '+SLAVANAP_VERSION+
                                 ' (build '+SLAVANAP_BUILD+
diff --dos -ur 24160/handler.pas 24161/handler.pas
--- 24160/handler.pas	Sat Apr 12 05:08:16 2003
+++ 24161/handler.pas	Sun Apr 13 14:27:10 2003
@@ -11051,6 +11051,7 @@
      Result:=false;
      exit;
    end;
+   if gcmd.id<>214 then local.last_command_time:=GetTickCount;
    user:=usr.data;
  end;
  tmp_pos:=2;
diff --dos -ur 24160/localusers.pas 24161/localusers.pas
--- 24160/localusers.pas	Wed Apr 09 14:45:10 2003
+++ 24161/localusers.pas	Sun Apr 13 14:12:52 2003
@@ -69,6 +69,7 @@
   blocked_tooshortmp3,
   blocked_other   : Word; //blocked_otherはブロックワードによるブロックを含まない
   detector        : TLocalUserDetector;
+  last_command_time: Cardinal;
   constructor Create;
   destructor Destroy; override;
   function  logged: Boolean;
@@ -136,6 +137,7 @@
  blocked_tooshortmp3:=0;
  blocked_other      :=0;
  detector:=[];
+ last_command_time:=current_time;
 {$IFDEF USERS_DOUBLE_QUEUE}
  StrHash_Reset(out_list2);
 {$ENDIF}
@@ -215,6 +217,7 @@
  blocked_tooshortmp3:=0;
  blocked_other      :=0;
  detector:=[];
+ last_command_time:=current_time;
 {$IFDEF USERS_DOUBLE_QUEUE}
  StrHash_Clear(out_list2);
 {$ENDIF}
diff --dos -ur 24160/mainform.pas 24161/mainform.pas
--- 24160/mainform.pas	Sat Mar 29 13:22:32 2003
+++ 24161/mainform.pas	Sun Apr 13 15:30:16 2003
@@ -1498,6 +1498,7 @@
   allowed_clients[softUnknown]    :=ini.ReadBool('Other2','AllowSoftOther',false);
   for i:=0 to max_custom_allow do
    allowed_custom[i]:=ini.ReadString('Other2','AllowCustomClient'+IntToStr(i),'');
+  kill_idleuser:=ini.ReadBool('Other2','KillIdleUser',false);
   // set up console
   LogStartup('mainform::loadconfig: setting up console user');
   cons_channels:=TMyList.Create;
@@ -1976,6 +1977,7 @@
   ini.WriteBool('Other2','AllowSoftOther',allowed_clients[softUnknown]);
   for i:=0 to max_custom_allow do
    ini.WriteString('Other2','AllowCustomClient'+IntToStr(i),allowed_custom[i]);
+  ini.WriteBool('Other2','KillIdleUser',kill_idleuser);
   finally
   ini.Free;
  end;
diff --dos -ur 24160/settings.dfm 24161/settings.dfm
--- 24160/settings.dfm	Sat Mar 29 13:20:46 2003
+++ 24161/settings.dfm	Sun Apr 13 13:41:30 2003
@@ -285,7 +285,7 @@
       Top = 38
       Width = 365
       Height = 392
-      ActivePage = sh_other4
+      ActivePage = sh_other3
       Align = alClient
       MultiLine = True
       OwnerDraw = True
@@ -6177,7 +6177,7 @@
           Visible = False
         end
         object rd_xbutton_attr: TRadioGroup
-          Left = 8
+          Left = 224
           Top = 232
           Width = 129
           Height = 65
@@ -6196,6 +6196,14 @@
           Height = 17
           Caption = '共有が下限以下でも検索・参照を許す'
           TabOrder = 13
+        end
+        object cb_kill_idleuser: TCheckBox
+          Left = 8
+          Top = 224
+          Width = 185
+          Height = 17
+          Caption = 'アイドル状態のユーザーを切断'
+          TabOrder = 14
         end
       end
       object sh_other4: TDFWTabSheetes
diff --dos -ur 24160/settings.pas 24161/settings.pas
--- 24160/settings.pas	Sat Mar 29 14:00:26 2003
+++ 24161/settings.pas	Sun Apr 13 15:30:32 2003
@@ -616,6 +616,7 @@
     edit_allow_sign3: TEdit;
     edit_allow_sign4: TEdit;
     cb_allow_teknap: TCheckBox;
+    cb_kill_idleuser: TCheckBox;
     procedure Panel3Resize(Sender: TObject);
     procedure headerPaint(Sender: TObject);
     procedure SetTopText(str: String);
@@ -1586,6 +1587,7 @@
    False3:   rd_xbutton_attr.ItemIndex:=2;
  end;
  cb_minshare_noblockact.Checked:=minshare_noblockact;
+ cb_kill_idleuser.Checked:=kill_idleuser;
 end;
 
 procedure TSlavaNapSettings.sh_other4Show(Sender: TObject);
@@ -2184,6 +2186,7 @@
      2: b3_canclose:=False3;
    end;
    minshare_noblockact:=cb_minshare_noblockact.Checked;
+   kill_idleuser:=cb_kill_idleuser.Checked;
   except
  end else if pages.ActivePage=sh_other4 then
  try
diff --dos -ur 24160/thread.pas 24161/thread.pas
--- 24160/thread.pas	Fri Mar 21 13:18:58 2003
+++ 24161/thread.pas	Sun Apr 13 15:01:08 2003
@@ -68,6 +68,7 @@
   procedure ResetDLRequestControl;
   procedure CheckBlockedShare;
   procedure CheckForceEnter;
+  procedure KillIdleUser;
  end;
 
 var
@@ -1312,6 +1313,7 @@
  db_reconnect.Clear;
  ResetWantQueueControl;
  ResetDLRequestControl;
+ KillIdleUser;
  tmp_pos:=1562;
  if num_servers>0 then
   for i:=0 to db_local.count-1 do
@@ -2018,6 +2020,27 @@
     end;
   end;
   tmp_pos:=12270;
+end;
+
+procedure TMainThread.KillIdleUser;
+var
+ i: Integer;
+ loc: TLocalUser;
+begin
+ if not kill_idleuser then exit;
+ for i:=db_local.count-1 downto 0 do
+ try
+   loc:=db_local.Items[i];
+   if loc.logged then
+   if GetTickCount-loc.last_command_time>60000 then
+   if loc.level<NapUserModerator then
+   if not StrHash_FindString(db_friends,loc.nick,true) then
+   begin
+     AddReconnector(decode_ip(loc.ip));
+     DisconnectUser(loc,'','','KillIdleUser',false);
+   end;
+  except
+ end;
 end;
 
 end.
diff --dos -ur 24160/vars.pas 24161/vars.pas
--- 24160/vars.pas	Sat Mar 29 11:08:36 2003
+++ 24161/vars.pas	Sun Apr 13 13:42:22 2003
@@ -341,6 +341,7 @@
  allowed_clients_desc: Array[0..8] of PChar = ('Napster', 'WinMX', 'Napchan',
  'Lopster', 'XNap', 'Utatane', '2get', 'Teknap', 'Other');
  allowed_custom: Array[0..MAX_CUSTOM_ALLOW] of String;
+ kill_idleuser: Boolean;
 
 implementation