Subversion Repositories php-qbpwcf

Rev

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

Rev 317 Rev 323
Line 89... Line 89...
89
session_start();
89
session_start();
90
 
90
 
91
#取得session id
91
#取得session id
92
$sId=session_id();
92
$sId=session_id();
93
 
93
 
-
 
94
#debug
-
 
95
#var_dump(__LINE__,$sId);exit;
-
 
96
 
94
#函式說明:
97
#函式說明:
95
#依照OPTIONS的要求,判斷條件,給予允許呼叫的header。
98
#依照OPTIONS的要求,判斷條件,給予允許呼叫的header。
96
#回傳結果:
99
#回傳結果:
97
#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
100
#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
98
#$result["function"],當前執行的函數名稱.
101
#$result["function"],當前執行的函數名稱.
Line 184... Line 187...
184
#$conf["ignore"]=字串陣列,如果要接收的變數名稱與該陣列其一元素一樣,則不放進要回傳的變數裏面.
187
#$conf["ignore"]=字串陣列,如果要接收的變數名稱與該陣列其一元素一樣,則不放進要回傳的變數裏面.
185
#$conf["ignore"]=array();
188
#$conf["ignore"]=array();
186
#$conf["correctCharacter"]=,字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設爲要進行處理.
189
#$conf["correctCharacter"]=,字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設爲要進行處理.
187
$conf["correctCharacter"]="false";
190
$conf["correctCharacter"]="false";
188
#$conf["checkedVarName"],字串陣列,為檢查是否有接收到哪些變數.
191
#$conf["checkedVarName"],字串陣列,為檢查是否有接收到哪些變數.
189
$conf["checkedVarName"]=array("sid","mail");
192
$conf["checkedVarName"]=array("sid","mail","id");
190
#$conf["canBeEmptyString"],字串,用$conf["checkedVarName"]指定接收的變數名稱陣列,若接收到的內容為空字串是否算有接收到內容,預設為"false","true"代表接收到的內容可以為空字串,"false"代表接收到的內容不可以為空字串.
193
#$conf["canBeEmptyString"],字串,用$conf["checkedVarName"]指定接收的變數名稱陣列,若接收到的內容為空字串是否算有接收到內容,預設為"false","true"代表接收到的內容可以為空字串,"false"代表接收到的內容不可以為空字串.
191
#$conf["canBeEmptyString"]="false";
194
#$conf["canBeEmptyString"]="false";
192
#$conf["sessionNameArray"],陣列,若存在則代表若沒有從表單取得變數,則從session變數中取得內容,每個元素代表每個表單變數對應的session名稱,若不是要改用session方式取得變數內容的變數,請輸入null,數量請跟$conf["checkedVarName"]參數一致.
195
#$conf["sessionNameArray"],陣列,若存在則代表若沒有從表單取得變數,則從session變數中取得內容,每個元素代表每個表單變數對應的session名稱,若不是要改用session方式取得變數內容的變數,請輸入null,數量請跟$conf["checkedVarName"]參數一致.
193
#$conf["sessionNameArray"]=array("sendMailAgentAPIkey");
196
#$conf["sessionNameArray"]=array("sendMailAgentAPIkey");
194
#$conf["unsetSessionArray"],陣列,與$conf["sessionNameArray"]對應的元素,是否要接收到變數後就卸除,"true"代表要卸除,"false"代表不要卸除.
197
#$conf["unsetSessionArray"],陣列,與$conf["sessionNameArray"]對應的元素,是否要接收到變數後就卸除,"true"代表要卸除,"false"代表不要卸除.
Line 281... Line 284...
281
	#結束執行,回傳錯誤代碼1
284
	#結束執行,回傳錯誤代碼1
282
	exit(1);
285
	exit(1);
283
 
286
 
284
	}#if end
287
	}#if end
285
 
288
 
-
 
289
#儲存收到用於識別資訊資源的id
-
 
290
$wsClientId=$responseMultiInputDataSecurityEnhance["inputDataContent"]["id"];
-
 
