private function send_prep($prep) { global $Conf; $cbkey = "c" . join("_", $prep->contacts) . "p" . $prep->paperId; if ($this->sending && !defval($_REQUEST, $cbkey)) { return; } set_time_limit(30); $this->echo_prologue(); self::fix_body($prep); ++$this->mcount; if ($this->sending) { Mailer::send_preparation($prep); foreach ($prep->contacts as $cid) { $Conf->log("Account was sent mail" . $this->mailid_text, $cid, $prep->paperId); } } // hide passwords from non-chair users $show_prep = $prep; if (get($prep, "sensitive")) { $show_prep = $prep->sensitive; $show_prep->to = $prep->to; self::fix_body($show_prep); } echo '<div class="mail"><table>'; $nprintrows = 0; foreach (array("To", "cc", "bcc", "reply-to", "Subject") as $k) { if ($k == "To") { $vh = array(); foreach ($show_prep->to as $to) { $vh[] = htmlspecialchars(MimeText::decode_header($to)); } $vh = '<div style="max-width:60em"><span class="nw">' . join(',</span> <span class="nw">', $vh) . '</span></div>'; } else { if ($k == "Subject") { $vh = htmlspecialchars(MimeText::decode_header($show_prep->subject)); } else { if ($line = get($show_prep->headers, $k)) { $k = substr($line, 0, strlen($k)); $vh = htmlspecialchars(MimeText::decode_header(substr($line, strlen($k) + 2))); } else { continue; } } } echo " <tr>"; if (++$nprintrows > 1) { echo "<td class='mhpad'></td>"; } else { if ($this->sending) { echo "<td class='mhx'></td>"; } else { ++$this->cbcount; echo '<td class="mhcb"><input type="checkbox" class="cb" name="', $cbkey, '" value="1" checked="checked" data-range-type="mhcb" id="psel', $this->cbcount, '" onclick="rangeclick(event,this)" /></td>'; } } echo '<td class="mhnp nw">', $k, ":</td>", '<td class="mhdp">', $vh, "</td></tr>\n"; } echo " <tr><td></td><td></td><td class='mhb'><pre class='email'>", Ht::link_urls(htmlspecialchars($show_prep->body)), "</pre></td></tr>\n", "<tr><td class='mhpad'></td><td></td><td class='mhpad'></td></tr>", "</table></div>\n"; }
function parse_value($sv, $name, $info) { global $Conf, $Me, $Now, $Opt; if (!isset($sv->req[$name])) { $xname = str_replace(".", "_", $name); if (isset($sv->req[$xname])) { $sv->req[$name] = $sv->req[$xname]; } else { if ($info->type === "checkbox" || $info->type === "cdate") { return 0; } else { return null; } } } $v = trim($sv->req[$name]); if ($info->placeholder && $info->placeholder === $v || $info->invalid_value && $info->invalid_value === $v) { $v = ""; } if ($info->type === "checkbox") { return $v != "" ? 1 : 0; } else { if ($info->type === "cdate" && $v == "1") { return 1; } else { if ($info->type === "date" || $info->type === "cdate" || $info->type === "ndate") { if ($v == "" || !strcasecmp($v, "N/A") || !strcasecmp($v, "same as PC") || $v == "0" || $info->type !== "ndate" && !strcasecmp($v, "none")) { return -1; } else { if (!strcasecmp($v, "none")) { return 0; } else { if (($v = $Conf->parse_time($v)) !== false) { return $v; } else { $err = unparse_setting_error($info, "Invalid date."); } } } } else { if ($info->type === "grace") { if (($v = parseGrace($v)) !== null) { return intval($v); } else { $err = unparse_setting_error($info, "Invalid grace period."); } } else { if ($info->type === "int" || $info->type === "zint") { if (preg_match("/\\A[-+]?[0-9]+\\z/", $v)) { return intval($v); } else { $err = unparse_setting_error($info, "Should be a number."); } } else { if ($info->type === "string") { // Avoid storing the default message in the database if (substr($name, 0, 9) == "mailbody_") { $t = expandMailTemplate(substr($name, 9), true); $v = cleannl($v); if ($t["body"] == $v) { return ""; } } return $v; } else { if ($info->type === "simplestring") { return simplify_whitespace($v); } else { if ($info->type === "tag" || $info->type === "tagbase") { $tagger = new Tagger($Me); $v = trim($v); if ($v === "" && $info->optional) { return $v; } $v = $tagger->check($v, $info->type === "tagbase" ? Tagger::NOVALUE : 0); if ($v) { return $v; } $err = unparse_setting_error($info, $tagger->error_html); } else { if ($info->type === "emailheader") { $v = MimeText::encode_email_header("", $v); if ($v !== false) { return $v == "" ? "" : MimeText::decode_header($v); } $err = unparse_setting_error($info, "Invalid email header."); } else { if ($info->type === "emailstring") { $v = trim($v); if ($v === "" && $info->optional) { return ""; } else { if (validate_email($v) || $v === $v_active) { return $v; } else { $err = unparse_setting_error($info, "Invalid email."); } } } else { if ($info->type === "urlstring") { $v = trim($v); if ($v === "" && $info->optional || preg_match(',\\A(?:https?|ftp)://\\S+\\z,', $v)) { return $v; } else { $err = unparse_setting_error($info, "Invalid URL."); } } else { if ($info->type === "htmlstring") { if (($v = CleanHTML::basic_clean($v, $err)) === false) { $err = unparse_setting_error($info, $err); } else { if ($info->message_default && $v === $Conf->message_default_html($info->message_default)) { return ""; } else { return $v; } } } else { if ($info->type === "radio") { foreach ($info->values as $allowedv) { if ((string) $allowedv === $v) { return $allowedv; } } $err = unparse_setting_error($info, "Parse error (unexpected value)."); } else { return $v; } } } } } } } } } } } } } $sv->set_error($name, $err); return null; }