4 # This file is part of lainsafe.
6 # lainsafe 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, either version 3 of the License, or
9 # (at your option) any later version.
11 # lainsafe is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with lainsafe. If not, see <https://www.gnu.org/licenses/>.
32 # Default options, if no specified.
33 $DEFAULT_SERVER = "https://lainsafe.delegao.moe";
34 $DISPLAY_ASCII = 1; # 0 if you don't want the ascii
36 my $ASCII_ART = <<'EOF';
47 | /v` ,--- ---- .^.| ;
49 ' | '. @@ / \@@ / |\ |;
66 print "lainsafecli, a command line interface for lainsafe.\n";
67 print "USAGE: lainsafecli [--server] FILE\n\n";
68 print "if --server not given, $DEFAULT_SERVER is used.\n";
74 my $ua = LWP
::UserAgent
->new;
75 GetOptions
("server=s" => \
$DEFAULT_SERVER,
78 if($help || not defined $ARGV[0])
83 # check if file is given
85 $file = $ARGV[@ARGV-1];
87 die "File does not exist\n" if !-e
$file;
89 die "Give a file\n" unless defined $file;
93 my $url_to_upload = $DEFAULT_SERVER . "/upload.cgi";
97 $ua->agent("Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0");
99 # check if server is running lainsafe
101 if(!$ua->get($url_to_upload)->is_success)
103 print "$url_to_upload is not running lainsafe.\n";
108 $req = $ua->post($url_to_upload,
109 Content_Type
=> 'form-data',
116 print $ASCII_ART if $DISPLAY_ASCII;
117 print $DEFAULT_SERVER . "/" . $req->{_content
} . "\n";