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 183
Line 59... Line 59...
59
 
59
 
60
#匯入外部套件
60
#匯入外部套件
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
#預設的範例資料參數
66
/*
67
$params=array();
-
 
68
$params["dbSecret"]=$dbSecret;
-
 
69
$params["dbAddr"]=$dbAddress;
-
 
70
$params["dbPort"]=$dbPort;
-
 
71
$params["dbName"]=$dbName;
-
 
72
$params["dbUser"]=$dbAccount;
-
 
73
$params["dbPass"]=$dbPassword;
-
 
74
$params["dtName"]="namespace";
-
 
75
$params["cols"]=array("name","comment");
-
 
76
$params["vals"]=array("notExist","not exist namespace");
67
 
77
 
-
 
78
#加密參數
-
 
79
#函式說明:
-
 
80
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
81
#回傳結果:
-
 
82
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
83
#$result["function"],當前執行的函數名稱.
-
 
84
#$result["content"],加密後的結果.
-
 
85
#$result["error"],錯誤訊息陣列.
-
 
86
#$result["argu"],使用的參數.
-
 
87
#必填參數:
-
 
88
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
89
$conf["enCodeStr"]=$params;
68
# test case - 1 - start
90
#$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加解密.
-
 
91
$conf["enCodeType"]="qbpwcf";
-
 
92
#可省略參數:
-
 
93
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
94
#$conf["sha1Raw"]="false";
-
 
95
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
96
#$conf["p_hash"]="";
-
 
97
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
98
#$conf["keyForAes256"]="";
-
 
99
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
100
#$conf["aes256Encode"]="";
-
 
101
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
102
#$conf["qbpwcfDecode"]="false";
-
 
103
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
104
#$conf["gpgDecrypt"]="false";
-
 
105
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
106
#$conf["gpgId"]="";
-
 
107
#參考資料:
-
 
108
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
109
#md5=>http://php.net/manual/en/function.md5.php
-
 
110
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
111
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
112
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
113
#備註:
-
 
114
#無.
-
 
115
$enCodeStr=authenticate::enCodeStr($conf);
-
 
116
unset($conf);
69
 
117
 
70
$params=array();
118
#如果執行異常
71
$params["dbSecret"]="";
-
 
72
$params["dbAddr"]="localhost";
-
 
73
$params["dbPort"]="3306";
-
 
74
$params["dbName"]="test";
-
 
75
$params["dbUser"]="test";
-
 
76
$params["dbPass"]="test";
119
if($enCodeStr["status"]==="false"){
77
$params["dtName"]="member";
-
 
78
$params["cols"]=array("account","password","comment");
-
 
79
$params["vals"]=array("test acct","test pass","test comment");
-
 
80
 
120
 
-
 
121
	#函式說明:
-
 
122
	#撰寫log
-
 
123
	#回傳結果:
-
 
124
	#$result["status"],狀態,"true"或"false".
-
 
125
	#$result["error"],錯誤訊息陣列.
-
 
126
	#$result["function"],當前函式的名稱.
-
 
127
	#$result["argu"],使用的參數.
81
#設置參數
128
	#必填參數:
-
 
129
	#$conf["path"],log檔案的路徑與名稱.
-
 
130
	$conf["path"]=$logFile;
-
 
131
	#$conf["content"],字串,要寫的內容.
82
$_POST["params"]=base64_encode(urlencode(json_encode($params)));
132
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
133
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
134
	$conf["fileArgu"]=__FILE__;
-
 
135
	#可省略參數:
-
 
136
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
137
	#$conf["rewrite"]="false";
-
 
138
	#參考資料:
-
 
139
	#無.
-
 
140
	#備註:
-
 
141
	#無.	
-
 
142
	$record=logs::record($conf);
-
 
143
	unset($conf);
-
 
144
 
-
 
145
	#如果寫log 失敗
-
 
146
	if($record["status"]==="false"){
-
 
147
 
-
 
148
		#印出訊息
-
 
149
		echo json_encode($record);
-
 
150
		
-
 
151
		#異常結束執行
-
 
152
		exit(1);
83
 
153
 
-
 
154
		}#if end
-
 
155
		
84
# test case - 1 - end
156
	#異常結束執行
-
 
157
	exit(1);
85
 
158
 
-
 
159
	}#if end
-
 
160
	
-
 
161
#加密參數
-
 
162
#函式說明:
-
 
163
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
164
#回傳結果:
-
 
165
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
166
#$result["function"],當前執行的函數名稱.
-
 
167
#$result["content"],加密後的結果.
-
 
168
#$result["error"],錯誤訊息陣列.
-
 
169
#$result["argu"],使用的參數.
-
 
170
#必填參數:
-
 
171
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
172
$conf["enCodeStr"]=$enCodeStr["content"];
-
 
173
#$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加解密.
-
 
174
$conf["enCodeType"]="gpg";
-
 
175
#可省略參數:
-
 
176
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
177
#$conf["sha1Raw"]="false";
-
 
178
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
179
#$conf["p_hash"]="";
-
 
180
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
181
#$conf["keyForAes256"]="";
-
 
182
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
183
#$conf["aes256Encode"]="";
-
 
184
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
185
#$conf["qbpwcfDecode"]="false";
-
 
186
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
187
$conf["gpgDecrypt"]="false";
-
 
188
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
189
#$conf["gpgId"]="";
-
 
190
#參考資料:
-
 
191
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
192
#md5=>http://php.net/manual/en/function.md5.php
-
 
193
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
194
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
195
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
196
#備註:
-
 
197
#無.
-
 
198
$enCodeStr=authenticate::enCodeStr($conf);
-
 
199
unset($conf);
-
 
200
 
-
 
201
#如果執行異常
-
 
202
if($enCodeStr["status"]==="false"){
-
 
203
 
-
 
204
	#函式說明:
-
 
205
	#撰寫log
-
 
206
	#回傳結果:
-
 
207
	#$result["status"],狀態,"true"或"false".
-
 
208
	#$result["error"],錯誤訊息陣列.
-
 
209
	#$result["function"],當前函式的名稱.
-
 
210
	#$result["argu"],使用的參數.
-
 
211
	#必填參數:
-
 
212
	#$conf["path"],log檔案的路徑與名稱.
-
 
213
	$conf["path"]=$logFile;
-
 
214
	#$conf["content"],字串,要寫的內容.
-
 
215
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
216
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
217
	$conf["fileArgu"]=__FILE__;
-
 
218
	#可省略參數:
-
 
219
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
220
	#$conf["rewrite"]="false";
-
 
221
	#參考資料:
-
 
222
	#無.
-
 
223
	#備註:
-
 
224
	#無.	
-
 
225
	$record=logs::record($conf);
-
 
226
	unset($conf);
-
 
227
 
-
 
228
	#如果寫log 失敗
-
 
229
	if($record["status"]==="false"){
-
 
230
 
-
 
231
		#印出訊息
-
 
232
		echo json_encode($record);
-
 
233
		
-
 
234
		#異常結束執行
-
 
235
		exit(1);
-
 
236
 
-
 
237
		}#if end
-
 
238
	
-
 
239
	#異常結束執行
-
 
240
	exit(1);
-
 
241
 
-
 
242
	}#if end
-
 
243
	
-
 
244
#編碼參數
-
 
245
#函式說明:
-
 
246
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
247
#回傳結果:
-
 
248
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
249
#$result["function"],當前執行的函數名稱.
-
 
250
#$result["content"],加密後的結果.
-
 
251
#$result["error"],錯誤訊息陣列.
-
 
252
#$result["argu"],使用的參數.
-
 
253
#必填參數:
-
 
254
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
255
$conf["enCodeStr"]=$enCodeStr["content"];
86
*/
256
#$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加解密.
-
 
257
$conf["enCodeType"]="bin2hex";
-
 
258
#可省略參數:
-
 
259
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
260
#$conf["sha1Raw"]="false";
-
 
261
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
262
#$conf["p_hash"]="";
-
 
263
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
264
#$conf["keyForAes256"]="";
-
 
265
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
266
#$conf["aes256Encode"]="";
-
 
267
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
268
#$conf["qbpwcfDecode"]="false";
-
 
269
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
270
#$conf["gpgDecrypt"]="false";
-
 
271
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
272
#$conf["gpgId"]="";
-
 
273
#參考資料:
-
 
274
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
275
#md5=>http://php.net/manual/en/function.md5.php
-
 
276
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
277
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
278
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
279
#備註:
-
 
280
#無.
-
 
281
$enCodeStr=authenticate::enCodeStr($conf);
-
 
282
unset($conf);
-
 
283
 
-
 
284
#如果執行異常
-
 
285
if($enCodeStr["status"]==="false"){
-
 
286
 
-
 
287
	#函式說明:
-
 
288
	#撰寫log
-
 
289
	#回傳結果:
-
 
290
	#$result["status"],狀態,"true"或"false".
-
 
291
	#$result["error"],錯誤訊息陣列.
-
 
292
	#$result["function"],當前函式的名稱.
-
 
293
	#$result["argu"],使用的參數.
-
 
294
	#必填參數:
-
 
295
	#$conf["path"],log檔案的路徑與名稱.
-
 
296
	$conf["path"]=$logFile;
-
 
297
	#$conf["content"],字串,要寫的內容.
-
 
298
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
299
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
300
	$conf["fileArgu"]=__FILE__;
-
 
301
	#可省略參數:
-
 
302
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
303
	#$conf["rewrite"]="false";
-
 
304
	#參考資料:
-
 
305
	#無.
-
 
306
	#備註:
-
 
307
	#無.	
-
 
308
	$record=logs::record($conf);
-
 
309
	unset($conf);
-
 
310
 
-
 
311
	#如果寫log 失敗
-
 
312
	if($record["status"]==="false"){
-
 
313
 
-
 
314
		#印出訊息
-
 
315
		echo json_encode($record);
-
 
316
		
-
 
317
		#異常結束執行
-
 
318
		exit(1);
-
 
319
 
-
 
320
		}#if end
-
 
321
		
-
 
322
	#異常結束執行
-
 
323
	exit(1);
-
 
324
 
-
 
325
	}#if end
-
 
326
	
-
 
327
#更新POST的預設參數
-
 
328
$_POST["params"]=$enCodeStr["content"];
87
 
329
 
88
#涵式說明:
330
#涵式說明:
89
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
331
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
90
#回傳的結果:
332
#回傳的結果:
91
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
333
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 128... Line 370...
128
#備註:
370
#備註:
129
#表單變數的名稱若含有「.」,則會變成「-」。
371
#表單變數的名稱若含有「.」,則會變成「-」。
130
$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf);
372
$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf);
131
unset($conf);
373
unset($conf);
132
 
374
 
-
 
375
#如果執行異常
-
 
376
if($responseMultiInputDataSecurityEnhance["status"]==="false"){
-
 
377
 
-
 
378
	#函式說明:
-
 
379
	#撰寫log
-
 
380
	#回傳結果:
-
 
381
	#$result["status"],狀態,"true"或"false".
-
 
382
	#$result["error"],錯誤訊息陣列.
-
 
383
	#$result["function"],當前函式的名稱.
-
 
384
	#$result["argu"],使用的參數.
-
 
385
	#必填參數:
-
 
386
	#$conf["path"],log檔案的路徑與名稱.
-
 
387
	$conf["path"]=$logFile;
-
 
388
	#$conf["content"],字串,要寫的內容.
-
 
389
	$conf["content"]="Form data error, please see json:".json_encode($responseMultiInputDataSecurityEnhance).PHP_EOL;
-
 
390
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
391
	$conf["fileArgu"]=__FILE__;
-
 
392
	#可省略參數:
-
 
393
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
394
	#$conf["rewrite"]="false";
-
 
395
	#參考資料:
-
 
396
	#無.
-
 
397
	#備註:
-
 
398
	#無.	
-
 
399
	$record=logs::record($conf);
-
 
400
	unset($conf);
-
 
401
 
-
 
402
	#如果寫log 失敗
-
 
403
	if($record["status"]==="false"){
-
 
404
 
-
 
405
		#印出訊息
-
 
406
		echo json_encode($record);
-
 
407
		
-
 
408
		#異常結束執行
-
 
409
		exit(1);
-
 
410
 
-
 
411
		}#if end
-
 
412
		
-
 
413
	#異常結束執行
-
 
414
	exit(1);
-
 
415
	
-
 
416
	}#if end
-
 
417
 
