频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> PHP教程 -> 用PHP实现登陆验证码(类似条行码状)

用PHP实现登陆验证码(类似条行码状)

作者:未知  来源:http://edu.chinaz.com  发布时间:2005-7-19 0:27:15  发布人:acx

减小字体 增大字体

<?php

function UPCAbarcode($code) {
  $lw = 2; $hi = 100;
  $Lencode = array('0001101','0011001','0010011','0111101','0100011',
                   '0110001','0101111','0111011','0110111','0001011');
  $Rencode = array('1110010','1100110','1101100','1000010','1011100',
                   '1001110','1010000','1000100','1001000','1110100');
  $ends = '101'; $center = '01010';
  /* UPC-A Must be 11 digits, we compute the checksum. */
  if ( strlen($code) != 11 ) { die("UPC-A Must be 11 digits."); }
  /* Compute the EAN-13 Checksum digit */
  $ncode = '0'.$code;
  $even = 0; $odd = 0;
  for ($x=0;$x<12;$x++) {
    if ($x % 2) { $odd += $ncode[$x]; } else { $even += $ncode[$x]; }
  }
  $code.=(10 - (($odd * 3 + $even) % 10)) % 10;
  /* Create the bar encoding using a binary string */
  $bars=$ends;
  $bars.=$Lencode[$code[0]];
  for($x=1;$x<6;$x++) {
    $bars.=$Lencode[$code[$x]];
  }
  $bars.=$center;
  for($x=6;$x<12;$x++) {
    $bars.=$Rencode[$code[$x]];
  }
  $bars.=$ends;
  /* Generate the Barcode Image */
  $img = ImageCreate($lw*95+30,$hi+30);
  $fg = ImageColorAllocate($img, 0, 0, 0);
  $bg = ImageColorAllocate($img, 255, 255, 255);
  ImageFilledRectangle($img, 0, 0, $lw*95+30, $hi+30, $bg);
  $shift=10;
  for ($x=0;$x<strlen($bars);$x++) {
    if (($x<10) || ($x>=45 && $x<50) || ($x >=85)) { $sh=10; } else { $sh=0; }
    if ($bars[$x] == '1') { $color = $fg; } else { $color = $bg; }
    ImageFilledRectangle($img, ($x*$lw)+15,5,($x+1)*$lw+14,$hi+5+$sh,$color);
  }
  /* Add the Human Readable Label */
  ImageString($img,4,5,$hi-5,$code[0],$fg);
  for ($x=0;$x<5;$x++) {
    ImageString($img,5,$lw*(13+$x*6)+15,$hi+5,$code[$x+1],$fg);
    ImageString($img,5,$lw*(53+$x*6)+15,$hi+5,$code[$x+6],$fg);
  }
  ImageString($img,4,$lw*95+17,$hi-5,$code[11],$fg);
  /* Output the Header and Content. */
  header("Content-Type: image/png");
  ImagePNG($img);
}

UPCAbarcode('12345678901');

?>


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
下一篇文章:php做饼图的函数
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· X-Space详细图文安装及常..
· 用Photoshop打造时尚美女..
· ImageReady CS新功能掠影..
· ASP网站远程客户实现EXC..
· ASP创建用户,目录和站点..
· 用VB创建FTP组件(get)
· 介绍MS Agent控件在VB.N..
· 网页学习基础知识之认识..
· Photoshop打造肌理文字—..
· 制作简单又漂亮的网格字..
· 被Google Adsense 除名后..
· 按下回车键指向下一个位..
· CSS样式表:详细介绍IE7..
· 关于打印页面的一些经验..
· 新网站如何获得外部的优..
· “熊猫烧香”背后的牟利..
相关文章
· 使用PHP的日期与时间函数提..
· 用PHP程序直接调用文本文件..
· 用PHP添加地图功能
· 用PHP命令行控制脚本
· 用PHP实现windows风格的树型..
· 新手学习用PHP程序对网页表..
· 用PHP5的DirectoryIterator..
· 用PHP程序实现删除目录的三..
· 用PHP程序实现从数组里筛选..
· 实用:使用PHP脚本修改Linu..
· 用PHP脚本生成word文档的程..
· 技巧:用PHP编写留言本应注意..
· 如何利用PHP+MYSQL保存和输..
· PHP实例:用PHP编写的网上调..
· 使用PHP开发网站过程中你注..
· PHP实例:用PHP实现多文件上..
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号