captcha_non_gd.php
来自「这些都是我以前学习是用到的源码」· PHP 代码 · 共 343 行 · 第 1/5 页
PHP
343 行
if ($i > $offset_y && $i < $offset_y + $img_height) { for ($j = 0; $j < $offset_x; $j++) { $image .= chr(mt_rand(140, 255)); } for ($j = 0; $j < $code_len; $j++) { $image .= $this->randomise(substr($hold_chars[$code{$j}][$i - $offset_y - 1], 1), $char_widths[$j]); } for ($j = $offset_x + $img_width; $j < $this->width; $j++) { $image .= chr(mt_rand(140, 255)); } } else { for ($j = 0; $j < $this->width; $j++) { $image .= chr(mt_rand(140, 255)); } } } unset($hold_chars); $image = $this->create_png($image, $this->width, $this->height); // Output image header('Content-Type: image/png'); header('Cache-control: no-cache, no-store'); echo $image; exit; } /** * This is designed to randomise the pixels of the image data within * certain limits so as to keep it readable. It also varies the image * width a little */ function randomise($scanline, $width) { $new_line = ''; $end = strlen($scanline) - ceil($width/2); for ($i = floor($width/2); $i < $end; $i++) { $pixel = ord($scanline{$i}); if ($pixel < 190) { $new_line .= chr(mt_rand(0, 205)); } else if ($pixel > 190) { $new_line .= chr(mt_rand(145, 255)); } else { $new_line .= $scanline{$i}; } } return $new_line; } /** * This creates a chunk of the given type, with the given data
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?