summaryrefslogtreecommitdiff
path: root/sqlgrey/includes
diff options
context:
space:
mode:
Diffstat (limited to 'sqlgrey/includes')
-rw-r--r--sqlgrey/includes/awl.inc.php64
-rw-r--r--sqlgrey/includes/config.inc.php41
-rw-r--r--sqlgrey/includes/connect.inc.php50
-rw-r--r--sqlgrey/includes/copyright.inc.php28
-rw-r--r--sqlgrey/includes/functions.inc.php132
-rw-r--r--sqlgrey/includes/opt_in_out.inc.php31
6 files changed, 346 insertions, 0 deletions
diff --git a/sqlgrey/includes/awl.inc.php b/sqlgrey/includes/awl.inc.php
new file mode 100644
index 0000000..5fbc3c9
--- /dev/null
+++ b/sqlgrey/includes/awl.inc.php
@@ -0,0 +1,64 @@
+<?php
+
+/***************************************************
+SQLgrey Web Interface
+Filename: awl.inc.php
+Purpose: Functions for awl.php (whitelists)
+Version: 1.1.6
+****************************************************/
+
+function add_sender($mode, $sendername, $senderdomain, $src) {
+ global $added;
+ if ($mode == "email") {
+ if ($sendername == '' || $senderdomain == '' || $src == '') {
+ $added = "<br />WARNING: Insufficient data - nothing was added !";
+ } else {
+ $query = "INSERT INTO from_awl(sender_name, sender_domain, src, first_seen, last_seen)
+ VALUES('".addslashes($sendername)."', '".addslashes($senderdomain)."', '".addslashes($src)."', now(), now())";
+ $added = "<br />E-mail address ".$sendername."@".$senderdomain." (".$src.") added.";
+ do_query($query);
+ }
+ } else {
+ if ($senderdomain == '' || $src == '') {
+ $added = "<br />WARNING: Insufficient data - nothing was added!";
+ } else {
+ $query = "INSERT INTO domain_awl(sender_domain, src, first_seen, last_seen)
+ VALUES('".addslashes($senderdomain)."', '".addslashes($src)."', now(), now())";
+ $added = "<br />Domain ".$senderdomain." (".$src.") added.";
+ do_query($query);
+ }
+ }
+}
+
+function delete_undef($mode) {
+ global $message;
+ if ($mode == "email") {
+ $query_cnt = "SELECT COUNT(*) AS count FROM from_awl WHERE sender_name='-undef-' AND sender_domain='-undef-'";
+ $query = "DELETE FROM from_awl WHERE sender_name='-undef-' AND sender_domain='-undef-'";
+ } else {
+ $query_cnt = "SELECT COUNT(*) AS count FROM domain_awl WHERE sender_domain='-undef-'";
+ $query = "DELETE FROM domain_awl WHERE sender_domain='-undef-'";
+ }
+ $result = do_query($query_cnt);
+ $n = fetch_row($result);
+ if ($n["count"] > 0) {
+ do_query($query);
+ $message = '<br />-undef- entries ('.$n["count"].') deleted.';
+ } else {
+ $message = "<br />No -undef- entries found - nothing was deleted.";
+ }
+}
+
+function delete_entry($mode, $sendername, $senderdomain, $src) {
+ global $deleted;
+ if ($mode == "email") {
+ $query = "DELETE FROM from_awl WHERE sender_name='".addslashes($sendername)."' AND sender_domain='".addslashes($senderdomain)."' AND src='".addslashes($src)."'";
+ $deleted .= "<br />".$sendername."@".$senderdomain." (".$src.") deleted.";
+ } else {
+ $query = "DELETE FROM domain_awl WHERE sender_domain='".addslashes($senderdomain)."' AND src='".addslashes($src)."'";
+ $deleted .= "<br />".$senderdomain." (".$src.") deleted.";
+ }
+ do_query($query);
+}
+
+?> \ No newline at end of file
diff --git a/sqlgrey/includes/config.inc.php b/sqlgrey/includes/config.inc.php
new file mode 100644
index 0000000..a18caa0
--- /dev/null
+++ b/sqlgrey/includes/config.inc.php
@@ -0,0 +1,41 @@
+<?php
+
+/***************************************************
+SQLgrey Web Interface
+Filename: config.inc.php
+Purpose: Configuration database and options
+Version: 1.1.6
+****************************************************/
+
+/* Database settings */
+$db_db = "ccwn_sqlgrey";
+$db_hostname = "database";
+$db_user = "sqlgrey";
+$db_pass = "YfDWm3PzTR35QWuD";
+$db_type = "mysql"; // mysql or pg (pg=postgress)
+
+/* Set close_btn to 'yes' to enable the close button in index.php (main menu)
+ the button action = ../ which could be a security issue
+ default = no
+*/
+$close_btn = "no";
+
+/* Set no_millisecs to 'no' if your server's dbase shows milliseconds
+ and you do want these to be displayed - this will take two lines per entry.
+ Also set this to 'no' if you encounter problems with displaying the timestamps
+ ('no' used to be the default and leaves the date format untouched).
+ When set to 'yes' timestamps will be formatted as 'yyyy-mm-dd hh:mm:ss'
+ which doubles the amount of visible entries.
+ default = yes
+*/
+$no_millisecs = "yes";
+
+/* Depending on your PHP version you may have to set default timezone to avoid warnings.
+ Remove the comment (//) and change the default to your region.
+ See http://www.php.net/manual/en/timezones.php to determine the syntax of your region.
+ Examples are: 'America/Los_Angeles', 'Europe/Berlin' etc.
+ default = 'UTC'
+*/
+//date_default_timezone_set('UTC');
+
+?>
diff --git a/sqlgrey/includes/connect.inc.php b/sqlgrey/includes/connect.inc.php
new file mode 100644
index 0000000..d72a674
--- /dev/null
+++ b/sqlgrey/includes/connect.inc.php
@@ -0,0 +1,50 @@
+<?php
+
+/***************************************************
+SQLgrey Web Interface
+Filename: connect.inc.php
+Purpose: Functions for connect.php (greylist)
+Version: 1.1.6
+****************************************************/
+
+function forget_entry($sendername, $senderdomain, $src, $rcpt) {
+ global $deleted;
+ $query = "DELETE FROM connect WHERE sender_name='".addslashes($sendername)."' AND sender_domain='".addslashes($senderdomain)."' AND src='".addslashes($src)."' AND rcpt='".addslashes($rcpt)."'";
+ do_query($query);
+ $deleted .= '<br />'.$sendername.'@'.$senderdomain.' ['.$src.'] for '.$rcpt.' deleted.';
+}
+
+function move_entry($sendername, $senderdomain, $src, $rcpt) {
+ global $moved;
+ $query = "SELECT first_seen FROM connect WHERE sender_name='".addslashes($sendername)."' AND sender_domain='".addslashes($senderdomain)."' AND src='".addslashes($src)."' AND rcpt='".addslashes($rcpt)."'";
+ $result = do_query($query);
+ $line = fetch_row($result);
+ # add to 'from_awl'
+ $query = "INSERT INTO from_awl(sender_name, sender_domain, src, first_seen, last_seen) VALUES('".
+ addslashes($sendername)."', '".
+ addslashes($senderdomain)."', '".
+ addslashes($src)."', '".
+ $line["first_seen"]."', '".
+ $line["first_seen"]."')";
+ do_query($query);
+ # and remove from 'connect'
+ $query = "DELETE FROM connect WHERE sender_name='".addslashes($sendername)."' AND sender_domain='".addslashes($senderdomain)."' AND src='".addslashes($src)."' AND rcpt='".addslashes($rcpt)."'";
+ do_query($query);
+ $moved .= '<br />'.$sendername.'@'.$senderdomain.' ['.$src.'] for '.$rcpt.' moved to whitelist.';
+}
+
+function del_older_than($year, $month, $day, $hour, $minute, $seconds, $err) {
+ global $warning, $message;
+ if ($err) {
+ $warning = "Aborted: invalid date.";
+ } else {
+ $nicedate = $year.'-'.substr("00".$month, -2, 2).'-'.substr("00".$day, -2, 2).' '.substr("00".$hour, -2, 2).':'.substr("00".$minute, -2, 2).':'.substr("00".$seconds, -2, 2);
+ $query = "DELETE FROM connect WHERE first_seen < ".$year.substr("00".$month, -2, 2).substr("00".$day, -2, 2).substr("00".$hour, -2, 2).substr("00".$minute, -2, 2).substr("00".$seconds, -2, 2);
+ do_query($query);
+ $message = 'Entries older than '.$nicedate.' deleted.';
+ $warning = "<br />Sorting set to &#39;Seen at&#39; (ascending).";
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/sqlgrey/includes/copyright.inc.php b/sqlgrey/includes/copyright.inc.php
new file mode 100644
index 0000000..c6d2524
--- /dev/null
+++ b/sqlgrey/includes/copyright.inc.php
@@ -0,0 +1,28 @@
+<?php
+
+/***************************************************
+SQLgrey Web Interface
+Filename: copyright.inc.php
+Purpose: Inserting copyright notice
+Version: 1.1.6
+
+ *** Please do not alter these references! ***
+
+****************************************************/
+
+?>
+<table width="100%" summary="footer">
+ <tr>
+ <td>
+ <hr />
+ <font size="-1">
+ <a href="http://www.vanheusden.com/sgwi/" target="_blank">SQLGrey webinterface v 1.1.6</a>
+ by
+ <a href="http://www.vanheusden.com/feedbackform.php?subject=SQLGrey%20webinterface" target="_blank">folkert@vanheusden.com</a>
+ and Jan Ceulen |
+ <a href="http://www.beebeec.nl/sgwi/" target="_blank">BeeBeeC</a>
+ </font>
+ <hr />
+ </td>
+ </tr>
+</table> \ No newline at end of file
diff --git a/sqlgrey/includes/functions.inc.php b/sqlgrey/includes/functions.inc.php
new file mode 100644
index 0000000..cf5933e
--- /dev/null
+++ b/sqlgrey/includes/functions.inc.php
@@ -0,0 +1,132 @@
+<?php
+
+/***********************************************************
+SQLgrey Web Interface
+Filename: awl.inc.php
+Purpose: Database and navigation and other functions
+Version: 1.1.6
+************************************************************/
+
+require "config.inc.php";
+
+// Globally used phrases.
+
+$dom_out = 'domains of recipients for whom messages are never greylisted';
+$email_out = 'e-mail addresses of recipients for whom messages are never greylisted';
+$dom_in = 'domains of recipients for whom messages are always greylisted unless they are in the optout domain table';
+$email_in = 'e-mail addresses of recipients for whom messages are always greylisted unless they are in the optout e-mail table';
+
+
+// Database functions.
+
+function do_query($query) {
+ global $db_hostname, $db_user, $db_pass, $db_db, $db_type;
+ /* Connecting, selecting database */
+ if ($db_type == "mysql") {
+ $link = mysql_connect($db_hostname, $db_user, $db_pass) or die("Could not connect to database");
+ mysql_select_db($db_db) or die("Could not select database");
+
+ $result = mysql_query($query) or die("Query failed");
+
+ /* Closing connection */
+ mysql_close($link);
+ } else {
+ $link = pg_connect("host=$db_hostname dbname=$db_db user=$db_user password=$db_pass") or die("Could not connect to database");
+
+ $result = pg_query($link, $query) or die("Query failed");
+
+ /* Closing connection */
+ pg_close($link);
+ }
+ return $result;
+}
+
+function fetch_row($result) {
+ global $db_type;
+ if ($db_type == "mysql") {
+ return mysql_fetch_array($result, MYSQL_ASSOC);
+ } else {
+ return pg_fetch_assoc($result);
+ }
+}
+
+
+// Navigation functions.
+
+function shownav($colour, $mode, $direction, $what) {
+ // Menubar setup for all pages
+ global $dom_out, $email_out, $dom_in, $email_in;
+ if ($colour == 'white') {
+ // only awl.php
+ echo ('
+ <ul id="navlist">
+ <li><a href="index.php">Main menu</a></li>
+ <li><a href="connect.php" title="hosts/domains that are currently greylisted">Waiting (greylist)</a></li>
+ <li><a href="awl.php?mode=email"'.is_active1("email", $mode).
+ 'title="auto-whitelisted e-mailadresses (that have passed greylisting)">E-mail addresses</a></li>
+ <li><a href="awl.php?mode=domains"'.is_active1('domains', $mode).
+ 'title="auto-whitelisted domains (that have passed greylisting)">Domains</a></li>
+ <li><a href="opt_in_out.php?direction=out&amp;what=domain" title="&nbsp;'.$dom_out.'">Optout domain</a></li>
+ <li><a href="opt_in_out.php?direction=out&amp;what=email" title="&nbsp;'.$email_out.'">Optout e-mail</a></li>
+ <li><a href="opt_in_out.php?direction=in&amp;what=domain" title="&nbsp;'.$dom_in.'">Optin domain</a></li>
+ <li><a href="opt_in_out.php?direction=in&amp;what=email" title="&nbsp;'.$email_in .'">Optin e-mail</a></li>
+ </ul>
+ ');
+ } else {
+ // index and connect (with dummies) and opt_in_out.
+ echo ('
+ <ul id="navlist">
+ <li><a href="index.php"'.is_active2("ind", $direction, "ind", $what).'>Main menu</a></li>
+ <li><a href="connect.php"'.is_active2("con", $direction, "con", $what).
+ 'title="hosts/domains that are currently greylisted">Waiting (greylist)</a></li>
+ <li><a href="awl.php?mode=email" title="auto-whitelisted e-mailadresses (that have passed greylisting)">E-mail addresses</a></li>
+ <li><a href="awl.php?mode=domains" title="auto-whitelisted domains (that have passed greylisting)">Domains</a></li>
+ <li><a href="opt_in_out.php?direction=out&amp;what=domain"'.is_active2("out", $direction, "domain", $what).' title="'.$dom_out.'">Optout domain</a></li>
+ <li><a href="opt_in_out.php?direction=out&amp;what=email"'.is_active2("out", $direction, "email", $what).' title="'.$email_out.'">Optout e-mail</a></li>
+ <li><a href="opt_in_out.php?direction=in&amp;what=domain"'.is_active2('in',$direction,'domain',$what).' title="'.$dom_in.'">Optin domain</a></li>
+ <li><a href="opt_in_out.php?direction=in&amp;what=email"'.is_active2('in',$direction,'email',$what).' title="'.$email_in.'">Optin e-mail</a></li>
+ </ul>
+ ');
+ }
+}
+
+function is_active1($mode, $get) {
+ // For awl menubar items - sets item active.
+ if ($mode == $get) {
+ return ' id="current" ';
+ } else {
+ return ' ';
+ }
+}
+
+function is_active2($direction, $getdir, $what, $getwhat) {
+ // For index, connect and opt_in_out menubar items - sets item active.
+ if (($direction == $getdir) && ($what == $getwhat)) {
+ return ' id="current" ';
+ } else {
+ return ' ';
+ }
+}
+
+
+// Other functions.
+
+function shorten_it($sendername, $nr) {
+ // For managing the width of the Sender name, Sender domain and Recipient columns.
+ if (strlen($sendername) > $nr) {
+ $sendername = substr($sendername, 0, $nr ).'<b>...</b>';
+ }
+ return $sendername;
+}
+
+function strip_millisecs($ts) {
+ // Formats timestamp without milliseconds.
+ global $no_millisecs;
+ if ($no_millisecs == "yes") {
+ $ts = date_create($ts);
+ $ts = date_format($ts, 'Y-m-d H:i:s');
+ }
+ return $ts;
+}
+
+?> \ No newline at end of file
diff --git a/sqlgrey/includes/opt_in_out.inc.php b/sqlgrey/includes/opt_in_out.inc.php
new file mode 100644
index 0000000..236687f
--- /dev/null
+++ b/sqlgrey/includes/opt_in_out.inc.php
@@ -0,0 +1,31 @@
+<?php
+
+/**************************************
+SQLgrey Web Interface
+Filename: opt_in_out.inc.php
+Purpose: Opt in/out functions
+Version: 1.1.6
+***************************************/
+
+ if ($_GET["direction"] == "out") {
+ $title = "Opt-out";
+ $helptag_dir = "<br />(recipients for whom messages are never greylisted)";
+ $table = "optout_";
+ } else {
+ $title = "Opt-in";
+ $helptag_dir = "<br />(recipients for whom messages are always greylisted unless they are in the ";
+ $table = "optin_";
+ }
+
+ if ($_GET["what"] == "domain") {
+ $title .= " domains";
+ $helptag_what = "optout domain table)";
+ $table .= "domain";
+ $field = "domain";
+ } else {
+ $title .= " e-mail addresses";
+ $helptag_what = "optout e-mail table)";
+ $table .= "email";
+ $field = "email";
+ }
+?> \ No newline at end of file