| 2 |
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 |
#使用 qbpwcf 命名空間
|
|
|
26 |
namespace qbpwcf;
|
|
|
27 |
|
|
|
28 |
#取得 lib path
|
|
|
29 |
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
|
|
|
30 |
|
|
|
31 |
#如果執行失敗
|
|
|
32 |
if($status!==0){
|
|
|
33 |
|
|
|
34 |
#debug
|
|
|
35 |
var_dump(__LINE__,$output);
|
|
|
36 |
|
|
|
37 |
#結束執行,回傳shell 1.
|
|
|
38 |
exit(1);
|
|
|
39 |
|
|
|
40 |
}#if end
|
|
|
41 |
|
|
|
42 |
#儲存lib path
|
|
|
43 |
$folderOfUsrLib=$output[0];
|
|
|
44 |
|
|
|
45 |
#以該檔案的實際位置的 lib path 為 include path 首位
|
|
|
46 |
$output=array();
|
|
|
47 |
exec("cd ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/usr/".$folderOfUsrLib."/qbpwcf").";pwd;",$output,$status);
|
|
|
48 |
|
|
|
49 |
#如果執行失敗
|
|
|
50 |
if($status!==0){
|
|
|
51 |
|
|
|
52 |
#debug
|
|
|
53 |
var_dump(__LINE__,$output);
|
|
|
54 |
|
|
|
55 |
#結束執行,回傳shell 1.
|
|
|
56 |
exit(1);
|
|
|
57 |
|
|
|
58 |
}#if end
|
|
|
59 |
|
|
|
60 |
#設置 include path
|
|
|
61 |
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
|
|
|
62 |
|
|
|
63 |
#匯入套件
|
|
|
64 |
require_once("allInOne.php");
|
|
|
65 |
|
|
|
66 |
#建議的log位置
|
|
|
67 |
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
|
|
|
68 |
|
|
|
69 |
#函式說明:
|
|
|
70 |
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
|
|
|
71 |
#回傳的變數說明:
|
|
|
72 |
#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
|
|
|
73 |
#$result["error"],錯誤訊息提示.
|
|
|
74 |
#$result["warning"],警告訊息.
|
|
|
75 |
#$result["function"],當前執行的函數名稱.
|
|
|
76 |
#$result["fileContent"],爲檔案的內容陣列.
|
|
|
77 |
#$result["lineCount"],爲檔案內容總共的行數.
|
|
|
78 |
#$result["fullContent"],為檔案的完整內容.
|
|
|
79 |
#$result["base64data"],為檔案的base64內容.
|
|
|
80 |
#$result["mimeType"],為檔案的mime type.
|
|
|
81 |
#必填參數:
|
|
|
82 |
#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
|
|
|
83 |
$conf["filePositionAndName"]="Release Note";
|
|
|
84 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
85 |
$conf["fileArgu"]=__FILE__;
|
|
|
86 |
#可省略參數:
|
|
|
87 |
#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
|
|
|
88 |
#$conf["web"]="true";
|
|
|
89 |
#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
|
|
|
90 |
#$conf["createIfnotExist"]="false";
|
|
|
91 |
#參考資料:
|
|
|
92 |
#file(),取得檔案內容的行數.
|
|
|
93 |
#file=>http:#php.net/manual/en/function.file.php
|
|
|
94 |
#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
|
|
|
95 |
#filesize=>http://php.net/manual/en/function.filesize.php
|
|
|
96 |
#參考資料:
|
|
|
97 |
#無.
|
|
|
98 |
#備註:
|
|
|
99 |
#無.
|
|
|
100 |
$getFileContent=fileAccess::getFileContent($conf);
|
|
|
101 |
unset($conf);
|
|
|
102 |
|
|
|
103 |
#如果執行失敗
|
|
|
104 |
if($getFileContent["status"]==="false"){
|
|
|
105 |
|
|
|
106 |
#函式說明:
|
|
|
107 |
#設定session變數後,立即轉址.
|
|
|
108 |
#回傳的結果:
|
|
|
109 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
|
|
|
110 |
#$result["function"],當前執行的函數名稱.
|
|
|
111 |
#$result["error"],錯誤訊息陣列.
|
|
|
112 |
#必填參數:
|
|
|
113 |
#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
|
|
|
114 |
$conf["headerLocation"]="https://sourceforge.net/projects/qbpwc/";
|
|
|
115 |
#可省略參數:
|
|
|
116 |
#$conf["sessionName"],字串陣列,可以指派session變數的名稱.
|
|
|
117 |
#$conf["sessionName"]=array("");
|
|
|
118 |
#$conf["sessionValue"]字串陣列,可以指派session變數的內容.
|
|
|
119 |
#$conf["sessionValue"]=array("");
|
|
|
120 |
#參考資料:
|
|
|
121 |
#http://php.net/manual/en/reserved.variables.server.php
|
|
|
122 |
#備註:
|
|
|
123 |
#無.
|
|
|
124 |
$redirectionNow=header::redirectionNow($conf);
|
|
|
125 |
unset($conf);
|
|
|
126 |
|
|
|
127 |
#如果執行失敗
|
|
|
128 |
if($redirectionNow["status"]==="false"){
|
|
|
129 |
|
|
|
130 |
#函式說明:
|
|
|
131 |
#撰寫log
|
|
|
132 |
#回傳結果:
|
|
|
133 |
#$result["status"],狀態,"true"或"false".
|
|
|
134 |
#$result["error"],錯誤訊息陣列.
|
|
|
135 |
#$result["function"],當前函式的名稱.
|
|
|
136 |
#$result["argu"],使用的參數.
|
|
|
137 |
#$result["content"],要寫入log的內容字串.
|
|
|
138 |
#必填參數:
|
|
|
139 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
140 |
$conf["path"]=$logFile;
|
|
|
141 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
142 |
$conf["content"]=$redirectionNow;
|
|
|
143 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
144 |
$conf["fileArgu"]=__FILE__;
|
|
|
145 |
#可省略參數:
|
|
|
146 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
147 |
#$conf["rewrite"]="false";
|
|
|
148 |
#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
|
|
|
149 |
#$conf["returnOnly"]="true";
|
|
|
150 |
#參考資料:
|
|
|
151 |
#無.
|
|
|
152 |
#備註:
|
|
|
153 |
#無.
|
|
|
154 |
$record=logs::record($conf);
|
|
|
155 |
unset($conf);
|
|
|
156 |
|
|
|
157 |
#如果執行失敗
|
|
|
158 |
if($record["status"]==="false"){
|
|
|
159 |
|
|
|
160 |
#印出結果
|
|
|
161 |
var_dump($record);
|
|
|
162 |
|
|
|
163 |
#結束執行
|
|
|
164 |
exit;
|
|
|
165 |
|
|
|
166 |
}#if end
|
|
|
167 |
|
|
|
168 |
#結束執行
|
|
|
169 |
exit;
|
|
|
170 |
|
|
|
171 |
}#if end
|
|
|
172 |
|
|
|
173 |
}#if end
|
|
|
174 |
|
|
|
175 |
#var_dump($getFileContent["fileContent"]);exit;
|
|
|
176 |
|
|
|
177 |
#函式說明:
|
|
|
178 |
#顯示多行文字.
|
|
|
179 |
#回傳的結果:
|
|
|
180 |
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
|
|
|
181 |
#$result["error"],錯誤訊息陣列.
|
|
|
182 |
#$result["function"],當前執行的函數名稱.
|
|
|
183 |
#$result["content"],語法.
|
|
|
184 |
#必填參數:
|
|
|
185 |
#$conf["string"],字串陣列,要放置的內容.
|
|
|
186 |
$conf["string"]=$getFileContent["fileContent"];
|
|
|
187 |
#可省略參數:
|
|
|
188 |
#$conf["class"],字串,要使用的css樣式名稱,預設為"__defaultTextStyle"
|
|
|
189 |
#$conf["class"]="";
|
| 207 |
liveuser |
190 |
#$conf["type"],字串,要用"div"或"divNoWrap"或"span"或"br"或"p"或"EOL"或"textarea"來段行,預設為"EOL".
|
| 2 |
liveuser |
191 |
$conf["type"]="textarea";
|
|
|
192 |
#參考資料:
|
|
|
193 |
#無.
|
|
|
194 |
#備註:
|
|
|
195 |
#無.
|
|
|
196 |
$multiLine=text::multiLine($conf);
|
|
|
197 |
unset($conf);
|
|
|
198 |
|
|
|
199 |
#如果執行失敗
|
|
|
200 |
if($multiLine["status"]==="false"){
|
|
|
201 |
|
|
|
202 |
#函式說明:
|
|
|
203 |
#撰寫log
|
|
|
204 |
#回傳結果:
|
|
|
205 |
#$result["status"],狀態,"true"或"false".
|
|
|
206 |
#$result["error"],錯誤訊息陣列.
|
|
|
207 |
#$result["function"],當前函式的名稱.
|
|
|
208 |
#$result["argu"],使用的參數.
|
|
|
209 |
#$result["content"],要寫入log的內容字串.
|
|
|
210 |
#必填參數:
|
|
|
211 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
212 |
$conf["path"]=$logFile;
|
|
|
213 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
214 |
$conf["content"]=$multiLine;
|
|
|
215 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
216 |
$conf["fileArgu"]=__FILE__;
|
|
|
217 |
#可省略參數:
|
|
|
218 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
219 |
#$conf["rewrite"]="false";
|
|
|
220 |
#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
|
|
|
221 |
#$conf["returnOnly"]="true";
|
|
|
222 |
#參考資料:
|
|
|
223 |
#無.
|
|
|
224 |
#備註:
|
|
|
225 |
#無.
|
|
|
226 |
$record=logs::record($conf);
|
|
|
227 |
unset($conf);
|
|
|
228 |
|
|
|
229 |
#如果執行失敗
|
|
|
230 |
if($record["status"]==="false"){
|
|
|
231 |
|
|
|
232 |
#印出結果
|
|
|
233 |
var_dump($record);
|
|
|
234 |
|
|
|
235 |
#結束執行
|
|
|
236 |
exit;
|
|
|
237 |
|
|
|
238 |
}#if end
|
|
|
239 |
|
|
|
240 |
#結束執行
|
|
|
241 |
exit;
|
|
|
242 |
|
|
|
243 |
}#if end
|
|
|
244 |
|
|
|
245 |
#印出結果
|
|
|
246 |
echo $multiLine["content"];
|
|
|
247 |
|
|
|
248 |
?>
|