function captcha($lang, $arglist = false) { $id = false; if (is_array($arglist)) { if (isset($arglist[0])) { $id = $arglist[0]; } } $accepted = array('login', 'register', 'remindme', 'mailme', 'subscribe', 'unsubscribe', 'comment'); if ($id and !in_array($id, $accepted)) { return run('error/badrequest', $lang); } $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $code = strrand($charset, 4); if ($id) { $_SESSION['captcha'][$id] = $code; } $img = strtag($code); header('Content-Type: image/png'); header("Content-Disposition: inline; filename=captcha.png"); header("Cache-Control: no-cache"); imagepng($img); imagedestroy($img); return false; }
function emailcrypto($text, $tag, $to, $subject, $sender = false) { global $signature, $mailer, $webmaster; if (!$sender) { $sender = $webmaster; } $img = strtag($tag); ob_start(); imagepng($img); imagedestroy($img); $imgdata = ob_get_contents(); ob_end_clean(); $sep = md5(uniqid('sep')); $data = chunk_split(base64_encode($imgdata)); $headers = <<<_SEP_ From: {$sender} Return-Path: {$sender} Content-Type: multipart/mixed; boundary="{$sep}" X-Mailer: {$mailer} _SEP_; $body = ''; if ($text) { $body .= <<<_SEP_ --{$sep} Content-Type: text/plain; charset=utf-8 {$text} {$signature} _SEP_; } $body .= <<<_SEP_ --{$sep} Content-Type: image/png; name="crypto.png" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="crypto.png" {$data} --{$sep}-- _SEP_; return @mail($to, $subject, $body, $headers); }