query("insert into ".$table_pre."order_state (uid,cid,brand,action,attachments,add_date) values ('".$uid."','".$cid."','".$s_brand."','".$action."','".$attachments."','".$add_date."')"); } //记录订单表sql日志 function update_order_log($uid,$sql){ global $db,$table_pre; $add_date=date("Y-m-d H:i:s"); $db->query("insert into ".$table_pre."order_log (uid,sql_value,add_date) values ('".$uid."','".mysql_escape_string($sql)."','".$add_date."')"); } ////////////检查session function check_session(){ global $db,$table_pre; //$check_time=2*60*60; $check_time=30*60; $now1=time()-$check_time; $db->query("delete from ".$table_pre."session where lastactivity<".$now1); } ////////////解析session动作 function parse_session_action($action){ global $db,$table_pre; $arr_module=array("admin"=>"管理员","bb"=>"标准报表","plugin"=>"插件报表","boss_gl"=>"概览","dk"=>"单款","dk_single"=>"单款详情","dp"=>"搭配","dp_single"=>"搭配详情","cl"=>"陈列","cl_single"=>"陈列详情","cc_single"=>"橱窗详情","cc"=>"橱窗","ts"=>"推送","ty"=>"推演","msg"=>"消息","my_client"=>"我的客户","ph"=>"全国排行","detail"=>"订单明细","ph_my"=>"我的排行","sjs"=>"设计师","ts_zj"=>"推送主讲","xw"=>"行为分析","zycl"=>"自由陈列","zydp"=>"自由搭配","login"=>"登录"); $arr_cate_title=array("client"=>"客户","ks"=>"款式","kh"=>"款式","ms"=>"订货模式","size"=>"尺码","color"=>"颜色","ks_size"=>"款色深度"); // $q="select no,title from ".$table_pre."keyword where cate='arr_select'"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $arr_cate_title[$m["no"]]=$m["title"]; } $tmp=explode("|",$action); $_m=$tmp[0]; $_a=$tmp[1]; $cate=$tmp[2]; $r=""; $r.=get_main_value($arr_module,$_m); if($_m=="plugin"){ //取得插件名称 $m=get_db_msg("select title from ".$table_pre."plugin where file_name='".$_a."' and cate='".$cate."'"); $r.="-".$m["title"]; }else{ if($cate){ $arr_cate=explode("&",$cate); if($arr_cate[0]) $r.="-".get_main_value($arr_cate_title,$arr_cate[0]); if($arr_cate[1]) $r.="-".get_main_value($arr_cate_title,$arr_cate[1]); } } return $r; } ///////////////////////////////////////////////////////字符串 function deel_end($str,$len=1){ $r=""; if($str) $r=substr($str,0,-$len); return $r; } function ifor_edt_str2num($str){ $key="background"; $num=""; for($i=0;$i".$text.""; //$r=""; return $r; } //取得唯一标识 function gsession(){ $r=date("YmdHis").substr(microtime(),2,6); return $r; } //daddslashes function daddslashes($string) { if(!get_magic_quotes_gpc()) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = daddslashes($val, $force); } } else { $string = addslashes($string); } } return $string; } //dstripslashes function dstripslashes($string) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = dstripslashes($val, $force); } } else { $string = stripslashes($string); } return $string; } //取得随机字母 function get_rand($num){ $choper="123456789abcdefghijklmnpqrstuvwxyz"; for($i=0;$i<$num;$i++){ $r_str.=substr($choper,rand(0,strlen($choper)-1),1); } return $r_str; } //取得随机数字 function get_rand_num($num){ $choper="0123456789"; for($i=0;$i<$num;$i++){ $r_str.=substr($choper,rand(0,strlen($choper)-1),1); } return $r_str; } //转换成html function dhtmlchars($str){ $str=str_replace("<","<",$str); $str=str_replace(">",">",$str); $str=str_replace("\n","
",$str); $str=str_replace("\r","",$str); $str=str_replace(" "," ",$str); return $str; } //dhtmlspecialchars function dhtmlspecialchars($string) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = dhtmlspecialchars($val); } } else { $string = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\\1', str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string)); } return $string; } //去除html标记 function no_html($content){ $search=array("']*?>.*?'si", "'<[\/\!]*?[^<>]*?>'si", "'([\r\n])[\s]+'", "'&(quot|#34);'i", "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&#(\d+);'e"); $replace=array("", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)"); $content=preg_replace($search,$replace,$content); return $content; } /////显示短标题 //不带省略号 function substrgb($str,$len){ if(strlen($str)<$len+1){ return $str; }else{ $start=0; for($i=0;$i<$start+$len;$i++){ $tmpstr=(ord($str[$i])>=161 && ord($str[$i])<=247 && ord($str[$i+1])>=161 && ord($str[$i+1])<=254)?$str[$i].$str[++$i]:$tmpstr=$str[$i]; if ($i>=$start&&$i<($start+$len)) $tmp.=$tmpstr; } return $tmp; } } //带省略号 function substrgb1($str,$len){ if(strlen($str)<$len+1){ return $str; }else{ $start=0; for($i=0;$i<$start+$len;$i++){ $tmpstr=(ord($str[$i])>=161 && ord($str[$i])<=247 && ord($str[$i+1])>=161 && ord($str[$i+1])<=254)?$str[$i].$str[++$i]:$tmpstr=$str[$i]; if ($i>=$start&&$i<($start+$len)) $tmp.=$tmpstr; } return $tmp."..."; } } //截取字符 function sub_start_end($str,$start,$end){ $tmp=explode($start,$str); $tmp=explode($end,$tmp[1]); return $tmp[0]; } // function check_td($str){ return trim($str)?$str:" "; } ///////////////////////////////////////////////////////url相关 //重定向 function url_redirect($url=''){ $url=$url?$url:$_SERVER["HTTP_REFERER"]; //echo $url; echo ""; //echo ""; echo "Success!"; exit(); } //输出js代码并且重定向 function jscode_and_redirect($url='',$jscode=''){ $url=$url?$url:$_SERVER["HTTP_REFERER"]; echo "".$jscode.""; exit(); } //输出js错误提示 function alert($msg){ echo ""; exit(); } //输出js错误提示并返回 function alert_and_back($msg){ echo ""; exit(); } //输出js错误提示并关闭窗口 function alert_and_close($msg){ echo ""; exit(); } //输出js错误提示并重定向 function alert_and_redirect($msg,$url){ echo ""; exit(); } //输出js错误提示并关闭窗口 function alert_and_reload_opener($msg){ echo ""; exit(); } //重定向并post变量 function redirect_and_post($url,$var){ $html="
"; if(is_array($var)){ foreach($var as $key => $value){ $html.="\n"; } } $html.="
"; echo $html; } //处理url function url_add_getvar($url,$arr){ $tmp=str_replace("?","#",$url); if(ereg("#",$tmp)) $url.="&"; else $url.="?"; foreach($arr as $key => $value){ $url.=$key."=".$value."&"; } $url=substr($url,0,-1); return $url; } //=====================================================phpexcel //处理回车 function deel_tmp_td($str){ $str=str_replace("\r\n","",$str); $str=str_replace("\n","",$str); $str=str_replace("\r","",$str); return trim($str); } //把上传的excel文件转换成文本文件 function save_tmp_file($file){ require_once THIS_FILE_ROOT."/include/phpexcel/PHPExcel/IOFactory.php"; $file_name=gsession(); $file_ext=get_file_ext($file["name"]); $xls_file_name=$file_name.".".$file_ext; //$xls_file_name="../kh1.xls"; upload_file($file["tmp_name"],THIS_FILE_ROOT."/cache",$xls_file_name); $inputFileName=THIS_FILE_ROOT."/cache/".$xls_file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch(Exception $e) { die("加载文件发生错误:".pathinfo($inputFileName,PATHINFO_BASENAME).": ".$e->getMessage()); } $sheet=$objPHPExcel->getSheet(0); $highestRow=$sheet->getHighestRow(); $highestColumn=$sheet->getHighestColumn(); //获取一行的数据 $content=""; for($row=1;$row<=$highestRow;$row++){ $rowData = $sheet->rangeToArray("A".$row.":". $highestColumn.$row, NULL,TRUE,FALSE); if($rowData){ $line=""; for($i=0;$i"; } if($content){ $content=substr($content,0,-1); write_file(THIS_FILE_ROOT."/cache",$file_name,$content); } //del_file(THIS_FILE_ROOT."/cache/".$xls_file_name); return $file_name; } //取得临时文件内容 function get_tmp_content($file){ $content=read_file(THIS_FILE_ROOT."/cache/".$file); return $content; } //删除临时文件 function del_tmp_file($file){ del_file(THIS_FILE_ROOT."/cache/".$file); del_file(THIS_FILE_ROOT."/cache/".$file.".xls"); del_file(THIS_FILE_ROOT."/cache/".$file.".xlsx"); } //取得表头内容 function get_table_thead($content){ $arr=explode("\n",$content); $arr=explode("|^_^|",$arr[0]); return $arr; } //检查表头是否对应 function check_table_thead($arr_head,$arr_head_global){ global $arr_column_client_pinpai; $arr1=$arr2=array(); $arr3=$arr_column_client_pinpai; for($i=0;$igetDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); $excel->getDefaultStyle()->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER); $objActSheet = $excel->getActiveSheet(); $letter=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ'); $defaultFont = $excel->getDefaultStyle()->getFont(); //-------------------------------填充表格表头 $data_header=$data["header"]; $hang_max=count($data_header); $lie_max=count($data["col"]); $data_header=$data["header"]; $data_header=deel_data_cs_rs($data_header,$data["col"]); //print_r($data_header); //echo "
"; //填充 $thead_rows=0; for($row=0;$rowgetActiveSheet()->mergeCells($letter[$lie].$row1.':'.$letter[$lie].($row1+$arr_tmp1[1]-1)); }else if($arr_tmp1[0]=="cs"){ $excel->getActiveSheet()->mergeCells($letter[$lie].$row1.':'.$letter[$lie+$arr_tmp1[1]-1].$row1); } } $str1=$arr_tmp[0]; if($arr_tmp[0]!="^_^") $excel->getActiveSheet()->setCellValue($letter[$lie].$row1,$str1); } $thead_rows++; } $data["header"]=$data_header; //设置宽度 for($lie=0;$liegetActiveSheet()->getColumnDimension($letter[$lie])->setWidth(40); } } //-------------------------------填充表格内容 $data_body=$data["body"]; $data_body=deel_data_cs_rs($data_body,$data["col"]); for($row=0;$row"; if($arr_tmp1[0]=="rs"){ $imgh=$imgh-$arr_tmp1[1]*(19*4/3); } $is_img="y"; } } $j=$row+1+$thead_rows; //设置表格高度 if($is_img=="y"){ $excel->getActiveSheet()->getRowDimension($j)->setRowHeight($imgh); }else{ $excel->getActiveSheet()->getRowDimension($j)->setRowHeight(20); } //向每行单元格插入数据 for($lie=0;$liegetActiveSheet()->mergeCells($letter[$lie].$j.':'.$letter[$lie].($j+$arr_tmp1[1]-1)); }else if($arr_tmp1[0]=="cs"){ $excel->getActiveSheet()->mergeCells($letter[$lie].$j.':'.$letter[$lie+$arr_tmp1[1]-1].$j); } } $str1=$arr_tmp[0]; if($str1!="^_^"){ if($data["col"][$lie]=="img"){ //实例化插入图片类 if(is_file($str1)){ //$image_size=getimagesize($data_body[$row][$lie]); $objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing->setResizeProportional(false); $objDrawing->setPath($str1); //$objDrawing->setWidth($image_size[0]); //照片宽度 //$objDrawing->setHeight($image_size[1]);//照片高度 $objDrawing->setCoordinates($letter[$lie].$j); $objDrawing->setOffsetX(1); $objDrawing->setOffsetY(1); $objDrawing->getShadow()->setVisible(true); //$objDrawing->getShadow()->setDirection(50); $objDrawing->setWorksheet($excel->getActiveSheet()); }else{ //$excel->getActiveSheet()->setCellValue($letter[$lie].$j," "); } }else if($data["col"][$lie]=="str"){ $excel->getActiveSheet()->setCellValueExplicit($letter[$lie].$j,$str1,PHPExcel_Cell_DataType::TYPE_STRING); }else{ $excel->getActiveSheet()->setCellValue($letter[$lie].$j,$str1); } } } } if($download=="y"){ ob_end_clean(); //直接下载 $write = new PHPExcel_Writer_Excel5($excel); header("Pragma: public"); header("Expires: 0"); header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header("Content-Type:application/force-download"); header("Content-Type:application/vnd.ms-execl"); header("Content-Type:application/octet-stream"); header("Content-Type:application/download");; header("Content-Disposition:attachment;filename=".$file_name.".xls"); header("Content-Transfer-Encoding:binary"); $write->save('php://output'); }else{ //保存成文件 $write = new PHPExcel_Writer_Excel5($excel); $write->save($file_name); } } ///////////////////////////////////////////////////////文件操作 //上传文件 function upload_file($original_file,$path,$new_file_name){ make_dir($path); return copy($original_file,$path."/".$new_file_name); } //修改文件名 function modify_file_name($original_file,$new_file_name){ if(is_file($original_file)){ copy($original_file,$new_file_name); unlink($original_file); } } //创建目录 function make_dir($dir){ if(!is_dir($dir)) mkdir($dir,0777); } ///删除文件 function del_file($file){ if(is_file($file)) return @unlink($file); } //写入文件 function write_file($dir,$file_name,$content){ make_dir($dir); $file=$dir."/".$file_name; $fp=fopen($file,"w"); if(fwrite($fp,$content)) return true; else return false; } //写入并覆盖文件 function write_file1($dir,$file_name,$content){ make_dir($dir); $file=$dir."/".$file_name; $fp=fopen($file,"w+"); if(fwrite($fp,$content)) return true; else return false; } //取得上级路径 function get_last_path($p){ if(strpos($p,"\\")){ $arr1=explode("\\",$p); $str_split="\\"; }else if(strstr($p,"/")){ $arr1=explode("/",$p); $str_split="/"; } $p1=""; for($i=0;$i"; } //检查类型 function check_file_type($str,$type){ $r=false; $tmp=explode("|",$str); for($i=0;$i$srcH){ $dstW=$size; $dstH=intval($srcH*$size/$srcW); }else{ $dstH=$size; $dstW=intval($srcW*$size/$srcH); } $ni=imagecreatetruecolor($dstW,$dstH); imagecopyresampled($ni,$im,0,0,0,0,$dstW,$dstH,$srcW,$srcH); ImageJpeg($ni,$dstFile); } ///////////////////////////////////////////////////////数据库操作 function _mysql_connect($t=''){ global $dbhost,$dbuser,$dbpw,$dbname; switch($t){ case "1": // break; default: $db=new DB_Sql; $db->connect($dbhost,$dbuser,$dbpw,$dbname); break; } return $db; } //取得结果 function get_db_msg($query){ global $db; $res=$db->query($query); $msg=$db->fetch_array($res); return $msg; } ///////////////////////////////////////////////////////分页相关函数 // function get_order_reverse_url($tran_var,$order,$value,$url=''){ $url=$url?$url:$_SERVER[PHP_SELF]; foreach($tran_var as $key1=>$value1){ $other_var.="&".$key1."=".urlencode($value1); } if($value==str_replace("!","",$order) && !ereg("!",$order)) $other_var="?order=!".$value.$other_var; else $other_var="?order=".$value.$other_var; $r=$url.$other_var; return $r; } // function get_order_sql($order){ global $arr_order,$arr_order_d; $arr=ereg("!",$order)?$arr_order_d:$arr_order; $order=ereg("!",$order)?str_replace("!","",$order):$order; foreach($arr as $key => $value){ if($key==$order) $r=$value; } return $r; } // function get_pagesize_option($arr){ global $page_size; for($i=0;$i"; } return $r; } // function get_order_action($self,$order,$url,$tran_var){ $url=$url?$url:$_SERVER[PHP_SELF]; if(is_array($tran_var)){ foreach($tran_var as $key => $value){ $query.=$key."=".urlencode($value)."&"; } if(str_replace("!","",$order)==$self){ if(substr($order,strlen($order)-1,1)=="!"){ $query.="order=".$self; $img="order2h.gif"; }else{ $query.="order=".$self."!"; $img="order1h.gif"; } }else{ $query.="order=".$self; $img="order1.gif"; } return ""; }else{ return ; } } // ///////////////////////////////////////////////////////目录操作 // function path_cut0($path){ $tmp=explode("-",$path); for($i=0;$i0) $r.=$tmp[$i]."-"; } $r=substr($r,0,-1); return $r; } ///截去前$num层目录 function path_cut($path,$num){ $tmp=explode("-",$path); for($i=$num;$i0){ for($i=0;$i<$deep-1;$i++){ $r.="  "; } $r.="└ "; } return $r; } //取得父目录 function get_parent_id($path){ $tmp=explode("-",$path); $r=$tmp[count($tmp)-1]; $r=$r?$r:"0"; return $r; } //取得最后路径 function get_last_id($path){ $tmp=explode("-",$path); $r=$tmp[count($tmp)]; $r=$r?$r:"0"; return $r; } //取得最后路径 function get_last_id1($path){ $tmp=explode("-",$path); $r=$tmp[count($tmp)-1]; $r=$r?$r:"0"; return $r; } //检测是否存在下级目录 function check_subpath($path){ global $db,$table_pre,$_m; $check=false; $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."path where module='".$_m."' and path='".$path."'"); if($tmp[num]>0) $check=true; return $check; } // function get_deep($path){ $arr=explode("-",$path); return count($arr); } //根据charge_uid,计算charge_path,charge_real_path, function get_qj_charge($arr_charge_uid){ global $db,$table_pre; $arr_upath=array(); for($i=0;$i"; } //去掉多余 $arr_charge_path_real1=array(); for($i=0;$iquery("select * from ".$table_pre."path where module='".$mod."' and deep='1' order by ord"); while($msg=$db->fetch_array($res)){ $op_path.=""; } } return $op_path; } // function op_path_two1($path,$mod){ global $db,$table_pre; $op_path=""; $res=$db->query("select * from ".$table_pre."path where module='".$mod."' and deep='1' order by ord"); while($msg=$db->fetch_array($res)){ $check=get_db_msg("select count(*) 'num' from ".$table_pre."path where module='".$mod."' and path='".$msg["path"]."-".$msg["id"]."'"); $op_path.=""; } $r1=$db->query("select * from ".$table_pre."path where module='".$mod."' and path='".$m["path"]."-".$m["id"]."' order by ord"); while($m1=$db->fetch_array($r1)){ $op_path.=""; } } } return $op_path; } // function op_client_dp($path=''){ global $db,$table_pre; $op_path=""; $res=$db->query("select * from ".$table_pre."client where face='4' order by path, ord"); while($msg=$db->fetch_array($res)){ $op_path.=""; } $r1=$db->query("select * from ".$table_pre."client where path='".$m["path"]."-".$m["id"]."' order by ord"); while($m1=$db->fetch_array($r1)){ $check=get_db_msg("select count(*) 'num' from ".$table_pre."client where path='".$m1["path"]."-".$m1["id"]."'"); if($check[num]==0){ $op_path.=""; } $r2=$db->query("select * from ".$table_pre."client where path='".$m1["path"]."-".$m1["id"]."' order by ord"); while($m2=$db->fetch_array($r2)){ $check=get_db_msg("select count(*) 'num' from ".$table_pre."client where path='".$m2["path"]."-".$m2["id"]."'"); if($check[num]==0){ $op_path.=""; } } } } } return $op_path; } // function get_client_path_title($path,$split='-'){ global $db,$table_pre; $table=$table_pre."client"; $tmp=explode("-",$path); $r=""; for($i=0;$i0){ $t=get_db_msg("select * from ".$table." where id='".$tmp[$i]."'"); $r.=$t["title"].$split; } } $r=substr($r,0,0-strlen($split)); return $r?$r:$path; } // function get_path_title($path,$split='-',$table=''){ global $db,$table_pre; $table=$table?$table:$table_pre."path"; $tmp=explode("-",$path); $r=""; for($i=0;$i0){ $t=get_db_msg("select * from ".$table." where id='".$tmp[$i]."'"); $r.=$t["title"].$split; } } $r=substr($r,0,0-strlen($split)); return $r; } // function get_column_name($table,$id,$column){ global $db; $msg=get_db_msg("select * from ".$table." where id='".$id."'"); return $msg[$column]; } // function parse_deep($deep){ $r=""; for($i=1;$i<$deep;$i++){ $r.="    "; } return $r; } ///////////////////////////////////////////////////////数学和日期 // function sizecount($filesize) { if($filesize >= 1073741824) { $filesize = round($filesize / 1073741824 * 100) / 100 . ' G'; } elseif($filesize >= 1048576) { $filesize = round($filesize / 1048576 * 100) / 100 . ' M'; } elseif($filesize >= 1024) { $filesize = round($filesize / 1024 * 100) / 100 . ' K'; } else { $filesize = $filesize . ' bytes'; } return $filesize; } //保留小数 function keep_float($f,$num,$thousands_sep=''){ $r=number_format($f,$num,".",$thousands_sep); return $r; } //计算百分比 function deel_bfb($n1,$n2){ if($n2>0 && $n1>0){ $r=round(($n1/$n2)*100); $r=$r."%"; }else{ $r="0%"; } return $r; } //计算百分比 function deel_bfb1($n1,$n2,$num=2){ if($n2>0 && $n1>0){ $r=keep_float(($n1/$n2)*100,$num); $r=$r."%"; //$r=$n1.",".$n2; }else{ $r="0%"; } return $r; } //计算百分比 function deel_bfb3($n1,$num=0){ if($n1>0){ $r=keep_float($n1*100,$num); $r=$r."%"; //$r=$n1.",".$n2; }else{ $r="0%"; } return $r; } // function deel_date1($format,$time){ if($time>0) return date($format,$time); else return ""; } //处理数字 function deel_num($num){ return $num+1-1; } // function deel_price($price){ if($price==0) return ""; else return $price; } // function deel_date_null($date){ $date=str_replace("0000-00-00","",$date); return $date; } // function format_my_date($date){ $date=str_replace("/","-",$date); $date=deel_full_date($date); return $date; } // function get_min_in_array($arr){ if(is_array($arr)){ sort($arr); return $arr[0]; }else{ return 0; } } // function check_datetime($datetime){ $datetime=str_replace("-","",$datetime); $datetime=str_replace(":","",$datetime); $datetime=str_replace(" ","",$datetime); $datetime=$datetime+1-1; return $datetime; } // function day_add($date,$adder){ $tmp=explode("-",$date); $t=mktime(0,0,0,$tmp[1],$tmp[2]+$adder,$tmp[0]); return date("Y-n-j",$t); } // function day_add1($date,$adder){ $tmp=explode("-",$date); $t=mktime(0,0,0,$tmp[1],$tmp[2]+$adder,$tmp[0]); return date("Y-m-d",$t); } // function day_to_ymd($date){ if(!$date) return; $tmp=explode("-",$date); $t=mktime(0,0,0,$tmp[1],$tmp[2]+$adder,$tmp[0]); return date("Y-m-d",$t); } //日期转化为time()格式 function day_to_time($date){ if(!$date) return; $tmp=explode(" ",$date); $date=explode("-",$tmp[0]); $time=explode(":",$tmp[1]); return mktime($time[0],$time[1],$time[2],$date[1],$date[2],$date[0]); } //日期转化为time()格式,时间为0:0:0 function day_to_time1($date){ if(!$date) return; $date=explode("-",$date); return mktime(0,0,0,$date[1],$date[2],$date[0]); } //日期转化为time()格式,时间为23:59:59 function day_to_time2($date){ $date=explode("-",$date); return mktime(23,59,59,$date[1],$date[2],$date[0]); } //计算天数 function count_day($date1,$date2){ if(!$date2) return 0; $Date_List_1=explode("-",$date1); $Date_List_2=explode("-",$date2); $d1=mktime(0,0,0,$Date_List_1[1],$Date_List_1[2],$Date_List_1[0]); $d2=mktime(0,0,0,$Date_List_2[1],$Date_List_2[2],$Date_List_2[0]); $days=round(($d2-$d1)/3600/24); return $days; } //日期转成yyyy-dd-mm格式 function deel_full_date($date){ $arr=explode("-",$date); $m=strlen($arr[1])>1?$arr[1]:"0".$arr[1]; $d=strlen($arr[2])>1?$arr[2]:"0".$arr[2]; return $arr[0]."-".$m."-".$d; } // function hb_date($date1,$date2){ $a1=explode("-",$date1); $a2=explode("-",$date2); if($date1==$date2){ $r=$a1[0]."年".$a1[1]."月".$a1[2]."日"; }else if($a1[0]==$a2[0]){ if($a1[1]==$a2[1]){ $r=$a1[0]."年".$a1[1]."月".$a1[2]."日-".$a2[2]."日"; }else{ $r=$a1[0]."年".$a1[1]."月".$a1[2]."日-".$a2[1]."月".$a2[2]."日"; } }else{ $r=$a1[0]."年".$a1[1]."月".$a1[2]."日-".$a2[0]."年".$a2[1]."月".$a2[2]."日"; } return $r; } // function deel_add_date($add_date){ $arr1=explode(" ",$add_date); $arr_d=explode("-",$arr1[0]); $arr_t=explode(":",$arr1[1]); return $arr_d[2]."日 ".$arr_t[0]."点".$arr_t[1]."分".$arr_t[2]."秒"; } ///////////////////////////////////////////////////////权限相关 // function count_priv_channel($cid,$priv){ $p=explode(",",$priv); $count=0; for($i=0;$iquery($query); $i=0; while($msg=$db->fetch_array($res)){ $query1="select * from ".$table_pre."channel where path='0-".$msg["id"]."' order by ord"; $t=get_db_msg("select count(*) 'num' from ".$table_pre."channel where path='0-".$msg["id"]."'"); $t=$t["num"]; $r.="".$msg[title].""; $res1=$db->query($query1); $j=0; while($msg1=$db->fetch_array($res1)){ if(trim($msg1["priv"])!=""){ $r.="  ".$msg1["title"].":"; $a=explode(",",$msg1["priv"]); for($k=0;$k".get_main_value($arr_priv_tran,$a[$k]).""; } $r.="
"; }else{ $r.="  ".$msg1[title]."
"; } $j++; } $r.=""; $i++; } $r.=""; return $r; } // function print_form_priv1($priv=''){ global $arr_priv1; $check=explode(",",$priv); $r=""; $i=0; foreach($arr_priv1 as $k1 => $v1){ $r.="".$v1." "; $i++; } return $r; } //检查权限 function check_priv1($p,$priv){ $c=explode(",",$priv); if(in_array($p,$c)) return true; else return false; } // function deel_gang($str){ $str=str_replace("-","_",$str); return $str; } // function deel_0($str){ if($str==0) $str=""; return $str; } // function add_0($str){ if($str>0) $str=$str; else $str="0"; return $str; } // function deel_01($str){ $str=$str==""?"0":$str; return $str; } // function deel_td($str){ return $str?$str:" "; } function deel_td_zz($str){ return $str?$str:""; } // function split_priv_str($priv){ $tmp=explode(",",$priv); $r=array(); for($i=0;$i".$msg2["title"]; $col_priv.=$msg2["title"]; $col_priv.=", "; } } if($col_priv) $col_priv=substr($col_priv,0,-2); return $col_priv; } //=====================================判断权限 function return_priv($m,$priv){ global $db,$table_pre; $mc=get_db_msg("select id,path from ".$table_pre."channel where module='".$m."'"); $check=path_cut0($mc["path"]."-".$mc["id"]); $arr=explode(",",$priv); $r=array("n",""); for($i=0;$iquery("insert into ".$table_pre."log (uid,ip,action,remark,sql_value,add_date) values ('".$uid."','".$ip."','".$action."','".$remark."','".mysql_escape_string($query)."','".time()."')"); } ///////////////////////////////////////////////////////可选类别 ////////////输出cate // function out_select_cate($form,$name,$width,$cate,$value=''){ global $db,$table_pre; $width1=$width+18; $width2=$width+2; $d_value=$value; $r="
"; return $r; } // function out_select_cate1($form,$name,$width,$cate,$value=''){ global $db,$table_pre; $width1=$width+18; $d_value=$value; $r=" "; return $r; } ////////////更新 function update_cate($cate,$value){ global $db,$table_pre; if(trim($value)){ $msg=get_db_msg("select count(*) 'num' from ".$table_pre."keyword where title='".$value."' and cate='".$cate."'"); if($msg[num]==0){ $tmp=get_db_msg("select max(ord) 'ord' from ".$table_pre."keyword where cate='".$cate."'"); $ord=$tmp[ord]+1; $db->query("insert into ".$table_pre."keyword (ord,cate,title) values ('".$ord."','".$cate."','".$value."')"); } } } // function update_keyword($cate,$value){ global $db,$table_pre; $value=trim($value); if(trim($value)){ $msg=get_db_msg("select count(*) 'num' from ".$table_pre."keyword where title='".$value."' and cate='".$cate."'"); if($msg["num"]==0){ $tmp=get_db_msg("select max(ord) 'ord' from ".$table_pre."keyword where cate='".$cate."'"); if($tmp["ord"]>10) $ord=$tmp[ord]+1; else $ord=11; $db->query("insert into ".$table_pre."keyword (ord,cate,no,title) values ('".$ord."','".$cate."','".$ord."','".$value."')"); } } } // function update_keyword_color($code,$title){ global $db,$table_pre; $title=trim($title); $code=trim($code); if($title && $code){ $msg=get_db_msg("select count(*) 'num' from ".$table_pre."keyword where title='".$title."' and no='".$code."' and cate='color'"); if($msg["num"]==0){ $tmp=get_db_msg("select max(ord) 'ord' from ".$table_pre."keyword where cate='color'"); if($tmp["ord"]>0) $ord=$tmp[ord]+1; else $ord=1; $db->query("insert into ".$table_pre."keyword (ord,cate,no,title) values ('".$ord."','color','".$code."','".$title."')"); } } } ////////////op // function op_select_cate($cate,$value=""){ global $db,$table_pre; $r=$db->query("select * from ".$table_pre."keyword where cate='".$cate."' order by no"); $op=""; while($m=$db->fetch_array($r)){ $op.="