Subversion Repositories php-qbpwcf

Rev

Rev 239 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 liveuser 1
<?php
2
 
3
/*
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
239 liveuser 6
    Copyright (C) 2014~2026 MIN ZHI, CHEN
2 liveuser 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
 
226 liveuser 60
#設置 include path
2 liveuser 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
 
243 liveuser 69
#web page title
70
$title="PHP libary for quick build php website based on Fedora Linux(a.k.a. ,Low code platform library).";
71
 
72
#設置 title
2 liveuser 73
#函式說明:
243 liveuser 74
#建立網頁的標題,納入網絡搜尋的依據.
75
#回傳的內容:
76
#$result["status"],字串,"true"爲成功,"false"反之失敗.
77
#$result["error"],陣列,錯誤訊息.
78
#$result["function"],字串,當前執行的函數名稱.
79
#$result["content"],字串,設定網頁資訊的字串變數.
80
#必填參數:
81
#$conf["title"],字串,網頁的標題.
82
$conf["title"]=$title;
83
#可省略參數:
84
#$conf["desc"],字串,網站的描述.
85
#$conf["desc"]=$title;
86
#參考資料:
87
#無.
88
#備註:
89
#無.
90
$setPageInfo=header::setPageInfo($conf);
91
unset($conf);
92
 
93
#如果執行失敗
94
if($setPageInfo["status"]==="false"){
95
 
96
	#函式說明:
97
	#撰寫log
98
	#回傳結果:
99
	#$result["status"],狀態,"true"或"false".
100
	#$result["error"],錯誤訊息陣列.
101
	#$result["function"],當前函式的名稱.
102
	#$result["argu"],使用的參數.
103
	#$result["content"],要寫入log的內容字串.
104
	#必填參數:
105
	#$conf["path"],字串,log檔案的路徑與名稱.
106
	$conf["path"]=$logFile;
107
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
108
	$conf["content"]=$setPageInfo;
109
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
110
	$conf["fileArgu"]=__FILE__;
111
	#可省略參數:
112
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
113
	#$conf["rewrite"]="false";
114
	#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
115
	#$conf["returnOnly"]="true";
116
	#參考資料:
117
	#無.
118
	#備註:
119
	#無.
120
	$record=logs::record($conf);
121
	unset($conf);
122
 
123
	#如果執行失敗
124
	if($record["status"]==="false"){
125
 
126
		#印出結果
127
		var_dump($record);
128
 
129
		#結束執行
130
		exit;
131
 
132
		}#if end
133
 
134
	#結束執行
135
	exit;
136
 
137
	}#if end
138
 
139
#印出語法
140
echo $setPageInfo["content"];
141
 
142
#函式說明:
2 liveuser 143
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
144
#回傳的變數說明:
145
#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
146
#$result["error"],錯誤訊息提示.
147
#$result["warning"],警告訊息.
148
#$result["function"],當前執行的函數名稱.
149
#$result["fileContent"],爲檔案的內容陣列.
150
#$result["lineCount"],爲檔案內容總共的行數.
151
#$result["fullContent"],為檔案的完整內容.
152
#$result["base64data"],為檔案的base64內容.
153
#$result["mimeType"],為檔案的mime type.
154
#必填參數:
155
#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
156
$conf["filePositionAndName"]="Release Note";
157
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
158
$conf["fileArgu"]=__FILE__;
159
#可省略參數:
160
#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
161
#$conf["web"]="true";
162
#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
163
#$conf["createIfnotExist"]="false";
164
#參考資料:
165
#file(),取得檔案內容的行數.
166
#file=>http:#php.net/manual/en/function.file.php
167
#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
168
#filesize=>http://php.net/manual/en/function.filesize.php
169
#參考資料:
170
#無.
171
#備註:
172
#無.
173
$getFileContent=fileAccess::getFileContent($conf);
174
unset($conf);
175
 
176
#如果執行失敗
177
if($getFileContent["status"]==="false"){
178
 
179
	#函式說明:
180
	#設定session變數後,立即轉址.
181
	#回傳的結果:
182
	#$result["status"],執行是否成功,"true"代表成功,"false"代表不成功.
183
	#$result["function"],當前執行的函數名稱.
184
	#$result["error"],錯誤訊息陣列.
185
	#必填參數:
186
	#$conf["headerLocation"],為要轉址到的地方,若爲 $_SERVER["PHP_SELF"],則爲回到目前頁面,全民資安素養網爲 https://isafe.moe.edu.tw/.
187
	$conf["headerLocation"]="https://sourceforge.net/projects/qbpwc/";
188
	#可省略參數:
189
	#$conf["sessionName"],字串陣列,可以指派session變數的名稱.
190
	#$conf["sessionName"]=array("");
191
	#$conf["sessionValue"]字串陣列,可以指派session變數的內容.
192
	#$conf["sessionValue"]=array("");
193
	#參考資料:
194
	#http://php.net/manual/en/reserved.variables.server.php
195
	#備註:
196
	#無.
197
	$redirectionNow=header::redirectionNow($conf);
198
	unset($conf);
199
 
200
	#如果執行失敗
201
	if($redirectionNow["status"]==="false"){
226 liveuser 202
 
2 liveuser 203
		#函式說明:
204
		#撰寫log
205
		#回傳結果:
206
		#$result["status"],狀態,"true"或"false".
207
		#$result["error"],錯誤訊息陣列.
208
		#$result["function"],當前函式的名稱.
209
		#$result["argu"],使用的參數.
210
		#$result["content"],要寫入log的內容字串.
211
		#必填參數:
212
		#$conf["path"],字串,log檔案的路徑與名稱.
213
		$conf["path"]=$logFile;
214
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
215
		$conf["content"]=$redirectionNow;
216
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
217
		$conf["fileArgu"]=__FILE__;
218
		#可省略參數:
219
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
220
		#$conf["rewrite"]="false";
221
		#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
222
		#$conf["returnOnly"]="true";
223
		#參考資料:
224
		#無.
225
		#備註:
226
		#無.
227
		$record=logs::record($conf);
228
		unset($conf);
226 liveuser 229
 
2 liveuser 230
		#如果執行失敗
231
		if($record["status"]==="false"){
226 liveuser 232
 
2 liveuser 233
			#印出結果
234
			var_dump($record);
226 liveuser 235
 
2 liveuser 236
			#結束執行
237
			exit;
226 liveuser 238
 
2 liveuser 239
			}#if end
226 liveuser 240
 
2 liveuser 241
		#結束執行
242
		exit;
226 liveuser 243
 
2 liveuser 244
		}#if end
245
 
246
	}#if end
247
 
248
#var_dump($getFileContent["fileContent"]);exit;
249
 
250
#函式說明:
251
#顯示多行文字.
252
#回傳的結果:
253
#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
254
#$result["error"],錯誤訊息陣列.
255
#$result["function"],當前執行的函數名稱.
256
#$result["content"],語法.
257
#必填參數:
258
#$conf["string"],字串陣列,要放置的內容.
259
$conf["string"]=$getFileContent["fileContent"];
260
#可省略參數:
261
#$conf["class"],字串,要使用的css樣式名稱,預設為"__defaultTextStyle"
262
#$conf["class"]="";
207 liveuser 263
#$conf["type"],字串,要用"div"或"divNoWrap"或"span"或"br"或"p"或"EOL"或"textarea"來段行,預設為"EOL".
2 liveuser 264
$conf["type"]="textarea";
265
#參考資料:
266
#無.
267
#備註:
268
#無.
269
$multiLine=text::multiLine($conf);
270
unset($conf);
271
 
272
#如果執行失敗
273
if($multiLine["status"]==="false"){
274
 
275
	#函式說明:
276
	#撰寫log
277
	#回傳結果:
278
	#$result["status"],狀態,"true"或"false".
279
	#$result["error"],錯誤訊息陣列.
280
	#$result["function"],當前函式的名稱.
281
	#$result["argu"],使用的參數.
282
	#$result["content"],要寫入log的內容字串.
283
	#必填參數:
284
	#$conf["path"],字串,log檔案的路徑與名稱.
285
	$conf["path"]=$logFile;
286
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
287
	$conf["content"]=$multiLine;
288
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
289
	$conf["fileArgu"]=__FILE__;
290
	#可省略參數:
291
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
292
	#$conf["rewrite"]="false";
293
	#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
294
	#$conf["returnOnly"]="true";
295
	#參考資料:
296
	#無.
297
	#備註:
298
	#無.
299
	$record=logs::record($conf);
300
	unset($conf);
226 liveuser 301
 
2 liveuser 302
	#如果執行失敗
303
	if($record["status"]==="false"){
226 liveuser 304
 
2 liveuser 305
		#印出結果
306
		var_dump($record);
226 liveuser 307
 
2 liveuser 308
		#結束執行
309
		exit;
226 liveuser 310
 
2 liveuser 311
		}#if end
226 liveuser 312
 
2 liveuser 313
	#結束執行
314
	exit;
315
 
316
	}#if end
317
 
318
#印出結果
319
echo $multiLine["content"];
320
 
226 liveuser 321
?>