Subversion Repositories php-qbpwcf

Rev

Rev 317 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 317 Rev 326
Line 77... Line 77...
77
require_once("allInOneForJson.php");
77
require_once("allInOneForJson.php");
78
 
78
 
79
#建議的log位置
79
#建議的log位置
80
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
80
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
81
 
81
 
82
#關閉既有session
-
 
83
session_abort();
-
 
84
 
-
 
85
#設置session儲存位置
-
 
86
session_save_path(".hta-session");
-
 
87
 
-
 
88
#啟動 session
-
 
89
session_start();
-
 
90
 
-
 
91
#記錄開始時間
-
 
92
$_SESSION["start"]=time();
-
 
93
 
-
 
94
#取得session id
-
 
95
$sId=session_id();
-
 
96
 
-
 
97
#函式說明:
-
 
98
#依照OPTIONS的要求,判斷條件,給予允許呼叫的header。
-
 
99
#回傳結果:
-
 
100
#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
-
 
101
#$result["function"],當前執行的函數名稱.
-
 
102
#$result["error"],錯誤訊息陣列.
-
 
103
#$result["content"],回傳結果.
-
 
104
#$result["content"]["receivedHeader"],陣列,收到的header
-
 
105
#$result["content"]["sendedHeader"],陣列,要送出的header.
-
 
106
#必填參數:
-
 
107
#無
-
 
108
#可省略參數:
-
 
109
#$conf["allowDomain"],陣列變數,代表允許的來源domain name.
-
 
110
#$conf["allowDomain"]=array();
-
 
111
#$conf["allowMethod"],陣列變數,代表允許的要求方法.
-
 
112
#$conf["allowMethod"]=array();
-
 
113
#$conf["allowHeader"],陣列變數,代表要允許的header.
-
 
114
#$conf["allowHeader"]=array();
-
 
115
#參考資料:
-
 
116
#https://www.php.net/manual/en/function.header-remove.php
-
 
117
#https://www.php.net/manual/en/function.http-response-code.php
-
 
118
#備註:
-
 
119
#無.
-
 
120
$conf=array();
-
 
121
$accessControl=header::accessControl($conf);
-
 
122
unset($conf);
-
 
123
 
-
 
124
#如果執行失敗
-
 
125
if($accessControl["status"]==="false"){
-
 
126
 
-
 
127
	#函式說明:
-
 
128
	#撰寫log
-
 
129
	#回傳結果:
-
 
130
	#$result["status"],狀態,"true"或"false".
-
 
131
	#$result["error"],錯誤訊息陣列.
-
 
132
	#$result["function"],當前函式的名稱.
-
 
133
	#$result["argu"],使用的參數.
-
 
134
	#必填參數:
-
 
135
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
136
	$conf["path"]=$logFile;
-
 
137
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
138
	$conf["content"]=$accessControl;
-
 
139
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
140
	$conf["fileArgu"]=__FILE__;
-
 
141
	#可省略參數:
-
 
142
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
143
	#$conf["rewrite"]="false";
-
 
144
	#參考資料:
-
 
145
	#無.
-
 
146
	#備註:
-
 
147
	#無.
-
 
148
	$record=logs::record($conf);
-
 
149
	unset($conf);
-
 
150
 
-
 
151
	#如果寫log失敗
-
 
152
	if($record["status"]==="false"){
-
 
153
 
-
 
154
		#印出json結果
-
 
155
		echo json_encode($record);
-
 
156
 
-
 
157
		}#if end
-
 
158
 
-
 
159
	#結束執行,回傳錯誤代碼1
-
 
160
	exit(1);
-
 
161
 
-
 
162
	}#if end
-
 
163
 
-
 
164
#函式說明:
-
 
165
#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
-
 
166
#回傳結果:
-
 
167
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
-
 
168
#$result["error"],錯誤訊息陣列.
-
 
169
#$resutl["function"],當前執行的函式名稱.
-
 
170
#$result["warning"],警告訊息陣列.
-
 
171
#$result["passed"],是否有皆收到全部該接收到的變數,若有設定$conf["checkedVarName"]的話,執行正常後會回傳該結果。
-
 
172
#$result["lostVarName"],沒有皆收到的變數名稱陣列
-
 
173
#$result["inputDataContent"],所接收的參數陣列.
-
 
174
#$result["inputDataContent"]["變數名稱"],所接收變數的內容.
-
 
175
#$result["inputDataCount"],從表單總共接收到幾個元素.
-
 
176
#$result["HTTP_REFERER"],前一頁的網址,null代表不存在.
-
 
177
#必填參數:
-
 
178
#$conf["method"],字串,傳送過來的資料是用"post/POST"還是"get/GET"?
-
 
179
$conf["method"]="POST";
-
 
180
#可省略參數:
-
 
181
#$conf["allowGet"],字串,是否要允許 get 傳值,"true",代表允許;"false" ,代表不允許,預設爲不允許.
-
 
182
#$conf["allowGet"]="true";
-
 
183
#$conf["limitPrePage"],字串陣列,是否要限定前一頁的網址為哪些,才能接收內容,不符合則轉址.
-
 
184
#$conf["limitPrePage"]=array("");
-
 
185
#$conf["transferLocation"],字串,遇到get傳值,或前一個頁面不符合要求時要轉址到的頁面,預設爲資安素養網"https://isafe.moe.edu.tw/"
-
 
186
#$conf["transferLocation"]="";
-
 
187
#$conf["ignore"]=字串陣列,如果要接收的變數名稱與該陣列其一元素一樣,則不放進要回傳的變數裏面.
-
 
188
#$conf["ignore"]=array();
-
 
189
#$conf["correctCharacter"]=,字串,如果爲"false",則不處理可能導致網頁出問題的字串,預設爲要進行處理.
-
 
