Install.pm 0100644 0000764 0000770 00000013214 07234146604 011405 0 ustar 00alex cvs # ==================================================================
# Plugins::SearchLogger - Auto Generated Install Module
#
# Plugins::SearchLogger
# Author : Alex Krohn
# Version : 3.0.0
#
# ==================================================================
#
package Plugins::SearchLogger;
# ==================================================================
use strict;
use vars qw/$VERSION $DEBUG $NAME $META/;
$VERSION = '3.0.0';
$DEBUG = 0;
$NAME = 'SearchLogger';
$META = {
'author' => 'PUGDOG Enterprises, Inc/UltraNerds',
'url' => 'http://UltraNerds.com/',
'license' => 'Freeware',
'description' => 'Logs all your search terms and provides an admin interface to view searched queries.',
'prog_ver' => '2.0.0',
'version' => '3.0.0',
};
use Links qw/$IN $DB $TPL $CFG/;
sub pre_install {
# -------------------------------------------------------------------
# This function displays an HTML formatted message that will display
# to the user any instructions/information before they install
# the plugin.
#
my $inst_msg = 'The SearchLogger plugin will create a new search log table, and will hook into your search results. It then logs all queries people make and lets you view them from the admin panel.';
return $inst_msg;
}
sub pre_uninstall {
# -------------------------------------------------------------------
# This function displays an HTML formatted message that will display
# to the user any instructions/information before they remove the
# plugin.
#
my $inst_msg = 'The SearchLogger plugin will create a new search log table, and will hook into your search results. It then logs all queries people make and lets you view them from the admin panel.';
return $inst_msg;
}
sub install {
# -------------------------------------------------------------------
# This function does the actual installation. It's first argument is
# a plugin manager which you can use to register hooks, install files,
# add menu options, etc. You should return an HTML formatted string
# that will be displayed to the user.
#
my $mgr = shift;
my $c = $DB->creator('SearchLog');
my $error = '';
my $message = '';
$c->cols (
ID => { pos => 1, type => 'INT', not_null => 1, unsigned => 1, regex => '^\d+$' },
Term => { pos => 2, type => 'CHAR', size => '25', not_null => 1 },
HitCount => { pos => 3, type => 'SMALLINT', unsigned => 1, not_null => 1, default => 0 },
Results => { pos => 4, type => 'SMALLINT', unsigned => 1, not_null => 1, default => 0 },
Last_Hit => { pos => 5, type => 'DATE' },
TS => { pos => 5, type => 'TIMESTAMP' }
);
$c->pk('ID');
$c->ai('ID');
$c->unique(
{
Term2 => [ 'Term' ]
}
);
if (! $c->create()) {
$GT::SQL::errcode ||= ''; #silence -w, ugh.
$GT::SQL::errcode eq 'TBLEXISTS' ? ($message .= "Could not create table SearchLog (table already exists)\n") :
($error .= "Could not create table SearchLog: $GT::SQL::error)");
$c->set_defaults();
$c->save_schema();
};
my $c2 = $DB->creator('SearchLogDaily');
$c2->cols (
ID => { pos => 1, type => 'INT', not_null => 1, unsigned => 1, regex => '^\d+$' },
Term => { pos => 2, type => 'CHAR', size => '25', not_null => 1 },
HitCount => { pos => 3, type => 'SMALLINT', unsigned => 1, not_null => 1, default => 0 },
Results => { pos => 4, type => 'SMALLINT', unsigned => 1, not_null => 1, default => 0 },
Last_Hit => { pos => 5, type => 'DATE' },
Hit_Date => { pos => 6, type => 'DATE', not_null => 1, default =>'0000-00-00' },
TS => { pos => 7, type => 'TIMESTAMP' }
);
$c2->pk('ID');
$c2->ai('ID');
$c2->index (
{
# 'Term_Date' => ['Term','Hit_Date'],
'HitCount' => ['HitCount'],
'Last_Hit' => ['Last_Hit']
}
);
$c2->unique (
{
'Term_Date' => ['Term','Hit_Date']
}
);
if (! $c2->create()) {
$GT::SQL::errcode ||= ''; #silence -w, ugh.
$GT::SQL::errcode eq 'TBLEXISTS' ? ($message .= "Could not create table SearchLogDaily (table already exists)\n") :
($error .= "Could not create table SearchLogDaily: $GT::SQL::error)");
$c2->set_defaults();
$c2->save_schema();
};
$mgr->install_hooks ( 'SearchLogger', [ ['search_results', 'POST', 'Plugins::SearchLogger::log_query'] ]);
$mgr->install_menu ( 'SearchLogger', [
['View Totals Logs', 'admin.cgi?do=plugin&plugin=SearchLogger&func=view'],
['View Daily Logs', 'admin.cgi?do=plugin&plugin=SearchLogger&func=view_daily'],
['About', 'admin.cgi?do=plugin&plugin=SearchLogger&func=about']
] );
if ($error) {
$Plugins::SearchLogger::error ||= ''; #silence -w, ugh.
$Plugins::SearchLogger::error = $error;
return;
}
if ($message) {
return "The plugin has been installed, but there were the following warnings:
\n $message";
}
return "The plugin has been successfully installed!";
}
sub uninstall {
# -------------------------------------------------------------------
# This function removes the plugin. It's first argument is
# also a plugin manager which you can use to register hooks, install files,
# add menu options, etc. You should return an HTML formatted string
# that will be displayed to the user.
#
my $mgr = shift;
# my $e = $DB->editor('SearchLog');
# $e->drop_table();
$mgr->uninstall_hooks ( 'SearchLogger', [ ['search_results', 'POST', 'Plugins::SearchLogger::log_query'] ]);
$mgr->uninstall_menu ( 'SearchLogger', [ ['View Logs', 'admin.cgi?do=plugin&plugin=SearchLogger&func=view'] ] );
return "The plugin has been successfully removed!";
}
1;
SearchLogger.pm 0100644 0000764 0000770 00000035731 07234146604 012354 0 ustar 00alex cvs # ==================================================================
# Links SQL - enhanced directory management system
#
# Website : http://ultranerds.com/
# Support : http://ultranerds.com/forum
#
# Parts Copyright (c) 2000 Gossamer Threads Inc. All Rights Reserved.
# Modified by PUGDOG Enterprises, Inc. Parts Copyright 2000-2005
# Modified by UltraNerds
# ==================================================================
package Plugins::SearchLogger;
# ==================================================================
use strict;
use vars qw/$VERSION $DEBUG $NAME $FONT/;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$IN $DB $CFG/;
$VERSION = '3.0.0';
$DEBUG = 0;
$NAME = 'SearchLogger';
$FONT = 'font face="Tahoma,Arial,Helvetica" size="2"';
sub view {
# -------------------------------------------------------------------
# This is the admin view, it lets people search on keywords
# and purge old listings.
#
my $db = $DB->table('SearchLog');
my $days = $IN->param('days');
if (defined $days and $days =~ /^\d+$/) {
Links::init_date();
my $date = GT::Date::date_get (time - 86400 * $days);
if ($IN->param('total')) {
$db->delete ( GT::SQL::Condition->new ( 'Last_Hit', '<', $date) );
}
}
my $nh = $IN->param('nh') || 1;
my $mh = $IN->param('mh') || 25;
my $sth = $db->query_sth ($IN);
my $hits = $sth->rows;
my $tb = $DB->html($db,$IN)->toolbar ($nh, $mh, $hits, $IN->url);
my $output = qq~
|