| 3 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
|
|
6 |
Copyright (C) 2015~2025 Min-Jhin,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 |
#該檔案,不適用於撰寫SOAP服務。
|
|
|
28 |
|
|
|
29 |
#使用方法:
|
|
|
30 |
/*
|
|
|
31 |
|
|
|
32 |
#只要匯入當前目錄底下的 allInOne.php 即可使用各式類別方法。
|
|
|
33 |
#匯入的範例:
|
|
|
34 |
|
|
|
35 |
<?php
|
|
|
36 |
|
|
|
37 |
#使用命名空間,請務必指派爲 qbpwcf
|
|
|
38 |
namespace qbpwcf;
|
|
|
39 |
|
|
|
40 |
#匯入外部套件,檔案位置請依照需求去修改
|
|
|
41 |
require_once("allInOne.php");
|
|
|
42 |
|
|
|
43 |
#以下爲你的程式...
|
|
|
44 |
|
|
|
45 |
?>
|
|
|
46 |
|
|
|
47 |
*/
|
|
|
48 |
|
|
|
49 |
#指派命名空間
|
|
|
50 |
namespace qbpwcf;
|
|
|
51 |
|
|
|
52 |
#參考資料
|
|
|
53 |
#http://php.net/manual/en/function.set-exception-handler.php
|
|
|
54 |
#http://php.net/manual/en/function.set-error-handler.php
|
|
|
55 |
#https://stackoverflow.com/questions/4514568/how-to-catch-all-php-error
|
|
|
56 |
|
|
|
57 |
/*
|
|
|
58 |
|
|
|
59 |
#處理會導致程式無法執行的錯誤
|
|
|
60 |
set_error_handler(function($errno, $errstr, $errfile, $errline ){
|
|
|
61 |
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
|
|
|
62 |
});
|
|
|
63 |
|
|
|
64 |
#處理非導致程式無法執行的錯誤
|
|
|
65 |
#參考資料:
|
|
|
66 |
#http://php.net/manual/en/class.exception.php
|
|
|
67 |
set_exception_handler(function($exception){
|
|
|
68 |
echo "<p>".PHP_EOL;
|
|
|
69 |
echo "Uncaught exception: ".$exception->getMessage()."<br>".PHP_EOL;
|
|
|
70 |
echo "File: ".$exception->getFile()."<br>".PHP_EOL;
|
|
|
71 |
echo "Line: ".$exception->getLine()."<br>".PHP_EOL;
|
|
|
72 |
echo "Trace: ".print_r($exception->getTrace(),true)."<br>".PHP_EOL;
|
|
|
73 |
echo "The exception code is: ".$exception->getCode()."<br>".PHP_EOL;
|
|
|
74 |
exit;
|
|
|
75 |
});
|
|
|
76 |
|
|
|
77 |
*/
|
|
|
78 |
|
|
|
79 |
#如果是在命令列環境
|
|
|
80 |
if(!(isset($_SERVER['HTTP_USER_AGENT']))){
|
|
|
81 |
|
|
|
82 |
#改匯入 "allInOneForCmd.php"
|
|
|
83 |
require_once("allInOneForCmd.php");
|
|
|
84 |
|
|
|
85 |
#結束程式
|
|
|
86 |
return 0;
|
|
|
87 |
|
|
|
88 |
}#if end
|
|
|
89 |
|
|
|
90 |
#如果 session 不存在
|
|
|
91 |
if(!isset($_SESSION)){
|
|
|
92 |
|
|
|
93 |
#啟動 session
|
|
|
94 |
session_start();
|
|
|
95 |
|
|
|
96 |
}#if end
|
|
|
97 |
|
|
|
98 |
#如果尚未取得 lib path
|
|
|
99 |
if(!isset($folderOfUsrLib)){
|
|
|
100 |
|
|
|
101 |
#儲存要執行的指令
|
|
|
102 |
$cmd="php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../bin/libexec/folderOfUsrLib.php");
|
|
|
103 |
|
|
|
104 |
#取得 lib path
|
|
|
105 |
exec($cmd,$output,$status);
|
|
|
106 |
|
|
|
107 |
#如果執行失敗
|
|
|
108 |
if($status!==0){
|
|
|
109 |
|
|
|
110 |
#debug
|
|
|
111 |
var_dump($cmd,$ouput,$status);
|
|
|
112 |
|
|
|
113 |
#結束執行,回傳shell 1.
|
|
|
114 |
exit(1);
|
|
|
115 |
|
|
|
116 |
}#if end
|
|
|
117 |
|
|
|
118 |
#儲存lib path
|
|
|
119 |
$folderOfUsrLib=$output[0];
|
|
|
120 |
|
|
|
121 |
}#if end
|
|
|
122 |
|
|
|
123 |
#匯入自建的php類別檔
|
|
|
124 |
require_once("amazon.php"); #跟 amazon 互動的類別
|
|
|
125 |
require_once("analyse.php"); #跟問卷整理分析有關的類別
|
|
|
126 |
require_once("app.php"); #讓網頁變得更行動與app化
|
|
|
127 |
require_once("autoService.php"); #讓網頁可以管理系統的自動化服務
|
|
|
128 |
require_once("arrays.php"); #跟陣列有關的方法
|
|
|
129 |
require_once("authenticate.php"); #裏面包含跟驗證有關的功能
|
|
|
130 |
require_once("bigbluebutton.php"); #big blue button的應用
|
|
|
131 |
require_once("canvas.php"); #canvas 的應用
|
|
|
132 |
require_once("catchWebContent.php"); #包含可以抓取網頁內容的功能
|
|
|
133 |
require_once("chartJS.php"); #繪製圖表的js
|
|
|
134 |
require_once("cmd.php"); #跟命令列有關的功能
|
|
|
135 |
require_once("config.php"); #用於改變php執行環境的類別
|
|
|
136 |
require_once("css.php"); #裏面包含設定css樣式的功能,網頁美觀就靠它了。
|
|
|
137 |
require_once("csv.php"); #跟csv檔案有關的功能
|
|
|
138 |
require_once("csInformation.php"); #裏面包含取得用戶、伺服端資訊的功能。
|
|
|
139 |
#require_once("communication.php"); #網路通訊相關功能,開發中...
|
| 169 |
liveuser |
140 |
require_once("controlStructures.php"); #control structures 的應用.
|
| 3 |
liveuser |
141 |
require_once("ckEditor.php"); #ckeditor的相關應用
|
|
|
142 |
require_once("dataTable.php"); #將資料表的資料呈現出來並附上操作選項的設置
|
|
|
143 |
require_once("db.php"); #裏面包含跟資料庫操作有關的功能
|
|
|
144 |
require_once("external.php"); #執行外部程式
|
|
|
145 |
require_once("exam.php"); #包含跟測驗有關的功能
|
|
|
146 |
require_once("fb.php"); #裏面包含facebook提供的api服務
|
|
|
147 |
require_once("fileAccess.php"); #裏面包含檔案讀、寫的功能
|
|
|
148 |
require_once("flash.php"); #裏面包含嵌入flash到網頁會用到的功能
|
|
|
149 |
require_once("form.php"); #裏面包含表單的設計、傳送、接收與跟處理上傳檔案有關的功能
|
|
|
150 |
require_once("fuse.php"); #包含fuse的使用(ftp,sftp,glusterfs...)
|
|
|
151 |
require_once("frame.php"); #裏面包含 iframe 的設置功能
|
|
|
152 |
require_once("googleMap.php"); #裡面包含 googleMap 的應用
|
|
|
153 |
require_once("header.php"); #裏面包含轉址、網頁編碼、檔案下載、網頁資訊等設定功能
|
|
|
154 |
require_once("hive.php"); #連線到hiveServer進行操作
|
|
|
155 |
require_once("html.php"); #管理網頁內容的功能
|
|
|
156 |
require_once("img.php"); #裏面關於在網頁嵌入圖片、與繪圖的功能
|
|
|
157 |
require_once("javaScript.php"); #一些javaScript函式、語法可以參考
|
|
|
158 |
require_once("jquery.php"); #javascript的函式庫,提供較易使用的方式
|
|
|
159 |
require_once("jwt.php"); #提供 jwt token 的應用
|
|
|
160 |
require_once("libreoffice.php"); #提供 libreoffice 相關的應用
|
|
|
161 |
require_once("line.php"); # 提供 line 的相關應用
|
|
|
162 |
require_once("link.php"); #裏面包含跟超連結有關的功能
|
|
|
163 |
require_once("logs.php"); #跟log相關的功能
|
|
|
164 |
require_once("mail.php"); #跟寄信有關的功能
|
|
|
165 |
require_once("maintain.php"); #跟維護有關的類別
|
|
|
166 |
require_once("math.php"); #裏面包含跟數學運算有關的功能
|
|
|
167 |
require_once("od.php"); #跟open document有關的功能
|
|
|
168 |
require_once("parser.php"); #跟解析內容相關的功能.
|
|
|
169 |
require_once("phpLib.php"); #跟php函式庫管理有關的類別
|
|
|
170 |
require_once("qemu.php"); #跟qemu有關的功能
|
|
|
171 |
require_once("qrCode.php"); #裏面包含qrCode的功能
|
|
|
172 |
require_once("R.php"); #用於統計與報表產生的套件
|
|
|
173 |
require_once("record.php"); #用於記錄資訊的套件功能
|
|
|
174 |
require_once("session.php"); #用於管理session的功能
|
|
|
175 |
require_once("search.php"); #裏面包含跟搜尋有關的功能
|
|
|
176 |
require_once("security.php"); #裏面包含跟保護製作權有關的功能
|
|
|
177 |
require_once("soap.php"); #webService建構、存取的相關功能
|
|
|
178 |
require_once("sock.php"); #unix domain socket
|
|
|
179 |
require_once("sound.php"); #裏面包含嵌入音樂、聲音、語音到網頁的功能
|
|
|
180 |
require_once("stop.php"); #跟程式中止有關的功能
|
|
|
181 |
require_once("stringProcess.php"); #裏面包含字串處理的功能
|
|
|
182 |
require_once("tab.php"); #提供建立tab的功能
|
|
|
183 |
require_once("text.php"); #提供文字顯示的功能
|
|
|
184 |
require_once("table.php"); #裏面包含建立表格的功能
|
|
|
185 |
require_once("threads.php"); #提供多執行序功能
|
|
|
186 |
require_once("time.php"); #裏面包含關於跟時鐘、期間限定有關的功能
|
|
|
187 |
require_once("variableCheck.php"); #變數檢查
|
|
|
188 |
require_once("video.php"); #裏面包含跟嵌入影片到網頁有關的功能
|
|
|
189 |
require_once("webSock.php"); #裡面包含web socket的應用
|
|
|
190 |
require_once("xml.php"); #裏面包含xml資料的截取功能
|
|
|
191 |
require_once("zerossl.php"); #裡面包含應用zerossl提供的服務
|
|
|
192 |
|
|
|
193 |
#匯入別人的php類別檔
|
|
|
194 |
|
|
|
195 |
#套件說明:
|
|
|
196 |
#tcpdf,用於編輯pdf檔案的套件。
|
|
|
197 |
#參考資料:
|
|
|
198 |
#http://www.tcpdf.org/index.php
|
|
|
199 |
require_once("tcpdf/tcpdf.php");
|
|
|
200 |
|
|
|
201 |
#/*
|
|
|
202 |
|
|
|
203 |
#設定檢視該網頁時預設的編碼
|
|
|
204 |
#必填的參數:
|
|
|
205 |
$conf["encodingName"]="utf-8";#為網頁顯示的編碼的名稱,例如:"UTF-8"
|
|
|
206 |
header::htmlEncoding($conf);
|
|
|
207 |
unset($conf);
|
|
|
208 |
|
|
|
209 |
#*/
|
|
|
210 |
|
|
|
211 |
#/*
|
|
|
212 |
|
|
|
213 |
#預設啟用防止複製與右鍵功能
|
| 207 |
liveuser |
214 |
#函式說明:
|
|
|
215 |
#禁止做任違反版權的事情,禁止在網頁按下滑鼠右鍵,禁止複製圖片,禁止開新分頁(失敗), 版權所有、Power by訊息.
|
| 3 |
liveuser |
216 |
#回傳的內容:
|
|
|
217 |
#保護版權的語法
|
| 207 |
liveuser |
218 |
#必填參數:
|
|
|
219 |
#無
|
|
|
220 |
#可省略參數:
|
|
|
221 |
#$conf["name"],字串,公司、組織、單位的名稱,預設不指定.
|
|
|
222 |
$conf["name"]="北角網頁設計";
|
|
|
223 |
#$conf["powerBy"],字串,由誰提供,預設爲QBPWCF.
|
|
|
224 |
#$conf["powerBy"]="";
|
|
|
225 |
#$conf["powerByLink"],字串,power by字串的連結目標,預設爲"https://www.qbpwcf.org".
|
|
|
226 |
#$conf["powerByLink"]="";
|
|
|
227 |
#$conf["bgColor"],字串,背景顏色,預設爲淡藍色.
|
|
|
228 |
#$conf["bgColor"]="";
|
|
|
229 |
#參考資料:
|
|
|
230 |
#http://www.w3schools.com/jsref/dom_obj_event.asp
|
|
|
231 |
#備註:
|
|
|
232 |
#無.
|
| 3 |
liveuser |
233 |
$copyRight=security::copyRight($conf);
|
| 207 |
liveuser |
234 |
unset($conf);
|
| 180 |
liveuser |
235 |
|
|
|
236 |
if($copyRight["status"]==="false"){
|
|
|
237 |
|
| 3 |
liveuser |
238 |
#debug
|
|
|
239 |
var_dump($copyRight);
|
|
|
240 |
exit;
|
| 180 |
liveuser |
241 |
|
|
|
242 |
}#if end
|
| 206 |
liveuser |
243 |
|
|
|
244 |
#印出版權宣告
|
| 3 |
liveuser |
245 |
echo $copyRight["content"];
|
|
|
246 |
unset($conf);
|
|
|
247 |
|
|
|
248 |
#*/
|
|
|
249 |
|
|
|
250 |
#/*
|
|
|
251 |
|
|
|
252 |
#qbpwcf用的css樣式
|
|
|
253 |
$qbpwcfStyle=css::qbpwcfStyle();
|
|
|
254 |
|
|
|
255 |
#如果建立 qbpwcf 用的 css 語法失敗
|
|
|
256 |
if($qbpwcfStyle["status"]==="false"){
|
|
|
257 |
|
|
|
258 |
#debug
|
|
|
259 |
var_dump($qbpwcfStyle);
|
|
|
260 |
exit;
|
|
|
261 |
|
|
|
262 |
}#if end
|
|
|
263 |
|
|
|
264 |
#印出css語法
|
|
|
265 |
echo $qbpwcfStyle["content"];
|
|
|
266 |
|
|
|
267 |
#*/
|
|
|
268 |
|
|
|
269 |
#/* prevent header error
|
|
|
270 |
|
|
|
271 |
#qbpwcf用的javascript
|
|
|
272 |
$qbpwcfJavaScript=javaScript::qbpwcfJavaScript();
|
|
|
273 |
|
|
|
274 |
#如果建立 qbpwcf 用的 js 語法失敗
|
|
|
275 |
if($qbpwcfJavaScript["status"]==="false"){
|
|
|
276 |
|
|
|
277 |
#debug
|
|
|
278 |
var_dump($qbpwcfJavaScript);
|
|
|
279 |
|
|
|
280 |
#結束執行
|
|
|
281 |
exit;
|
|
|
282 |
|
|
|
283 |
}#if end
|
|
|
284 |
|
|
|
285 |
#印出js語法
|
|
|
286 |
echo $qbpwcfJavaScript["content"];
|
|
|
287 |
|
| 207 |
liveuser |
288 |
#將指定的字形套用在body上
|
|
|
289 |
#函式說明:
|
|
|
290 |
#將指定的字形套用在body上.
|
|
|
291 |
#回傳結果:
|
|
|
292 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
293 |
#$result["error"],錯誤訊息.
|
|
|
294 |
#$result["function"],當前執行的函數名稱.
|
|
|
295 |
#$result["content"],語法.
|
|
|
296 |
#必填參數:
|
|
|
297 |
#無.
|
|
|
298 |
#可省略參數:
|
|
|
299 |
#$conf["fontPath"],字串,字形檔案的位置,預設為"liberation-mono/LiberationMono-Regular.ttf".
|
|
|
300 |
#$conf["fontPath"]="";
|
|
|
301 |
#參考資料:
|
|
|
302 |
#無.
|
|
|
303 |
#備註:
|
|
|
304 |
#無.
|
|
|
305 |
$conf=array();
|
|
|
306 |
$setBodyFont=javaScript::setBodyFont($conf);
|
|
|
307 |
unset($conf);
|
|
|
308 |
|
|
|
309 |
#如果執行異常
|
|
|
310 |
if($setBodyFont["status"]==="false"){
|
|
|
311 |
|
|
|
312 |
#debug
|
|
|
313 |
var_dump($setBodyFont);
|
|
|
314 |
|
|
|
315 |
#結束執行
|
|
|
316 |
exit;
|
|
|
317 |
|
|
|
318 |
}#if end
|
|
|
319 |
|
|
|
320 |
#印出語法
|
|
|
321 |
echo $setBodyFont["content"];
|
|
|
322 |
|
| 3 |
liveuser |
323 |
#*/
|
|
|
324 |
|
|
|
325 |
#匯入全域的設定檔
|
|
|
326 |
require_once(pathinfo(__FILE__)["dirname"]."/../../../etc/qbpwcf/allInOneConfig.php");
|
|
|
327 |
|
|
|
328 |
#覆蓋資料庫連結用的資訊
|
|
|
329 |
#$dbAddress="localhost";#資料庫的位置
|
|
|
330 |
#$dbPort="3306";#資料庫的 tcp port
|
|
|
331 |
#$dbAccount="root";#資料庫帳號
|
|
|
332 |
#$dbPassword="";#資料庫密碼
|
|
|
333 |
#$dbName="test";#資料庫名稱
|
|
|
334 |
|
|
|
335 |
#定義常數變數,bbb service url
|
|
|
336 |
define("bbbUrl",$bbbUrl);
|
|
|
337 |
|
|
|
338 |
#定義常數變數,bbb service secret
|
|
|
339 |
define("bbbSecret",$bbbSecret);
|
|
|
340 |
|
| 182 |
liveuser |
341 |
#定義資料庫系統加解密用的GnuPG ID
|
| 3 |
liveuser |
342 |
define("dbSecret",$dbSecret);
|
|
|
343 |
|
|
|
344 |
#定義 qbpwcf unix domain socket path
|
|
|
345 |
define("qbpwcf_usock_path",$qbpwcf_usock_path);
|
|
|
346 |
|
|
|
347 |
#定義 Zero SSL API access key
|
|
|
348 |
define("zeroSSLapiKey",$zeroSSLapiKey);
|
|
|
349 |
|
| 77 |
liveuser |
350 |
#定義運行web服務的賬戶
|
|
|
351 |
define("webUser",$webUser);
|
|
|
352 |
|
|
|
353 |
#定義系統的domain
|
|
|
354 |
define("domain",$domain);
|
|
|
355 |
|
| 63 |
liveuser |
356 |
#定義用於gpg加解密的預設id
|
|
|
357 |
define("gnupgId",$gnupgId);
|
|
|
358 |
|
| 30 |
liveuser |
359 |
#定義供系統寄送信件的email帳號
|
|
|
360 |
define("systemMailAcct",$systemMailAcct);
|
|
|
361 |
|
|
|
362 |
#定義供系統寄送信件的email密碼
|
|
|
363 |
define("systemMailPass",$systemMailPass);
|
|
|
364 |
|
| 47 |
liveuser |
365 |
#定義環境模式
|
|
|
366 |
define("mode",$mode);
|
|
|
367 |
|
| 53 |
liveuser |
368 |
#定義 web socket server 預設的 listen address
|
|
|
369 |
define("webSocketServerDefaultListenAddr",$webSocketServerDefaultListenAddr);
|
|
|
370 |
|
|
|
371 |
#定義 web soscket server 預設的 listen port
|
|
|
372 |
define("webSocketServerDefaultListenPort",$webSocketServerDefaultListenPort);
|
|
|
373 |
|
| 3 |
liveuser |
374 |
/*
|
|
|
375 |
|
|
|
376 |
#取得使用者拜訪的頁面
|
|
|
377 |
#涵式說明:
|
|
|
378 |
#取得用戶端的資訊
|
|
|
379 |
#回傳的結果:
|
|
|
380 |
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
|
|
|
381 |
#$result["error"],錯誤訊息.
|
|
|
382 |
#$result["function"],檔前執行的函數名稱.
|
|
|
383 |
#$result["mode"],當前的模式是"cmd"還是"web".
|
|
|
384 |
#$result["userBrowserType"],爲使用者的瀏覽器資訊
|
|
|
385 |
#$result["userIp"],爲使用者的IP
|
|
|
386 |
#$result["serverIp"],為伺服器的IP
|
|
|
387 |
#$result["scheme"],通訊協定
|
|
|
388 |
#$result["serverPort"],伺服器給對外下載網頁的port
|
|
|
389 |
#$result["requestUri"],爲使用者要求的網址
|
|
|
390 |
#$result["username"],爲使用者目前的帳戶,若爲""則表示尚未登入成功
|
|
|
391 |
#$result["phpUser"],運行該php的使用者帳戶.
|
|
|
392 |
#必填的參數:
|
|
|
393 |
$conf["getAccount"]="true";#是否要取得帳號
|
|
|
394 |
#可省略的參數:
|
|
|
395 |
#$conf["accountVar"]=$_SESSION["username"];#帳號儲存在哪個變數裏面,預設爲$_SESSION["username"]
|
|
|
396 |
$conf["saveToDb"]="true";#是否要除儲存到資料庫,"true"為要儲存",預設為不儲存
|
|
|
397 |
$conf["dbAddress"]=$dbAddress;;#爲mysql-Server的位置,若#$conf["saveToDb"]設為"true",則該參數為必填。
|
|
|
398 |
$conf["dbAccount"]=$dbAccount;#爲用於連入mysql-Server時要使用的帳號,若#$conf["saveToDb"]設為"true",則該參數為必填。
|
|
|
399 |
$conf["dbName"]=$dbName;#要選取的資料庫名稱,若#$conf["saveToDb"]設為"true",則該參數為必填。
|
|
|
400 |
$conf["tableName"]="visitorInfo";#爲要插入資料的資料表名稱,若#$conf["saveToDb"]設為"true",則該參數為必填。
|
|
|
401 |
$conf["columnName"]=array("username","userWebBrowser","userIp","requestUri","systemDateAndTime");#爲資料表的項目名稱,
|
|
|
402 |
#例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);
|
|
|
403 |
#寫入的資料依序為,使用者帳戶、瀏覽器資訊、使用者IP、觀看的網址、當時的時間
|
|
|
404 |
#$conf["saveToDb"]設為"true",則該參數為必填。
|
|
|
405 |
$conf["dbPassword"]=$dbPassword;#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
|
|
|
406 |
#$conf["displayQueryError"]="true";#爲是否呈現Query的錯誤訊息,預設不呈現,若要呈現則請將此值設爲"true"
|
|
|
407 |
#$conf["displayQueryString"]="true";#爲是否呈現Query的命令,預設不呈現,若要呈現則請將此值設爲"true"
|
|
|
408 |
$recordResult=csInformation::getConnectionInfo($conf);
|
|
|
409 |
unset($conf);
|
|
|
410 |
|
|
|
411 |
#如果記錄拜訪資訊失敗
|
|
|
412 |
if($recordResult["status"]=="false"){
|
|
|
413 |
|
|
|
414 |
#debug
|
|
|
415 |
var_dump($recordResult);
|
|
|
416 |
exit;
|
|
|
417 |
|
|
|
418 |
}#if end
|
|
|
419 |
|
|
|
420 |
#如果要求的通訊協定不為https
|
|
|
421 |
if($recordResult["scheme"]!=="https"){
|
|
|
422 |
|
|
|
423 |
#函式說明:
|
|
|
424 |
#設定session變數後,立即轉址.
|
|
|
425 |
#回傳的結果:
|
|
|
426 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
|
|
|
427 |
#$result["function"],當前執行的函數名稱.
|
|
|
428 |
#$result["error"],錯誤訊息陣列.
|
|
|
429 |
#必填的參數:
|
|
|
430 |
#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
|
|
|
431 |
$conf["header::redirectionNow"]["headerLocation"]=$recordResult["scheme"]."s://".$recordResult["serverIp"].$recordResult["requestUri"];
|
|
|
432 |
#可省略的參數:
|
|
|
433 |
#$conf["sessionName"],字串陣列,可以指派session變數的名稱.
|
|
|
434 |
#$conf["sessionName"]=array("");
|
|
|
435 |
#$conf["sessionValue"]字串陣列,可以指派session變數的內容.
|
|
|
436 |
#$conf["sessionValue"]=array("");
|
|
|
437 |
#參靠資料來源:
|
|
|
438 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
439 |
$redirectionNow=header::redirectionNow($conf["header::redirectionNow"]);
|
|
|
440 |
unset($conf["header::redirectionNow"]);
|
|
|
441 |
|
|
|
442 |
#如果轉址失敗
|
|
|
443 |
if($redirectionNow["status"]==="false"){
|
|
|
444 |
|
|
|
445 |
#停止執行
|
|
|
446 |
exit;
|
|
|
447 |
|
|
|
448 |
}#if end
|
|
|
449 |
|
|
|
450 |
}#if end
|
|
|
451 |
|
|
|
452 |
#驗證權限,檢查會員所屬群組是否能拜訪該子細統
|
|
|
453 |
#函式說明:
|
|
|
454 |
#檢查session裏面的使用者資訊是否在會員清單裏面,
|
|
|
455 |
#該會員所屬的羣組是否具有權限瀏覽該子功能頁面
|
|
|
456 |
#目標資料庫裏面必須有名爲member作爲儲存會員資料的資料表。
|
|
|
457 |
#目標資料庫裏面必須有名爲userGroupAuthorities作爲儲存羣組資料的資料表
|
|
|
458 |
#回傳的參數:
|
|
|
459 |
#$result["status"],執行是否正常的識別,"true"代表一切正常,"false"代表不正常
|
|
|
460 |
#$result["error"],錯誤訊息
|
|
|
461 |
#$result["function"],當前執行的函數名稱
|
|
|
462 |
#$result["passed"],是否通過檢查,"true"代表通過檢查,"false"代表沒有通過檢查.
|
|
|
463 |
#$result["warning"],記錄不會影響程式執行,但是需要注意的事情。
|
|
|
464 |
#必填寫的參數:
|
|
|
465 |
$conf["thisSubSystemName"]="phplib";#爲該子系統的名稱,若該羣組所能瀏覽的子系統裏面有該名稱,則通過驗證。
|
|
|
466 |
$conf["dbName"]=$dbName;#爲指定的資料庫名稱,欲選擇的資料庫名稱
|
|
|
467 |
$conf["dbPassword"]=$dbPassword;#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
|
|
|
468 |
#可省略的參數:
|
|
|
469 |
#$conf["dbAddress"]="localhost";#爲資料庫的位置,預設爲 "localhost"
|
|
|
470 |
#$conf["dbAccount"]="root";#爲用於連入資料庫時要使用的帳號,預設爲 "root"
|
|
|
471 |
#$conf["dtName.member"]="member";#儲存會員資料的資料表,預設爲 "member"
|
|
|
472 |
#$conf["dtName.userGroup"]="userGroupAuthorities";#儲存羣組資料的資,預設爲 "userGroupAuthorities"
|
|
|
473 |
$authenticate=authenticate::checkUserGroupAuthorities($conf);
|
|
|
474 |
unset($conf);
|
|
|
475 |
|
|
|
476 |
#debug
|
|
|
477 |
#var_dump($conf);
|
|
|
478 |
#var_dump($authenticate);
|
|
|
479 |
#exit;
|
|
|
480 |
|
|
|
481 |
#如果驗證權權限失敗
|
|
|
482 |
if($authenticate["status"]==="false"){
|
|
|
483 |
|
|
|
484 |
#debug
|
|
|
485 |
#var_dump($authenticate);
|
|
|
486 |
#exit;
|
|
|
487 |
|
|
|
488 |
#函式說明:
|
|
|
489 |
#用彈出式視窗顯示訊息,接著設置seesion變數,最後進行轉址.
|
|
|
490 |
#回傳的結果:
|
|
|
491 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
|
|
|
492 |
#$result["error"],錯誤訊息陣列.
|
|
|
493 |
#必填的參數:
|
|
|
494 |
#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
|
|
|
495 |
$conf["headerLocation"]="/~qbpwcf/";
|
|
|
496 |
#$conf["alertMessage"],字串陣列,要顯示的彈出式視窗內容,第n個元素代表第n行的內容.
|
|
|
497 |
$conf["alertMessage"]=$authenticate["warning"];
|
|
|
498 |
#可省略的參數:
|
|
|
499 |
#$conf["sessionName"],字串陣,可以指派要建立的session變數名稱.
|
|
|
500 |
#$conf["sessionName"]=array("");
|
|
|
501 |
#$conf["sessionValue"]字串陣列,可以指派要建立的session變數的內容.
|
|
|
502 |
#$conf["sessionValue"]=array("");
|
|
|
503 |
#參靠資料來源:
|
|
|
504 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
505 |
header::redirectionAfterAlertWindows($conf);
|
|
|
506 |
unset($conf);
|
|
|
507 |
|
|
|
508 |
}#if end
|
|
|
509 |
|
|
|
510 |
#如果驗證權限不通過
|
|
|
511 |
if($authenticate["passed"]==="false"){
|
|
|
512 |
|
|
|
513 |
#函式說明:
|
|
|
514 |
#用彈出式視窗顯示訊息,接著設置seesion變數,最後進行轉址.
|
|
|
515 |
#回傳的結果:
|
|
|
516 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
|
|
|
517 |
#$result["error"],錯誤訊息陣列.
|
|
|
518 |
#必填的參數:
|
|
|
519 |
#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
|
|
|
520 |
$conf["headerLocation"]="/~qbpwcf/";
|
|
|
521 |
#$conf["alertMessage"],字串陣列,要顯示的彈出式視窗內容,第n個元素代表第n行的內容.
|
|
|
522 |
$conf["alertMessage"]=$authenticate["warning"];
|
|
|
523 |
#可省略的參數:
|
|
|
524 |
#$conf["sessionName"],字串陣,可以指派要建立的session變數名稱.
|
|
|
525 |
#$conf["sessionName"]=array("");
|
|
|
526 |
#$conf["sessionValue"]字串陣列,可以指派要建立的session變數的內容.
|
|
|
527 |
#$conf["sessionValue"]=array("");
|
|
|
528 |
#參靠資料來源:
|
|
|
529 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
530 |
header::redirectionAfterAlertWindows($conf);
|
|
|
531 |
unset($conf);
|
|
|
532 |
|
|
|
533 |
}#if end
|
|
|
534 |
|
|
|
535 |
*/
|
|
|
536 |
|
|
|
537 |
#涵式說明:
|
|
|
538 |
#使用預設的app化設置.
|
|
|
539 |
#回傳的結果:
|
|
|
540 |
#app化的語法.
|
|
|
541 |
echo app::defaultMode();
|
|
|
542 |
|
|
|
543 |
#函式說明:
|
|
|
544 |
#將php設定檔常用的設定進行調整使之變成適用於開發模式、釋出模式、或自訂要調整哪些設定值
|
|
|
545 |
#回傳結果:
|
|
|
546 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
547 |
#$result["error"],錯誤訊息陣列.
|
|
|
548 |
#$result["function"],當前執行的函數名稱.
|
|
|
549 |
#必填參數:
|
|
|
550 |
#$conf["mode"],參數設定的模式,"release"代表是指共一般使用所需;"develop"代表是在開發狀態下所需;"custom"代表自訂參數設定內容
|
| 47 |
liveuser |
551 |
$conf["mode"]=mode;
|
| 3 |
liveuser |
552 |
#可省略參數:
|
|
|
553 |
#$conf["customSettings"],要自訂的參數與其數值,例如array("display_errors=On").
|
|
|
554 |
$conf["customSettings"]=array();
|
|
|
555 |
#參考資料:
|
|
|
556 |
#ini_set=>http://www.php.net/manual/en/function.ini-set.php
|
|
|
557 |
#各個參數適用的修改方式=>http://www.php.net/manual/en/ini.list.php
|
|
|
558 |
#各個參數適用的修改方式的解說=>http://hi.baidu.com/richardali/item/d28104083c70c638a2332a60
|
|
|
559 |
#備註:
|
|
|
560 |
#使用該函式後,網頁會無法顯示。
|
|
|
561 |
$changeSettings=config::changeSettings($conf);
|
|
|
562 |
unset($conf);
|
|
|
563 |
|
|
|
564 |
#如果變更設定失敗
|
|
|
565 |
if($changeSettings["status"]==="false"){
|
|
|
566 |
|
|
|
567 |
#debug
|
| 47 |
liveuser |
568 |
var_dump($changeSettings);exit(1);
|
| 3 |
liveuser |
569 |
|
|
|
570 |
}#if end
|
|
|
571 |
|
|
|
572 |
?>
|