function notifyUsers($userids, $prizeid, $winEmail, $winNot)
{
    foreach ($userids as $userid) {
        notifyUser($userid, $prizeid, $winEmail, $winNot);
        //echo $message;
        //sendContactEmail() // would go here if we were doing it that way
    }
}
if (!isset($_GET['mail'])) {
    // userids and prizeid passed in from console
    $userids = explode(',', $userids);
    showUsersToBeNotified($userids);
    $winEmail = new stdClass();
    $winNot = new stdClass();
    getTemplates(&$winEmail, &$winNot);
    showNotificationForm($userids, $prizeid, $winEmail, $winNot);
} else {
    $userids = explode(',', $_POST['userids']);
    $prizeid = $_POST['prizeid'];
    $mailObj->email = $_POST['to'];
    $mailObj->from = $_POST['from'];
    $mailObj->subject = $_POST['subject'];
    $mailObj->body = $_POST['body'];
    $mailObj->bcc = $_POST['bcc'];
    $notObj->fbId = $_POST['fbId'];
    $notObj->body = $_POST['notificationBody'];
    echo "Awarding " . implode(',', $userids) . "...<br/>";
    awardUsers($userids, $prizeid);
    echo "Notifying " . implode(',', $userids) . "...<br/>";
    notifyUsers($userids, $prizeid, $mailObj, $notObj);
}
Example #2
0
                $userEmail = "";
                $userName = "******";
                $name = "noName";
            }
            $moderators = $user->getModeratorsEmails();
            $usersToNotify = $user->getUsersToNotify($info["page"], $result['id']);
            // notify moderators
            if (defined('__MODERATE__') && !__MODERATE__) {
                // unmoderated list
                notifyUsers($userEmail, $info["page"], $result['id'], $info["text"], $userName, $info['product'], $usersToNotify);
                notifyModerators($result['id'], $info["page"], $info["text"], $userName, $name, $info['product'], $moderators);
            } else {
                // moderated list
                if ($user->level != 'user') {
                    // moderator or admin
                    notifyUsers($userEmail, $info["page"], $result['id'], $info["text"], $userName, $info['product'], $usersToNotify);
                } else {
                    // user
                    notifyModerators($result['id'], $info["page"], $info["text"], $userName, $name, $info['product'], $moderators);
                }
            }
            echo "Inserted comment!|" . $result['id'];
        } else {
            throw new Exception("Comment not inserted!");
            echo "Comment not inserted!";
        }
    }
} else {
    if (isset($_POST["minVersion"]) && trim($_POST["minVersion"]) != "") {
        $pName = isset($_POST['productName']) ? $_POST['productName'] : "";
        $minVersion = isset($_POST['minVersion']) ? $_POST['minVersion'] : "";
Example #3
0
function sendMail($subject, $to, $from, $message)
{
    if ($from == '' || $to == '') {
        return;
    }
    if (mail($to, $subject, $message, 'From: ' . $from . "\nContent-Type: text/html; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n")) {
        echo "<p>Sent a message to: {$to}</p>";
    } else {
        echo "<p>Could not send email</p>";
    }
}
function matchesToString($matches)
{
    $output = "<ul>";
    foreach ($matches as $match) {
        $output = $output . '<li><a href="' . SITE_URL . 'match/' . $match->getId() . '">' . $match->getTeamA()->getName() . ' - ' . $match->getTeamB()->getName() . '</a> (' . date('d-m-Y', $match->getDate()) . ')' . '</li>';
    }
    $output = $output . "</ul>";
    return $output;
}
function notifyUsers($time = 604800)
{
    $database = new Database();
    foreach ($database->getAllUsers() as $user) {
        $matches = $database->getUnbetMatches($user->getId(), $time);
        $message = '<p>Dear ' . $user->getUserName() . ', you haven\'t yet placed any bets for the following upcoming events. Don\'t forget to take your chance!</p>' . matchesToString($matches) . '<p>Greetings, the ZeeJong team.</p>';
        sendMail('ZeeJong - Upcoming Events', $user->getMail(), '*****@*****.**', $message);
    }
}
notifyUsers();