291
 
286
#debug
292
#debug
287
#var_dump(__LINE__,$responseMultiInputDataSecurityEnhance);
293
#var_dump(__LINE__,$responseMultiInputDataSecurityEnhance);
288
 
294
 
289
#儲存收到的 session id
295
#儲存收到的 session id
290
$recvSid=$responseMultiInputDataSecurityEnhance["inputDataContent"]["sid"];
296
$recvSid=$responseMultiInputDataSecurityEnhance["inputDataContent"]["sid"];
Line 912... Line 918...
912
#$result["content"],加密後的結果.
918
#$result["content"],加密後的結果.
913
#$result["error"],錯誤訊息陣列.
919
#$result["error"],錯誤訊息陣列.
914
#$result["argu"],使用的參數.
920
#$result["argu"],使用的參數.
915
#必填參數:
921
#必填參數:
916
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
922
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
917
$conf["enCodeStr"]=$sId;
923
$conf["enCodeStr"]=array("sId"=>base64_encode($sId),"email"=>base64_encode($receiverMail),"id"=>base64_encode($wsClientId));
918
#$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.
924
#$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.
919
$conf["enCodeType"]="gpg";
925
$conf["enCodeType"]="gpg";
920
#可省略參數:
926
#可省略參數:
921
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
927
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
922
#$conf["sha1Raw"]="false";
928
#$conf["sha1Raw"]="false";
Line 981... Line 987...
981
	#結束執行,回傳錯誤代碼1
987
	#結束執行,回傳錯誤代碼1
982
	exit(1);
988
	exit(1);
983
 
989
 
984
	}#if end
990
	}#if end
985
	
991
	
986
#debug
-
 
987
#var_dump(__LINE__,strlen($enCodeStr["content"]),strlen(base64_encode($enCodeStr["content"])),base64_encode($enCodeStr["content"]));
-
 
988
 
-
 
989
#gpg加密後的內容為2元碼,因此要透過base64_encode為ASCII
992
#gpg加密後的內容為2元碼,因此要透過base64_encode為ASCII
990
$enCodeStr["content"]=base64_encode($enCodeStr["content"]);
993
$enCodeStr["content"]=base64_encode($enCodeStr["content"]);
991
 
994
 
992
#要作為get變數的數值,因此要 urlencode
995
#要作為get變數的數值,因此要 urlencode
993
$enCodeStr["content"]=urlencode($enCodeStr["content"]);
996
$enCodeStr["content"]=urlencode($enCodeStr["content"]);
994
 
997
 
995
#設置get變數,數值為加密後session id字串
998
#設置get變數,數值為加密後session id跟email字串
996
$encodedGetVar=$getVarName."=".$enCodeStr["content"];
999
$encodedGetVar=$getVarName."=".$enCodeStr["content"];
997
 
1000
 
998
#函式說明:
1001
#函式說明:
999
#使用 php-pear-smtp 來透過SMTP伺服器寄信.
1002
#使用 php-pear-smtp 來透過SMTP伺服器寄信.
1000
#回傳結果:
1003
#回傳結果:
Line 1089... Line 1092...
1089
 
1092
 
1090
	#結束執行,回傳錯誤代碼1
1093
	#結束執行,回傳錯誤代碼1
1091
	exit(1);
1094
	exit(1);
1092
 
1095
 
1093
	}#if end
1096
	}#if end
-
 
1097
	
-
 
1098
#debug
-
 
1099
#var_dump($pear_smtp_send);exit;
1094
 
1100
 
1095
#設置準備驗證 email 時間點 的 session
1101
#設置準備驗證 email 時間點 的 session
1096
$_SESSION["sendMailAgent"]["mailStart"]=time();
1102
$_SESSION["sendMailAgent"]["mailStart"]=time();
1097
 
1103
 
1098
#設置當前狀態為 "wait" 代表尚未被 web socket 接收與驗證
1104
#設置當前狀態為 "wait" 代表尚未被 web socket 接收與驗證