| 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 |
|
| 326 |
liveuser |
82 |
#取得用戶端資訊
|
| 317 |
liveuser |
83 |
#函式說明:
|
| 326 |
liveuser |
84 |
#取得用戶端的資訊,並依據需要寫入到資料表裡面
|
|
|
85 |
#回傳的結果:
|
| 317 |
liveuser |
86 |
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
|
|
|
87 |
#$result["error"],錯誤訊息.
|
|
|
88 |
#$result["function"],檔前執行的函數名稱.
|
| 326 |
liveuser |
89 |
#$result["mode"],當前的模式是"cmd"還是"web".
|
|
|
90 |
#$result["userBrowserType"],爲使用者的瀏覽器資訊
|
|
|
91 |
#$result["userIp"],爲使用者的IP
|
|
|
92 |
#$result["serverIp"],為伺服器的IP
|
|
|
93 |
#$result["server_name"],伺服器的 domain name
|
|
|
94 |
#$result["scheme"],通訊協定
|
|
|
95 |
#$result["serverPort"],伺服器給對外下載網頁的port
|
|
|
96 |
#$result["requestUri"],爲使用者要求的網址/php檔案.
|
|
|
97 |
#$result["requestUriFull"],為使用者要求的完整網址/php檔案路徑.
|
|
|
98 |
#$result["clientRequestIP"],用戶端要求的ip與port
|
|
|
99 |
#$result["username"],爲使用者目前的帳戶,若爲""則表示尚未登入成功
|
|
|
100 |
#$result["phpUser"],運行該php的使用者帳戶.若為空字串則代表非使用者直接觸發.
|
|
|
101 |
#$result["phpUserType"],運行該php的使用者帳戶類型,可能有"regular(no wheel member)","wheel(can use sudo)","intrinsic(root)","system(qemu,apache,...)".
|
|
|
102 |
#$result["header"],接收到的 header 陣列.
|
|
|
103 |
#$result["body"],接收到的 body 字串.
|
|
|
104 |
#必填參數:
|
|
|
105 |
#$conf["getAccount"],字串,是否要取得帳號,"true"代表要;"false"代表不要.
|
|
|
106 |
$conf["getAccount"]="false";
|
| 317 |
liveuser |
107 |
#可省略參數:
|
| 326 |
liveuser |
108 |
#$conf["accountVar"],字串,帳號儲存在哪個變數裏面,預設爲$_SESSION["username"].
|
|
|
109 |
#$conf["accountVar"]=$_SESSION["username"];
|
|
|
110 |
#$conf["saveToDb"],字串,是否要除儲存到資料庫,"true"為要儲存",預設為"false"不儲存.
|
|
|
111 |
#$conf["saveToDb"]="true";
|
|
|
112 |
#$conf["dbAddress"],字串,爲mysql/mariadb server的位置,若saveToDb設為"true",則該參數為必填.
|
|
|
113 |
#$conf["dbAddress"]=$dbAddress;
|
|
|
114 |
#$conf["dbAccount"],字串,爲用於連入mysql/mariadb server時要使用的帳號,若saveToDb設為"true",則該參數為必填.
|
|
|
115 |
#$conf["dbAccount"]=$dbAccount;
|
|
|
116 |
#$conf["dbName"],字串,要選取的資料庫名稱,若saveToDb設為"true",則該參數為必填.
|
|
|
117 |
#$conf["dbName"]=$dbName;
|
|
|
118 |
#$conf["tableName"],字串,爲要插入資料的資料表名稱,若saveToDb設為"true",則該參數為必填.
|
|
|
119 |
#$conf["tableName"]="visitorInfo";
|
|
|
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時要使用的密碼,可省略,若省略則代表不使用密碼.
|
|
|
123 |
#$conf["dbPassword"]=$dbPassword;
|
| 317 |
liveuser |
124 |
#參考資料:
|
| 326 |
liveuser |
125 |
#$_SERVER=>http://php.net/manual/zh/reserved.variables.server.php
|
|
|
126 |
#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
|
| 317 |
liveuser |
127 |
#備註:
|
|
|
128 |
#無.
|
| 326 |
liveuser |
129 |
$getConnectionInfo=csInformation::getConnectionInfo($conf);
|
| 317 |
liveuser |
130 |
unset($conf);
|
|
|
131 |
|
|
|
132 |
#如果執行失敗
|
| 326 |
liveuser |
133 |
if($getConnectionInfo["status"]==="false"){
|
| 317 |
liveuser |
134 |
|
|
|
135 |
#函式說明:
|
|
|
136 |
#撰寫log
|
|
|
137 |
#回傳結果:
|
|
|
138 |
#$result["status"],狀態,"true"或"false".
|
|
|
139 |
#$result["error"],錯誤訊息陣列.
|
|
|
140 |
#$result["function"],當前函式的名稱.
|
|
|
141 |
#$result["argu"],使用的參數.
|
|
|
142 |
#必填參數:
|
|
|
143 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
144 |
$conf["path"]=$logFile;
|
|
|
145 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
| 326 |
liveuser |
146 |
$conf["content"]=$getConnectionInfo;
|
| 317 |
liveuser |
147 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
148 |
$conf["fileArgu"]=__FILE__;
|
|
|
149 |
#可省略參數:
|
|
|
150 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
151 |
#$conf["rewrite"]="false";
|
|
|
152 |
#參考資料:
|
|
|
153 |
#無.
|
|
|
154 |
#備註:
|
|
|
155 |
#無.
|
|
|
156 |
$record=logs::record($conf);
|
|
|
157 |
unset($conf);
|
|
|
158 |
|
|
|
159 |
#如果寫log失敗
|
|
|
160 |
if($record["status"]==="false"){
|
|
|
161 |
|
| 326 |
liveuser |
162 |
#印出結果
|
|
|
163 |
var_dump($record);
|
| 317 |
liveuser |
164 |
|
|
|
165 |
}#if end
|
|
|
166 |
|
|
|
167 |
#結束執行,回傳錯誤代碼1
|
|
|
168 |
exit(1);
|
|
|
169 |
|
|
|
170 |
}#if end
|
|
|
171 |
|
| 326 |
liveuser |
172 |
#如果有 body
|
|
|
173 |
if(!empty($getConnectionInfo["body"])){
|
|
|
174 |
|
|
|
175 |
#異常結束
|
|
|
176 |
exit(1);
|
| 317 |
liveuser |
177 |
|
| 326 |
liveuser |
178 |
}#if end
|
| 317 |
liveuser |
179 |
|
| 326 |
liveuser |
180 |
#取得用戶的瀏覽器資訊
|
|
|
181 |
$clientAgent=$getConnectionInfo["userBrowserType"];
|
| 317 |
liveuser |
182 |
|
| 326 |
liveuser |
183 |
#取得用戶的ip
|
|
|
184 |
$clientIp=$getConnectionInfo["userIp"];
|
| 317 |
liveuser |
185 |
|
| 326 |
liveuser |
186 |
#取得用戶的heade
|
|
|
187 |
$clientHeader=$getConnectionInfo["header"];
|
| 317 |
liveuser |
188 |
|
|
|
189 |
|
|
|
190 |
|
| 326 |
liveuser |
191 |
#等待1秒,避免太頻繁運行
|
|
|
192 |
#sleep(1);
|
| 317 |
liveuser |
193 |
|
|
|
194 |
#函式說明:
|
| 326 |
liveuser |
195 |
#抓取命令列的參數.
|
| 317 |
liveuser |
196 |
#回傳結果:
|
|
|
197 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| 326 |
liveuser |
198 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
199 |
#$result["function"],當前執行的函式名稱.
|
|
|
200 |
#$result["argu"],使用的參數陣列.
|
|
|
201 |
#$result["content"],要回傳的參數陣列.
|
|
|
202 |
#$result["count"],參數的數量.
|
|
|
203 |
#$result["_GET"],收到的 HTTP GET 參數陣列.
|
|
|
204 |
#$result["_POST"],收到的 HTTP POST 參數陣列.
|
| 317 |
liveuser |
205 |
#必填參數:
|
| 326 |
liveuser |
206 |
#無
|
| 317 |
liveuser |
207 |
#可省略參數:
|
| 326 |
liveuser |
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";
|
|
|
214 |
#$conf["arguEqual2http"],字串,預設為"false",代表命令列環境的參數依序為程式名稱本身、第n個參數,反之為"true",代表命令列的第一個參數為第n個參數,亦即沒有程式本身名稱的參數.
|
|
|
215 |
$conf["arguEqual2http"]="true";
|
| 317 |
liveuser |
216 |
#參考資料:
|
| 326 |
liveuser |
217 |
#無.
|
| 317 |
liveuser |
218 |
#備註:
|
| 326 |
liveuser |
219 |
#pipe要用''包住,才會被解析,例如'|'、'>'、'>>'.
|
|
|
220 |
$getArgu=cmd::getArgu($conf);
|
| 317 |
liveuser |
221 |
unset($conf);
|
|
|
222 |
|
|
|
223 |
#函式說明:
|
| 326 |
liveuser |
224 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
| 317 |
liveuser |
225 |
#回傳結果:
|
| 326 |
liveuser |
226 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
227 |
#$result["error"],錯誤訊息陣列
|
|
|
228 |
#$result["function"],當前執行的函數名稱
|
|
|
229 |
#$result["content"],要執行的javaScript語法
|
| 317 |
liveuser |
230 |
#必填參數:
|
| 326 |
liveuser |
231 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
232 |
$conf["script"]="
|
| 317 |
liveuser |
233 |
|
| 326 |
liveuser |
234 |
//需要認證email
|
|
|
235 |
var mail='".systemMailAcct."';
|
| 317 |
liveuser |
236 |
|
| 326 |
liveuser |
237 |
//將需要加密的內容 ajax 給 api
|
|
|
238 |
//傳送表單
|
|
|
239 |
/*
|
|
|
240 |
設置 window.qbpwcf.ajaxP 函數
|
|
|
241 |
說明:
|
|
|
242 |
傳送ajax,指定傳送前要做什麼事情,然後回傳一個Promise.
|
|
|
243 |
參數:
|
|
|
244 |
params={};
|
|
|
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 {};
|
|
|
250 |
參考資料:
|
|
|
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);
|
| 317 |
liveuser |
259 |
|
| 326 |
liveuser |
260 |
//如果執行異常
|
|
|
261 |
if(res.status==='false'){
|
| 317 |
liveuser |
262 |
|
| 326 |
liveuser |
263 |
//console erorr message
|
|
|
264 |
console.error(res.error);
|
|
|
265 |
|
|
|
266 |
//結束執行
|
|
|
267 |
return;
|
| 317 |
liveuser |
268 |
|
| 326 |
liveuser |
269 |
}//if end
|
| 317 |
liveuser |
270 |
|
| 326 |
liveuser |
271 |
//如果不是合法的 json 格式
|
|
|
272 |
if(res.compliantJson==='false'){
|
| 317 |
liveuser |
273 |
|
| 326 |
liveuser |
274 |
//console erorr message
|
|
|
275 |
console.error('invalid json response');
|
|
|
276 |
|
|
|
277 |
//結束執行
|
|
|
278 |
return;
|
| 317 |
liveuser |
279 |
|
| 326 |
liveuser |
280 |
}//if end
|
| 317 |
liveuser |
281 |
|
| 326 |
liveuser |
282 |
//debug
|
|
|
283 |
//console.log(res);
|
|
|
284 |
|
|
|
285 |
//另存 加密後的 session
|
|
|
286 |
var sess=res.json.sess;
|
| 317 |
liveuser |
287 |
|
| 326 |
liveuser |
288 |
//要傳送給 api 的 mail 資料
|
|
|
289 |
var data={
|
| 317 |
liveuser |
290 |
|
| 326 |
liveuser |
291 |
sid:sess,
|
| 317 |
liveuser |
292 |
|
| 326 |
liveuser |
293 |
mail:res.json.post,
|
| 317 |
liveuser |
294 |
|
| 326 |
liveuser |
295 |
}//data end
|
| 317 |
liveuser |
296 |
|
| 326 |
liveuser |
297 |
//儲存用於識別用戶資源的id
|
|
|
298 |
var wsClientId=crypto.randomUUID();
|
| 317 |
liveuser |
299 |
|
| 326 |
liveuser |
300 |
//傳送要求認證的 ajax 給 api
|
|
|
301 |
//傳送表單
|
|
|
302 |
/*
|
|
|
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 {};
|
|
|
313 |
參考資料:
|
|
|
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';
|
|
|
320 |
ajaxP_params.url='../system/sendMailAgent/mail.php';
|
|
|
321 |
var res = await window.qbpwcf.ajaxP.call(this,ajaxP_params);
|
| 317 |
liveuser |
322 |
|
| 326 |
liveuser |
323 |
//如果執行異常
|
|
|
324 |
if(res.status==='false'){
|
| 317 |
liveuser |
325 |
|
| 326 |
liveuser |
326 |
//console erorr message
|
|
|
327 |
console.error(res.error);
|
|
|
328 |
|
|
|
329 |
//結束執行
|
|
|
330 |
return;
|
| 317 |
liveuser |
331 |
|
| 326 |
liveuser |
332 |
}//if end
|
| 317 |
liveuser |
333 |
|
| 326 |
liveuser |
334 |
//如果不是合法的 json 格式
|
|
|
335 |
if(res.compliantJson==='false'){
|
| 317 |
liveuser |
336 |
|
| 326 |
liveuser |
337 |
//console erorr message
|
|
|
338 |
console.error('invalid json response');
|
|
|
339 |
|
|
|
340 |
//結束執行
|
|
|
341 |
return;
|
| 317 |
liveuser |
342 |
|
| 326 |
liveuser |
343 |
}//if end
|
| 317 |
liveuser |
344 |
|
| 326 |
liveuser |
345 |
//連線到web socket,並傳輸資料,會回傳promise.亦即要在 async function 中使用,且使用 await 來取得結果.
|
|
|
346 |
//params,參數物件.
|
|
|
347 |
//params.url,web socket的url,加密的連線為wss://url,預設為當前頁面的 domain name/wss
|
|
|
348 |
//params.callback,函式,參數為收到的訊息,收到訊息後要怎麼處理.
|
|
|
349 |
//params.data,要傳輸的資料物件.
|
|
|
350 |
//params.data.id,用於識別wss連線是屬於誰的id資訊,預設為自動產生.
|
|
|
351 |
var params={};
|
|
|
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說認證通過
|
|
|
362 |
while(res.from!='server' || res.msg!='authenticated'){
|
|
|
363 |
|
|
|
364 |
//連線到web socket,並傳輸資料,會回傳promise.亦即要在 async function 中使用,且使用 await 來取得結果.
|
|
|
365 |
//params,參數物件.
|
|
|
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={};
|
|
|
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 |
";
|
| 317 |
liveuser |
385 |
#可省略參數:
|
| 326 |
liveuser |
386 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
387 |
#$conf["onReady"]="true";
|
|
|
388 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
389 |
#$conf["globalJs"]=array();
|
|
|
390 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
391 |
#$conf["jsFunciton"]=array();
|
|
|
392 |
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
|
|
|
393 |
#$conf["noScriptTag"]="false";
|
| 317 |
liveuser |
394 |
#參考資料:
|
| 326 |
liveuser |
395 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
| 317 |
liveuser |
396 |
#備註:
|
| 326 |
liveuser |
397 |
#無.
|
|
|
398 |
$toScript=javaScript::toScript($conf);
|
| 317 |
liveuser |
399 |
unset($conf);
|
|
|
400 |
|
| 326 |
liveuser |
401 |
#如果執行失敗
|
|
|
402 |
if($toScript["status"]==="false"){
|
| 317 |
liveuser |
403 |
|
|
|
404 |
#函式說明:
|
|
|
405 |
#撰寫log
|
|
|
406 |
#回傳結果:
|
|
|
407 |
#$result["status"],狀態,"true"或"false".
|
|
|
408 |
#$result["error"],錯誤訊息陣列.
|
|
|
409 |
#$result["function"],當前函式的名稱.
|
|
|
410 |
#$result["argu"],使用的參數.
|
|
|
411 |
#必填參數:
|
|
|
412 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
413 |
$conf["path"]=$logFile;
|
|
|
414 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
| 326 |
liveuser |
415 |
$conf["content"]=$toScript;
|
| 317 |
liveuser |
416 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
417 |
$conf["fileArgu"]=__FILE__;
|
|
|
418 |
#可省略參數:
|
|
|
419 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
420 |
#$conf["rewrite"]="false";
|
|
|
421 |
#參考資料:
|
|
|
422 |
#無.
|
|
|
423 |
#備註:
|
|
|
424 |
#無.
|
|
|
425 |
$record=logs::record($conf);
|
|
|
426 |
unset($conf);
|
|
|
427 |
|
|
|
428 |
#如果寫log失敗
|
|
|
429 |
if($record["status"]==="false"){
|
|
|
430 |
|
| 326 |
liveuser |
431 |
#印出結果
|
|
|
432 |
var_dump($record);
|
| 317 |
liveuser |
433 |
|
|
|
434 |
}#if end
|
|
|
435 |
|
|
|
436 |
#結束執行,回傳錯誤代碼1
|
|
|
437 |
exit(1);
|
|
|
438 |
|
|
|
439 |
}#if end
|
|
|
440 |
|
| 326 |
liveuser |
441 |
#debug
|
|
|
442 |
echo $toScript["content"];
|
| 317 |
liveuser |
443 |
|