133
#函式說明:
418
#函式說明:
134
#撰寫log
419
#撰寫log
135
#回傳結果:
420
#回傳結果:
136
#$result["status"],狀態,"true"或"false".
421
#$result["status"],狀態,"true"或"false".
137
#$result["error"],錯誤訊息陣列.
422
#$result["error"],錯誤訊息陣列.
Line 158... Line 443...
158
if($record["status"]==="false"){
443
if($record["status"]==="false"){
159
 
444
 
160
	#印出訊息
445
	#印出訊息
161
	echo json_encode($record);
446
	echo json_encode($record);
162
	
447
	
163
	#結束執行
448
	#異常結束執行
164
	exit;
449
	exit(1);
165
 
450
 
166
	}#if end
451
	}#if end
167
 
452
 
168
#如果執行失敗
453
#取得參數
169
if($responseMultiInputDataSecurityEnhance["status"]==="false"){
454
$params=$responseMultiInputDataSecurityEnhance["inputDataContent"]["params"];
170
 
455
 
-
 
456
#解碼參數
171
	#印出訊息
457
#函式說明:
-
 
458
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
459
#回傳結果:
-
 
460
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
461
#$result["function"],當前執行的函數名稱.
-
 
462
#$result["content"],加密後的結果.
-
 
463
#$result["error"],錯誤訊息陣列.
-
 
464
#$result["argu"],使用的參數.
-
 
465
#必填參數:
-
 
466
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
467
$conf["enCodeStr"]=$params;
172
	echo json_encode($responseMultiInputDataSecurityEnhance);
468
#$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加解密.
-
 
469
$conf["enCodeType"]="hex2bin";
-
 
470
#可省略參數:
-
 
471
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
472
#$conf["sha1Raw"]="false";
-
 
473
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
474
#$conf["p_hash"]="";
-
 
475
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
476
#$conf["keyForAes256"]="";
-
 
477
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
478
#$conf["aes256Encode"]="";
-
 
479
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
480
#$conf["qbpwcfDecode"]="false";
-
 
481
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
482
#$conf["gpgDecrypt"]="false";
-
 
483
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
484
#$conf["gpgId"]="";
-
 
485
#參考資料:
-
 
486
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
487
#md5=>http://php.net/manual/en/function.md5.php
-
 
488
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
489
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
490
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
491
#備註:
-
 
492
#無.
-
 
493
$enCodeStr=authenticate::enCodeStr($conf);
-
 
494
unset($conf);
173
 
495
 
-
 
496
#debug
-
 
497
#var_dump(__LINE__,$enCodeStr);
-
 
498
 
174
	#結束執行
499
#如果執行異常
175
	exit;
500
if($enCodeStr["status"]==="false"){
176
 
501
 
-
 
502
	#函式說明:
-
 
503
	#撰寫log
-
 
504
	#回傳結果:
-
 
505
	#$result["status"],狀態,"true"或"false".
-
 
506
	#$result["error"],錯誤訊息陣列.
-
 
507
	#$result["function"],當前函式的名稱.
-
 
508
	#$result["argu"],使用的參數.
-
 
509
	#必填參數:
-
 
510
	#$conf["path"],log檔案的路徑與名稱.
-
 
511
	$conf["path"]=$logFile;
-
 
512
	#$conf["content"],字串,要寫的內容.
-
 
513
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
514
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
515
	$conf["fileArgu"]=__FILE__;
-
 
516
	#可省略參數:
-
 
517
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
518
	#$conf["rewrite"]="false";
-
 
519
	#參考資料:
-
 
520
	#無.
-
 
521
	#備註:
-
 
522
	#無.	
-
 
523
	$record=logs::record($conf);
-
 
524
	unset($conf);
-
 
525
 
-
 
526
	#如果寫log 失敗
-
 
527
	if($record["status"]==="false"){
-
 
528
 
-
 
529
		#印出訊息
-
 
530
		echo json_encode($record);
-
 
531
		
-
 
532
		#異常結束執行
-
 
533
		exit(1);
-
 
534
 
-
 
535
		}#if end
-
 
536
		
-
 
537
	#異常結束執行
-
 
538
	exit(1);
-
 
539
	
177
	}#if end
540
	}#if end
178
 
541
 
-
 
542
#解密參數
-
 
543
#函式說明:
-
 
544
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
545
#回傳結果:
-
 
546
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
547
#$result["function"],當前執行的函數名稱.
-
 
548
#$result["content"],加密後的結果.
-
 
549
#$result["error"],錯誤訊息陣列.
-
 
550
#$result["argu"],使用的參數.
-
 
551
#必填參數:
-
 
