//1.7
class Captcha{
private $seitenpfad;
private $erfolg;
//--------------------------------------------------------------------------------------------------
function __construct($pfad){
$this->seitenpfad=$pfad;
$this->erfolg=false;
}
//----------------------------------------------------------------------------------------
function create_code() {
mt_srand((double)microtime()*1000000);
$code = mt_rand(1,2);
// Buchstabensalat generieren jeh nachdem ob Randval 1 oder 2 ist
switch ($code) {
case 1:
// Ziffern
$code = mt_rand(48, 57);
break;
case 2:
// Grosse Buchstaben
$code = mt_rand(65, 90);
break;
}
// Zufallscode ausgeben
return chr($code);
}
//----------------------------------------------------------------------------------------
public function steuerung($ziel){
if(isset($_POST['txtCode'])){
//Wenn Benutzer Code eingegeben hat
$eingabe = $this->crypto($_POST['txtCode']);
$cap = $_POST['cap'];
if ($eingabe == $cap){
//Wenn Code richtig war
$this->erfolg=true;
}
}
if ($this->erfolg==false){
// Zufallscode 6-stellig ausgeben
for ($i = 1; $i <= 6; $i++) {
$this->code .= $this->create_code();
}
$this->code=$this->crypto($this->code);
if (isset($this->code)) {
$_POST['cap'] = str_replace('I','E',str_replace('0','3',str_replace('1','S',str_replace('B','F',str_replace('O','P',str_replace('4','A',str_replace('D','K',$this->code)))))));
} else {
die("Zufallscode konnte nicht generiert werden!");
}
}
return;
}
//----------------------------------------------------------------------------------------
public function get_erfolg(){
return $this->erfolg;
}
//------------------------------------------------------------------------------------------------
public function rew($a){
$str='';
return $str;
}
//------------------------------------------------------------------------------------------------
public function crypto($a){
$al=strlen($a);
for($i=0; $i<$al; $i++){
$str.= $a[$al-$i-1];
}
return $str;
}
}
?>