1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
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" />'; } |