-->

Memasang perintah (script/code) di komponen

e- Pusat Sumber Belajar - Memasang perintah (script/code) di komponen


Pada materi ketiga ini kita akan memasukkan perintah/script pada komponen - komponen delphi. Jangan kawatir setiap tahap akan lampirkan tutorial berupa Giff  agar lebih mudah dipahami.

Lankah pertama adalah menambahkan perintah berikut dibawah private :
 Tombol:Boolean;

langkah kedua klik 2 kali botton "START" masukkan perintah berikut dibawah "begin" :
    if Tombol then begin
IdMappedPortTCP1.Active := False; // Perintah Request TCP dihentikan
IdMappedPortTCP1.Bindings.Clear;// Perintah untuk membersihkan koneksi TCP
  Sleep(100); // Jeda waktu
  Button1.Caption := 'START';
  Tombol := False;
end
else
begin
  Button1.Caption := 'STOP';
IdMappedPortTCP1.Bindings.Add.IP := '127.0.0.1'; // Local Host
IdMappedPortTCP1.Bindings.Add.Port := StrToInt('4545');// Listen Port buat bitvise atau layer kesamaannya
IdMappedPortTCP1.MappedHost :='202.152.240.50'; // Proxy default umumnya disini yang digunakan buat host squid
IdMappedPortTCP1.MappedPort := StrToInt('8080'); // Port Default umumnya ini yang digunakan buat port squid , squid gunakan mapped def
IdMappedPortTCP1.Active := True; // Perintah Request TCP dijalankan
  Tombol := True;
end;


Langkah ketiga klik aktifkan IdMappedPortTCP1, pada objek inspektor pilih event lalu klik 2 kali pada OnExecute masukkan perintah :
if (pos('CONNECT',athread.NetData)<>0)  then begin
Payload :=' #13#10;  // untuk playload bisa Konsultasi
athread.OutboundClient.Write(header);
Sleep (500);
athread.NetData:= payload;
end else
end;


untuk palyload yang work saat ini (AXIS / XL) sengaja di sensor silahkan konsultasi pada abugosok


klik 2 kali juga pada OutBoundata masukkan perintah :
Memo2.lines.add (Athread.NetData);
if Pos('HTTP/1.0', Athread.Netdata)= 1 then
begin
Athread.Netdata:=StringReplace(Athread.Netdata, 'HTTP/1.0', 'HTTP/1.1 200', [rfReplaceAll]);
end else
if Pos('HTTP/1.1', Athread.Netdata)= 1 then
begin
Athread.Netdata:=StringReplace(Athread.Netdata, 'HTTP/1.1', 'HTTP/1.1 200', [rfReplaceAll]);
AThread.NetData := StringReplace(AThread.NetData,'HTTP/1.0','HTTP/1.1 200 OK',[rfReplaceAll]);
AThread.NetData := StringReplace(AThread.NetData,'HTTP/1.1','HTTP/1.1 200 OK',[rfReplaceAll]);
AThread.NetData := StringReplace(athread.NetData,'HTML 2.0','200 OK',[rfReplaceAll]);
AThread.NetData := StringReplace(athread.NetData,'HTML','200 OK',[rfReplaceAll]);
AThread.NetData := StringReplace(athread.NetData,'html','200 OK',[rfReplaceAll]);
AThread.NetData := stringreplace(athread.NetData,'HTTP/1.1 200 Connection established','HTTP/1.0 200 Connection established',[rfReplaceAll]);
AThread.NetData := StringReplace(Athread.NetData,'HTTP/1.0'#13#10#13#10,'SHTTP/1.0 200 Connection established  HTTP/1.0'#13#10'Connection: Keep-Alive'#13#10, [rfReplaceAll]);
AThread.NetData := StringReplace(Athread.NetData,':443',':443 SHTTP/1.0 200 Connection established HTTP/1.0'#13#10,[rfReplaceAll]);
AThread.NetData := StringReplace(Athread.NetData,':443',':22 SHTTP/1.0 200 Connection established',[rfReplaceAll]);
AThread.NetData := StringReplace(Athread.NetData,':443',':443 HTTP/1.0 200 Connection established HTTP/1.0'#13#10,[rfReplaceAll]);
AThread.NetData := StringReplace(Athread.NetData,':443',':22 HTTP/1.0 200 Connection established',[rfReplaceAll]);
AThread.NetData := StringReplace(Athread.NetData,'HTTP/1.0'#13#10#13#10,'HTTP/1.0 200 Connection established  HTTP/1.0'#13#10'Connection: Keep-Alive'#13#10'Host: '#13#10#13#10, [rfReplaceAll]);
END ELSE
if Pos('HTTP/1.0 3',AThread.NetData) or Pos('HTTP/1.0 4',AThread.NetData) or Pos('HTTP/1.0 5',AThread.NetData)
    or Pos('HTTP/1.1 3',AThread.NetData) or Pos('HTTP/1.1 4',AThread.NetData) or Pos('HTTP/1.1 5',AThread.NetData) <> 0 then
    begin
    AThread.NetData := 'HTTP/1.0 200 OK'#13#10;
    AThread.NetData := StringReplace(AThread.NetData,'Proxy-Connection: close','Proxy-Connection: keep-alive',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'Connection: Close','Connection: keep-alive',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'505 HTTP Version Not Supported','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'504 Gateway Timeout','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'503 Service Unavailable','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'502 Bad Gateway','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'501 Not Implemented','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'500 Server Internal Eror','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'Server Error 5xx','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'417 Expectation Failed','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'416 Requested Range Not Satisfiable','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'415 Unsupported Media Type','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'414 Request-URI Too Long','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'413 Request Entity Too Large','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'412 Precondition Failed','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'411 Length Required','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'410 Gone','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'409 Conflict','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'408 Request Timeout','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'407 Proxy Authentication Required','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'406 Not Acceptable','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'405 Method Not Allowed','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'404 Document not found',' 200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'404 Not Found','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'403 Forbidden','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'402 Payment Required','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'401 Unauthorized','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'400 Bad Request','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'Client Error 4xx','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'307 Temporary Redirect','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'306 (Unused)','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'305 Use Proxy','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'304 Not Modified','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'303 See Other','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'302 Moved Temporarily','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'302 Redirect','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'302 Found','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'301 Moved Permanently','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'300 Multiple Choices','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'Redirection 3xx','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'206 Partial Content','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'205 Reset Content','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'204 No Content','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'203 Non-Authoritative Information','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'202 Accepted','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'201 Created','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'200 OK','200 OK',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,':143',':443',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,':109',':443',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,':22',':443',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'%20','_',[rfReplaceAll]);
    AThread.NetData := StringReplace(AThread.NetData,'%2f','/',[rfReplaceAll]);
    end;   end;



Langkah 4 Silahkan simpan dan build menjadi Exe dan siap untuk dites.


silahkan download source code jika kesulitan
Source Code Materi3

Ini hasilnya :

DAFTAR ISI

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel