最近项目不是很大,所以时间比较的空间,昨天琢磨着写点东西,想起了前几天电信公司投票选微笑天使的活动,投票是要填写验证码的,想了下想写个投票作弊程序,可是等我放假回来,人家活动已经结束了,昨天突然想起来,就写了一个获取验证码图片到本地的PHP程序,以备今后有类似的投票活动可以直接拿来使用。
程序采用了PHP的GD库,原理很简单,就是先建立一张空白图片,然后把验证码的图片使用PHP GD库中的imagecreatefromjpeg函数建立一个image对象,最后计算图片的长宽,再次使用PHP内置的imagecopy复制到一开始建立的空白图片上去。
全部代码如下:

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
代码:

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);
波比源码 » 修改获取验证码图片到本地的PHP程序
154 评论
评论已关闭
levofloxacin online order levofloxacin 250mg for sale
spironolactone 100mg canada propecia 1mg uk fluconazole 200mg canada
ampicillin 500mg over the counter cephalexin 500mg usa order erythromycin 500mg without prescription
sildenafil 100mg generic order aurogra 100mg for sale estradiol 1mg for sale
isotretinoin 10mg generic accutane us zithromax pills
indomethacin 50mg ca order generic indocin 75mg amoxicillin over the counter
arimidex 1 mg canada viagra 100 mg best price order viagra 50mg online cheap
tadalafil sans ordonnance viagra 50mg generique en pharmacie viagra sans ordonnance en pharmacie
cialis 5mg fГјr frauen tadalafil 20mg ohne rezept sildenafil 100mg kaufen ohne rezept
accutane generic purchase zithromax online cheap purchase ivermectin
modafinil 100mg brand Sales cialis diamox 250 mg oral
order altace sale purchase ramipril pill order astelin 10ml for sale
buspirone 10mg generic oral amiodarone 100mg oxybutynin 5mg sale
alendronate over the counter pepcid generic order pepcid online cheap
order generic zyban order generic zyrtec 10mg seroquel 100mg uk
order sertraline zoloft price order viagra online
salbutamol cheap viagra 50mg pills for men viagra 100mg generic
brand naltrexone 50mg buy femara generic buy abilify
furosemide 40mg without prescription furosemide 40mg tablet plaquenil brand
order tadalafil 10mg sale order anafranil 50mg generic anafranil brand
order chloroquine aralen us baricitinib 4mg ca
zyprexa price order olanzapine 10mg pill diovan for sale
order viagra 100mg online cheap viagra 50mg without prescription cheap lisinopril 2.5mg
pay for essay assignment writing services casino arizona
triamcinolone price triamcinolone online buy buy clarinex online
priligy 30mg price order generic synthroid 100mcg levothyroxine price
buy orlistat online cheap purchase xenical order acyclovir 800mg without prescription
order generic motilium 10mg flexeril for sale online buy cyclobenzaprine generic
gloperba sale colchicine without prescription free roulette online
zantac 150mg us order ranitidine online celecoxib usa
tamsulosin 0.4mg generic purchase tamsulosin order aldactone 100mg online
order cialis 10mg sale buy tadalafil pills ciprofloxacin 1000mg cost
cialis 5mg canada cialis 20mg generic viagra pharmacy
prednisone tablet prednisone for sale online order amoxil 500mg generic
generic sildenafil 50mg cialis pharmacy cost tadalafil 20mg
purchase furosemide generic cost doxycycline 100mg plaquenil 400mg tablet
order deltasone 5mg online cheap deltasone for sale vermox price
purchase lamisil sale cost suprax 100mg buy trimox
how much is cialis Cialis delivered overnight cialis 10mg for sale
sugarhouse casino online help me with my paper buy dissertation online
order altace 5mg without prescription glimepiride 1mg cheap etoricoxib pills
mesalamine 400mg sale buy asacol 400mg generic order avapro 150mg
diamox 250 mg uk buy acetazolamide without prescription imuran sale
digoxin 250 mg cost brand digoxin 250 mg brand molnunat
buy alendronate 35mg generic motrin pill ibuprofen 600mg brand
pamelor 25mg drug cheap nortriptyline 25 mg paxil 10mg price
buy pepcid 40mg generic tacrolimus 5mg price mirtazapine 30mg cost
order doxycycline 200mg without prescription medrol online order medrol online
purchase requip generic buy calcitriol pills labetalol 100mg cheap
tadalafil 10mg over the counter trimox 250mg pills trimox price
fenofibrate price sildenafil 50mg us viagra for sale
order esomeprazole 40mg without prescription buy nexium 20mg without prescription order lasix 40mg
minocin 50mg over the counter cost hytrin 5mg order terazosin 5mg pills
order cialis 20mg online erectile dysfunction medicines generic ed drugs
purchase glucophage online buy verapamil 120mg generic purchase nolvadex for sale
buy clomiphene 50mg lipitor 10mg drug prednisolone 20mg price
best ed pills non prescription uk buy ed medications propecia 5mg price
ivermectin 3mg tablets price prednisone brand order deltasone 40mg for sale
purchase albuterol generic ventolin inhalator online buy amoxiclav for sale online
order isotretinoin 40mg for sale buy azithromycin 500mg sale order generic zithromax
buy prednisolone 20mg sale cheap lasix 100mg order lasix 40mg pills
avodart drug cheap keflex 500mg xenical 60mg drug
buy monodox for sale order levitra 10mg generic zovirax brand
ditropan 2.5mg generic buy ditropan 2.5mg without prescription buy trileptal 300mg sale
omnicef 300mg cheap lansoprazole cost pantoprazole 40mg uk
zocor drug sildenafil pharmacy purchase sildalis
order dapsone pills atenolol 100mg usa buy generic atenolol 50mg
buy ezetimibe medication methotrexate 5mg uk order generic methotrexate 10mg
brand medex buy coumadin generic brand zyloprim 100mg
generic zyrtec 10mg buy zyrtec buy cheap generic sertraline
where to buy cenforce without a prescription buy glycomet 1000mg online buy glycomet pills
generic escitalopram purchase lexapro without prescription order naltrexone 50 mg generic
buy atorvastatin 10mg generic cheap generic sildenafil sildenafil buy online
buy generic letrozole for sale buy viagra pills sildenafil 100mg cost
how to get provigil without a prescription deltasone drug oral deltasone 5mg
buy amoxil without a prescription cheap amoxicillin generic order prednisolone 20mg online cheap
cost ventolin 4mg albuterol us synthroid brand
cheap prednisolone 20mg order prednisolone without prescription purchase lasix
buy clomiphene 100mg online cheap buy clomiphene 50mg sale plaquenil 200mg tablet
purchase tenormin online buy tenormin online letrozole 2.5 mg ca
albendazole online aripiprazole 30mg generic provera online
glycomet 500mg usa metformin for sale online amlodipine drug
buy generic praziquantel order biltricide sale buy periactin 4mg generic
lisinopril 10mg without prescription order zestril pills lopressor 100mg canada
buy orlistat 120mg pills buy xenical paypal zyloprim brand
order generic tetracycline 500mg order flexeril without prescription lioresal pills
brand toradol 10mg brand toradol inderal pill
order clopidogrel generic buy clopidogrel 150mg online cheap buy ketoconazole without prescription
cymbalta ca brand duloxetine piracetam 800 mg usa
where can i buy ipratropium cheap dexamethasone purchase zyvox without prescription
buy nebivolol 5mg online where to buy bystolic without a prescription purchase clozaril for sale
order nateglinide for sale order nateglinide online cheap buy candesartan 8mg pill
zocor order online purchase viagra for sale buy viagra 50mg without prescription
order carbamazepine buy ciplox 500mg lincomycin 500mg ca
over the counter cialis Rx generic sildenafil sildenafil drug
buy cleocin no prescription cleocin medication order sildenafil online cheap
nolvadex medication budesonide oral buy ceftin pill
purchase bimatoprost generic trazodone 100mg sale trazodone 50mg over the counter
arava 20mg tablet order viagra order azulfidine 500mg
purchase azipro generic cheap gabapentin order neurontin 100mg online cheap
vardenafil 10mg drug plaquenil sale buy hydroxychloroquine
order asacol generic asacol us avapro 300mg uk
buy carvedilol 25mg buy carvedilol sale order aralen 250mg online cheap
acetazolamide medication buy azathioprine 50mg online buy imuran 50mg online
lanoxin drug order digoxin pills molnunat us
brand singulair 5mg where to buy montelukast without a prescription purchase dapsone online cheap
buy norvasc 5mg order norvasc 10mg pills prilosec 20mg ca
order metoprolol 100mg generic order metoprolol 50mg sale methylprednisolone 4mg tablets
order dapoxetine 30mg order cytotec 200mcg online buy generic xenical over the counter
buy triamcinolone 4mg online buy desloratadine online claritin 10mg us
buy diltiazem online allopurinol 100mg brand purchase zyloprim without prescription
crestor over the counter zetia price order domperidone 10mg generic
buy sumycin 250mg online cheap baclofen medication buy baclofen 10mg for sale
bactrim 960mg canada bactrim 480mg pills clindamycin pill
buy erythromycin tablets cost tamoxifen 20mg generic nolvadex 20mg
buy plavix medication coumadin cost buy coumadin 2mg pill
buy budesonide without a prescription budesonide drug buy careprost generic
brand metoclopramide 10mg order cozaar 50mg generic purchase esomeprazole without prescription
order robaxin 500mg generic cost desyrel 100mg purchase sildenafil
aurogra 100mg cheap purchase sildalis pills buy estrace generic
avodart medication meloxicam for sale online order meloxicam generic
celecoxib 100mg brand tamsulosin pills buy ondansetron 4mg without prescription
aldactone price buy aldactone for sale valtrex 500mg ca
buy propecia generic order viagra 100mg generic sildenafil 100mg for sale
tadacip 10mg drug voltaren canada buy indomethacin 50mg capsule
online cialis how to buy fluconazole buy ed pills generic
best ed drug tadalafil over the counter order cialis 10mg without prescription
purchase lansoprazole without prescription protonix online buy pantoprazole pills for sale
where can i buy ed pills order generic cialis 5mg oral cialis
purchase dapsone generic order generic aceon perindopril 4mg price
where to buy fexofenadine without a prescription amaryl order purchase glimepiride generic
order generic hytrin order generic pioglitazone overnight delivery cialis
arcoxia 60mg uk generic arcoxia astelin 10 ml usa
cordarone 100mg for sale order coreg 6.25mg buy generic dilantin online
buy irbesartan medication buspirone 5mg pills order generic buspar
purchase albendazole for sale albendazole sale buy generic medroxyprogesterone 5mg
praziquantel tablet periactin us buy cyproheptadine 4mg generic
buy generic fluvoxamine fluvoxamine brand order duloxetine 20mg online cheap
glipizide 10mg tablet buy betamethasone 20gm for sale betamethasone 20 gm cost
clomipramine for sale buy anafranil generic prometrium price
buy tacrolimus paypal buy cheap requip order requip 2mg
buy tinidazole online olanzapine 10mg drug bystolic online buy
order calcitriol online cheap buy generic labetalol 100mg order generic fenofibrate 160mg
order diovan pills clozapine 50mg cheap ipratropium canada
oxcarbazepine price oxcarbazepine 300mg oral order actigall 300mg sale
purchase decadron online cheap buy linezolid 600mg order nateglinide 120 mg sale
buy zyban without prescription oral zyrtec 5mg cost atomoxetine
buy capoten pills for sale order capoten 25 mg generic buy tegretol 200mg sale
purchase seroquel for sale order lexapro 10mg for sale escitalopram 10mg generic
purchase fluoxetine without prescription buy femara 2.5 mg pill femara for sale online
purchase epivir retrovir 300mg for sale accupril oral
buy frumil sale order frumil where to buy acyclovir without a prescription
order bisoprolol generic lozol order buy oxytetracycline no prescription
valaciclovir 1000mg uk buy generic valcivir 1000mg floxin 200mg us