一月 2019
« 四月    
 123456
78910111213
14151617181920
21222324252627
28293031  

[VBB] 將圖片驗證改成計算題

最近因為廣告帳號註冊越來越多,所以起了想要修改它的念頭…
改完之後驗證碼會變成簡單的加法
修改 include/functions_regimage.php
將原本內容砍掉貼上新的 (  記得備份資料 )

< ?php
function fetch_regimage_string($length)
{
	return rand(0,9).'+'.rand(0,9).'+'.rand(10,99);
}
function fetch_regimage_hash()
{
	global $vbulletin;

	$string = fetch_regimage_string(6);
	$regimagehash = md5(uniqid(rand(), 1));

	$vbulletin->db->query_write("
		INSERT INTO " . TABLE_PREFIX . "regimage
			(regimagehash, imagestamp, dateline)
		VALUES
			('" . $vbulletin->db->escape_string($regimagehash) . "', '" . $vbulletin->db->escape_string($string) . "', " . TIMENOW . ")"
	);
	return $regimagehash;
}

function verify_regimage_hash($imagehash, $imagestamp)
{
	global $vbulletin;

	$imagestamp = str_replace(' ', '', $imagestamp);

	$res = $vbulletin->db->query_write("
	SELECT imagestamp FROM " . TABLE_PREFIX . "regimage 
	WHERE regimagehash = '" . $vbulletin->db->escape_string($imagehash) . "'
	");
	
	$rs = mysql_fetch_row($res);
	
	$calc = substr($rs[0],0,1)+substr($rs[0],2,1)+substr($rs[0],4,2);

	$rs = $vbulletin->db->affected_rows();
	
		$vbulletin->db->query_write("
		DELETE FROM " . TABLE_PREFIX . "regimage
		WHERE regimagehash = '" . $vbulletin->db->escape_string($imagehash) . "'
		");
	
	if( $imagestamp == $calc )
		return true;
	else
		return false;
}
?>

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>