190
#$conf["correctCharacter"]="false";
-
 
191
#$conf["checkedVarName"],字串陣列,為檢查是否有接收到哪些變數.
-
 
192
$conf["checkedVarName"]=array("email");
-
 
193
#$conf["canBeEmptyString"],字串,用$conf["checkedVarName"]指定接收的變數名稱陣列,若接收到的內容為空字串是否算有接收到內容,預設為"false","true"代表接收到的內容可以為空字串,"false"代表接收到的內容不可以為空字串.
-
 
194
#$conf["canBeEmptyString"]="false";
-
 
195
#$conf["sessionNameArray"],陣列,若存在則代表若沒有從表單取得變數,則從session變數中取得內容,每個元素代表每個表單變數對應的session名稱,若不是要改用session方式取得變數內容的變數,請輸入null,數量請跟$conf["checkedVarName"]參數一致.
82
#取得用戶端資訊
196
#$conf["sessionNameArray"]=array("sendMailAgentAPIkey");
-
 
197
#$conf["unsetSessionArray"],陣列,與$conf["sessionNameArray"]對應的元素,是否要接收到變數後就卸除,"true"代表要卸除,"false"代表不要卸除.
-
 
198
#$conf["unsetSessionArray"]=array("true");
-
 
199
#$conf["recaptcha_url"],字串,有內容代表要檢查有無透過recaptcha於特定頁面網址認證過.
-
 
200
#$conf["recaptcha_url"]="";
-
 
201
#參考資料:
-
 
202
#foreach 的用法 -> http://php.net/manual/en/control-structures.foreach.php
-
 
203
#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
-
 
204
#備註:
-
 
205
#表單變數的名稱若含有「.」,則會變成「-」。
-
 
206
$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf);
-
 
207
unset($conf);
-
 
208
 
-
 
209
#如果執行失敗
-
 
210
if($responseMultiInputDataSecurityEnhance["status"]==="false"){
-
 
211
 
-
 
212
	#函式說明:
-
 
213
	#撰寫log
-
 
214
	#回傳結果:
-
 
215
	#$result["status"],狀態,"true"或"false".
-
 
216
	#$result["error"],錯誤訊息陣列.
-
 
217
	#$result["function"],當前函式的名稱.
-
 
218
	#$result["argu"],使用的參數.
-
 
219
	#必填參數:
-
 
220
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
221
	$conf["path"]=$logFile;
-
 
222
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
223
	$conf["content"]=$accessControl;
-
 
224
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
225
	$conf["fileArgu"]=__FILE__;
-
 
226
	#可省略參數:
-
 
227
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
228
	#$conf["rewrite"]="false";
-
 
229
	#參考資料:
-
 
230
	#無.
-
 
231
	#備註:
-
 
232
	#無.
-
 
233
	$record=logs::record($conf);
-
 
234
	unset($conf);
-
 
235
 
-
 
236
	#如果寫log失敗
-
 
237
	if($record["status"]==="false"){
-
 
238
 
-
 
239
		#印出json結果
-
 
240
		echo json_encode($record);
-
 
241
 
-
 
242
		}#if end
-
 
243
 
-
 
244
	#結束執行,回傳錯誤代碼1
-
 
245
	exit(1);
-
 
246
 
-
 
247
	}#if end
-
 
248
 
-
 
249
#如果驗證失敗
-
 
250
if($responseMultiInputDataSecurityEnhance["passed"]==="false"){
-
 
251
 
-
 
252
	#函式說明:
-
 
253
	#撰寫log
-
 
254
	#回傳結果:
-
 
255
	#$result["status"],狀態,"true"或"false".
-
 
256
	#$result["error"],錯誤訊息陣列.
-
 
257
	#$result["function"],當前函式的名稱.
-
 
258
	#$result["argu"],使用的參數.
-
 
259
	#必填參數:
-
 
260
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
261
	$conf["path"]=$logFile;
-
 
262
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
263
	$conf["content"]=$accessControl;
-
 
264
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
265
	$conf["fileArgu"]=__FILE__;
-
 
266
	#可省略參數:
-
 
267
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
268
	#$conf["rewrite"]="false";
-
 
269
	#參考資料:
-
 
270
	#無.
-
 
271
	#備註:
-
 
272
	#無.
-
 
273
	$record=logs::record($conf);
-
 
274
	unset($conf);
-
 
275
 
-
 
276
	#如果寫log失敗
-
 
277
	if($record["status"]==="false"){
-
 
278
 
-
 
279
		#印出json結果
-
 
280
		echo json_encode($record);
-
 
281
 
-
 
282
		}#if end
-
 
283
 
-
 
284
	#結束執行,回傳錯誤代碼1
-
 
285
	exit(1);
-
 
286
 
-
 
287
	}#if end
-
 
288
 
-
 
289
#提供驗證email服務的doamin
-
 
290
$domain="silverblue-guest.qbpwcf.org";
-
 
291
 
-
 
292
#到驗證email服務的路徑
-
 
293
$path="/php-qbpwcf-devel/";
-
 
294
 
-
 
295
#函式說明:
83
#函式說明:
296
#建立以圖片(PNG格式)呈現的驗證碼.
84
#取得用戶端的資訊,並依據需要寫入到資料表裡面
297
#回傳的解果:
85
#回傳的結果:
298
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
86
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
299
#$result["error"],錯誤訊息.
87
#$result["error"],錯誤訊息.
300
#$result["function"],檔前執行的函數名稱.
88
#$result["function"],檔前執行的函數名稱.
-
 
89
#$result["mode"],當前的模式是"cmd"還是"web".
-
 
