Subversion Repositories php-qbpwcf

Rev

Rev 106 | Rev 222 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 106 Rev 182
Line 61... Line 61...
61
include("allInOneForJson.php");
61
include("allInOneForJson.php");
62
 
62
 
63
#建議的log位置
63
#建議的log位置
64
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
64
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
65
 
65
 
66
/*
-
 
67
 
-
 
68
# test case - 1 - start
66
#預設的範例資料參數
69
 
-
 
70
$params=array();
67
$params=array();
71
$params["dbSecret"]="";
68
$params["dbSecret"]=$dbSecret;
72
$params["dbAddr"]="localhost";
69
$params["dbAddr"]=$dbAddress;
73
$params["dbPort"]="3306";
70
$params["dbPort"]=$dbPort;
74
$params["dbName"]="test";
71
$params["dbName"]=$dbName;
75
$params["dbUser"]="test";
72
$params["dbUser"]=$dbAccount;
76
$params["dbPass"]="test";
73
$params["dbPass"]=$dbPassword;
77
$params["dtName"]="member";
74
$params["dtName"]="namespace";
78
$params["cols"]=array("*");
75
$params["cols"]=array("*");
79
#$params["WhereColumnName"];
76
#$params["WhereColumnName"];
80
#$params["WhereColumnValue"];
77
#$params["WhereColumnValue"];
81
#$params["WhereColumnOperator"];
78
#$params["WhereColumnOperator"];
82
#$params["orderItem"];
79
#$params["orderItem"];
83
#$params["ascORdesc"];
80
#$params["ascORdesc"];
84
#$params["numLimit"];
81
#$params["numLimit"];
85
#$params["numberStart"];
82
#$params["numberStart"];
86
 
83
 
87
#設置參數
84
#加密參數
-
 
85
#函式說明:
-
 
86
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
87
#回傳結果:
-
 
88
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
89
#$result["function"],當前執行的函數名稱.
-
 
90
#$result["content"],加密後的結果.
-
 
91
#$result["error"],錯誤訊息陣列.
-
 
92
#$result["argu"],使用的參數.
-
 
93
#必填參數:
-
 
94
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
95
$conf["enCodeStr"]=$params;
88
$_POST["params"]=base64_encode(urlencode(json_encode($params)));
96
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
-
 
97
$conf["enCodeType"]="qbpwcf";
-
 
98
#可省略參數:
-
 
99
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
100
#$conf["sha1Raw"]="false";
-
 
101
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
102
#$conf["p_hash"]="";
-
 
103
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
104
#$conf["keyForAes256"]="";
-
 
105
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
106
#$conf["aes256Encode"]="";
-
 
107
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
108
#$conf["qbpwcfDecode"]="false";
-
 
109
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
110
#$conf["gpgDecrypt"]="false";
-
 
111
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
112
#$conf["gpgId"]="";
-
 
113
#參考資料:
-
 
114
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
115
#md5=>http://php.net/manual/en/function.md5.php
-
 
116
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
117
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
118
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
119
#備註:
-
 
120
#無.
-
 
121
$enCodeStr=authenticate::enCodeStr($conf);
-
 
122
unset($conf);
89
 
123
 
-
 
124
#debug
90
# test case - 1 - end
125
#var_dump(__LINE__,$enCodeStr);
91
 
126
 
-
 
127
#如果執行異常
-
 
128
if($enCodeStr["status"]==="false"){
-
 
129
 
-
 
130
	#函式說明:
-
 
131
	#撰寫log
-
 
132
	#回傳結果:
-
 
133
	#$result["status"],狀態,"true"或"false".
-
 
134
	#$result["error"],錯誤訊息陣列.
-
 
135
	#$result["function"],當前函式的名稱.
-
 
136
	#$result["argu"],使用的參數.
-
 
137
	#必填參數:
-
 
138
	#$conf["path"],log檔案的路徑與名稱.
-
 
139
	$conf["path"]=$logFile;
-
 
140
	#$conf["content"],字串,要寫的內容.
-
 
141
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
142
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
143
	$conf["fileArgu"]=__FILE__;
-
 
144
	#可省略參數:
-
 
145
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
146
	#$conf["rewrite"]="false";
-
 
147
	#參考資料:
-
 
148
	#無.
-
 
149
	#備註:
-
 
150
	#無.	
-
 
151
	$record=logs::record($conf);
-
 
152
	unset($conf);
-
 
153
 
-
 
154
	#如果寫log 失敗
-
 
155
	if($record["status"]==="false"){
-
 
156
 
-
 
157
		#印出訊息
-
 
158
		echo json_encode($record);
-
 
159
		
-
 
160
		#異常結束執行
-
 
161
		exit(1);
-
 
162
 
-
 
163
		}#if end
-
 
164
		
-
 
165
	#異常結束執行
-
 
166
	exit(1);
-
 
167
 
-
 
168
	}#if end
-
 
169
 
-
 
170
#加密參數
-
 
171
#函式說明:
-
 
172
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
173
#回傳結果:
-
 
174
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
175
#$result["function"],當前執行的函數名稱.
-
 
176
#$result["content"],加密後的結果.
-
 
177
#$result["error"],錯誤訊息陣列.
-
 
178
#$result["argu"],使用的參數.
-
 
179
#必填參數:
-
 
180
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
181
$conf["enCodeStr"]=$enCodeStr["content"];
-
 
182
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
-
 
183
$conf["enCodeType"]="gpg";
-
 
184
#可省略參數:
-
 
185
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
186
#$conf["sha1Raw"]="false";
-
 
187
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
188
#$conf["p_hash"]="";
-
 
189
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
190
#$conf["keyForAes256"]="";
-
 
191
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
192
#$conf["aes256Encode"]="";
-
 
193
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
194
#$conf["qbpwcfDecode"]="false";
-
 
195
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
196
$conf["gpgDecrypt"]="false";
-
 
197
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
198
#$conf["gpgId"]="";
-
 
199
#參考資料:
-
 
200
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
201
#md5=>http://php.net/manual/en/function.md5.php
-
 
202
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
203
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
204
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
205
#備註:
-
 
206
#無.
-
 
207
$enCodeStr=authenticate::enCodeStr($conf);
-
 
208
unset($conf);
-
 
209
 
-
 
210
#debug
-
 
211
#var_dump(__LINE__,$enCodeStr);
-
 
212
 
-
 
213
#如果執行異常
-
 
214
if($enCodeStr["status"]==="false"){
-
 
215
 
-
 
216
	#函式說明:
-
 
217
	#撰寫log
-
 
218
	#回傳結果:
-
 
219
	#$result["status"],狀態,"true"或"false".
-
 
220
	#$result["error"],錯誤訊息陣列.
-
 
221
	#$result["function"],當前函式的名稱.
-
 
222
	#$result["argu"],使用的參數.
-
 
223
	#必填參數:
-
 
224
	#$conf["path"],log檔案的路徑與名稱.
-
 
225
	$conf["path"]=$logFile;
-
 
226
	#$conf["content"],字串,要寫的內容.
-
 
227
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
228
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
229
	$conf["fileArgu"]=__FILE__;
-
 
230
	#可省略參數:
-
 
231
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
232
	#$conf["rewrite"]="false";
-
 
233
	#參考資料:
-
 
234
	#無.
-
 
235
	#備註:
-
 
236
	#無.	
-
 
237
	$record=logs::record($conf);
-
 
238
	unset($conf);
-
 
239
 
-
 
240
	#如果寫log 失敗
-
 
241
	if($record["status"]==="false"){
-
 
242
 
-
 
243
		#印出訊息
-
 
244
		echo json_encode($record);
-
 
245
		
-
 
246
		#異常結束執行
-
 
247
		exit(1);
-
 
248
 
-
 
249
		}#if end
-
 
250
	
-
 
251
	#異常結束執行
-
 
252
	exit(1);
-
 
253
 
-
 
254
	}#if end
-
 
255
 
-
 
256
#編碼參數
-
 
257
#函式說明:
-
 
258
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
259
#回傳結果:
-
 
260
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
261
#$result["function"],當前執行的函數名稱.
-
 
262
#$result["content"],加密後的結果.
-
 
263
#$result["error"],錯誤訊息陣列.
-
 
264
#$result["argu"],使用的參數.
-
 
265
#必填參數:
-
 
266
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
267
$conf["enCodeStr"]=$enCodeStr["content"];
92
*/
268
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
-
 
