Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Just Can't seem to get the variable!

Quote Reply
Just Can't seem to get the variable!
Hi:

I am working on a plug-in to limit the number of times different users can use my search function (Seems a couple big companies seem to think they can run 1000's of queries a day on my DB and not have to pay for it!)

Anyway, my thought it to track searches by IP and Username... those with no username (Guests) will get 10 searches, users 50, and anyone who "donates" will get unlimited.

So I am looking at inserting some code into search.pm, like this: (NOTE: My only changes to existing code are inside the "######## Dave Mod" comments)

Code:


sub search {

# ------------------------------------------------------------------

# Do the search and print out the results.

#

my $results = GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'search_results', \&query, {});
if (defined $results->{error}) {

print $IN->header();
print Links::SiteHTML::display ('search', $results);

}

else {

######## Dave Mod

my ($rec) = @_;

my $username = $rec->{'Username'};
my $ip = $ENV{REMOTE_HOST} || $ENV{REMOTE_ADDR} || 'None';
my $member = "No"; #$IN->param('member');
my $number;
my $count;

my $s_db = $Links::DB->table('Search_Count');


# Set date variable to today's date.

Links::init_date();
my $today = GT::Date::date_get();
my $date = $today;


# Update the search count unless this is the first search.

$s_db->add ( { IP => $ip, Date => $date, User => $username, Count => $member } );


if ($count >= $number) {
print $IN->header();

print Links::SiteHTML::display ('search_limit', $results);

}

else {

######## End Dave Mod


print $IN->header();
print Links::SiteHTML::display ('search_results', $results);

}


Note this is very simplified right now-- I am still trying to get the basics to work before I throw in all the checks! So $member is hard-coded to no, the date works, IP works, etc. I will eventually add in an update to update the count for existing records... but right now I am just trying to get the dang Username to appear!!!! (If I hard-code $username ="Guest"; or something, the above will add to database Search_Count, but trying to get the darn Username is not working)

Can anyone give me a pointer so I can get this variable to appear!

BTW, I did do a variable dump on the Search Resuts page, and both "Username" and "member" do show up, so I KNOW they there to grab- I just cannot seem to grab them!!!!

TIA!
dave

Big Cartoon DataBase
Big Comic Book DataBase

Last edited by:

carfac: Aug 24, 2003, 10:12 AM
Subject Author Views Date
Thread Just Can't seem to get the variable! carfac 6322 Aug 24, 2003, 10:07 AM
Thread Re: [carfac] Just Can't seem to get the variable!
carfac 6183 Aug 24, 2003, 6:08 PM
Thread Re: [carfac] Just Can't seem to get the variable!
yogi 6175 Aug 24, 2003, 8:34 PM
Thread Re: [yogi] Just Can't seem to get the variable!
carfac 6174 Aug 24, 2003, 9:02 PM
Thread Re: [carfac] Just Can't seem to get the variable!
carfac 6221 Aug 24, 2003, 9:11 PM
Thread Re: [carfac] Just Can't seem to get the variable!
pugdog 6172 Aug 25, 2003, 8:38 AM
Thread Re: [pugdog] Just Can't seem to get the variable!
carfac 6166 Aug 25, 2003, 9:09 AM
Thread Re: [carfac] Just Can't seem to get the variable!
carfac 6176 Aug 25, 2003, 9:15 AM
Thread Re: [carfac] Just Can't seem to get the variable!
carfac 6162 Aug 25, 2003, 10:29 AM
Thread Re: [carfac] Just Can't seem to get the variable!
yogi 6152 Aug 25, 2003, 11:06 AM
Thread Re: [yogi] Just Can't seem to get the variable!
carfac 6153 Aug 25, 2003, 12:09 PM
Thread Re: [carfac] Just Can't seem to get the variable!
carfac 6174 Aug 25, 2003, 12:23 PM
Thread Re: [carfac] Just Can't seem to get the variable!
yogi 6188 Aug 25, 2003, 12:56 PM
Post Re: [yogi] Just Can't seem to get the variable!
carfac 6136 Aug 25, 2003, 1:04 PM
Thread Re: [carfac] Just Can't seem to get the variable!
pugdog 6124 Aug 25, 2003, 1:29 PM
Post Re: [pugdog] Just Can't seem to get the variable!
carfac 6159 Aug 25, 2003, 1:42 PM