Subversion Repositories php-qbpwcf

Rev

Rev 324 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
317 liveuser 1
<?php
2
 
3
/*
4
 
5
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2014~2026 MIN ZHI, CHEN
7
 
8
    This file is part of QBPWCF.
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
 
25
/*
26
 
27
本程式說明:
28
 
326 liveuser 29
接收email認證的link,驗證session,放行表單(可送出了).
317 liveuser 30
 
31
*/
32
 
33
#使用命名空間qbpwcf
34
namespace qbpwcf;
35
 
36
#初始化輸出
37
$output=array();
38
 
39
#取得 lib path
40
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
41
 
42
#如果執行失敗
43
if($status!==0){
44
 
45
	#debug
46
	var_dump(__LINE__,$output);
47
 
48
	#結束執行,回傳shell 1.
49
	exit(1);
50
 
51
	}#if end
52
 
53
#儲存lib path
54
$folderOfUsrLib=$output[0];
55
 
56
#初始化輸出
57
$output=array();
58
 
59
#以該檔案的實際位置的 lib path 為 include path 首位
60
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);
61
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
62
 
63
#匯入套件
64
require_once("allInOne.php");
65
 
66
#建議的log位置
67
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
68
 
69
#從 GET 取得加密後的 session 數值
70
#函式說明:
71
#抓取命令列的參數.
72
#回傳結果:
73
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
74
#$reuslt["error"],執行不正常結束的錯訊息陣列.
75
#$result["function"],當前執行的函式名稱.
76
#$result["argu"],使用的參數陣列.
77
#$result["content"],要回傳的參數陣列.
78
#$result["count"],參數的數量.
79
#$result["_GET"],收到的 HTTP GET 參數陣列.
80
#$result["_POST"],收到的 HTTP POST 參數陣列.
81
#必填參數:
82
#無
83
#可省略參數:
84
#$conf["echo"],字串,"true"代表要將抓到的參數一個個印出來,"false"代表用回傳的方式,預設為"false".
85
#$conf["echo"]="false";
86
#$conf["httpGetToArgu"],字串,"true"代表要將 http get 參數變成參數來取得,像是 $_GET["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
87
$conf["httpGetToArgu"]="true";
88
#$conf["httpPostToArgu"],字串,"true"代表要將 http post 參數變成參數來取得,像是 $_POST["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
89
#$conf["httpPostToArgu"]="false";
90
#$conf["arguEqual2http"],字串,預設為"false",代表命令列環境的參數依序為程式名稱本身、第n個參數,反之為"true",代表命令列的第一個參數為第n個參數,亦即沒有程式本身名稱的參數.
91
$conf["arguEqual2http"]="true";
92
#參考資料:
93
#無.
94
#備註:
95
#pipe要用''包住,才會被解析,例如'|'、'>'、'>>'.
96
$getArgu=cmd::getArgu($conf);
97
unset($conf);
98
 
323 liveuser 99
#debug
100
#var_dump(__LINE__,$getArgu);exit;
101
 
317 liveuser 102
#如果執行失敗
103
if($getArgu["status"]==="false"){
104
 
105
	#函式說明:
106
	#撰寫log
107
	#回傳結果:
108
	#$result["status"],狀態,"true"或"false".
109
	#$result["error"],錯誤訊息陣列.
110
	#$result["function"],當前函式的名稱.
111
	#$result["argu"],使用的參數.
112
	#必填參數:
113
	#$conf["path"],字串,log檔案的路徑與名稱.
114
	$conf["path"]=$logFile;
115
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
116
	$conf["content"]=$getArgu;
117
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
118
	$conf["fileArgu"]=__FILE__;
119
	#可省略參數:
120
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
121
	#$conf["rewrite"]="false";
122
	#參考資料:
123
	#無.
124
	#備註:
125
	#無.
126
	$record=logs::record($conf);
127
	unset($conf);
128
 
129
	#如果寫log失敗
130
	if($record["status"]==="false"){
131
 
132
		#印出json結果
133
		echo json_encode($record);
134
 
135
		}#if end
136
 
137
	#結束執行,回傳錯誤代碼1
138
	exit(1);
139
 
140
	}#if end
141
 
142
#如果沒有一個 GET 參數
143
if(count($getArgu["_GET"])!==1){
144
 
145
	#函式說明:
146
	#撰寫log
147
	#回傳結果:
148
	#$result["status"],狀態,"true"或"false".
149
	#$result["error"],錯誤訊息陣列.
150
	#$result["function"],當前函式的名稱.
151
	#$result["argu"],使用的參數.
152
	#必填參數:
153
	#$conf["path"],字串,log檔案的路徑與名稱.
154
	$conf["path"]=$logFile;
155
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
156
	$conf["content"]=$getArgu;
157
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
158
	$conf["fileArgu"]=__FILE__;
159
	#可省略參數:
160
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
161
	#$conf["rewrite"]="false";
162
	#參考資料:
163
	#無.
164
	#備註:
165
	#無.
166
	$record=logs::record($conf);
167
	unset($conf);
168
 
169
	#如果寫log失敗
170
	if($record["status"]==="false"){
171
 
172
		#印出json結果
173
		echo json_encode($record);
174
 
175
		}#if end
176
 
177
	#結束執行,回傳錯誤代碼1
178
	exit(1);
179
 
180
	}#if end
181
 
