Subversion Repositories php-qbpwcf

Rev

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

Rev 317 Rev 323
Line 94... Line 94...
94
#備註:
94
#備註:
95
#pipe要用''包住,才會被解析,例如'|'、'>'、'>>'.
95
#pipe要用''包住,才會被解析,例如'|'、'>'、'>>'.
96
$getArgu=cmd::getArgu($conf);
96
$getArgu=cmd::getArgu($conf);
97
unset($conf);
97
unset($conf);
98
 
98
 
-
 
99
#debug
-
 
100
#var_dump(__LINE__,$getArgu);exit;
-
 
101
 
99
#如果執行失敗
102
#如果執行失敗
100
if($getArgu["status"]==="false"){
103
if($getArgu["status"]==="false"){
101
 
104
 
102
	#函式說明:
105
	#函式說明:
103
	#撰寫log
106
	#撰寫log
Line 236... Line 239...
236
	#結束執行,回傳錯誤代碼1
239
	#結束執行,回傳錯誤代碼1
237
	exit(1);
240
	exit(1);
238
 
241
 
239
	}#if end
242
	}#if end
240
 
243
 
241
#取得未解密的 session 數值
244
#取得未解密的字串
242
$encodedSessionStr=$inspectKey["content"]["val"][0];
245
$encodedSessionStr=$inspectKey["content"]["val"][0];
243
 
246
 
244
#debug
247
#debug
245
#var_dump(__LINE__,$encodedSessionStr);exit;
248
#var_dump(__LINE__,$encodedSessionStr,base64_decode($encodedSessionStr));exit;
246
 
249
 
247
#解密 seesion 數值 - start
250
#解密 json 數值 - start
248
 
251
 
249
#用gpg解密session數值
252
#用gpg解密
250
#函式說明:
253
#函式說明:
251
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
254
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
252
#回傳結果:
255
#回傳結果:
253
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
256
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
254
#$result["function"],當前執行的函數名稱.
257
#$result["function"],當前執行的函數名稱.
Line 327... Line 330...
327
	#結束執行,回傳錯誤代碼1
330
	#結束執行,回傳錯誤代碼1
328
	exit(1);
331
	exit(1);
329
 
332
 
330
	}#if end
333
	}#if end
331
 
334
 
332
#儲存解密後的 seesion 名稱
335
#儲存解密後的 json 
333
$sessionName=$enCodeStr["content"];
336
$json=$enCodeStr["content"];
-
 
337
 
-
 
338
#debug
-
 
339
#var_dump(__LINE__,$json);exit;
-
 
340
 
-
 
341
#解密 json 數值 - end
-
 
342
 
-
 
343
#取得用於識別資源的id
-
 
344
$wsClientId=base64_decode($json->id);
334
 
345
 
335
#解密 seesion 數值 - end
346
#取得 session 名稱 
-
 
347
$sessionNameOnly=base64_decode($json->sId);
336
 
348
 
337
#取得 session 檔案名稱
349
#取得 session 檔案名稱
338
$sessionName="../.hta-session/sess_".$sessionName;
350
$sessionName="../.hta-session/sess_".$sessionNameOnly;
-
 
351
 
-
 
352
#取得認證過的信箱
-
 
353
$validatedEmail=base64_decode($json->email);
-
 
354
 
-
 
355
#debug
-
 
356
#var_dump(__LINE__,$sessionName,$validatedEmail);exit;
339
 
357
 
340
#檢查 session 的內容是否正確
358
#檢查 session 的內容是否正確
341
 
359
 
342
#函式說明:
360
#函式說明:
343
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
361
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
Line 605... Line 623...
605
 
623
 
606
	#隨機產生get變數名稱
624
	#隨機產生get變數名稱
607
	$getVarName=$validationCode["randNumberWord"];
625
	$getVarName=$validationCode["randNumberWord"];
608
 
626
 
609
	#儲存含有亂數get名稱的session名稱
627
	#儲存含有亂數get名稱的session名稱
610
	$sess_str=$getVarName."=".$sessionName;