90
#$result["userBrowserType"],爲使用者的瀏覽器資訊
301
#$result["randNumberWord"],傳驗證碼的內容.
91
#$result["userIp"],爲使用者的IP
302
#$result["imgAddress"],包含src圖片的位置與名稱.
92
#$result["serverIp"],為伺服器的IP
303
#$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
93
#$result["server_name"],伺服器的 domain name
304
#必填參數:
94
#$result["scheme"],通訊協定
-
 
95
#$result["serverPort"],伺服器給對外下載網頁的port
-
 
96
#$result["requestUri"],爲使用者要求的網址/php檔案.
-
 
97
#$result["requestUriFull"],為使用者要求的完整網址/php檔案路徑.
-
 
98
#$result["clientRequestIP"],用戶端要求的ip與port
305
#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
99
#$result["username"],爲使用者目前的帳戶,若爲""則表示尚未登入成功
-
 
100
#$result["phpUser"],運行該php的使用者帳戶.若為空字串則代表非使用者直接觸發.
-
 
101
#$result["phpUserType"],運行該php的使用者帳戶類型,可能有"regular(no wheel member)","wheel(can use sudo)","intrinsic(root)","system(qemu,apache,...)".
306
$conf["imgAddressAndName"]="/tmp/notExsit.img";
102
#$result["header"],接收到的 header 陣列.
-
 
103
#$result["body"],接收到的 body 字串.
-
 
104
#必填參數:
307
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
105
#$conf["getAccount"],字串,是否要取得帳號,"true"代表要;"false"代表不要.
308
$conf["fileArgu"]=__FILE__;
106
$conf["getAccount"]="false";
309
#可省略參數:
107
#可省略參數:
310
#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
108
#$conf["accountVar"],字串,帳號儲存在哪個變數裏面,預設爲$_SESSION["username"].
311
#$conf["num"]="8";
109
#$conf["accountVar"]=$_SESSION["username"];
312
#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
110
#$conf["saveToDb"],字串,是否要除儲存到資料庫,"true"為要儲存",預設為"false"不儲存.
313
$conf["disableImg"]="true";
111
#$conf["saveToDb"]="true";
314
#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
112
#$conf["dbAddress"],字串,爲mysql/mariadb server的位置,若saveToDb設為"true",則該參數為必填.
-
 
113
#$conf["dbAddress"]=$dbAddress;
-
 
114
#$conf["dbAccount"],字串,爲用於連入mysql/mariadb server時要使用的帳號,若saveToDb設為"true",則該參數為必填.
315
#$conf["imgToData"]="true";
115
#$conf["dbAccount"]=$dbAccount;
316
#$conf["class"],字串,圖片要套用的css樣式類別.
116
#$conf["dbName"],字串,要選取的資料庫名稱,若saveToDb設為"true",則該參數為必填.
317
#$conf["class"]="";
117
#$conf["dbName"]=$dbName;
-
 
118
#$conf["tableName"],字串,爲要插入資料的資料表名稱,若saveToDb設為"true",則該參數為必填.
-
 
119
#$conf["tableName"]="visitorInfo";
318
#$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
120
#$conf["columnName"],字串陣列,爲資料表的項目名稱,例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);寫入的資料依序為,使用者帳戶、瀏覽器資訊、使用者IP、觀看的網址、當時的時間.若saveToDb設為"true",則該參數為必填.
-
 
121
#$conf["columnName"]=array("username","userWebBrowser","userIp","requestUri","systemDateAndTime");
-
 
122
#$conf["dbPassword"],字串,爲連線到mysql/mariadb server時要使用的密碼,可省略,若省略則代表不使用密碼.
319
#$conf["content"]=array();
123
#$conf["dbPassword"]=$dbPassword;
320
#參考資料:
124
#參考資料:
321
#無.
-
 
-
 
125
#$_SERVER=>http://php.net/manual/zh/reserved.variables.server.php
-
 
126
#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
322
#備註:
127
#備註:
323
#無.
128
#無.
324
$validationCode=authenticate::validationCode($conf);
129
$getConnectionInfo=csInformation::getConnectionInfo($conf);
325
unset($conf);
130
unset($conf);
326
 
131
 
327
#如果執行失敗
132
#如果執行失敗
328
if($validationCode["status"]==="false"){
133
if($getConnectionInfo["status"]==="false"){
329
 
134
 
330
	#函式說明:
135
	#函式說明:
331
	#撰寫log
136
	#撰寫log
332
	#回傳結果:
137
	#回傳結果:
333
	#$result["status"],狀態,"true"或"false".
138
	#$result["status"],狀態,"true"或"false".
Line 336... Line 141...
336
	#$result["argu"],使用的參數.
141
	#$result["argu"],使用的參數.
337
	#必填參數:
142
	#必填參數:
338
	#$conf["path"],字串,log檔案的路徑與名稱.
143
	#$conf["path"],字串,log檔案的路徑與名稱.
339
	$conf["path"]=$logFile;
144
	$conf["path"]=$logFile;
340
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
145
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
341
	$conf["content"]=$validationCode;
146
	$conf["content"]=$getConnectionInfo;
342
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
147
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
343
	$conf["fileArgu"]=__FILE__;
148
	$conf["fileArgu"]=__FILE__;
344
	#可省略參數:
149
	#可省略參數:
345
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
150
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
346
	#$conf["rewrite"]="false";
151
	#$conf["rewrite"]="false";
Line 352... Line 157...
352
	unset($conf);
157
	unset($conf);
353
 
158
 
354
	#如果寫log失敗
159
	#如果寫log失敗
355
	if($record["status"]==="false"){
160
	if($record["status"]==="false"){
356
 
161
 
357
		#印出json結果
162
		#印出結果
358
		echo json_encode($record);
163
		var_dump($record);
359
 
164
 
360
		}#if end
165
		}#if end
361
 
166
 
362
	#結束執行,回傳錯誤代碼1
167
	#結束執行,回傳錯誤代碼1
363
	exit(1);
168
	exit(1);
364
 
169
 
365
	}#if end
170
	}#if end
