function render($euid) { global $lang, $sid, $msid, $offset, $message; $magic_quotes = get_magic_quotes_gpc(); $nothing_to_show = true; $offset = 0; $this->smarty->assign("msid", $msid); $this->smarty->assign("lang", $lang); $this->smarty->assign("actionlang", response_text($this->type)); $user_config = get_maia_user_row($euid); //set the class names for the given cache type, and default box to check. switch ($this->type) { case 'ham': $this->smarty->assign("banner_class", "hambanner"); $this->smarty->assign("header_class", "hamheader"); $this->smarty->assign("body_class", "hambody"); $this->smarty->assign("alt_body_class", "hambody_alt"); $this->smarty->assign("header_text", $lang['header_suspected_ham']); $this->smarty->assign("def_rb", "ham"); break; case 'spam': $this->smarty->assign("banner_class", "suspected_spambanner"); $this->smarty->assign("header_class", "suspected_spamheader"); $this->smarty->assign("body_class", "suspected_spambody"); $this->smarty->assign("alt_body_class", "suspected_spambody_alt"); $this->smarty->assign("header_text", $lang['header_spam']); $this->smarty->assign("def_rb", "spam"); break; case "virus": $this->smarty->assign("banner_class", "virusbanner"); $this->smarty->assign("header_class", "virusheader"); $this->smarty->assign("body_class", "virusbody"); $this->smarty->assign("alt_body_class", "virusbody_alt"); $this->smarty->assign("header_text", $lang['header_viruses']); $this->smarty->assign("def_rb", "delete"); break; case "attachment": $this->smarty->assign("banner_class", "banned_filebanner"); $this->smarty->assign("header_class", "banned_fileheader"); $this->smarty->assign("body_class", "banned_filebody"); $this->smarty->assign("alt_body_class", "banned_filebody_alt"); $this->smarty->assign("header_text", $lang['header_banned_files']); $this->smarty->assign("def_rb", "delete"); break; case "header": $this->smarty->assign("banner_class", "bad_headerbanner"); $this->smarty->assign("header_class", "bad_headerheader"); $this->smarty->assign("body_class", "bad_headerbody"); $this->smarty->assign("alt_body_class", "bad_headerbody_alt"); $this->smarty->assign("header_text", $lang['header_bad_headers']); $this->smarty->assign("def_rb", "delete"); break; } $numRows = $this->dbh->getOne($this->select_count, array($euid)); if ($numRows > 0) { $select2 = "SELECT email FROM users WHERE maia_user_id = ?"; $sth2 = $this->dbh->query($select2, array($euid)); while ($row2 = $sth2->fetchrow()) { $personal_addresses[] = $row2["email"]; } $sth2->free(); $personal_addresses = array_flip($personal_addresses); $domain_default = is_a_domain_default_user($euid); $need_to = count($personal_addresses) > 1 || $domain_default; $this->smarty->assign("need_to", $need_to); //need to output the to: column $per_page = get_user_value($euid, "items_per_page"); $this->smarty->assign("truncate_subject", $user_config["truncate_subject"] == 0 ? 10000 : $user_config["truncate_subject"]); $this->smarty->assign("truncate_email", $user_config["truncate_email"] == 0 ? 10000 : $user_config["truncate_email"]); $pagerOptions = array('mode' => 'Sliding', 'delta' => 5, 'perPage' => $per_page, 'totalItems' => $numRows); $paged_data = Pager_Wrapper_DB($this->dbh, $this->select_stmt, $pagerOptions, null, DB_FETCHMODE_ASSOC, array($euid)); //$paged_data['data']; //paged data //$paged_data['links']; //xhtml links for page navigation //$paged_data['page_numbers']; //array('current', 'total'); if (PEAR::isError($paged_data)) { $_SESSION["message"] = $paged_data->getMessage(); header("Location: welcome.php" . $sid); exit; } $maxid = 0; $nothing_to_show = false; $this->smarty->assign("data", $paged_data['data']); $this->smarty->assign("offset", $offset); //print_r($paged_data['page_numbers']); $this->smarty->assign("pages", $paged_data['page_numbers']); if ($numRows == 1) { $item_text = $lang['text_item']; } else { $item_text = $lang['text_items']; } $count = 0; $rows = array(); foreach ($paged_data['data'] as $row) { if ($row["id"] > $maxid) { $maxid = $row["id"]; } $rows[$count]['id'] = $row['id']; if ($this->type == 'attachment') { $bnames = $this->get_banned_names($row['id']); foreach ($bnames as $bname) { $rows[$count]['file'] .= $bname . "<br>"; } } elseif ($this->type == 'virus') { $vnames = $this->get_virus_names($row['id']); $rows[$count]['virus_name'] = ""; foreach ($vnames as $vname) { $vurl = get_virus_info_url($vname); if ($vurl == "") { $rows[$count]['virus_name'] .= $row["virus_name"]; } else { $rows[$count]['virus_name'] .= "<a href=\"" . $vurl . "\">" . $vname . "</a>"; } $rows[$count]['virus_name'] .= "<br>"; } } $rows[$count]['received_date'] = $row["received_date"]; $rows[$count]['sender_email'] = $magic_quotes ? stripslashes($row["sender_email"]) : $row["sender_email"]; $rows[$count]['score'] = $row['score']; $to_list = explode(" ", $row["envelope_to"]); $rectmp = ""; foreach ($to_list as $recipient) { if (isset($personal_addresses[$recipient]) || $domain_default) { $rectmp[] = $recipient; } } $rows[$count]['recipient_email'] = $rectmp; $subject = $magic_quotes ? stripslashes($row['subject']) : $row['subject']; if ($subject == "") { $subject = "(" . $lang['text_no_subject'] . ")"; } else { if (preg_match('/=\\?.+\\?=/', $subject)) { $subject = htmlspecialchars(iconv_mime_decode($subject, 2, 'utf-8'), ENT_NOQUOTES, 'UTF-8'); } else { $subject = htmlspecialchars($subject); } } $rows[$count]['subject'] = $subject; $count++; } $this->smarty->assign("row", $rows); $this->smarty->assign("maxid", $maxid); $this->smarty->assign("links", $paged_data['links']); } else { $_SESSION["message"] = $message; header("Location: welcome.php" . $sid); exit; } $this->smarty->assign("nothing_to_show", $nothing_to_show); $this->smarty->display("list-cache.tpl"); }
function add_domain($domain_name) { global $dbh; global $logger; if (get_domain_id($domain_name) != 0) { $logger->warning("Attempt to add duplicate domain:" . $domain_name); return 0; } // get default autocreation policy $default_policies = get_default_domain_policies(); $default_autocreation_policy = $default_policies['autocreation']; $default_transport = $default_policies['transport']; $routing_domain = substr($domain_name, 1); // Add the domain to the maia_domains table $sth = $dbh->prepare("INSERT INTO maia_domains (domain, enable_user_autocreation, routing_domain, transport) VALUES (?,?,?,?)"); $sth->execute(array($domain_name, $default_autocreation_policy, $routing_domain, $default_transport)); if (PEAR::isError($sth)) { die($sth->getMessage()); } $sth->free(); $sth = $dbh->prepare("SELECT id FROM maia_domains WHERE domain = ?"); $res = $sth->execute(array($domain_name)); if (PEAR::isError($sth)) { die($sth->getMessage()); } if ($row = $res->fetchrow()) { $domain_id = $row["id"]; } $sth->free(); // Add a new policy for the domain, based on the // system defaults. $policy_id = add_policy($domain_name); // Add the domain address to the users table $primary_email_id = add_address_to_user($policy_id, $domain_name, 0, $domain_id); $default_user_config = get_maia_user_row(get_user_id("@.", "@.")); // Add a domain default user to the maia_users table $sth = $dbh->prepare("INSERT INTO maia_users (user_name, primary_email_id, reminders, discard_ham, theme_id) VALUES (?, ?, 'N', ?, ?)"); $sth->execute(array($domain_name, $primary_email_id, $default_user_config["discard_ham"], $default_user_config["theme_id"])); if (PEAR::isError($sth)) { die($sth->getMessage()); } $sth->free(); $sth = $dbh->prepare("SELECT id FROM maia_users WHERE user_name = ?"); $res = $sth->execute(array($domain_name)); if (PEAR::isError($sth)) { die($sth->getMessage()); } if ($row = $res->fetchrow()) { $maia_user_id = $row["id"]; } $sth->free(); // Update the users table to link the e-mail address back to the domain $sth = $dbh->prepare("UPDATE users SET maia_user_id = ? WHERE id = ?"); $sth->execute(array($maia_user_id, $primary_email_id)); if (PEAR::isError($sth)) { die($sth->getMessage()); } return $domain_id; }
function add_user($user_name, $email) { global $dbh; global $logger; // get domain default if available.... $domain = get_domain_from_email($email); $domain_id = get_user_id("@" . $domain, "@" . $domain); if ($domain_id != 0) { $domain_defaults = get_maia_user_row($domain_id); } else { $domain_defaults = get_maia_user_row(get_user_id("@.", "@.")); } // Add an entry to the maia_users table $sth = $dbh->prepare("INSERT INTO maia_users (user_name, reminders, charts, language, auto_whitelist, " . "items_per_page, theme_id, quarantine_digest_interval, truncate_subject, truncate_email, spamtrap) " . "VALUES (?,?,?,?,?,?,?,?,?,?,'N')"); $res = $sth->execute(array($user_name, $domain_defaults["reminders"], $domain_defaults["charts"], $domain_defaults["language"], $domain_defaults["auto_whitelist"], $domain_defaults["items_per_page"], $domain_defaults["theme_id"], $domain_defaults["quarantine_digest_interval"], $domain_defaults["truncate_subject"], $domain_defaults["truncate_email"])); if (PEAR::isError($res)) { $logger->err("Can't insert new user: "******"SELECT id FROM maia_users WHERE user_name = ?"); $res = $sth->execute(array($user_name)); if (PEAR::isError($sth)) { die($sth->getMessage()); } if ($row = $res->fetchRow()) { $uid = $row["id"]; } $sth->free(); // Link this e-mail address to this user $email_id = add_email_address_to_user($uid, $email); // Make this e-mail address the user's primary address set_primary_email($uid, $email_id); return $uid; }