} function checkAICode($code) { global $sess_key_name; session_start(); // Comment out following two lines to be case sensitive $code = strtoupper($code); $entered_code = strtoupper($_SESSION[$sess_key_name]); $return = ($code == $_SESSION[$sess_key_name]) ? 1 : 0; if(!isset($_SESSION[$sess_key_name])) { $return = 0; } else { session_unset(); session_destroy(); session_start(); } // set new random code. $_SESSION[$sess_key_name] = randomString('alpha'); return $return; } function createAICode($type) { global $sess_key_name; $code = randomString('alpha'); session_start(); $_SESSION[$sess_key_name] = $code; if ($type != "text") { if (!isset($plugins_dir)) $plugins_dir = dirname(__FILE__).'/'; $fontfile = "atomicclockradio.ttf"; $font = $plugins_dir . $fontfile; $im = @imageCreate(155, 50) or die("Cannot Initialize new GD image stream"); $background_color = imageColorAllocate($im, 170, 170, 170); $text_color = imageColorAllocate($im, 0x00, 0x00, 0x00); ImageTTFText($im, 20, 5, 18, 38, $text_color, $font, $code); // Date in the past header("Expires: Thu, 28 Aug 1997 05:00:00 GMT"); // always modified $timestamp = gmdate("D, d M Y H:i:s"); header("Last-Modified: " . $timestamp . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); // dump out the image header("Content-type: image/jpeg"); ImageJPEG($im); } else { // Show phonetic text instead settype($code, "string"); echo createAIAltText($code); } } function createAIAltText($code) { $alt_char = array('a' => 'ay', 'b' => 'bee', 'c' => 'see', 'd' => 'dee', 'e' => 'eee', 'f' => 'eff', 'g' => 'jee', 'h' => 'aych', 'i' => 'eye', 'j' => 'jay', 'k' => 'kay', 'l' => 'ell', 'm' => 'em', 'n' => 'en', 'o' => 'oh', 'p' => 'pea', 'q' => 'que', 'r' => 'are', 's' => 'ess', 't' => 'tee', 'u' => 'you', 'v' => 'vee', 'w' => 'double-u', 'x' => 'ecks', 'y' => 'why', 'z' => 'zee', '0' => 'zero', '1' => 'one', '2' => 'two', '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six', '7' => 'seven', '8' => 'eight', '9' => 'nine'); $alt_code = ""; for($i = 0; $i < 6; $i++) { if (!is_numeric($code{$i})) { if (ctype_upper($code{$i})) { $alt_code = $alt_code . "upper-" . $alt_char[strtolower($code{$i})] . " "; } else { $alt_code = $alt_code . "lower-" . $alt_char[$code{$i}] . " "; } } else { $alt_code = $alt_code . $alt_char[$code{$i}] . " "; } } return $alt_code; } function randomString($type='num',$length=6) { $randstr=''; srand((double)microtime()*1000000); $chars = array ( '1','2','3','4','5','6','7','8','9','0' ); if ($type == "alpha") { array_push ( $chars, 'A','B','C','D','E','F','G','H','I','J','K','L', 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' ); } for ($rand = 0; $rand < $length; $rand++) { $random = rand(0, count($chars) -1); $randstr .= $chars[$random]; } return $randstr; } add_filter('wp_head','testValues'); ?>