blob: f52d16721b25f10215c7f3c3937149aea90afd9c (
plain)
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
|
<?php
include_once($UTIL_DIR . "/error.php");
include_once($UTIL_DIR . "/log.php");
/**
* CONFIG
*/
$subject_prefix = "DIE CMS notifier";
$sender = "DIE <info@executionroom.com>";
$replyto = $sender;
$footer = "
Stay Brutal!
// DIE
http://www.executionroom.com
info@executionroom.com
";
function send($email, $subject, $message)
{
global $subject_prefix;
global $sender;
global $replyto;
global $footer;
$message .= $footer;
// $message .= "";
$headers = "From: " . $sender . "\r\n";
$headers .= "Reply-To: " . $replyto . "\r\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
$subject = "[".$subject_prefix."] " . utf8_decode($subject);
$ret = mail($email, $subject, utf8_decode($message), $headers);
if(!$ret) echo error("The mail to " . $email . "could not be sent.");
}
function notify($module = "", $event = "")
{
global $users;
global $current_user;
$users_changed = false;
foreach($users->users as $user) {
if($user->uid == 0) continue; // Don't notify the admin
if($user->enabled == false) continue; // Do not mail disabled accounts.
if($module == "calendar" || // Always mail calendar updates.
(
$module == "forum" &&
$user != $current_user && // Don't notify current user.
$user->notified < (time() - (60 * 60 * 24 * 7)) // Don't notify if already notified.
)
) {
send($user->email, $module . " changed",
"There has been a change in the " . $module . " module by " .
$current_user->name . ":\n" . $event);
_log($user->username, "notified (" . $module . ")");
if($module != "calendar") {
$user->notified = time();
$users_changed = true;
}
}
}
if($users_changed == true) $users->write();
}
?>
|