[BACK]Return to captcha.png CVS log [TXT][DIR] Up to [local] / botnow

Annotation of botnow/captcha.png, Revision 1.1

1.1     ! bountyht    1: <?php
        !             2:
        !             3: $hash = explode("/", $_SERVER["REQUEST_URI"])[1];
        !             4: $fpr{"hash"} = $hash;
        !             5: $fpr{"remoteaddr"} = $_SERVER['REMOTE_ADDR'];
        !             6: $fpr{"httpxforwarded"} = $_SERVER['HTTP_X_FORWARDED_FOR'];
        !             7: $fpr{"time"} = date("Y-m-d H:i:s");
        !             8: foreach (getallheaders() as $key => $value) {
        !             9:        if ($key == "User-Agent") {
        !            10:                $fpr{"useragent"} = $value;
        !            11:        } elseif ($key == "Upgrade-Insecure-Requests") {
        !            12:                $fpr{"upgradeinsecure"} = $value;
        !            13:        } elseif ($key == "Host") {
        !            14:                $fpr{"host"} = $value;
        !            15:        } elseif ($key == "Dnt") {
        !            16:                $fpr{"dnt"} = $value;
        !            17:        } elseif ($key == "Connection") {
        !            18:                $fpr{"connection"} = $value;
        !            19:        } elseif ($key == "Cache-Control") {
        !            20:                $fpr{"cachecontrol"} = $value;
        !            21:        } elseif ($key == "Accept-Language") {
        !            22:                $fpr{"acceptlanguage"} = $value;
        !            23:        } elseif ($key == "Accept-Encoding") {
        !            24:                $fpr{"acceptencoding"} = $value;
        !            25:        } elseif ($key == "Accept") {
        !            26:                $fpr{"accept"} = $value;
        !            27:        }
        !            28: }
        !            29:
        !            30: class wwwdb extends SQLite3 {
        !            31:        function __construct() {
        !            32:                $this->open('/botnow/botnow.db');
        !            33:        }
        !            34: }
        !            35: $wwwdb = new wwwdb();
        !            36: if(!$wwwdb) {
        !            37:        echo $wwwdb->lastErrorMsg();
        !            38: } else {
        !            39:        foreach ($fpr as $key => $value) {
        !            40:                $keys[] = $key;
        !            41:                $values[] = $value;
        !            42:        }
        !            43:        $keystr = '"'.implode('","', $keys).'"';
        !            44:        $valstr = '"'.implode('","', $values).'"';
        !            45:        $sql =<<<EOF
        !            46: INSERT INTO www ($keystr)
        !            47: VALUES ($valstr);
        !            48: EOF;
        !            49:
        !            50:        if (!$wwwdb->exec($sql)) {
        !            51:                echo $db->lastErrorMsg();
        !            52:                return;
        !            53:        }
        !            54:
        !            55:        $sql =<<<EOF
        !            56: SELECT * from bnc;
        !            57: EOF;
        !            58:        $ret = $wwwdb->query($sql);
        !            59:        while($row = $ret->fetchArray(SQLITE3_ASSOC)) {
        !            60: //             echo "hash: $hash, row['hashid']: ".$row['hashid']."<br>\n";
        !            61:                if ($hash == $row['hashid']) {
        !            62:                        $captcha = $row['captcha'];
        !            63: //                     echo $captcha;
        !            64:                }
        !            65:        }
        !            66:        $wwwdb->close();
        !            67: //             echo "Records created successfully\n";
        !            68: }
        !            69: session_start();
        !            70:
        !            71: // The capcha will be stored
        !            72: // for the session
        !            73: $_SESSION["captcha"] = $captcha;
        !            74:
        !            75: // Generate a 50x24 standard captcha image
        !            76: $im = imagecreatetruecolor(250, 120);
        !            77:
        !            78: // Blue color
        !            79: $bg = imagecolorallocate($im, 22, 86, 165);
        !            80:
        !            81: // White color
        !            82: $fg = imagecolorallocate($im, 255, 255, 255);
        !            83:
        !            84: // Give the image a blue background
        !            85: imagefill($im, 0, 0, $bg);
        !            86:
        !            87: // Print the captcha text in the image
        !            88: // with random position & size
        !            89: //imagestring($im, 5, rand(1, 40), rand(1, 40),  $captcha, $fg);
        !            90: imagettftext($im , 96, 0, rand(0,130), 120-rand(0,60), $fg , 'intuitive.ttf', $captcha);
        !            91: //imagettftext($im , 96, 0, rand(20, 50), rand(20, 50), $fg , 'eczar.ttf', $captcha);
        !            92:
        !            93: // VERY IMPORTANT: Prevent any Browser Cache!!
        !            94: header("Cache-Control: no-store,
        !            95:             no-cache, must-revalidate");
        !            96:
        !            97: // The PHP-file will be rendered as image
        !            98: header('Content-type: image/png');
        !            99:
        !           100: // Finally output the captcha as
        !           101: // PNG image the browser
        !           102: imagepng($im);
        !           103:
        !           104: // Free memory
        !           105: imagedestroy($im);
        !           106: ?>

CVSweb