552
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
553
$conf["enCodeStr"]=$enCodeStr["content"];
179
#如果邊數檢查不通過
554
#$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加解密.
-
 
555
$conf["enCodeType"]="gpg";
-
 
556
#可省略參數:
-
 
557
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
558
#$conf["sha1Raw"]="false";
-
 
559
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
560
#$conf["p_hash"]="";
-
 
561
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
562
#$conf["keyForAes256"]="";
-
 
563
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
564
#$conf["aes256Encode"]="";
-
 
565
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
566
#$conf["qbpwcfDecode"]="true";
-
 
567
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
568
$conf["gpgDecrypt"]="true";
-
 
569
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
570
#$conf["gpgId"]="";
-
 
571
#參考資料:
-
 
572
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
573
#md5=>http://php.net/manual/en/function.md5.php
180
if($responseMultiInputDataSecurityEnhance["passed"]==="false"){
574
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
575
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
576
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
577
#備註:
-
 
578
#無.
-
 
579
$enCodeStr=authenticate::enCodeStr($conf);
-
 
580
unset($conf);
181
 
581
 
182
	#印出訊息
582
#debug
183
	echo json_encode($responseMultiInputDataSecurityEnhance);
583
#var_dump(__LINE__,$enCodeStr);exit;
184
 
584
 
-
 
585
#如果執行異常
-
 
586
if($enCodeStr["status"]==="false"){
-
 
587
 
-
 
588
	#函式說明:
-
 
589
	#撰寫log
-
 
590
	#回傳結果:
-
 
591
	#$result["status"],狀態,"true"或"false".
-
 
592
	#$result["error"],錯誤訊息陣列.
-
 
593
	#$result["function"],當前函式的名稱.
-
 
594
	#$result["argu"],使用的參數.
-
 
595
	#必填參數:
-
 
596
	#$conf["path"],log檔案的路徑與名稱.
-
 
597
	$conf["path"]=$logFile;
-
 
598
	#$conf["content"],字串,要寫的內容.
-
 
599
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
600
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
601
	$conf["fileArgu"]=__FILE__;
-
 
602
	#可省略參數:
-
 
603
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
604
	#$conf["rewrite"]="false";
-
 
605
	#參考資料:
-
 
606
	#無.
-
 
607
	#備註:
-
 
608
	#無.	
-
 
609
	$record=logs::record($conf);
-
 
610
	unset($conf);
-
 
611
 
-
 
612
	#如果寫log 失敗
-
 
613
	if($record["status"]==="false"){
-
 
614
 
-
 
615
		#印出訊息
-
 
616
		echo json_encode($record);
-
 
617
		
185
	#結束執行
618
		#異常結束執行
186
	exit;
619
		exit(1);
187
 
620
 
-
 
621
		}#if end
-
 
622
		
-
 
623
	#異常結束執行
-
 
624
	exit(1);
-
 
625
	
188
	}#if end
626
	}#if end
189
 
627
 
-
 
628
#解密參數
-
 
629
#函式說明:
-
 
630
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
631
#回傳結果:
-
 
632
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
-
 
633
#$result["function"],當前執行的函數名稱.
-
 
634
#$result["content"],加密後的結果.
-
 
635
#$result["error"],錯誤訊息陣列.
-
 
636
#$result["argu"],使用的參數.
190
#取得參數
637
#必填參數:
-
 
638
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
639
$conf["enCodeStr"]=$enCodeStr["content"];
191
$params=$responseMultiInputDataSecurityEnhance["inputDataContent"]["params"];
640
#$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加解密.
-
 
641
$conf["enCodeType"]="qbpwcf";
-
 
642
#可省略參數:
-
 
643
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
644
#$conf["sha1Raw"]="false";
-
 
645
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
646
#$conf["p_hash"]="";
-
 
647
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
648
#$conf["keyForAes256"]="";
-
 
649
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
650
#$conf["aes256Encode"]="";
-
 
651
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
652
$conf["qbpwcfDecode"]="true";
-
 
653
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
654
#$conf["gpgDecrypt"]="true";
-
 
655
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
-
 
656
#$conf["gpgId"]="";
-
 
657
#參考資料:
-
 
658
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
659
#md5=>http://php.net/manual/en/function.md5.php
-
 
660
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
661
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
662
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
663
#備註:
-
 
664
#無.
-
 