269
$conf["enCodeType"]="bin2hex";
-
 
270
#可省略參數:
-
 
271
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
272
#$conf["sha1Raw"]="false";
-
 
273
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
274
#$conf["p_hash"]="";
-
 
275
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
276
#$conf["keyForAes256"]="";
-
 
277
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
278
#$conf["aes256Encode"]="";
-
 
279
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
280
#$conf["qbpwcfDecode"]="false";
-
 
281
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
282
#$conf["gpgDecrypt"]="false";
-
 
283
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
284
#$conf["gpgId"]="";
-
 
285
#參考資料:
-
 
286
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
287
#md5=>http://php.net/manual/en/function.md5.php
-
 
288
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
289
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
290
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
291
#備註:
-
 
292
#無.
-
 
293
$enCodeStr=authenticate::enCodeStr($conf);
-
 
294
unset($conf);
-
 
295
 
-
 
296
#debug
-
 
297
#var_dump(__LINE__,$enCodeStr);
-
 
298
 
-
 
299
#如果執行異常
-
 
300
if($enCodeStr["status"]==="false"){
-
 
301
 
-
 
302
	#函式說明:
-
 
303
	#撰寫log
-
 
304
	#回傳結果:
-
 
305
	#$result["status"],狀態,"true"或"false".
-
 
306
	#$result["error"],錯誤訊息陣列.
-
 
307
	#$result["function"],當前函式的名稱.
-
 
308
	#$result["argu"],使用的參數.
-
 
309
	#必填參數:
-
 
310
	#$conf["path"],log檔案的路徑與名稱.
-
 
311
	$conf["path"]=$logFile;
-
 
312
	#$conf["content"],字串,要寫的內容.
-
 
313
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
314
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
315
	$conf["fileArgu"]=__FILE__;
-
 
316
	#可省略參數:
-
 
317
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
318
	#$conf["rewrite"]="false";
-
 
319
	#參考資料:
-
 
320
	#無.
-
 
321
	#備註:
-
 
322
	#無.	
-
 
323
	$record=logs::record($conf);
-
 
324
	unset($conf);
-
 
325
 
-
 
326
	#如果寫log 失敗
-
 
327
	if($record["status"]==="false"){
-
 
328
 
-
 
329
		#印出訊息
-
 
330
		echo json_encode($record);
-
 
331
		
-
 
332
		#異常結束執行
-
 
333
		exit(1);
-
 
334
 
-
 
335
		}#if end
-
 
336
		
-
 
337
	#異常結束執行
-
 
338
	exit(1);
-
 
339
 
-
 
340
	}#if end
