The only thing a person would have to do is create a new table in the ME database called mero, and change the connection string. Other than that, all the old rules apply.
To add the new table to your ME database use the following code:
Code: Select all
CREATE TABLE mero(
id int IDENTITY(1,1) NOT NULL,
mode int NOT NULL,
addressmask varchar(15) NOT NULL,
status int NOT NULL,
account varchar(50) NOT NULL,
accessright varchar(50)NOT NULL,
threat int NOT NULL,
date_mod smalldatetime NOT NULL,
date_create smalldatetime NOT NULL,
CONSTRAINT [PK_mero] PRIMARY KEY CLUSTERED (id ASC) ON [PRIMARY]
)
This is the modified mero VBS script:
Code: Select all
Option Explicit
Private Const lMaxDel = 100
Dim Conn 'As Connection
Dim rs 'As Recordset
Dim i 'As Long
Set Conn = WScript.CreateObject("ADODB.Connection")
Set rs = WScript.CreateObject("ADODB.RecordSet")
Conn.Open "Provider=SQLOLEDB.1;Server=your_server;Database=me_database;Integrated Security=SSPI;"
Conn.Execute "UPDATE m SET m.threat = ABS(m.threat - (CASE WHEN m.threat < 1 THEN 1 ELSE 0 END)), m.date_mod = GETDATE() FROM mero m JOIN smtp_access s ON s.addressmask = m.addressmask"
Conn.Execute "INSERT INTO mero (mode, addressmask, status, account, accessright, threat, date_mod, date_create) SELECT mode, addressmask, status, account, accessright, 1, GETDATE(), GETDATE() FROM smtp_access WHERE addressmask NOT IN (SELECT addressmask FROM mero)"
Conn.Execute "DELETE FROM mero WHERE date_mod < DateAdd(d, -90, GETDATE()) AND threat < 0"
Conn.Execute "UPDATE mero SET threat = (CASE WHEN threat < 5 THEN 0 - threat ELSE threat END), date_mod = GETDATE() WHERE DateDiff(d, DateAdd(d, 1, GETDATE()), date_create) % 60 = 0 AND threat < 5"
rs.Open "SELECT COUNT(id) AS rcount FROM mero WHERE threat > 0 AND threat < 5", Conn, 0, 1
i = CLng(rs("rcount") * 0.9)
rs.Close
If lMaxDel < i Then i = lMaxDel
Conn.Execute "DELETE FROM smtp_access"
Conn.Execute "INSERT INTO smtp_access (mode, addressmask, status, account, accessright) SELECT mode, addressmask, status, account, accessright FROM (SELECT addressmask, mode, account, accessright, status, threat, date_mod FROM mero WHERE threat > 4 UNION ALL SELECT TOP " & i & " addressmask, mode, account, accessright, status, threat, date_mod FROM mero WHERE threat > 0 AND threat < 5) AS temp ORDER BY threat DESC, date_mod, addressmask"
Conn.Execute "UPDATE mero SET threat = (CASE WHEN threat < 0 THEN threat ELSE 0 - threat END) WHERE addressmask NOT IN (SELECT addressmask FROM smtp_access)"
Conn.Close
Set rs = Nothing
Set Conn = Nothing