function thislibs(){
$lib['0'] = '0001101000';
$lib['1'] = '1001000010';
$lib['2'] = '0011000010';
$lib['3'] = '1011000000';
$lib['4'] = '0001100010';
$lib['5'] = '1001100000';
$lib['6'] = '0011100000';
$lib['7'] = '0001001010';
$lib['8'] = '1001001000';
$lib['9'] = '0011001000';
$lib['kt'] = '0100101000';
$lib['A'] = '110101001011';
$lib['B'] = '101101001011';
$lib['C'] = '110110100101';
$lib['D'] = '101011001011';
$lib['E'] = '110101100101';
$lib['F'] = '101101100101';
$lib['G'] = '101010011011';
$lib['H'] = '110101001101';
$lib['I'] = '101101001101';
$lib['J'] = '101011001101';
$lib['K'] = '110101010011';
$lib['L'] = '101101010011';
$lib['M'] = '110110101001';
$lib['N'] = '101011010011';
$lib['O'] = '110101101001';
$lib['P'] = '101101101001';
$lib['Q'] = '101010110011';
$lib['R'] = '110101011001';
$lib['S'] = '101101011001';
$lib['T'] = '101011011001';
$lib['U'] = '110010101011';
$lib['V'] = '100110101011';
$lib['W'] = '110011010101';
$lib['X'] = '100101101011';
$lib['Y'] = '110010110101';
$lib['Z'] = '100110110101';
$lib['-'] = '100101011011';
$lib['.'] = '110010101101';
$lib[' '] = '100110101101';
$lib['*'] = '100101101101';
$lib['$'] = '100100100101';
$lib['/'] = '100100101001';
$lib['+'] = '100101001001';
$lib['%'] = '101001001001';
return $lib;
}
/**
* 得到code的进入的接口代码
* @param mixed 进入的code内容
* @param string code处理的接口的方法
* @return 处理后的code数据
*/
function get($data,$code=39){
$func = 'code_'.$code;
if(method_exists($this,$func)){
return $this->$func($data);
}else{
return $data;
}
}
/**
* 得到code的进入的接口代码
* @param mixed 进入的code内容
* @param string code处理的接口的方法
* @return 处理后的code数据
*/
function getErp($data,$code=39){
$func = 'erpcode_'.$code;
if(method_exists($this,$func)){
return $this->$func($data);
}else{
return $data;
}
}
/**
* 验证码的具体实现方法
* @param string 制作验证码的数据
* @return string code的html的结果
*/
function erpcode_39($data){
$slen = strlen($data);
$lib =$this->thislibs();
$code = $lib['kt'];
$row1 = '<td rowspan="2" valign="top" style="padding:0px;border:none">'.$this->erpcode_39_line(0,1,90).'</td>';
$cell='';
for($j=1;$j<10;$j++){
$cell.=$this->erpcode_39_line($code{$j},$j%2!=1,60);
}
$row1 .= '<td style="padding:0px;border:none">'.$cell.'</td>';
$row2 ='<td style="text-align:center;font-size:9px;padding:0px;border:none">*</td>';
for($i=0;$i<$slen;$i++){
if($code = $lib[$data{$i}]){
$cell='';
for($j=0;$j<10;$j++){
$cell.=$this->erpcode_39_line($code{$j},$j%2!=1,60);
}
$row1.='<td style="padding:0px;border:none">'.$cell.'</td>';
}else{
$row1.='';
}
$row2.='<td style="text-align:center;font-size:9px;padding:0px;border:none">'.$data{$i}.'</td>';
}
$row2 .='<td style="text-align:center;font-size:9px;padding:0px;border:none">*</td>';
$code = $lib['kt'];
$cell = '';
for($j=0;$j<8;$j++){
$cell.=$this->erpcode_39_line($code{$j},$j%2!=1,60);
}
$row1 .= '<td style="padding:0px;border:none">'.$cell.'</td>';
$row1 .= '<td rowspan="2" valign="top" style="padding:0px;border:none">'.$this->erpcode_39_line(0,1,90).'</td>';
return "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"margin:0 auto;\"><tr>{$row1}</tr><tr>{$row2}</tr></table>";
}
/**
* 生成验证码的html的image行
* @param int 宽度制定为5或者2pt
* @param int 背景图片的是否使用
* @param int height 单位px
* @return string html结果
*/
function erpcode_39_line($i,$b,$h){
$file = $b?'black.gif':'transparent.gif';
return '<img src="'.app::get('ectools')->res_url.'/'.$file.'" class="x-barcode" width="'.($i?3:1).'pt" height="'.$h.'px" />';
}
赞 1
您可以选择一种方式赞助本站
支付宝扫一扫
微信扫一扫
赏
分享
您可以选择一种方式赞助本站
支付宝扫一扫
微信扫一扫