182
#函式說明:
183
#將陣列的key資訊取出,以方便使用.
184
#回傳結果:
185
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
186
#$reuslt["error"],執行不正常結束的錯訊息陣列.
187
#$result["function"],當前執行的函式名稱.
188
#$result["argu"],使用的參數.
189
#$result["content"],結果陣列.
190
#$result["content"]["key"],陣列key數值的陣列.
191
#$result["content"]["val"],陣列value的陣列.
192
#必填參數:
193
#$conf["array"],陣列,要讀取的一維陣列.
194
$conf["array"]=$getArgu["_GET"];
195
#可省略參數:
196
#無.
197
#參考資料:
198
#無.
199
#備註:
200
#無.
201
$inspectKey=arrays::inspectKey($conf);
202
unset($conf);
203
 
204
#如果執行出錯
205
if($inspectKey["status"]==="false"){
206
 
207
	#函式說明:
208
	#撰寫log
209
	#回傳結果:
210
	#$result["status"],狀態,"true"或"false".
211
	#$result["error"],錯誤訊息陣列.
212
	#$result["function"],當前函式的名稱.
213
	#$result["argu"],使用的參數.
214
	#必填參數:
215
	#$conf["path"],字串,log檔案的路徑與名稱.
216
	$conf["path"]=$logFile;
217
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
218
	$conf["content"]=$inspectKey;
219
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
220
	$conf["fileArgu"]=__FILE__;
221
	#可省略參數:
222
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
223
	#$conf["rewrite"]="false";
224
	#參考資料:
225
	#無.
226
	#備註:
227
	#無.
228
	$record=logs::record($conf);
229
	unset($conf);
230
 
231
	#如果寫log失敗
232
	if($record["status"]==="false"){
233
 
234
		#印出json結果
235
		echo json_encode($record);
236
 
237
		}#if end
238
 
239
	#結束執行,回傳錯誤代碼1
240
	exit(1);
241
 
242
	}#if end
243
 
323 liveuser 244
#取得未解密的字串
317 liveuser 245
$encodedSessionStr=$inspectKey["content"]["val"][0];
246
 
247
#debug
323 liveuser 248
#var_dump(__LINE__,$encodedSessionStr,base64_decode($encodedSessionStr));exit;
317 liveuser 249
 
323 liveuser 250
#解密 json 數值 - start
317 liveuser 251
 
323 liveuser 252
#用gpg解密
317 liveuser 253
#函式說明:
254
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
255
#回傳結果:
256
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
257
#$result["function"],當前執行的函數名稱.
258
#$result["content"],加密後的結果.
259
#$result["error"],錯誤訊息陣列.
260
#$result["argu"],使用的參數.
261
#必填參數:
262
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
263
$conf["enCodeStr"]=base64_decode($encodedSessionStr);
264
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時,"md5"較快,"p_hash"適用於密碼加密,"aes256"是對稱式加解密,"qbpwcf"是透過urlencode、json_encode、base64_encode的結果,"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin","gpg"是應用gpg進行加解密,需要先有ID對應的key.
265
$conf["enCodeType"]="gpg";
266
#可省略參數:
267
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
268
#$conf["sha1Raw"]="false";
269
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
270
#$conf["p_hash"]="";
271
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
272
#$conf["keyForAes256"]="";
273
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
274
#$conf["aes256Encode"]="";
275
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
276
#$conf["qbpwcfDecode"]="false";
277
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
278
$conf["gpgDecrypt"]="true";
279
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,該參數必填.
280
$conf["gpgId"]=gnupgId;
281
#參考資料:
282
#sha1=>http://php.net/manual/en/function.sha1.php
283
#md5=>http://php.net/manual/en/function.md5.php
284
#password_hash=>http://php.net/manual/en/function.password-hash.php
285
#password_verify=>http://php.net/manual/en/function.password-verify.php
286
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
287
#備註:
288
#無.
289
$enCodeStr=authenticate::enCodeStr($conf);
290
unset($conf);
291
 
292
#debug
293
#var_dump(__LINE__,$enCodeStr);exit;
294
 
295
#如果執行出錯
296
if($enCodeStr["status"]==="false"){
297
 
298
	#函式說明:
299
	#撰寫log
300
	#回傳結果:
301
	#$result["status"],狀態,"true"或"false".
302
	#$result["error"],錯誤訊息陣列.
303
	#$result["function"],當前函式的名稱.
304
	#$result["argu"],使用的參數.
305
	#必填參數:
306
	#$conf["path"],字串,log檔案的路徑與名稱.
307
	$conf["path"]=$logFile;
308
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
309
	$conf["content"]=$enCodeStr;
310
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
311
	$conf["fileArgu"]=__FILE__;
312
	#可省略參數:
313
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
314
	#$conf["rewrite"]="false";
315
	#參考資料:
316
	#無.
317
	#備註:
318
	#無.
319
	$record=logs::record($conf);
320
	unset($conf);
321
 
322
	#如果寫log失敗
323
	if($record["status"]==="false"){
324
 
325
		#印出json結果
326
		echo json_encode($record);
327
 
328
		}#if end
329
 
330
	#結束執行,回傳錯誤代碼1
331
	exit(1);
332
 
333
	}#if end
334
 
323 liveuser 335
#儲存解密後的 json 
336
$json=$enCodeStr["content"];
317 liveuser 337
 
323 liveuser 338
#debug
339
#var_dump(__LINE__,$json);exit;
317 liveuser 340
 
323 liveuser 341
#解密 json 數值 - end
342
 
343
#取得用於識別資源的id
344
$wsClientId=base64_decode($json->id);
345
 
