Where in this script do I turn captca on/off? <?php function smarty_cms_function_tellafriend_form($params, &$smarty) { global $gCms; if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) { $captcha =& $gCms->modules['Captcha']['object']; } if (empty($params['emailsubject'])){ echo '<div class="formError">An email subject must be specified in order to use this plugin, using the format emailsubject="Your subject here"</div>'; return; }else{ $subject = $params['emailsubject']; $canned = $params['cannedtext']; } $style = true; // Use default styles if (FALSE == empty($params['style']) && $params['style'] === "false" ) $style = false; // Except if "false" given in params // Default styles $inputStyle = 'style="width:100%;border: 1px solid black; margin:0 0 5px 0;"'; // input boxes $taStyle = 'style="word-wrap:break-word; overflow-x:hidden; overflow-y:auto; width:100%; border: 1px solid black; margin:0 0 5px 0; font-size:.8em; font-family:arial,helvetica,sans-serif;"'; // TextArea boxes $formStyle = 'style="width:300px; line-height:90%;"'; // form $errorsStyle = 'style="color: white; background-color: red; font-weight: bold; border: 3px solid black; margin: 5px;"'; // Errors box (div) $labelStyle = 'style="display:block; font-size:.8em; font-family:arial,helvetica,sans-serif;"'; $buttonStyle = 'style="float:left; width:50%;"'; $fieldsetStyle = 'style="padding:12px; border:1px solid #999999; text-align:left;"'; $captchaStyle = 'style="margin-bottom:5px; text-align: center;"'; $errors=$to=$name=$email=$message = ''; $pageURL = "\r\n\r\nLes om organdonasjon. www.organdonasjon.no"; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $message = $canned . $pageURL ; if($_SERVER['REQUEST_METHOD']=='POST'){ if (!empty($_POST['subject'])) $subject = tafsanitize($_POST['subject']); if (!empty($_POST['to'])) $to = tafsanitize($_POST['to']); if (!empty($_POST['name'])) $name = tafsanitize($_POST['name']); if (!empty($_POST['email'])) $email = tafsanitize($_POST['email']); if (!empty($_POST['canned'])) $canned = $_POST['canned']; if (!empty($_POST['message'])) $message = $_POST['message']; if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) { if (!empty($_POST['captcha_resp'])) { $captcha_resp = $_POST['captcha_resp']; } } //Mail headers $extra = "From: $name <$email>\r\n"; $charset = isset($gCms->config['default_encoding']) && $gCms->config['default_encoding'] != '' ? $gCms->config['default_encoding'] : 'utf-8'; $extra .= "Content-Type: text/plain; charset=" . $charset . "\r\n"; if (empty($name)) $errors .= "\t\t<li>" . 'Skriv inn navnet ditt' . "</li>\n"; if (empty($email)) $errors .= "\t\t<li>" . 'Skriv inn epostadressen din' . "</li>\n"; elseif (!tafvalidEmail($email)) $errors .= "\t\t<li>" . 'Du har brukt en epostadresse som ikke er gyldig' . "</li>\n"; if (empty($to)) $errors .= "\t\t<li>" . 'Skriv inn din venns epostadresse' . "</li>\n"; elseif (!tafvalidtoEmail($to)) $errors .= "\t\t<li>" . 'Din venns epostadresse er ikke gyldig' . "</li>\n"; if (empty($message)) $errors .= "\t\t<li>" . 'Skriv en beskjed her' . "</li>\n"; if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) { if (empty($captcha_resp)) $errors .= "\t\t<li>" . 'Please enter the text in the image' . "</li>\n"; elseif (! ($captcha->checkCaptcha($captcha_resp))) $errors .= "\t\t<li>" . 'The text from the image was not entered correctly' . "</li>\n"; } if (!empty($errors)) { echo '<div class="formError" ' . (($style) ? $errorsStyle:'') . '>' . "\n"; echo '<p>Feil : </p>' . "\n"; echo "\t<ul>\n"; echo $errors; echo "\t</ul>\n"; echo "</div>"; } elseif (@mail($to, $subject, $message, $extra)) { echo '<div class="formMessage">Din beskjed ble sendt.</div>' . "\n"; return; } else { echo '<div class="formError" ' . (($style) ? $errorsStyle:'') . '>Beklager, beskjeden ble ikke sendt, prøv igjen om litt.</div>' . "\n"; return; } } if (isset($_SERVER['REQUEST_URI'])) { $action = $_SERVER['REQUEST_URI']; } else { $action = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : ''; if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') { $action .= '?'.$_SERVER['QUERY_STRING']; } } ?> <!-- TELLAFRIEND_FORM --> <form action="<?php echo $action ?>" class="tellafriendform" method="post" <?php echo ($style) ? $formStyle:''; ?>> <fieldset <?php echo ($style) ? $fieldsetStyle:''; ?>> <label for="name" <?php echo ($style) ? $labelStyle:''; ?> >Ditt navn :</label> <input type="text" id="name" name="name" value="<?php echo htmlspecialchars($name); ?>" <?php echo ($style) ? $inputStyle:''; ?>/> <label for="email" <?php echo ($style) ? $labelStyle:''; ?> >Din epostadresse : </label> <input type="text" id="email" name="email" value="<?php echo htmlspecialchars($email); ?>" <?php echo ($style) ? $inputStyle:''; ?>/> <label for="to" <?php echo ($style) ? $labelStyle:''; ?> >Din venns epostdresse : </label> <input type="text" id="to" name="to" value="<?php echo htmlspecialchars($to); ?>" <?php echo ($style) ? $inputStyle:''; ?>/> <label for="message" <?php echo ($style) ? $labelStyle:''; ?> >Beskjed : </label> <textarea id="message" name="message" rows="5" cols="48" <?php echo ($style) ? $taStyle:''; ?>><?php echo $message; ?></textarea> <?php if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) { ?> <label for="captcha_resp" <?php echo ($style) ? $labelStyle:''; ?> >Enter the text from the image below : </label> <input type="text" id="captcha_resp" name="captcha_resp" value="" <?php echo ($style) ? $inputStyle:''; ?>/> <?php echo "<div $captchaStyle>" . $captcha->getCaptcha() . '</div>'; } ?> <input type="submit" class="button" value="Send!" <?php echo ($style) ? $buttonStyle: ''; ?> /> <input type="reset" class="button" value="Slett skjemaet" <?php echo ($style) ? $buttonStyle: ''; ?> /> </fieldset> </form> <!-- END of TELLAFRIEND_FORM --> <?php } function smarty_cms_help_function_tellafriend_form() { ?> <h3>What does this do?</h3> <p>This tag renders a small "Tell a Friend" form, which automatically includes the URL of the page the form is on. The user fills in their name and email address, the recipients email address, and optionally a message. Pressing submit sends an email to the recipient.</p> <p>This tag is a mashup of the contact_form tag and some code <a href="http://forum.cmsmadesimple.org/index.php/topic,8827.0.html" target="_blank">posted in the forums</a> by <b>samalah</b>. This tag was created to offer something more formal than a mailto link, and something more spam-resistant than a plain form (through Captcha support).</p> <h3>How do I use it?</h3> <p>Just insert the tag into your template/page like: <code>{tellafriend_form emailsubject="Check out this page at foo.com!"}</code><br> <br> </p> <h3>What parameters does it take?</h3> <ul> <li>emailsubject - The subject of the email that will be sent.</li> <li><em>(optional)</em>style - true/false, use the predefined styles. Default is true.</li> <li><em>(optional)</em>cannedtext - Used to include some default text in the message field. If you omit this, the message field will just contain the page URL.</li> <li><em>(optional)</em>captcha - true/false, use Captcha response test (Captcha module must be installed). Default is false.</li> </ul> </p> <?php } function smarty_cms_about_function_tellafriend_form() { ?> <p>Author: Vaughn Teegarden <vaughn@vaughnsphotoart.com>, with heavy credit to Brett Batie <brett-cms@classicwebdevelopment.com> & Simon van der Linden <ifmy@geekbox.be> for their work on the contact_form tag, and to forum member "samalah" for the URL code.</p> <p>Version: 1.0 (20070308)</p> <p> Change History:<br/> <ul> <li>Initial publication of 1.0</li> </ul> </p> <?php } function tafsanitize($content){ return str_replace(array("\r", "\n"), "", trim($content)); } function tafvalidEmail($email) { if (!preg_match("/^([\w|\.|\-|_]+)@([\w||\-|_]+)\.([\w|\.|\-|_]+)$/i", $email)) { return false; exit; } return true; } function tafvalidtoEmail($to) { if (!preg_match("/^([\w|\.|\-|_]+)@([\w||\-|_]+)\.([\w|\.|\-|_]+)$/i", $to)) { return false; exit; } return true; } ?>