<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] 自己寫的驗證碼是這幾個文件 Captch.class.php(驗證碼工具類) home.html(前臺頁面,入口文件) check.php(檢查處理文件) # Captcha.class.php ~~~ <?php class Captcha{ //碼值庫 private $charset =<<<"herdoc" abcdefghkmnprstuvwxyzabcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ01234567890123456789 lol英雄如下 戰爭女神 希維爾 輪子媽 曙光女神 蕾歐娜 風暴女神 迦娜 皎月女神 黛安娜 朋友圈都是賣面膜 真的好煩 herdoc; private $code; //驗證碼字符串 private $codelen = 4; //驗證碼長度 private $width = 150; //寬度 private $height = 50; //高度 private $img; //圖形資源句柄 private $font; //指定的字體 private $fontsize = 20; //指定字體大小 private $fontcolor; //指定字體顏色 //構造方法初始化 /** * @param $codelen=4,$width=150,$height=40,$fontsize = 20,$font="Elephant.ttf" * @access public */ public function __construct($codelen=4,$width=150,$height=40,$fontsize = 20,$font="./simkai.ttf") { $this->charset = str_replace(" ", "x", $this->charset); $this->charset = str_replace("\n", "j", $this->charset); $this->charset = str_replace("\r", "d", $this->charset); $this->charset = str_replace("\t", "z", $this->charset); $this->codelen = $codelen; $this->width = $width; $this->height = $height; $this->fontsize = $fontsize; $this->font = $font; } /** * 生成隨機碼,也就是碼值,保存到$this->code * @access private * @return void */ private function createCode() { $_len = mb_strlen($this->charset,'utf-8')-1; $this->code=""; //初始化碼值字符串 for($i=0;$i<$this->codelen;++$i){ $rand_index = mt_rand(0,$_len); $this->code .= mb_substr($this->charset,$rand_index,1,'utf-8'); } /* for ($i=0;$i<$this->codelen;++$i) { $this->code .= mb_substr($this->charset,mt_rand(0,$_len),1,'utf-8'); } */ } /** * 生成背景色 * @access private * @return void */ private function createBg() { $this->img = imagecreatetruecolor($this->width, $this->height); $color = imagecolorallocate($this->img, mt_rand(170,250), mt_rand(170,255), mt_rand(170,255)); imagefilledrectangle($this->img,0,$this->height,$this->width,0,$color); } /** * 生成文字到畫布 * @access private * @return void */ private function createFont() { $_x = $this->width / $this->codelen; for ($i=0;$i<$this->codelen;++$i) { $this->fontcolor = imagecolorallocate($this->img,mt_rand(0,156),mt_rand(0,160),mt_rand(0,160));; imagettftext($this->img,$this->fontsize,mt_rand(-30,50),$_x*$i+mt_rand(1,5),$this->height / 1.4,$this->fontcolor,$this->font,mb_substr($this->code,$i,1,'utf-8')); } } /** * 生成線條、雪花 * @access private * @return void */ private function createLine() { for ($i=0;$i<6;++$i) { $color = imagecolorallocate($this->img,mt_rand(0,156),mt_rand(0,156),mt_rand(0,156)); imageline($this->img,mt_rand(0,$this->width),mt_rand(0,$this->height),mt_rand(0,$this->width),mt_rand(0,$this->height),$color); } for ($i=0;$i<100;++$i) { $color = imagecolorallocate($this->img,mt_rand(150,200),mt_rand(200,255),mt_rand(150,255)); imagestring($this->img,mt_rand(1,5),mt_rand(0,$this->width),mt_rand(0,$this->height),'*',$color); } //點 for($k=0;$k<300;$k++){ $color=imagecolorallocate($this->img,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200)); imagesetpixel($this->img,mt_rand(1,$this->width-2),mt_rand(1,$this->height-2),$color); } //圓弧 for($a=0;$a<20;$a++){ $color=imagecolorallocate($this->img,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200)); imagearc($this->img,mt_rand(10,$this->width-10),mt_rand(4,$this->height-5),mt_rand(20,100),mt_rand(20,100),20,100,$color); } } /** * 輸出到網頁 * @access private */ private function outPut() { ob_end_clean(); //清空前面的輸出 if(imagetypes()&IMG_GIF){ header("Content-Type:image/gif"); imagegif($this->img); }elseif(imagetypes()&IMG_PNG){ header("Content-Type:image/png"); imagepng($this->img); }elseif(imagetypes()&IMG_JPEG){ header("Content-Type:image/jpge"); imagejpeg($this->img,null,100); }else{ die("error:no image in the php server"); } imagedestroy($this->img); } /** * 對外生成 * @access private * @return 驗證碼 */ public function generateCode() { $this->createBg(); $this->createCode(); $this->createLine(); $this->createFont(); $this->outPut(); } /** * 獲取驗證碼的正確碼值 * @access public * @return string 小寫的驗證碼碼值 */ public function getCode() { return strtolower($this->code); } } $c = new Captcha(); $c->generateCode(); @session_start(); $_SESSION['captcha'] = $c->getCode(); ~~~ # home.html ~~~ <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>session 圖片驗證實例</title> <style type="text/css"> #login p{ margin-top: 15px; line-height: 20px; font-size: 14px; font-weight: bold; } #login img{ cursor:pointer; } form{ margin-left:20px; } </style> </head> <body> <?php @session_start(); header('Expires:-1'); header('Cache-Control:no-cache'); header('Pragma:no-cache'); ?> <form id="login" action="./check.php" method="post"> <p>此例為session驗證碼,不區分大小寫,點擊圖片更換</p> <p> <span>驗證碼:</span> <input type="text" name="validate" value="" size=10> <img title="點擊刷新" src="Captcha.class.php" onclick="this.src='Captcha.class.php?r='+Math.random()"></img> </p> <p> <input type="submit"> </p> </form> ~~~ # check.php ~~~ <?php @session_start(); echo "<a href='./home.html'>返回驗證</a><br /><br />"; if(isset($_POST["validate"])){ $validate=mb_strtolower(trim($_POST["validate"]),'utf-8'); echo "您剛才輸入的是!<font color='blue'>".$_POST["validate"]."</font>!<br>"; if($validate != $_SESSION["captcha"]){ //判斷session值與用戶輸入的驗證碼是否一致; echo "<font color=red>輸入有誤</font>"; echo "<br />答案是!<font color='blue'>".$_SESSION['captcha'],"</font>!<br />"; }else{ echo "<font color=green>通過驗證</font>"; echo "<br />答案是!<font color='blue'>".$_SESSION['captcha'],"</font>!<br />"; } } ?> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看