7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
3768 lines
100 KiB
PHP
3768 lines
100 KiB
PHP
<?php
|
||
//记录订单操作日志
|
||
function update_order_state($uid,$cid,$action,$attachments){
|
||
global $db,$table_pre,$s_brand;
|
||
$add_date=date("Y-m-d H:i:s");
|
||
if($s_brand){
|
||
$arr_s_brand=explode(",",$s_brand);
|
||
for($i=0;$i<count($arr_s_brand);$i++){
|
||
$db->query("insert into ".$table_pre."order_state (uid,cid,brand,action,attachments,add_date) values ('".$uid."','".$cid."','".$arr_s_brand[$i]."','".$action."','".$attachments."','".$add_date."')");
|
||
}
|
||
}else{
|
||
$db->query("insert into ".$table_pre."order_state (uid,cid,brand,action,attachments,add_date) values ('".$uid."','".$cid."','','".$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."')");
|
||
}
|
||
//记录客户操作日志
|
||
function update_log_hd(){
|
||
global $db,$table_pre,$hd_face,$arr_log_hd_action_in,$_m,$_a,$uid,$s_tab,$id,$khid,$khid,$log_hd_old_num,$log_hd_num,$s_is_ordered,$is_hd_log;
|
||
//
|
||
if($is_hd_log=="n")
|
||
return false;
|
||
//取得订货模式
|
||
$m1=get_db_msg("select _t1 from ".$table_pre."set where _k='sys_ms'");
|
||
$sys_ms1=$m1["_t1"];
|
||
$arr_ms1=explode(",",$sys_ms1);
|
||
$arr_ms2=array();
|
||
$default_ms="";
|
||
for($i=0;$i<count($arr_ms1);$i++){
|
||
$arr_tmp=explode("|",$arr_ms1[$i]);
|
||
if($i==0)
|
||
$default_ms=$arr_tmp[1];
|
||
$arr_ms2[$arr_tmp[0]]=$arr_tmp[1];
|
||
}
|
||
$log_hd_ms=$_COOKIE["sys_ms"]?get_main_value($arr_ms2,$_COOKIE["sys_ms"]):$default_ms;
|
||
//
|
||
$ip=$_SERVER["REMOTE_ADDR"];
|
||
$add_date=date("Y-m-d H:i:s");
|
||
$action=0;
|
||
$iid=0;
|
||
$num=0;
|
||
if($_m=="main_4"){
|
||
//店铺界面
|
||
|
||
}else if($_m=="order_single"){
|
||
//订单界面
|
||
$iid=$id;
|
||
if($_a=="save"){
|
||
$num=abs($log_hd_num);
|
||
if($log_hd_old_num+$log_hd_num==0){
|
||
$action=24;
|
||
}else{
|
||
if($log_hd_num>0){
|
||
if($log_hd_old_num>0)
|
||
$action=23;
|
||
else
|
||
$action=21;
|
||
}else if($log_hd_num<0){
|
||
$action=22;
|
||
}
|
||
}
|
||
}else if($_a=="del"){
|
||
$num=$log_hd_num;
|
||
$action=24;
|
||
}
|
||
}else if($_m=="dp_single"){
|
||
global $log_hd_old_num_kh;
|
||
//搭配订单界面
|
||
$iid=$khid;
|
||
if($_a=="save"){
|
||
$num=abs($log_hd_num);
|
||
if($log_hd_num>0){
|
||
//21下单,23加量
|
||
if($log_hd_old_num_kh==0)
|
||
$action=21;
|
||
else
|
||
$action=23;
|
||
}else if($log_hd_num<0){
|
||
//22减量,24删单
|
||
if($log_hd_old_num_kh==$num)
|
||
$action=24;
|
||
else
|
||
$action=22;
|
||
}
|
||
}
|
||
}else if($_m=="cc_single"){
|
||
global $flag_action;
|
||
//橱窗订单界面
|
||
$num=abs($log_hd_num);
|
||
$iid=$khid;
|
||
$action=$flag_action;
|
||
}else if($_m=="login"){
|
||
//登陆
|
||
$action=11;
|
||
}else if($_m=="client_pj"){
|
||
//评款
|
||
$num=$log_hd_num;
|
||
$iid=$khid;
|
||
if($_a=="save_pj")
|
||
$action=61;
|
||
else
|
||
$action=62;
|
||
}else if($_m=="logout"){
|
||
//注销
|
||
$action=12;
|
||
}else if($_m=="main_8"){
|
||
//管理员界面
|
||
$action=0;
|
||
}
|
||
if(in_array($action,$arr_log_hd_action_in) && $uid>0){
|
||
if($num==0 && ($action!=11 || $action!=12)){
|
||
$q="";
|
||
}else{
|
||
$q="insert into ".$table_pre."log_hd (uid,iid,num,ip,action,ms,hd_type,add_date) values ('".$uid."','".$iid."','".$num."','".$ip."','".$action."','".$log_hd_ms."','".$hd_face."','".$add_date."')";
|
||
$db->query($q);
|
||
}
|
||
}
|
||
}
|
||
////////////更新session
|
||
function update_session($uid,$ip){
|
||
global $db,$table_pre,$_m,$_a,$hd_face;
|
||
$server_ip=$_SERVER['HTTP_HOST'];
|
||
$action=$_m."|".$_a;
|
||
if($_m!="load_pic"){
|
||
$ip=$_SERVER["REMOTE_ADDR"];
|
||
$msg=get_db_msg("select * from ".$table_pre."session where uid='".$uid."' and ip='".$ip."' limit 0,1");
|
||
if($msg["id"]>0)
|
||
$db->query("update ".$table_pre."session set action='".$action."',remark='".$hd_face."',server_ip='".$server_ip."',lastactivity='".time()."' where id='".$msg["id"]."'");
|
||
else
|
||
$db->query("insert into ".$table_pre."session (uid,ip,server_ip,action,remark,lastactivity) values ('".$uid."','".$ip."','".$server_ip."','".$action."','".$hd_face."','".time()."')");
|
||
}
|
||
}
|
||
////////////检查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);
|
||
$db->query("delete from ".$table_pre."session where uid=0");
|
||
}
|
||
////////////删除session
|
||
function delete_session($uid){
|
||
global $db,$table_pre;
|
||
$q="delete from ".$table_pre."session where uid='".$uid."'";
|
||
$db->query($q);
|
||
}
|
||
//更新服务器的连接数
|
||
function cache_servers_num(){
|
||
global $db,$table_pre;
|
||
$q="select * from ".$table_pre."servers";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."servers_online where server_ip='".$m["ip"]."'");
|
||
$db->query("update ".$table_pre."servers set num='".$tmp["num"]."' where id='".$m["id"]."'");
|
||
}
|
||
}
|
||
///////////////////////////////////////////////////////字符串
|
||
function ifor_edt_str2num($str){
|
||
$key="background";
|
||
$num="";
|
||
for($i=0;$i<strlen($str);$i++){
|
||
for($k=0;$k<strlen($key);$k++){
|
||
if(substr($key,$k,1)==substr($str,$i,1))
|
||
$num.=$k;
|
||
}
|
||
}
|
||
return $num;
|
||
}
|
||
function ifor_edt_client_decode($str){
|
||
$arr=array();
|
||
$str=substr($str,16,-16);
|
||
$str=base64_decode($str);
|
||
//echo $str."<br>";
|
||
$arr1=explode("+",$str);
|
||
$arr[0]=ifor_edt_str2num($arr1[0]);
|
||
$arr[1]=$arr1[1];
|
||
$arr[2]=ifor_edt_str2num($arr1[2]);
|
||
$arr[3]=ifor_edt_str2num($arr1[3]);
|
||
$arr[4]=$arr1[4];
|
||
$arr[5]=$arr1[5];
|
||
$arr[6]=$arr1[6];
|
||
$arr[7]=$arr1[7];
|
||
return $arr;
|
||
}
|
||
//
|
||
function deel_text_html($text){
|
||
$text=StripSlashes($text);
|
||
$text=str_replace("\"","'",$text);
|
||
return $text;
|
||
}
|
||
//处理数字
|
||
function deel_num($num){
|
||
return $num+1-1;
|
||
}
|
||
//
|
||
function get_editor($text,$id='content1',$w='100%',$h='450px'){
|
||
$text=deel_text_html($text);
|
||
$r="<textarea id=\"".$id."\" name=\"".$id."\" style=\"width:".$w.";height:".$h.";visibility:hidden;\">".$text."</textarea>";
|
||
//$r="<INPUT type=\"hidden\" name=\"".$id."\" value=\"".$text."\"><IFRAME ID=\"".$text1."\" src=\"editor/ewebeditor.htm?id=".$id."&style=mini\" frameborder=\"0\" scrolling=\"no\" width=\"".$w."\" height=\"".$h."\"></IFRAME>";
|
||
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","<br>",$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("'<script[^>]*?>.*?</script>'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];
|
||
}
|
||
///////////////////////////////////////////////////////url相关
|
||
//重定向
|
||
function url_redirect($url=''){
|
||
$url=$url?$url:$_SERVER["HTTP_REFERER"];
|
||
echo "<meta http-equiv=\"refresh\" content=\"0;url=".$url."\">";
|
||
exit();
|
||
}
|
||
//输出js代码并且重定向
|
||
function jscode_and_redirect($url='',$jscode=''){
|
||
$url=$url?$url:$_SERVER["HTTP_REFERER"];
|
||
echo "<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"><meta http-equiv=\"refresh\" content=\"1;url=".$url."\"></head><body>".$jscode."</body></html>";
|
||
exit();
|
||
}
|
||
//输出js错误提示
|
||
function alert($msg){
|
||
echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"><script> alert('".$msg."'); </script>";
|
||
exit();
|
||
}
|
||
//输出js错误提示并返回
|
||
function alert_and_back($msg){
|
||
echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"><script> alert('".$msg."');\n history.back(); </script>";
|
||
exit();
|
||
}
|
||
//输出js错误提示并关闭窗口
|
||
function alert_and_close($msg){
|
||
echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"><script> alert('".$msg."');\n window.close(); </script>";
|
||
exit();
|
||
}
|
||
//输出js错误提示并重定向
|
||
function alert_and_redirect($msg,$url){
|
||
echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"><script> alert('".$msg."'); </script>";
|
||
echo "<meta http-equiv=\"refresh\" content=\"0;url=".$url."\">";
|
||
exit();
|
||
}
|
||
//输出js错误提示并关闭窗口
|
||
function alert_and_reload_opener($msg){
|
||
echo "<script> alert('".$msg."');\n window.opener.location.reload();\n window.close();\n </script>";
|
||
exit();
|
||
}
|
||
//重定向并post变量
|
||
function redirect_and_post($url,$var){
|
||
$html="<body onload='document.form1.submit();'><form name=form1 method='post' action=\"".$url."\">";
|
||
if(is_array($var)){
|
||
foreach($var as $key => $value){
|
||
$html.="<input type=hidden name=\"".$key."\" value=\"".urlencode($value)."\">\n";
|
||
}
|
||
}
|
||
$html.="</form></body>";
|
||
echo $html;
|
||
}
|
||
//输出错误结果
|
||
function echo_wrong($msg){
|
||
echo "<html><head><meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\"></head><body>";
|
||
echo "<br><br><div style=\"background-color:#ffffff;\" align=\"center\" width=\"80%\"><br><br>".$msg."! <input type=\"button\" name=\"b1\" style=\"height:30px;\" value=\" 返 回 \" onclick=\"history.back();\"><br><br></div></body></html>";
|
||
exit;
|
||
}
|
||
//处理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;
|
||
}
|
||
//
|
||
function get_this_url(){
|
||
$this_url="";
|
||
if(is_array($_GET)){
|
||
foreach($_GET as $k => $v){
|
||
$this_url.=$k."=".urlencode($v)."&";
|
||
}
|
||
}
|
||
if(is_array($_POST)){
|
||
foreach($_POST as $k => $v){
|
||
$this_url.=$k."=".urlencode($v)."&";
|
||
}
|
||
}
|
||
if($this_url)
|
||
$this_url="?".substr($this_url,0,-1);
|
||
return $this_url;
|
||
}
|
||
//
|
||
function del_url_para($url,$arr){
|
||
$arr1=explode("?",$url);
|
||
$arr2=explode("&",$arr1[1]);
|
||
$str1="";
|
||
for($i=0;$i<count($arr2);$i++){
|
||
$arr3=explode("=",$arr2[$i]);
|
||
if(!in_array($arr3[0],$arr)){
|
||
$str1.="&".$arr2[$i];
|
||
}
|
||
}
|
||
if($str1)
|
||
$str1=substr($str1,1,strlen($str1)-1);
|
||
return $arr1[0]."?".$str1;
|
||
}
|
||
///////////////////////////////////////////////////////文件操作
|
||
//上传文件
|
||
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 read_file($file){
|
||
$content="";
|
||
if(is_file($file)){
|
||
$fp=fopen($file,"r");
|
||
while($buffer=fread($fp,1024)){
|
||
$content.=$buffer;
|
||
}
|
||
fclose($fp);
|
||
}
|
||
return $content;
|
||
}
|
||
//取得文件名
|
||
function get_file_name($file_name){
|
||
$arr_tmp=explode(".",$file_name);
|
||
$num=count($arr_tmp)-1;
|
||
$r="";
|
||
for($i=0;$i<$num;$i++){
|
||
$r.=$arr_tmp[$i].".";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//取得文件的后缀名
|
||
function get_file_ext($file_name){
|
||
$arr_tmp=explode(".",$file_name);
|
||
$num=count($arr_tmp)-1;
|
||
return strtolower($arr_tmp[$num]);
|
||
}
|
||
//取得文件的图标
|
||
function get_file_ext_icon($file_ext,$property){
|
||
$ft="";
|
||
switch($file_ext){
|
||
case "rm":
|
||
case "swf":
|
||
$ft=$file_ext;
|
||
break;
|
||
default:
|
||
$ft="avi";
|
||
break;
|
||
}
|
||
return "<img src=\"images/f_".$ft.".gif\" border=\"0\"".$property.">";
|
||
}
|
||
//检查类型
|
||
function check_file_type($str,$type){
|
||
$r=false;
|
||
$tmp=explode("|",$str);
|
||
for($i=0;$i<count($tmp);$i++){
|
||
if(strtolower($tmp[$i])==strtolower($type)){
|
||
$r=true;
|
||
break;
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//检查文件大小
|
||
function check_file_size($f_size,$c_size){
|
||
$r=false;
|
||
if($f_size/1024<$c_size)
|
||
$r=true;
|
||
return $r;
|
||
}
|
||
//制作缩略图
|
||
function make_mini_picture($srcFile,$dstFile,$size=200,$quality=80){
|
||
if(is_file($srcFile)){
|
||
$data=GetImageSize($srcFile);
|
||
switch($data[2]){
|
||
case 1:
|
||
$im=@ImageCreateFromGIF($srcFile);
|
||
break;
|
||
case 2:
|
||
$im=@ImageCreateFromJPEG($srcFile);
|
||
break;
|
||
case 3:
|
||
$im=@ImageCreateFromPNG($srcFile);
|
||
break;
|
||
}
|
||
$srcW=ImageSX($im);
|
||
$srcH=ImageSY($im);
|
||
if($srcW<$size && $srcH<$size){
|
||
$dstW=$srcW;
|
||
$dstH=$srcH;
|
||
}else if($srcW>$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,$quality);
|
||
}
|
||
}
|
||
///////////////////////////////////////////////////////数据库操作
|
||
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<count($arr);$i++){
|
||
$r.="<option value='".$arr[$i]."'";
|
||
if($page_size==$arr[$i])
|
||
$r.=" selected";
|
||
$r.=">".$arr[$i]."</option>";
|
||
}
|
||
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 "<a href=\"".$url."?".$query."\"><img src=\"images/".$img."\" border=0></a>";
|
||
}else{
|
||
return ;
|
||
}
|
||
}
|
||
//
|
||
///////////////////////////////////////////////////////目录操作
|
||
//
|
||
function path_cut0($path){
|
||
$tmp=explode("-",$path);
|
||
for($i=0;$i<count($tmp);$i++){
|
||
if($tmp[$i]>0)
|
||
$r.=$tmp[$i]."-";
|
||
}
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
///截去前$num层目录
|
||
function path_cut($path,$num){
|
||
$tmp=explode("-",$path);
|
||
for($i=$num;$i<count($tmp);$i++){
|
||
$r.=$tmp[$i]."-";
|
||
}
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//截去后$num层目录
|
||
function path_cutb($path,$num){
|
||
$tmp=explode("-",$path);
|
||
for($i=0;$i<count($tmp)-$num;$i++){
|
||
$r.=$tmp[$i]."-";
|
||
}
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//截去后$num层目录
|
||
function dir_cutb($path,$num){
|
||
if(@ereg("/",$path)){
|
||
$flag="/";
|
||
}else{
|
||
$flag="\\";
|
||
}
|
||
$tmp=explode($flag,$path);
|
||
$r="";
|
||
for($i=0;$i<count($tmp)-$num;$i++){
|
||
$r.=$tmp[$i].$flag;
|
||
}
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//去除目录
|
||
function dir_cutc($path){
|
||
if(@ereg("/",$path)){
|
||
$flag="/";
|
||
}else{
|
||
$flag="\\";
|
||
}
|
||
$tmp=explode($flag,$path);
|
||
$r=$tmp[count($tmp)-1];
|
||
return $r;
|
||
}
|
||
//缩进
|
||
function indent($deep){
|
||
if($deep>0){
|
||
for($i=0;$i<$deep-1;$i++){
|
||
$r.=" ";
|
||
}
|
||
$r.="└ ";
|
||
}
|
||
return $r;
|
||
}
|
||
function indent_dote($deep){
|
||
if($deep>0){
|
||
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 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);
|
||
}
|
||
//
|
||
function op_path($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)){
|
||
$op_path.="<option value='".$msg[path]."-".$msg[id]."'";
|
||
if($path==$msg[path]."-".$msg[id])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]."</option>";
|
||
}
|
||
return $op_path;
|
||
}
|
||
//
|
||
function op_path_two($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]."'");
|
||
if($check[num]==0){
|
||
$op_path.="<option value='".$msg[path]."-".$msg[id]."'";
|
||
if($path==$msg[path]."-".$msg[id])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]."</option>";
|
||
}
|
||
$r=$db->query("select * from ".$table_pre."path where module='".$mod."' and path='0-".$msg[id]."' order by ord");
|
||
while($m=$db->fetch_array($r)){
|
||
$op_path.="<option value='".$m[path]."-".$m[id]."'";
|
||
if($path==$m[path]."-".$m[id])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]." -> ".$m["title"]."</option>";
|
||
}
|
||
}
|
||
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.="<option value='".$msg[path]."-".$msg[id]."'";
|
||
if($path==$msg[path]."-".$msg[id])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]."</option>";
|
||
$r=$db->query("select * from ".$table_pre."path where module='".$mod."' and path='0-".$msg[id]."' order by ord");
|
||
while($m=$db->fetch_array($r)){
|
||
$op_path.="<option value='".$m[path]."-".$m[id]."'";
|
||
if($path==$m[path]."-".$m[id])
|
||
$op_path.=" selected";
|
||
$op_path.="> ".$m["title"]."</option>";
|
||
}
|
||
}
|
||
return $op_path;
|
||
}
|
||
//
|
||
function op_path_two_pid($pid,$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.="<option value='".$msg["id"]."'";
|
||
if($pid==$msg["id"])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]."</option>";
|
||
|
||
$r=$db->query("select * from ".$table_pre."path where module='".$mod."' and path='0-".$msg[id]."' order by ord");
|
||
while($m=$db->fetch_array($r)){
|
||
$op_path.="<option value='".$m["id"]."'";
|
||
if($pid==$m["id"])
|
||
$op_path.=" selected";
|
||
$op_path.="> ".$m["title"]."</option>";
|
||
}
|
||
}
|
||
return $op_path;
|
||
}
|
||
//
|
||
function op_path_three($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]."'");
|
||
if($check[num]==0){
|
||
$op_path.="<option value='".$msg[path]."-".$msg[id]."'";
|
||
if($path==$msg[path]."-".$msg[id])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]."</option>";
|
||
}
|
||
$r=$db->query("select * from ".$table_pre."path where module='".$mod."' and path='0-".$msg[id]."' order by ord");
|
||
while($m=$db->fetch_array($r)){
|
||
$check=get_db_msg("select count(*) 'num' from ".$table_pre."path where module='".$mod."' and path='".$m[path]."-".$m[id]."'");
|
||
if($check[num]==0){
|
||
$op_path.="<option value='".$m[path]."-".$m[id]."'";
|
||
if($path==$m[path]."-".$m[id])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]." -> ".$m["title"]."</option>";
|
||
}
|
||
$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.="<option value='".$m1[path]."-".$m1[id]."'";
|
||
if($path==$m1[path]."-".$m1[id])
|
||
$op_path.=" selected";
|
||
$op_path.=">".$msg["title"]." -> ".$m["title"]." -> ".$m1["title"]."</option>";
|
||
}
|
||
}
|
||
}
|
||
return $op_path;
|
||
}
|
||
//
|
||
function get_jxs_path_title($path,$split='-'){
|
||
global $db,$table_pre;
|
||
$table=$table_pre."jxs";
|
||
$tmp=explode("-",$path);
|
||
$r="";
|
||
for($i=0;$i<count($tmp);$i++){
|
||
if($tmp[$i]>0){
|
||
$t=get_db_msg("select * from ".$table." where id='".$tmp[$i]."'");
|
||
$r.=$t["username"].$split;
|
||
}
|
||
}
|
||
$r=substr($r,0,0-strlen($split));
|
||
return $r;
|
||
}
|
||
//
|
||
function get_path_title($path,$split='-',$table=''){
|
||
global $db,$table_pre;
|
||
$table=$table?$table:$table_pre."path";
|
||
$tmp=explode("-",$path);
|
||
$r="";
|
||
for($i=0;$i<count($tmp);$i++){
|
||
if($tmp[$i]>0){
|
||
$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_path_title_web($path,$cate,$split='-',$var='pid',$prop=''){
|
||
global $db,$table_pre;
|
||
$table=$table_pre."path";
|
||
$tmp=explode("-",$path);
|
||
$r="";
|
||
for($i=0;$i<count($tmp);$i++){
|
||
if($tmp[$i]>0){
|
||
$t=get_db_msg("select * from ".$table." where id='".$tmp[$i]."'");
|
||
$r.="<a href=\"".$cate.".php?".$var."=".$t[id]."\"".$prop.">".$t["title"]."</a>".$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 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 deel_cf($n1,$n2){
|
||
if($n2>0 && $n1>0){
|
||
$r=$n1/$n2;
|
||
}else{
|
||
$r="0";
|
||
}
|
||
return $r;
|
||
}
|
||
//保留小数
|
||
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_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 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 get_op_month($month){
|
||
$op="";
|
||
$arr=array();
|
||
for($i=1;$i<13;$i++){
|
||
$op.="<option value='".$i."'";
|
||
if($i==$month)
|
||
$op.=" selected";
|
||
$op.=">".$i."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//取得年选项
|
||
function get_op_year($year,$start_y='',$end_y=''){
|
||
$start_y=$start_y?$start_y:"2000";
|
||
$end_y=$end_y?$end_y:date("Y");
|
||
$arr=array();
|
||
for($i=$start_y;$i<=$end_y;$i++){
|
||
$op.="<option value='".$i."'";
|
||
if($i==$year)
|
||
$op.=" selected";
|
||
$op.=">".$i."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
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 count_priv_channel($cid,$priv){
|
||
$p=explode(",",$priv);
|
||
$count=0;
|
||
for($i=0;$i<count($p);$i++){
|
||
$t1=explode("-",$p[$i]);
|
||
if($t1[0]==$cid)
|
||
$count++;
|
||
}
|
||
return $count;
|
||
}
|
||
//
|
||
function print_form_priv($priv=''){
|
||
global $db,$table_pre,$arr_priv_tran;
|
||
$check=split_priv_str($priv);
|
||
$r="<table cellpadding=0 cellspacing=1 width=100% border=0 bgcolor=#ffffff>";
|
||
$query="select * from ".$table_pre."channel where deep=1 order by ord";
|
||
$res=$db->query($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.="<tr><td style='background-color:#f5f5f5;height:18px'><input type=checkbox id='".$i."_main' onclick=\"check_multi(".$t.",'".$i."')\"";
|
||
if(count_priv_channel($msg[id],$priv)==$t)
|
||
$r.=" checked";
|
||
$r.="><label for=\"".$i."_main\">".$msg["title"]."</label></td></tr><tr><td>";
|
||
$res1=$db->query($query1);
|
||
$j=0;
|
||
while($msg1=$db->fetch_array($res1)){
|
||
if(trim($msg1["priv"])!=""){
|
||
$r.=" <input type=hidden name=priv_id[] value=\"".$msg[id]."-".$msg1[id]."\">".$msg1["title"].":";
|
||
$a=explode(",",$msg1["priv"]);
|
||
for($k=0;$k<count($a);$k++){
|
||
$r.="<input type=\"radio\" name=\"priv_".$msg[id]."_".$msg1[id]."\" id=\"priv_".$msg[id]."_".$msg1[id]."_".$a[$k]."\" value=\"".$a[$k]."\"";
|
||
if($k==0)
|
||
$r.=" checked";
|
||
else if(in_array($msg[id]."-".$msg1[id]."|".$a[$k],$check[1]))
|
||
$r.=" checked";
|
||
$r.="><label for=\"priv_".$msg[id]."_".$msg1[id]."_".$a[$k]."\">".get_main_value($arr_priv_tran,$a[$k])."</label>";
|
||
}
|
||
$r.="<br>";
|
||
}else{
|
||
$r.=" <input type=checkbox name=priv_id[] id=\"".$i."_".$j."\" value=\"".$msg[id]."-".$msg1[id]."\"";
|
||
if(in_array($msg[id]."-".$msg1[id],$check[0]))
|
||
$r.=" checked";
|
||
$r.="><label for=\"".$i."_".$j."\">".$msg1["title"]."</label><br>";
|
||
}
|
||
$j++;
|
||
}
|
||
$r.="</td></tr>";
|
||
$i++;
|
||
}
|
||
$r.="</table>";
|
||
return $r;
|
||
}
|
||
//
|
||
function print_form_priv1($priv=''){
|
||
global $arr_priv1;
|
||
$check=explode(",",$priv);
|
||
$r="";
|
||
$i=0;
|
||
foreach($arr_priv1 as $k1 => $v1){
|
||
$r.="<input type=checkbox id='p1_".$i."' name=\"priv1_".$i."\" value=\"".$k1."\"";
|
||
if(in_array($k1,$check))
|
||
$r.=" checked";
|
||
$r.="><label for=\"p1_".$i."\">".$v1."</label> ";
|
||
$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_multi_num($num,$i){
|
||
$str=$num;
|
||
$num1=strlen($num);
|
||
if($i>$num1){
|
||
for($j=0;$j<$i-$num1;$j++){
|
||
$str="0".$str;
|
||
}
|
||
}
|
||
return $str;
|
||
}
|
||
//
|
||
function deel_01($str){
|
||
$str=$str==""?"0":$str;
|
||
return $str;
|
||
}
|
||
//
|
||
function deel_td($str){
|
||
return $str?$str:" ";
|
||
}
|
||
//
|
||
function deel_js_var($str){
|
||
$str=str_replace("\"","\\\"",$str);
|
||
$str=str_replace(array("\r\n","\r","\n"),"",$str);
|
||
$str=str_replace(" ","",$str);
|
||
return $str;
|
||
}
|
||
//
|
||
function split_priv_str($priv){
|
||
$tmp=explode(",",$priv);
|
||
$r=array();
|
||
for($i=0;$i<count($tmp);$i++){
|
||
$tmp1=explode('|',$tmp[$i]);
|
||
$r[0][$i]=$tmp1[0];
|
||
$r[1][$i]=$tmp[$i];
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function print_priv_str($priv){
|
||
global $db,$table_pre,$arr_priv_tran;
|
||
$col_priv="";
|
||
$priv1=explode(",",$priv);
|
||
for($i=0;$i<count($priv1);$i++){
|
||
$priv2=explode("|",$priv1[$i]);
|
||
$priv3=explode("-",$priv2[0]);
|
||
$msg1=get_db_msg("select * from ".$table_pre."channel where id='".$priv3[0]."'");
|
||
$msg2=get_db_msg("select * from ".$table_pre."channel where id='".$priv3[1]."'");
|
||
$col_priv.=$msg1["title"]."->".$msg2["title"];
|
||
if($priv2[1])
|
||
$col_priv.="|".get_main_value($arr_priv_tran,$priv2[1]);
|
||
$col_priv.="<br>";
|
||
}
|
||
return $col_priv;
|
||
}
|
||
//
|
||
function return_priv($cid,$priv){
|
||
global $db,$table_pre;
|
||
$mc=get_db_msg("select * from ".$table_pre."channel where id='".$cid."'");
|
||
$check=path_cut0($mc["path"]."-".$mc["id"]);
|
||
$arr=explode(",",$priv);
|
||
$r=array("n","");
|
||
for($i=0;$i<count($arr);$i++){
|
||
$arr1=explode("|",$arr[$i]);
|
||
if($check==$arr1[0]){
|
||
$r[0]="y";
|
||
$r[1]=$arr1[1];
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function set_log($action='',$remark=''){
|
||
global $db,$table_pre,$query,$uid;
|
||
$ip=$_SERVER["REMOTE_ADDR"];
|
||
$db->query("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="<DIV style=\"POSITION: relative\"><SPAN style=\"MARGIN-LEFT: ".$width."px; OVERFLOW: hidden; WIDTH: 18px\"> <SELECT style=\"MARGIN-LEFT: -".$width."px; WIDTH: ".$width1."px\" onchange=".$form.".".$name.".value=this.value>";
|
||
$query="select * from ".$table_pre."keyword where cate='".$cate."' order by no";
|
||
$res=$db->query($query);
|
||
$count=0;
|
||
$r.="<option value=''></option>";
|
||
while($msg=$db->fetch_array($res)){
|
||
$r.="<option value=\"".$msg["title"]."\"";
|
||
if($msg["title"]==$d_value)
|
||
$r.=" selected";
|
||
$r.=">".$msg["title"]."</option>";
|
||
$count++;
|
||
}
|
||
$r.="</SELECT></SPAN><INPUT style=\"LEFT: 0px; WIDTH: ".$width2."px; POSITION: absolute;z-index:10000\" value=\"".$d_value."\" name=\"".$name."\"></DIV>";
|
||
return $r;
|
||
}
|
||
//
|
||
function out_select_cate1($form,$name,$width,$cate,$value=''){
|
||
global $db,$table_pre;
|
||
$width1=$width+18;
|
||
$d_value=$value;
|
||
$r="<input id=\"".$name."\" name=\"".$name."\" value=\"".$d_value."\" type=\"text\" style=\"width:".$width."px;POSITION: absolute\">
|
||
<select name=\"".$name."_s_cate\" id=\"".$name."_s_cate\" onchange=\"document.getElementById('".$name."').value=this.options[this.selectedIndex].value\" style=\"width:".$width1."px;CLIP: rect(auto auto auto ".$width."px);\">";
|
||
$query="select * from ".$table_pre."keyword where cate='".$cate."' order by no";
|
||
$res=$db->query($query);
|
||
$count=0;
|
||
$r.="<option value=''></option>";
|
||
while($msg=$db->fetch_array($res)){
|
||
$r.="<option value=\"".$msg["title"]."\"";
|
||
if($msg["title"]==$d_value)
|
||
$r.=" selected";
|
||
$r.=">".$msg["title"]."</option>";
|
||
$count++;
|
||
}
|
||
$r.="</SELECT>";
|
||
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."')");
|
||
}
|
||
}
|
||
}
|
||
////////////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.="<option value=\"".$m["title"]."\"";
|
||
if($value==$m["title"])
|
||
$op.=" selected";
|
||
$op.=">".$m["title"]."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function op_select_cate1($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.="<option value=\"".$m["no"]."\"";
|
||
if($value==$m["no"])
|
||
$op.=" selected";
|
||
$op.=">".$m["no"]."(".$m["title"].")</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function op_select_cate2($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.="<option value=\"".$m["no"]."\"";
|
||
if($value==$m["no"])
|
||
$op.=" selected";
|
||
$op.=">".$m["title"]."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
function js_op_select_cate2($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.="\"".$m["no"]."|".$m["title"]."\",";
|
||
}
|
||
$op.="]";
|
||
return $op;
|
||
}
|
||
//
|
||
function js_op_arr($arr){
|
||
$op="[";
|
||
foreach($arr as $k1 => $v1){
|
||
$op.="\"".$k1."|".$v1."\",";
|
||
}
|
||
$op.="]";
|
||
return $op;
|
||
}
|
||
//
|
||
function op_select_cate4($cate,$value=""){
|
||
global $db,$table_pre;
|
||
//取得选项
|
||
$arr1=array();
|
||
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'sx' order by ord";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arr1[]=$m1["no"];
|
||
}
|
||
for($i=0;$i<count($arr1);$i++){
|
||
$v="s_".$arr1[$i];
|
||
global $$v;
|
||
}
|
||
$con1="";
|
||
for($i=0;$i<count($arr1);$i++){
|
||
$v="s_".$arr1[$i];
|
||
if($cate!=$arr1[$i] && trim($$v)){
|
||
$con1.=" and ".$arr1[$i]."='".$$v."'";
|
||
|
||
}
|
||
}
|
||
$r=$db->query("select * from ".$table_pre."kh where ".$cate."<>'' ".$con1." group by ".$cate." order by ".$cate);
|
||
$op="";
|
||
while($m=$db->fetch_array($r)){
|
||
$op.="<option value=\"".$m[$cate]."\"";
|
||
if($value==$m[$cate])
|
||
$op.=" selected";
|
||
$op.=">".get_cate_title_no($cate,$m[$cate])."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
function js_op_select_cate4($cate,$value=""){
|
||
global $db,$table_pre;
|
||
//取得选项
|
||
$arr1=array();
|
||
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'sx' order by ord";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arr1[]=$m1["no"];
|
||
}
|
||
for($i=0;$i<count($arr1);$i++){
|
||
$v="s_".$arr1[$i];
|
||
global $$v;
|
||
}
|
||
$con1="";
|
||
for($i=0;$i<count($arr1);$i++){
|
||
$v="s_".$arr1[$i];
|
||
if($cate!=$arr1[$i] && trim($$v)){
|
||
$con1.=" and ".$arr1[$i]."='".$$v."'";
|
||
|
||
}
|
||
}
|
||
$r=$db->query("select * from ".$table_pre."kh where ".$cate."<>'' ".$con1." group by ".$cate." order by ".$cate);
|
||
$op="[";
|
||
while($m=$db->fetch_array($r)){
|
||
$op.="\"".$m[$cate]."|".get_cate_title_no($cate,$m[$cate])."\",";
|
||
}
|
||
$op.="]";
|
||
return $op;
|
||
}
|
||
//
|
||
function op_select_cate3($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.="<option value=\"".$m["no"]."\"";
|
||
if($value==$m["no"])
|
||
$op.=" selected";
|
||
$op.=">".$m["title"]."(".$m["no"].")</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_cate_title_no($cate,$value){
|
||
global $db,$table_pre;
|
||
$m=get_db_msg("select * from ".$table_pre."keyword where cate='".$cate."' and no='".$value."' limit 0,1");
|
||
return $m["title"];
|
||
}
|
||
//
|
||
function arr_select($cate,$col1="no",$col2="title"){
|
||
global $db,$table_pre;
|
||
$r=$db->query("select * from ".$table_pre."keyword where cate='".$cate."' order by no");
|
||
$arr=array();
|
||
while($m=$db->fetch_array($r)){
|
||
$arr[$m[$col1]]=$m[$col2];
|
||
}
|
||
return $arr;
|
||
}
|
||
///////////////////////////////////////////////////////模板相关
|
||
//取得tmpl模板
|
||
function template($tpl){
|
||
$tpl=THIS_FILE_ROOT."/template/".$tpl.".php";
|
||
if(is_file($tpl)){
|
||
return $tpl;
|
||
}else{
|
||
exit("找不到相关模板(".$tpl.")!");
|
||
}
|
||
}
|
||
//
|
||
function _include($inc){
|
||
$inc=THIS_FILE_ROOT."/inc/".$inc.".php";
|
||
if(is_file($inc)){
|
||
return $inc;
|
||
}else{
|
||
exit("找不到相关模块(".$inc.")!");
|
||
}
|
||
}
|
||
///////////////////////////////////////////////////////数组
|
||
//插入值到最后第二个
|
||
function insert_last_2($arr,$v){
|
||
$arr1=array();
|
||
for($i=0;$i<count($arr);$i++){
|
||
if($i<count($arr)-1){
|
||
$arr1[]=$arr[$i];
|
||
}else{
|
||
$arr1[]=$v;
|
||
$arr1[]=$arr[$i];
|
||
}
|
||
}
|
||
return $arr1;
|
||
}
|
||
//找出数组中的重复数据
|
||
function find_repeat_data($arr){
|
||
$r=array();
|
||
$r1=array();
|
||
foreach($arr as $k1 => $v1){
|
||
if(!in_array($v1,$r)){
|
||
$r[$k1]=$v1;
|
||
}else{
|
||
$r1[$k1]=$v1;
|
||
}
|
||
}
|
||
return array($r,$r1);
|
||
}
|
||
//累计数组指定索引前面的值的和
|
||
function count_arr_num_before($arr,$i){
|
||
$r=0;
|
||
if($i>0){
|
||
for($k=0;$k<$i;$k++){
|
||
$r+=$arr[$k];
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
function arr_push($arr,$num){
|
||
$r=array();
|
||
$i=0;
|
||
if($num>0){
|
||
foreach($arr as $k => $v){
|
||
if($i<=$num){
|
||
$r[$k]=$v;
|
||
}
|
||
$i++;
|
||
}
|
||
}else{
|
||
foreach($arr as $k => $v){
|
||
if($i>=abs($num)){
|
||
$r[$k]=$v;
|
||
}
|
||
$i++;
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function arr_to_str($arr){
|
||
$r="";
|
||
for($i=0;$i<count($arr);$i++){
|
||
$r.=$arr[$i].",";
|
||
}
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//
|
||
function arr2str($arr,$ind='k'){
|
||
$str="";
|
||
if(is_array($arr)){
|
||
foreach($arr as $k => $v){
|
||
$str.=$$ind.",";
|
||
}
|
||
}
|
||
if($str)
|
||
$str=substr($str,0,-1);
|
||
return $str;
|
||
}
|
||
//
|
||
function arr2str1($arr){
|
||
$str="";
|
||
for($i=0;$i<count($arr);$i++){
|
||
$str.=$arr[$i].",";
|
||
}
|
||
if($str)
|
||
$str=substr($str,0,-1);
|
||
return $str;
|
||
}
|
||
//
|
||
function arr_minus($arr,$v){
|
||
$r=array();
|
||
for($i=0,$j=0;$i<count($arr);$i++){
|
||
if($arr[$i]!=$v){
|
||
$r[$j]=$arr[$i];
|
||
$j++;
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function arr_part($arr,$arr_ind){
|
||
$r=array();
|
||
foreach($arr as $key => $value){
|
||
if(in_array($key,$arr_ind))
|
||
$r[$key]=$value;
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function arr_last_key($arr){
|
||
$r="";
|
||
if(!is_array($arr))
|
||
return;
|
||
$i=0;
|
||
$len=count($arr);
|
||
foreach($arr as $key => $value){
|
||
if($i==$len-1)
|
||
$r=$key;
|
||
$i++;
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function get_main_radio($arr,$name,$v='',$fuc=''){
|
||
$op="";
|
||
if(!is_array($arr))
|
||
return;
|
||
$i=1;
|
||
foreach($arr as $key => $value){
|
||
$op.="<input type='radio' name='".$name."' id='".$name."_".$i."' value='".$key."'".$fuc."";
|
||
if($v==$key)
|
||
$op.=" checked";
|
||
$op.="><label for='".$name."_".$i."'>".$value."</label> ";
|
||
$i++;
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_main_radio2($arr,$num,$name,$v='',$fuc=''){
|
||
$op="";
|
||
if(!is_array($arr))
|
||
return;
|
||
if($num>0){
|
||
$i=1;
|
||
foreach($arr as $key => $value){
|
||
if($i<=$num){
|
||
$op.="<input type='radio' name='".$name."' id='".$name."_".$i."' value='".$key."'".$fuc."";
|
||
if($v==$key)
|
||
$op.=" checked";
|
||
$op.="><label for='".$name."_".$i."'>".$value."</label> ";
|
||
}
|
||
$i++;
|
||
}
|
||
}else{
|
||
$i=1;
|
||
foreach($arr as $key => $value){
|
||
if($i>=abs($num)){
|
||
$op.="<input type='radio' name='".$name."' id='".$name."_".$i."' value='".$key."'".$fuc."";
|
||
if($v==$key)
|
||
$op.=" checked";
|
||
$op.="><label for='".$name."_".$i."'>".$value."</label> ";
|
||
}
|
||
$i++;
|
||
}
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_main_checkbox($arr,$name,$v='',$fuc=''){
|
||
$op="";
|
||
if(!is_array($arr))
|
||
return;
|
||
$i=1;
|
||
$check=explode(",",$v);
|
||
foreach($arr as $key => $value){
|
||
$op.="<input type=\"checkbox\" name=\"".$name."[]\" id=\"".$name."_".$i."\" value=\"".$key."\"".$fuc."";
|
||
if(in_array($key,$check))
|
||
$op.=" checked";
|
||
$op.="><label for='".$name."_".$i."'>".$value."</label> ";
|
||
$i++;
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_main_radio1($arr,$name,$v='',$fuc=''){
|
||
$op="";
|
||
if(!is_array($arr))
|
||
return;
|
||
$i=1;
|
||
foreach($arr as $key => $value){
|
||
$op.="<input type='radio' name='".$name."' id='".$name."_".$i."' value='".$value."'".$fuc."";
|
||
if($v==$key)
|
||
$op.=" checked";
|
||
$op.="><label for='".$name."_".$i."'>".$value."</label> ";
|
||
$i++;
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_main_op($arr,$v=''){
|
||
$op="";
|
||
if(!is_array($arr))
|
||
return;
|
||
foreach($arr as $key => $value){
|
||
$op.="<option value='".$key."'";
|
||
if($v==$key)
|
||
$op.=" selected";
|
||
$op.=">".$value."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_main_op1($arr,$v=''){
|
||
$op="";
|
||
if(!is_array($arr))
|
||
return;
|
||
foreach($arr as $key => $value){
|
||
$op.="<option value='".$key."'";
|
||
if($v==$key)
|
||
$op.=" selected";
|
||
$op.=">".$key."(".$value.")</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_main_op2($arr,$v,$v1='',$v2=''){
|
||
$op="";
|
||
if(!is_array($arr))
|
||
return;
|
||
foreach($arr as $key => $value){
|
||
$op.="<option value='".$key."'";
|
||
if($v==$key)
|
||
$op.=" selected";
|
||
$op.=">".$v1.$value.$v2."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function get_op_num($num1,$num2,$v=''){
|
||
$op="";
|
||
for($i=$num1;$i<=$num2;$i++){
|
||
$op.="<option value='".$i."'";
|
||
if($v==$i)
|
||
$op.=" selected";
|
||
$op.=">".$i."</option>";
|
||
}
|
||
return $op;
|
||
}
|
||
//
|
||
function reverse_array($arr){
|
||
if(!is_array($arr))
|
||
return;
|
||
$r=array();
|
||
foreach($arr as $key => $value){
|
||
$r[$value]=$key;
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function get_main_value($arr,$k){
|
||
if(!is_array($arr))
|
||
return;
|
||
foreach($arr as $key => $value){
|
||
if($key==$k)
|
||
return $value;
|
||
}
|
||
return $k;
|
||
}
|
||
//
|
||
function get_main_value1($arr,$k){
|
||
if(!is_array($arr))
|
||
return;
|
||
foreach($arr as $key => $value){
|
||
if($key==$k)
|
||
return $value;
|
||
}
|
||
return "";
|
||
}
|
||
//
|
||
function get_main_value_arr($arr,$str){
|
||
if(!is_array($arr))
|
||
return;
|
||
$tmp=explode(",",$str);
|
||
$r="";
|
||
for($i=0;$i<count($tmp);$i++){
|
||
$r.=get_main_value($arr,$tmp[$i]).",";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//
|
||
function get_main_key($arr,$v){
|
||
if(!is_array($arr))
|
||
return;
|
||
foreach($arr as $key => $value){
|
||
if($value==$v)
|
||
return $key;
|
||
}
|
||
return $v;
|
||
}
|
||
//
|
||
function get_main_key1($arr,$v){
|
||
for($i=0;$i<count($arr);$i++){
|
||
if($arr[$i]==$v)
|
||
return $i;
|
||
}
|
||
return 0;
|
||
}
|
||
//
|
||
function get_key($arr){
|
||
if(!is_array($arr))
|
||
return;
|
||
$arr1=array();
|
||
foreach($arr as $key => $value){
|
||
$arr1[]=$key;
|
||
}
|
||
return $arr1;
|
||
}
|
||
///////////////////////////////////////////////////////远程操作
|
||
function get_from_url($url){
|
||
$fp=@fopen($url,"r");
|
||
if($fp){
|
||
while($buffer=fread($fp,1024)){
|
||
$content.=$buffer;
|
||
}
|
||
return $content;
|
||
}else{
|
||
return false;
|
||
}
|
||
}
|
||
///////////////////////////////////////////////////////ajax
|
||
//执行
|
||
function ajax_do($url,$method='GET',$arr_success_js=''){
|
||
$str="<script>
|
||
var xmlhttp=ajaxinit();
|
||
var url=\"".$url."\";
|
||
xmlhttp.open(\"".$method."\",url,true);
|
||
xmlhttp.setRequestHeader(\"Cache-Control\",\"no-cache\");
|
||
xmlhttp.onreadystatechange=function(){
|
||
if(xmlhttp.readyState==4 && xmlhttp.status==200){
|
||
//alert(xmlhttp.responseText);
|
||
".$arr_success_js."
|
||
}
|
||
}
|
||
xmlhttp.send(null);
|
||
</script>";
|
||
return $str;
|
||
}
|
||
///////////////////////////////////////////////////////其他
|
||
//
|
||
function get_sex_op($value=1){
|
||
global $arr_gender;
|
||
$r="";
|
||
foreach($arr_gender as $k => $v){
|
||
$r.=" <input type=radio name=gender value=\"".$k."\"";
|
||
if($k==$value)
|
||
$r.=" checked";
|
||
$r.=">".$v;
|
||
}
|
||
return $r;
|
||
}
|
||
//输出比例图片
|
||
function out_good_pic($pic,$width,$height,$property=''){
|
||
if(is_file($pic)){
|
||
$wh=GetImageSize($pic);
|
||
}else{
|
||
$pic1=str_replace("content://com.muchuang.edt/","../",$pic).".jpg";
|
||
if(is_file($pic1))
|
||
$wh=GetImageSize($pic1);
|
||
}
|
||
$tmp="";
|
||
if($width<$wh[0] || $height<$wh[1]){
|
||
if(($wh[0]/$width)>($wh[1]/$height))
|
||
$tmp=" width=\"".$width."\"";
|
||
else
|
||
$tmp=" height=\"".$height."\"";
|
||
}
|
||
return "<img src=\"".$pic."\"".$tmp." border=\"0\" ".$property.">";
|
||
}
|
||
//输出图片实际高度
|
||
function get_good_pic_height($pic,$width,$height){
|
||
if(is_file($pic)){
|
||
$wh=GetImageSize($pic);
|
||
}else{
|
||
$pic1=str_replace("content://com.muchuang.edt/","../",$pic).".jpg";
|
||
if(is_file($pic1))
|
||
$wh=GetImageSize($pic1);
|
||
}
|
||
$h=0;
|
||
if($width<$wh[0] || $height<$wh[1]){
|
||
if(($wh[0]/$width)>($wh[1]/$height)){
|
||
$h=round($wh[1]*$width/$wh[0]);
|
||
}else{
|
||
$h=$height;
|
||
}
|
||
}else{
|
||
$h=$wh[1];
|
||
}
|
||
return $h;
|
||
}
|
||
//给出按比例图片的参数
|
||
function out_good_pic_set($pic,$width,$height){
|
||
if(is_file($pic)){
|
||
$wh=GetImageSize($pic);
|
||
}else{
|
||
$pic1=str_replace("content://com.muchuang.edt/","../",$pic).".jpg";
|
||
if(is_file($pic1))
|
||
$wh=GetImageSize($pic1);
|
||
}
|
||
$tmp="";
|
||
if(($width>0 && $width<$wh[0]) || ($height>0 && $height<$wh[1])){
|
||
if(($wh[0]/$width)>($wh[1]/$height)){
|
||
$tmp=" width=".$width." height=".round($wh[1]*$width/$wh[0]);
|
||
|
||
}else{
|
||
$tmp=" width=".round($wh[0]*$height/$wh[1])." height=".$height;
|
||
}
|
||
}else{
|
||
$tmp=" width=".$wh[0]." height=".$wh[1];
|
||
}
|
||
return $tmp;
|
||
}
|
||
//
|
||
function check_cookie_jxs(){
|
||
$login_uid=$_COOKIE[THIS_COOKIE];
|
||
$url=$_SERVER[PHP_SELF];
|
||
if($login_uid>0){
|
||
return $login_uid;
|
||
}else{
|
||
url_redirect($url);
|
||
exit();
|
||
}
|
||
}
|
||
|
||
//
|
||
function get_video_url($v){
|
||
$max_video_link=200;
|
||
$v=explode("\n",$v);
|
||
return $v[0];
|
||
}
|
||
//
|
||
function out_answer($type,$answer){
|
||
$arr_new_answer=array("y"=>"对","n"=>"错");
|
||
if($type=="1")
|
||
$r=get_main_value($arr_new_answer,$answer);
|
||
else
|
||
$r=$answer;
|
||
return $r;
|
||
}
|
||
//
|
||
function format_time_minute($t){
|
||
$r=$t?$t."分钟":"--";
|
||
return $r;
|
||
}
|
||
//
|
||
function format_num($num){
|
||
$num=$num+1-1;
|
||
return $num;
|
||
}
|
||
//
|
||
//取得订单数量
|
||
function get_order_num($id,$color,$bx,$size){
|
||
global $uid,$db,$table_pre,$_key;
|
||
$tmp1=get_db_msg("select * from ".$table_pre."order where _key='".$_key."' and uid='".$uid."' and iid='".$id."' and color='".$color."' and bx='".$bx."'");
|
||
$r=$tmp1["num_".strtolower($size)];
|
||
$r=$r>0?$r:"";
|
||
return $r;
|
||
}
|
||
//取得款号订单数量
|
||
function get_order_num_kh($id){
|
||
global $uid,$db,$table_pre,$_key;
|
||
$r=0;
|
||
$tmp1=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key='".$_key."' and uid='".$uid."' and iid='".$id."' and ka<>'y'");
|
||
$r=$tmp1["num"];
|
||
if($r>0)
|
||
return $r;
|
||
else
|
||
return ;
|
||
}
|
||
//取得款号订单数量
|
||
function get_order_num_kh_color($id,$color){
|
||
global $uid,$db,$table_pre,$_key;
|
||
$r=0;
|
||
$tmp1=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where _key='".$_key."' and uid='".$uid."' and iid='".$id."' and color='".$color."' and ka<>'y'");
|
||
$r=$tmp1["num"];
|
||
if($r>0)
|
||
return $r;
|
||
else
|
||
return ;
|
||
}
|
||
//判断是否买断
|
||
function check_md($kh,$color,$bx,$size,$dj=''){
|
||
global $db,$table_pre;
|
||
if($dj)
|
||
$sql_dj=" (dj='".$dj."' or dj='') and ";
|
||
else
|
||
$sql_dj="";
|
||
$r="n";
|
||
$check=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md where".$sql_dj." kh='".$kh."'");
|
||
if($check["num"]>0){
|
||
//买断款
|
||
$check=get_db_msg("select id,price from ".$table_pre."kh_md where".$sql_dj." kh='".$kh."' and color='' and bx='' and size=''");
|
||
if($check["id"]>0)
|
||
return $check["price"];
|
||
//买断颜色
|
||
$check=get_db_msg("select id,price from ".$table_pre."kh_md where".$sql_dj." kh='".$kh."' and color='".$color."' and bx='' and size=''");
|
||
if($check["id"]>0)
|
||
return $check["price"];
|
||
//买断杯型
|
||
$check=get_db_msg("select id,price from ".$table_pre."kh_md where".$sql_dj." kh='".$kh."' and color='".$color."' and bx='".$bx."' and size=''");
|
||
if($check["id"]>0)
|
||
return $check["price"];
|
||
//买断尺码
|
||
$check=get_db_msg("select id,price,size from ".$table_pre."kh_md where".$sql_dj." kh='".$kh."' and color='".$color."' and bx='".$bx."'");
|
||
if($check["id"]>0){
|
||
$arr1=explode(",",$check["size"]);
|
||
if(in_array($size,$arr1))
|
||
return $check["price"];
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//判断是否不予下单尺码
|
||
function check_size_not($kh,$color,$bx,$size){
|
||
global $db,$table_pre;
|
||
$r="n";
|
||
$check=get_db_msg("select count(*) 'num' from ".$table_pre."size_not");
|
||
if($check["num"]>0){
|
||
//款
|
||
$check=get_db_msg("select id from ".$table_pre."size_not where kh='".$kh."' and color='' and bx='' and size=''");
|
||
if($check["id"]>0)
|
||
return "y";
|
||
//颜色
|
||
$check=get_db_msg("select id from ".$table_pre."size_not where kh='".$kh."' and color='".$color."' and bx='' and size=''");
|
||
if($check["id"]>0)
|
||
return "y";
|
||
//杯型
|
||
$check=get_db_msg("select id from ".$table_pre."size_not where kh='".$kh."' and color='".$color."' and bx='".$bx."' and size=''");
|
||
if($check["id"]>0)
|
||
return "y";
|
||
//尺码
|
||
$check=get_db_msg("select id,size from ".$table_pre."size_not where kh='".$kh."' and color='".$color."' and bx='".$bx."'");
|
||
if($check["id"]>0){
|
||
$arr1=explode(",",$check["size"]);
|
||
if(in_array($size,$arr1))
|
||
return "y";
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//取得吊牌价格
|
||
function get_price_dp($cid,$khid,$color='',$bx=''){
|
||
global $db,$table_pre,$is_multi_price;
|
||
$is_ggk=is_ggk($khid);
|
||
if($is_ggk=="y"){
|
||
//有规格
|
||
$con1="";
|
||
if($color)
|
||
$con1.=" and color='".$color."'";
|
||
if($bx)
|
||
$con1.=" and gg='".$bx."'";
|
||
$m1=get_db_msg("select sum(price)/count(*) 'price' from ".$table_pre."kh_gg where iid='".$khid."'".$con1);
|
||
$price=$m1["price"];
|
||
}else{
|
||
//无规格
|
||
if($is_multi_price=="y"){
|
||
$m1=get_db_msg("select dp_price from ".$table_pre."client where id='".$cid."'");
|
||
$zd_price=$m1["dp_price"]?$m1["dp_price"]:"price1";
|
||
}else{
|
||
$zd_price="price";
|
||
}
|
||
$m_kh=get_db_msg("select ".$zd_price." from ".$table_pre."kh where id='".$khid."'");
|
||
$price=$m_kh[$zd_price];
|
||
}
|
||
return deel_num($price);
|
||
}
|
||
//取得结算价
|
||
function get_price_zk($cid,$khid,$color='',$bx=''){
|
||
global $db,$table_pre,$zk_type;
|
||
$price_zk=0;
|
||
$m1=get_db_msg("select * from ".$table_pre."zk where cid='".$cid."' and iid='".$khid."'");
|
||
if($zk_type=="kl"){
|
||
//扣率
|
||
$price_dp=get_price_dp($cid,$khid,$color,$bx);
|
||
$zk=($m1["id"]>0)?$m1["zk"]:1;
|
||
$price_zk=$price_dp*$zk;
|
||
}else{
|
||
//金额
|
||
if($m1["price"]>0){
|
||
$price_zk=$m1["price"];
|
||
}else{
|
||
$price_zk=get_price_dp($cid,$khid,$color,$bx);
|
||
}
|
||
}
|
||
return $price_zk;
|
||
}
|
||
//是否设置了折扣
|
||
function is_set_zk($cid,$khid){
|
||
global $db,$table_pre;
|
||
$r="n";
|
||
$m1=get_db_msg("select id from ".$table_pre."zk where cid='".$cid."' and iid='".$khid."'");
|
||
if($m1["id"]>0)
|
||
$r="y";
|
||
return $r;
|
||
}
|
||
//缓存订单表的数量和金额
|
||
function cache_order($uid,$khid,$color,$bx){
|
||
global $db,$table_pre,$zk_type,$bx_sizegroup_title,$is_multi_price;
|
||
$price_zk_dl=$price_md=0;
|
||
if($bx_sizegroup_title){
|
||
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$bx_sizegroup_title."' limit 0,1");
|
||
$bx_sizegroup_id=$tmp["id"];
|
||
}else{
|
||
$bx_sizegroup_id=0;
|
||
}
|
||
$m=get_db_msg("select ".get_size_sql("sum")." 'num',price,color,bx,upath,id,".get_size_sql("insert1")." from ".$table_pre."order where uid='".$uid."' and iid='".$khid."' and color='".$color."' and bx='".$bx."'");
|
||
if($m["id"]>0){
|
||
//
|
||
$num=$m["num"];
|
||
//------计算结算金额
|
||
$jsje=$jsje_dl=$mdje=0;
|
||
$m_kh=get_db_msg("select no,size_group,size from ".$table_pre."kh where id='".$khid."'");
|
||
//取得杯型
|
||
if($m_kh["size_group"]==$bx_sizegroup_id){
|
||
$tmp=get_db_msg("select size from ".$table_pre."size_bx where no='".$m_kh["no"]."' and bx='".$bx."'");
|
||
$arr_size=explode(",",$tmp["size"]);
|
||
}else{
|
||
$arr_size=explode(",",$m_kh["size"]);
|
||
}
|
||
//
|
||
$dl_uid=get_dl_id($m["upath"]);
|
||
$qy_uid=get_qy_id($m["upath"]);
|
||
//
|
||
$price_zk=get_price_zk($uid,$khid,$color,$bx);
|
||
if($dl_uid>0 && is_set_zk($dl_uid,$khid)=="y"){
|
||
$price_zk_dl=get_price_zk($dl_uid,$khid,$color,$bx);
|
||
}else{
|
||
$price_zk_dl=$price_zk;
|
||
}
|
||
$price_dp=get_price_dp($uid,$khid,$color,$bx);
|
||
$je=$num*$price_dp;
|
||
for($i=0;$i<count($arr_size);$i++){
|
||
$num_tmp=$m["num_".$arr_size[$i]];
|
||
$price_md=check_md($m_kh["no"],$m["color"],$bx,$arr_size[$i]);
|
||
//代理商结算金额
|
||
if($price_md!="n"){
|
||
$price_zk1=$price_md>0?$price_md:$price_zk;
|
||
$price_zk1_dl=$price_md>0?$price_md:$price_zk_dl;
|
||
$mdje+=$num_tmp*$price_zk1;
|
||
}else{
|
||
$price_zk1=$price_zk;
|
||
$price_zk1_dl=$price_zk_dl;
|
||
}
|
||
$jsje+=$num_tmp*$price_zk1;
|
||
$jsje_dl+=$num_tmp*$price_zk1_dl;
|
||
}
|
||
$q1="update ".$table_pre."order set price='".deel_num($price_dp)."',price_zk='".deel_num($price_zk)."',num='".$num."',je='".deel_num($je)."',jsje='".deel_num($jsje)."',jsje_dl='".deel_num($jsje_dl)."',mdje='".deel_num($mdje)."',qy='".$qy_uid."',dl='".$dl_uid."' where id='".$m["id"]."'";
|
||
$db->query($q1);
|
||
}
|
||
}
|
||
//
|
||
function set_order_total($uid){
|
||
global $db,$table_pre,$_key;
|
||
$order_num=$order_num1=0;
|
||
$order_money=$order_money_zk=$order_money1=$order_money1_zk=$order_money_md=0;
|
||
$m1=get_db_msg("select id,path,face from ".$table_pre."client where id='".$uid."'");
|
||
if($m1["face"]=="4"){
|
||
$jsje_title="jsje";
|
||
$con_uid="uid='".$uid."'";
|
||
}else{
|
||
$jsje_title="jsje_dl";
|
||
$con_uid="upath like '".$m1["path"]."-".$m1["id"]."-%'";
|
||
}
|
||
//所有
|
||
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(".$jsje_title.") 'jsje',sum(mdje) 'mdje' from ".$table_pre."order where ka<>'y' and ".$con_uid);
|
||
$order_num=$tmp["num"];
|
||
$order_money=$tmp["je"];
|
||
$order_money_zk=$tmp["jsje"];
|
||
$order_money_md=$tmp["mdje"];
|
||
//成衣
|
||
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(".$jsje_title.") 'jsje' from ".$table_pre."order where ka<>'y' and ".$con_uid." and is_sp<>'y'");
|
||
$order_num1=$tmp["num"];
|
||
$order_money1=$tmp["je"];
|
||
$order_money1_zk=$tmp["jsje"];
|
||
$db->query("update ".$table_pre."client set order_num='".$order_num."',order_num1='".$order_num1."',order_money='".$order_money."',order_money_zk='".$order_money_zk."',order_money1='".$order_money1."',order_money1_zk='".$order_money1_zk."',order_money_md='".$order_money_md."' where id='".$uid."'");
|
||
}
|
||
//
|
||
function set_order_total_all(){
|
||
global $db,$table_pre,$_key;
|
||
$q="select * from ".$table_pre."client where face='4' or face='3'";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
set_order_total($m["id"]);
|
||
}
|
||
}
|
||
//
|
||
//取得参数
|
||
function get_set($k){
|
||
global $db,$table_pre;
|
||
$m=get_db_msg("select * from ".$table_pre."set where _k='".$k."'");
|
||
if($m["id"]>0)
|
||
return $m["_v"];
|
||
else
|
||
return "";
|
||
}
|
||
//
|
||
function deel_color($c){
|
||
if($c){
|
||
$arr=explode(",",$c);
|
||
$b="";
|
||
for($i=0;$i<count($arr);$i++){
|
||
$arr1=explode("-",$arr[$i]);
|
||
$b.=$arr1[0].",";
|
||
}
|
||
if($b)
|
||
$b=substr($b,0,-1);
|
||
return $b;
|
||
}else{
|
||
return;
|
||
}
|
||
}
|
||
//
|
||
function show_color($c){
|
||
global $table_pre,$db;
|
||
if($c){
|
||
$arr=explode(",",$c);
|
||
$b="";
|
||
for($i=0;$i<count($arr);$i++){
|
||
$arr1=get_cate_title_no("color",$arr[$i]);
|
||
$b.=$arr[$i]."-".$arr1.",";
|
||
}
|
||
if($b)
|
||
$b=substr($b,0,-1);
|
||
return $b;
|
||
}else{
|
||
return;
|
||
}
|
||
}
|
||
//
|
||
function get_num_je_size($s,$s_group_id){
|
||
global $table_pre,$db,$con,$s_key;
|
||
$s=strtolower($s);
|
||
$m1=get_db_msg("select sum(num_".$s.") 'num',sum(num_".$s."*price) 'je' from ".$table_pre."order where _key='".$s_key."' and size_group_id='".$s_group_id."' ".$con);
|
||
return array($m1["num"],$m1["je"]);
|
||
}
|
||
//
|
||
function get_num_je_size_category($s,$cate,$no){
|
||
global $table_pre,$db,$con,$s_key;
|
||
$s=strtolower($s);
|
||
$m1=get_db_msg("select sum(num_".$s.") 'num',sum(num_".$s."*price) 'je' from ".$table_pre."order where _key='".$s_key."' and ".$cate."='".$no."' ".$con);
|
||
return array($m1["num"],$m1["je"]);
|
||
}
|
||
//
|
||
function get_c($pic){
|
||
$c="";
|
||
if($pic!="images/no_pic_80.gif"){
|
||
$tmp=explode("_",$pic);
|
||
$c=$tmp[count($tmp)-1];
|
||
if($c)
|
||
$c=substr($c,0,-4);
|
||
}
|
||
return $c;
|
||
}
|
||
//
|
||
function decode_pad_image($str){
|
||
return $str;
|
||
}
|
||
//
|
||
function get_picture($pic,$flag_pad=''){
|
||
$pic_pad="content://com.muchuang.edt/attachments/".$pic;
|
||
$pic="../attachments/".$pic;
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//-----------------------------------------------------------------自由搭配相关
|
||
//取得自由搭配图片
|
||
function get_zydp_pic($pic,$t='mini'){
|
||
global $sys_zydp_pic_path_mini,$sys_zydp_pic_path_big,$theme_path;
|
||
$v1="sys_zydp_pic_path_".$t;
|
||
$hz=($t=="mini")?"jpg":"png";
|
||
$pic="../attachments/zydp/".$$v1."/".$pic.".".$hz;
|
||
if(!is_file($pic)){
|
||
$pic=$theme_path."/images/no_pic.png";
|
||
}
|
||
return $pic;
|
||
}
|
||
//取得自由搭配模特遮罩图片
|
||
function get_zydp_mt_zz(){
|
||
global $sys_zydp_pic_path_mt;
|
||
$arr_tmp=explode(".",$sys_zydp_pic_path_mt);
|
||
return $arr_tmp[0]."_zz.".$arr_tmp[1];
|
||
}
|
||
//-----------------------------------------------------------------自由陈列相关
|
||
//计算侧挂的偏移量
|
||
function count_gan_pic_die_num($gan_width1,$gan_pic_width1,$sj_pic_width1,$pic_width1){
|
||
$width_over=$gan_pic_width1-$gan_width1;
|
||
$r=0;
|
||
if($width_over>0){
|
||
$r=round($width_over*$pic_width1/$sj_pic_width1);
|
||
}
|
||
return $r;
|
||
}
|
||
//取得自由陈列图片
|
||
function get_zycl_pic($pic,$t='mini'){
|
||
global $sys_zycl_pic_path_mini,$sys_zycl_pic_path_gan,$sys_zydp_pic_path_zen1,$sys_zydp_pic_path_zen2,$theme_path;
|
||
$v1="sys_zycl_pic_path_".$t;
|
||
$hz=($t=="mini")?"jpg":"png";
|
||
$pic="../attachments/zycl/".$$v1."/".$pic.".".$hz;
|
||
if(!is_file($pic)){
|
||
$pic=$theme_path."/images/no_pic.png";
|
||
}
|
||
return $pic;
|
||
}
|
||
//取得自由陈列大图系统指定路径
|
||
function get_zycl_pic_path($mb,$wzh){
|
||
global $sys_zycl_mb;
|
||
$arr_this_mb=array();
|
||
for($i=0;$i<count($sys_zycl_mb);$i++){
|
||
$tmp=explode("|",$sys_zycl_mb[$i]);
|
||
$tmp1=explode(",",$tmp[0]);
|
||
if($tmp1[0]==$mb){
|
||
$arr_this_mb=explode("|",$sys_zycl_mb[$i]);
|
||
break;
|
||
}
|
||
}
|
||
$arr_tmp_pic_path=explode(",",$arr_this_mb[2]);
|
||
$arr_tmp_wzh=explode(",",$arr_this_mb[1]);
|
||
$r="";
|
||
for($i=0;$i<count($arr_tmp_wzh);$i++){
|
||
if($arr_tmp_wzh[$i]==$wzh){
|
||
$r=$arr_tmp_pic_path[$i];
|
||
break;
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//取得自由陈列大图的真实路径
|
||
function get_zycl_pic_big_path($mb,$wzh,$list){
|
||
global $sys_zycl_mb,$sys_zycl_pic_path_gan;
|
||
$arr_this_mb=array();
|
||
for($i=0;$i<count($sys_zycl_mb);$i++){
|
||
$tmp=explode("|",$sys_zycl_mb[$i]);
|
||
$tmp1=explode(",",$tmp[0]);
|
||
if($tmp1[0]==$mb){
|
||
$arr_this_mb=explode("|",$sys_zycl_mb[$i]);
|
||
break;
|
||
}
|
||
}
|
||
$arr_tmp_wzh=explode(",",$arr_this_mb[1]);
|
||
$arr_tmp_pic_path=explode(",",$arr_this_mb[2]);
|
||
$ind=0;
|
||
$r="";
|
||
for($i=0;$i<count($arr_tmp_wzh);$i++){
|
||
if($arr_tmp_wzh[$i]==$wzh){
|
||
$ind=$i;
|
||
break;
|
||
}
|
||
}
|
||
if(get_zycl_pic_path($mb,$wzh)=="gan"){
|
||
$r=$sys_zycl_pic_path_gan;
|
||
}else{
|
||
if($list==0){
|
||
//正挂第一张
|
||
$r="z1";
|
||
}else{
|
||
//正挂叠装
|
||
$r="z2";
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//取得自由陈列大图的坐标
|
||
function get_zycl_pic_zb($mb,$wzh,$is_xz,$pic_w){
|
||
global $sys_zycl_mb,$sys_zycl_xz_top,$sys_zycl_pic_path_gan;
|
||
$arr_this_mb=array();
|
||
for($i=0;$i<count($sys_zycl_mb);$i++){
|
||
$tmp=explode("|",$sys_zycl_mb[$i]);
|
||
$tmp1=explode(",",$tmp[0]);
|
||
if($tmp1[0]==$mb){
|
||
$arr_this_mb=explode("|",$sys_zycl_mb[$i]);
|
||
break;
|
||
}
|
||
}
|
||
$arr_tmp_wzh=explode(",",$arr_this_mb[1]);
|
||
$ind_wzh=0;
|
||
for($i=0;$i<count($arr_tmp_wzh);$i++){
|
||
if($arr_tmp_wzh[$i]==$wzh){
|
||
$ind_wzh=$i;
|
||
break;
|
||
}
|
||
}
|
||
$arr_tmp_rec=explode(",",$arr_this_mb[3]);
|
||
if(get_zycl_pic_path($mb,$wzh)=="gan"){
|
||
$x=$arr_tmp_rec[$ind_wzh*4];
|
||
$y=$arr_tmp_rec[$ind_wzh*4+1];
|
||
}else{
|
||
$x=($arr_tmp_rec[$ind_wzh*4+2]-$arr_tmp_rec[$ind_wzh*4])/2+$arr_tmp_rec[$ind_wzh*4]-$pic_w/2;
|
||
$y=($is_xz=="y")?($arr_tmp_rec[$ind_wzh*4+1]+$sys_zycl_xz_top):$arr_tmp_rec[$ind_wzh*4+1];
|
||
}
|
||
return array($x,$y);
|
||
}
|
||
//
|
||
function get_kh_picture($no,$main_pic,$color,$flag_pad=''){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic.png";
|
||
$pic="";
|
||
if(trim($main_pic)){
|
||
$pic="../attachments/design/mini/".$no."_".$main_pic.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/mini/".decode_pad_image($no."_".$main_pic);
|
||
}
|
||
if(!is_file($pic)){
|
||
$pic="../attachments/design/mini/".$no.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/mini/".decode_pad_image($no);
|
||
}
|
||
if(!is_file($pic)){
|
||
$tmp=explode(",",$color);
|
||
for($j=0;$j<count($tmp);$j++){
|
||
$pic="../attachments/design/mini/".$no."_".$tmp[$j].".jpg";
|
||
if(is_file($pic)){
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/mini/".decode_pad_image($no."_".$tmp[$j]);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(!is_file($pic)){
|
||
$pic=$pic_pad=$theme_path."/images/no_pic.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//-----------------------------------------------------------------结束自由陈列相关
|
||
|
||
//图片合成
|
||
function imagecopymerge_alpha($dst_im,$src_im,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h){
|
||
$pct=100;
|
||
$cut=imagecreatetruecolor($src_w,$src_h);
|
||
imagecopy($cut,$dst_im,0,0,$dst_x,$dst_y,$src_w,$src_h);
|
||
imagecopy($cut,$src_im,0,0,$src_x,$src_y,$src_w,$src_h);
|
||
imagecopymerge($dst_im,$cut,$dst_x,$dst_y,0,0,$src_w,$src_h,$pct);
|
||
}
|
||
//
|
||
function get_sql_client_type($s_type){
|
||
global $msg_login;
|
||
if($s_type=="1"){
|
||
$r="upath='".$msg_login["path"]."-".$msg_login["id"]."' and ";
|
||
}else{
|
||
$r="(upath='') and ";
|
||
}
|
||
//echo $r."<br>";
|
||
return $r;
|
||
}
|
||
//存储图片到数据库
|
||
function put_pic_to_mysql($mod,$cate,$pic_name,$pic){
|
||
global $table_pre,$db;
|
||
if(is_file($pic)){
|
||
$c=get_db_msg("select id from ".$table_pre."pic where pic_mod='".$mod."' and pic_cate='".$cate."' and pic_name='".$pic_name."'");
|
||
$PSize=filesize($pic);
|
||
$mysqlPicture=addslashes(fread(fopen($pic,"r"),$PSize));
|
||
if($c["id"]>0){
|
||
$q="update ".$table_pre."pic set pic='".$mysqlPicture."' where id='".$c["id"]."'";
|
||
}else{
|
||
$q="insert into ".$table_pre."pic (pic_mod,pic_cate,pic_name,pic) values ('".$mod."','".$cate."','".$pic_name."','".$mysqlPicture."')";
|
||
}
|
||
$db->query($q);
|
||
}
|
||
}
|
||
//从数据库读取图片到指定路径
|
||
function read_pic_from_mysql($mod,$cate,$pic_name,$path){
|
||
global $table_pre,$db;
|
||
$c=get_db_msg("select id,pic from ".$table_pre."pic where pic_mod='".$mod."' and pic_cate='".$cate."' and pic_name='".$pic_name."'");
|
||
if($c["id"]>0){
|
||
write_file($path,$pic_name,$c["pic"]);
|
||
}
|
||
}
|
||
//
|
||
function get_kh_color_picture($no,$c,$flag_pad=''){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic.png";
|
||
$pic="../attachments/design/mini/".$no."_".$c.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/mini/".decode_pad_image($no."_".$c);
|
||
if(!is_file($pic)){
|
||
$pic="../attachments/design/mini/".$no.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/mini/".decode_pad_image($no);
|
||
}
|
||
if(!is_file($pic)){
|
||
$pic_pad=$pic=$theme_path."/images/no_pic.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_color_picture1($no,$c,$flag_pad=''){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic.png";
|
||
$pic="../attachments/design/mini/".$no."_".$c.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/mini/".decode_pad_image($no."_".$c);
|
||
if(!is_file($pic)){
|
||
$pic_pad=$pic=$theme_path."/images/no_pic.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_color_picture_big($no,$c,$flag_pad=''){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic_big.png";
|
||
$pic="../attachments/design/big/".$no."_".$c.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/big/".decode_pad_image($no."_".$c);
|
||
if(!is_file($pic)){
|
||
$pic="../attachments/design/big/".$no.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/big/".decode_pad_image($no);
|
||
}
|
||
if(!is_file($pic))
|
||
$pic=$pic_pad=$theme_path."/images/no_pic_big.png";
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_picture_big($no,$main_pic,$color,$flag_pad=''){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic_big.png";
|
||
$pic="";
|
||
if(trim($main_pic)){
|
||
$pic="../attachments/design/big/".$no."_".$main_pic.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/big/".decode_pad_image($no."_".$main_pic);
|
||
}
|
||
if(!is_file($pic)){
|
||
$pic="../attachments/design/big/".$no.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/big/".decode_pad_image($no);
|
||
}
|
||
if(!is_file($pic)){
|
||
$tmp=explode(",",$color);
|
||
for($j=0;$j<count($tmp);$j++){
|
||
$pic="../attachments/design/big/".$no."_".$tmp[$j].".jpg";
|
||
if(is_file($pic)){
|
||
$pic_pad="content://com.muchuang.edt/attachments/design/big/".decode_pad_image($no."_".$tmp[$j]);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(!is_file($pic)){
|
||
$pic=$pic_pad=$theme_path."/images/no_pic_big.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_dp_big($dph,$flag_pad=''){
|
||
global $sys_close_image,$sys_zydp,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic_big.png";
|
||
global $order_session;
|
||
$s_dir=$order_session?$order_session."/":"";
|
||
$pic="../attachments/dp/".$s_dir."big/".$dph.".jpg";
|
||
if($sys_zydp=="y" && !is_file($pic)){
|
||
read_pic_from_mysql("zydp","big",$dph.".jpg","../attachments/dp/".$s_dir."big");
|
||
}
|
||
$pic_pad="content://com.muchuang.edt/attachments/dp/".$s_dir."big/".decode_pad_image($dph);
|
||
if(!is_file($pic)){
|
||
$pic_pad=$pic=$theme_path."/images/no_pic_big.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_dp_mini($dph,$flag_pad=''){
|
||
global $sys_close_image,$sys_zydp,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic.png";
|
||
global $order_session;
|
||
$s_dir=$order_session?$order_session."/":"";
|
||
$pic="../attachments/dp/".$s_dir."mini/".$dph.".jpg";
|
||
if($sys_zydp=="y" && !is_file($pic)){
|
||
read_pic_from_mysql("zydp","mini",$dph.".jpg","../attachments/dp/".$s_dir."mini");
|
||
}
|
||
$pic_pad="content://com.muchuang.edt/attachments/dp/".$s_dir."mini/".decode_pad_image($dph);
|
||
if(!is_file($pic)){
|
||
$pic=$pic_pad=$theme_path."/images/no_pic.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_cl_big($clh,$flag_pad=''){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic_big.png";
|
||
global $order_session;
|
||
$s_dir=$order_session?$order_session."/":"";
|
||
$pic="../attachments/cl/".$s_dir."big/".$clh.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/cl/".$s_dir."big/".decode_pad_image($clh);
|
||
if(!is_file($pic)){
|
||
$pic_pad=$pic=$theme_path."/images/no_pic_big.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_cl_mini($clh,$flag_pad=''){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic.png";
|
||
global $order_session;
|
||
$s_dir=$order_session?$order_session."/":"";
|
||
$pic="../attachments/cl/".$s_dir."mini/".$clh.".jpg";
|
||
$pic_pad="content://com.muchuang.edt/attachments/cl/".$s_dir."mini/".decode_pad_image($clh);
|
||
if(!is_file($pic)){
|
||
$pic=$pic_pad=$theme_path."/images/no_pic.png";
|
||
}
|
||
$v="pic".$flag_pad;
|
||
return $$v;
|
||
}
|
||
//
|
||
function get_kh_cc_big($cch){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic_big.png";
|
||
global $order_session;
|
||
$s_dir=$order_session?$order_session."/":"";
|
||
$pic="../attachments/cc/".$s_dir."big/".$cch.".jpg";
|
||
if(!is_file($pic)){
|
||
$pic=$theme_path."/images/no_pic_big.png";
|
||
}
|
||
return $pic;
|
||
}
|
||
//
|
||
function get_kh_cc_mini($cch){
|
||
global $sys_close_image,$theme_path;
|
||
if($sys_close_image=="y")
|
||
return $theme_path."/images/no_pic.png";
|
||
global $order_session;
|
||
$s_dir=$order_session?$order_session."/":"";
|
||
$pic="../attachments/cc/".$s_dir."mini/".$cch.".jpg";
|
||
if(!is_file($pic)){
|
||
$pic=$theme_path."/images/no_pic.png";
|
||
}
|
||
return $pic;
|
||
}
|
||
//
|
||
function get_set_value_dote($set,$v){
|
||
$arr1=explode(",",$set);
|
||
$r="";
|
||
for($i=0;$i<count($arr1);$i++){
|
||
$arr2=explode("|",$arr1[$i]);
|
||
if($arr2[0]==$v){
|
||
$r=$arr2[1];
|
||
break;
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//输出界面
|
||
function go_face($face){
|
||
return "main_".$face;
|
||
}
|
||
//
|
||
function get_size_merged(){
|
||
global $table_pre,$db;
|
||
$arr_size_merged=array();
|
||
$r1=$db->query("select no from ".$table_pre."size group by no order by no");
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arr_size_merged[]=$m1["no"];
|
||
}
|
||
return $arr_size_merged;
|
||
}
|
||
//
|
||
function check_arr_select_show($no){
|
||
global $db,$table_pre;
|
||
$check=get_db_msg("select * from ".$table_pre."keyword where cate='arr_select' and no='".$no."'");
|
||
if($check["flag_ka"]=="y")
|
||
return true;
|
||
else
|
||
return false;
|
||
}
|
||
//
|
||
function get_jgd($price){
|
||
global $db,$table_pre;
|
||
$re="";
|
||
$q="select * from ".$table_pre."keyword where cate='jgd' order by no";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
if(check_jgd($price,$m["title"])){
|
||
$re=$m["no"];
|
||
}
|
||
}
|
||
return $re;
|
||
}
|
||
//
|
||
function check_jgd($price,$jgd){
|
||
$r=false;
|
||
if(strpos($jgd,"以下")){
|
||
$p=str_replace("以下","",$jgd);
|
||
if($price<$p)
|
||
$r=true;
|
||
}else if(strpos($jgd,"以上")){
|
||
$p=str_replace("以上","",$jgd);
|
||
if($price>$p)
|
||
$r=true;
|
||
}else if(strpos($jgd,"-")){
|
||
$p=explode("-",$jgd);
|
||
if($price>=$p[0] && $price<=$p[1])
|
||
$r=true;
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function get_zb_dw($zb_type){
|
||
if($zb_type=="js"){
|
||
$dw="件";
|
||
}else{
|
||
$dw="万";
|
||
}
|
||
return $dw;
|
||
}
|
||
//取得指标
|
||
function get_zb(){
|
||
global $db,$table_pre,$zbxf,$zb_uid,$zb_bc,$zb_season,$zb_series,$zb_brand,$zb_category,$zb_category1;
|
||
$q="";
|
||
$c1=explode("_",$zbxf);
|
||
if(count($c1)>1){
|
||
//
|
||
$v1="zb_".$c1[0];
|
||
$v2="zb_".$c1[1];
|
||
if($$v1 && $$v2){
|
||
$q="select * from ".$table_pre."client_zb where cid='".$zb_uid."' and ".$c1[0]."='".$$v1."' and ".$c1[1]."='".$$v2."' limit 0,1";
|
||
//echo $q."<br>";
|
||
}else if($$v1){
|
||
$q="select sum(num) 'num' from ".$table_pre."client_zb where cid='".$zb_uid."' and ".$c1[0]."='".$$v1."' limit 0,1";
|
||
}else if($$v2){
|
||
$q="select sum(num) 'num' from ".$table_pre."client_zb where cid='".$zb_uid."' and ".$c1[1]."='".$$v2."' limit 0,1";
|
||
}
|
||
}else{
|
||
$v1="zb_".$c1[0];
|
||
$q="select * from ".$table_pre."client_zb where cid='".$zb_uid."' and ".$c1[0]."='".$$v1."' limit 0,1";
|
||
}
|
||
$m=get_db_msg($q);
|
||
$r=$m["num"];
|
||
return $r."%";
|
||
}
|
||
//取得评价图标
|
||
function get_pj_icon($race,$khid,$icon){
|
||
$r="<table width=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\"><tr>";
|
||
for($i=1;$i<=$race;$i++){
|
||
$r.="<td align=\"center\"><img src='".get_star($icon,"")."' id='pj_".$khid."_".$i."' style=\"cursor:pointer;\" onclick=\"save_pj_race(".$i.",".$race.",'".$khid."','".$icon."')\"></td>";
|
||
}
|
||
for($j=$i;$j<=5;$j++){
|
||
$r.="<td align=\"center\"><img src='".get_star($icon,"1")."' id='pj_".$khid."_".$j."' style=\"cursor:pointer;\" onclick=\"save_pj_race(".$j.",".$race.",'".$khid."','".$icon."')\"></td>";
|
||
}
|
||
$r.="</tr></table>";
|
||
return $r;
|
||
}
|
||
//显示评价图标
|
||
function get_star($icon,$color){
|
||
global $theme_path;
|
||
if($icon=="mini"){
|
||
return $theme_path."/images/star_mini".$color.".png";
|
||
}else{
|
||
return $theme_path."/images/star".$color.".png";
|
||
}
|
||
}
|
||
//
|
||
function get_sx($color){
|
||
global $table_pre,$db;
|
||
$q="select * from ".$table_pre."sx";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
$arr=explode(",",$m["_v"]);
|
||
for($i=0;$i<count($arr);$i++){
|
||
if($arr[$i]==$color)
|
||
return $m["no"];
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
//检查数组内的数字是否相同
|
||
function check_arr_equal($arr){
|
||
$r=true;
|
||
$num=$arr[0];
|
||
for($i=0;$i<count($arr);$i++){
|
||
if($arr[$i]!=$num){
|
||
$r=false;
|
||
break;
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//检查数组内的数字没有零
|
||
function check_arr_not_zero($arr){
|
||
$r=true;
|
||
$c=0;
|
||
for($i=0;$i<count($arr);$i++){
|
||
$c+=$arr[$i];
|
||
}
|
||
if($c>0){
|
||
for($i=0;$i<count($arr);$i++){
|
||
if($arr[$i]==0){
|
||
$r=false;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function get_client_autocompelete($uid=''){
|
||
global $db,$table_pre;
|
||
$con="";
|
||
if($uid){
|
||
$m1=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
|
||
$con=" where path='".$m1["path"]."-".$m1["id"]."'";
|
||
}
|
||
$str="var clients = [\n";
|
||
$con=$face?" where face='".$face."'":"";
|
||
$q="select id,title,username,path,CONCAT(path,'-',id) 'abs_path' from ".$table_pre."client ".$con." order by abs_path";
|
||
$r=$db->query($q);
|
||
$i=0;
|
||
while($m=$db->fetch_array($r)){
|
||
$str.="{id:\"".$m["id"]."\",t:\"".$m["title"]."\",u:\"".$m["username"]."\",p:\"".$m["path"]."-".$m["id"]."\"},\n";
|
||
$i++;
|
||
}
|
||
if($i>0)
|
||
$str=substr($str,0,-2);
|
||
$str.="];\n";
|
||
return $str;
|
||
}
|
||
//取得折扣
|
||
function get_zk($cid,$category){
|
||
global $db,$table_pre;
|
||
$zk=100;
|
||
$tmp=get_db_msg("select zk from ".$table_pre."client_zk where cid='".$cid."' and category='".$category."'");
|
||
if($tmp["zk"]>0)
|
||
$zk=$tmp["zk"];
|
||
return $zk;
|
||
}
|
||
//取得款号的序号,当序号到色或者到款都支持
|
||
function get_kh_xh($msg,$color=''){
|
||
global $db,$table_pre,$xh_ms;
|
||
if($xh_ms=="2"){
|
||
//
|
||
if(trim($color))
|
||
$m1=get_db_msg("select * from ".$table_pre."kh_xh where kh='".$msg["no"]."' and color='".$color."' limit 0,1");
|
||
if($m1["id"]>0){
|
||
$xh=$m1["xh"];
|
||
}else{
|
||
$m1=get_db_msg("select * from ".$table_pre."kh_xh where kh='".$msg["no"]."' limit 0,1");
|
||
if($m1["id"]>0)
|
||
$xh=$m1["xh"];
|
||
else
|
||
$xh=$msg["xh"];
|
||
}
|
||
}else{
|
||
//到款
|
||
$xh=$msg["xh"];
|
||
}
|
||
return $xh;
|
||
}
|
||
//检查必订款
|
||
function check_dhgz_bdk($msg,$num){
|
||
global $db,$table_pre,$msg_login;
|
||
$client_dj=trim($msg_login["dj"]);
|
||
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
|
||
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='bdk' and kh='".$msg["no"]."'".$con_dj);
|
||
if($tmp["num"]>$num){
|
||
alert_and_back("对不起,定单量必须大于必订量(".$tmp["num"]."件)");
|
||
}
|
||
}
|
||
|
||
//检查起订量
|
||
function check_dhgz_qdl($msg,$color,$num){
|
||
global $db,$table_pre,$msg_login;
|
||
$client_dj=trim($msg_login["dj"]);
|
||
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
|
||
if($color){
|
||
$con_color=" and color='".$color."'";
|
||
$str_color="(".$color."-".get_cate_title_no("color",$color).")";
|
||
}else{
|
||
$con_color=" and color=''";
|
||
$str_color="";
|
||
}
|
||
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='qdl' and kh='".$msg["no"]."'".$con_dj.$con_color);
|
||
if($num>0 && $tmp["num"]>0 && $num<$tmp["num"]){
|
||
alert_and_back("对不起,".$msg["no"].$str_color.",必须大于起订量(".$tmp["num"]."件)");
|
||
}
|
||
}
|
||
//检查关联款
|
||
function check_dhgz_glk($kh,$num,$str_kh_num=''){
|
||
global $db,$table_pre,$msg_login;
|
||
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='glk' and (kh='".$kh."' or color='".$kh."')");
|
||
if($tmp["id"]>0){
|
||
$kh_gl=($kh==$tmp["kh"])?$tmp["color"]:$tmp["kh"];
|
||
//取得关联款订单
|
||
$tmp_num=get_db_msg("select sum(num) 'num' from ".$table_pre."order where uid='".$msg_login["id"]."' and no='".$kh_gl."'");
|
||
$num1=$tmp_num["num"];
|
||
if($str_kh_num){
|
||
$arr_tmp=explode(",",$str_kh_num);
|
||
for($i1=0;$i1<count($arr_tmp);$i1++){
|
||
$arr_tmp1=explode("|",$arr_tmp[$i1]);
|
||
if($arr_tmp1[0]==$kh_gl)
|
||
$num1+=$arr_tmp1[1];
|
||
}
|
||
}
|
||
if($tmp["num"]==1){
|
||
if($num>0 && $num1>0)
|
||
alert_and_back("对不起,".$kh."(".deel_num($num)."件)与".$kh_gl."(".deel_num($num1)."件)只能选择一款订货!");
|
||
}else if($tmp["num"]==3){
|
||
if($kh==$tmp["kh"]){
|
||
if($num<$num1)
|
||
alert_and_back("对不起,".$kh."(".deel_num($num)."件)的订量要求大于等于".$kh_gl."(".deel_num($num1)."件)!");
|
||
}else{
|
||
if($num>$num1)
|
||
alert_and_back("对不起,".$kh."(".deel_num($num)."件)的订量要求小于等于".$kh_gl."(".deel_num($num1)."件)!");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//检查必订款色
|
||
function check_dhgz_bdks($msg,$color,$num){
|
||
global $db,$table_pre,$msg_login;
|
||
$client_dj=trim($msg_login["dj"]);
|
||
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
|
||
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='bdks' and kh='".$msg["no"]."' and color='".$color."'".$con_dj);
|
||
if($tmp["num"]>$num){
|
||
alert_and_back("对不起,".$msg["no"]."(".$color."-".get_cate_title_no("color",$color)."),定单量必须大于必订量(".$tmp["num"]."件)");
|
||
}
|
||
}
|
||
//检查订货倍数
|
||
function check_dhgz_dhbs($kh,$gg,$size,$num){
|
||
global $db,$table_pre;
|
||
if($num>0){
|
||
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='dhbs' and kh='".$kh."' and bc='".$gg."'");
|
||
if($tmp["id"]>0 && $num%$tmp["num"]!=0){
|
||
$m_error="对不起,".$kh;
|
||
if($gg)
|
||
$m_error.="|".get_gg_title($gg);
|
||
$m_error.="|".$size.",不符合".d_translate("dhbs")."(".$tmp["num"].")";
|
||
alert_and_back($m_error);
|
||
}
|
||
}
|
||
}
|
||
//检查必订规格
|
||
function check_dhgz_bdgg($kh,$color,$gg,$num){
|
||
global $db,$table_pre,$msg_login;
|
||
$client_dj=trim($msg_login["dj"]);
|
||
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
|
||
$tmp=get_db_msg("select * from ".$table_pre."gz where cate='bdgg' and kh='".$kh."' and color='".$color."' and bc='".$gg."'".$con_dj);
|
||
if($tmp["num"]>$num){
|
||
alert_and_back("对不起,".$color."-".get_cate_title_no("color",$color)."|".get_gg_title($gg).",定单量必须大于必订量(".$tmp["num"]."件)");
|
||
}
|
||
}
|
||
//检查客户是否符合订货规则
|
||
function check_dhgz_client($uid,$ajax="n"){
|
||
global $db,$table_pre,$is_spk,$s_brand;
|
||
$sql_size1=get_size_sql("sum");
|
||
$m_client=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
|
||
$client_dj=trim($m_client["dj"]);
|
||
$con_dj=$client_dj?" and (dj='".$client_dj."' or dj='')":" and dj=''";
|
||
$wrong="n";
|
||
$con_brand_kh="";
|
||
if($s_brand){
|
||
$q1="select no from ".$table_pre."kh where brand='".$s_brand."'";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$con_brand_kh.="'".$m1["no"]."',";
|
||
}
|
||
}
|
||
if($con_brand_kh)
|
||
$con_brand_kh=" and kh in(".substr($con_brand_kh,0,-1).")";
|
||
//必订款
|
||
$q1="select * from ".$table_pre."gz where cate='bdk'".$con_dj.$con_brand_kh." order by kh";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
|
||
//取得实际数量
|
||
$tmp=get_db_msg("select sum(".$sql_size1.") 'num' from ".$table_pre."order where no='".$m1["kh"]."' and uid='".$uid."'");
|
||
if($m1["num"]>$tmp["num"]){
|
||
$wrong="必订款";
|
||
break;
|
||
}
|
||
}
|
||
if($wrong=="n"){
|
||
//必订款色
|
||
$q1="select * from ".$table_pre."gz where cate='bdks'".$con_dj.$con_brand_kh." order by kh";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
|
||
//取得实际数量
|
||
$tmp=get_db_msg("select sum(".$sql_size1.") 'num' from ".$table_pre."order where no='".$m1["kh"]."' and color='".$m1["color"]."' and uid='".$uid."'");
|
||
if($m1["num"]>$tmp["num"]){
|
||
$wrong="必订款色";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if($wrong=="n"){
|
||
//必订规格
|
||
$q1="select * from ".$table_pre."gz where cate='bdgg'".$con_dj.$con_brand_kh." order by kh";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
|
||
//取得实际数量
|
||
$tmp=get_db_msg("select sum(".$sql_size1.") 'num' from ".$table_pre."order where no='".$m1["kh"]."' and color='".$m1["color"]."' and bx='".$m1["bc"]."' and uid='".$uid."'");
|
||
if($m1["num"]>$tmp["num"]){
|
||
$wrong="必订".d_translate("gg");
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if($wrong=="n"){
|
||
//必订色
|
||
$q1="select * from ".$table_pre."gz where cate='bds'".$con_dj.$con_brand_kh." order by kh";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$m_kh=get_db_msg("select * from ".$table_pre."kh where no='".$m1["kh"]."'");
|
||
//取得实际数量
|
||
$tmp=get_db_msg("select sum(".$sql_size1.") 'num' from ".$table_pre."order where bc='".$m1["bc"]."' and color='".$m1["color"]."' and uid='".$uid."'");
|
||
if($m1["num"]>$tmp["num"]){
|
||
$wrong="必订色";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if($wrong=="n"){
|
||
//金额比例
|
||
//订单总金额
|
||
if($is_spk=="y"){
|
||
$total_money=$m_client["order_money1_zk"];
|
||
$con_sp=" and is_sp='y'";
|
||
}else{
|
||
$total_money=$m_client["order_money_zk"];
|
||
$con_sp="";
|
||
}
|
||
$q1="select * from ".$table_pre."keyword where cate='kh_dj' order by no";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$m2=get_db_msg("select * from ".$table_pre."gz where cate='jebl'".$con_dj." and kh='".$m1["no"]."'");
|
||
if($m2["id"]>0){
|
||
//取得实际金额
|
||
$tmp=get_db_msg("select sum(jsje) 'je' from ".$table_pre."order where kh_dj='".$m1["no"]."' and uid='".$uid."'".$con_sp);
|
||
if($total_money>0){
|
||
$bl=($tmp["je"]/$total_money)*100;
|
||
}else{
|
||
$bl=0;
|
||
}
|
||
$gs=$bl.$m2["color"].$m2["num"];
|
||
eval("\$r=$gs;");
|
||
if($r==false){
|
||
$wrong="金额比例";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if($wrong=="n"){
|
||
//必订款式
|
||
$q1="select bc,num from ".$table_pre."gz where cate='bdkshi'".$con_dj." group by bc";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
//取得实际数量
|
||
$q2="select kh from ".$table_pre."gz where cate='bdkshi' and bc='".$m1["bc"]."'";
|
||
$r2=$db->query($q2);
|
||
$yd_ks=0;
|
||
while($m2=$db->fetch_array($r2)){
|
||
$c=get_db_msg("select id from ".$table_pre."order where no='".$m2["kh"]."' and uid='".$uid."'");
|
||
if($c["id"]>0)
|
||
$yd_ks++;
|
||
}
|
||
if($yd_ks<$m1["num"]){
|
||
$wrong="必订款式";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if($wrong!="n"){
|
||
if($ajax=="y"){
|
||
return $wrong;
|
||
}else{
|
||
alert_and_back("对不起,订单不符合订货规则,请检查!(".$wrong.")");
|
||
}
|
||
}
|
||
return "y";
|
||
}
|
||
//检查最高订量
|
||
function check_zgdl($uid,$ajax="n"){
|
||
global $db,$table_pre,$is_brand;
|
||
$q="select * from ".$table_pre."gz where cate='zgdl' order by kh,color";
|
||
$r=$db->query($q);
|
||
$str_wrong="";
|
||
while($m=$db->fetch_array($r)){
|
||
$m_kh=get_db_msg("select id from ".$table_pre."kh where no='".$m["kh"]."'");
|
||
if(trim($m["color"])){
|
||
$con_color=" and o.color='".trim($m["color"])."'";
|
||
$title_c="|".$m["color"]."-".get_cate_title_no("color",$m["color"]);
|
||
}else{
|
||
$con_color="";
|
||
$title_c="";
|
||
}
|
||
$tmp=get_db_msg("select sum(o.num) 'num' from ".$table_pre."order o,".$table_pre."client c where o.uid=c.id and o.iid='".$m_kh["id"]."'".$con_color." and (c.is_checked='y' or c.id='".$uid."')");
|
||
if($tmp["num"]>$m["num"]){
|
||
$str_wrong.=$m["kh"].$title_c."(超".($tmp["num"]-$m["num"])."件),";
|
||
}
|
||
}
|
||
if($str_wrong){
|
||
if($ajax=="y"){
|
||
return $wrong;
|
||
}else{
|
||
alert_and_back("对不起,有部分款的订单超过了最高订量(".substr($str_wrong,0,-1).")");
|
||
}
|
||
}
|
||
return "y";
|
||
}
|
||
//尺码sql脚本
|
||
function get_size_sql($t){
|
||
global $sys_size_num;
|
||
$r="";
|
||
switch($t){
|
||
case "sum";
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$r.="num_".$s1."+";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "suma";
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$r.="a.num_".$s1."+";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "sumb";
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$r.="b.num_".$s1."+";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "sum1";
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$r.="sum(num_".$s1.") 'num_".$s1."',";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "update":
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
global $$v1;
|
||
$r.=$v1."='".$$v1."',";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "insert1":
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$r.="num_".$s1.",";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "inserta":
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$r.="a.num_".$s1.",";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "insert2":
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
global $$v1;
|
||
$r.="'".$$v1."',";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
break;
|
||
case "count_total":
|
||
$r=0;
|
||
for($s1=1;$s1<=$sys_size_num;$s1++){
|
||
$v1="num_".$s1;
|
||
global $$v1;
|
||
$r+=$$v1;
|
||
}
|
||
break;
|
||
|
||
}
|
||
return $r;
|
||
}
|
||
//取得数字输入框的宽度
|
||
function get_input_width($num){
|
||
if($num<11){
|
||
$r=40;
|
||
}else if($num>10 & $num<21){
|
||
$r=20;
|
||
}else{
|
||
$r=15;
|
||
}
|
||
return $r;
|
||
}
|
||
//处理显示的金额方式
|
||
function deel_je_show($je){
|
||
if($je>=100000000){
|
||
$je=deel_num(keep_float(($je/100000000),2))."亿";
|
||
}else if($je>=10000){
|
||
$je=deel_num(keep_float(($je/10000),2))."万";
|
||
}else{
|
||
$je=deel_num($je);
|
||
}
|
||
return $je;
|
||
}
|
||
//解析多品牌入口
|
||
function parse_client_title($title){
|
||
$arr_images=array("jpg","gif","png");
|
||
$arr_title=explode("|",$title);
|
||
if(in_array(substr($arr_title[0],strlen($arr_title[0])-3,3),$arr_images)){
|
||
$r="<img src=\"../attachments/".$arr_title[0]."\">";
|
||
}else{
|
||
$r=$arr_title[0];
|
||
}
|
||
return $r;
|
||
}
|
||
//解析多品牌入口
|
||
function parse_client_title_login($title){
|
||
$arr_images=array("jpg","gif","png");
|
||
$arr_title=explode("|",$title);
|
||
$url1=$_SERVER["PHP_SELF"];
|
||
$arr_url1=explode("/",$url1);
|
||
$r="";
|
||
if(count($arr_title)>1){
|
||
for($i=0;$i<count($arr_title);$i++){
|
||
//多品牌
|
||
if(in_array(substr($arr_title[$i],strlen($arr_title[$i])-3,3),$arr_images)){
|
||
if($i==0)
|
||
$r.="<img src=\"../attachments/".$arr_title[$i]."\" style=\"border:4px solid #33ff00;\"> ";
|
||
else
|
||
$r.="<a href=\"../".md5($arr_title[$i])."/".$arr_url1[count($arr_url1)-2]."\"><img src=\"../attachments/".$arr_title[$i]."\" style=\"border:0px;\"></a> ";
|
||
}else{
|
||
if($i==0)
|
||
$r.="".$arr_title[$i]."</span> ";
|
||
else
|
||
$r.="<a href=\"../".md5($arr_title[$i])."/".$arr_url1[count($arr_url1)-2]."\" style=\"font-size:30px;font-weight:bold;color:#ffffff;\"><span".$sty.">".$arr_title[$i]."</span></a> ";
|
||
}
|
||
}
|
||
}else{
|
||
//
|
||
if(in_array(substr($arr_title[0],strlen($arr_title[0])-3,3),$arr_images)){
|
||
$r="<img src=\"../attachments/".$arr_title[0]."\">";
|
||
}else{
|
||
$r=$arr_title[0];
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//-------------------------------------------------------------------------计算排行表
|
||
//到色计算
|
||
function count_ph($uid,$iid,$color){
|
||
global $db,$table_pre;
|
||
$c1=get_db_msg("select count(*) 'num' from ".$table_pre."ph");
|
||
if($c1["num"]==0)
|
||
cache_ph_first();
|
||
$m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$iid."'");
|
||
$m_client=get_db_msg("select path,username,in_ph from ".$table_pre."client where id='".$uid."'");
|
||
if($m_kh["in_ph"]=="y" && $m_client["in_ph"]=="y"){
|
||
$qy_id=get_qy_id($m_client["path"]);
|
||
//取得选项
|
||
$arr_select_no=array();
|
||
$sql1=$sql2="";
|
||
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'sx' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$sql1.=$m1["no"].",";
|
||
$sql2.="'".$m_kh[$m1["no"]]."',";
|
||
}
|
||
//饰品款
|
||
$sql1.="is_sp,";
|
||
$sql2.="'".$m_kh["is_sp"]."',";
|
||
//
|
||
$check=get_db_msg("select * from ".$table_pre."ph where qy='".$qy_id."' and iid='".$iid."' and color='".$color."'");
|
||
//
|
||
$m1=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where qy='".$qy_id."' and iid='".$iid."' and color='".$color."' and ka<>'y' group by qy,iid,color");
|
||
//
|
||
if($check["id"]>0){
|
||
if($m1["num"]==0)
|
||
$q="delete from ".$table_pre."ph where id='".$check["id"]."'";
|
||
else
|
||
$q="update ".$table_pre."ph set num='".$m1["num"]."',je='".$m1["je"]."' where id='".$check["id"]."'";
|
||
}else{
|
||
if($m1["num"]>0)
|
||
$q="insert into ".$table_pre."ph (iid,qy,no,color,".$sql1."num,je) values ('".$iid."','".$qy_id."','".$m_kh["no"]."','".$color."',".$sql2."'".$m1["num"]."','".$m1["je"]."')";
|
||
}
|
||
if($q)
|
||
$db->query($q);
|
||
}
|
||
}
|
||
//到款计算
|
||
function count_ph_uid_kh($uid,$iid){
|
||
global $db,$table_pre;
|
||
$c1=get_db_msg("select count(*) 'num' from ".$table_pre."ph");
|
||
if($c1["num"]==0)
|
||
cache_ph_first();
|
||
$m_client=get_db_msg("select path,in_ph from ".$table_pre."client where id='".$uid."'");
|
||
$m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$iid."'");
|
||
if($m_kh["in_ph"]=="y" && $m_client["in_ph"]=="y"){
|
||
$qy_id=get_qy_id($m_client["path"]);
|
||
//删除相关数据
|
||
$db->query("delete from ".$table_pre."ph where qy='".$qy_id."' and iid='".$iid."'");
|
||
//取得选项
|
||
$arr_select_no=array();
|
||
$sql1="";
|
||
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'sx' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arr_select_no[]=$m1["no"];
|
||
$sql1.=$m1["no"].",";
|
||
}
|
||
//饰品款
|
||
$sql1.="is_sp,";
|
||
//
|
||
$q1="select sum(num) 'num',sum(je) 'je',color from ".$table_pre."order where qy='".$qy_id."' and iid='".$iid."' and ka<>'y' group by qy,iid,color";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
//取得选项
|
||
$sql2="";
|
||
for($i1=0;$i1<count($arr_select_no);$i1++){
|
||
$sql2.="'".$m_kh[$arr_select_no[$i1]]."',";
|
||
}
|
||
$sql2.="'".$m_kh["is_sp"]."',";
|
||
if($m1["num"]>0){
|
||
$q="insert into ".$table_pre."ph (iid,qy,no,color,".$sql1."num,je) values ('".$iid."','".$qy_id."','".$m_kh["no"]."','".$m1["color"]."',".$sql2."'".$m1["num"]."','".$m1["je"]."')";
|
||
//echo $q."<br>";
|
||
$db->query($q);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//初次读入排行数据
|
||
function cache_ph_first(){
|
||
global $db,$table_pre;
|
||
//取得选项
|
||
$arr_select_no=array();
|
||
$sql1="";
|
||
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'sx' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arr_select_no[]=$m1["no"];
|
||
$sql1.=$m1["no"].",";
|
||
}
|
||
//饰品款
|
||
$sql1.="is_sp,";
|
||
$q="select * from ".$table_pre."kh where ka<>'y' and in_ph='y'";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
$arr_color=explode(",",$m["color"]);
|
||
$arr_color_ka=explode(",",$m["color_ka"]);
|
||
for($k=0;$k<count($arr_color);$k++){
|
||
if(!in_array($arr_color[$k],$arr_color_ka)){
|
||
//取得选项
|
||
$sql2="";
|
||
for($i1=0;$i1<count($arr_select_no);$i1++){
|
||
$sql2.="'".$m[$arr_select_no[$i1]]."',";
|
||
}
|
||
$sql2.="'".$m_kh["is_sp"]."',";
|
||
$q1="insert into ".$table_pre."ph (iid,qy,no,color,".$sql1."num,je) values ('".$m["id"]."','','".$m["no"]."','".$arr_color[$k]."',".$sql2."'0','0')";
|
||
//echo $q1."<br>";
|
||
$db->query($q1);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//重新缓存排行表
|
||
function cache_ph(){
|
||
global $db,$table_pre;
|
||
//取得选项
|
||
$arr_select_no=array();
|
||
$sql1="";
|
||
$sql11="";
|
||
$q1="select no from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'sx' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arr_select_no[]=$m1["no"];
|
||
$sql1.=$m1["no"].",";
|
||
$sql11.="o.".$m1["no"].",";
|
||
}
|
||
//饰品款
|
||
$sql1.="is_sp,";
|
||
$sql11.="o.is_sp,";
|
||
//重新读入数据
|
||
$db->query("truncate table ".$table_pre."ph");
|
||
//读入订单数据
|
||
$q="select o.iid 'iid',o.no 'no',o.color 'color',".$sql11."sum(o.num) 'num',sum(o.je) 'je',o.qy 'qy' from ".$table_pre."order o,".$table_pre."kh k,".$table_pre."client c where o.iid=k.id and o.uid=c.id and o.ka<>'y' and k.in_ph='y' and c.in_ph='y' and o.ka<>'y' group by o.qy,o.no,o.color";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
//取得选项
|
||
$sql2="";
|
||
for($i1=0;$i1<count($arr_select_no);$i1++){
|
||
$sql2.="'".$m[$arr_select_no[$i1]]."',";
|
||
}
|
||
$sql2.="'".$m["is_sp"]."',";
|
||
$q1="insert into ".$table_pre."ph (iid,qy,no,color,".$sql1."num,je) values ('".$m["iid"]."','".$m["qy"]."','".$m["no"]."','".$m["color"]."',".$sql2."'".$m["num"]."','".$m["je"]."')";
|
||
//echo $q1."<br>";
|
||
$db->query($q1);
|
||
}
|
||
//读入未定款色
|
||
$q="select * from ".$table_pre."kh where ka<>'y' and in_ph='y'";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
$arr_color=explode(",",$m["color"]);
|
||
$arr_color_ka=explode(",",$m["color_ka"]);
|
||
for($k=0;$k<count($arr_color);$k++){
|
||
if(!in_array($arr_color[$k],$arr_color_ka)){
|
||
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."ph where iid='".$m["id"]."' and color='".$arr_color[$k]."'");
|
||
if($tmp["num"]>0){
|
||
//已存在,则不读入
|
||
}else{
|
||
//不存在,则读入
|
||
//取得选项
|
||
$sql2="";
|
||
for($i1=0;$i1<count($arr_select_no);$i1++){
|
||
$sql2.="'".$m[$arr_select_no[$i1]]."',";
|
||
}
|
||
$sql2.="'".$m["is_sp"]."',";
|
||
$q1="insert into ".$table_pre."ph (iid,qy,no,color,".$sql1."num,je) values ('".$m["id"]."','','".$m["no"]."','".$arr_color[$k]."',".$sql2."'0','0')";
|
||
//echo $q1."<br>";
|
||
$db->query($q1);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//取得上级区域
|
||
function get_qy_id($path){
|
||
global $db,$table_pre;
|
||
$arr_path=explode("-",$path);
|
||
for($i=count($arr_path)-1;$i>=0;$i--){
|
||
if($arr_path[$i]>0){
|
||
$m1=get_db_msg("select id,face from ".$table_pre."client where id='".$arr_path[$i]."'");
|
||
if($m1["face"]=="9"){
|
||
return $m1["id"];
|
||
}
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
//取得上级代理
|
||
function get_dl_id($path){
|
||
global $db,$table_pre;
|
||
$arr_path=explode("-",$path);
|
||
for($i=count($arr_path)-1;$i>=0;$i--){
|
||
if($arr_path[$i]>0){
|
||
$m1=get_db_msg("select id,face from ".$table_pre."client where id='".$arr_path[$i]."'");
|
||
if($m1["face"]=="3"){
|
||
return $m1["id"];
|
||
}
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
//读取可支持的最大尺码
|
||
function get_max_size_num(){
|
||
global $db,$table_pre;
|
||
$q="show columns from ".$table_pre."order";
|
||
$r=$db->query($q);
|
||
$max=0;
|
||
while($m=$db->fetch_array($r)){
|
||
if(substr($m["Field"],0,4)=="num_"){
|
||
$arr=explode("_",$m["Field"]);
|
||
$max=$arr[1]>$max?$arr[1]:$max;
|
||
}
|
||
}
|
||
return $max;
|
||
}
|
||
//规范配码规则
|
||
function deel_pm_gz($gz){
|
||
$gz=str_replace(":",":",$gz);
|
||
$gz=str_replace(";",":",$gz);
|
||
$gz=str_replace(";",":",$gz);
|
||
$arr1=explode(":",$gz);
|
||
$r="";
|
||
for($i=0;$i<count($arr1);$i++){
|
||
$num=$arr1[$i]+1-1;
|
||
$r.=$num.":";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//单独计算代理商金额
|
||
function cache_je_dl($id){
|
||
global $db,$table_pre;
|
||
$m=get_db_msg("select path from ".$table_pre."client where id='".$id."'");
|
||
$tmp=get_db_msg("select sum(jsje_dl) 'money' from ".$table_pre."order where upath like '".$m["path"]."-".$id."-%' and is_sp<>'y'");
|
||
$order_money_zk=$tmp["money"];
|
||
$tmp=get_db_msg("select sum(jsje_dl) 'money' from ".$table_pre."order where upath like '".$m["path"]."-".$id."-%' and is_sp='y'");
|
||
$order_money1_zk=$tmp["money"];
|
||
$db->query("update ".$table_pre."client set order_money_zk='".$order_money_zk."',order_money1_zk='".$order_money1_zk."' where id='".$id."'");
|
||
}
|
||
//是否启用多品牌
|
||
function is_brand(){
|
||
global $db,$table_pre;
|
||
$r=get_set("is_brand");
|
||
$r=$r?$r:"n";
|
||
return $r;
|
||
}
|
||
//取得用户订单确认情况
|
||
function get_client_state($is_jd,$is_checked){
|
||
global $show_jd;
|
||
$r="";
|
||
if($show_jd=="y"){
|
||
if($is_checked=="y"){
|
||
$r="已确认";
|
||
}else{
|
||
if($is_jd=="y"){
|
||
$r="已交单";
|
||
}else{
|
||
$r="未交单";
|
||
}
|
||
}
|
||
}else{
|
||
if($is_checked=="y")
|
||
$r="已确认";
|
||
else
|
||
$r="未确认";
|
||
}
|
||
return $r;
|
||
}
|
||
//获取启用多品牌后,客户所有品牌的订单确认情况
|
||
function get_client_state_all_brand($id){
|
||
global $db,$table_pre,$show_jd;
|
||
$client_state="";
|
||
if($show_jd=="y"){
|
||
$c1=get_db_msg("select count(*) 'num' from ".$table_pre."client_brand where cid='".$id."' and is_checked='y'");
|
||
$c2=get_db_msg("select count(*) 'num' from ".$table_pre."client_brand where cid='".$id."'");
|
||
if($c1["num"]==$c2["num"]){
|
||
$client_state="已确认";
|
||
}else{
|
||
$c1=get_db_msg("select count(*) 'num' from ".$table_pre."client_brand where cid='".$id."' and is_jd='y'");
|
||
$c2=get_db_msg("select count(*) 'num' from ".$table_pre."client_brand where cid='".$id."'");
|
||
if($c1["num"]==$c2["num"])
|
||
$client_state="已交单";
|
||
else
|
||
$client_state="未交单";
|
||
}
|
||
}else{
|
||
$c1=get_db_msg("select count(*) 'num' from ".$table_pre."client_brand where cid='".$id."' and is_checked='y'");
|
||
$c2=get_db_msg("select count(*) 'num' from ".$table_pre."client_brand where cid='".$id."'");
|
||
if($c1["num"]==$c2["num"])
|
||
$client_state="已确认";
|
||
else
|
||
$client_state="未确认";
|
||
}
|
||
return $client_state;
|
||
}
|
||
//翻译词汇
|
||
function d_translate($k){
|
||
global $arr_sys_lang;
|
||
foreach($arr_sys_lang as $k1 => $v1){
|
||
if($k==$k1)
|
||
return $v1;
|
||
}
|
||
return $k;
|
||
}
|
||
//行为分析时间段显示格式化
|
||
function deel_date_format($con,$d){
|
||
$r1=$r2="";
|
||
$d=trim($d);
|
||
if($con=="hour"){
|
||
$r1=substr($d,8,2)."日";
|
||
$r2=substr($d,11,2)."点";
|
||
}else if($con=="minute"){
|
||
$r1=substr($d,8,2)."日";
|
||
$r2=substr($d,11,2)."点".substr($d,14,1)."0分";
|
||
}else if($con=="half_day"){
|
||
$r1=substr($d,8,2)."日";
|
||
if(substr($d,12,1)=="1")
|
||
$r2="上午";
|
||
else if(substr($d,12,1)=="2")
|
||
$r2="下午";
|
||
else
|
||
$r2="晚上";
|
||
}else{
|
||
$r1=substr($d,8,2)."日";
|
||
}
|
||
return $r1.$r2;
|
||
}
|
||
//检查表是否存在
|
||
function check_table_exist($t){
|
||
global $db,$table_pre,$dbname;
|
||
$check=get_db_msg("select count(*) 'num' from information_schema.TABLES where TABLE_SCHEMA='".$dbname."' and TABLE_NAME='".$t."'");
|
||
if($check["num"]>0)
|
||
return "y";
|
||
else
|
||
return "n";
|
||
}
|
||
//更新规格名称
|
||
function insert_gg($gg){
|
||
global $db,$table_pre;
|
||
if(trim($gg)){
|
||
$c=get_db_msg("select id from ".$table_pre."kh_gg_title where title='".$gg."'");
|
||
if($c["id"]>0){
|
||
//已经有数据
|
||
}else{
|
||
$db->query("insert ".$table_pre."kh_gg_title (title) values ('".$gg."')");
|
||
}
|
||
}
|
||
}
|
||
//取得规格名称
|
||
function get_gg_title($gg){
|
||
global $db,$table_pre;
|
||
$gg_title="";
|
||
if(trim($gg)){
|
||
$c=get_db_msg("select title from ".$table_pre."kh_gg_title where id='".$gg."'");
|
||
$gg_title=$c["title"];
|
||
}
|
||
return $gg_title;
|
||
}
|
||
//取得规格编号
|
||
function get_gg_id($gg){
|
||
global $db,$table_pre;
|
||
$ggid="";
|
||
if(trim($gg)){
|
||
$c=get_db_msg("select id from ".$table_pre."kh_gg_title where title='".$gg."'");
|
||
$ggid=$c["id"];
|
||
}
|
||
return $ggid;
|
||
}
|
||
//检查是否是规格款
|
||
function is_ggk($khid){
|
||
global $db,$table_pre,$is_gg;
|
||
$r="n";
|
||
if($is_gg!="n"){
|
||
if(check_table_exist($table_pre."kh_gg")=="y"){
|
||
$check_gg=get_db_msg("select count(*) 'num' from ".$table_pre."kh_gg where iid='".$khid."'");
|
||
if($check_gg["num"]>0){
|
||
$r=$is_gg;
|
||
}
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//检查是否是规格款色
|
||
function is_gg_ks($khid,$color){
|
||
global $db,$table_pre,$is_gg;
|
||
$r="n";
|
||
if($is_gg!="n"){
|
||
if(check_table_exist($table_pre."kh_gg")=="y"){
|
||
$check_gg=get_db_msg("select count(*) 'num' from ".$table_pre."kh_gg where iid='".$khid."' and color='".$color."'");
|
||
if($check_gg["num"]>0){
|
||
$r=$is_gg;
|
||
}
|
||
}
|
||
}
|
||
return $r;
|
||
}
|
||
//检查区经是否有cid下的所有店铺权限
|
||
function check_qj_priv_all($cid){
|
||
global $db,$table_pre,$arr_upath;
|
||
$m1=get_db_msg("select id,path from ".$table_pre."client where id='".$cid."'");
|
||
$this_p=$m1["path"]."-".$cid;
|
||
$num1=0;
|
||
for($i=0;$i<count($arr_upath);$i++){
|
||
if(@ereg($this_p."-",$arr_upath[$i]))
|
||
$num1++;
|
||
}
|
||
$m2=get_db_msg("select count(*) 'num' from ".$table_pre."client where path='".$this_p."' or path like '".$this_p."-%'");
|
||
$r="n";
|
||
if($m2["num"]==$num1)
|
||
$r="y";
|
||
return $r;
|
||
}
|
||
//取得区经所属权限sql语句
|
||
function get_qj_ucon_all($charge_path_real){
|
||
$r="";
|
||
$arr_upath=explode(",",$charge_path_real);
|
||
for($i=0;$i<count($arr_upath);$i++){
|
||
$r.="upath='".$arr_upath[$i]."' or upath like '".$arr_upath[$i]."-%' or ";
|
||
}
|
||
if($r){
|
||
$r=" and (".substr($r,0,-4).")";
|
||
}else{
|
||
$r=" and uid=0";
|
||
}
|
||
return $r;
|
||
}
|
||
//取得区经所属店铺id的sql语句
|
||
function get_qj_ucon_all_dpid($charge_uid,$pre,$zd_name=''){
|
||
$zd_name=$zd_name?$zd_name:"uid";
|
||
$r="";
|
||
$arr_tmp=explode(",",$charge_uid);
|
||
for($i=0;$i<count($arr_tmp);$i++){
|
||
$r.=$pre.$zd_name."='".$arr_tmp[$i]."' or ";
|
||
}
|
||
if($r){
|
||
$r=" and (".substr($r,0,-3).")";
|
||
}else{
|
||
$r=" and ".$zd_name."=0";
|
||
}
|
||
return $r;
|
||
}
|
||
//
|
||
function get_theme_path(){
|
||
global $db,$table_pre;
|
||
return "theme/".get_set("sys_theme");
|
||
}
|
||
//取得自定义下拉按钮的字串
|
||
function get_str_menu_other(){
|
||
global $sys_menu_other;
|
||
$r="";
|
||
for($i=0;$i<count($sys_menu_other);$i++){
|
||
$r.=arr_to_str($sys_menu_other[$i])."|";
|
||
}
|
||
if($r)
|
||
$r=substr($r,0,-1);
|
||
return $r;
|
||
}
|
||
//输出插件的模板
|
||
function plugin_template(){
|
||
global $msg_logion;
|
||
if($msg_logion["face"]=="2")
|
||
include template("order_list_js_win");
|
||
else
|
||
include template("order_list_js");
|
||
exit;
|
||
}
|
||
//计算数组的离散程度
|
||
function get_pc($list){
|
||
if(count($list)>0){
|
||
$avg=array_sum($list)/count($list);
|
||
$total_var=0;
|
||
foreach ($list as $lv){
|
||
if(($lv-$avg)>0)
|
||
$total_var+=pow(($lv-$avg),2);
|
||
}
|
||
return sqrt($total_var/count($list));
|
||
}
|
||
} |