求助!!哪位高人会PHP,帮我把这段代码转成C#的啊?急求!谢谢

问题描述

文件1code.php:<?phpheader("Content-type:text/html;charset=utf-8");include_once('conn/funcs.php');//自定义函数include('conn/Valite.php');$confirmId=$_GET['confirmId'];$data=getcurl("http://wap.cmgame.com:8080/portalone/WebGameQueryPicVcode?confirmId=".$confirmId);$path="code/".date("Ymd")."/";$fname=date("His").rand(1,9999).'.jpg';loginlog($path,$data,$fname);$valite=newValite();$valite->setImage($path.$fname);$valite->getHec();$ert=$valite->run();//$ert="1234";print_r($ert);@unlink($path.$fname);?>

解决方案

解决方案二:
============================================================================================文件二codeWENDA.php:<?phpheader("Content-type:text/html;charset=utf-8");include_once('conn/funcs.php');//自定义函数$Keys=array('0'=>'11111111111110000000001111111111111111111111110000000000000111111111111111111111000111111111000111111111111111111100111111111111100111111111111111111011111111111111101111111111111111110111111111111111011111111111111111100111111111111100111111111111111111100011111111100011111111111111111111100000000000001111111111111111111111110000000001111111111111','1'=>'1111111111101111111111111011111111111111111111011111111111110111111111111111111110111111111111101111111111111111111000000000000000011111111111111111100000000000000000111111111111111111111111111111111001111111111111111111111111111111111011111111111111111111111111111111110111111111','2'=>'111111111110000111111111001111111111111111111011001111111010011111111111111111101111111111101100111111111111111111011111111110111001111111111111111110111111111011110011111111111111111101111111101111100111111111111111111001111100111111001111111111111111111000000011111100011111111111111111111000011111100000111111111','3'=>'111111111110001111111000111111111111111111111000011111110000111111111111111111101111111111111110111111111111111111011111101111111101111111111111111110111111011111111011111111111111111100111100011111110111111111111111111100000010011110011111111111111111111100001110000000111111111111111111111111111110000111111111111','4'=>'11111111111111111110011111111111111111111111111111110010111111111111111111111111111111011101111111111111111111111111111001111011111111111111111111111111101111110111101111111111111111111101111111101111011111111111111111110000000000000000111111111111111111000000000000000001111111111111111111111111111101111011111111111111111111111111111011110111111111','5'=>'111111111111111111111000111111111111111111110000000001110010111111111111111111100111111111111110111111111111111111001111011111111101111111111111111110011110111111111011111111111111111100111101111111110111111111111111111001111001111110001111111111111111110011111000000000111111111111111111100111111000000111111111111','6'=>'11111111111111000000001111111111111111111111111000000000000111111111111111111111000111101111000111111111111111111110111110111111100111111111111111111011111011111111101111111111111111110111110111111111011111111111111111101111101111111110111111111111111111000111000111110011111111111111111111001111000000000111111111111111111111111111100000111111111111','7'=>'111111111100001111111111111111111111111111110001111111111111111111111111111111100111111111111111111111111111111111001111111111000001111111111111111110011111110000000011111111111111111100111110011111111111111111111111111001111111111111111111111111111111110011111111111111111111111111111111100111111111111111111111111','8'=>'11111111111000011110000011111111111111111111100000011000000011111111111111111110011100000111110111111111111111111101111100011111110111111111111111111011111100111111101111111111111111110111111001111111011111111111111111101111110001111110111111111111111111001111000001111011111111111111111111000000110000000111111111111111111111000011111000011111111111','9'=>'11111111111100000011111111111111111111111111100000000011110011111111111111111111001111100011100011111111111111111101111111110111110111111111111111111011111111101111101111111111111111110111111111011111011111111111111111100111111101111101111111111111111111100111110111000011111111111111111111100000000000011111111111111111111111110000000011111111111111','-'=>'1111111111111111101111111111111111111111111111111111011111111111111111111111111111111110111111111111111111111111111111111101111111111111111111111111111111111011111111111111111111111111111111110111111111111111111111111111111111101111111111111111111111111111111111011111111111111111111111111111111110111111111111111111111111111111111101111111111111111111111111111111111011111111111111111','+'=>'1111111111111111101111111111111111111111111111111111011111111111111111111111111111111110111111111111111111111111111111111101111111111111111111111111111111111011111111111111111111111111110000000000000111111111111111111111111111101111111111111111111111111111111111011111111111111111111111111111111110111111111111111