628
	$sess_str=$getVarName."=".$sessionNameOnly;
611
 
629
 
612
	#加密 $sess_str
630
	#加密 $sess_str
613
	#函式說明:
631
	#函式說明:
614
	#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
632
	#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
615
	#回傳結果:
633
	#回傳結果:
Line 633... Line 651...
633
	#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
651
	#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
634
	#$conf["aes256Encode"]="";
652
	#$conf["aes256Encode"]="";
635
	#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
653
	#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
636
	#$conf["qbpwcfDecode"]="false";
654
	#$conf["qbpwcfDecode"]="false";
637
	#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
655
	#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
656
	#$conf["gpgDecrypt"]="true";
-
 
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
	#無.
-
 
667
	$enCodeStr=authenticate::enCodeStr($conf);
-
 
668
	unset($conf);
-
 
669
 
-
 
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;
638
	$conf["gpgDecrypt"]="true";
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";
639
	#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
980
	#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,要使用的gpg id,預設為gnupgId.
640
	#$conf["gpgId"]="";
981
	#$conf["gpgId"]="";
641
	#參考資料:
982
	#參考資料:
642
	#sha1=>http://php.net/manual/en/function.sha1.php
983
	#sha1=>http://php.net/manual/en/function.sha1.php
643
	#md5=>http://php.net/manual/en/function.md5.php
984
	#md5=>http://php.net/manual/en/function.md5.php
644
	#password_hash=>http://php.net/manual/en/function.password-hash.php
985
	#password_hash=>http://php.net/manual/en/function.password-hash.php
645
	#password_verify=>http://php.net/manual/en/function.password-verify.php
986
	#password_verify=>http://php.net/manual/en/function.password-verify.php
646
	#json_decode=>https://www.php.net/manual/en/function.json-decode.php
987
	#json_decode=>https://www.php.net/manual/en/function.json-decode.php
647
	#備註:
988
	#備註:
648
	#無.
989
	#無.
649
	$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
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的格式寫入.
650
	unset($conf["authenticate::enCodeStr"]);
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"];
651
 
1035
 
652
	#初始化要傳遞的json字串
1036
	#初始化要傳遞的json字串
653
	$json=array();
1037
	$json=array();
654
	
1038
	
655
	#設置接收訊息的id(加密過)
1039
	#設置接收訊息的id(加密過)
656
	$json["to"]=$enCodeStr["content"];
1040
	$json["to"]=base64_encode($wsRevId);
-
 
1041
	
-
 
1042
	#設置要傳遞加密後訊息的內容
-
 
1043
	$json["content"]=base64_encode($msg);
-
 
1044
 
-
 
1045
	#設置通過認證加密後的email
-
 
1046
	$json["email"]=base64_encode($validatedEmail);
657
	
1047
	
658
	#設置要傳遞的訊息內容
1048
	#設置識別資訊的id
659
	$json["content"]="authenticated";
1049
	$json["id"]=$wsClientId;
-
 
1050
	
-
 
1051
	#debug
-
 
1052
	#var_dump(__LINE__,$json,json_encode($json));
660
 
1053
 
661
	#web socket 告訴 client 可以填寫表單內容了.
1054
	#web socket 告訴 client 可以填寫表單內容了.
662
	#函式說明:
1055
	#函式說明:
663
	#webSocket的javaScript用戶端
1056
	#webSocket的javaScript用戶端
664
	#回傳結果:
1057
	#回傳結果:
Line 681... Line 1074...
681
	$conf["oneTimeMsg"]=json_encode($json);
1074
	$conf["oneTimeMsg"]=json_encode($json);
682
	#參考資料:
1075
	#參考資料:
683
	#無.
1076
	#無.
684
	#備註:
1077
	#備註:
685
	#無.
1078
	#無.
686
	$client=webSocket::client($conf);
1079
	$client=webSock::client($conf);
687
	unset($conf);
1080
	unset($conf);
688
	
1081
	
689
	#如果執行異常
1082
	#如果執行異常
690
	if($client["status"]==="false"){
1083
	if($client["status"]==="false"){
691
	
1084