if ($_SERVER['LOGNAME'] == 'safeballots') { set_include_path($_SERVER['PWD'] . '/httpdocs/'); date_default_timezone_set('America/Halifax'); include_once 'core/Database.php'; include_once 'modules/Campaigns/include/Campaign.php'; include_once 'modules/Campaigns/include/CampaignUser.php'; include_once 'include/Site.php'; $sql = 'SELECT id FROM campaigns where autosend = 1'; $debug = false; if (@$argv[1] == 'debug') { $debug = true; } $results = Database::singleton()->query_fetch_all($sql); foreach ($results as &$campaign) { $campaign = new Campaign($campaign['id']); switch ($campaign->calcStatus(true)) { case 2: break; case 1: $sql = 'SELECT aut_email FROM auth WHERE aut_agp_id = ' . $campaign->getGroup() . ' LIMIT 1'; $email = Database::singleton()->query_fetch($sql); $email = $email['aut_email']; $sql = 'SELECT agp_name FROM auth_groups WHERE agp_id = ' . $campaign->getGroup(); $group = Database::singleton()->query_fetch($sql); $group = $group['agp_name']; $campaign->mailOut('votes', $group, $email); if ($debug) { echo "Sent " . $campaign->getName() . " emails.\n"; } default: $sql = 'UPDATE campaigns SET autosend = 0 WHERE id = ' . $campaign->getId();
public static function getByEmail($addr) { if (eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\\.([a-zA-Z]{2,4})$', $addr)) { $sql = 'SELECT id FROM campaign_recipients WHERE email = \'' . e($addr) . "'"; $result = Database::singleton()->query_fetch_all($sql); if ($result && count($result) == 1) { $id = $result[0]['id']; $sql = 'INSERT INTO campaign_hash_requests SET IP = \'' . $_SERVER['REMOTE_ADDR'] . '\', email = \'' . e($addr) . '\''; Database::singleton()->query($sql); $sql = 'SELECT hash,campaign_id FROM campaign_hash WHERE user_id = ' . $id; $results = Database::singleton()->query_fetch_all($sql); $body = "This e-mail address was used to request the retrieval of hash keys on the SafeBallot system. " . "If you believe you have received this message in error, please contact the person in charge of voting " . "campaigns at your organization and ensure to keep the original copy of this contact.\n\nHash keys:\n"; if ($results) { for ($i = 0; $i < count($results); $i++) { $cid = $results[$i]["campaign_id"]; $hash = $results[$i]["hash"]; $campaign = new Campaign($cid); if ($campaign->calcStatus(true) == 1) { $body .= "\nCampaign '" . $campaign->getName() . "' -> " . $hash; } } } else { $body .= "There are currently no voting campaigns in progress."; } mail($addr, 'Hash Key Retrieval', $body, "From: Safeballot <*****@*****.**>"); return true; } } return false; }