366
 
171
 
367
#隨機產生get變數名稱
-
 
368
$getVarName=$validationCode["randNumberWord"];
-
 
369
 
-
 
370
#取得未加密的get變數
-
 
371
$plainGetVar=$getVarName."=".$sId;
-
 
372
 
-
 
373
#用GnuPG加密
-
 
374
 
-
 
375
#函式說明:
172
#如果有 body
376
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
377
#回傳結果:
-
 
378
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
379
#$result["function"],當前執行的函數名稱.
-
 
380
#$result["content"],加密後的結果.
-
 
381
#$result["error"],錯誤訊息陣列.
-
 
382
#$result["argu"],使用的參數.
-
 
383
#必填參數:
-
 
384
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
-
 
385
$conf["enCodeStr"]=$plainGetVar;
-
 
386
#$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.
173
if(!empty($getConnectionInfo["body"])){
387
$conf["enCodeType"]="gpg";
-
 
388
#可省略參數:
-
 
389
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
-
 
390
#$conf["sha1Raw"]="false";
-
 
391
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
-
 
392
#$conf["p_hash"]="";
-
 
393
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
-
 
394
#$conf["keyForAes256"]="";
-
 
395
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
-
 
396
#$conf["aes256Encode"]="";
-
 
397
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
-
 
398
#$conf["qbpwcfDecode"]="false";
-
 
399
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
-
 
400
#$conf["gpgDecrypt"]="false";
-
 
401
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,該參數必填.
-
 
402
$conf["gpgId"]=gnupgId;
-
 
403
#參考資料:
-
 
404
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
405
#md5=>http://php.net/manual/en/function.md5.php
-
 
406
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
407
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
408
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
409
#備註:
-
 
410
#無.
-
 
411
$enCodeStr=authenticate::enCodeStr($conf);
-
 
412
unset($conf);
-
 
413
 
-
 
414
#如果執行失敗
-
 
415
if($writeTextIntoFile["status"]==="false"){
-
 
416
 
174
	
417
	#函式說明:
-
 
418
	#撰寫log
-
 
419
	#回傳結果:
175
	#異常結束
420
	#$result["status"],狀態,"true"或"false".
-
 
421
	#$result["error"],錯誤訊息陣列.
-
 
422
	#$result["function"],當前函式的名稱.
-
 
423
	#$result["argu"],使用的參數.
-
 
424
	#必填參數:
-
 
425
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
426
	$conf["path"]=$logFile;
-
 
427
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
428
	$conf["content"]=$enCodeStr;
-
 
429
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
430
	$conf["fileArgu"]=__FILE__;
-
 
431
	#可省略參數:
-
 
432
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
433
	#$conf["rewrite"]="false";
-
 
434
	#參考資料:
-
 
435
	#無.
-
 
436
	#備註:
-
 
437
	#無.
-
 
438
	$record=logs::record($conf);
-
 
439
	unset($conf);
-
 
440
 
-
 
441
	#如果寫log失敗
-
 
442
	if($record["status"]==="false"){
-
 
443
 
-
 
444
		#印出json結果
-
 
445
		echo json_encode($record);
-
 
446
 
-
 
447
		}#if end
-
 
448
 
-
 
449
	#結束執行,回傳錯誤代碼1
-
 
450
	exit(1);
176
	exit(1);
451
 
177
 
452
	}#if end
178
	}#if end
453
 
179
 
454
#取得加密後的get變數
180
#取得用戶的瀏覽器資訊
455
$encryptedGetVar=$enCodeStr["content"];
181
$clientAgent=$getConnectionInfo["userBrowserType"];
456
 
182
 
457
#函式說明:
-
 
458
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
-
 
459
#回傳結果:
183
#取得用戶的ip
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"]=$encryptedGetVar;
-
 
468
#$conf["enCodeType"],"字串",加密的類型,有"sha1"與"md5"與"p_hash"與"aes256"與"qbpwcf"與"bin2hex"與"hex2bin",7種,"sha1"較耗時,"md5"較快,"p_hash"適用於密碼加密,"aes256"是對稱式加解密,"qbpwcf"是透過urlencode、json_encode、base64_encode的結果,"bin2hex"是依照每個byte的整數數值轉成"00"~"FF"後的結果,反之為"hex2bin".
184
$clientIp=$getConnectionInfo["userIp"];
469
$conf["enCodeType"]="bin2hex";
-
 
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
#參考資料:
-
 
482
#sha1=>http://php.net/manual/en/function.sha1.php
-
 
483
#md5=>http://php.net/manual/en/function.md5.php
-
 
484
#password_hash=>http://php.net/manual/en/function.password-hash.php
-
 
485
#password_verify=>http://php.net/manual/en/function.password-verify.php
-
 
486
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
-
 
487
#serialize=>https://www.php.net/manual/en/function.serialize.php
-
 
488
#備註:
-
 
489
#無.
-
 
490
$enCodeStr=authenticate::enCodeStr($conf);
-
 
491
unset($conf);
-
 
492
 
185
 
