This site uses cookies own and third. If you continue to browse consider to accept the use of cookies. OK More Info.

[Delphi] ImageShack Uploader 0.3

  • 0 Replies
  • 2072 Views

0 Members and 2 Guests are viewing this topic.

Offline BigBear

  • *
  • Underc0der
  • Posts: 543
  • Actividad:
    0%
  • Reputación 3
    • View Profile

[Delphi] ImageShack Uploader 0.3

  • on: May 02, 2014, 06:02:11 pm
Version Final de este programa para subir imagenes a ImageShack usando el API que ofrecen.

Una imagen :



El codigo :

Code: (delphi) You are not allowed to view links. Register or Login
// ImageShack Uploader 0.3
// Based in the API of ImageShack
// Coded By Doddy H

unit image;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdHTTP, Vcl.Imaging.pngimage, Vcl.ExtCtrls,
  Vcl.ComCtrls, Vcl.StdCtrls, about, IdMultipartFormData, PerlRegEx;

type
  TForm1 = class(TForm)
    IdHTTP1: TIdHTTP;
    Image1: TImage;
    StatusBar1: TStatusBar;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    GroupBox2: TGroupBox;
    Edit2: TEdit;
    GroupBox3: TGroupBox;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    procedure Button4Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    Edit1.Text := OpenDialog1.FileName;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  regex: TPerlRegEx;
  datos: TIdMultiPartFormDataStream;
  code: string;
  url: string;

begin

  if FileExists(Edit1.Text) then
  begin

    regex := TPerlRegEx.Create();

    StatusBar1.Panels[0].Text := '[+] Uploading ...';
    Form1.StatusBar1.Update;

    datos := TIdMultiPartFormDataStream.Create;
    datos.AddFormField('key', '');
    // Fuck You
    datos.AddFile('fileupload', Edit1.Text, 'application/octet-stream');
    datos.AddFormField('format', 'json');

    code := IdHTTP1.Post('http://post.imageshack.us/upload_api.php', datos);

    regex.regex := '"image_link":"(.*?)"';
    regex.Subject := code;

    if regex.Match then
    begin
      url := regex.Groups[1];
      url := StringReplace(url, '\', '', [rfReplaceAll, rfIgnoreCase]);
      Edit2.Text := url;
      StatusBar1.Panels[0].Text := '[+] Done';
      Form1.StatusBar1.Update;

    end
    else
    begin
      StatusBar1.Panels[0].Text := '[-] Error uploading';
      Form1.StatusBar1.Update;
    end;

    regex.Free;

  end
  else
  begin
    StatusBar1.Panels[0].Text := '[+] File not Found';
    Form1.StatusBar1.Update;
  end;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Edit2.SelectAll;
  Edit2.CopyToClipboard;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  Form2.Show;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  Form1.Close();
  Form2.Close();
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  OpenDialog1.InitialDir := GetCurrentDir;
end;

end.

// The End ?

Si lo quieren bajar lo pueden hacer de You are not allowed to view links. Register or Login.
« Last Edit: May 02, 2014, 06:03:45 pm by Doddy »