665
$enCodeStr=authenticate::enCodeStr($conf);
-
 
666
unset($conf);
-
 
667
 
-
 
668
#debug
-
 
669
#var_dump(__LINE__,$enCodeStr);exit;
-
 
670
 
-
 
671
#如果執行異常
-
 
672
if($enCodeStr["status"]==="false"){
-
 
673
 
-
 
674
	#函式說明:
-
 
675
	#撰寫log
-
 
676
	#回傳結果:
-
 
677
	#$result["status"],狀態,"true"或"false".
-
 
678
	#$result["error"],錯誤訊息陣列.
-
 
679
	#$result["function"],當前函式的名稱.
-
 
680
	#$result["argu"],使用的參數.
-
 
681
	#必填參數:
-
 
682
	#$conf["path"],log檔案的路徑與名稱.
-
 
683
	$conf["path"]=$logFile;
-
 
684
	#$conf["content"],字串,要寫的內容.
-
 
685
	$conf["content"]=json_encode($enCodeStr).PHP_EOL;
-
 
686
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
687
	$conf["fileArgu"]=__FILE__;
-
 
688
	#可省略參數:
-
 
689
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
690
	#$conf["rewrite"]="false";
-
 
691
	#參考資料:
-
 
692
	#無.
-
 
693
	#備註:
-
 
694
	#無.	
-
 
695
	$record=logs::record($conf);
-
 
696
	unset($conf);
-
 
697
 
-
 
698
	#如果寫log 失敗
-
 
699
	if($record["status"]==="false"){
-
 
700
 
-
 
701
		#印出訊息
-
 
702
		echo json_encode($record);
-
 
703
		
-
 
704
		#異常結束執行
-
 
705
		exit(1);
-
 
706
 
-
 
707
		}#if end
-
 
708
		
-
 
709
	#異常結束執行
-
 
710
	exit(1);
-
 
711
	
-
 
712
	}#if end
192
 
713
 
193
#解析變數
714
#取得解碼後的結果
194
$params=json_decode(urldecode(base64_decode($params)));
715
$params=$enCodeStr["content"];
195
 
716
 
196
#轉換為陣列
717
#轉換為陣列
197
$params=(array)$params;
718
$params=(array)$params;
198
 
719
 
199
#函式說明:
720
#函式說明:
Line 224... Line 745...
224
if($record["status"]==="false"){
745
if($record["status"]==="false"){
225
 
746
 
226
	#印出訊息
747
	#印出訊息
227
	echo json_encode($record);
748
	echo json_encode($record);
228
	
749
	
229
	#結束執行
750
	#異常結束執行
230
	exit;
751
	exit(1);
231
 
752
 
232
	}#if end
753
	}#if end
233
 
754
 