-
 
341
 
-
 
342
#更新POST的預設參數
-
 
343
$_POST["params"]=$enCodeStr["content"];
93
 
344
 
94
#涵式說明:
345
#涵式說明:
95
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
346
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
96
#回傳的結果:
347
#回傳的結果:
97
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
348
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 134... Line 385...
134
#備註:
385
#備註:
135
#表單變數的名稱若含有「.」,則會變成「-」。
386
#表單變數的名稱若含有「.」,則會變成「-」。
136
$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf);
387
$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf);
137
unset($conf);
388
unset($conf);
138
 
389
 
-
 
390
#如果執行異常
-
 
391
if($responseMultiInputDataSecurityEnhance["status"]==="false"){
-
 
392
 
-
 
393
	#函式說明:
-
 
394
	#撰寫log
-
 
395
	#回傳結果:
-
 
396
	#$result["status"],狀態,"true"或"false".
-
 
397
	#$result["error"],錯誤訊息陣列.
-
 
398
	#$result["function"],當前函式的名稱.
-
 
399
	#$result["argu"],使用的參數.
-
 
400
	#必填參數:
-
 
401
	#$conf["path"],log檔案的路徑與名稱.
-
 
402
	$conf["path"]=$logFile;
-
 
403
	#$conf["content"],字串,要寫的內容.
-
 
404
	$conf["content"]="Form data error, please see json:".json_encode($responseMultiInputDataSecurityEnhance).PHP_EOL;
-
 
405
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
406
	$conf["fileArgu"]=__FILE__;
-
 
407
	#可省略參數:
-
 
408
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
409
	#$conf["rewrite"]="false";
-
 
410
	#參考資料:
-
 
411
	#無.
-
 
412
	#備註:
-
 
413
	#無.	
-
 
414
	$record=logs::record($conf);
-
 
415
	unset($conf);
-
 
416
 
-
 
417
	#如果寫log 失敗
-
 
418
	if($record["status"]==="false"){
-
 
419
 
-
 
420
		#印出訊息
-
 
421
		echo json_encode($record);
-
 
422
		
-
 
423
		#異常結束執行
-
 
424
		exit(1);
-
 
425
 
-
 
426
		}#if end
-
 
427
		
-
 
428
	#異常結束執行
-
 
429
	exit(1);
-
 
430
	
-
 
431
	}#if end
