我是 drupal_mail 功能的新手,需要帮助。我的代码有效,但我想摆脱 $_POST 参数以限制我的安全漏洞。
我不知道如何在不使用 $_POST 参数的情况下获取发布的变量,理想情况下,我想单独列出每个参数以在其上放置自定义标签。
任何帮助将不胜感激。
function revenue_calculations() {
$block = array();
$a = $b = $c = '';
$errors = array();
$output = '';
if (isset($_POST)) {
if (isset($_POST['a'])) $a = (int) round($_POST['a']);
if (isset($_POST['b'])) $b = (int) round($_POST['b']);
if (isset($_POST['c'])) $c = (int) round($_POST['c']);
if (!empty($a) && !empty($b)&& !empty($c)) {
$calc1 = $a * ($b/100);
$calc2 = $calc1 * ($c/100);
$calc3 = $calc2 * .65 * .99;
$display = '$'.number_format($calc3,2);
////// throw in a drupal_mail send, with the form details //////
function calculator_mail($key, &$message, $params) {
switch ($key) {
case 'calculation':
$message['subject'] = t('CALCULATION DONE');
foreach ($params as $key=>$value) {
$message['body'][] = $key.': '.check_plain($value);
}
break;
}
}
drupal_mail('calculator', 'calculation', 'xxx@xxx.com', language_default(), $_POST);
$output = "Your result is $display;
}
}
$output .= revenue_calculator();
return $output;
}