346
#取得 session 名稱 
347
$sessionNameOnly=base64_decode($json->sId);
348
 
317 liveuser 349
#取得 session 檔案名稱
323 liveuser 350
$sessionName="../.hta-session/sess_".$sessionNameOnly;
317 liveuser 351
 
323 liveuser 352
#取得認證過的信箱
353
$validatedEmail=base64_decode($json->email);
354
 
355
#debug
356
#var_dump(__LINE__,$sessionName,$validatedEmail);exit;
357
 
317 liveuser 358
#檢查 session 的內容是否正確
359
 
360
#函式說明:
361
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
362
#回傳的變數說明:
363
#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
364
#$result["error"],錯誤訊息提示.
365
#$result["warning"],警告訊息.
366
#$result["function"],當前執行的函數名稱.
367
#$result["fileContent"],爲檔案的內容陣列.
368
#$result["lineCount"],爲檔案內容總共的行數.
369
#$result["fullContent"],為檔案的完整內容.
370
#$result["base64data"],為檔案的base64內容.
371
#$result["mimeType"],為檔案的mime type.
372
#必填參數:
373
#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
374
$conf["filePositionAndName"]=$sessionName;
375
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
376
$conf["fileArgu"]=__FILE__;
377
#可省略參數:
378
#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
379
#$conf["web"]="true";
380
#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
381
#$conf["createIfnotExist"]="false";
382
#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
383
#$conf["autoDeleteSpaceOnEachLineStart"]="false";
384
#參考資料:
385
#file(),取得檔案內容的行數.
386
#file=>http:#php.net/manual/en/function.file.php
387
#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
388
#filesize=>http://php.net/manual/en/function.filesize.php
389
#參考資料:
390
#無.
391
#備註:
392
#無.
393
$getFileContent=fileAccess::getFileContent($conf);
394
unset($conf);
395
 
396
#如果無內容
397
if(!isset($getFileContent["fileContent"][0])){
398
 
399
	#函式說明:
400
	#撰寫log
401
	#回傳結果:
402
	#$result["status"],狀態,"true"或"false".
403
	#$result["error"],錯誤訊息陣列.
404
	#$result["function"],當前函式的名稱.
405
	#$result["argu"],使用的參數.
406
	#必填參數:
407
	#$conf["path"],字串,log檔案的路徑與名稱.
408
	$conf["path"]=$logFile;
409
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
410
	$conf["content"]=$getFileContent;
411
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
412
	$conf["fileArgu"]=__FILE__;
413
	#可省略參數:
414
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
415
	#$conf["rewrite"]="false";
416
	#參考資料:
417
	#無.
418
	#備註:
419
	#無.
420
	$record=logs::record($conf);
421
	unset($conf);
422
 
423
	#如果寫log失敗
424
	if($record["status"]==="false"){
425
 
426
		#印出json結果
427
		echo json_encode($record);
428
 
429
		}#if end
430
 
431
	#結束執行,回傳錯誤代碼1
432
	exit(1);
433
 
434
	}#if end
435
 
436
#debug
437
#var_dump(__LINE__,$getFileContent["fileContent"][0]);exit;
438
 
439
#解開 session 並使用之
440
$session_decode=session_decode($getFileContent["fileContent"][0]);
441
 
442
#如果沒有應該要有的內容
443
if(!isset($_SESSION["sendMailAgent"])){
444
 
445
	#函式說明:
446
	#撰寫log
447
	#回傳結果:
448
	#$result["status"],狀態,"true"或"false".
449
	#$result["error"],錯誤訊息陣列.
450
	#$result["function"],當前函式的名稱.
451
	#$result["argu"],使用的參數.
452
	#必填參數:
453
	#$conf["path"],字串,log檔案的路徑與名稱.
454
	$conf["path"]=$logFile;
455
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
456
	$conf["content"]=$_SESSION;
457
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
458
	$conf["fileArgu"]=__FILE__;
459
	#可省略參數:
460
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
461
	#$conf["rewrite"]="false";
462
	#參考資料:
463
	#無.
464
	#備註:
465
	#無.
466
	$record=logs::record($conf);
467
	unset($conf);
468
 
469
	#如果寫log失敗
470
	if($record["status"]==="false"){
471
 
472
		#印出json結果
473
		echo json_encode($record);
474
 
475
		}#if end
476
 
477
	#結束執行,回傳錯誤代碼1
478
	exit(1);
479
 
480
	}#if end
481
 
482
#debug
483
#var_dump($_SESSION);exit;
484
 
485
#如果沒有應該要有的內容
486
if(!isset($_SESSION["sendMailAgent"]["status"])){
487
 
488
	#函式說明:
489
	#撰寫log
490
	#回傳結果:
491
	#$result["status"],狀態,"true"或"false".
492
	#$result["error"],錯誤訊息陣列.
493
	#$result["function"],當前函式的名稱.
494
	#$result["argu"],使用的參數.
495
	#必填參數:
496
	#$conf["path"],字串,log檔案的路徑與名稱.
497
	$conf["path"]=$logFile;
498
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
499
	$conf["content"]=$_SESSION;
500
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
501
	$conf["fileArgu"]=__FILE__;
502
	#可省略參數:
503
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
504
	#$conf["rewrite"]="false";
505
	#參考資料:
506
	#無.
507
	#備註:
508
	#無.
509
	$record=logs::record($conf);
510
	unset($conf);
511
 
512
	#如果寫log失敗
513
	if($record["status"]==="false"){
514
 
515
		#印出json結果
516
		echo json_encode($record);
517
 
518
		}#if end
519
 
520
	#結束執行,回傳錯誤代碼1
521
	exit(1);
522
 
523
	}#if end
