chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
This commit is contained in:
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
//-------------------------------插件管理
|
||||
header("Content-type: text/html; charset=utf-8");
|
||||
if(THIS_IN!="edt_admin")
|
||||
exit("错误的访问!");
|
||||
$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
|
||||
//---------priv
|
||||
$priv=return_priv($_m,$msg_login_user["priv"]);
|
||||
$att_dir=dir_cutb(THIS_FILE_ROOT,1);
|
||||
$arr_select_other=array("s_spk"=>"是否饰品款","s_ka"=>"是否删除款");
|
||||
$json_data="{";
|
||||
if($priv[0]=="n"){
|
||||
//没有操作权限
|
||||
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
|
||||
}else{
|
||||
switch($_a){
|
||||
case "pick":
|
||||
$return_var=$return_var?$return_var:"file_name";
|
||||
//取得插件
|
||||
$plugin_root=$att_dir."/plugin/".$s_cate;
|
||||
$olddir="../plugin/".$s_cate;
|
||||
$d=dir($olddir);
|
||||
$arr_file=array();
|
||||
$i=0;
|
||||
while($a=$d->read()){
|
||||
if(is_file($olddir.'/'.$a) && ($a!='.') && ($a!='..')){
|
||||
$ext=get_file_ext($a);
|
||||
if($ext=="php"){
|
||||
$tmp=read_file($plugin_root."/".$a);
|
||||
//读取插件名称
|
||||
$title=read_plugin_title($tmp);
|
||||
//读取插件参数设置
|
||||
$str_param=read_plugin_param($tmp);
|
||||
$arr_file[$i][0]=str_replace(".php","",$a);
|
||||
$arr_file[$i][1]=$title;
|
||||
$arr_file[$i][2]=$str_param;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
//
|
||||
for($i=0;$i<count($arr_file);$i++){
|
||||
if($arr_file[$i])
|
||||
$content.="{\"no\":\"".$arr_file[$i][0]."\",\"title\":\"".$arr_file[$i][1]."\",\"param\":\"".$arr_file[$i][2]."\"},";
|
||||
}
|
||||
$json_data.="\"color\":[".substr($content,0,-1)."],";
|
||||
break;
|
||||
case "add" :
|
||||
if($id){
|
||||
$msg=get_db_msg("select * from ".$table_pre."plugin where id='".$id."'");
|
||||
$file_name=$msg["file_name"];
|
||||
$s_face=$msg["face"];
|
||||
if(!$s_face) $s_face=99;
|
||||
}else{
|
||||
$file_name="";
|
||||
$s_face=4;
|
||||
}
|
||||
if($s_cate=="client_bb"){
|
||||
//取得选项
|
||||
$arr_client_face1=array("1"=>"总经理","2"=>"区域经理","3"=>"代理商","4"=>"店铺","10"=>"推演师");
|
||||
$op="";
|
||||
foreach($arr_client_face1 as $k1 => $v1){
|
||||
$op.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\"},";
|
||||
}
|
||||
}
|
||||
//取得keyword选项
|
||||
$str1="";
|
||||
$str_select1="";
|
||||
$q="select no,title from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
|
||||
$r=$db->query($q);
|
||||
while($m=$db->fetch_array($r)){
|
||||
$str1.="{\"no\":\"".$m["no"]."\",\"title\":\"".$m["title"]."\"},";
|
||||
}
|
||||
$str_select1=$str1;
|
||||
$json_data.="\"select_dz\":[".substr($op,0,-1)."],\"file_name\":\"".$file_name."\",\"title\":\"".$msg["title"]."\",\"param\":\"".$msg["param"]."\",\"face\":\"".$s_face."\",";
|
||||
$json_data.="\"arr_keyword\":[".substr($str1,0,-1)."],";
|
||||
|
||||
//搜索选项
|
||||
foreach($arr_select_other as $key => $val){
|
||||
$str_select1.="{\"no\":\"".$key."\",\"title\":\"".$val."\"},";
|
||||
}
|
||||
$json_data.="\"arr_select_zd\":[".substr($str_select1,0,-1)."],";
|
||||
|
||||
//读取可用图标
|
||||
$pathdir="../ipad/images";
|
||||
$d=dir($pathdir);
|
||||
$i=1;
|
||||
$str1="";
|
||||
while($a=$d->read()){
|
||||
if(is_file($pathdir.'/'.$a) && ($a!='.') && ($a!='..') && substr($a,0,10)=="menu_icon_"){
|
||||
$icon=str_replace(".png","",$a);
|
||||
$str1.="{\"icon\":\"".$icon."\"},";
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
$json_data.="\"arr_icon\":[".substr($str1,0,-1)."],";
|
||||
//取得color_zd
|
||||
$str1="";
|
||||
foreach($sys_color_zd as $k1 => $v1){
|
||||
$str1.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\"},";
|
||||
}
|
||||
$json_data.="\"arr_color_zd\":[".substr($str1,0,-1)."],";
|
||||
break;
|
||||
case "save_add" :
|
||||
//把名称选项转成no
|
||||
function title_2_no($arr,$title){
|
||||
$r=$title;
|
||||
foreach($arr as $no1 => $title1){
|
||||
if($title1==$title)
|
||||
$r=$no1;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
$c=get_db_msg("select count(*) 'num' from ".$table_pre."plugin where (title='".$title."' and face='".$face."') and id<>'".$id."' and cate='".$s_cate."'");
|
||||
if($c["num"]>0){
|
||||
$json_data.="\"code\":\"0\",\"msg\":\"该名称已经存在!\",";
|
||||
}else{
|
||||
$errmsg="";
|
||||
if($file_name=="report_zdy_3w"){
|
||||
$tmpname="tbname|".$param_tbname."|额外数据表名";
|
||||
$tmpt=get_db_msg("select count(*) 'num' from ".$table_pre."plugin where id<>'".$id."' and cate='".$s_cate."' and param like '%".$tmpname."%'");
|
||||
if($tmpt["num"]>0){
|
||||
$errmsg="该额外数据库表名已被使用!";
|
||||
}
|
||||
|
||||
if(!$param_keyword_zd1){
|
||||
$errmsg="至少需要设置一个keyword字段!";
|
||||
}
|
||||
if(!$param_dr_zd1){
|
||||
$errmsg="至少需要设置一个导入字段!";
|
||||
}
|
||||
if($param_keyword_zd1 && !$param_keyword_zd2 && $param_keyword_zd3){
|
||||
$errmsg="keyword字段请按顺序填入!";
|
||||
}
|
||||
$flag1=$flag2=0;
|
||||
for($i=1;$i<=8;$i++){
|
||||
$tmpv="param_dr_zd".$i;
|
||||
if($$tmpv && $flag1>0){
|
||||
$errmsg="导入字段请按顺序填入!";
|
||||
}
|
||||
if(!$$tmpv){
|
||||
$flag1++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($errmsg){
|
||||
$json_data.="\"code\":\"0\",\"msg\":\"".$errmsg."\",";
|
||||
}else{
|
||||
if($file_name=="report_zdy_3w"){
|
||||
$tname=$table_pre."plugin_zdy_".$param_tbname;
|
||||
$sql_create_table="CREATE TABLE ".$tname." (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`uid` int(10) unsigned NOT NULL default '0',
|
||||
`upath` varchar(255) NOT NULL default '',";
|
||||
for($i=1;$i<=3;$i++){
|
||||
$tmpv="param_keyword_zd".$i;
|
||||
if($$tmpv){
|
||||
$sql_create_table.="`zd".$i."` varchar(255) NOT NULL default '',";
|
||||
}
|
||||
}
|
||||
for($i=1;$i<=8;$i++){
|
||||
$tmpv="param_dr_zd".$i;
|
||||
$tmp_arr=explode("_",$$tmpv);
|
||||
if($tmp_arr[1]=="文本"){
|
||||
$sql_create_table.="`dr_zd".$i."` varchar(255) NOT NULL default '',";
|
||||
}
|
||||
if($tmp_arr[1]=="数字"){
|
||||
$sql_create_table.="`dr_zd".$i."` decimal(10,2) NOT NULL DEFAULT '0.00',";
|
||||
}
|
||||
if($tmp_arr[1]=="百分比"){
|
||||
$sql_create_table.="`dr_zd".$i."` decimal(10,4) NOT NULL DEFAULT '0.0000',";
|
||||
}
|
||||
}
|
||||
|
||||
$sql_create_table.="PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
|
||||
if($is_sc=="on"){
|
||||
//初始化
|
||||
$db->query("DROP TABLE IF EXISTS `".$tname."`;");
|
||||
}
|
||||
if(check_table_exist($tname)!="y"){
|
||||
$db->query($sql_create_table);
|
||||
}
|
||||
}
|
||||
//取得选项
|
||||
$arr_select1=array();
|
||||
$q="select no,title from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord";
|
||||
$r=$db->query($q);
|
||||
while($m=$db->fetch_array($r)){
|
||||
$arr_select1[$m["no"]]=$m["title"];
|
||||
}
|
||||
foreach($arr_select_other as $key=>$val){
|
||||
$arr_select1[$key]=$val;
|
||||
}
|
||||
//取得参数
|
||||
$str_param="";
|
||||
if($param_k){
|
||||
$arr_param_k=explode(",",$param_k);
|
||||
for($i=0;$i<count($arr_param_k);$i++){
|
||||
$var="param_".$arr_param_k[$i];
|
||||
$var1="param_tip_".$arr_param_k[$i];
|
||||
$str_param.=$arr_param_k[$i]."|".title_2_no($arr_select1,$$var)."|".$$var1.",";
|
||||
}
|
||||
if($str_param)
|
||||
$str_param=substr($str_param,0,-1);
|
||||
}
|
||||
if($id){
|
||||
$msg=get_db_msg("select * from ".$table_pre."plugin where id='".$id."'");
|
||||
if($s_cate=="client_bb"){
|
||||
$query="update ".$table_pre."plugin set title='".$title."',face='".$face."',file_name='".$file_name."',param='".$str_param."' where id='".$id."'";
|
||||
$db->query($query);
|
||||
$json_data.="\"code\":\"1\",";
|
||||
}else{
|
||||
$query="update ".$table_pre."plugin set title='".$title."',file_name='".$file_name."',param='".$str_param."' where id='".$id."'";
|
||||
$db->query($query);
|
||||
$log_action="修改";
|
||||
$json_data.="\"code\":\"1\",";
|
||||
}
|
||||
}else{
|
||||
$query="insert ".$table_pre."plugin (face,file_name,title,cate,param) values ('".$face."','".$file_name."','".$title."','".$s_cate."','".$str_param."')";
|
||||
$db->query($query);
|
||||
$iid=$db->insert_id();
|
||||
$log_action="新增";
|
||||
$json_data.="\"code\":\"1\",";
|
||||
}
|
||||
}
|
||||
}
|
||||
$lid=$id?$id:$iid;
|
||||
set_log($log_action."插件",$title."|".$lid);
|
||||
break;
|
||||
case "del" :
|
||||
$num=count($id);
|
||||
if($num==0)
|
||||
$json_data.="\"code\":\"0\",";
|
||||
for($i=0;$i<$num;$i++){
|
||||
$tmp=get_db_msg("select * from ".$table_pre."plugin where id='".$id[$i]."'");
|
||||
$lid.=$tmp["title"]."|".$id[$i].", ";
|
||||
$db->query("delete from ".$table_pre."plugin where id='".$id[$i]."'");
|
||||
$json_data.="\"code\":\"1\",";
|
||||
}
|
||||
$lid=substr($lid,0,-2);
|
||||
set_log("删除插件",$lid);
|
||||
break;
|
||||
default :
|
||||
//取得默认s_cate
|
||||
$arr_client_face1=array("1"=>"总经理","2"=>"区域经理","3"=>"代理商","4"=>"店铺","10"=>"推演师"," "=>"所有人");
|
||||
$s_cate=$s_cate?$s_cate:"client_bb";
|
||||
$json_data.="\"s_cate\":\"".$s_cate."\",";
|
||||
$admin_plugin_root=$att_dir."/admin/debug";
|
||||
$sql_con="where cate='".$s_cate."'";
|
||||
$tmp=get_db_msg("select count(*) 'total' from ".$table_pre."plugin ".$sql_con);
|
||||
$total_num=$tmp["total"];
|
||||
//-----------------------tab
|
||||
$str_tab="";
|
||||
$str_tab.="{\"no\":\"client_bb\",\"title\":\"客户端\"},{\"no\":\"admin_bb\",\"title\":\"后台\"},";
|
||||
$str_tab=deel_end($str_tab);
|
||||
$json_data.="\"tab\":[".$str_tab."],";
|
||||
//-----------------------/tab
|
||||
//
|
||||
$query="select * from ".$table_pre."plugin ".$sql_con." order by id";
|
||||
//echo $query."<br>";
|
||||
$res=$db->query($query);
|
||||
$count=0;
|
||||
$json_data.="\"code\":0,\"msg\":\"\",\"count\":".$total_num.",\"data\":[";
|
||||
$str_dx=$str_tmp="";
|
||||
while($msg=$db->fetch_array($res)){
|
||||
if($s_cate=="client_bb"){
|
||||
if($msg["face"])
|
||||
$str_dx=get_main_value($arr_client_face1,$msg["face"]);
|
||||
else
|
||||
$str_dx="所有人";
|
||||
}
|
||||
//是否有数据管理模块
|
||||
$this_file_root=$admin_plugin_root."/plugin_".$msg["file_name"].".php";
|
||||
$is_admin_file="";
|
||||
if(is_file($this_file_root)){
|
||||
$is_admin_file=$msg["file_name"];
|
||||
}
|
||||
$is_zdy="n";
|
||||
if($msg["file_name"]=="report_zdy_3w"){
|
||||
$is_zdy="y";
|
||||
}
|
||||
$str_tmp.="{";
|
||||
$str_tmp.="\"id\":\"".$msg["id"]."\",";
|
||||
$str_tmp.="\"admin_file\":\"".$is_admin_file."\",";
|
||||
$str_tmp.="\"face\":\"".$str_dx."\",";
|
||||
$str_tmp.="\"is_zdy\":\"".$is_zdy."\",";
|
||||
$str_tmp.="\"title\":\"".$msg["title"]."\"";
|
||||
$str_tmp.="},";
|
||||
$count++;
|
||||
}
|
||||
$json_data.=substr($str_tmp,0,-1)."],";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$json_data=substr($json_data,0,-1)."}";
|
||||
echo $json_data;
|
||||
?>
|
||||
Reference in New Issue
Block a user