本文整理汇总了PHP中imagechar函数的典型用法代码示例。如果您正苦于以下问题:PHP imagechar函数的具体用法?PHP imagechar怎么用?PHP imagechar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagechar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: checkcode
public function checkcode($width = 60, $height = 24, $verifyName = 'checkcode')
{
if (!isset($_SESSION)) {
session_start();
}
$code = "ABCDEFGHKLMNPRSTUVWYZ23456789";
$length = 4;
$randval = '';
for ($i = 0; $i < $length; $i++) {
$char = $code[rand(0, strlen($code) - 1)];
$randval .= $char;
}
$_SESSION[$verifyName] = strtolower($randval);
$width = $length * 10 + 10 > $width ? $length * 10 + 10 : $width;
$im = imagecreate($width, $height);
$backColor = imagecolorallocate($im, 255, 255, 255);
$borderColor = imagecolorallocate($im, 255, 255, 255);
@imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
@imagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);
$fontcolor = imagecolorallocate($im, rand(0, 200), rand(0, 120), rand(0, 120));
for ($i = 0; $i < $length; $i++) {
$fontsize = 5;
$x = floor($width / $length) * $i + 5;
$y = rand(0, $height - 15);
imagechar($im, $fontsize, $x, $y, $randval[$i], $fontcolor);
}
self::output($im, 'png');
}
开发者ID:43431655,项目名称:qizhongbao,代码行数:28,代码来源:image.class.php
示例2: render
/**
* 显示验证码
*/
public function render()
{
header('Pragma: no-cache');
header('Cache-Control: no-cache');
header('Content-Type: image/jpeg');
$image = imagecreatetruecolor(79, 25);
$color_Background = imagecolorallocate($image, mt_rand(190, 255), mt_rand(190, 255), mt_rand(190, 255));
imagefill($image, 0, 0, $color_Background);
$key = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'T', 'U', 'V', 'W', 'X', 'Y', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'h', 'i', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 't', 'v', 'w', 'x', 'y');
$string = null;
$char_X = mt_rand(1, 20);
$char_Y = 0;
for ($i = 0; $i < 4; $i++) {
$char_Y = mt_rand(1, 6);
$char = $key[mt_rand(0, 49)];
$string .= $char;
$color_Char = imagecolorallocate($image, mt_rand(20, 190), mt_rand(20, 190), mt_rand(20, 190));
imagechar($image, 5, $char_X, $char_Y, $char, $color_Char);
$char_X = $char_X + mt_rand(8, 20);
}
$this->_code = $string;
$_SESSION[self::SESSION_KEY] = $string;
imagegif($image);
imagedestroy($image);
}
开发者ID:sibphp,项目名称:sframe,代码行数:28,代码来源:Captcha.php
示例3: image
/**
* generates the image for the captcha
* @param string $name, used in the session
* @param int $width
* @param int $height
* @param string $baseList
*/
public static function image($name = '', $width = 120, $height = 40, $baseList = '123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ')
{
//echo $name.' orig= '.Session::instance()->get('captcha_'.$name).'<br>';
$length = mt_rand(3, 5);
//code length
$lines = mt_rand(1, 5);
//to make the image dirty
$image = @imagecreate($width, $height) or die('Cannot initialize GD!');
$code = '';
//code generated saved at session
//base image with dirty lines
for ($i = 0; $i < $lines; $i++) {
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), imagecolorallocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
}
//writting the chars
for ($i = 0, $x = 0; $i < $length; $i++) {
$actChar = substr($baseList, rand(0, strlen($baseList) - 1), 1);
$x += 10 + mt_rand(0, 10);
imagechar($image, mt_rand(4, 5), $x, mt_rand(5, 20), $actChar, imagecolorallocate($image, mt_rand(0, 155), mt_rand(0, 155), mt_rand(0, 155)));
$code .= strtolower($actChar);
}
Session::instance()->set('captcha_' . $name, $code);
//die( 'changed= '.Session::instance()->get('captcha_'.$name));
// prevent client side caching
header("Expires: Wed, 1 Jan 1997 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", FALSE);
header("Pragma: no-cache");
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
}
开发者ID:ThomWensink,项目名称:common,代码行数:40,代码来源:captcha.php
示例4: create_captha_img
function create_captha_img($char)
{
$width = 100;
$height = 25;
$im = @imagecreate($width, $height) or die("Cannot initialize new GD image stream!");
$char = str_replace(array('a', 'b', 'c', 'd', 'e', 'f'), array('1', '5', '8', '2', '7', '9'), $char);
$char = substr($char, 1, 4);
imagecolortransparent($im, imagecolorallocate($im, 205, 255, 255));
for ($i = 0; $i < strlen($char); $i++) {
$text_color = imagecolorallocate($im, rand(200, 255), rand(0, 120), rand(0, 120));
$x = $width / 10 + $i * ($width / 5);
$y = 0;
imagechar($im, 4, $x, $y, chr(rand(65, 90)), $text_color);
}
imageline($im, 1, rand(5, 10), $width - 10, rand(5, 10), imagecolorallocatealpha($im, rand(180, 255), rand(0, 120), rand(0, 120), 60));
for ($i = 0; $i < strlen($char); $i++) {
$text_color = imagecolorallocate($im, rand(0, 180), rand(0, 180), rand(0, 180));
$x = rand(0, 5) + $i * $width / rand(4, 5);
$y = rand(8, 12);
imagechar($im, 5, $x, $y, $char[$i], $text_color);
}
ob_start();
imagepng($im);
$src = 'data:image/png;base64,' . base64_encode(ob_get_contents());
ob_end_clean();
imagedestroy($im);
return $src;
}
开发者ID:LeonisX,项目名称:cms,代码行数:28,代码来源:index.php
示例5: verify_code
function verify_code()
{
$randCode = '';
$chars = 'abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPRSTUVWXYZ23456789';
for ($i = 0; $i < 5; $i++) {
$randCode .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
$img = imagecreate(70, 22);
$bgColor = imagecolorallocate($img, 255, 255, 255);
$pixColor = imagecolorallocate($img, mt_rand(30, 180), mt_rand(10, 100), mt_rand(40, 250));
for ($i = 0; $i < 5; $i++) {
$x = $i * 13 + mt_rand(0, 4) - 2;
$y = mt_rand(0, 3);
$text_color = imagecolorallocate($img, mt_rand(30, 180), mt_rand(10, 100), mt_rand(40, 250));
imagechar($img, 5, $x + 5, $y + 3, $randCode[$i], $text_color);
}
for ($j = 0; $j < 60; $j++) {
$x = mt_rand(0, 70);
$y = mt_rand(0, 22);
imagesetpixel($img, $x, $y, $pixColor);
}
$_SESSION['code'] = $randCode;
header('Content-Type: image/png');
imagepng($img);
imagedestroy($img);
}
开发者ID:simayubo,项目名称:simple,代码行数:26,代码来源:function.php
示例6: getCaptcha
/**
* 生成验证码
* @param int $width 验证码图片宽度.默认130
* @param int $height 验证码图片高度.默认40
* @param int $fontSize 验证码字体大小.默认20
* @param int $length 验证码字符个数.默认4
* @return string 验证码中的字符串
*/
public static function getCaptcha($width = '130', $height = '40', $fontSize = '20', $length = '4')
{
$chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$randStr = substr(str_shuffle($chars), 0, $length);
$image = imagecreatetruecolor($width, $height);
// 定义背景色
$bgColor = imagecolorallocate($image, 0xff, 0xff, 0xff);
// 定义文字及边框颜色
$blackColor = imagecolorallocate($image, 0x0, 0x0, 0x0);
//生成矩形边框
imagefilledrectangle($image, 0, 0, $width, $height, $bgColor);
// 循环生成雪花点
for ($i = 0; $i < 200; $i++) {
$grayColor = imagecolorallocate($image, 128 + rand(0, 128), 128 + rand(0, 128), 128 + rand(0, 128));
imagesetpixel($image, rand(1, $width - 2), rand(4, $height - 2), $grayColor);
}
$font = ROOT_PATH . 'resources/fonts/acidic.ttf';
// 把随机字符串输入图片
$i = -1;
while (isset($randStr[++$i])) {
$fontColor = imagecolorallocate($image, rand(0, 100), rand(0, 100), rand(0, 100));
if (!function_exists('imagettftext')) {
imagechar($image, $fontSize, 15 + $i * 30, rand(5, 20), $randStr[$i], $fontColor);
} else {
imagettftext($image, $fontSize, 0, 10 + $i * 30, rand(25, 35), $fontColor, $font, $randStr[$i]);
}
}
imagepng($image);
$image = $bgColor = $blackColor = $grayColor = $fontColor = null;
return $randStr;
}
开发者ID:hellocc2,项目名称:crmht,代码行数:39,代码来源:Image.php
示例7: newVerify
public static function newVerify($width = 60, $height = 25)
{
$im = imagecreate($width, $height);
$backgroundcolor = imagecolorallocate($im, 255, 255, 255);
$mCheckCodeNum = 4;
$mCheckCode = '';
for ($i = 0; $i < $mCheckCodeNum; $i++) {
$mCheckCode .= strtoupper(chr(rand(97, 122)));
}
$session = new XF_Session('XF_ImageVerify');
$session->write(strtolower($mCheckCode));
for ($i = 0; $i <= 64; $i++) {
$pointcolor = imagecolorallocate($im, mt_rand(1, 155), mt_rand(0, 200), mt_rand(1, 155));
imagesetpixel($im, mt_rand(0, $width - 1), mt_rand(0, $height - 1), $pointcolor);
}
$snowflake_size = 5;
for ($i = 0; $i < $mCheckCodeNum; $i++) {
$font_color = imagecolorallocate($im, mt_rand(1, 155), mt_rand(1, 200), 100);
$x = floor($width / $mCheckCodeNum) * $i + 3;
$y = rand(0, $height - 15);
imagechar($im, $snowflake_size, $x, $y, $mCheckCode[$i], $font_color);
}
$bordercolor = imagecolorallocate($im, 188, 188, 188);
imagerectangle($im, 0, 0, $width - 1, $height - 1, $bordercolor);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
}
开发者ID:kevinwan,项目名称:xf,代码行数:28,代码来源:Images.php
示例8: writeCheckCodeToImage
private function writeCheckCodeToImage()
{
for ($i = 0; $i <= $this->codenum; $i++) {
$bg_color = imagecolorallocate($this->checkimage, rand(0, 255), rand(0, 128), rand(0, 255));
$x = floor($this->width / $this->codenum) * $i + 2;
$y = rand(1, $this->height - 15);
imagechar($this->checkimage, rand(5, 8), $x, $y, $this->checkcode[$i], $bg_color);
}
}
开发者ID:rust1989,项目名称:edit,代码行数:9,代码来源:validationCode.php
示例9: WriteCheckCodeToImage
/**
* @write code to Image
*/
function WriteCheckCodeToImage()
{
for ($i = 0; $i <= $this->mCheckCodeNum; $i++) {
$bg_color = imagecolorallocate($this->mCheckImage, rand(0, 255), rand(0, 128), rand(0, 255));
$x = floor($this->mCheckImageWidth / $this->mCheckCodeNum) * $i;
$y = rand(0, $this->mCheckImageHeight - 15);
imagechar($this->mCheckImage, 5, $x, $y, $this->mCheckCode[$i], $bg_color);
}
}
开发者ID:Jesuslagliva12,项目名称:OpenAPI,代码行数:12,代码来源:captcha.class.php
示例10: outputtext
private function outputtext()
{
for ($i = 0; $i < $this->codeNum; $i++) {
$fontcolor = imagecolorallocate($this->image, rand(0, 128), rand(0, 128), rand(0, 128));
$fontsize = rand(3, 5);
$x = floor($this->width / $this->codeNum) * $i + 3;
$y = rand(0, $this->height - imagefontheight($fontsize));
imagechar($this->image, $fontsize, $x, $y, $this->checkcode[$i], $fontcolor);
}
}
开发者ID:JiaJia01,项目名称:homework_09,代码行数:10,代码来源:yzm1.php
示例11: outputText
private function outputText()
{
for ($i = 0; $i <= $this->codeNum; $i++) {
$bg_color = imagecolorallocate($this->image, mt_rand(0, 255), mt_rand(0, 128), mt_rand(0, 255));
$x = floor($this->width / $this->codeNum) * $i + 3;
$y = mt_rand(0, $this->height - 15);
$str = substr($this->checkCode, $i, 1);
imagechar($this->image, 5, $x, $y, $str, $bg_color);
}
}
开发者ID:laiello,项目名称:ffphp,代码行数:10,代码来源:verify.class.php
示例12: setCaptcha
private function setCaptcha()
{
for ($i = 0; $i < $this->codeNum; $i++) {
$color = imagecolorallocate($this->im, rand(50, 250), rand(100, 250), rand(128, 250));
$size = rand(floor($this->height / 5), floor($this->height / 3));
$x = floor($this->width / $this->codeNum) * $i + 5;
$y = rand(0, $this->height - 20);
imagechar($this->im, $size, $x, $y, $this->code[$i], $color);
}
}
开发者ID:jaya-project,项目名称:zycms,代码行数:10,代码来源:MyCaptcha.php
示例13: outputText
private function outputText()
{
for ($i = 0; $i < $this->codeNum; $i++) {
$bg_color = imagecolorallocate($this->image, rand(0, 255), rand(0, 128), rand(0, 255));
$x = floor($this->width / $this->codeNum) * $i + 3;
$y = rand(0, $this->height - 15);
//echo $this->checkCode;
imagechar($this->image, 5, $x, $y, $this->checkCode[$i], $bg_color);
}
}
开发者ID:yunkaiyueming,项目名称:ci_cms,代码行数:10,代码来源:ValidateCode.php
示例14: outstring
private function outstring()
{
for ($i = 0; $i < $this->num; $i++) {
$color = imagecolorallocate($this->img, rand(0, 128), rand(0, 128), rand(0, 128));
$fontsize = rand(3, 5);
$x = 3 + $this->width / $this->num * $i;
$y = rand(0, imagefontheight($fontsize) - 3);
imagechar($this->img, $fontsize, $x, $y, $this->code[$i], $color);
}
}
开发者ID:Qsaka,项目名称:rumRaisin,代码行数:10,代码来源:getCaptcha.php
示例15: drawCode
private function drawCode()
{
for ($i = 0; $i < $this->codeLen; $i++) {
$color = imagecolorallocate($this->img, mt_rand(0, 128), mt_rand(0, 128), mt_rand(0, 128));
$fontsize = mt_rand(5, 8);
$x = 3 + $this->codeWidth / $this->codeLen * $i;
$y = rand(2, imagefontheight($fontsize) - 10);
imagechar($this->img, $fontsize, $x, $y, $this->code[$i], $color);
}
return;
}
开发者ID:marche147,项目名称:nsc-website,代码行数:11,代码来源:verify_code.php
示例16: setCaptcha
private function setCaptcha()
{
$this->createCode();
for ($i = 0; $i < $this->codeNum; $i++) {
$color = imagecolorallocate($this->im, hexdec(substr($this->fontColor, 1, 2)), hexdec(substr($this->fontColor, 3, 2)), hexdec(substr($this->fontColor, 5, 2)));
$size = rand(floor($this->height / 5), floor($this->height / 3));
$x = floor($this->width / $this->codeNum) * $i + 5;
$y = rand(0, $this->height - 20);
imagechar($this->im, $size, $x, $y, $this->code[$i], $color);
}
}
开发者ID:ailingsen,项目名称:pigcms,代码行数:11,代码来源:checkCode.class.php
示例17: _create_captha_img
/**
* MaxSite CMS
* (c) http://max-3000.com/
*/
function _create_captha_img()
{
$width = 100;
$height = 25;
$im = @imagecreate($width, $height) or die("Cannot initialize new GD image stream!");
if (isset($_GET['image']) and isset($_GET['page'])) {
$char = md5($_GET['image'] . $_GET['page']);
} else {
die("error");
}
$char = str_replace(array('a', 'b', 'c', 'd', 'e', 'f'), array('0', '5', '8', '3', '4', '7'), $char);
$char = substr($char, 1, 4);
imagecolortransparent($im, imagecolorallocate($im, 205, 255, 255));
// rnd
for ($i = 0; $i < strlen($char); $i++) {
// $text_color = imagecolorallocate ($im, rand(220,255), rand(0,40), 120);
$text_color = imagecolorallocate($im, 255, 0, 0);
$x = $width / 10 + $i * ($width / 5);
// $y = rand(0, 5);
$y = 0;
imagechar($im, 4, $x, $y, chr(rand(49, 90)), $text_color);
}
$point_color = imagecolorallocate($im, 255, 120, 120);
ImageLine($im, 3, 9, 150, 2, $point_color);
//output characters
for ($i = 0; $i < strlen($char); $i++) {
$text_color = imagecolorallocate($im, rand(0, 120), rand(0, 180), rand(0, 180));
// $x = 5 + $i * 40 + rand(-5, 5);
$x = 3 + $i * $width / 4;
//$y = rand(0, 5);
$y = 10;
imagechar($im, 5, $x, $y, $char[$i], $text_color);
}
//ouput PNG
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// HTTP/1.0
if (function_exists("imagepng")) {
header("Content-type: image/png");
imagepng($im);
} elseif (function_exists("imagegif")) {
header("Content-type: image/gif");
imagegif($im);
} elseif (function_exists("imagejpeg")) {
header("Content-type: image/jpeg");
imagejpeg($im);
} else {
die("No image support in this PHP server!");
}
imagedestroy($im);
}
开发者ID:rb2,项目名称:MaxSite-CMS,代码行数:58,代码来源:img.php
示例18: setCaptcha
private function setCaptcha()
{
$this->createCode();
$changdu = strlen($this->codeNum);
for ($i = 0; $i < $changdu; $i++) {
$color = imagecolorallocate($this->im, 250, 0, 0);
// $size = rand(floor($this->height / 5), floor($this->height / 3));
$x = floor($this->width / $changdu) * $i + 5;
$y = rand(0, $this->height - 20);
imagechar($this->im, 5, $x, $y, $this->code[$i], $color);
}
}
开发者ID:kenleemyth,项目名称:MythPHPQuery,代码行数:12,代码来源:telimg.class.php
示例19: setCaptcha
private function setCaptcha()
{
$this->createCode();
$tCode = '';
for ($i = 0; $i < $this->codeNum; $i++) {
$color = imagecolorallocate($this->im, rand(200, 250), rand(200, 250), rand(228, 250));
$size = rand(floor($this->height / 5), floor($this->height / 3));
$x = floor($this->width / $this->codeNum) * $i + 5;
$y = rand(0, $this->height - 20);
imagechar($this->im, $size, $x, $y, $this->code[$i], $color);
$tCode .= $this->code[$i];
}
$_SESSION['captcha'] = $tCode;
}
开发者ID:tanqinwang,项目名称:test_own,代码行数:14,代码来源:Captcha.php
示例20: yzm
function yzm($width = 100, $height = 40, $length = 4, $type = 3, $imageType = 'jpeg')
{
switch ($type) {
case 1:
$str = join('', array_rand(range(0, 9), 4));
break;
case 2:
$str = join('', array_rand(array_flip(range(a, z)), 4));
break;
case 3:
$str = '';
for ($i = 0; $i < 4; $i++) {
$sj = mt_rand(0, 2);
switch ($sj) {
case 0:
$char = mt_rand(0, 9);
break;
case 1:
$char = array_rand(array_flip(range('a', 'z')), 1);
break;
case 2:
$char = array_rand(array_flip(range('A', 'Z')), 1);
break;
}
$str .= $char;
}
break;
}
//echo $str; 不可以输出
$_SESSION['yzm'] = $str;
$img = imagecreate($width, $height);
imagefilledrectangle($img, 0, 0, $width, $height, qianys($img));
//干扰元素,像素点
for ($i = 0; $i < 50; $i++) {
imagesetpixel($img, mt_rand(1, $width), mt_rand(1, $height), shenys($img));
}
//干扰元素,线段
for ($i = 0; $i < 4; $i++) {
imageline($img, mt_rand(1, $width), mt_rand(1, $height), mt_rand(1, $width), mt_rand(1, $height), shenys($img));
}
//写字
for ($i = 0; $i < 4; $i++) {
imagechar($img, 5, mt_rand(25 * $i, 22 * ($i + 1)), mt_rand(1, 25), $str[$i], shenys($img));
}
//输出
header('Content-Type:image/jpeg');
imagejpeg($img);
//关闭资源
imagedestroy($img);
}
开发者ID:xiexianbo123,项目名称:boshop,代码行数:50,代码来源:yzm.func.php
注:本文中的imagechar函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论