function fill_comment_form_submit($name, $email, $url, $cookie, $comm, $notify, $discreet) { // Clean up user input $name = js_sanctify($name); $email = js_sanctify($email); $url = js_sanctify($url); $comm = js_sanctify($comm, '<b>,<i>,<em>,<strong>'); $output = "<script type=\"text/javascript\">\n"; $output .= "var form = document.getElementById('form');\n"; $output .= "if (form) {\n"; if ($name != "") { $output .= "form.piv_name.value='" . $name . "';\n"; } if ($email != "") { $output .= "form.piv_email.value='" . $email . "';\n"; } if ($url != "") { $output .= "form.piv_url.value='" . $url . "';\n"; } if ($comm != "") { $output .= "form.piv_comment.value='" . $comm . "';\n"; } if ($cookie == "yes") { $output .= "form.piv_rememberinfo[0].checked=true;\n"; } else { $output .= "form.piv_rememberinfo[1].checked=true;\n"; } if ($notify != "") { $output .= "form.piv_notify.checked=true;\n"; } if ($discreet != "") { $output .= "form.piv_discreet.checked=true;\n;"; } $output .= "}\n</script>\n"; return $output; }
/** * Produces the Javascript code that prefills the comment form (either when * previewing or being a registered visitor). * * @param string $name * @param string $email * @param string $url * @param string $cookie * @param string $comm * @param integer $notify * @param integer $hidemail * @return string */ function fill_comment_form($name = '', $email = '', $url = '', $cookie = '', $comm = '', $notify = 0, $hidemail = 0) { global $Paths; require_once $Paths['pivot_path'] . "modules/module_userreg.php"; // if user is logged in as registered visitor, we must always use // that info in the form. if ($user = load_user($_COOKIE['piv_reguser'])) { $name = $user['name']; $email = $user['email']; $url = $user['url']; $notify = $user['notify_default']; $hidemail = 1 - $user['show_address']; } // Clean up user input $name = js_sanctify($name); $email = js_sanctify($email); $url = js_sanctify($url); $comm = js_sanctify($comm, '<b>,<i>,<em>,<strong>'); $output = "<script type=\"text/javascript\">\n"; $output .= "var form = document.getElementById('form');\n"; $output .= "if (form) { "; if ($name != "") { $output .= "form.piv_name.value='" . $name . "';\n"; } if ($email != "") { $output .= "form.piv_email.value='" . $email . "';\n"; } if ($url != "") { $output .= "form.piv_url.value='" . $url . "';\n"; } if ($comm != "") { $output .= "form.piv_comment.value='" . $comm . "';\n"; } if ($cookie == "yes") { $output .= "form.piv_rememberinfo[0].checked=true;\n"; } else { $output .= "form.piv_rememberinfo[1].checked=true;\n"; } if ($notify == 1) { $output .= "form.piv_notify.checked=true;\n"; } else { $output .= "form.piv_notify.checked=false;\n"; } if ($hidemail == 1) { $output .= "form.piv_discreet.checked=true;\n"; } else { $output .= "form.piv_discreet.checked=false;\n"; } $output .= "}"; $output .= "</script>\n"; return $output; }