(required)

comment_rollback($post_ID); //roll back die( __('Error: please enter the security code.') ); } if ( $_SESSION['IMAGE_CODE'] != $securitycode ) { $this->comment_rollback($post_ID); //roll back die( __('Invalid security code. Press your browsers back button and try again.') ); } else { unset($_SESSION['IMAGE_CODE']); } } return $post_ID; } function comment_rollback($post_ID) { global $wpdb, $wp_version; $pid = $wpdb->get_var("SELECT comment_post_ID FROM {$wpdb->comments} WHERE comment_ID = {$post_ID}"); $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_ID = {$post_ID}"); //roll back if ($wp_version >= '2.0') { $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_post_ID = {$pid} AND comment_approved = '1'"); $wpdb->query( "UPDATE {$wpdb->posts} SET comment_count = {$count} WHERE ID = {$pid}" ); } } } ///:~ } //end if $secimg = new AntiSpamImage(); if (isset($_GET['image']) && preg_match('/^[0-9]+$/', $_GET['image'])) { //display image //@ob_clean(); //@session_start(); $operand1 = rand(0,10); $operand2 = rand(0,10); $operand3 = rand(0,10); $op = rand(0,1); $answer = 0; if ($op == 0) { $answer = $operand1 * $operand2 + $operand3; $question = "%operand1 * %operand2 + %operand3 = ?"; } else if ($op == 1) { $answer = $operand1 + $operand2 * $operand3; $question = "%operand1 + %operand2 * %operand3 = ?"; } $question = str_replace("%operand1",$operand1,$question); $question = str_replace("%operand2",$operand2,$question); $question = str_replace("%operand3",$operand3,$question); //$_SESSION['IMAGE_CODE'] = str_replace(array('0', 'o'), array('1', 'p'), strtolower(substr(md5(rand()), 20, 4))); $_SESSION['IMAGE_CODE'] = $answer; //$char = $_SESSION['IMAGE_CODE']; $char = $question; $im = @imagecreate (150, 20) or die ("Cannot initialize new GD image stream!"); $background_color = imagecolorallocate ($im, 232, 238, 247); //random points for ($i = 0; $i <= 128; $i++) { $point_color = imagecolorallocate ($im, rand(0,255), rand(0,255), rand(0,255)); imagesetpixel($im, rand(2,128), rand(2,38), $point_color); } //output characters for ($i = 0; $i < strlen($char); $i++) { $text_color = imagecolorallocate ($im, rand(0,255), rand(0,128), rand(0,255)); $x = 5 + $i * 10; $y = rand(1, 4); imagechar ($im, 5, $x, $y, $char{$i}, $text_color); } //ouput PNG header("Expires: Mon, 26 Jul 1997 05:00:00 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"); // Let it more flexible! if (function_exists("imagepng")) { header("Content-type: image/png"); imagepng($im); } elseif (function_exists("imagegif")) { header("Content-type: image/gif"); imagegif($im); } elseif (function_exists("imagejpeg")) { header("Content-type: image/jpeg"); imagejpeg($im); } else { die("No image support in this PHP server!"); } imagedestroy ($im); exit; } //end if ?>