Sitemap
Links
+++ erd.trabant +++

+++ erd.trabant +++

blablabla

blablabla

Span Captcha - unbreakable captcha code

for php5!


class Captcha {
 
    private $matrix = array();
    private $number;
    private $captcha;
 
    public function __construct() {
        $this->matrix[0] = array(1,1,1,1,0,1,1,0,1,1,0,1,1,1,1); // 0        
        $this->matrix[1] = array(0,0,1,0,1,1,0,0,1,0,0,1,0,0,1); // 1
        $this->matrix[2] = array(1,1,1,0,0,1,1,1,1,1,0,0,1,1,1); // 2
        $this->matrix[3] = array(1,1,1,0,0,1,0,1,1,0,0,1,1,1,1); // 3
        $this->matrix[4] = array(1,0,1,1,0,1,1,1,1,0,0,1,0,0,1); // 4
        $this->matrix[5] = array(1,1,1,1,0,0,1,1,1,0,0,1,1,1,1); // 5
        $this->matrix[6] = array(1,1,1,1,0,0,1,1,1,1,0,1,1,1,1); // 6
        $this->matrix[7] = array(1,1,1,0,0,1,0,0,1,0,0,1,0,0,1); // 7
        $this->matrix[8] = array(1,1,1,1,0,1,1,1,1,1,0,1,1,1,1); // 8
        $this->matrix[9] = array(1,1,1,1,0,1,1,1,1,0,0,1,1,1,1); // 9
    }
 
    public function generate() {
        $this->number = rand();
        $list = str_split($this->number);
        $this->captcha .= "\n".'<pre style="font-size: 3px;line-height: 1.0;">';
        for($a=0;$a<5;$a++) {
 
            foreach($list as $number) {
                for($i=$a*3;$i<$a*3+3;$i++) {
                    if($this->matrix[$number][$i]===1) {
                        $this->captcha .= '<span style="color: black; background-color: black;">&nbsp;&nbsp;</span>';
                    } else {
                        $this->captcha .= '&nbsp;&nbsp;';
                    }
                }
                $this->captcha .= '&nbsp;&nbsp;';
 
            }
 
            $this->captcha .= "\n";
 
        }
        $this->captcha .= "</pre>\n";
 
    }
 
    public function getNumber() {
        return $this->number;
    }
 
    public function getCaptcha() {
        return $this->captcha;
    }
 
}



(c) s7n dot de, s7ncms

>>PopUP / Drucken / Print<<
blablabla