Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 615 | Rev 753 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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