Source code taken from cacert-20111227.tar.bz2
[cacert-devel.git] / cacertupload.pl
1 #!/usr/bin/perl
2
3 #LibreSSL - CAcert web application
4 #Copyright (C) 2004-2008 CAcert Inc.
5 #
6 #This program is free software; you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation; version 2 of the License.
9 #
10 #This program is distributed in the hope that it will be useful,
11 #but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #GNU General Public License for more details.
14 #
15 #You should have received a copy of the GNU General Public License
16 #along with this program; if not, write to the Free Software
17 #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19 use LWP::UserAgent;
20 $ua = LWP::UserAgent->new(agent => 'Translingo Client 1.0');
21 use HTTP::Request::Common qw(POST);
22
23 my $translingo_password;
24 my $translingo_account;
25
26 # Read Account&Password from file
27 eval `cat password.dat`;
28
29 $ua->cookie_jar({});
30 $ua->timeout(10000);
31
32 my $req = POST 'http://translingo.cacert.org/login.php',
33 [
34 ];
35 # ggf. Referer faken
36 $req->referer('http://translingo.cacert.org/');
37 $ua->request($req)->as_string;
38
39 # 1.Test - Umgebung
40 my $req = POST 'http://translingo.cacert.org/login.php',
41 [
42 username => $translingo_account,
43 password => $translingo_password,
44 submit => 'Login',
45 ];
46 # ggf. Referer faken
47 $req->referer('http://translingo.cacert.org/');
48 $ua->request($req)->as_string;
49
50 # 2.Test - FileUpload
51 my $req = POST 'http://translingo.cacert.org/upload.php',
52 Content_Type => 'form-data',
53 Content => [
54 project => '1',
55 fileformat => '1',
56 pofile => ["messages.po" => "messages.po", 'Content_Type' => "application/x-gettext"],
57 ];
58 print $ua->request($req)->as_string;
59