| 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 |
|
| 326 |
liveuser |
27 |
本程式說明:
|
| 317 |
liveuser |
28 |
|
| 326 |
liveuser |
29 |
已拋棄.
|
| 317 |
liveuser |
30 |
|
|
|
31 |
*/
|
|
|
32 |
|
|
|
33 |
#使用命名空間qbpwcf
|
|
|
34 |
namespace qbpwcf;
|
|
|
35 |
|
|
|
36 |
#初始化輸出
|
|
|
37 |
$output=array();
|
|
|
38 |
|
|
|
39 |
#取得 lib path
|
|
|
40 |
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
|
|
|
41 |
|
|
|
42 |
#如果執行失敗
|
|
|
43 |
if($status!==0){
|
|
|
44 |
|
|
|
45 |
#debug
|
|
|
46 |
var_dump(__LINE__,$output);
|
|
|
47 |
|
|
|
48 |
#結束執行,回傳shell 1.
|
|
|
49 |
exit(1);
|
|
|
50 |
|
|
|
51 |
}#if end
|
|
|
52 |
|
|
|
53 |
#儲存lib path
|
|
|
54 |
$folderOfUsrLib=$output[0];
|
|
|
55 |
|
|
|
56 |
#初始化輸出
|
|
|
57 |
$output=array();
|
|
|
58 |
|
|
|
59 |
#以該檔案的實際位置的 lib path 為 include path 首位
|
|
|
60 |
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);
|
|
|
61 |
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
|
|
|
62 |
|
|
|
63 |
#建議的log位置
|
|
|
64 |
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
|
|
|
65 |
|
|
|
66 |
#關閉既有session
|
|
|
67 |
session_abort();
|
|
|
68 |
|
|
|
69 |
#設置session儲存位置
|
|
|
70 |
session_save_path(".hta-session");
|
|
|
71 |
|
|
|
72 |
#啟動 session
|
|
|
73 |
session_start();
|
|
|
74 |
|
|
|
75 |
#取得session id
|
|
|
76 |
$sId=session_id();
|
|
|
77 |
|
|
|
78 |
#匯入套件
|
|
|
79 |
require_once("allInOne.php");
|
|
|
80 |
|
|
|
81 |
#函式說明:
|
|
|
82 |
#建立以圖片(PNG格式)呈現的驗證碼.
|
|
|
83 |
#回傳的解果:
|
|
|
84 |
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
|
|
|
85 |
#$result["error"],錯誤訊息.
|
|
|
86 |
#$result["function"],檔前執行的函數名稱.
|
|
|
87 |
#$result["randNumberWord"],傳驗證碼的內容.
|
|
|
88 |
#$result["imgAddress"],包含src圖片的位置與名稱.
|
|
|
89 |
#$result["imgSrcVal"],放在src裏面的圖片位置與名稱.
|
|
|
90 |
#必填參數:
|
|
|
91 |
#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
|
|
|
92 |
$conf["imgAddressAndName"]="/tmp/notExsit.img";
|
|
|
93 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
94 |
$conf["fileArgu"]=__FILE__;
|
|
|
95 |
#可省略參數:
|
|
|
96 |
#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
|
|
|
97 |
#$conf["num"]="8";
|
|
|
98 |
#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
|
|
|
99 |
$conf["disableImg"]="true";
|
|
|
100 |
#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
|
|
|
101 |
#$conf["imgToData"]="true";
|
|
|
102 |
#$conf["class"],字串,圖片要套用的css樣式類別.
|
|
|
103 |
#$conf["class"]="";
|
|
|
104 |
#$conf["content"],字串陣列,允許的亂數陣列內容,預設爲(1~9 and A~Z).
|
|
|
105 |
#$conf["content"]=array();
|
|
|
106 |
#參考資料:
|
|
|
107 |
#無.
|
|
|
108 |
#備註:
|
|
|
109 |
#無.
|
|
|
110 |
$validationCode=authenticate::validationCode($conf);
|
|
|
111 |
unset($conf);
|
|
|
112 |
|
|
|
113 |
#如果執行失敗
|
|
|
114 |
if($validationCode["status"]==="false"){
|
|
|
115 |
|
|
|
116 |
#函式說明:
|
|
|
117 |
#撰寫log
|
|
|
118 |
#回傳結果:
|
|
|
119 |
#$result["status"],狀態,"true"或"false".
|
|
|
120 |
#$result["error"],錯誤訊息陣列.
|
|
|
121 |
#$result["function"],當前函式的名稱.
|
|
|
122 |
#$result["argu"],使用的參數.
|
|
|
123 |
#必填參數:
|
|
|
124 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
125 |
$conf["path"]=$logFile;
|
|
|
126 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
127 |
$conf["content"]=$validationCode;
|
|
|
128 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
129 |
$conf["fileArgu"]=__FILE__;
|
|
|
130 |
#可省略參數:
|
|
|
131 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
132 |
#$conf["rewrite"]="false";
|
|
|
133 |
#參考資料:
|
|
|
134 |
#無.
|
|
|
135 |
#備註:
|
|
|
136 |
#無.
|
|
|
137 |
$record=logs::record($conf);
|
|
|
138 |
unset($conf);
|
|
|
139 |
|
|
|
140 |
#如果寫log失敗
|
|
|
141 |
if($record["status"]==="false"){
|
|
|
142 |
|
|
|
143 |
#印出json結果
|
|
|
144 |
echo json_encode($record);
|
|
|
145 |
|
|
|
146 |
}#if end
|
|
|
147 |
|
|
|
148 |
#結束執行,回傳錯誤代碼1
|
|
|
149 |
exit(1);
|
|
|
150 |
|
|
|
151 |
}#if end
|
|
|
152 |
|
|
|
153 |
#隨機產生字串
|
|
|
154 |
$randomStr=$validationCode["randNumberWord"];
|
|
|
155 |
|
|
|
156 |
#session file 的儲存路徑
|
|
|
157 |
$sessionStorePath=shell_exec("pwd")."/.hta-session/";
|
|
|
158 |
|
|
|
159 |
#變成json字串
|
|
|
160 |
#指定要使用的函式(callFunc)
|
|
|
161 |
#指定session檔案的位置(sessionStorePath)
|
|
|
162 |
#指定session檔案名稱的關鍵內容(sId)
|
|
|
163 |
#設置最長等待(timeout)300秒
|
|
|
164 |
#透過randomStr讓內容隨着時間變化
|
|
|
165 |
$jsonStr=json_encode(array("callFunc"=>"checkStatusOfEmailVarify","timeout"=>"300","randomStr"=>$randomStr,"sessionStorePath"=>$sessionStorePath,"sId"=>$sId));
|
|
|
166 |
|
|
|
167 |
#用GnuPG加密
|
|
|
168 |
|
|
|
169 |
#函式說明:
|
|
|
170 |
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,gpg,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
|
|
|
171 |
#回傳結果:
|
|
|
172 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
173 |
#$result["function"],當前執行的函數名稱.
|
|
|
174 |
#$result["content"],加密後的結果.
|
|
|
175 |
#$result["error"],錯誤訊息陣列.
|
|
|
176 |
#$result["argu"],使用的參數.
|
|
|
177 |
#必填參數:
|
|
|
178 |
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
|
|
|
179 |
$conf["enCodeStr"]=$jsonStr;
|
|
|
180 |
#$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.
|
|
|
181 |
$conf["enCodeType"]="gpg";
|
|
|
182 |
#可省略參數:
|
|
|
183 |
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
|
|
|
184 |
#$conf["sha1Raw"]="false";
|
|
|
185 |
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
|
|
|
186 |
#$conf["p_hash"]="";
|
|
|
187 |
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
|
|
|
188 |
#$conf["keyForAes256"]="";
|
|
|
189 |
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
|
|
|
190 |
#$conf["aes256Encode"]="";
|
|
|
191 |
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
|
|
|
192 |
#$conf["qbpwcfDecode"]="false";
|
|
|
193 |
#$conf["gpgDecrypt"],字串,若"enCodeType"為"gpg",則預設為"false",代表加密;反之為"true",代表解密.
|
|
|
194 |
#$conf["gpgDecrypt"]="false";
|
|
|
195 |
#$conf["gpgId"],字串,若"enCodeType"為"gpg"時,該參數必填.
|
|
|
196 |
$conf["gpgId"]=gnupgId;
|
|
|
197 |
#參考資料:
|
|
|
198 |
#sha1=>http://php.net/manual/en/function.sha1.php
|
|
|
199 |
#md5=>http://php.net/manual/en/function.md5.php
|
|
|
200 |
#password_hash=>http://php.net/manual/en/function.password-hash.php
|
|
|
201 |
#password_verify=>http://php.net/manual/en/function.password-verify.php
|
|
|
202 |
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
|
|
|
203 |
#備註:
|
|
|
204 |
#無.
|
|
|
205 |
$enCodeStr=authenticate::enCodeStr($conf);
|
|
|
206 |
unset($conf);
|
|
|
207 |
|
|
|
208 |
#如果執行失敗
|
|
|
209 |
if($enCodeStr["status"]==="false"){
|
|
|
210 |
|
|
|
211 |
#函式說明:
|
|
|
212 |
#撰寫log
|
|
|
213 |
#回傳結果:
|
|
|
214 |
#$result["status"],狀態,"true"或"false".
|
|
|
215 |
#$result["error"],錯誤訊息陣列.
|
|
|
216 |
#$result["function"],當前函式的名稱.
|
|
|
217 |
#$result["argu"],使用的參數.
|
|
|
218 |
#必填參數:
|
|
|
219 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
220 |
$conf["path"]=$logFile;
|
|
|
221 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
222 |
$conf["content"]=$enCodeStr;
|
|
|
223 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
224 |
$conf["fileArgu"]=__FILE__;
|
|
|
225 |
#可省略參數:
|
|
|
226 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
227 |
#$conf["rewrite"]="false";
|
|
|
228 |
#參考資料:
|
|
|
229 |
#無.
|
|
|
230 |
#備註:
|
|
|
231 |
#無.
|
|
|
232 |
$record=logs::record($conf);
|
|
|
233 |
unset($conf);
|
|
|
234 |
|
|
|
235 |
#如果寫log失敗
|
|
|
236 |
if($record["status"]==="false"){
|
|
|
237 |
|
|
|
238 |
#印出json結果
|
|
|
239 |
echo json_encode($record);
|
|
|
240 |
|
|
|
241 |
}#if end
|
|
|
242 |
|
|
|
243 |
#結束執行,回傳錯誤代碼1
|
|
|
244 |
exit(1);
|
|
|
245 |
|
|
|
246 |
}#if end
|
|
|
247 |
|
|
|
248 |
#取得加密後的json字串
|
|
|
249 |
$encryptedJsonStr=$enCodeStr["content"];
|
|
|
250 |
|
|
|
251 |
#函式說明:
|
|
|
252 |
#加密或編碼字串,可以用的方法有sha1,md5,password_sha,qbpwcf,bin2hex,hex2bin,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
|
|
|
253 |
#回傳結果:
|
|
|
254 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
255 |
#$result["function"],當前執行的函數名稱.
|
|
|
256 |
#$result["content"],加密後的結果.
|
|
|
257 |
#$result["error"],錯誤訊息陣列.
|
|
|
258 |
#$result["argu"],使用的參數.
|
|
|
259 |
#必填參數:
|
|
|
260 |
#$conf["enCodeStr"],any,要加密的字串,陣列,物件.
|
|
|
261 |
$conf["enCodeStr"]=$encryptedJsonStr;
|
|
|
262 |
#$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".
|
|
|
263 |
$conf["enCodeType"]="bin2hex";
|
|
|
264 |
#可省略參數:
|
|
|
265 |
#$conf["sha1Raw"],字串,sha1加密的結果要用20個0與1組合還是要用40位數的16進位數值,"true"代表前者,"false"代表後者,預設為"false".
|
|
|
266 |
#$conf["sha1Raw"]="false";
|
|
|
267 |
#$conf["p_hash"],字串,p_hash加密過後的字串,該參數若存在且$conf["enCodeType"]為"p_hash",則代表是要檢查$conf["enCodeStr"]是否為符合$conf["p_hash"]的密碼.
|
|
|
268 |
#$conf["p_hash"]="";
|
|
|
269 |
#$conf["keyForAes256"],字串,用來 AES256 加解密的金鑰.
|
|
|
270 |
#$conf["keyForAes256"]="";
|
|
|
271 |
#$conf["aes256Encode"],字串,"true"代表是要加密,"false"代表是要解密.
|
|
|
272 |
#$conf["aes256Encode"]="";
|
|
|
273 |
#$conf["qbpwcfDecode"],字串,若"enCodeType"為"qbpwcf",則預設為"false",代表加密;反之為"true",代表解密.
|
|
|
274 |
#$conf["qbpwcfDecode"]="false";
|
|
|
275 |
#參考資料:
|
|
|
276 |
#sha1=>http://php.net/manual/en/function.sha1.php
|
|
|
277 |
#md5=>http://php.net/manual/en/function.md5.php
|
|
|
278 |
#password_hash=>http://php.net/manual/en/function.password-hash.php
|
|
|
279 |
#password_verify=>http://php.net/manual/en/function.password-verify.php
|
|
|
280 |
#json_decode=>https://www.php.net/manual/en/function.json-decode.php
|
|
|
281 |
#備註:
|
|
|
282 |
#無.
|
|
|
283 |
$enCodeStr=authenticate::enCodeStr($conf);
|
|
|
284 |
unset($conf);
|
|
|
285 |
|
|
|
286 |
#如果執行失敗
|
|
|
287 |
if($enCodeStr["status"]==="false"){
|
|
|
288 |
|
|
|
289 |
#函式說明:
|
|
|
290 |
#撰寫log
|
|
|
291 |
#回傳結果:
|
|
|
292 |
#$result["status"],狀態,"true"或"false".
|
|
|
293 |
#$result["error"],錯誤訊息陣列.
|
|
|
294 |
#$result["function"],當前函式的名稱.
|
|
|
295 |
#$result["argu"],使用的參數.
|
|
|
296 |
#必填參數:
|
|
|
297 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
298 |
$conf["path"]=$logFile;
|
|
|
299 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
300 |
$conf["content"]=$enCodeStr;
|
|
|
301 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
302 |
$conf["fileArgu"]=__FILE__;
|
|
|
303 |
#可省略參數:
|
|
|
304 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
305 |
#$conf["rewrite"]="false";
|
|
|
306 |
#參考資料:
|
|
|
307 |
#無.
|
|
|
308 |
#備註:
|
|
|
309 |
#無.
|
|
|
310 |
$record=logs::record($conf);
|
|
|
311 |
unset($conf);
|
|
|
312 |
|
|
|
313 |
#如果寫log失敗
|
|
|
314 |
if($record["status"]==="false"){
|
|
|
315 |
|
|
|
316 |
#印出json結果
|
|
|
317 |
echo json_encode($record);
|
|
|
318 |
|
|
|
319 |
}#if end
|
|
|
320 |
|
|
|
321 |
#結束執行,回傳錯誤代碼1
|
|
|
322 |
exit(1);
|
|
|
323 |
|
|
|
324 |
}#if end
|
|
|
325 |
|
|
|
326 |
#取得編碼後的加密後的json字串
|
|
|
327 |
$encodedEencryptedJsonStr=$enCodeStr["content"];
|
|
|
328 |
|
|
|
329 |
#函式說明:
|
|
|
330 |
#可以輸入Email的輸入方框
|
|
|
331 |
#回傳結果:
|
|
|
332 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
333 |
#$result["function"],當前執行的函數.
|
|
|
334 |
#$result["error"],錯誤訊息陣列.
|
|
|
335 |
#$result["content"],按鈕語法.
|
|
|
336 |
#必填參數:
|
|
|
337 |
#$conf["name"],字串,爲該文字輸入框的名稱,用於讓接收頁面讀取的名稱。
|
|
|
338 |
$conf["name"]="email";
|
|
|
339 |
#$conf["readOnly"],字串,爲該文字框是否可以填寫資料,若要只能觀看不能填寫,那麼就必須將其值設爲"true",反之要設爲"false".
|
|
|
340 |
$conf["readOnly"]="false";
|
|
|
341 |
#可省略參數:
|
|
|
342 |
#$conf["width"],字串,爲文字框的外觀長度,預設為"100%".
|
|
|
343 |
#$conf["width"]="";
|
|
|
344 |
#$conf["maxInputLength"],字串,爲可輸入的最大位元長度,預設不限制.
|
|
|
345 |
#$conf["maxInputLength"]="";
|
|
|
346 |
#$conf["autoFocus"],字串,是否為將填寫的指標移到該表單,"true"代表要,預設為"false".
|
|
|
347 |
$conf["autoFocus"]="true";
|
|
|
348 |
#$conf["value"],字串,爲該文字框預設要顯示的文字,預設爲"".
|
|
|
349 |
#$conf["value"]="";
|
|
|
350 |
#$conf["class"],字串,爲要套用的css樣式,若省略,則會套用預設的 "__qbpwcf_inputTextCssStyle" 樣式,其屬性爲 "width:100%","font-size:30px"
|
|
|
351 |
#$conf["class"]="";
|
|
|
352 |
#$conf["classList"],字串陣列,為要使用的多個css class樣式,若有使用,則會取代"class"參數的設定.
|
|
|
353 |
#$conf["classList"]=array();
|
|
|
354 |
#$conf["jsActivitor"],字串,爲觸發js的條件,可以是"onChange"(已改變內容時)、"onClick"(按下按鈕時)、"onkeyup"(當鍵盤按下放開後)、"onmouseover"(當滑鼠移過去的時候)...,須搭配$conf["jsSubmitActionTarget"]參數。
|
|
|
355 |
#$conf["jsActivitor"]="";
|
|
|
356 |
#$conf["jsAction"],字串,爲該js是要做什麼,可以是"document.testForm.submit()"(傳送名爲testForm的表單內容)...,須搭配$conf["jsActivitor"]參數。
|
|
|
357 |
#$conf["jsAction"]="";
|
|
|
358 |
#$conf["trStart"],字串,爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
359 |
#$conf["trStart"]="";
|
|
|
360 |
#$conf["tdStart"],字串,爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
361 |
#$conf["tdStart"]="";
|
|
|
362 |
#$conf["formStart"],字串,爲是否要以<form>開頭,"true"表示"是",也可以看成表單的開始,預設為"false".
|
|
|
363 |
#$conf["formStart"]="";
|
|
|
364 |
#$conf["formAction"],字串,表單遞交的目的地,若$conf["formStart"]為"true",則該參數不能省略.
|
|
|
365 |
#$conf["formAction"]="";
|
|
|
366 |
#$conf["formName"],字串,爲該表單的名稱
|
|
|
367 |
#$conf["formName"]="email";
|
|
|
368 |
#$conf["formMethod"],字串,爲傳輸的方法,若沒設定則預設爲post,其他可用的參數爲get。
|
|
|
369 |
#$conf["formMethod"]="";
|
|
|
370 |
#$conf["formTarget"],字串,為顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。
|
|
|
371 |
#$conf["formTarget"]="";
|
|
|
372 |
#$conf["tableStart"],字串,爲該表單是否要以<table>開始。"true"爲是,預設為"false".
|
|
|
373 |
#$conf["tableStart"]="";
|
|
|
374 |
#$conf["tableClass"],字串,表格要套用的css樣式,若爲"__withoutBorder"的話則套用無框線的預設樣式;若爲"__withBorder"的話,則爲有框線的預設樣式,預設為"__withoutBorder".
|
|
|
375 |
#$conf["tableClass"]="";
|
|
|
376 |
#$conf["formEnd"],字串,爲是否要以<form>結尾,"true"表示"是",也可以看成表單的結束,預設為"false".
|
|
|
377 |
#$conf["formEnd"]="true";
|
|
|
378 |
#$conf["tdEnd"],字串,爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
379 |
#$conf["tdEnd"]="true";
|
|
|
380 |
#$conf["trEnd"],字串,爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
381 |
#$conf["trEnd"]="true";
|
|
|
382 |
#$conf["tableEnd"],字串,爲該表單是否要以</table>結尾,"true"爲是,預設為"false".
|
|
|
383 |
#$conf["tableEnd"]="true";
|
|
|
384 |
#$conf["autocomplete"],字串,是否依據使用者過往輸入的記錄來提示可能要的輸入內容,"on"為啟用,"off"為停用,預設為"on".
|
|
|
385 |
#$conf["autocomplete"]="off";
|
|
|
386 |
#$conf["required"],字串,該欄位是否必填,"true"為必填,"false"為可留空,預設為"false".
|
|
|
387 |
$conf["required"]="true";
|
|
|
388 |
#$conf["comment"],字串,輸入方框上面要放哪些註解文字,亦即用label來呈現,同時指定"for"屬性的數值為當前"input"標籤的id,意即參數"name"的內容.
|
|
|
389 |
$conf["comment"]="請先進行Email認證";
|
|
|
390 |
#$conf["placeholder"],字串,當沒有內容時要顯示的內容.
|
|
|
391 |
$conf["placeholder"]="username@mail.doamin";
|
|
|
392 |
#$conf["br"],字串,"true"代表最後要換行,預設為"false".
|
|
|
393 |
#$conf["br"]="true";
|
|
|
394 |
#$conf["p"],字串,"true"代表最後要空一行,預設為"false".
|
|
|
395 |
#$conf["p"]="true";
|
|
|
396 |
#$conf["id"],字串,該元素的id,預設不使用.
|
|
|
397 |
$conf["id"]="email";
|
|
|
398 |
#$conf["dataFormId"],字串,提供用於識別哪一張表單的data屬性名稱.
|
|
|
399 |
#$conf["dataFormId"]="";
|
|
|
400 |
#參考資料:
|
|
|
401 |
#https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/email
|
|
|
402 |
#備註:
|
|
|
403 |
#無.
|
|
|
404 |
$inputEmail=form::inputEmail($conf);
|
|
|
405 |
unset($conf);
|
|
|
406 |
|
|
|
407 |
#如果執行失敗
|
|
|
408 |
if($inputEmail["status"]==="false"){
|
|
|
409 |
|
|
|
410 |
#函式說明:
|
|
|
411 |
#撰寫log
|
|
|
412 |
#回傳結果:
|
|
|
413 |
#$result["status"],狀態,"true"或"false".
|
|
|
414 |
#$result["error"],錯誤訊息陣列.
|
|
|
415 |
#$result["function"],當前函式的名稱.
|
|
|
416 |
#$result["argu"],使用的參數.
|
|
|
417 |
#必填參數:
|
|
|
418 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
419 |
$conf["path"]=$logFile;
|
|
|
420 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
421 |
$conf["content"]=$inputEmail;
|
|
|
422 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
423 |
$conf["fileArgu"]=__FILE__;
|
|
|
424 |
#可省略參數:
|
|
|
425 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
426 |
#$conf["rewrite"]="false";
|
|
|
427 |
#參考資料:
|
|
|
428 |
#無.
|
|
|
429 |
#備註:
|
|
|
430 |
#無.
|
|
|
431 |
$record=logs::record($conf);
|
|
|
432 |
unset($conf);
|
|
|
433 |
|
|
|
434 |
#如果寫log失敗
|
|
|
435 |
if($record["status"]==="false"){
|
|
|
436 |
|
|
|
437 |
#印出結果
|
|
|
438 |
var_dump($record);
|
|
|
439 |
|
|
|
440 |
}#if end
|
|
|
441 |
|
|
|
442 |
#結束執行,回傳錯誤代碼1
|
|
|
443 |
exit(1);
|
|
|
444 |
|
|
|
445 |
}#if end
|
|
|
446 |
|
|
|
447 |
#印出語法
|
|
|
448 |
echo $inputEmail["content"];
|
|
|
449 |
|
|
|
450 |
#函式說明:
|
|
|
451 |
#放置按鈕
|
|
|
452 |
#回傳結果:
|
|
|
453 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
454 |
#$result["function"],當前執行的函數.
|
|
|
455 |
#$result["error"],錯誤訊息陣列.
|
|
|
456 |
#$result["content"],按鈕語法.
|
|
|
457 |
#必填參數:
|
|
|
458 |
$conf["buttonDisplayValue"]="驗證Email";#爲按鈕上顯示的文字。
|
|
|
459 |
#可省略參數:
|
|
|
460 |
#$conf["buttonStyleName"]="";#可省略,爲按鈕所要使用的css樣式類別名稱,預設的css樣式爲 __qbpwcf_button 。
|
|
|
461 |
#$conf["buttonActionScriptFunction"]="";#可省略,爲按下按鈕時所要執行的javaScript函式或程式,預設不設定。
|
|
|
462 |
#"document.forms.formName.submit()"爲傳送名爲testForm的表單內容
|
|
|
463 |
#"window.print()"爲使用瀏覽器內建工具列印當前網頁
|
|
|
464 |
#若搭配 javaScript 類別的 confirmWindow 函數的回傳結果,則會有確認視窗的效果.
|
|
|
465 |
#$conf["buttonBorder"]="";#可省略,爲IE9內會自動產生外框,此爲外框的厚度,屬性值爲正整數,預設爲0。
|
|
|
466 |
#$conf["disabled"]="true";#可省略,為按鈕的功能是否要取消,若為"true"則代表要取消,若為"false"則代表功能正常,預設為"false".
|
|
|
467 |
#$conf["tableStart"]="true";#爲是否要表格開始。"false"代表否,"true"代表是。預設爲"false"。
|
|
|
468 |
#$conf["tableClass"]="";#表格要套用的css樣式,若省略的話,則預設爲 __defaultTbaleCsssStyle 其屬性爲 table-layout:fixed word-break:break-all width:100% ,須搭配 $conf["tablStart"] 與 $conf["tableEnd"] 使用。
|
|
|
469 |
#$conf["trStart"]="true";#爲是否要以<tr>開頭,"true"表示"是"。也可以看作新的一列開始,預設為"false".
|
|
|
470 |
#$conf["trClass"]="__withoutBorder";#<tr>要套用的css樣式,預設為"__withoutBorder",亦即沒有框線的樣式;"__withBorder"則爲有框線的樣式
|
|
|
471 |
#$conf["tdStart"]="true";#爲是否要以<td>開頭,"true"表示"是"。也可以看成列裏面的元素開始,預設為"false".
|
|
|
472 |
#$conf["tdClass"]="__withoutBorder";#<td>要套用的css樣式,"__withoutBorder"爲沒有框線的樣式;__withBorder爲有框線的樣式
|
|
|
473 |
#$conf["tdEnd"]="true";#爲是否要以</td>結尾,"true"表示"是"。也可以看成列裏面的元素結束,預設為"false".
|
|
|
474 |
#$conf["trEnd"]="true";#爲是否要以</tr>結尾,"true"表示"是"。也可以看作該列結束,預設為"false".
|
|
|
475 |
#$conf["tableEnd"]="true";#爲是否要表格結束。"false"代表否,"true"代表是,預設爲"false"。
|
|
|
476 |
#$conf["formStart"]="true";#爲是否要表單開始,如果爲"true"則代表要表單開始,預設為"false".
|
|
|
477 |
#$conf["action"]="";#爲表單要傳送到哪個頁面,須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
478 |
#$conf["target"]="";#為目標表單顯示的方式,若沒設定則預設爲"_self",其他可用的參數爲 "_blank"、"_parent"、"_top",也可以是iframe的名稱。須搭配$conf["formStart"]與$conf["formEnd"]參數使用
|
|
|
479 |
#$conf["formEnd"]="true";#爲是否要表單結束,如果爲"true"則代表要表單結束,預設為"false".
|
|
|
480 |
#$conf["formId"],字串,表單的id.
|
|
|
481 |
#$conf["formId"]="";
|
|
|
482 |
#$conf["buttonId"],字串,按鈕的id.
|
|
|
483 |
$conf["buttonId"]="validEmailBtn";
|
|
|
484 |
#參考資料:
|
|
|
485 |
#http://stackoverflow.com/questions/3014649/how-to-disable-html-button-using-javascript
|
|
|
486 |
#備註:
|
|
|
487 |
#無.
|
|
|
488 |
$button=form::button($conf);
|
|
|
489 |
unset($conf);
|
|
|
490 |
|
|
|
491 |
#如果執行失敗
|
|
|
492 |
if($button["status"]==="false"){
|
|
|
493 |
|
|
|
494 |
#函式說明:
|
|
|
495 |
#撰寫log
|
|
|
496 |
#回傳結果:
|
|
|
497 |
#$result["status"],狀態,"true"或"false".
|
|
|
498 |
#$result["error"],錯誤訊息陣列.
|
|
|
499 |
#$result["function"],當前函式的名稱.
|
|
|
500 |
#$result["argu"],使用的參數.
|
|
|
501 |
#必填參數:
|
|
|
502 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
503 |
$conf["path"]=$logFile;
|
|
|
504 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
505 |
$conf["content"]=$button;
|
|
|
506 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
507 |
$conf["fileArgu"]=__FILE__;
|
|
|
508 |
#可省略參數:
|
|
|
509 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
510 |
#$conf["rewrite"]="false";
|
|
|
511 |
#參考資料:
|
|
|
512 |
#無.
|
|
|
513 |
#備註:
|
|
|
514 |
#無.
|
|
|
515 |
$record=logs::record($conf);
|
|
|
516 |
unset($conf);
|
|
|
517 |
|
|
|
518 |
#如果寫log失敗
|
|
|
519 |
if($record["status"]==="false"){
|
|
|
520 |
|
|
|
521 |
#印出結果
|
|
|
522 |
var_dump($record);
|
|
|
523 |
|
|
|
524 |
}#if end
|
|
|
525 |
|
|
|
526 |
#結束執行,回傳錯誤代碼1
|
|
|
527 |
exit(1);
|
|
|
528 |
|
|
|
529 |
}#if end
|
|
|
530 |
|
|
|
531 |
#印出按鈕
|
|
|
532 |
echo $button["content"];
|
|
|
533 |
|
|
|
534 |
#函式說明:
|
|
|
535 |
#將要執行的script語法透過該函式執行(會在程式外層用<script></script>包起來).
|
|
|
536 |
#回傳結果:
|
|
|
537 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
538 |
#$result["error"],錯誤訊息陣列
|
|
|
539 |
#$result["function"],當前執行的函數名稱
|
|
|
540 |
#$result["content"],要執行的javaScript語法
|
|
|
541 |
#必填參數:
|
|
|
542 |
#$conf["script"],字串,要執行的javaScript語法.
|
|
|
543 |
$conf["script"]=
|
|
|
544 |
"
|
|
|
545 |
//匿名的函式
|
|
|
546 |
var waitVerifiedEmail=function(){
|
|
|
547 |
|
|
|
548 |
//建立跟 server 的 web socket,並等待訊息
|
|
|
549 |
//連線到web socket,並傳輸資料,會回傳promise.亦即要在 async function 中使用,且使用 await 來取得結果.
|
|
|
550 |
//params,參數物件.
|
|
|
551 |
//params.url,web socket的url,加密的連線為 wss://url,url預設為當前頁面的 domain name.
|
|
|
552 |
//params.callback,函式,參數為收到的訊息,收到訊息後要怎麼處理.
|
|
|
553 |
//params.data,要傳輸的資料物件.
|
|
|
554 |
//params.data.id,用於識別wss連線是屬於誰的id資訊,預設為自動產生.
|
|
|
555 |
param={};
|
|
|
556 |
param.url='wss://ws.qbpwcf.org';
|
|
|
557 |
param.data={};
|
|
|
558 |
param.data.secrect='".$encodedEencryptedJsonStr."';
|
|
|
559 |
var res=await window.qbpwcf.ws.init(param);
|
|
|
560 |
|
|
|
561 |
//debug
|
|
|
562 |
console.log(res);
|
|
|
563 |
|
|
|
564 |
//如果收到驗證通過的訊息
|
|
|
565 |
if(res==='pass'){
|
|
|
566 |
|
|
|
567 |
//設置給予parent的用戶email
|
|
|
568 |
window.parent.window.validEmail=email.value;
|
|
|
569 |
|
|
|
570 |
//將本iframe移除
|
|
|
571 |
window.parent.window.document.getElementsByTagName('iframe')[0].remove();
|
|
|
572 |
|
|
|
573 |
}//if end
|
|
|
574 |
|
|
|
575 |
}//function end
|
|
|
576 |
|
|
|
577 |
//取得驗證email的按鈕
|
|
|
578 |
var validEmailBtn=document.getElementById('validEmailBtn');
|
|
|
579 |
|
|
|
580 |
//取得要驗證email
|
|
|
581 |
var email=document.getElementById('email');
|
|
|
582 |
|
|
|
583 |
//點擊驗證email按鈕後
|
|
|
584 |
validEmailBtn.addEventListener('click',async function(e){
|
|
|
585 |
|
|
|
586 |
//若 email 無效
|
|
|
587 |
if(email.validity.valid===false){
|
|
|
588 |
|
|
|
589 |
//關注 email 欄位
|
|
|
590 |
email.focus();
|
|
|
591 |
|
|
|
592 |
}//if end
|
|
|
593 |
|
|
|
594 |
//反之
|
|
|
595 |
else{
|
|
|
596 |
|
|
|
597 |
/*
|
|
|
598 |
設置 window.qbpwcf.ajaxP 函數
|
|
|
599 |
說明:
|
|
|
600 |
傳送ajax,指定傳送前要做什麼事情,然後回傳一個Promise.
|
|
|
601 |
參數:
|
|
|
602 |
params={};
|
|
|
603 |
params.method='POST' or 'GET' or 'HEAD' or 'OPTIONS';
|
|
|
604 |
params.headers={name:value};
|
|
|
605 |
params.url='url to request';
|
|
|
606 |
params.preAc='function name to call before send request';
|
|
|
607 |
params.data='data to contain','key1=encodeURIComponent(val1)&key2=encodeURIComponent(val2)';if no data please use {};
|
|
|
608 |
參考資料:
|
|
|
609 |
https://eyesofkids.gitbooks.io/javascript-start-es6-promise/content/contents/ch11_snippets.html
|
|
|
610 |
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
|
611 |
*/
|
|
|
612 |
params={};
|
|
|
613 |
params.method='POST';
|
|
|
614 |
params.url='../sendMailAgent/';
|
|
|
615 |
//params.preAc='function name to call before send request';
|
|
|
616 |
params.data='email='+encodeURIComponent(email.value);
|
|
|
617 |
var res=await window.qbpwcf.ajaxP(params);
|
|
|
618 |
|
|
|
619 |
//等待認證通過
|
|
|
620 |
waitVerifiedEmail;
|
|
|
621 |
|
|
|
622 |
}//else end
|
|
|
623 |
|
|
|
624 |
});
|
|
|
625 |
";
|
|
|
626 |
#可省略參數:
|
|
|
627 |
#$conf["onReady"],字串,是否要在網頁完全載入後再執行,"false"為不等載入完就先執行,預設為"true"要等載入完再執行.
|
|
|
628 |
#$conf["onReady"]="true";
|
|
|
629 |
#$conf["globalJs"],字串陣列,為要放入<script>標籤的js全域變數.
|
|
|
630 |
#$conf["globalJs"]=array();
|
|
|
631 |
#$conf["jsFunciton"],字串陣列,為要放入<script>標籤的js函數.
|
|
|
632 |
#$conf["jsFunciton"]=array();
|
|
|
633 |
#$conf["noScriptTag"],字串,是否不要輸出<script></script>,預設為"false",代表要輸出;反之為"true",代表不要輸出.
|
|
|
634 |
#$conf["noScriptTag"]="false";
|
|
|
635 |
#參考資料:
|
|
|
636 |
#http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the
|
|
|
637 |
#備註:
|
|
|
638 |
#無.
|
|
|
639 |
$toScript=javaScript::toScript($conf);
|
|
|
640 |
unset($conf);
|
|
|
641 |
|
|
|
642 |
#如果執行失敗
|
|
|
643 |
if($toScript["status"]==="false"){
|
|
|
644 |
|
|
|
645 |
#函式說明:
|
|
|
646 |
#撰寫log
|
|
|
647 |
#回傳結果:
|
|
|
648 |
#$result["status"],狀態,"true"或"false".
|
|
|
649 |
#$result["error"],錯誤訊息陣列.
|
|
|
650 |
#$result["function"],當前函式的名稱.
|
|
|
651 |
#$result["argu"],使用的參數.
|
|
|
652 |
#必填參數:
|
|
|
653 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
654 |
$conf["path"]=$logFile;
|
|
|
655 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
656 |
$conf["content"]=$toScript;
|
|
|
657 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
658 |
$conf["fileArgu"]=__FILE__;
|
|
|
659 |
#可省略參數:
|
|
|
660 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
661 |
#$conf["rewrite"]="false";
|
|
|
662 |
#參考資料:
|
|
|
663 |
#無.
|
|
|
664 |
#備註:
|
|
|
665 |
#無.
|
|
|
666 |
$record=logs::record($conf);
|
|
|
667 |
unset($conf);
|
|
|
668 |
|
|
|
669 |
#如果寫log失敗
|
|
|
670 |
if($record["status"]==="false"){
|
|
|
671 |
|
|
|
672 |
#印出結果
|
|
|
673 |
var_dump($record);
|
|
|
674 |
|
|
|
675 |
}#if end
|
|
|
676 |
|
|
|
677 |
#結束執行,回傳錯誤代碼1
|
|
|
678 |
exit(1);
|
|
|
679 |
|
|
|
680 |
}#if end
|
|
|
681 |
|
|
|
682 |
#印出語法
|
|
|
683 |
echo $toScript["content"];
|