better-staridc-MNBT
1<?php
2
3function formcl($cxform,$yhform){ //用户填写的表单处理
4 $arr=[];
5 if (!is_array($yhform)) $yhform = [];
6 foreach (json_decode($cxform,true) ?: [] as $va=>$val){
7 $userfmdata=(isset($yhform[$va]) && is_array($yhform[$va])) ? ($yhform[$va][$val['cz']] ?? null) : null; //获取用户提交的数据
8 if($val['bt']=='是' && $userfmdata==null)return ["code"=>0,"msg"=>"错误,表单未填写完整"];
9 if($val['srlx']=='数字' && !is_numeric($userfmdata))return ["code"=>0,"msg"=>"错误,表单未按照要求填写!"];
10 if(is_numeric($val['cdxz']) && mb_strlen($userfmdata)>$val['cdxz'])return ["code"=>0,"msg"=>"错误,表单内容长度已超过预设值".$val['cdxz']."个字符!"];
11 $arr[$val['blx']]=$userfmdata;
12 }
13 return $arr;
14}
15
16function tihs($data,$arr=false,$yhc){ //替换数据
17 //以下为替换系统提供的操作选项
18 $data=str_ireplace('[cn_host]','localhost',$data);
19 $data=str_ireplace('[cn_port]','3306',$data);
20 $data=str_ireplace('[cn_user]',$yhc['sqluser'],$data);
21 $data=str_ireplace('[cn_pass]',$yhc['sqlpass'],$data);
22 $data=str_ireplace('[cn_name]',$yhc['sqluser'],$data);
23 $data=str_ireplace('[cn_date]',date("Y-m-d H:i:s"),$data);
24 if($arr){
25 foreach ($arr as $name=>$val){ //以下为替换为表单数据
26 $data=str_ireplace('[sf_'.$name.']',$val,$data);
27 }
28 }
29 return $data;
30}
31
32
33function xjwj($val,$yhc,$os_xt,$userbd){ //新建文件
34 $mly=$val['ml'];
35 if($val['ml']!='/'){
36 $ml = substr($mly, 0, 1 );
37 $mlh = substr($mly, -1);
38 if($ml!='/'){$mly='/'.$mly;}
39 if($mlh!='/'){$mly=$mly.'/';}
40 }
41 $sc=$os_xt.$yhc['sqldz'].$mly.$val['name'];
42 return($sc);
43}
44
45function xjwjj($val,$yhc,$os_xt,$userbd){ //新建文件夹
46 $mly=$val['ml'];
47 if($val['ml']!='/'){
48 $ml = substr($mly, 0, 1 );
49 $mlh = substr($mly, -1);
50 if($ml!='/'){$mly='/'.$mly;}
51 if($mlh!='/'){$mly=$mly.'/';}
52 }
53 $sc=$os_xt.$yhc['sqldz'].$mly.$val['name'];
54 return($sc);
55}
56
57function delwj($val,$yhc,$os_xt,$userbd){ //删除文件
58 $mly=$val['ml'];
59 if($val['ml']!='/'){
60 $ml = substr($mly, 0, 1 );
61 $mlh = substr($mly, -1);
62 if($ml!='/'){$mly='/'.$mly;}
63 if($mlh!='/'){$mly=$mly.'/';}
64 }
65 $sc=$os_xt.$yhc['sqldz'].$mly.$val['name'];
66 return($sc);
67}
68
69function delwjj($val,$yhc,$os_xt,$userbd){ //删除文件夹
70 $mly=$val['ml'];
71 if($val['ml']!='/'){
72 $ml = substr($mly, 0, 1 );
73 $mlh = substr($mly, -1);
74 if($ml!='/'){$mly='/'.$mly;}
75 if($mlh!='/'){$mly=$mly.'/';}
76 }
77 $sc=$os_xt.$yhc['sqldz'].$mly.$val['name'];
78 return($sc);
79}
80
81function setwj($val,$yhc,$os_xt,$userbd){ //修改文件内容
82 $mly=$val['ml'];
83 if($val['ml']!='/'){
84 $ml = substr($mly, 0, 1 );
85 $mlh = substr($mly, -1);
86 if($ml!='/'){$mly='/'.$mly;}
87 if($mlh!='/'){$mly=$mly.'/';}
88 }
89 $nr = file_get_contents($val['nr']);
90 $nr=tihs($nr,$userbd,$yhc);
91 $sc=array($nr,$os_xt.$yhc['sqldz'].$mly.$val['name']);
92 return($sc);
93}
94
95function drsql($val,$yhc,$os_xt,$userbd){ //导入数据库
96 $mly=$val['ml'];
97 if($val['ml']!='/'){
98 $ml = substr($mly, 0, 1 );
99 $mlh = substr($mly, -1);
100 if($ml!='/'){$mly='/'.$mly;}
101 if($mlh!='/'){$mly=$mly.'/';}
102 }
103 $sc=array($os_xt.$yhc['sqldz'].$mly.$val['name'],$yhc['sqluser']);
104 return($sc);
105}
106
107function gettj($val,$yhc,$os_xt,$userbd){ //GET提交
108 $nr = $val['get'];
109 $nr=tihs($nr,$userbd,$yhc);
110 $sc=file_get_contents('http://'.$val['url'].'?'.$nr);
111 return($sc);
112}
113
114function cxname($val,$yhc,$os_xt,$userbd){ //文件重命名
115 $mly=$val['lj'];
116 if($val['lj']!='/'){
117 $ml = substr($mly, 0, 1 );
118 $mlh = substr($mly, -1);
119 if($ml!='/'){$mly='/'.$mly;}
120 if($mlh!='/'){$mly=$mly.'/';}
121 }
122 $sc=array($os_xt.$yhc['sqldz'],$mly,$val['jne'],$val['xne']);
123 return($sc);
124}
125
126function setyxml($val,$yhc,$os_xt,$userbd){ //设置运行目录
127 $mly=$val['lj'];
128 if($val['lj']!='/'){
129 $ml = substr($mly, 0, 1 );
130 if($ml!='/'){$mly='/'.$mly;}
131 }
132 $sc=array($yhc['btid'],$mly,$os_xt.$yhc['sqldz']);
133 return($sc);
134}
135
136function setwjt($val,$yhc,$os_xt,$userbd){ //设置伪静态
137 $mly=$val['lj'];
138 if($val['lj']!='/'){
139 $ml = substr($mly, 0, 1 );
140 $mlh = substr($mly, -1);
141 if($ml!='/'){$mly='/'.$mly;}
142 if($mlh!='/'){$mly=$mly.'/';}
143 }
144 $nr = file_get_contents($val['nr']);
145 $nr=tihs($nr,$userbd,$yhc);
146 $sc=array($nr,'/www/server/panel/vhost/rewrite/'.$yhc['sqldz'].'.conf');
147 return($sc);
148}
149
150function setphp($val,$yhc,$os_xt,$userbd){ //设置PHP版本
151 $php=tihs($val['php'],$userbd,$yhc);
152 $php=preg_replace('/[^0-9]/','',$php);
153 if($php==='')return array('','');
154 $sc=array($yhc['sqldz'],$php);
155 return($sc);
156}
157?>