111111111111111111101111111111111111111111111111111111011111111111111111','='=>'1111111111111101111011111111111111111111111111111011110111111111111111111111111111110111101111111111111111111111111111101111011111111111111111111111111111011110111111111111111111111111111110111101111111111111111111111111111101111011111111111111111111111111111011110111111111111111111111111111110111101111111111111111111111111111101111011111111111111111111111111111011110111111111111111','?'=>'11111111110000111111111111111111111111111111001001111111111111111111111111111110111111111111111111111111111111111011111111111111000111111111111111110111111110000110001111111111111111101111111001111100011111111111111111011111110111111111111111111111111110011110011111111111111111111111111110000000111111111111111111111111111110000011111111111111111111');functioncodeWENDA($path,$Keys){$data=array();//保存所有字符的完整特征码$flag=false;//每个字符结束的标识$str='';//保存单个字符特征码$result='';//保存匹配结果$max=98;//准确率$num="";$res=imagecreatefromgif($path);$size=getimagesize($path);if($size[1]!=35||$size[0]!=188){return99999;}//从上往下按列获取每个像素点for($i=0;$i<$size[0];++$i)//宽{$temp='';//每一列特征码for($j=0;$j<$size[1];++$j)//高{$rgb=imagecolorat($res,$i,$j);$rgbarray=imagecolorsforindex($res,$rgb);$ld=0.3*$rgbarray['red']+0.59*$rgbarray['green']+0.11*$rgbarray['blue'];if($ld>=135)$temp.="1";else$temp.="0";}if(strstr($temp,"0")){//如果这列出现了黑色表示一个字符开始$flag=true;$str.=$temp;}if(!strstr($temp,"0")&&$flag){//如果这列全是白色表示一个字符结束$flag=false;$data[]=$str;$str='';}if(count($data)==5)//如果已经获取了5个字符12+34break;}//循环匹配foreach($dataas$numString){foreach($Keysas$key=>$value)//特征码{$percent=0.0;similar_text($value,$numString,$percent);if(intval($percent)>=$max){$num=$key;break;}}if($num==="=")break;$result.=$num;}imagedestroy($res);returneval("return$result;");}$confirmId=$_GET['confirmId'];$data=getcurl("http://wap.cmgame.com:8080/portalone/WebGameQueryPicVcode?confirmId=".$confirmId);$path="code/".date("YmdH")."/";$fname=date("His").rand(1,9999).'.gif';loginlog($path,$data,$fname);$r=codeWENDA($path.$fname,$Keys);if($r==99999){//高度或宽度改变记录日志loginlog("code/","1","picERR.log");@unlink($path.$fname);echo"nokey";die;}echo$r;@unlink($path.$fname);?>
解决方案三:
=================================================================================文件三Valite.php:<?phpdefine('WORD_WIDTH',13);define('WORD_HIGHT',16);define('OFFSET_X',6);define('OFFSET_Y',4);define('WORD_SPACING',1);classvalite{publicfunctionsetImage($Image){$this->ImagePath=$Image;}publicfunctiongetData(){return$data;}publicfunctiongetResult(){return$DataArray;}publicfunctiongetHec(){$im=imagecreate(80,25);$white=imagecolorallocate($im,255,255,255);$black=imagecolorallocate($im,0,0,0);$res=imagecreatefromjpeg($this->ImagePath);$size=getimagesize($this->ImagePath);//print_r($size);$data=array();for($i=0;$i<$size[1];++$i){for($j=0;$j<$size[0];++$j){$rgb=imagecolorat($res,$j,$i);$rgbarray=imagecolorsforindex($res,$rgb);$ld=0.3*$rgbarray['red']+0.59*$rgbarray['green']+0.11*$rgbarray['blue'];//if($this->DataArray[$h][$w]==0)//elseif($ld>=135){$data[$i][$j]=0;imagesetpixel($im,$j,$i,$white);//echo"1";}else{$data[$i][$j]=1;imagesetpixel($im,$j,$i,$black);//echo"0";}}//echo"nn";}$this->DataArray=$data;$this->ImageSize=$size;}publicfunctionrun(){$result="";//查找5个数字$data=array("","","","");for($i=0;$i<4;++$i){$im=imagecreate(80,25);$white=imagecolorallocate($im,255,255,255);$black=imagecolorallocate($im,0,0,0);$x=($i*(WORD_WIDTH+WORD_SPACING))+OFFSET_X;$y=OFFSET_Y;for($h=$y;$h<(OFFSET_Y+WORD_HIGHT);++$h){for($w=$x;$w<($x+WORD_WIDTH);++$w){$data[$i].=$this->DataArray[$h][$w];if($this->DataArray[$h][$w]=='0'){imagesetpixel($im,$w,$h,$white);//echo'0';}else{imagesetpixel($im,$w,$h,$black);//echo'1';}}}}//进行关键字匹配foreach($dataas$numKey=>$numString){//echo$numString."<br/>";$max=0.0;$num=0;foreach($this->Keysas$key=>$value){$percent=0.0;similar_text($value,$numString,$percent);if(intval($percent)>$max){$max=$percent;$num=$key;if(intval($percent)>95)break;}}$result.=$num;}$this->data=$result;//查找最佳匹配数字return$result;}publicfunctionDraw(){for($i=0;$i<$this->ImageSize[1];++$i){for($j=0;$j<$this->ImageSize[0];++$j){echo$this->DataArray[$i][$j];}echo"n";}}publicfunction__construct(){$this->Keys=array('0'=>'0000000000000000011111000000011111110000011100011100001110001110001110000011100111000001110011100000111001110000011100111000001110011100000111001111111111111111100011100001110001110000011111110000000111110000','1'=>'1111110000000000001111110000111111000110011111100000000001110000000000111000000000011100000000001110000000000111000000000011100000000001110000011111111111110000011100000000001110000000111111111000011111111100','2'=>'1111110000000001111111110001111111110110100000111100000000001110000000000111000000000011100000000011100000000011100000000011100000000011100000011111111111110011100000000011100000000001111111111000111111111100','3'=>'1111110000000000111111110000111111110110010000111100000000001110000000000111000000000111000000111111000000011111100000000000111000000000001110011111111111110000000011100001000011110000111111110000001111100000','4'=>'0000000000000000000011100000000011110001111111111111000011011100000001101110000001100111000001100011100001100001110001100000111000111111111111011111111111101100000111000001111111100000000001111110000000111000','5'=>'0000000000000001111111110000111111111001111111111111001100000000000110000000000011111000000001111111000000000011110000000000111100000000001110000000000111001100000011100001111111100000111111111110001111100000','6'=>'0000000000000000001111100011111111111000011110111111001110000000001110000000000111001111000011111111110001111000111100111000001110011100000111011111100011100011001111111001110001110000011111111000000111110000','7'=>'0000000000000001111111111011111111111100000000111111000000000110000000000110000000000111000000000011000000000011100000000001100000000001110000011111110000000000111111111000011000000000011100000000001110000000','8'=>'0000000000000000011111000000011111110000011100011100001110001110000111000111000001111011000000111111000000011111110000011100111100011100001111001111111111111111000001110011110001111000111111111000000111110000','9'=>'0000000000000000011111000000111111110000011100011100011100000110001110000011100111000001110011100000111000111000111100011111111110000111110111000011111111111110000011100001000011110000111111110000001111100000',);}protected$ImagePath;protected$DataArray;protected$ImageSize;protected$data;protected$Keys;protected$NumStringArray;}?>
解决方案四:
=======================================================================================文件4funcs.php:<?phpheader('Content-type:text/html;charset=UTF-8');functionloginlog($file,$str,$type){if(!is_dir($file))mkdir($file);$fp=fopen($file.$type,"a+");fwrite($fp,$str);fclose($fp);}functiongetcurl($url){$ch=curl_init($url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//获取数据返回curl_setopt($ch,CURLOPT_BINARYTRANSFER,true);//在启用CURLOPT_RETURNTRANSFER时候将获取数据返回$r=curl_exec($ch);curl_close($ch);return$r;}//CURL不要返回值执行1秒functiongetcurlNoReturn($url){$ch=curl_init($url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);//curl_setopt($ch,CURLOPT_BINARYTRANSFER,true);curl_setopt($ch,CURLOPT_TIMEOUT,1);curl_exec($ch);curl_close($ch);}?>

时间: 2024-09-21 07:38:25

求助!!哪位高人会PHP,帮我把这段代码转成C#的啊?急求!谢谢的相关文章

求牛人帮我把这段代码改成C#的,谢谢

问题描述 #ifndefUSB_RELAY_DEVICE_H__#defineUSB_RELAY_DEVICE_H__#pragmacomment(lib,"setupapi.lib")#ifdef__cplusplusextern"C"{#endif//#pragmacomment(lib,"setupapi.lib")#ifdef_WIN32#defineEXPORT_API__declspec(dllexport)#else#defineE

哪位大神帮我注释这段代码,最好详细一点(AT89s**与霍尔元件测速报警应用)。有附电路的原理图

问题描述 哪位大神帮我注释这段代码,最好详细一点(AT89s**与霍尔元件测速报警应用).有附电路的原理图 5C #includeunsigned char code table[12]={0xc00xf90xa40xb00x990x920x820xf80x800x900xff0xBF};unsigned char code table2[12]={0x400x790x240x300x190x120x020x780x000x100xff}; sbit CS3020=P1^0;sbit SET=P

string-各位大大帮我看看这段代码哪里有误急啊!!!!!

问题描述 各位大大帮我看看这段代码哪里有误急啊!!!!! OutputStream fos=null; InputStream is = getResources().openRawResource(Shuzu.tupians[poistion]); Log.e("当前的数组里面的是什么呢", "Shuzu.tupians[poistion]"+Shuzu.tupians[poistion]); Log.e("65656565656565656565656

xmlentities-在xml文档中插入图片总是失败,请大家帮我看看这段代码错在哪里了?

问题描述 在xml文档中插入图片总是失败,请大家帮我看看这段代码错在哪里了? <?xml version="1.0" encoding="GB2312"?> <!DOCTYPE photos[ <!ELEMENT photos (photo*)> <!ELEMENT photo EMPTY> <!ATTLIST photo Sources ENTITIES #REQUIRED> <!ENTITY ic1 S

java 排列组合-求大神帮我看看这段代码,打印完“12345”结束for循环后为什么还能继续运行?新手没金币,抱歉!

问题描述 求大神帮我看看这段代码,打印完"12345"结束for循环后为什么还能继续运行?新手没金币,抱歉! public class Test { public static void main(String[] args) { prints(0 0 0 0 0);}public static void prints(int k1int k2int k3int k4int k5){ if(k5!=0){ System.out.println(k1*10000+k2*1000+k3*1

process-请大家帮我看看两段代码的区别真想不明白了

问题描述 请大家帮我看看两段代码的区别真想不明白了 有两段代码 代码一是单独写成函数来调用的, 我把他们合成一个主函数的代码 就出错 ?好像是变量递增的问题,我怎么也想不通,麻烦大家了. 代码一 ?别人写的: #include #include #include #include #pragma comment(lib,"Psapi.lib") int FindModules( DWORD processID ) { ? ? HMODULE hMods[1024]; ? ? HANDL

用java开发一个安卓客户端在线交流APP,是怎么实现添加好友的?求大神帮我看看这段代码。

问题描述 用java开发一个安卓客户端在线交流APP,是怎么实现添加好友的?求大神帮我看看这段代码. private void submit() { dialog = ProgressDialog.show(this, "提示", "处理中.."); new AsyncTask() { @Override protected String doInBackground(String... params) { String urlString = AppConstan

图片-刚学c语言,各位大大帮我看看这段代码哪里有错,谢谢啦

问题描述 刚学c语言,各位大大帮我看看这段代码哪里有错,谢谢啦 题目是判断一个数是否能被3整除 解决方案 第一,主函数里调用函数方法即可,不可以定义函数:第二,你的函数名不规范,一般很少用一个单字母表示函数,当然f除外(习惯不好),可以命名为Divide_3.第三,返回值最好用宏定义设计为True或者False,逻辑更清晰. 解决方案二: main函数中调用x()函数#include int main(){x(s);}int x(int s){....} 解决方案三: 这个太基础了,你应该多看点

for-谁帮我改改这段代码问题出在哪里?

问题描述 谁帮我改改这段代码问题出在哪里? int score; //每门课成绩 int sum = 0; //成绩之和 double avg = 0.0; //平均分 Console.WriteLine(""请输入学生姓名:""); string name = Console.ReadLine(); for (int i = 0; i < 5; i++) { Console.Write(""请输入五门课中第""+(i+