Location: PHPKode > projects > H-tracker > backend/captcha.php
<?
//
//  H-Tracker v0.2
//    http://h-tracker.org
//    Based on TorrentTrader (http://www.torrenttrader.org)
//
//

function random_str($length = 20) {
$set = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J","k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T","u","U","v","V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6","7","8","9");
$str;
for($i = 1; $i <= $length; $i++)
{
$ch = rand(0, count($set)-1);
$str .= $set[$ch];
}
return $str;
}

function create_captcha() {
$randomstr = random_str(4);
$imagehash = md5($randomstr);
mysql_query("INSERT INTO captcha SET imagehash = ".sqlesc($imagehash).", imagestring = ".sqlesc($randomstr).", dateline = ".sqlesc(time())) or sqlerr(__FILE__,__LINE__);
return $imagehash;
}

function my_strlen($string) {
$string = preg_replace("#&\#(0-9]+);#", "-", $string);
if(function_exists("mb_strlen")) {
$string_length = mb_strlen($string);
} else {
$string_length = strlen($string);
}

return $string_length;
}

function get_extension($file) {
return strtolower(my_substr(strrchr($file, "."), 1));
}

function my_substr($string, $start, $length="") {
if(function_exists("mb_substr")) {
if($length != "") {
$cut_string = mb_substr($string, $start, $length);
} else {
$cut_string = mb_substr($string, $start);
}
} else {
if($length != "") {
$cut_string = substr($string, $start, $length);
} else {
$cut_string = substr($string, $start);
}
}

return $cut_string;
}

?>
Return current item: H-tracker