| 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 |
|
|
|
29 |
將通過email驗證後的用戶,將其填寫好的表單資訊寄送給管理者的系統.
|
|
|
30 |
|
|
|
31 |
1.使用者提供email進行認證
|
|
|
32 |
1-1. web socket 等待 server 通知認證通過
|
|
|
33 |
|
|
|
34 |
2.使用者點選email中的一次性超連結認證
|
|
|
35 |
2-1. 超連結的頁面會讓 server 跟 web socket client 端說通過認證了.
|
|
|
36 |
2-1-1. 若重複拜訪該頁面將無效果.
|
|
|
37 |
2-1-2. 若之前有同 email 的一次性超連結認證未註銷,則註銷之.
|
|
|
38 |
2-1-3. 若距離產生一次性超連結時間大於300秒,則無效且註銷之.
|
|
|
39 |
|
|
|
40 |
3.頁面呈現其他資訊表單給使用者填寫
|
|
|
41 |
|
|
|
42 |
4.表單填寫好送出後,該一次性表單就註銷,然後管理者就會收到表單內容的 email.
|
|
|
43 |
|
|
|
44 |
*/
|
|
|
45 |
|
|
|
46 |
#使用命名空間qbpwcf
|
|
|
47 |
namespace qbpwcf;
|
|
|
48 |
|
|
|
49 |
#初始化輸出
|
|
|
50 |
$output=array();
|
|
|
51 |
|
|
|
52 |
#取得 lib path
|
|
|
53 |
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
|
|
|
54 |
|
|
|
55 |
#如果執行失敗
|
|
|
56 |
if($status!==0){
|
|
|
57 |
|
|
|
58 |
#debug
|
|
|
59 |
var_dump(__LINE__,$output);
|
|
|
60 |
|
|
|
61 |
#結束執行,回傳shell 1.
|
|
|
62 |
exit(1);
|
|
|
63 |
|
|
|
64 |
}#if end
|
|
|
65 |
|
|
|
66 |
#儲存lib path
|
|
|
67 |
$folderOfUsrLib=$output[0];
|
|
|
68 |
|
|
|
69 |
#初始化輸出
|
|
|
70 |
$output=array();
|
|
|
71 |
|
|
|
72 |
#以該檔案的實際位置的 lib path 為 include path 首位
|
|
|
73 |
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);
|
|
|
74 |
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
|
|
|
75 |
|
|
|
76 |
#匯入套件
|
|
|
77 |
require_once("allInOneForJson.php");
|
|
|
78 |
|
|
|
79 |
#建議的log位置
|
|
|
80 |
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
|
|
|
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"]參數一致.
|
|
|
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 |
#函式說明:
|
|
|
296 |
#建立以圖片(PNG格式)呈現的驗證碼.
|
|
|
297 |
#回傳的解果:
|
|
|
298 |
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
|
|
|
299 |
#$result["error"],錯誤訊息.
|
|
|
300 |
#$result["function"],檔前執行的函數名稱.
|
|
|
301 |
#$result["randNumberWord"],傳驗證碼的內容.
|
|
|
302 |
#$result["imgAddress"],包含src圖片的位置與名稱.
|
|
|
303 |
#$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
|
|
|
304 |
#必填參數:
|
|
|
305 |
#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
|
|
|
306 |
$conf["imgAddressAndName"]="/tmp/notExsit.img";
|
|
|
307 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
308 |
$conf["fileArgu"]=__FILE__;
|
|
|
309 |
#可省略參數:
|
|
|
310 |
#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
|
|
|
311 |
#$conf["num"]="8";
|
|
|
312 |
#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
|
|
|
313 |
$conf["disableImg"]="true";
|
|
|
314 |
#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
|
|
|
315 |
#$conf["imgToData"]="true";
|
|
|
316 |
#$conf["class"],字串,圖片要套用的css樣式類別.
|
|
|
317 |
#$conf["class"]="";
|
|
|
318 |
#$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
|
|
|
319 |
#$conf["content"]=array();
|
|
|
320 |
#參考資料:
|
|
|
321 |
#無.
|
|
|
322 |
#備註:
|
|
|
323 |
#無.
|
|
|
324 |
$validationCode=authenticate::validationCode($conf);
|
|
|
325 |
unset($conf);
|
|
|
326 |
|
|
|
327 |
#如果執行失敗
|
|
|
328 |
if($validationCode["status"]==="false"){
|
|
|
329 |
|
|
|
330 |
#函式說明:
|
|
|
331 |
#撰寫log
|
|
|
332 |
#回傳結果:
|
|
|
333 |
#$result["status"],狀態,"true"或"false".
|
|
|
334 |
#$result["error"],錯誤訊息陣列.
|
|
|
335 |
#$result["function"],當前函式的名稱.
|
|
|
336 |
#$result["argu"],使用的參數.
|
|
|
337 |
#必填參數:
|
|
|
338 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
339 |
$conf["path"]=$logFile;
|
|
|
340 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
341 |
$conf["content"]=$validationCode;
|
|
|
342 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
343 |
$conf["fileArgu"]=__FILE__;
|
|
|
344 |
#可省略參數:
|
|
|
345 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
346 |
#$conf["rewrite"]="false";
|
|
|
347 |
#參考資料:
|
|
|
348 |
#無.
|
|
|
349 |
#備註:
|
|
|
350 |
#無.
|
|
|
351 |
$record=logs::record($conf);
|
|
|
352 |
unset($conf);
|
|
|
353 |
|
|
|
354 |
#如果寫log失敗
|
|
|
355 |
if($record["status"]==="false"){
|
|
|
356 |
|
|
|
357 |
#印出json結果
|
|
|
358 |
echo json_encode($record);
|
|
|
359 |
|
|
|
360 |
}#if end
|
|
|
361 |
|
|
|
362 |
#結束執行,回傳錯誤代碼1
|
|
|
363 |
exit(1);
|
|
|
364 |
|
|
|
365 |
}#if end
|
|
|
366 |
|
|
|
367 |
#隨機產生get變數名稱
|
|
|
368 |
$getVarName=$validationCode["randNumberWord"];
|
|
|
369 |
|
|
|
370 |
#取得未加密的get變數
|
|
|
371 |
$plainGetVar=$getVarName."=".$sId;
|
|
|
372 |
|
|
|
373 |
#用GnuPG加密
|
|
|
374 |
|
|
|
375 |
#函式說明:
|
|
|
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.
|
|
|
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 |
|
|
|
417 |
#函式說明:
|
|
|
418 |
#撰寫log
|
|
|
419 |
#回傳結果:
|
|
|
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);
|
|
|
451 |
|
|
|
452 |
}#if end
|
|
|
453 |
|
|
|
454 |
#取得加密後的get變數
|
|
|
455 |
$encryptedGetVar=$enCodeStr["content"];
|
|
|
456 |
|
|
|
457 |
#函式說明:
|
|
|
458 |
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
|
|
|
459 |
#回傳結果:
|
|
|
460 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
461 |
#$result["function"],當前執行的函數名稱.
|
|
|
462 |
#$result["content"],加密後的結果.
|
|
|
463 |
#$result["error"],錯誤訊息陣列.
|
|
|
464 |
#$result["argu"],使用的參數.
|
|
|
465 |
#必填參數:
|
|
|
466 |
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
|
|
|
467 |
$conf["enCodeStr"]=$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".
|
|
|
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 |
|
|
|
493 |
#如果執行失敗
|
|
|
494 |
if($enCodeStr["status"]==="false"){
|
|
|
495 |
|
|
|
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 |
|
|
|
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 |
|
|
|
539 |
#預設的email登入賬號
|
|
|
540 |
$username=systemMailAcct;
|
|
|
541 |
|
|
|
542 |
#函式說明:
|
|
|
543 |
#將字串特定關鍵字與其後面的內容剔除
|
|
|
544 |
#回傳結果:
|
|
|
545 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
546 |
#$result["error"],錯誤訊息陣列.
|
|
|
547 |
#$result["warning"],警告訊息鎮列.
|
|
|
548 |
#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
|
|
|
549 |
#$result["function"],當前執行的函數名稱.
|
|
|
550 |
#$result["oriStr"],要處理的原始字串內容.
|
|
|
551 |
#$result["content"],處理好的的字串內容.
|
|
|
552 |
#$result["deleted"],被移除的內容.
|
|
|
553 |
#$result["argu"],使用的參數.
|
|
|
554 |
#必填參數:
|
|
|
555 |
#$conf["stringIn"],字串,要處理的字串.
|
|
|
556 |
$conf["stringIn"]=$username;
|
|
|
557 |
#$conf["keyWord"],字串,特定字串.
|
|
|
558 |
$conf["keyWord"]="@";
|
|
|
559 |
#可省略參數:
|
|
|
560 |
#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
|
|
|
561 |
$conf["deleteLastRepeatedOne"]="true";
|
|
|
562 |
#參考資料:
|
|
|
563 |
#無.
|
|
|
564 |
#備註:
|
|
|
565 |
#無.
|
|
|
566 |
$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf);
|
|
|
567 |
unset($conf);
|
|
|
568 |
|
|
|
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 |
#函式說明:
|
|
|
627 |
#將字串特定關鍵字與其後面的內容剔除
|
|
|
628 |
#回傳結果:
|
|
|
629 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
630 |
#$result["error"],錯誤訊息陣列.
|
|
|
631 |
#$result["warning"],警告訊息鎮列.
|
|
|
632 |
#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
|
|
|
633 |
#$result["function"],當前執行的函數名稱.
|
|
|
634 |
#$result["oriStr"],要處理的原始字串內容.
|
|
|
635 |
#$result["content"],處理好的的字串內容.
|
|
|
636 |
#$result["deleted"],被移除的內容.
|
|
|
637 |
#$result["argu"],使用的參數.
|
|
|
638 |
#必填參數:
|
|
|
639 |
#$conf["stringIn"],字串,要處理的字串.
|
|
|
640 |
$conf["stringIn"]=$receiverMail[0];
|
|
|
641 |
#$conf["keyWord"],字串,特定字串.
|
|
|
642 |
$conf["keyWord"]="@";
|
|
|
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 |
|
|
|
686 |
}#if end
|
|
|
687 |
|
|
|
688 |
#結束執行,回傳錯誤代碼1
|
|
|
689 |
exit(1);
|
|
|
690 |
|
|
|
691 |
}#if end
|
|
|
692 |
|
|
|
693 |
#如果有@關鍵字
|
|
|
694 |
if($delStrAfterKeyWord["founded"]==="true"){
|
|
|
695 |
|
|
|
696 |
#取得接收者的 username
|
|
|
697 |
$rev_username[0]=$delStrAfterKeyWord["content"];
|
|
|
698 |
|
|
|
699 |
}#if end
|
|
|
700 |
|
|
|
701 |
#函式說明:
|
|
|
702 |
#使用 php-pear-smtp 來透過SMTP伺服器寄信.
|
|
|
703 |
#回傳結果:
|
|
|
704 |
#$result["status"],執行正常與否,"true"代表正常;反之為"false".
|
|
|
705 |
#$result["error"],錯誤訊息陣列
|
|
|
706 |
#$result["function"],當前執行的函數.
|
|
|
707 |
#必填參數:
|
|
|
708 |
#$conf["mailServer"],字串,要使用的SMTP郵件伺服器網址.若為tls加密,開頭請輸入"ssl://".
|
|
|
709 |
$conf["mailServer"]="ssl://qbpwcf.org";
|
|
|
710 |
#$conf["username"],字串,用來登入郵件伺服器的帳號
|
|
|
711 |
$conf["username"]=$username;
|
|
|
712 |
#$conf["password"],字串,用來登入郵件伺服器的密碼
|
|
|
713 |
$conf["password"]=systemMailPass;
|
|
|
714 |
#$conf["receiverMail"],陣列,收件人的信箱
|
|
|
715 |
$conf["receiverMail"]=array($responseMultiInputDataSecurityEnhance["inputDataContent"]["email"]);
|
|
|
716 |
#$conf["subject"],字串,郵件的主題
|
|
|
717 |
$conf["subject"]="Please verify the request is made by yourself";
|
|
|
718 |
#$conf["plainBody"],字串,郵件本文的純文字內容.
|
|
|
719 |
$conf["plainBody"]="Please visit url(https://".$domain.$path."var/qbpwcf/system/sendMailAgent/receiver/index.php?".$encodedGetVar.") to finish the email verifition";
|
|
|
720 |
#$conf["htmlBody"]="";,字串,郵件本文的html內容,多媒體盡量不要用base64的方式來嵌入,因為大部分的郵件服務(Gmail)都不支援,如果是在單機上的郵件軟體就可能有支援,例如:Evolution.
|
|
|
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>";
|
|
|
722 |
#可省略參數:
|
|
|
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"] 對應的元素.
|
|
|
730 |
$conf["receiverNameDisplay"]=$rev_username;
|
|
|
731 |
#$conf["attachment"],陣列,每個要寄送的附件路徑與檔案名稱
|
|
|
732 |
#$conf["attachment"]=array();
|
|
|
733 |
#$conf["attachmentName"],陣列,每個要寄送的附件顯示名稱,預設為$conf["attachment"]中的實際檔案名稱.
|
|
|
734 |
#$conf["attachmentName"]=array();
|
|
|
735 |
#$conf["attachmentMimeType"],陣列,每個附件的 mimeType,預設為"application/*".
|
|
|
736 |
#$conf["attachmentMimeType"]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".
|
|
|
742 |
#$conf["notifyReceived"]="true";
|
|
|
743 |
#$conf["signWithGPGid"],字串,用於簽署的gpg id,預設不使用.
|
|
|
744 |
$conf["signWithGPGid"]="web@qbpwcf.org";
|
|
|
745 |
#參考資料:
|
|
|
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
|
|
|
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 |
#備註:
|
|
|
752 |
#需要php-pear-Net-SMTP
|
|
|
753 |
$pear_smtp_send=mail::pear_smtp_send($conf);
|
|
|
754 |
unset($conf);
|
|
|
755 |
|
|
|
756 |
#如果失敗
|
|
|
757 |
if($pear_smtp_send["status"]==="false"){
|
|
|
758 |
|
|
|
759 |
#函式說明:
|
|
|
760 |
#撰寫log
|
|
|
761 |
#回傳結果:
|
|
|
762 |
#$result["status"],狀態,"true"或"false".
|
|
|
763 |
#$result["error"],錯誤訊息陣列.
|
|
|
764 |
#$result["function"],當前函式的名稱.
|
|
|
765 |
#$result["argu"],使用的參數.
|
|
|
766 |
#必填參數:
|
|
|
767 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
768 |
$conf["path"]=$logFile;
|
|
|
769 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
770 |
$conf["content"]=$pear_smtp_send;
|
|
|
771 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
772 |
$conf["fileArgu"]=__FILE__;
|
|
|
773 |
#可省略參數:
|
|
|
774 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
775 |
#$conf["rewrite"]="false";
|
|
|
776 |
#參考資料:
|
|
|
777 |
#無.
|
|
|
778 |
#備註:
|
|
|
779 |
#無.
|
|
|
780 |
$record=logs::record($conf);
|
|
|
781 |
unset($conf);
|
|
|
782 |
|
|
|
783 |
#如果寫log失敗
|
|
|
784 |
if($record["status"]==="false"){
|
|
|
785 |
|
|
|
786 |
#印出json結果
|
|
|
787 |
echo json_encode($record);
|
|
|
788 |
|
|
|
789 |
}#if end
|
|
|
790 |
|
|
|
791 |
#結束執行,回傳錯誤代碼1
|
|
|
792 |
exit(1);
|
|
|
793 |
|
|
|
794 |
}#if end
|
|
|
795 |
|
|
|
796 |
#初始化 sendMailAgent 到 session
|
|
|
797 |
$_SESSION["sendMailAgent"]=array();
|
|
|
798 |
|
|
|
799 |
#設置當前狀態為 "wait" 代表尚未被 web socket 接收與驗證
|
|
|
800 |
$_SESSION["sendMailAgent"]["status"]="wait";
|
|
|
801 |
|
|
|
802 |
#初始化結果
|
|
|
803 |
$result=array();
|
|
|
804 |
|
|
|
805 |
#設置執行正常
|
|
|
806 |
$result["status"]="true";
|
|
|
807 |
|
|
|
808 |
#印出json結果
|
|
|
809 |
echo json_encode($result);
|