1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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&what=domain" title=" '.$dom_out.'">Optout domain</a></li>
<li><a href="opt_in_out.php?direction=out&what=email" title=" '.$email_out.'">Optout e-mail</a></li>
<li><a href="opt_in_out.php?direction=in&what=domain" title=" '.$dom_in.'">Optin domain</a></li>
<li><a href="opt_in_out.php?direction=in&what=email" title=" '.$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&what=domain"'.is_active2("out", $direction, "domain", $what).' title="'.$dom_out.'">Optout domain</a></li>
<li><a href="opt_in_out.php?direction=out&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&what=domain"'.is_active2('in',$direction,'domain',$what).' title="'.$dom_in.'">Optin domain</a></li>
<li><a href="opt_in_out.php?direction=in&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;
}
?>
|