493
#如果執行失敗
186
#取得用戶的heade
494
if($enCodeStr["status"]==="false"){
187
$clientHeader=$getConnectionInfo["header"];
495
 
188
 
496
	#函式說明:
-
 
497
	#撰寫log
-
 
498
	#回傳結果:
-
 
499
	#$result["status"],狀態,"true"或"false".
-
 
500
	#$result["error"],錯誤訊息陣列.
-
 
501
	#$result["function"],當前函式的名稱.
-
 
502
	#$result["argu"],使用的參數.
-
 
503
	#必填參數:
-
 
504
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
505
	$conf["path"]=$logFile;
-
 
506
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
507
	$conf["content"]=$enCodeStr;
-
 
508
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
509
	$conf["fileArgu"]=__FILE__;
-
 
510
	#可省略參數:
-
 
511
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
512
	#$conf["rewrite"]="false";
-
 
513
	#參考資料:
-
 
514
	#無.
-
 
515
	#備註:
-
 
516
	#無.
-
 
517
	$record=logs::record($conf);
-
 
518
	unset($conf);
-
 
519
 
-
 
520
	#如果寫log失敗
-
 
521
	if($record["status"]==="false"){
-
 
522
 
189
 
523
		#印出json結果
-
 
524
		echo json_encode($record);
-
 
525
 
-
 
526
		}#if end
-
 
527
 
-
 
528
	#結束執行,回傳錯誤代碼1
-
 
529
	exit(1);
-
 
530
 
-
 
531
	}#if end
-
 
532
 
-
 
533
#取得編碼後的GET變數
-
 
534
$encodedGetVar=$enCodeStr["content"];
-
 
535
 
-
 
536
#debug
-
 
537
#var_dump(__LINE__,$encodedGetVar);exit;
-
 
538
 
190
 
539
#預設的email登入賬號
191
#等待1秒,避免太頻繁運行
540
$username=systemMailAcct;
192
#sleep(1);
541
 
193
 
542
#函式說明:
194
#函式說明:
543
#將字串特定關鍵字與其後面的內容剔除
195
#抓取命令列的參數.
544
#回傳結果:
196
#回傳結果:
545
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
197
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
546
#$result["error"],錯誤訊息陣列.
198
#$reuslt["error"],執行不正常結束的錯訊息陣列.
547
#$result["warning"],警告訊息鎮列.
199
#$result["function"],當前執行的函式名稱.
548
#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
549
#$result["function"],當前執行的函數名稱.
200
#$result["argu"],使用的參數陣列.
550
#$result["oriStr"],要處理的原始字串內容.
201
#$result["content"],要回傳的參數陣列.
551
#$result["content"],處理好的的字串內容.
202
#$result["count"],參數的數量.
552
#$result["deleted"],被移除的內容.
203
#$result["_GET"],收到的 HTTP GET 參數陣列.
553
#$result["argu"],使用的參數.
204
#$result["_POST"],收到的 HTTP POST 參數陣列.
554
#必填參數:
205
#必填參數:
555
#$conf["stringIn"],字串,要處理的字串.
-
 
556
$conf["stringIn"]=$username;
-
 
557
#$conf["keyWord"],字串,特定字串.
-
 
558
$conf["keyWord"]="@";
206
#無
559
#可省略參數:
207
#可省略參數:
-
 
208
#$conf["echo"],字串,"true"代表要將抓到的參數一個個印出來,"false"代表用回傳的方式,預設為"false".
-
 
209
#$conf["echo"]="false";
-
 
210
#$conf["httpGetToArgu"],字串,"true"代表要將 http get 參數變成參數來取得,像是 $_GET["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
-
 
211
$conf["httpGetToArgu"]="true";
-
 
212
#$conf["httpPostToArgu"],字串,"true"代表要將 http post 參數變成參數來取得,像是 $_POST["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
-
 
213
#$conf["httpPostToArgu"]="false";
560
#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
214
#$conf["arguEqual2http"],字串,預設為"false",代表命令列環境的參數依序為程式名稱本身、第n個參數,反之為"true",代表命令列的第一個參數為第n個參數,亦即沒有程式本身名稱的參數.
561
$conf["deleteLastRepeatedOne"]="true";
215
$conf["arguEqual2http"]="true";
562
#參考資料:
216
#參考資料:
563
#無.
217
#無.
564
#備註:
218
#備註:
565
#無.
-
 
-
 
219
#pipe要用''包住,才會被解析,例如'|'、'>'、'>>'.
566
$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf);
220
$getArgu=cmd::getArgu($conf);
567
unset($conf);
221
unset($conf);
568
 
222
 
569
#如果異常
-
 
570
if($delStrAfterKeyWord["status"]==="false"){
-
 
571
 
-
 
572
	#函式說明:
-
 
573
	#撰寫log
-
 
574
	#回傳結果:
-
 
575
	#$result["status"],狀態,"true"或"false".
-
 
576
	#$result["error"],錯誤訊息陣列.
-
 
577
	#$result["function"],當前函式的名稱.
-
 
578
	#$result["argu"],使用的參數.
-
 
579
	#必填參數:
-
 
580
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
581
	$conf["path"]=$logFile;
-
 
582
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
583
	$conf["content"]=$delStrAfterKeyWord;
-
 
584
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
585
	$conf["fileArgu"]=__FILE__;
-
 
586
	#可省略參數:
-
 
587
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
588
	#$conf["rewrite"]="false";
-
 
589
	#參考資料:
-
 
590
	#無.
-
 
591
	#備註:
-
 
592
	#無.
-
 
593
	$record=logs::record($conf);
-
 
594
	unset($conf);
-
 
595
 
-
 
596
	#如果寫log失敗
-
 
597
	if($record["status"]==="false"){
-
 
598
 
-
 
599
		#印出json結果
-
 
600
		echo json_encode($record);
-
 
601
 
-
 
602
		}#if end
-
 
603
 
-
 
604
	#結束執行,回傳錯誤代碼1
-
 
605
	exit(1);
-
 
606
 
-
 
607
	}#if end
-
 
608
 
-
 
609
#如果有@關鍵字
-
 
610
if($delStrAfterKeyWord["founded"]==="true"){
-
 
611
 
-
 
612
	#取得 username
-
 
613
	$username=$delStrAfterKeyWord["content"];
-
 
614
 
-
 
615
	#取得寄信的 email server
-
 
616
	$senderMailServer=$delStrAfterKeyWord["deleted"];
-
 
617
 
-
 
618
	}#if end
