|
|
1.1 ! root 1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */ ! 2: ! 3: /* $Id: ClientFormUnit.cpp,v 1.14 2006/09/24 19:56:04 deuce Exp $ */ ! 4: ! 5: /**************************************************************************** ! 6: * @format.tab-size 4 (Plain Text/Source Code File Header) * ! 7: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * ! 8: * * ! 9: * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html * ! 10: * * ! 11: * This program is free software; you can redistribute it and/or * ! 12: * modify it under the terms of the GNU General Public License * ! 13: * as published by the Free Software Foundation; either version 2 * ! 14: * of the License, or (at your option) any later version. * ! 15: * See the GNU General Public License for more details: gpl.txt or * ! 16: * http://www.fsf.org/copyleft/gpl.html * ! 17: * * ! 18: * Anonymous FTP access to the most recent released source is available at * ! 19: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * ! 20: * * ! 21: * Anonymous CVS access to the development source and modification history * ! 22: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * ! 23: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * ! 24: * (just hit return, no password is necessary) * ! 25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * ! 26: * * ! 27: * For Synchronet coding style and modification guidelines, see * ! 28: * http://www.synchro.net/source.html * ! 29: * * ! 30: * You are encouraged to submit any modifications (preferably in Unix diff * ! 31: * format) via e-mail to [email protected] * ! 32: * * ! 33: * Note: If this box doesn't appear square, then you need to fix your tabs. * ! 34: ****************************************************************************/ ! 35: ! 36: //--------------------------------------------------------------------------- ! 37: ! 38: #include "sbbs.h" // filter_ip ! 39: #include <vcl.h> ! 40: #pragma hdrstop ! 41: ! 42: #include <stdio.h> // sprintf ! 43: #include <winsock.h> // closesocket ! 44: #include "ClientFormUnit.h" ! 45: ! 46: void socket_open(void*, BOOL open); ! 47: //--------------------------------------------------------------------------- ! 48: #pragma package(smart_init) ! 49: #pragma resource "*.dfm" ! 50: TClientForm *ClientForm; ! 51: //--------------------------------------------------------------------------- ! 52: __fastcall TClientForm::TClientForm(TComponent* Owner) ! 53: : TForm(Owner) ! 54: { ! 55: MainForm=(TMainForm*)Application->MainForm; ! 56: ListMutex=CreateMutex(NULL,false,NULL); ! 57: } ! 58: //--------------------------------------------------------------------------- ! 59: void __fastcall TClientForm::FormHide(TObject *Sender) ! 60: { ! 61: MainForm->ViewClients->Checked=false; ! 62: } ! 63: //--------------------------------------------------------------------------- ! 64: void __fastcall TClientForm::TimerTimer(TObject *Sender) ! 65: { ! 66: char str[64]; ! 67: int i; ! 68: time_t t; ! 69: ! 70: if(WaitForSingleObject(ListMutex,1)!=WAIT_OBJECT_0) ! 71: return; ! 72: for(i=0;i<ListView->Items->Count;i++) { ! 73: t=time(NULL)-(ulong)ListView->Items->Item[i]->Data; ! 74: if(t/(60*60)) ! 75: sprintf(str,"%d:%02d:%02d",t/(60*60),(t/60)%60,t%60); ! 76: else ! 77: sprintf(str,"%d:%02d",(t/60)%60,t%60); ! 78: ListView->Items->Item[i]->SubItems->Strings[5]=str; ! 79: ! 80: } ! 81: ReleaseMutex(ListMutex); ! 82: ! 83: } ! 84: //--------------------------------------------------------------------------- ! 85: ! 86: void __fastcall TClientForm::CloseSocketMenuItemClick(TObject *Sender) ! 87: { ! 88: TListItem* ListItem; ! 89: TItemStates State; ! 90: ! 91: ListItem=ListView->Selected; ! 92: State << isSelected; ! 93: ! 94: while(ListItem!=NULL) { ! 95: closesocket(atoi(ListItem->Caption.c_str())); ! 96: ListItem=ListView->GetNextItem(ListItem,sdAll,State); ! 97: } ! 98: } ! 99: //--------------------------------------------------------------------------- ! 100: ! 101: void __fastcall TClientForm::FilterIpMenuItemClick(TObject *Sender) ! 102: { ! 103: char str[256]; ! 104: int res; ! 105: TListItem* ListItem; ! 106: TItemStates State; ! 107: ! 108: ListItem=ListView->Selected; ! 109: State << isSelected; ! 110: ! 111: while(ListItem!=NULL) { ! 112: ! 113: AnsiString prot = ListItem->SubItems->Strings[0]; ! 114: AnsiString username = ListItem->SubItems->Strings[1]; ! 115: AnsiString ip_addr = ListItem->SubItems->Strings[2]; ! 116: AnsiString hostname = ListItem->SubItems->Strings[3]; ! 117: ! 118: wsprintf(str,"Disallow future connections from %s" ! 119: ,ip_addr); ! 120: res=Application->MessageBox(str,"Filter IP?" ! 121: ,MB_YESNOCANCEL|MB_ICONQUESTION); ! 122: if(res==IDCANCEL) ! 123: break; ! 124: if(res==IDYES) ! 125: filter_ip(&MainForm->cfg,prot.c_str(),"abuse",hostname.c_str() ! 126: ,ip_addr.c_str(),username.c_str(),NULL); ! 127: if(ListView->Selected == NULL) ! 128: break; ! 129: ListItem=ListView->GetNextItem(ListItem,sdAll,State); ! 130: } ! 131: } ! 132: //--------------------------------------------------------------------------- ! 133:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.