1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ICQClient, StdCtrls, ExtCtrls, DBXpress, DB, SqlExpr, IdBaseComponent, IdComponent, IdHTTP, Grids,IniFiles, IdFTP, IdTCPConnection, IdTCPClient, ComCtrls;
type TForm1 = class(TForm) ICQClient: TICQClient; Label1: TLabel; Timer1: TTimer; KeepAlive: TTimer; Timer_getwork: TTimer; IdHTTP1: TIdHTTP; ListBox_vis: TListBox; SG: TStringGrid; TSend: TTimer; Timer_updateArray: TTimer; ListBox_work: TListBox; Label2: TLabel; Button1: TButton; procedure Timer1Timer(Sender: TObject); procedure getWorkClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure KeepAliveTimer(Sender: TObject); procedure Timer_getworkTimer(Sender: TObject); procedure ICQClientLogin(Sender: TObject); procedure ICQClientLogOff(Sender: TObject); procedure TSendTimer(Sender: TObject); procedure Timer_updateArrayTimer(Sender: TObject); procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1; jobs_id,jobs_con,jobs_time,jobs_emp:Array [0..9999999] of String; ini:TIniFile; quelle,ziel:String;
implementation
const UnixStartDate: TDateTime = 25569.0;
function DateTimeToUnix(ConvDate: TDateTime): Longint; begin Result := Round((ConvDate - UnixStartDate) * 86400); end;
function UnixToDateTime(USec: Longint): TDateTime; begin Result := (Usec / 86400) + UnixStartDate; end;
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject); begin if ICQClient.LoggedIn = true then begin Label1.Caption :='Verbindungsstatus: Online' end else begin Label1.Caption :='Verbindungsstatus: Offline'; end;
end;
procedure TForm1.getWorkClick(Sender: TObject); var quelle,ziel:string; var empfang:TFileStream; begin quelle := 'http://burning-headz.de/icq.txt'; ziel := 'C:\icq.txt';
empfang := TFileStream.Create(ziel, fmCreate); IdHTTP1.Get(quelle,empfang); ListBox_work.Items.LoadFromFile(ziel); end;
procedure TForm1.FormCreate(Sender: TObject); begin quelle := 'http://burning-headz.de/icq_bot/'; ziel := 'C:\icq\'; ini := TIniFile.Create(Ziel+'icq.ini'); ICQClient.Login(); end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin ICQClient.LogOff; end;
procedure TForm1.KeepAliveTimer(Sender: TObject); begin ICQClient.SendKeepAlive; end;
procedure TForm1.Timer_getworkTimer(Sender: TObject); var k,last_id:string; var empfang,empfang2:TFileStream; var max,q,h,e,j,ie,oe,max_pos,laenge:Integer; var value : Array [0..4] of String;
var liste_sec:TStringList; var c:Array[0..3] of String;
procedure tausche(var a,b:String); var c:String; Begin c:=a; a:=b; b:=c; end;
function str_str(st:String):String; var pos,i,o,last_match:Integer; var str:String; Begin str := st; last_match := 0; pos := AnsiPos(' ',str); value[0] := Copy(str,last_match,pos); str := Copy(str,pos+1,length(str)-pos+1);
pos := AnsiPos(' ',str); value[1] := Copy(str,last_match,pos); str := Copy(str,pos+1,length(str)-pos+1);
pos := AnsiPos(' ',str); value[2] := Copy(str,last_match,pos); str := Copy(str,pos+1,length(str)-pos+1);
pos := AnsiPos(' ',str); value[3] := Copy(str,last_match,pos); value[4] := str; str_str := 'gfggff'; end; begin empfang := TFileStream.Create(ziel+'icq.txt', fmCreate); IdHTTP1.Get(quelle+'icq.txt',empfang); empfang.free;
ListBox_work.Items.LoadFromFile(ziel+'icq.txt'); max := ListBox_work.Count;
for oe :=0 to length(jobs_time)-1 Do Begin jobs_time[oe] := ''; jobs_emp[oe] := ''; jobs_con[oe] := ''; jobs_id[oe] := '';
end;
try for h:=1 to max-1 do Begin k:=str_str(ListBox_work.Items[h]); ini.WriteString(value[0],'MessageId',value[0]); ini.WriteString(value[0],'MessageEmpfänger',value[1]); ini.WriteString(value[0],'MessageTime',value[2]); ini.WriteString(value[0],'MessageContent',value[4]); end; finally end;
empfang2 := TFileStream.Create(ziel+'delete.txt', fmCreate); IdHTTP1.Get(quelle+'delete.php?id='+value[0],empfang2); empfang2.free;
liste_sec := TStringList.Create; ini.ReadSections(liste_sec);
laenge := liste_sec.Count-1; j:=0;
for j:=0 to laenge do Begin jobs_id[j] := ini.ReadString(liste_sec[j],'MessageId','999'); jobs_emp[j] := ini.ReadString(liste_sec[j],'MessageEmpfänger','999'); jobs_time[j] := ini.ReadString(liste_sec[j],'MessageTime','999'); jobs_con[j] := ini.ReadString(liste_sec[j],'MessageContent','LEER'); end; max_pos :=0;
for ie := laenge DownTo 1 Do Begin for oe := 0 To laenge-1 Do Begin if StrToInt(jobs_time[oe]) > StrToInt(jobs_time[oe+1]) then Begin tausche(jobs_time[oe],jobs_time[oe+1]); tausche(jobs_con[oe],jobs_con[oe+1]); tausche(jobs_emp[oe],jobs_emp[oe+1]); tausche(jobs_id[oe],jobs_id[oe+1]); end; end; end;
for oe := 0 to SG.RowCount - 1 do SG.Rows[oe].Clear;
end;
procedure TForm1.ICQClientLogin(Sender: TObject); begin KeepAlive.Enabled := true; end;
procedure TForm1.ICQClientLogOff(Sender: TObject); begin KeepAlive.Enabled := false; end;
procedure TForm1.TSendTimer(Sender: TObject); var year1,month1,day1,hour1,min1,sec1,mil1,year2,month2,day2,hour2,min2,sec2,mil2:Word; var akt_zeit:Integer; begin if jobs_time[0] <> '' then Begin if DateTimetoUnix(now)-StrToInt(jobs_time[0]) > 7200 then Begin ShowMessage('Löschen 1.: '+IntToStr(DateTimetoUnix(now))+'-'+jobs_time[0]); ini.EraseSection(jobs_id[0]); end;
akt_zeit := StrToInt(jobs_time[0]);
DecodeDate(now, year1,month1,day1); DecodeTime(now,hour1,min1,sec1,mil1);
DecodeDate(UnixToDateTime(akt_zeit),year2,month2,day2); DecodeTime(UnixToDateTime(akt_zeit),hour2,min2,sec2,mil2); if (year1 = year2) and (month1 = month2) and (hour1 = hour2) and (min1 = min2) and (day1 = day2) then Begin ini.EraseSection(jobs_id[0]); end; end; end;
procedure TForm1.Timer_updateArrayTimer(Sender: TObject); var oe:Integer; begin for oe :=0 to length(jobs_time)-1 do Begin SG.Cells[0,oe] := jobs_time[oe]; SG.Cells[1,oe] := jobs_emp[oe]; SG.Cells[2,oe] := jobs_con[oe]; SG.Cells[3,oe] := jobs_id[oe]; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin ICQClient.LogOff; end;
end. |