-
 
619
 
-
 
620
#取得收件人的email
-
 
621
$receiverMail=array($responseMultiInputDataSecurityEnhance["inputDataContent"]["email"]);
-
 
622
 
-
 
623
#取得收件人的username
-
 
624
$rev_username=$receiverMail;
-
 
625
 
-
 
626
#函式說明:
223
#函式說明:
627
#將字串特定關鍵字與其後面的內容剔除
224
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
628
#回傳結果:
225
#回傳結果:
629
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
226
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
630
#$result["error"],錯誤訊息陣列.
227
#$result["error"],錯誤訊息陣列
631
#$result["warning"],警告訊息鎮列.
-
 
632
#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
633
#$result["function"],當前執行的函數名稱.
228
#$result["function"],當前執行的函數名稱
634
#$result["oriStr"],要處理的原始字串內容.
-
 
635
#$result["content"],處理好的的字串內容.
229
#$result["content"],要執行的javaScript語法
636
#$result["deleted"],被移除的內容.
-
 
637
#$result["argu"],使用的參數.
-
 
638
#必填參數:
230
#必填參數:
639
#$conf["stringIn"],字串,要處理的字串.
231
#$conf["script"],字串,要執行的javaScript語法.
640
$conf["stringIn"]=$receiverMail[0];
-
 
641
#$conf["keyWord"],字串,特定字串.
-
 
642
$conf["keyWord"]="@";
232
$conf["script"]="
643
#可省略參數:
-
 
644
#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
-
 
645
$conf["deleteLastRepeatedOne"]="true";
-
 
646
#參考資料:
-
 
647
#無.
-
 
648
#備註:
-
 
649
#無.
-
 
650
$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf);
-
 
651
unset($conf);
-
 
652
 
-
 
653
#如果異常
-
 
654
if($delStrAfterKeyWord["status"]==="false"){
-
 
655
 
-
 
656
	#函式說明:
-
 
657
	#撰寫log
-
 
658
	#回傳結果:
-
 
659
	#$result["status"],狀態,"true"或"false".
-
 
660
	#$result["error"],錯誤訊息陣列.
-
 
661
	#$result["function"],當前函式的名稱.
-
 
662
	#$result["argu"],使用的參數.
-
 
663
	#必填參數:
-
 
664
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
665
	$conf["path"]=$logFile;
-
 
666
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
667
	$conf["content"]=$delStrAfterKeyWord;
-
 
668
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
669
	$conf["fileArgu"]=__FILE__;
-
 
670
	#可省略參數:
-
 
671
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
672
	#$conf["rewrite"]="false";
-
 
673
	#參考資料:
-
 
674
	#無.
-
 
675
	#備註:
-
 
676
	#無.
-
 
677
	$record=logs::record($conf);
-
 
678
	unset($conf);
-
 
679
 
-
 
680
	#如果寫log失敗
-
 
681
	if($record["status"]==="false"){
-
 
682
 
-
 
683
		#印出json結果
-
 
684
		echo json_encode($record);
-
 
685
 
233
 
686
		}#if end
-
 
687
 
-
 
688
	#結束執行,回傳錯誤代碼1
-
 
689
	exit(1);
-
 
690
 
-
 
691
	}#if end
-
 
692
 
-
 
693
#如果有@關鍵字
234
	//需要認證email
694
if($delStrAfterKeyWord["founded"]==="true"){
-
 
695
 
-
 
696
	#取得接收者的 username
-
 
697
	$rev_username[0]=$delStrAfterKeyWord["content"];
235
	var mail='".systemMailAcct."';
698
 
-
 
699
	}#if end
-
 
700
 
236
 
-
 
237
	//將需要加密的內容 ajax 給 api
-
 
238
	//傳送表單
-
 
239
	/*
-
 
240
	設置 window.qbpwcf.ajaxP 函數
701
#函式說明:
241
	說明:
-
 
242
	傳送ajax,指定傳送前要做什麼事情,然後回傳一個Promise.
-
 
243
	參數:
-
 
244
	params={};
702
#使用 php-pear-smtp 來透過SMTP伺服器寄信.
245
	params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';
-
 
246
	params.headers={name:value};
-
 
247
	params.url='url to request';
-
 
248
	params.preAc='function name to call before send request';
-
 
249
	params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};
703
#回傳結果:
250
	參考資料:
704
#$result["status"],執行正常與否,"true"代表正常;反之為"false".
251
	https://eyesofkids.gitbooks.io/javascript-start-es6-promise/content/contents/ch11_snippets.html
-
 
252
	https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
-
 
253
	*/
-
 
254
	ajaxP_params={};
-
 
255
	ajaxP_params.data='mail='+encodeURIComponent(mail);
-
 
256
	ajaxP_params.method='POST';
-
 
257
	ajaxP_params.url='../system/sendMailAgent/encrypt.php';
-
 
258
	var res = await window.qbpwcf.ajaxP.call(this,ajaxP_params);
-
 
259
 
-
 
260
	//如果執行異常
-
 
261
	if(res.status==='false'){
-
 
262
 
-
 
263
		//console erorr message
-
 
264
		console.error(res.error);
-
 
265
		
-
 
266
		//結束執行
-
 
267
		return;
-
 
268
 
-
 
269
		}//if end
-
 
270
 
-
 
271
	//如果不是合法的 json 格式
-
 
272
	if(res.compliantJson==='false'){
-
 
273
 
-
 
274
		//console erorr message
705
#$result["error"],錯誤訊息陣列
275
		console.error('invalid json response');
-
 
276
		
-
 
277
		//結束執行
-
 
278
		return;
-
 
279
 
-
 
280
		}//if end
-
 
281
 