524
 
525
#如果尚未記錄成通過email認證
526
if($_SESSION["sendMailAgent"]["status"]==="wait"){
527
 
528
	#如果超過 5 分鐘了
529
	if(time()-$_SESSION["start"]>300){
530
 
531
		#移除session
532
		session_destroy();
533
 
534
		#因為儲存seesion檔案的路徑未修改,因此得手動移除session檔案
535
		unlink($sessionName);
536
 
537
		}#if end
538
 
539
	#更新 session 檔案的內容為已經通過 email 認證
540
	$_SESSION["sendMailAgent"]["status"]="pass";
541
 
542
	#記錄通過 email 認證的時間點
543
	$_SESSION["sendMailAgent"]["passTime"]=time();
544
 
545
	#debug
546
	#var_dump(__LINE__,"seesion 已經更新");
547
 
548
	#debug
549
	#var_dump(__LINE__,"web socket 可以告訴 client 可以填寫表單內容了");
550
 
551
	#產生亂數
552
	#函式說明:
553
	#建立以圖片(PNG格式)呈現的驗證碼.
554
	#回傳的解果:
555
	#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
556
	#$result["error"],錯誤訊息.
557
	#$result["function"],檔前執行的函數名稱.
558
	#$result["randNumberWord"],傳驗證碼的內容.
559
	#$result["imgAddress"],包含src圖片的位置與名稱.
560
	#$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
561
	#必填參數:
562
	#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
563
	$conf["imgAddressAndName"]="/tmp/notExsit.img";
564
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
565
	$conf["fileArgu"]=__FILE__;
566
	#可省略參數:
567
	#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
568
	#$conf["num"]="8";
569
	#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
570
	$conf["disableImg"]="true";
571
	#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
572
	#$conf["imgToData"]="true";
573
	#$conf["class"],字串,圖片要套用的css樣式類別.
574
	#$conf["class"]="";
575
	#$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
576
	#$conf["content"]=array();
577
	#參考資料:
578
	#無.
579
	#備註:
580
	#無.
581
	$validationCode=authenticate::validationCode($conf);
582
	unset($conf);
583
 
584
	#如果執行失敗
585
	if($validationCode["status"]==="false"){
586
 
587
		#函式說明:
588
		#撰寫log
589
		#回傳結果:
590
		#$result["status"],狀態,"true"或"false".
591
		#$result["error"],錯誤訊息陣列.
592
		#$result["function"],當前函式的名稱.
593
		#$result["argu"],使用的參數.
594
		#必填參數:
595
		#$conf["path"],字串,log檔案的路徑與名稱.
596
		$conf["path"]=$logFile;
597
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
598
		$conf["content"]=$validationCode;
599
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
600
		$conf["fileArgu"]=__FILE__;
601
		#可省略參數:
602
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
603
		#$conf["rewrite"]="false";
604
		#參考資料:
605
		#無.
606
		#備註:
607
		#無.
608
		$record=logs::record($conf);
609
		unset($conf);
610
 
611
		#如果寫log失敗
612
		if($record["status"]==="false"){
613
 
614
			#印出json結果
615
			echo json_encode($record);
616
 
617
			}#if end
618
 
619
		#結束執行,回傳錯誤代碼1
620
		exit(1);
621
 
622
		}#if end
623
 
624
	#隨機產生get變數名稱
625
	$getVarName=$validationCode["randNumberWord"];
626
 
627
	#儲存含有亂數get名稱的session名稱
323 liveuser 628
	$sess_str=$getVarName."=".$sessionNameOnly;
317 liveuser 629
 
630
	#加密 $sess_str
631
	#函式說明:
632
	#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
633
	#回傳結果:
634
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
635
	#$result["function"],當前執行的函數名稱.
636
	#$result["content"],加密後的結果.
637
	#$result["error"],錯誤訊息陣列.
638
	#$result["argu"],使用的參數.
639
	#必填參數:
640
	#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
641
	$conf["enCodeStr"]=$sess_str;
642
	#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
643
	$conf["enCodeType"]="gpg";
644
	#可省略參數:
645
	#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
646
	#$conf["sha1Raw"]="false";
647
	#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
648
	#$conf["p_hash"]="";
649
	#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
650
	#$conf["keyForAes256"]="";
651
	#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
652
	#$conf["aes256Encode"]="";
653
	#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
654
	#$conf["qbpwcfDecode"]="false";
655
	#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
323 liveuser 656
	#$conf["gpgDecrypt"]="true";
317 liveuser 657
	#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
658
	#$conf["gpgId"]="";
659
	#參考資料:
660
	#sha1=>http://php.net/manual/en/function.sha1.php
661
	#md5=>http://php.net/manual/en/function.md5.php
662
	#password_hash=>http://php.net/manual/en/function.password-hash.php
663
	#password_verify=>http://php.net/manual/en/function.password-verify.php
664
	#json_decode=>https://www.php.net/manual/en/function.json-decode.php
665
	#備註:
666
	#無.
323 liveuser 667
	$enCodeStr=authenticate::enCodeStr($conf);
668
	unset($conf);
317 liveuser 669
 
323 liveuser 670
	#如果執行失敗
671
	if($enCodeStr["status"]==="false"){
672
 
673
		#函式說明:
674
		#撰寫log
675
		#回傳結果:
676
		#$result["status"],狀態,"true"或"false".
677
		#$result["error"],錯誤訊息陣列.
678
		#$result["function"],當前函式的名稱.
679
		#$result["argu"],使用的參數.
680
		#必填參數:
681
		#$conf["path"],字串,log檔案的路徑與名稱.
682
		$conf["path"]=$logFile;
683
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
684
		$conf["content"]=$enCodeStr;
685
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
686
		$conf["fileArgu"]=__FILE__;
687
		#可省略參數:
688
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
689
		#$conf["rewrite"]="false";
690
		#參考資料:
691
		#無.
692
		#備註:
693
		#無.
694
		$record=logs::record($conf);
695
		unset($conf);
696
 
697
		#如果寫log失敗
698
		if($record["status"]==="false"){
699
 
700
			#印出json結果
701
			echo json_encode($record);
702
 
703
			}#if end
704
 
705
		#結束執行,回傳錯誤代碼1
706
		exit(1);
707
 
708
		}#if end
709
 
710
	#取得訊息接收者的id
711
	$wsRevId=$enCodeStr["content"];
712
 
713
	#產生亂數
714
	#函式說明:
715
	#建立以圖片(PNG格式)呈現的驗證碼.
716
	#回傳的解果:
717
	#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
718
	#$result["error"],錯誤訊息.
719
	#$result["function"],檔前執行的函數名稱.
720
	#$result["randNumberWord"],傳驗證碼的內容.
721
	#$result["imgAddress"],包含src圖片的位置與名稱.
722
	#$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
723
	#必填參數:
724
	#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
725
	$conf["imgAddressAndName"]="/tmp/notExsit.img";
726
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
727
	$conf["fileArgu"]=__FILE__;
728
	#可省略參數:
729
	#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
730
	#$conf["num"]="8";
731
	#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
732
	$conf["disableImg"]="true";
733
	#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
734
	#$conf["imgToData"]="true";
735
	#$conf["class"],字串,圖片要套用的css樣式類別.
736
	#$conf["class"]="";
737
	#$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
738
	#$conf["content"]=array();
739
	#參考資料:
740
	#無.
741
	#備註:
742
	#無.
743
	$validationCode=authenticate::validationCode($conf);
744
	unset($conf);
745
 
746
	#如果執行失敗
747
	if($validationCode["status"]==="false"){
748
 
749
		#函式說明:
750
		#撰寫log
751
		#回傳結果:
752
		#$result["status"],狀態,"true"或"false".
753
		#$result["error"],錯誤訊息陣列.
754
		#$result["function"],當前函式的名稱.
755
		#$result["argu"],使用的參數.
756
		#必填參數:
757
		#$conf["path"],字串,log檔案的路徑與名稱.
758
		$conf["path"]=$logFile;
759
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
760
		$conf["content"]=$validationCode;
761
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
762
		$conf["fileArgu"]=__FILE__;
763
		#可省略參數:
764
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
765
		#$conf["rewrite"]="false";
766
		#參考資料:
767
		#無.
768
		#備註:
769
		#無.
770
		$record=logs::record($conf);
771
		unset($conf);
772
 
773
		#如果寫log失敗
774
		if($record["status"]==="false"){
775
 
776
			#印出json結果
777
			echo json_encode($record);
778
 
779
			}#if end
780
 
781
		#結束執行,回傳錯誤代碼1
782
		exit(1);
783
 
784
		}#if end
785
 
786
	#隨機產生get變數名稱
787
	$getVarName=$validationCode["randNumberWord"];
788
 
789
	#儲存含有亂數get名稱的validatedEmail名稱
790
	$validatedEmail=$getVarName."=".$validatedEmail;
791
 
792
	#函式說明:
793
	#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
794
	#回傳結果:
795
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
796
	#$result["function"],當前執行的函數名稱.
797
	#$result["content"],加密後的結果.
798
	#$result["error"],錯誤訊息陣列.
799
	#$result["argu"],使用的參數.
800
	#必填參數:
801
	#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
802
	$conf["enCodeStr"]=$validatedEmail;
803
	#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
804
	$conf["enCodeType"]="gpg";
805
	#可省略參數:
806
	#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
807
	#$conf["sha1Raw"]="false";
808
	#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
809
	#$conf["p_hash"]="";
810
	#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
811
	#$conf["keyForAes256"]="";
812
	#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
813
	#$conf["aes256Encode"]="";
814
	#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
815
	#$conf["qbpwcfDecode"]="false";
816
	#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
817
	#$conf["gpgDecrypt"]="true";
818
	#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
819
	#$conf["gpgId"]="";
820
	#參考資料:
821
	#sha1=>http://php.net/manual/en/function.sha1.php
822
	#md5=>http://php.net/manual/en/function.md5.php
823
	#password_hash=>http://php.net/manual/en/function.password-hash.php
824
	#password_verify=>http://php.net/manual/en/function.password-verify.php
825
	#json_decode=>https://www.php.net/manual/en/function.json-decode.php
826
	#備註:
827
	#無.
828
	$enCodeStr=authenticate::enCodeStr($conf);
829
	unset($conf);
830
 
831
	#如果執行失敗
832
	if($enCodeStr["status"]==="false"){
833
 
834
		#函式說明:
835
		#撰寫log
836
		#回傳結果:
837
		#$result["status"],狀態,"true"或"false".
838
		#$result["error"],錯誤訊息陣列.
839
		#$result["function"],當前函式的名稱.
840
		#$result["argu"],使用的參數.
841
		#必填參數:
842
		#$conf["path"],字串,log檔案的路徑與名稱.
843
		$conf["path"]=$logFile;
844
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
845
		$conf["content"]=$enCodeStr;
846
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
847
		$conf["fileArgu"]=__FILE__;
848
		#可省略參數:
849
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
850
		#$conf["rewrite"]="false";
851
		#參考資料:
852
		#無.
853
		#備註:
854
		#無.
855
		$record=logs::record($conf);
856
		unset($conf);
857
 
858
		#如果寫log失敗
859
		if($record["status"]==="false"){
860
 
861
			#印出json結果
862
			echo json_encode($record);
863
 
864
			}#if end
865
 
866
		#結束執行,回傳錯誤代碼1
867
		exit(1);
868
 
869
		}#if end
870
 
871
	#取得加密後的含email字串
872
	$validatedEmail=$enCodeStr["content"];
873
 
874
	#產生亂數
875
	#函式說明:
876
	#建立以圖片(PNG格式)呈現的驗證碼.
877
	#回傳的解果:
878
	#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
879
	#$result["error"],錯誤訊息.
880
	#$result["function"],檔前執行的函數名稱.
881
	#$result["randNumberWord"],傳驗證碼的內容.
882
	#$result["imgAddress"],包含src圖片的位置與名稱.
883
	#$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
884
	#必填參數:
885
	#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
886
	$conf["imgAddressAndName"]="/tmp/notExsit.img";
887
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
888
	$conf["fileArgu"]=__FILE__;
889
	#可省略參數:
890
	#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
891
	#$conf["num"]="8";
892
	#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
893
	$conf["disableImg"]="true";
894
	#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
895
	#$conf["imgToData"]="true";
896
	#$conf["class"],字串,圖片要套用的css樣式類別.
897
	#$conf["class"]="";
898
	#$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
899
	#$conf["content"]=array();
900
	#參考資料:
901
	#無.
902
	#備註:
903
	#無.
904
	$validationCode=authenticate::validationCode($conf);
905
	unset($conf);
906
 
907
	#如果執行失敗
908
	if($validationCode["status"]==="false"){
909
 
910
		#函式說明:
911
		#撰寫log
912
		#回傳結果:
913
		#$result["status"],狀態,"true"或"false".
914
		#$result["error"],錯誤訊息陣列.
915
		#$result["function"],當前函式的名稱.
916
		#$result["argu"],使用的參數.
917
		#必填參數:
918
		#$conf["path"],字串,log檔案的路徑與名稱.
919
		$conf["path"]=$logFile;
920
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
921
		$conf["content"]=$validationCode;
922
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
923
		$conf["fileArgu"]=__FILE__;
924
		#可省略參數:
925
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
926
		#$conf["rewrite"]="false";
927
		#參考資料:
928
		#無.
929
		#備註:
930
		#無.
931
		$record=logs::record($conf);
932
		unset($conf);
933
 
934
		#如果寫log失敗
935
		if($record["status"]==="false"){
936
 
937
			#印出json結果
938
			echo json_encode($record);
939
 
940
			}#if end
941
 
942
		#結束執行,回傳錯誤代碼1
943
		exit(1);
944
 
945
		}#if end
946
 
947
	#隨機產生get變數名稱
948
	$getVarName=$validationCode["randNumberWord"];
949
 
950
	#儲存含有亂數get名稱的msg內容
951
	$msg=$getVarName."=authenticated";
952
 
953
	#加密要傳遞的訊息內容
954
	#函式說明:
955
	#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
956
	#回傳結果:
957
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
958
	#$result["function"],當前執行的函數名稱.
959
	#$result["content"],加密後的結果.
960
	#$result["error"],錯誤訊息陣列.
961
	#$result["argu"],使用的參數.
962
	#必填參數:
963
	#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
964
	$conf["enCodeStr"]=$msg;
965
	#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
966
	$conf["enCodeType"]="gpg";
967
	#可省略參數:
968
	#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
969
	#$conf["sha1Raw"]="false";
970
	#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
971
	#$conf["p_hash"]="";
972
	#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
973
	#$conf["keyForAes256"]="";
974
	#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
975
	#$conf["aes256Encode"]="";
976
	#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
977
	#$conf["qbpwcfDecode"]="false";
978
	#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
979
	#$conf["gpgDecrypt"]="true";
980
	#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
981
	#$conf["gpgId"]="";
982
	#參考資料:
983
	#sha1=>http://php.net/manual/en/function.sha1.php
984
	#md5=>http://php.net/manual/en/function.md5.php
985
	#password_hash=>http://php.net/manual/en/function.password-hash.php
986
	#password_verify=>http://php.net/manual/en/function.password-verify.php
987
	#json_decode=>https://www.php.net/manual/en/function.json-decode.php
988
	#備註:
989
	#無.
990
	$enCodeStr=authenticate::enCodeStr($conf);
991
	unset($conf);
992
 
993
	#如果執行失敗
994
	if($enCodeStr["status"]==="false"){
995
 
996
		#函式說明:
997
		#撰寫log
998
		#回傳結果:
999
		#$result["status"],狀態,"true"或"false".
1000
		#$result["error"],錯誤訊息陣列.
1001
		#$result["function"],當前函式的名稱.
1002
		#$result["argu"],使用的參數.
1003
		#必填參數:
1004
		#$conf["path"],字串,log檔案的路徑與名稱.
1005
		$conf["path"]=$logFile;
1006
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1007
		$conf["content"]=$enCodeStr;
1008
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1009
		$conf["fileArgu"]=__FILE__;
1010
		#可省略參數:
1011
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1012
		#$conf["rewrite"]="false";
1013
		#參考資料:
1014
		#無.
1015
		#備註:
1016
		#無.
1017
		$record=logs::record($conf);
1018
		unset($conf);
1019
 
1020
		#如果寫log失敗
1021
		if($record["status"]==="false"){
1022
 
1023
			#印出json結果
1024
			echo json_encode($record);
1025
 
1026
			}#if end
1027
 
1028
		#結束執行,回傳錯誤代碼1
1029
		exit(1);
1030
 
1031
		}#if end
1032
 
1033
	#取得加密後的msg
1034
	$msg=$enCodeStr["content"];
1035
 
324 liveuser 1036
	#產生亂數
1037
	#函式說明:
1038
	#建立以圖片(PNG格式)呈現的驗證碼.
1039
	#回傳的解果:
1040
	#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
1041
	#$result["error"],錯誤訊息.
1042
	#$result["function"],檔前執行的函數名稱.
1043
	#$result["randNumberWord"],傳驗證碼的內容.
1044
	#$result["imgAddress"],包含src圖片的位置與名稱.
1045
	#$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
1046
	#必填參數:
1047
	#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
1048
	$conf["imgAddressAndName"]="/tmp/notExsit.img";
1049
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1050
	$conf["fileArgu"]=__FILE__;
1051
	#可省略參數:
1052
	#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
1053
	#$conf["num"]="8";
1054
	#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
1055
	$conf["disableImg"]="true";
1056
	#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
1057
	#$conf["imgToData"]="true";
1058
	#$conf["class"],字串,圖片要套用的css樣式類別.
1059
	#$conf["class"]="";
1060
	#$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
1061
	#$conf["content"]=array();
1062
	#參考資料:
1063
	#無.
1064
	#備註:
1065
	#無.
1066
	$validationCode=authenticate::validationCode($conf);
1067
	unset($conf);
1068
 
1069
	#如果執行失敗
1070
	if($validationCode["status"]==="false"){
1071
 
1072
		#函式說明:
1073
		#撰寫log
1074
		#回傳結果:
1075
		#$result["status"],狀態,"true"或"false".
1076
		#$result["error"],錯誤訊息陣列.
1077
		#$result["function"],當前函式的名稱.
1078
		#$result["argu"],使用的參數.
1079
		#必填參數:
1080
		#$conf["path"],字串,log檔案的路徑與名稱.
1081
		$conf["path"]=$logFile;
1082
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1083
		$conf["content"]=$validationCode;
1084
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1085
		$conf["fileArgu"]=__FILE__;
1086
		#可省略參數:
1087
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1088
		#$conf["rewrite"]="false";
1089
		#參考資料:
1090
		#無.
1091
		#備註:
1092
		#無.
1093
		$record=logs::record($conf);
1094
		unset($conf);
1095
 
1096
		#如果寫log失敗
1097
		if($record["status"]==="false"){
1098
 
1099
			#印出json結果
1100
			echo json_encode($record);
1101
 
1102
			}#if end
1103
 
1104
		#結束執行,回傳錯誤代碼1
1105
		exit(1);
1106
 
1107
		}#if end
1108
 
1109
	#隨機產生get變數名稱
1110
	$getVarName=$validationCode["randNumberWord"];
1111
 
1112
	#儲存含有亂數get名稱的from數值
1113
	$from=$getVarName."=server";
1114
 
1115
	#加密要傳遞的訊息內容
1116
	#函式說明:
1117
	#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
1118
	#回傳結果:
1119
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1120
	#$result["function"],當前執行的函數名稱.
1121
	#$result["content"],加密後的結果.
1122
	#$result["error"],錯誤訊息陣列.
1123
	#$result["argu"],使用的參數.
1124
	#必填參數:
1125
	#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
1126
	$conf["enCodeStr"]=$from;
1127
	#$conf["enCodeType"],"字串",加密或編碼的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin"與"gpg",8種,"sha1"較耗時;"md5"較快;"p_hash"適用於密碼加密;"aes256"是對稱式加解密;"qbpwcf"是透過先json_encdoe後再urlencode最後再base64_encode後bin2hex的結果;"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin";"gpg"是應用gpg進行加解密,需要先有ID對應的key.
1128
	$conf["enCodeType"]="gpg";
1129
	#可省略參數:
1130
	#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
1131
	#$conf["sha1Raw"]="false";
1132
	#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
1133
	#$conf["p_hash"]="";
1134
	#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
1135
	#$conf["keyForAes256"]="";
1136
	#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
1137
	#$conf["aes256Encode"]="";
1138
	#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
1139
	#$conf["qbpwcfDecode"]="false";
1140
	#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
1141
	#$conf["gpgDecrypt"]="true";
1142
	#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
1143
	#$conf["gpgId"]="";
1144
	#參考資料:
1145
	#sha1=>http://php.net/manual/en/function.sha1.php
1146
	#md5=>http://php.net/manual/en/function.md5.php
1147
	#password_hash=>http://php.net/manual/en/function.password-hash.php
1148
	#password_verify=>http://php.net/manual/en/function.password-verify.php
1149
	#json_decode=>https://www.php.net/manual/en/function.json-decode.php
1150
	#備註:
1151
	#無.
1152
	$enCodeStr=authenticate::enCodeStr($conf);
1153
	unset($conf);
1154
 
1155
	#如果執行失敗
1156
	if($enCodeStr["status"]==="false"){
1157
 
1158
		#函式說明:
1159
		#撰寫log
1160
		#回傳結果:
1161
		#$result["status"],狀態,"true"或"false".
1162
		#$result["error"],錯誤訊息陣列.
1163
		#$result["function"],當前函式的名稱.
1164
		#$result["argu"],使用的參數.
1165
		#必填參數:
1166
		#$conf["path"],字串,log檔案的路徑與名稱.
1167
		$conf["path"]=$logFile;
1168
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1169
		$conf["content"]=$enCodeStr;
1170
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1171
		$conf["fileArgu"]=__FILE__;
1172
		#可省略參數:
1173
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1174
		#$conf["rewrite"]="false";
1175
		#參考資料:
1176
		#無.
1177
		#備註:
1178
		#無.
1179
		$record=logs::record($conf);
1180
		unset($conf);
1181
 
1182
		#如果寫log失敗
1183
		if($record["status"]==="false"){
1184
 
1185
			#印出json結果
1186
			echo json_encode($record);
1187
 
1188
			}#if end
1189
 
1190
		#結束執行,回傳錯誤代碼1
1191
		exit(1);
1192
 
1193
		}#if end
1194
 
1195
	#取得加密後的from
1196
	$from=$enCodeStr["content"];
1197
 
317 liveuser 1198
	#初始化要傳遞的json字串
1199
	$json=array();
1200
 
324 liveuser 1201
	#設置傳送訊息的來源
1202
	$json["from"]=base64_encode($from);
1203
 
317 liveuser 1204
	#設置接收訊息的id(加密過)
323 liveuser 1205
	$json["to"]=base64_encode($wsRevId);
317 liveuser 1206
 
323 liveuser 1207
	#設置要傳遞加密後訊息的內容
1208
	$json["content"]=base64_encode($msg);
317 liveuser 1209
 
323 liveuser 1210
	#設置通過認證加密後的email
1211
	$json["email"]=base64_encode($validatedEmail);
1212
 
1213
	#設置識別資訊的id
1214
	$json["id"]=$wsClientId;
1215
 
1216
	#debug
1217
	#var_dump(__LINE__,$json,json_encode($json));
1218
 
317 liveuser 1219
	#web socket 告訴 client 可以填寫表單內容了.
1220
	#函式說明:
1221
	#webSocket的javaScript用戶端
1222
	#回傳結果:
1223
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1224
	#$result["error"],錯誤訊息陣列.
1225
	#$resutl["function"],當前執行的涵式名稱.
1226
	#$result["argu"],所使用的參數.
1227
	#$result["content"],語法.
1228
	#必填參數:
1229
	#$conf["url"],字串要拜訪的web socket,請省略"ws://".
1230
	$conf["url"]=system_sendMailAgent_ws_domain.system_sendMailAgent_path;
1231
	#可省略參數:
1232
	#$conf["entry"],字串,是否要用加密的wss,預設為"false",代表用ws,若為"true"則為wss.
1233
	$conf["entry"]="true";
1234
	#$conf["connVar"],字串,用來儲存webSocket連線的物件名稱,預設為"conn".
1235
	#$conf["connVar"]="conn";
1236
	#$conf["sendThenClose"],字串,是否要傳遞訊息後關閉連線,預設為"false",代表不要要;反之為"true".
1237
	$conf["sendThenClose"]="true";
1238
	#$conf["oneTimeMsg"],字串,要傳遞的一次訊息內容,預設不指定.
1239
	$conf["oneTimeMsg"]=json_encode($json);
1240
	#參考資料:
1241
	#無.
1242
	#備註:
1243
	#無.
323 liveuser 1244
	$client=webSock::client($conf);
317 liveuser 1245
	unset($conf);
1246
 
1247
	#如果執行異常
1248
	if($client["status"]==="false"){
1249
 
1250
		#函式說明:
1251
		#撰寫log
1252
		#回傳結果:
1253
		#$result["status"],狀態,"true"或"false".
1254
		#$result["error"],錯誤訊息陣列.
1255
		#$result["function"],當前函式的名稱.
1256
		#$result["argu"],使用的參數.
1257
		#必填參數:
1258
		#$conf["path"],字串,log檔案的路徑與名稱.
1259
		$conf["path"]=$logFile;
1260
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1261
		$conf["content"]=$client;
1262
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1263
		$conf["fileArgu"]=__FILE__;
1264
		#可省略參數:
1265
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1266
		#$conf["rewrite"]="false";
1267
		#參考資料:
1268
		#無.
1269
		#備註:
1270
		#無.
1271
		$record=logs::record($conf);
1272
		unset($conf);
1273
 
1274
		#如果寫log失敗
1275
		if($record["status"]==="false"){
1276
 
1277
			#印出json結果
1278
			echo json_encode($record);
1279
 
1280
			}#if end
1281
 
1282
		#結束執行,回傳錯誤代碼1
1283
		exit(1);
1284
 
1285
		}#if end
1286
 
1287
	#印出語法
1288
	echo $client["content"];
1289
 
1290
	#移除session
1291
	session_destroy();
1292
 
1293
	#因為儲存seesion檔案的路徑未修改,因此得手動移除session檔案
1294
	unlink($sessionName);
1295
 
1296
	#結束執行
1297
	exit;
1298
 
1299
	}#if end
1300
 
1301
#debug
1302
#var_dump(__LINE__,$_SESSION);
1303
 
1304
#例外狀況
1305
exit(1);