-
 
432
 
139
#函式說明:
433
#函式說明:
140
#撰寫log
434
#撰寫log
141
#回傳結果:
435
#回傳結果:
142
#$result["status"],狀態,"true"或"false".
436
#$result["status"],狀態,"true"或"false".
143
#$result["error"],錯誤訊息陣列.
437
#$result["error"],錯誤訊息陣列.
Line 164... Line 458...
164
if($record["status"]==="false"){
458
if($record["status"]==="false"){
165
 
459
 
166
	#印出訊息
460
	#印出訊息
167
	echo json_encode($record);
461
	echo json_encode($record);
168
	
462
	
169
	#結束執行
463
	#異常結束執行
170
	exit;
464
	exit(1);
171
 
465
 
172
	}#if end
466
	}#if end
173
 
467
 
174
#如果執行失敗
468
#取得參數
175
if($responseMultiInputDataSecurityEnhance["status"]==="false"){
469
$params=$responseMultiInputDataSecurityEnhance["inputDataContent"]["params"];
176
 
470
 
-
 
471
#解碼參數
177
	#印出訊息
472
#函式說明:
-
 
473
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
474
#回傳結果:
-
 
475
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
476
#$result["function"],當前執行的函數名稱.
-
 
477
#$result["content"],加密後的結果.
-
 
478
#$result["error"],錯誤訊息陣列.
-
 
479
#$result["argu"],使用的參數.
-
 
480
#必填參數:
-
 
481
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
482
$conf["enCodeStr"]=$params;
178
	echo json_encode($responseMultiInputDataSecurityEnhance);
483
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
-
 
484
$conf["enCodeType"]="hex2bin";
-
 
485
#可省略參數:
-
 
486
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
487
#$conf["sha1Raw"]="false";
-
 
488
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
489
#$conf["p_hash"]="";
-
 
490
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
491
#$conf["keyForAes256"]="";
-
 
492
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
493
#$conf["aes256Encode"]="";
-
 
494
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
495
#$conf["qbpwcfDecode"]="false";
-
 
496
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
497
#$conf["gpgDecrypt"]="false";
-
 
498
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
499
#$conf["gpgId"]="";
-
 
500
#參考資料:
-
 
501
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
502
#md5=>http://php.net/manual/en/function.md5.php
-
 
503
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
504
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
505
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
506
#備註:
-
 
507
#無.
-
 
508
$enCodeStr=authenticate::enCodeStr($conf);
-
 
509
unset($conf);
179
 
510
 
-
 
511
#debug
-
 
512
#var_dump(__LINE__,$enCodeStr);
-
 
513
 
-
 
514
#如果執行異常
-
 
515
if($enCodeStr["status"]==="false"){
-
 
516
 
-
 
517
	#函式說明:
-
 
518
	#撰寫log
-
 
519
	#回傳結果:
-
 
520
	#$result["status"],狀態,"true"或"false".
-
 
521
	#$result["error"],錯誤訊息陣列.
-
 
522
	#$result["function"],當前函式的名稱.
-
 
523
	#$result["argu"],使用的參數.
-
 
524
	#必填參數:
-
 
525
	#$conf["path"],log檔案的路徑與名稱.
-
 
526
	$conf["path"]=$logFile;
-
 
527
	#$conf["content"],字串,要寫的內容.
-
 
528
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
529
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
530
	$conf["fileArgu"]=__FILE__;
-
 
531
	#可省略參數:
-
 
532
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
533
	#$conf["rewrite"]="false";
-
 
534
	#參考資料:
-
 
535
	#無.
-
 
536
	#備註:
-
 
537
	#無.	
-
 
538
	$record=logs::record($conf);
-
 
539
	unset($conf);
-
 
540
 
-
 
541
	#如果寫log 失敗
-
 
542
	if($record["status"]==="false"){
-
 
543
 
-
 
544
		#印出訊息
-
 
545
		echo json_encode($record);
-
 
546
		
180
	#結束執行
547
		#異常結束執行
181
	exit;
548
		exit(1);
182
 
549
 
-
 
550
		}#if end
-
 
551
		
-
 
552
	#異常結束執行
-
 
553
	exit(1);
-
 
554
	
183
	}#if end
555
	}#if end