-
 
282
	//debug
-
 
283
	//console.log(res);
-
 
284
	
-
 
285
	//另存 加密後的 session
-
 
286
	var sess=res.json.sess;
-
 
287
 
-
 
288
	//要傳送給 api 的 mail 資料
-
 
289
	var data={
-
 
290
 
-
 
291
		sid:sess,
-
 
292
 
-
 
293
		mail:res.json.post,
-
 
294
 
-
 
295
		}//data end
-
 
296
 
-
 
297
	//儲存用於識別用戶資源的id
-
 
298
	var wsClientId=crypto.randomUUID();
-
 
299
 
-
 
300
	//傳送要求認證的 ajax 給 api
-
 
301
	//傳送表單
-
 
302
	/*
706
#$result["function"],當前執行的函數.
303
	設置 window.qbpwcf.ajaxP 函數
-
 
304
	說明:
-
 
305
	傳送ajax,指定傳送前要做什麼事情,然後回傳一個Promise.
-
 
306
	參數:
-
 
307
	params={};
-
 
308
	params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';
-
 
309
	params.headers={name:value};
-
 
310
	params.url='url to request';
-
 
311
	params.preAc='function name to call before send request';
-
 
312
	params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};
707
#必填參數:
313
	參考資料:
708
#$conf["mailServer"],字串,要使用的SMTP郵件伺服器網址.若為tls加密,開頭請輸入"ssl://".
314
	https://eyesofkids.gitbooks.io/javascript-start-es6-promise/content/contents/ch11_snippets.html
-
 
315
	https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
-
 
316
	*/
-
 
317
	ajaxP_params={};
-
 
318
	ajaxP_params.data='sid='+encodeURIComponent(res.json.sess)+'&mail='+encodeURIComponent(res.json.post)+'&id='+encodeURIComponent(wsClientId);
-
 
319
	ajaxP_params.method='POST';
709
$conf["mailServer"]="ssl://qbpwcf.org";
320
	ajaxP_params.url='../system/sendMailAgent/mail.php';
710
#$conf["username"],字串,用來登入郵件伺服器的帳號
321
	var res = await window.qbpwcf.ajaxP.call(this,ajaxP_params);
-
 
322
 
-
 
323
	//如果執行異常
-
 
324
	if(res.status==='false'){
-
 
325
 
-
 
326
		//console erorr message
711
$conf["username"]=$username;
327
		console.error(res.error);
-
 
328
		
-
 
329
		//結束執行
-
 
330
		return;
-
 
331
 
-
 
332
		}//if end
-
 
333
 
712
#$conf["password"],字串,用來登入郵件伺服器的密碼
334
	//如果不是合法的 json 格式
713
$conf["password"]=systemMailPass;
335
	if(res.compliantJson==='false'){
-
 
336
 
-
 
337
		//console erorr message
714
#$conf["receiverMail"],陣列,收件人的信箱
338
		console.error('invalid json response');
-
 
339
		
-
 
340
		//結束執行
-
 
341
		return;
-
 
342
 
-
 
343
		}//if end
-
 
344
 
-
 
345
	//連線到web socket,並傳輸資料,會回傳promise.亦即要在 async function 中使用,且使用 await 來取得結果.
-
 
346
	//params,參數物件.
715
$conf["receiverMail"]=array($responseMultiInputDataSecurityEnhance["inputDataContent"]["email"]);
347
	//params.url,web socket的url,加密的連線為wss://url,預設為當前頁面的 domain name/wss
-
 
348
	//params.callback,函式,參數為收到的訊息,收到訊息後要怎麼處理.
716
#$conf["subject"],字串,郵件的主題
349
	//params.data,要傳輸的資料物件.
-
 
350
	//params.data.id,用於識別wss連線是屬於誰的id資訊,預設為自動產生.
-
 
351
	var params={};
717
$conf["subject"]="Please verify the request is made by yourself";
352
	params.url='wss://".\system_sendMailAgent_ws_domain."';
-
 
353
	params.data={};
-
 
354
	params.data.sess=sess;
-
 
355
	params.data.id=wsClientId;
-
 
356
	var res=await window.qbpwcf.ws.init(params);
-
 
357
	
-
 
358
	//debug
-
 
359
	console.log(res);
-
 
360
	
-
 
361
	//如果來自server說認證通過
718
#$conf["plainBody"],字串,郵件本文的純文字內容.
362
	while(res.from!='server' || res.msg!='authenticated'){
-
 
363
	
719
$conf["plainBody"]="Please visit url(https://".$domain.$path."var/qbpwcf/system/sendMailAgent/receiver/index.php?".$encodedGetVar.") to finish the email verifition";
364
		//連線到web socket,並傳輸資料,會回傳promise.亦即要在 async function 中使用,且使用 await 來取得結果.
-
 
365
		//params,參數物件.
720
#$conf["htmlBody"]="";,字串,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
366
		//params.url,web socket的url,加密的連線為wss://url,預設為當前頁面的 domain name/wss
-
 
367
		//params.callback,函式,參數為收到的訊息,收到訊息後要怎麼處理.
-
 
368
		//params.data,要傳輸的資料物件.
-
 
369
		//params.data.id,用於識別wss連線是屬於誰的id資訊,預設為自動產生.
-
 
370
		var params={};
721
$conf["htmlBody"]="Please <a href=\"https://".$domain.$path."var/qbpwcf/system/sendMailAgent/receiver/index.php?".$encodedGetVar."\">click this link to verif your email</a>";
371
		params.url='wss://".\system_sendMailAgent_ws_domain."';
-
 
372
		params.data={};
-
 
373
		params.data.id=window.qbpwcf.ws.wss[params.url].params.data.id;
-
 
374
		res=await window.qbpwcf.ws.init(params);
-
 
375
	
-
 
376
		//debug
-
 
377
		console.log(res);
-
 
378
	
-
 
379
		}//if end
