修改获取验证码图片到本地的PHP程序

最近项目不是很大,所以时间比较的空间,昨天琢磨着写点东西,想起了前几天电信公司投票选微笑天使的活动,投票是要填写验证码的,想了下想写个投票作弊程序,可是等我放假回来,人家活动已经结束了,昨天突然想起来,就写了一个获取验证码图片到本地的PHP程序,以备今后有类似的投票活动可以直接拿来使用。

程序采用了PHP的GD库,原理很简单,就是先建立一张空白图片,然后把验证码的图片使用PHP GD库中的imagecreatefromjpeg函数建立一个image对象,最后计算图片的长宽,再次使用PHP内置的imagecopy复制到一开始建立的空白图片上去。
全部代码如下:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
header("Content-type:image/png");
set_time_limit(0);//设置PHP超时时间
$url = $_GET[‘url’];
$url = "http://vcer.baidu.com/verify";
$imginfo = GetImageSize ( $url );
$imgw = $imginfo [0];
$imgh = $imginfo [1];
$bg = imagecreatetruecolor($imgw,$imgh);
$image = imagecreatefromjpeg($url);
imagecolorallocate($image,255,255,255);
imagecopy($bg,$image,0,0, 0,0,$imgw,$imgh);
imagedestroy($image);
ImagePng($bg);

此处的代码支持验证码格式为jpg的格式,如果是png或者gif的格式可以参考第二页。

通过上一页一个获取验证码图片到本地的PHP程序,对于验证码为jpg格式的图片是可以正常输出的,对于png、gif的验证码则不能正常使用,今天稍微修改一下PHP代码,使其可以支持png、gif、jpg三种格式的验证码。

PHP判断图片的格式可使用php内置的exif_imagetype函数,非常方便,

关于exif_imagetype的详细使用方法可以访问:http://php.net/manual/en/function.exif-imagetype.php

代码:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com]
header("Content-type:image/png");
set_time_limit(0);//设置PHP超时时间
$url = $_GET[‘url’];
$url = "http://vcer.baidu.com/verify";
if(empty($url)){
echo "没有图片";
die;
}
$imginfo = GetImageSize ( $url );
$type = exif_imagetype($url);
$imgw = $imginfo [0];
$imgh = $imginfo [1];
$bg = imagecreatetruecolor($imgw,$imgh);
if($type==IMAGETYPE_GIF){
$image = imagecreatefromgif($url);
}elseif($type==IMAGETYPE_JPEG){
$image = imagecreatefromjpeg($url);
}elseif($type==IMAGETYPE_PNG){
$image = imagecreatefrompng($url);
}

imagecolorallocate($image,255,255,255);
imagecopy($bg,$image,0,0, 0,0,$imgw,$imgh);
imagedestroy($image);
ImagePng($bg);

波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » 修改获取验证码图片到本地的PHP程序

154 评论

  1. spironolactone 100mg canada propecia 1mg uk fluconazole 200mg canada

  2. ampicillin 500mg over the counter cephalexin 500mg usa order erythromycin 500mg without prescription

  3. isotretinoin 10mg generic accutane us zithromax pills

  4. modafinil 100mg brand Sales cialis diamox 250 mg oral

  5. alendronate over the counter pepcid generic order pepcid online cheap

  6. order sertraline zoloft price order viagra online

  7. order chloroquine aralen us baricitinib 4mg ca

  8. buy orlistat online cheap purchase xenical order acyclovir 800mg without prescription

  9. generic sildenafil 50mg cialis pharmacy cost tadalafil 20mg

  10. buy alendronate 35mg generic motrin pill ibuprofen 600mg brand

  11. minocin 50mg over the counter cost hytrin 5mg order terazosin 5mg pills

  12. ivermectin 3mg tablets price prednisone brand order deltasone 40mg for sale

  13. generic zyrtec 10mg buy zyrtec buy cheap generic sertraline

  14. buy generic letrozole for sale buy viagra pills sildenafil 100mg cost

  15. how to get provigil without a prescription deltasone drug oral deltasone 5mg

  16. cost ventolin 4mg albuterol us synthroid brand

  17. lisinopril 10mg without prescription order zestril pills lopressor 100mg canada

  18. where can i buy ipratropium cheap dexamethasone purchase zyvox without prescription

  19. buy cleocin no prescription cleocin medication order sildenafil online cheap

  20. arava 20mg tablet order viagra order azulfidine 500mg

  21. purchase azipro generic cheap gabapentin order neurontin 100mg online cheap

  22. vardenafil 10mg drug plaquenil sale buy hydroxychloroquine

  23. order asacol generic asacol us avapro 300mg uk

  24. crestor over the counter zetia price order domperidone 10mg generic

  25. buy plavix medication coumadin cost buy coumadin 2mg pill

  26. buy budesonide without a prescription budesonide drug buy careprost generic

  27. celecoxib 100mg brand tamsulosin pills buy ondansetron 4mg without prescription

  28. tadacip 10mg drug voltaren canada buy indomethacin 50mg capsule

  29. purchase lansoprazole without prescription protonix online buy pantoprazole pills for sale

  30. where to buy fexofenadine without a prescription amaryl order purchase glimepiride generic

  31. purchase albendazole for sale albendazole sale buy generic medroxyprogesterone 5mg

  32. praziquantel tablet periactin us buy cyproheptadine 4mg generic

  33. buy generic fluvoxamine fluvoxamine brand order duloxetine 20mg online cheap

  34. purchase decadron online cheap buy linezolid 600mg order nateglinide 120 mg sale

  35. buy zyban without prescription oral zyrtec 5mg cost atomoxetine

  36. buy frumil sale order frumil where to buy acyclovir without a prescription

  37. order bisoprolol generic lozol order buy oxytetracycline no prescription

评论已关闭

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