184
 
556
 
-
 
557
#解密參數
-
 
558
#函式說明:
-
 
559
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
560
#回傳結果:
-
 
561
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
562
#$result["function"],當前執行的函數名稱.
-
 
563
#$result["content"],加密後的結果.
-
 
564
#$result["error"],錯誤訊息陣列.
-
 
565
#$result["argu"],使用的參數.
-
 
566
#必填參數:
-
 
567
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
568
$conf["enCodeStr"]=$enCodeStr["content"];
185
#如果邊數檢查不通過
569
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
-
 
570
$conf["enCodeType"]="gpg";
-
 
571
#可省略參數:
-
 
572
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
573
#$conf["sha1Raw"]="false";
-
 
574
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
575
#$conf["p_hash"]="";
-
 
576
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
577
#$conf["keyForAes256"]="";
-
 
578
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
579
#$conf["aes256Encode"]="";
-
 
580
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
581
#$conf["qbpwcfDecode"]="true";
-
 
582
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
583
$conf["gpgDecrypt"]="true";
-
 
584
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
585
#$conf["gpgId"]="";
-
 
586
#參考資料:
-
 
587
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
588
#md5=>http://php.net/manual/en/function.md5.php
186
if($responseMultiInputDataSecurityEnhance["passed"]==="false"){
589
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
590
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
591
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
592
#備註:
-
 
593
#無.
-
 
594
$enCodeStr=authenticate::enCodeStr($conf);
-
 
595
unset($conf);
187
 
596
 
188
	#印出訊息
597
#debug
189
	echo json_encode($responseMultiInputDataSecurityEnhance);
598
#var_dump(__LINE__,$enCodeStr);exit;
190
 
599
 
-
 
600
#如果執行異常
-
 
601
if($enCodeStr["status"]==="false"){
-
 
602
 
-
 
603
	#函式說明:
-
 
604
	#撰寫log
-
 
605
	#回傳結果:
-
 
606
	#$result["status"],狀態,"true"或"false".
-
 
607
	#$result["error"],錯誤訊息陣列.
-
 
608
	#$result["function"],當前函式的名稱.
-
 
609
	#$result["argu"],使用的參數.
-
 
610
	#必填參數:
-
 
611
	#$conf["path"],log檔案的路徑與名稱.
-
 
612
	$conf["path"]=$logFile;
-
 
613
	#$conf["content"],字串,要寫的內容.
-
 
614
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
615
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
616
	$conf["fileArgu"]=__FILE__;
-
 
617
	#可省略參數:
-
 
618
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
619
	#$conf["rewrite"]="false";
-
 
620
	#參考資料:
-
 
621
	#無.
-
 
622
	#備註:
-
 
623
	#無.	
-
 
624
	$record=logs::record($conf);
-
 
625
	unset($conf);
-
 
626
 
-
 
627
	#如果寫log 失敗
-
 
628
	if($record["status"]==="false"){
-
 
629
 
-
 
630
		#印出訊息
-
 
631
		echo json_encode($record);
-
 
632
		
191
	#結束執行
633
		#異常結束執行
192
	exit;
634
		exit(1);
193
 
635
 
-
 
636
		}#if end
-
 
637
		
-
 
638
	#異常結束執行
-
 
639
	exit(1);
-
 
640
	
194
	}#if end
641
	}#if end
195
 
642
 
-
 
643
#解密參數
-
 
644
#函式說明:
-
 
645
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
646
#回傳結果:
-
 
647
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
648
#$result["function"],當前執行的函數名稱.
-
 
649
#$result["content"],加密後的結果.
-
 
650
#$result["error"],錯誤訊息陣列.
-
 
651
#$result["argu"],使用的參數.
196
#取得參數
652
#必填參數:
-
 
653
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
654
$conf["enCodeStr"]=$enCodeStr["content"];
197
$params=$responseMultiInputDataSecurityEnhance["inputDataContent"]["params"];
655
#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg"與"hex2bin&gpg",9種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過urlencode、json_encode、base64_encode的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key;"hex2bin&gpg"為先hex2bin在進行gpg加解密.
-
 
656
$conf["enCodeType"]="qbpwcf";
-
 
657
#可省略參數:
-
 
658
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
659
#$conf["sha1Raw"]="false";
-
 
660
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
661
#$conf["p_hash"]="";
-
 
662
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
663
#$conf["keyForAes256"]="";
-
 
