-
Notifications
You must be signed in to change notification settings - Fork 16
/
configOperator.php
242 lines (183 loc) · 5.96 KB
/
configOperator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
/**
* Created by PhpStorm.
* User: abcdlzy
* Date: 15/2/3
* Time: 下午12:09
*/
include_once(dirname(__FILE__).'/config.php');
$_configFile="./config.php";
function getConfig_PerPageCount(){
return get_config($GLOBALS['_configFile'],'perPageCount','int');
}
function setConfig_PerPageCount($value){
update_config($GLOBALS['_configFile'],'perPageCount',$value,'int');
}
function getConfig_LoginPassword(){
return get_config($GLOBALS['_configFile'],'loginPassWord');
}
function setConfig_LoginPassword($value){
update_config($GLOBALS['_configFile'],'loginPassWord',$value);
}
function setConfig_CAPrivateKey($value){
update_config($GLOBALS['_configFile'],'CAPrivKeyStr',$value);
}
function getConfig_CAPrivateKey(){
return get_config($GLOBALS['_configFile'],'CAPrivKeyStr');
}
function getConfig_CAPublishPEM(){
return getConfigCAPublishX509();
}
function getConfig_CAPublishX509(){
return get_config($GLOBALS['_configFile'],'CAPubX509');
}
function setConfig_CAPublishPEM($value){
setConfig_CAPublishX509($value);
}
function setConfig_CAPublishX509($value){
update_config($GLOBALS['_configFile'],'CAPubX509',$value);
}
function getConfig_PublicX509FromCA(){
return get_config($GLOBALS['_configFile'],'PubX509fromCA');
}
function setConfig_PublicX509FromCA($value){
update_config($GLOBALS['_configFile'],'PubX509fromCA',$value);
}
function setConfig_IsCA($value){
update_config($GLOBALS['_configFile'],'isCA',$value);
}
function getConfig_IsCA(){
return get_config($GLOBALS['_configFile'],'isCA');
}
function getConfig_CAName(){
return get_config($GLOBALS['_configFile'],'CAname');
}
function setConfig_CAName($value){
update_config($GLOBALS['_configFile'],'CAname',$value);
}
function getConfig_RSALength(){
return get_config($GLOBALS['_configFile'],'RSALength','int');
}
function setConfig_RSALength($value){
update_config($GLOBALS['_configFile'],'RSALength',$value,'int');
}
function getConfig_CAIntertfaceURL(){
return get_config($GLOBALS['_configFile'],'CAIntertfaceURL');
}
function setConfig_CAIntertfaceURL($value){
update_config($GLOBALS['_configFile'],'CAIntertfaceURL',$value);
}
function getConfig_SelfIntertfaceURL(){
return get_config($GLOBALS['_configFile'],'selfInterfaceURL');
}
function setConfig_SelfIntertfaceURL($value){
update_config($GLOBALS['_configFile'],'selfInterfaceURL',$value);
}
function getConfig_SelfPrivateKey(){
return get_config($GLOBALS['_configFile'],'privateKey');
}
function setConfig_SelfPrivateKey($value){
update_config($GLOBALS['_configFile'],'privateKey',$value);
}
function getConfig_SelfPublicX509(){
return get_config($GLOBALS['_configFile'],'publicX509');
}
function setConfig_SelfPublicX509($value){
update_config($GLOBALS['_configFile'],'publicX509',$value);
}
function getConfig_DBRunAtStatus(){
return get_config($GLOBALS['_configFile'],'dbRunAt','int');
}
function setConfig_DBRunAtStatus($value){
update_config($GLOBALS['_configFile'],'dbRunAt',$value,'int');
}
function getConfig_FileSQL(){
return get_config($GLOBALS['_configFile'],'FileSQL');
}
function setConfig_FileSQL($value){
update_config($GLOBALS['_configFile'],'FileSQL',$value);
}
function setConfig_SelfGUID($value){
update_config($GLOBALS['_configFile'],'selfGUID',$value);
}
function getConfig_SelfGUID(){
return get_config($GLOBALS['_configFile'],'selfGUID');
}
function setConfig_CAGUID($value){
update_config($GLOBALS['_configFile'],'CAGUID',$value);
}
function getConfig_CAGUID(){
return get_config($GLOBALS['_configFile'],'CAGUID');
}
function setConfig_TempAESKey($value){
update_config($GLOBALS['_configFile'],'tempAESKey',$value);
}
function getConfig_TempAESKey(){
return get_config($GLOBALS['_configFile'],'tempAESKey');
}
function setConfig_TempAESiv($value){
update_config($GLOBALS['_configFile'],'tempAESiv',$value);
}
function getConfig_TempAESiv(){
return get_config($GLOBALS['_configFile'],'tempAESiv');
}
function getConfig_SQLiteFile(){
return get_config($GLOBALS['_configFile'],'sqliteFile');
}
function setConfig_SQLiteFile($value){
update_config($GLOBALS['_configFile'],'sqliteFile',$value);
}
function getConfig_MySQL_Host(){
return get_config($GLOBALS['_configFile'],'mysql_host');
}
function setConfig_MySQL_Host($value){
update_config($GLOBALS['_configFile'],'mysql_host',$value);
}
function getConfig_MySQL_UserName(){
return get_config($GLOBALS['_configFile'],'mysql_username');
}
function setConfig_MySQL_UserName($value){
update_config($GLOBALS['_configFile'],'mysql_username',$value);
}
function getConfig_MySQL_Password(){
return get_config($GLOBALS['_configFile'],'mysql_password');
}
function setConfig_MySQL_Password($value){
update_config($GLOBALS['_configFile'],'mysql_password',$value);
}
function getConfig_MySQL_DataBase(){
return get_config($GLOBALS['_configFile'],'mysql_database');
}
function setConfig_MySQL_DataBase($value){
update_config($GLOBALS['_configFile'],'mysql_database',$value);
}
function get_config($file, $ini, $type="string"){
if(!file_exists($file)) return false;
$str = file_get_contents($file);
if ($type=="int"){
$config = preg_match("/".preg_quote($ini)."=(.*);/", $str, $res);
return $res[1];
}
else{
$config = preg_match("/".preg_quote($ini)."=\"(.*)\";/", $str, $res);
if($res[1]==null){
$config = preg_match("/".preg_quote($ini)."='(.*)';/", $str, $res);
}
return $res[1];
}
}
function update_config($file, $ini, $value,$type="string"){
if(!file_exists($file)) return false;
$str = file_get_contents($file);
$str2="";
$value=str_replace("\n","",$value);
$value=str_replace("\r","",$value);
if($type=="int"){
$str2 = preg_replace("/".preg_quote($ini)."=(.*);/", $ini."=".$value.";",$str);
}
else{
$str2 = preg_replace("/".preg_quote($ini)."=(.*);/",$ini."=\"".$value."\";",$str);
}
file_put_contents($file, $str2);
}
?>