'), array('<', '>'), $cont); //$cont = str_replace(array('[B]','[/B]', '[/A]', "\n"), array('','', '','

'), $cont); $cont = str_replace(array('[B]','[/B]', '[/A]'), array('','', ''), $cont); preg_match_all('/\[(.*?)\]/', $cont, $list); foreach($list[0] as $k=>$nrs){ if($this->rock->contain($nrs, '[A,')){ $url = str_replace('[A,', '', $nrs); $url = str_replace(']', '', $url); $cont = str_replace($nrs, '', $cont); } if($this->rock->contain($nrs, '[IMG,')){ $url = str_replace('[IMG,', '', $nrs); $url = str_replace(']', '', $url); $a = explode(',', $url); $str = ''.$title.''; } $pstr = ''; foreach($fields as $fid=>$na){ $val = ''; $sty = 'padding:8px;'; if(isset($arr[$fid]))$val = $arr[$fid]; if(isset($arr[$fid.'_style']))$sty .= $arr[$fid.'_style']; $s .= ''.$na.''.$val.''; } $s .=''; return $s; } /** * 单据详情默认展示的 */ public function xiangtable($fields, $arr,$bcolor='', $lx='') { return $this->createtable($fields, $arr,'',$lx, $bcolor); } /** 创建table表格数据 @param string $rows 下载导出数据 @param string $headstr 表格表头(如:lie1,列1,left@lie2,列2,center) @return string */ public function createrows($rows, $headstr='', $bor='#C9ECFF',$lx='') { if($headstr == '')$headstr = $this->request('header'); if($headstr == '')return ''; $arrh = explode('@', $headstr); $thead = count($arrh); $lens = $thead-1; $rlen = count($rows); for($i=0; $i<$thead; $i++){ $te_str = $arrh[$i]; if(count(explode(',', $te_str)) < 3)$te_str.=',center'; $head[] = explode(',', $te_str); } $txt = ''; $style = "padding:3px;border:1px ".$bor." solid;border:var(--border)"; if($lx=='print')$style = "border:.5pt #000000 solid"; $txt .= ''; $txt .= ''; for($h=0; $h<$thead; $h++){ $stls= $style; if($lx=='noborder'){ $stls.=';border-top:none'; if($h==0)$stls.=';border-left:none'; if($h==$lens)$stls.=';border-right:none'; } $txt.= ''; } $txt .= ''; foreach($rows as $k=>$rs){ $txt .= ''; $rs['xuhaos'] = $k+1; for($h=0; $h<$thead; $h++){ $stls= $style; $stls.=''; if($lx=='noborder'){ if($h==0)$stls.=';border-left:none'; if($h==$lens)$stls.=';border-right:none'; if($k==$rlen-1)$stls.=';border-bottom:none'; } $val = isset($rs[$head[$h][0]]) ? $rs[$head[$h][0]] : ''; $txt .= ''; } $txt .= ''; } $txt .= '
'.$head[$h][1].'
'.$val.'
'; return $txt; } /** * 创建excel导出表格 */ public function execltable($title, $headArr, $rows, $lx='') { if($lx=='')$lx='xls'; $borst = '.5pt'; $sty = 'style="white-space:nowrap;border:'.$borst.' solid #000000;font-size:12px;{0}"'; $s = ''.$title.''; $s .= ''; $hlen = 1; $s1=''; foreach($headArr as $na){ $hlen++; $s1.=''; } $s1.=''; $s.=''; $s.=$s1; foreach($rows as $k=>$rs){ $atr = ''; if(isset($rs['trbgcolor']))$atr=' bgcolor="'.$rs['trbgcolor'].'"'; $s.=''; $s.=''; foreach($headArr as $kf=>$na){ $val = ''; if(isset($rs[$kf]))$val=$rs[$kf]; $s.=''; } $s.=''; } $s.='
getstyle($sty).'>序号getstyle($sty).'>'.$na.'
getstyle($sty).' colspan="'.$hlen.'">'.$title.'
getstyle($sty).'>'.($k+1).'getstyle($sty,'mso-number-format:\@').'>'.$val.'
'; $s.=''; $mkdir = ''.UPDIR.'/logs/'.date('Y-m').''; if(!contain(strtolower(PHP_OS),'win')){ $title = c('pingyin')->get($title, 1);//linux要用拼音,不然会乱码 } $filename = ''.$title.'_'.date('d_His').'.'.$lx.''; $filename = str_replace('/','',$filename); $url = ''.$mkdir.'/'.$filename.''; $bo = $this->rock->createtxt(iconv('utf-8','gb2312',$url), $s); return $url; } //超过11位的数字就会变型处理 private function execelval($str) { return $str; if($str!=''){ if(is_numeric($str) && strlen($str)>11)$str=''.$str.' '; } return $str; } private function getstyle($sty, $vs='') { return str_replace('{0}',$vs,$sty); } public function htmlremove($str) { $str = preg_replace("/<[^>]*>/si",'',$str); $str = str_replace(array(' ',"\n"),'', $str); return $str; } public function substrstr($str, $start, $length=null) { preg_match_all('/./us', $str, $match); $chars = is_null($length)? array_slice($match[0], $start ) : array_slice($match[0], $start, $length); unset($str); return implode('', $chars); } //判断字符串是否包含html代码 public function ishtml($val) { $bo = false; if(isempt($val))return $bo; $valstr = strtolower($val); $sparr = explode(',','p,div,span,font,table,b,a'); foreach($sparr as $sp){ if(contain($valstr,'<'.$sp.'')){ $bo=true; break; } } return $bo; } private $importerrarr = array(); public function importerrda() { return $this->importerrarr; } /** * 导入数据处理 */ public function importdata($fields,$btfid='', $fid='', $lx=0) { $this->importerrarr = array(); if($fid=='')$fid='importcont'; $rows = array(); $val = $this->rock->post($fid); if($val=='')return $rows; $arrs = explode("\n", $val); $farr = explode(',', $fields); $fars = explode(',', $btfid); foreach($arrs as $xu=>$valss){ $dars = explode(' ', $valss); $barr = array(); foreach($farr as $k=>$fid){ $barr[$fid] = isset($dars[$k]) ? $dars[$k] : ''; $barr[$fid] = str_replace('[XINHUBR]', "\n", $barr[$fid]); } $bos = true; foreach($fars as $fids){ if(isset($barr[$fids]) && isempt($barr[$fids])){ $bos = false; $this->importerrarr[$xu] = ''.$fids.'是必须的'; break; } } if($lx==1)$barr['drxu'] = $xu; if($bos)$rows[] = $barr; } return $rows; } }