664
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
665
#$conf["aes256Encode"]="";
-
 
666
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
667
$conf["qbpwcfDecode"]="true";
-
 
668
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
669
#$conf["gpgDecrypt"]="true";
-
 
670
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
671
#$conf["gpgId"]="";
-
 
672
#參考資料:
-
 
673
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
674
#md5=>http://php.net/manual/en/function.md5.php
-
 
675
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
676
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
677
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
678
#備註:
-
 
679
#無.
-
 
680
$enCodeStr=authenticate::enCodeStr($conf);
-
 
681
unset($conf);
-
 
682
 
-
 
683
#debug
-
 
684
#var_dump(__LINE__,$enCodeStr);exit;
-
 
685
 
-
 
686
#如果執行異常
-
 
687
if($enCodeStr["status"]==="false"){
-
 
688
 
-
 
689
	#函式說明:
-
 
690
	#撰寫log
-
 
691
	#回傳結果:
-
 
692
	#$result["status"],狀態,"true"或"false".
-
 
693
	#$result["error"],錯誤訊息陣列.
-
 
694
	#$result["function"],當前函式的名稱.
-
 
695
	#$result["argu"],使用的參數.
-
 
696
	#必填參數:
-
 
697
	#$conf["path"],log檔案的路徑與名稱.
-
 
698
	$conf["path"]=$logFile;
-
 
699
	#$conf["content"],字串,要寫的內容.
-
 
700
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
701
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
702
	$conf["fileArgu"]=__FILE__;
-
 
703
	#可省略參數:
-
 
704
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
705
	#$conf["rewrite"]="false";
-
 
706
	#參考資料:
-
 
707
	#無.
-
 
708
	#備註:
-
 
709
	#無.	
-
 
710
	$record=logs::record($conf);
-
 
711
	unset($conf);
-
 
712
 
-
 
713
	#如果寫log 失敗
-
 
714
	if($record["status"]==="false"){
-
 
715
 
-
 
716
		#印出訊息
-
 
717
		echo json_encode($record);
-
 
718
		
-
 
719
		#異常結束執行
-
 
720
		exit(1);
198
 
721
 
-
 
722
		}#if end
-
 
723
		
-
 
724
	#異常結束執行
-
 
725
	exit(1);
-
 
726
	
-
 
727
	}#if end
-
 
728
 
199
#解析變數
729
#取得解碼後的結果
200
$params=json_decode(urldecode(base64_decode($params)));
730
$params=$enCodeStr["content"];
201
 
731
 
202
#轉換為陣列
732
#轉換為陣列
203
$params=(array)$params;
733
$params=(array)$params;
204
 
734
 
205
#函式說明:
735
#函式說明:
Line 230... Line 760...
230
if($record["status"]==="false"){
760
if($record["status"]==="false"){
231
 
761
 
232
	#印出訊息
762
	#印出訊息
233
	echo json_encode($record);
763
	echo json_encode($record);
234
	
764
	
235
	#結束執行
765
	#異常結束執行
236
	exit;
766
	exit(1);
237
 
767
 
238
	}#if end
768
	}#if end
239
 
769
 
