# ODP::Editors::HTTP - Handles editorside HTTP requests [using a helper] (Version 0.01) # Copyright (C)2002 Richard P. Fuller # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # This module is a wrapper for ODP::Editors::HTTP::Somethings package ODP::Editors::HTTP; use utf8; my $mod_lwp1; my $mod_lwp2; foreach $prefix (@INC) { if (-e "$prefix/LWP/UserAgent.pm") { $mod_lwp1 = 1; } if (-e "$prefix/HTML/HeadParser.pm") { $mod_lwp2 = 1; } } if ($mod_lwp1 && $mod_lwp2) { require ODP::Editors::HTTP::LWP; } else { require ODP::Editors::HTTP::Lynx; } use strict; # new: Creates a new ODP::HTTP object # Parameters: GET|POST, URI, your ODP username, your ODP password # Returns: An ODP::HTTP::Something object sub new ($$$$) { my $object; if ($mod_lwp1 && $mod_lwp2) { $object = new ODP::Editors::HTTP::LWP; } else { $object = new ODP::Editors::HTTP::Lynx; } my $null; my @parameters; ($null, $object->{'method'},$object->{'uri'},$object->{'username'},$object->{'password'},@parameters) = @_; $object->{'parameters'} = \@parameters; if ($object->{'method'} ne 'GET' && $object->{'method'} ne 'POST') { die 'Invalid method specified.'; } if ($object->{'uri'} !~ m|^http://dmoz.org/| && $object->{'uri'} !~ m|^http://dmoz.org:8080/| && $object->{'uri'} !~ m|^http://forums.dmoz.org/| && $object->{'uri'} !~ m|^http://editors.dmoz.org/| && $object->{'uri'} !~ m|^http://editors.dmoz.org:8080/| && $object->{'uri'} !~ m|^http://odpstage-n02.netscape.com:8080/|) { die 'Attempted to pass dmoz username/password to site other than dmoz.org.'; } return $object; } 1;