From: Eric A. <de...@us...> - 2004-03-28 02:21:00
|
Update of /cvsroot/sprawler/sprawler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2460 Added Files: reg_harvester.pl Log Message: - Added tool for registering new client, preregistering a default, and checking status of a client. --- NEW FILE: reg_harvester.pl --- #!/usr/bin/perl -w # Copyright (c) 2003, 2004 Sprawler Project # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # Alternatively, this software may be distributed under the terms of the # GNU General Public License ("GPL") version 2 as published by the Free # Software Foundation. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # $Id: reg_harvester.pl,v 1.1 2004/03/28 02:09:41 destari Exp $ use IO::Handle; use lib "./lib"; use Sprawler::Master; use DB_File; $email = shift; $preregister = shift; # open config file and read in settings my $configfile = "master.conf"; my $master=Sprawler::Master->new(); $master->load($configfile); if ($email =~ /\@.+\-\d+/) { if ($preregister) { &preregister_clientid($email,"STATUS"); } my $retval=$master->check_clientid($email,"STATUS"); print "Found -> $retval\n"; } else { ®ister_clientid($email,"STATUS"); } sub preregister_clientid { my $clientid=shift; my $request=shift; my $index_path=$master->get("INDEX_PATH"); my $clientid_tag = $clientid . "-$request"; my $client_checkoutdb = $index_path."client_checkout.db"; my ($obj0, $fdesc0, $dbh0)=$master->open_db($client_checkoutdb, "CLIENTDBPRE"); $dbh0->{$clientid_tag} = 1; print "Pre-registered clientid: $clientid clientid_tag: $clientid_tag\n"; $master->close_db($obj0, $fdesc0, "CLIENTDBPRE"); } sub register_clientid { my $clientemail=shift; my $request=shift; my $index_path=$master->get("INDEX_PATH"); my $time = time(); srand($time); my $random = int(rand(1000)); my $clientid = "$email-$random$time"; my $clientid_tag = $clientid . "-$request"; my $client_checkoutdb = $index_path."client_checkout.db"; my ($obj1, $fdesc1, $dbh1)=$master->open_db($client_checkoutdb, "CLIENTDB"); $dbh1->{$clientid_tag} = 1; print "Registered $email with clientid: $clientid clientid_tag: $clientid_tag\n"; $master->close_db($obj1, $fdesc1, "CLIENTDB"); } |