240
#如果少了使用資料庫系統的dbSecret
770
#如果少了使用資料庫系統的dbSecret
241
if(!isset($params["dbSecret"])){
771
if(!isset($params["dbSecret"])){
Line 249... Line 779...
249
else{
779
else{
250
 
780
 
251
	#若dbSecret錯誤
781
	#若dbSecret錯誤
252
	if($params["dbSecret"]!==dbSecret){
782
	if($params["dbSecret"]!==dbSecret){
253
	
783
	
-
 
784
		#函式說明:
-
 
785
		#撰寫log
-
 
786
		#回傳結果:
-
 
787
		#$result["status"],狀態,"true"或"false".
-
 
788
		#$result["error"],錯誤訊息陣列.
-
 
789
		#$result["function"],當前函式的名稱.
-
 
790
		#$result["argu"],使用的參數.
-
 
791
		#必填參數:
-
 
792
		#$conf["path"],log檔案的路徑與名稱.
-
 
793
		$conf["path"]=$logFile;
-
 
794
		#$conf["content"],字串,要寫的內容.
-
 
795
		$conf["content"]="wrong dbSecret".PHP_EOL;
-
 
796
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
797
		$conf["fileArgu"]=__FILE__;
-
 
798
		#可省略參數:
-
 
799
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
800
		#$conf["rewrite"]="false";
-
 
801
		#參考資料:
-
 
802
		#無.
-
 
803
		#備註:
-
 
804
		#無.	
-
 
805
		$record=logs::record($conf);
-
 
806
		unset($conf);
-
 
807
 
-
 
808
		#如果寫log 失敗
-
 
809
		if($record["status"]==="false"){
-
 
810
 
-
 
811
			#印出訊息
-
 
812
			echo json_encode($record);
-
 
813
			
-
 
814
			#異常結束執行
-
 
815
			exit(1);
-
 
816
 
-
 
817
			}#if end
-
 
818
	
254
		#結束執行
819
		#結束執行
255
		exit;
820
		exit;
256
	
821
	
257
		}#if end
822
		}#if end
258
	
823
	
Line 339... Line 904...
339
if($record["status"]==="false"){
904
if($record["status"]==="false"){
340
 
905
 
341
	#印出訊息
906
	#印出訊息
342
	echo json_encode($record);
907
	echo json_encode($record);
343
	
908
	
344
	#結束執行
909
	#異常結束執行
345
	exit;
910
	exit(1);
346
 
911
 
347
	}#if end
912
	}#if end
348
 
913
 
349
#如果執行失敗
914
#如果執行失敗
350
if($checkArguments["status"]==="false"){
915
if($checkArguments["status"]==="false"){
351
 
916
 
352
	#印出訊息
917
	#印出訊息
353
	echo json_encode($checkArguments);
918
	echo json_encode($checkArguments);
354
 
919
 
355
	#結束執行
920
	#異常結束執行
356
	exit;
921
	exit(1);
357
 
922
 
358
	}#if end
923
	}#if end
359
 
924
 
360
#如果邊數檢查不通過
925
#如果邊數檢查不通過
361
if($checkArguments["passed"]==="false"){
926
if($checkArguments["passed"]==="false"){
Line 470... Line 1035...
470
#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的3306 port.
1035
#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的3306 port.
471
$conf["dbPort"]=$params["dbPort"];
1036
$conf["dbPort"]=$params["dbPort"];
472
$fastGetDbData=db::fastGetDbData($conf);
1037
$fastGetDbData=db::fastGetDbData($conf);
473
unset($conf);
1038
unset($conf);
474
 
1039
 
-
 
1040
#如果執行異常
-
 
1041
if($fastGetDbData["status"]==="false"){
-
 
1042
 
-
 
1043
	#函式說明:
-
 
1044
	#撰寫log
-
 
1045
	#回傳結果:
-
 
1046
	#$result["status"],狀態,"true"或"false".
-
 
1047
	#$result["error"],錯誤訊息陣列.
-
 
1048
	#$result["function"],當前函式的名稱.
-
 
1049
	#$result["argu"],使用的參數.
-
 
1050
	#必填參數:
-
 
1051
	#$conf["path"],log檔案的路徑與名稱.
-
 
1052
	$conf["path"]=$logFile;
-
 
1053
	#$conf["content"],字串,要寫的內容.
-
 
1054
	$conf["content"]=json_encode($fastGetDbData).PHP_EOL;
-
 
1055
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
1056
	$conf["fileArgu"]=__FILE__;
-
 
1057
	#可省略參數:
-
 
1058
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
1059
	#$conf["rewrite"]="false";
-
 
1060
	#參考資料:
-
 
1061
	#無.
-
 
1062
	#備註:
-
 
1063
	#無.	
-
 
1064
	$record=logs::record($conf);
-
 
1065
	unset($conf);
-
 
1066
 
-
 
1067
	#如果寫log 失敗
-
 
1068
	if($record["status"]==="false"){
-
 
1069
 
-
 
1070
		#印出訊息
-
 
1071
		echo json_encode($record);
-
 
1072
		
-
 
1073
		#異常結束執行
-
 
1074
		exit(1);
-
 
1075
 
-
 
1076
		}#if end
-
 
1077
		
-
 
1078
	#異常結束執行
-
 
1079
	exit(1);
-
 
1080
		
-
 
1081
	}#if end
-
 
1082
 
475
#函式說明:
1083
#函式說明:
476
#撰寫log
1084
#撰寫log
477
#回傳結果:
1085
#回傳結果:
478
#$result["status"],狀態,"true"或"false".
1086
#$result["status"],狀態,"true"或"false".
479
#$result["error"],錯誤訊息陣列.
1087
#$result["error"],錯誤訊息陣列.