# ODP::Editors::Editor - An ODP editor-side editor parsing class (Version 0.01) # Copyright (C)2002-2003 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 package ODP::Editors::Editor; # Will eventually inherit from ODP::Editor, but that doesn't exist yet # Functionality is currently limited, since this class has been built quickly to support ODP::Passport use strict; use CGI qw(:standard); use URI::Escape; use ODP::Editors::HTTP; # new - Initialises a new ODP::Editors::Editor object # Parameters: your username, your password, editor name # Returns: ODP::Editors::Editor object sub new ($$$) { my $object = {}; $object->{'e_name'} = $_[1]; $object->{'e_pass'} = $_[2]; $object->{'editor'} = $_[3]; return bless $object; } # fetch - Fetches the editor profile (editor-side) and stores the source in the object # Parameters: # Returns: sub fetch { my $self = shift; $self->{'editor'} =~ s/[^a-z0-9]+//g; my $url = "http://editors.dmoz.org/editors/profile.cgi?editor=$self->{'editor'}&nometa=1&nokmeta=1&noeditall=1&nokeditall=1&nocatmv=1&nokcatmv=1"; my $ua = new ODP::Editors::HTTP('GET',$url,$self->{'e_name'},$self->{'e_pass'}); $self->{'content'} = $ua->execute(); } # isactive - Returns whether or not the editor has an active account # Parameters: # Returns: active (boolean) sub isactive { my $self = shift; if (!$self->{'content'}) { $self->fetch; } my $html = $self->{'content'}; $html =~ /^.*?
(.*?)<\/blockquote>/s; my $interesting_html = $1; return $interesting_html =~ //; } # sendfeedback - Sends feedback to an editor # Parameters: Subject, message # Returns: sub sendfeedback($$) { my $self = shift; my $subject = $_[0]; my $message = $_[1]; my $ua = new ODP::Editors::HTTP('POST','http://editors.dmoz.org/editors/send2.cgi',$self->{'e_name'},$self->{'e_pass'}, [ toeditor=>$self->{'editor'}, subject=>$subject, ccme=>'no', COMMENTS=>$message ]); $ua->execute(); } 1;