-
 
380
		
-
 
381
	//提示通過email認證
-
 
382
	console.log('email validated');
-
 
383
	
-
 
384
	";
722
#可省略參數:
385
#可省略參數:
723
#$conf["mailServerPort"],整數,smtp server的port,預設為465.
-
 
724
#$conf["mailServerPort"]=465;
-
 
725
#$conf["mailerMailDisplay"],字串,要顯示的寄件人信箱,預設爲 $conf["username"]
-
 
726
$conf["mailerMailDisplay"]="web@qbpwcf.org";
-
 
727
#$conf["mailerNameDisplay"],字串,要顯示的寄件人姓名,預設爲 $conf["username"]
-
 
728
$conf["mailerNameDisplay"]="send mail agent";
-
 
729
#$conf["receiverNameDisplay"],陣列,要顯示的收件人姓名,預設爲 $conf["receiverMail"] 對應的元素.
386
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
730
$conf["receiverNameDisplay"]=$rev_username;
387
#$conf["onReady"]="true";
731
#$conf["attachment"],陣列,每個要寄送的附件路徑與檔案名稱
388
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
732
#$conf["attachment"]=array();
389
#$conf["globalJs"]=array();
733
#$conf["attachmentName"],陣列,每個要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
-
 
734
#$conf["attachmentName"]=array();
-
 
735
#$conf["attachmentMimeType"],陣列,每個附件的 mimeType,預設為"application/*".
390
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
736
#$conf["attachmentMimeType"]array();
391
#$conf["jsFunciton"]=array();
737
#$conf["userAgent"],字串,用於表示使用smtp服務的軟體資訊,預設為"Powerd by QBPWCF(https://lib.qbpwcf.org)".
-
 
738
#$conf["userAgent"]="Powerd by QBPWCF(https://lib.qbpwcf.org)";
-
 
739
#$conf["org"],字串,若要表示來源組織名稱,可在此設定.
-
 
740
$conf["org"]="QBPWCF(https://www.qbpwcf.org)";
-
 
741
#$conf["notifyReceived"],字串,回報已讀通知,預設為"true"代表要;反之為"false".
392
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
742
#$conf["notifyReceived"]="true";
393
#$conf["noScriptTag"]="false";
743
#$conf["signWithGPGid"],字串,用於簽署的gpg id,預設不使用.
-
 
744
$conf["signWithGPGid"]="web@qbpwcf.org";
-
 
745
#參考資料:
394
#參考資料:
746
#官網=>http://pear.php.net/package/Net_SMTP
-
 
747
#Document=>https://github.com/pear/Net_SMTP
-
 
748
#SSL=>https://github.com/pear/Net_SMTP?tab=readme-ov-file#secure-connections
395
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
749
#Message-ID: =>https://datatracker.ietf.org/doc/html/rfc5322
-
 
750
#mail body boundary=>https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
-
 
751
#備註:
396
#備註:
752
#需要php-pear-Net-SMTP
397
#無.
753
$pear_smtp_send=mail::pear_smtp_send($conf);
398
$toScript=javaScript::toScript($conf);
754
unset($conf);
399
unset($conf);
755
 
400
 
756
#如果失敗
401
#如果執行失敗
757
if($pear_smtp_send["status"]==="false"){
402
if($toScript["status"]==="false"){
758
 
403
 
759
	#函式說明:
404
	#函式說明:
760
	#撰寫log
405
	#撰寫log
761
	#回傳結果:
406
	#回傳結果:
762
	#$result["status"],狀態,"true"或"false".
407
	#$result["status"],狀態,"true"或"false".
Line 765... Line 410...
765
	#$result["argu"],使用的參數.
410
	#$result["argu"],使用的參數.
766
	#必填參數:
411
	#必填參數:
767
	#$conf["path"],字串,log檔案的路徑與名稱.
412
	#$conf["path"],字串,log檔案的路徑與名稱.
768
	$conf["path"]=$logFile;
413
	$conf["path"]=$logFile;
769
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
414
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
770
	$conf["content"]=$pear_smtp_send;
415
	$conf["content"]=$toScript;
771
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
416
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
772
	$conf["fileArgu"]=__FILE__;
417
	$conf["fileArgu"]=__FILE__;
773
	#可省略參數:
418
	#可省略參數:
774
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
419
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
775
	#$conf["rewrite"]="false";
420
	#$conf["rewrite"]="false";
Line 781... Line 426...
781
	unset($conf);
426
	unset($conf);
782
 
427
 
783
	#如果寫log失敗
428
	#如果寫log失敗
784
	if($record["status"]==="false"){
429
	if($record["status"]==="false"){
785
 
430
 
786
		#印出json結果
431
		#印出結果
787
		echo json_encode($record);
432
		var_dump($record);
788
 
433
 
789
		}#if end
434
		}#if end
790
 
435
 
791
	#結束執行,回傳錯誤代碼1
436
	#結束執行,回傳錯誤代碼1
792
	exit(1);
437
	exit(1);
793
 
438
 
794
	}#if end
439
	}#if end
795
 
440
 
796
#初始化 sendMailAgent 到 session
-
 
797
$_SESSION["sendMailAgent"]=array();
-
 
798
 
-
 
799
#設置當前狀態為 "wait" 代表尚未被 web socket 接收與驗證
-
 
800
$_SESSION["sendMailAgent"]["status"]="wait";
-
 
801
 
-
 
802
#初始化結果
-
 
803
$result=array();
441
#debug
804
 
-
 
805
#設置執行正常
-
 
806
$result["status"]="true";
442
echo $toScript["content"];
807
 
443
 
808
#印出json結果
-
 
809
echo json_encode($result);
-