--- rpms/smeserver-mailstats/contribs7/smeserver-mailstats-0.0.3-implementDBCreation.patch 2008/10/04 08:46:59 1.1 +++ rpms/smeserver-mailstats/contribs7/smeserver-mailstats-0.0.3-implementDBCreation.patch 2008/10/11 23:29:50 1.2 @@ -1,237 +1,11 @@ ---- smeserver-mailstats-0.0.3/root/usr/bin/spamfilter-stats-7.pl.implementDBCreation 2008-10-04 10:25:00.000000000 +0200 -+++ smeserver-mailstats-0.0.3/root/usr/bin/spamfilter-stats-7.pl 2008-10-04 10:36:33.000000000 +0200 -@@ -115,155 +115,6 @@ - # / Interval - "day", "week", "fortnight", "month", "99999" - last is number of seconds (default is day) - # / Base - "Midnight", "Midday", "Now", "99" hour (0-23) (default is midnight) - # --############################################################################# --# --# Table structure for MySQL table for saving data --# --# Database : `mailstats` --# --# use mailstats; --# -------------------------------------------------------- -- --# --# Table structure for table `ColumnStats` --# --# --#CREATE TABLE `ColumnStats` ( --# `ColumnStatsid` int(11) NOT NULL auto_increment, --# `dateid` int(11) NOT NULL default '0', --# `timeid` int(11) NOT NULL default '0', --# `descr` varchar(20) NOT NULL default '', --# `count` bigint(20) NOT NULL default '0', --# `servername` varchar(30) NOT NULL default '', --# PRIMARY KEY (`ColumnStatsid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --# -------------------------------------------------------- -- --# --# Table structure for table `JunkMailStats` --# -- --#CREATE TABLE `JunkMailStats` ( --# `JunkMailstatsid` int(11) NOT NULL auto_increment, --# `dateid` int(11) NOT NULL default '0', --# `user` varchar(12) NOT NULL default '', --# `count` bigint(20) NOT NULL default '0', --# `servername` varchar(30) default NULL, --# PRIMARY KEY (`JunkMailstatsid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; --# --# -------------------------------------------------------- -- --# --# Table structure for table `SARules` --# -- --#CREATE TABLE `SARules` ( --# `SARulesid` int(11) NOT NULL auto_increment, --# `dateid` int(11) NOT NULL default '0', --# `rule` varchar(50) NOT NULL default '', --# `count` bigint(20) NOT NULL default '0', --# `totalhits` bigint(20) NOT NULL default '0', --# `servername` varchar(30) NOT NULL default '', --# PRIMARY KEY (`SARulesid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --# -------------------------------------------------------- -- --# --# Table structure for table `SAscores` --# -- --#CREATE TABLE `SAscores` ( --# `SAscoresid` int(11) NOT NULL auto_increment, --# `dateid` int(11) NOT NULL default '0', --# `acceptedcount` bigint(20) NOT NULL default '0', --# `rejectedcount` bigint(20) NOT NULL default '0', --# `hamcount` bigint(20) NOT NULL default '0', --# `acceptedscore` decimal(20,2) NOT NULL default '0.00', --# `rejectedscore` decimal(20,2) NOT NULL default '0.00', --# `hamscore` decimal(20,2) NOT NULL default '0.00', --# `totalsmtp` bigint(20) NOT NULL default '0', --# `totalrecip` bigint(20) NOT NULL default '0', --# `servername` varchar(30) NOT NULL default '', --# PRIMARY KEY (`SAscoresid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --# -------------------------------------------------------- -- --# --# Table structure for table `VirusStats` --# -- --#CREATE TABLE `VirusStats` ( --# `VirusStatsid` int(11) NOT NULL auto_increment, --# `dateid` int(11) NOT NULL default '0', --# `descr` varchar(40) NOT NULL default '', --# `count` bigint(20) NOT NULL default '0', --# `servername` varchar(30) NOT NULL default '', --# PRIMARY KEY (`VirusStatsid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; --# --# -------------------------------------------------------- -- --# --# Table structure for table `date` --# -- --#CREATE TABLE `date` ( --# `dateid` int(11) NOT NULL auto_increment, --# `date` date NOT NULL default '0000-00-00', --# PRIMARY KEY (`dateid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; --# --# -------------------------------------------------------- -- --# --# Table structure for table `domains` --# -- --#CREATE TABLE `domains` ( --# `domainsid` int(11) NOT NULL auto_increment, --# `dateid` int(11) NOT NULL default '0', --# `domain` varchar(40) NOT NULL default '', --# `type` varchar(10) NOT NULL default '', --# `total` bigint(20) NOT NULL default '0', --# `denied` bigint(20) NOT NULL default '0', --# `xfererr` bigint(20) NOT NULL default '0', --# `accept` bigint(20) NOT NULL default '0', --# `servername` varchar(30) NOT NULL default '', --# PRIMARY KEY (`domainsid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --# -------------------------------------------------------- -- --# --# Table structure for table `qpsmtpdcodes` --# -- --#CREATE TABLE `qpsmtpdcodes` ( --# `qpsmtpdcodesid` int(11) NOT NULL auto_increment, --# `dateid` int(11) NOT NULL default '0', --# `reason` varchar(40) NOT NULL default '', --# `count` bigint(20) NOT NULL default '0', --# `servername` varchar(30) NOT NULL default '', --# PRIMARY KEY (`qpsmtpdcodesid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --# -------------------------------------------------------- -- --# --# Table structure for table `time` --# -- --#CREATE TABLE `time` ( --# `timeid` int(11) NOT NULL auto_increment, --# `time` time NOT NULL default '00:00:00', --# PRIMARY KEY (`timeid`) --#) ENGINE=MyISAM DEFAULT CHARSET=latin1; --# --############################################################################# - - # internal modules (part of core perl distribution) - use strict; -@@ -1361,7 +1212,7 @@ - # now fill in day related stats - must always check for it already there - # incase the module is run more than once in a day - my $SAScoresid = check_date_rec($dbh,"SAscores",$dateid,$servername); -- $dbh->do( "UPDATE SAscores SET ". -+ $dbh->do( "UPDATE sascores SET ". - "acceptedcount=".$spamcount. - ",rejectedcount=".$above15. - ",hamcount=".$hamcount. -@@ -1374,19 +1225,19 @@ - "' WHERE SAscoresid =".$SAScoresid); - # Junkmail stats - # delete if already there -- $dbh->do("DELETE from JunkMailStats WHERE dateid = ".$dateid." AND servername='".$servername."'"); -+ $dbh->do("DELETE from junkmailstats WHERE dateid = ".$dateid." AND servername='".$servername."'"); - # and add records - foreach my $thisuser (keys %junkcount){ -- $dbh->do("INSERT INTO JunkMailStats (dateid,user,count,servername) VALUES ('". -+ $dbh->do("INSERT INTO junkmailstats (dateid,user,count,servername) VALUES ('". - $dateid."','".$thisuser."','".$junkcount{$thisuser}."','".$servername."')"); - $reccount++; - } - #SA rules - delete any first -- $dbh->do("DELETE from SARules WHERE dateid = ".$dateid." AND servername='".$servername."'"); -+ $dbh->do("DELETE from sarules WHERE dateid = ".$dateid." AND servername='".$servername."'"); - # and add records - foreach my $thisrule (keys %found_SARules){ -- $dbh->do("INSERT INTO SARules (dateid,rule,count,totalhits,servername) VALUES ('". -- $dateid."','".$thisrule."','".$found_SARules{$thisrule}{'count'}."','". -+ $dbh->do("INSERT INTO sarules (dateid,rule,count,totalhits,servername) VALUES ('". -+ $dateid."','".$thisrule."','".$found_sarules{$thisrule}{'count'}."','". - $found_SARules{$thisrule}{'totalhits'}."','".$servername."')"); - $reccount++; - } -@@ -1399,10 +1250,10 @@ - $reccount++; - } - # virus stats -- $dbh->do("DELETE from VirusStats WHERE dateid = ".$dateid." AND servername='".$servername."'"); -+ $dbh->do("DELETE from virusstats WHERE dateid = ".$dateid." AND servername='".$servername."'"); - # and add records - foreach my $thisvirus (keys %found_viruses){ -- $dbh->do("INSERT INTO VirusStats (dateid,descr,count,servername) VALUES ('". -+ $dbh->do("INSERT INTO virusstats (dateid,descr,count,servername) VALUES ('". - $dateid."','".$thisvirus."','".$found_viruses{$thisvirus}."','".$servername."')"); - $reccount++; - -@@ -1453,17 +1304,17 @@ - $reportdate = $currentdate; - } - # delete for this date and time -- $dbh->do("DELETE from ColumnStats WHERE dateid = ".$dateid." AND timeid = ".$timeid." AND servername='".$servername."'"); -+ $dbh->do("DELETE from columnstats WHERE dateid = ".$dateid." AND timeid = ".$timeid." AND servername='".$servername."'"); - while ( $ncateg < @categs-1 ) { - # then add in each entry - if (($counts{$nhour}{$categs[$ncateg]} || 0) != 0) { -- $dbh->do("INSERT INTO ColumnStats (dateid,timeid,descr,count,servername) VALUES (" -+ $dbh->do("INSERT INTO columnstats (dateid,timeid,descr,count,servername) VALUES (" - .$dateid.",".$timeid.",'".$categs[$ncateg]."'," - .$counts{$nhour}{$categs[$ncateg]}.",'".$servername."')"); - $reccount++; - } - --# print("INSERT INTO ColumnStats (dateid,timeid,descr,count) VALUES (" -+# print("INSERT INTO columnstats (dateid,timeid,descr,count) VALUES (" - # .$dateid.",".$timeid.",'".$categs[$ncateg]."'," - # .$counts{$nhour}{$categs[$ncateg]}.")\n"); - ---- smeserver-mailstats-0.0.3/root/etc/e-smith/templates/etc/e-smith/sql/mailstats-create-schema.sql.implementDBCreation 2008-10-04 10:26:03.000000000 +0200 -+++ smeserver-mailstats-0.0.3/root/etc/e-smith/templates/etc/e-smith/sql/mailstats-create-schema.sql 2008-10-04 10:30:51.000000000 +0200 -@@ -0,0 +1,90 @@ -+IF NOT EXISTS CREATE DATABASE `mailstats`; +--- smeserver-mailstats-0.0.3/root/etc/e-smith/templates/etc/e-smith/sql/init/smeserver-mailstats.sql.implementDBCreation 2008-10-12 01:05:19.000000000 +0200 ++++ smeserver-mailstats-0.0.3/root/etc/e-smith/templates/etc/e-smith/sql/init/smeserver-mailstats.sql 2008-10-12 01:05:19.000000000 +0200 +@@ -0,0 +1,91 @@ ++CREATE DATABASE IF NOT EXISTS `mailstats`; + +USE `mailstats`; + -+IF NOT EXISTS CREATE TABLE `columnstats` ( ++CREATE TABLE IF NOT EXISTS `ColumnStats` ( + `ColumnStatsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `timeid` int(11) NOT NULL default '0', @@ -241,16 +15,16 @@ + PRIMARY KEY (`ColumnStatsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `junkmailstats` ( ++CREATE TABLE IF NOT EXISTS `JunkMailStats` ( + `JunkMailstatsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', -+ `user` varchar(12) NOT NULL default '', ++ `user` varchar(12) NOT NULL default '', + `count` bigint(20) NOT NULL default '0', + `servername` varchar(30) default NULL, + PRIMARY KEY (`JunkMailstatsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `sarules` ( ++CREATE TABLE IF NOT EXISTS `SARules` ( + `SARulesid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `rule` varchar(50) NOT NULL default '', @@ -260,7 +34,7 @@ + PRIMARY KEY (`SARulesid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `sascores` ( ++CREATE TABLE IF NOT EXISTS `SAscores` ( + `SAscoresid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `acceptedcount` bigint(20) NOT NULL default '0', @@ -275,7 +49,7 @@ + PRIMARY KEY (`SAscoresid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `virusstats` ( ++CREATE TABLE IF NOT EXISTS `VirusStats` ( + `VirusStatsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `descr` varchar(40) NOT NULL default '', @@ -284,13 +58,14 @@ + PRIMARY KEY (`VirusStatsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `date` ( ++CREATE TABLE IF NOT EXISTS `date` ( + `dateid` int(11) NOT NULL auto_increment, + `date` date NOT NULL default '0000-00-00', + PRIMARY KEY (`dateid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `domains` ( ++ ++CREATE TABLE IF NOT EXISTS `domains` ( + `domainsid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `domain` varchar(40) NOT NULL default '', @@ -303,7 +78,7 @@ + PRIMARY KEY (`domainsid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `qpsmtpdcodes` ( ++CREATE TABLE IF NOT EXISTS `qpsmtpdcodes` ( + `qpsmtpdcodesid` int(11) NOT NULL auto_increment, + `dateid` int(11) NOT NULL default '0', + `reason` varchar(40) NOT NULL default '', @@ -312,8 +87,12 @@ + PRIMARY KEY (`qpsmtpdcodesid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + -+IF NOT EXISTS CREATE TABLE `time` ( ++CREATE TABLE IF NOT EXISTS `time` ( + `timeid` int(11) NOT NULL auto_increment, + `time` time NOT NULL default '00:00:00', + PRIMARY KEY (`timeid`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +--- smeserver-mailstats-0.0.3/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/smeserver-mailstats.sql.implementDBCreation 2008-10-12 00:54:31.000000000 +0200 ++++ smeserver-mailstats-0.0.3/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/smeserver-mailstats.sql 2008-10-12 00:55:01.000000000 +0200 +@@ -0,0 +1 @@ ++PERMS=0540