#!/usr/bin/perl # $Id: $ # vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: # # gnopaster.pl - a gnopaste submitter # # @authors Milan 't4c' Berger # Thomas 'mosez' Boerger # @since 30/07/2005 # @version 0.0.5 # # Copyright (C) 2005 ghcif.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # CHANGELOG # # 0.0.1 initial release # # 0.0.2 cleaned ip code # new helpfile # set under GPL License # added UserAgent # # 0.0.3 added http proxy support # # 0.0.4 added 3rd pasting option # changed name to gnopaster.pl # # 0.0.5 changed regexp for compatibility # with further gnopaste versions (>0.5.2) # added UserAgent Versionstring # CREDITS (in alphabetic order) # # google for giving our brains food (google.ru) # MacFly for "Gimme a gnopaste.pl!" (german-bash.org) # Nermal for nerves and kicking dt (nermal => IRCNet) # our moms for teaching us reading (home.b0x) # sh0 for preventing from the dark side (das.sho.org) # tengri for idea and exbase (unixfreunde.de) # zero for gettin sum regexp help (gpg: 0x857f10E0) use strict; use warnings; use Getopt::Std; use LWP; sub help { printf <) { $code .= $_; } die "error - no data received from stdin.\n" unless length $code; # send form data my $req = LWP::UserAgent->new; $req->agent('gnopaster/'.$version); $req->proxy(['http'],$proxy); my $res = $req->post ($url, [ 'name' => $nick, 'code_lang' => $sl, 'tab_length' => '4', 'description' => $desc, 'code' => $code, 'submit' => 'submit', ], 'content_type' => 'multipart/form-data', ); die "$url error: ", $res->status_line unless $res->is_success; die "Wrong content type at $url -- ", $res->content_type unless $res->content_type eq 'text/html'; # preparing output $data = $res->content; if ($data =~ s/^.*? ".$url."?id=".$data."\n"; exit(0); } # The server made a boo boo print "Couldn't extract gnopaste url string\n"; print "pastefile is too big?\n"; #print $res->content; # uncomment for debugging