234
#如果少了使用資料庫系統的dbSecret
755
#如果少了使用資料庫系統的dbSecret
235
if(!isset($params["dbSecret"])){
756
if(!isset($params["dbSecret"])){
Line 243... Line 764...
243
else{
764
else{
244
 
765
 
245
	#若dbSecret錯誤
766
	#若dbSecret錯誤
246
	if($params["dbSecret"]!==dbSecret){
767
	if($params["dbSecret"]!==dbSecret){
247
	
768
	
-
 
769
		#函式說明:
-
 
770
		#撰寫log
-
 
771
		#回傳結果:
-
 
772
		#$result["status"],狀態,"true"或"false".
-
 
773
		#$result["error"],錯誤訊息陣列.
-
 
774
		#$result["function"],當前函式的名稱.
-
 
775
		#$result["argu"],使用的參數.
-
 
776
		#必填參數:
-
 
777
		#$conf["path"],log檔案的路徑與名稱.
-
 
778
		$conf["path"]=$logFile;
-
 
779
		#$conf["content"],字串,要寫的內容.
-
 
780
		$conf["content"]="wrong dbSecret".PHP_EOL;
-
 
781
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
782
		$conf["fileArgu"]=__FILE__;
-
 
783
		#可省略參數:
-
 
784
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
785
		#$conf["rewrite"]="false";
-
 
786
		#參考資料:
-
 
787
		#無.
-
 
788
		#備註:
-
 
789
		#無.	
-
 
790
		$record=logs::record($conf);
-
 
791
		unset($conf);
-
 
792
 
-
 
793
		#如果寫log 失敗
-
 
794
		if($record["status"]==="false"){
-
 
795
 
-
 
796
			#印出訊息
-
 
797
			echo json_encode($record);
-
 
798
			
-
 
799
			#異常結束執行
-
 
800
			exit(1);
-
 
801
 
-
 
802
			}#if end
-
 
803
	
248
		#結束執行
804
		#結束執行
249
		exit;
805
		exit;
250
	
806
	
251
		}#if end
807
		}#if end
252
	
808
	
Line 360... Line 916...
360
	#結束執行
916
	#結束執行
361
	exit;
917
	exit;
362
 
918
 
363
	}#if end
919
	}#if end
364
 
920
 
-
 
921
/*
365
#取得資料庫連線參數
922
#可能存在的參數
366
$params["dbAddr"];
923
$params["dbAddr"];
367
$params["dbPort"];#預設為3306
924
$params["dbPort"];
368
$params["dbName"];
925
$params["dbName"];
369
$params["dbUser"];
926
$params["dbUser"];
370
$params["dbPass"];
927
$params["dbPass"];
371
$params["dtName"];
928
$params["dtName"];
372
$params["cols"];
929
$params["cols"];#條件欄位
373
$params["vals"];
930
$params["vals"];#條件欄位對應數值
374
 
931
*/
375
#var_dump($params);
-
 
376
#exit;
-
 
377
 
932
 
378
#涵式說明:
933
#涵式說明:
379
#插入資料到指定的資料表裡面,插入資料完畢可以選擇是否要進行轉址。
934
#插入資料到指定的資料表裡面,插入資料完畢可以選擇是否要進行轉址。
380
#回傳的數值:	
935
#回傳的數值:	
381
#$result["status"],爲查詢是否成功,若爲"true"則成功,若爲"false"則表示失敗了.
936
#$result["status"],爲查詢是否成功,若爲"true"則成功,若爲"false"則表示失敗了.
Line 398... Line 953...
398
#參考資料來源:
953
#參考資料來源:
399
#http://www.javaworld.com.tw/jute/post/view?bid=21&id=173738&sty=1
954
#http://www.javaworld.com.tw/jute/post/view?bid=21&id=173738&sty=1
400
$insertData=db::insertData($conf);
955
$insertData=db::insertData($conf);
401
unset($conf);
956
unset($conf);
402
 
957
 
-
 
958
#如果執行異常
-
 
959
if($insertData["status"]==="false"){
-
 
960
 
-
 
961
	#函式說明:
-
 
962
	#撰寫log
-
 
963
	#回傳結果:
-
 
964
	#$result["status"],狀態,"true"或"false".
-
 
965
	#$result["error"],錯誤訊息陣列.
-
 
966
	#$result["function"],當前函式的名稱.
-
 
967
	#$result["argu"],使用的參數.
-
 
968
	#必填參數:
-
 
969
	#$conf["path"],log檔案的路徑與名稱.
-
 
970
	$conf["path"]=$logFile;
-
 
971
	#$conf["content"],字串,要寫的內容.
-
 
972
	$conf["content"]=json_encode($insertData).PHP_EOL;
-
 
973
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
974
	$conf["fileArgu"]=__FILE__;
-
 
975
	#可省略參數:
-
 
976
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
977
	#$conf["rewrite"]="false";
-
 
978
	#參考資料:
-
 
979
	#無.
-
 
980
	#備註:
-
 
981
	#無.	
-
 
982
	$record=logs::record($conf);
-
 
983
	unset($conf);
-
 
984
 
-
 
985
	#如果寫log 失敗
-
 
986
	if($record["status"]==="false"){
-
 
987
 
-
 
988
		#印出訊息
-
 
989
		echo json_encode($record);
-
 
990
		
-
 
991
		#異常結束執行
-
 
992
		exit(1);
-
 
993
 
-
 
994
		}#if end
-
 
995
		
-
 
996
	#異常結束執行
-
 
997
	exit(1);
-
 
998
 
-
 
999
	}#if end
-
 
1000
 
403
#函式說明:
1001
#函式說明:
404
#撰寫log
1002
#撰寫log
405
#回傳結果:
1003
#回傳結果:
406
#$result["status"],狀態,"true"或"false".
1004
#$result["status"],狀態,"true"或"false".
407
#$result["error"],錯誤訊息陣列.
1005
#$result["error"],錯誤訊息陣列.