| 3 |
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
|
| 3 |
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 |
namespace qbpwcf;
|
|
|
25 |
|
|
|
26 |
/*
|
|
|
27 |
類別說明:
|
|
|
28 |
flash動畫應用的類別.
|
|
|
29 |
備註:
|
|
|
30 |
無.
|
|
|
31 |
*/
|
|
|
32 |
class flash{
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
#函式說明:
|
|
|
36 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
37 |
#回傳結果:
|
|
|
38 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
39 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
40 |
#$result["function"],當前執行的函式名稱.
|
|
|
41 |
#必填參數:
|
|
|
42 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
43 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
44 |
#參考資料:
|
|
|
45 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
46 |
*/
|
|
|
47 |
public function __call($method,$arguments){
|
| 226 |
liveuser |
48 |
|
| 3 |
liveuser |
49 |
#取得當前執行的函式
|
|
|
50 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
51 |
|
| 3 |
liveuser |
52 |
#設置執行不正常
|
|
|
53 |
$result["status"]="false";
|
| 226 |
liveuser |
54 |
|
| 3 |
liveuser |
55 |
#設置執行錯誤
|
|
|
56 |
$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
|
| 226 |
liveuser |
57 |
|
| 3 |
liveuser |
58 |
#設置所丟入的參數
|
|
|
59 |
$result["error"][]=$arguments;
|
| 226 |
liveuser |
60 |
|
| 3 |
liveuser |
61 |
#回傳結果
|
|
|
62 |
return $result;
|
| 226 |
liveuser |
63 |
|
| 3 |
liveuser |
64 |
}#function __call end
|
| 226 |
liveuser |
65 |
|
| 3 |
liveuser |
66 |
/*
|
|
|
67 |
#函式說明:
|
|
|
68 |
#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
|
|
|
69 |
#回傳結果:
|
|
|
70 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
71 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
72 |
#$result["function"],當前執行的函式名稱.
|
|
|
73 |
#必填參數:
|
|
|
74 |
#$method,物件,為物件實體或類別名稱,會自動置入該參數.
|
|
|
75 |
#$arguments,陣列,為呼叫方法時所用的參數.
|
|
|
76 |
#參考資料:
|
|
|
77 |
#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
|
|
|
78 |
*/
|
|
|
79 |
public static function __callStatic($method,$arguments){
|
| 226 |
liveuser |
80 |
|
| 3 |
liveuser |
81 |
#取得當前執行的函式
|
|
|
82 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
83 |
|
| 3 |
liveuser |
84 |
#設置執行不正常
|
|
|
85 |
$result["status"]="false";
|
| 226 |
liveuser |
86 |
|
| 3 |
liveuser |
87 |
#設置執行錯誤
|
|
|
88 |
$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
|
| 226 |
liveuser |
89 |
|
| 3 |
liveuser |
90 |
#設置所丟入的參數
|
|
|
91 |
$result["error"][]=$arguments;
|
| 226 |
liveuser |
92 |
|
| 3 |
liveuser |
93 |
#回傳結果
|
|
|
94 |
return $result;
|
| 226 |
liveuser |
95 |
|
| 3 |
liveuser |
96 |
}#function __callStatic end
|
|
|
97 |
|
|
|
98 |
/*
|
|
|
99 |
#涵式說明:
|
|
|
100 |
#類別函數,將flash嵌入,會自動去背。
|
|
|
101 |
#回傳的結果:
|
|
|
102 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
103 |
#$result["error"],錯誤訊息陣列.
|
|
|
104 |
#$resutl["function"],當前執行的涵式名稱.
|
|
|
105 |
#$result["content"],放置flash的語法.
|
|
|
106 |
#$result["contentBase64"],放置base64過後flash檔案的語法.
|
|
|
107 |
#必填的參數:
|
|
|
108 |
$conf["swfFileLocation"]="";#爲swf檔案的位置。
|
|
|
109 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
110 |
$conf["fileArgu"]=__FILE__;
|
|
|
111 |
#可省略的參數:
|
|
|
112 |
#$conf["width"]="";#爲swf檔案的寬度,預設為100%.
|
|
|
113 |
#$conf["height"]="";#爲swf檔案的高度,預設為100%.
|
|
|
114 |
#參考資料:
|
|
|
115 |
#swf mime type=>http://www.sitepoint.com/web-foundations/mime-types-complete-list/
|
|
|
116 |
#備註:
|
|
|
117 |
#$result["contentBase64"],無法被flash player解析.
|
|
|
118 |
*/
|
|
|
119 |
function show(&$conf){
|
|
|
120 |
|
|
|
121 |
#初始化要回傳的變數
|
|
|
122 |
$result=array();
|
| 226 |
liveuser |
123 |
|
| 3 |
liveuser |
124 |
#設置當前執行的涵式
|
|
|
125 |
$result["function"]=__FUNCTION__;
|
| 226 |
liveuser |
126 |
|
| 3 |
liveuser |
127 |
#如果 $conf 不為陣列
|
|
|
128 |
if(gettype($conf)!="array"){
|
| 226 |
liveuser |
129 |
|
| 3 |
liveuser |
130 |
#設置執行失敗
|
|
|
131 |
$result["status"]="false";
|
| 226 |
liveuser |
132 |
|
| 3 |
liveuser |
133 |
#設置執行錯誤訊息
|
|
|
134 |
$result["error"][]="\$conf變數須為陣列形態";
|
|
|
135 |
|
|
|
136 |
#如果傳入的參數為 null
|
|
|
137 |
if($conf==null){
|
| 226 |
liveuser |
138 |
|
| 3 |
liveuser |
139 |
#設置執行錯誤訊息
|
|
|
140 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| 226 |
liveuser |
141 |
|
| 3 |
liveuser |
142 |
}#if end
|
|
|
143 |
|
|
|
144 |
#回傳結果
|
|
|
145 |
return $result;
|
| 226 |
liveuser |
146 |
|
| 3 |
liveuser |
147 |
}#if end
|
| 226 |
liveuser |
148 |
|
| 3 |
liveuser |
149 |
#檢查參數
|
|
|
150 |
#函式說明:
|
|
|
151 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
152 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
153 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
154 |
#$result["function"],當前執行的函式名稱.
|
|
|
155 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
156 |
#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
157 |
#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
158 |
#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
159 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
160 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
161 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
162 |
#必填寫的參數:
|
|
|
163 |
#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
164 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
|
|
165 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
166 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","swfFileLocation");
|
| 226 |
liveuser |
167 |
#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
168 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
|
|
|
169 |
#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
170 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
171 |
#可以省略的參數:
|
|
|
172 |
#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
|
|
|
173 |
$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
|
|
|
174 |
#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
175 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("width","height");
|
| 226 |
liveuser |
176 |
#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 3 |
liveuser |
177 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
|
|
|
178 |
#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
179 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("100%","100%");
|
|
|
180 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
181 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
182 |
#參考資料來源:
|
|
|
183 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
184 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
|
|
185 |
unset($conf["variableCheck::checkArguments"]);
|
|
|
186 |
|
|
|
187 |
#如果 $checkArguments["status"] 等於 "false"
|
|
|
188 |
if($checkArguments["status"]=="false"){
|
| 226 |
liveuser |
189 |
|
| 3 |
liveuser |
190 |
#設置錯誤識別
|
|
|
191 |
$result["status"]="false";
|
| 226 |
liveuser |
192 |
|
| 3 |
liveuser |
193 |
#設置錯誤訊息
|
|
|
194 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
195 |
|
| 3 |
liveuser |
196 |
#回傳結果
|
| 226 |
liveuser |
197 |
return $result;
|
|
|
198 |
|
| 3 |
liveuser |
199 |
}#if end
|
| 226 |
liveuser |
200 |
|
| 3 |
liveuser |
201 |
#如果 $checkArguments["passed"] 等於 "false"
|
|
|
202 |
if($checkArguments["passed"]=="false"){
|
| 226 |
liveuser |
203 |
|
| 3 |
liveuser |
204 |
#設置錯誤識別
|
|
|
205 |
$result["status"]="false";
|
| 226 |
liveuser |
206 |
|
| 3 |
liveuser |
207 |
#設置錯誤訊息
|
|
|
208 |
$result["error"]=$checkArguments;
|
| 226 |
liveuser |
209 |
|
| 3 |
liveuser |
210 |
#回傳結果
|
| 226 |
liveuser |
211 |
return $result;
|
|
|
212 |
|
| 3 |
liveuser |
213 |
}#if end
|
| 226 |
liveuser |
214 |
|
| 3 |
liveuser |
215 |
#檢查flash檔案是否存在
|
|
|
216 |
#涵式說明:檢查多個檔案與資料夾是否存在.
|
|
|
217 |
#回傳的結果:
|
|
|
218 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
219 |
#$result["error"],錯誤訊息陣列.
|
|
|
220 |
#$resutl["function"],當前執行的涵式名稱.
|
|
|
221 |
#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
|
|
|
222 |
#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
|
|
|
223 |
#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
|
|
|
224 |
#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
|
|
|
225 |
#必填參數:
|
|
|
226 |
#$conf["fileAccess::checkMultiFileExist"]["fileArray"],陣列字串,要檢查書否存在的檔案有哪些,須爲一維陣列數值。
|
|
|
227 |
$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["swfFileLocation"]);
|
|
|
228 |
#$conf["fileAccess::checkMultiFileExist"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
229 |
$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
|
|
|
230 |
#可省略參數
|
|
|
231 |
#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
|
|
|
232 |
#$conf["disableWebSearch"]="false";
|
|
|
233 |
#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
|
|
|
234 |
#$conf["userDir"]="true";
|
|
|
235 |
#參考資料來源:
|
|
|
236 |
#http://php.net/manual/en/function.file-exists.php
|
|
|
237 |
#http://php.net/manual/en/control-structures.foreach.php
|
|
|
238 |
#備註:
|
|
|
239 |
#函數file_exists檢查的路徑為檔案系統的路徑
|
|
|
240 |
$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
|
|
|
241 |
unset($conf["fileAccess::checkMultiFileExist"]);
|
| 226 |
liveuser |
242 |
|
| 3 |
liveuser |
243 |
#如果檢查檔案失敗
|
|
|
244 |
if($checkMultiFileExist["status"]=="false"){
|
| 226 |
liveuser |
245 |
|
| 3 |
liveuser |
246 |
#設置錯誤識別
|
|
|
247 |
$result["status"]="false";
|
| 226 |
liveuser |
248 |
|
| 3 |
liveuser |
249 |
#設置錯誤訊息
|
|
|
250 |
$result["error"]=$checkMultiFileExist;
|
| 226 |
liveuser |
251 |
|
| 3 |
liveuser |
252 |
#回傳結果
|
|
|
253 |
return $result;
|
| 226 |
liveuser |
254 |
|
| 3 |
liveuser |
255 |
}#if end
|
| 226 |
liveuser |
256 |
|
| 3 |
liveuser |
257 |
#如果檔案不存在
|
|
|
258 |
if($checkMultiFileExist["allExist"]=="false"){
|
| 226 |
liveuser |
259 |
|
| 3 |
liveuser |
260 |
#設置錯誤識別
|
|
|
261 |
$result["status"]="false";
|
| 226 |
liveuser |
262 |
|
| 3 |
liveuser |
263 |
#設置錯誤訊息
|
|
|
264 |
$result["error"]=$checkMultiFileExist;
|
| 226 |
liveuser |
265 |
|
| 3 |
liveuser |
266 |
#回傳結果
|
|
|
267 |
return $result;
|
| 226 |
liveuser |
268 |
|
| 3 |
liveuser |
269 |
}#if end
|
| 226 |
liveuser |
270 |
|
| 3 |
liveuser |
271 |
#設定寬度
|
|
|
272 |
$conf["width"]="width = ".$conf["width"];
|
|
|
273 |
|
|
|
274 |
#設定高度
|
|
|
275 |
$conf["height"]="height = ".$conf["height"];
|
| 226 |
liveuser |
276 |
|
| 3 |
liveuser |
277 |
#wmode=transparent 這是去背的語法
|
| 226 |
liveuser |
278 |
$result["content"]="<embed src = ".$checkMultiFileExist["varName"][0]." ".$conf["width"]." ".$conf["height"]." wmode = transparent>";
|
|
|
279 |
|
| 3 |
liveuser |
280 |
#將flash壓縮成base64字串
|
|
|
281 |
#application/x-shockwave-flash
|
|
|
282 |
#函數說明:
|
|
|
283 |
#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
|
|
|
284 |
#回傳結果:
|
|
|
285 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
286 |
#$result["error"],錯誤訊息
|
|
|
287 |
#$result["content"],檔案變數的內容
|
|
|
288 |
#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
|
| 226 |
liveuser |
289 |
#$result["function"],當前執行的函數名稱
|
| 3 |
liveuser |
290 |
#必填參數:
|
|
|
291 |
#$conf["filePosition"],要轉存成2元碼的圖片檔案位置與名稱
|
|
|
292 |
$conf["fileAccess::data"]["filePosition"]=$checkMultiFileExist["varNameFullPath"][0];
|
|
|
293 |
#$conf["mimeType"],2元碼的內容是什麼
|
|
|
294 |
$conf["fileAccess::data"]["mimeType"]="application/x-shockwave-flash";
|
|
|
295 |
#可省略參數:
|
|
|
296 |
#$conf["compressType"],2元碼壓縮的方式,預設為"base64".
|
|
|
297 |
#$conf["compressType"]="base64";
|
|
|
298 |
#$conf["delFile"],讀取完檔案後,要移除檔案嗎?"true"代表要移除,"false"代表不要移除,預設為"false".
|
|
|
299 |
#$conf["delFile"]="false";
|
|
|
300 |
#參考資料:
|
|
|
301 |
#將檔案用字串變數儲存起來=>http://php.net/manual/en/function.file-get-contents.php
|
|
|
302 |
#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
|
|
|
303 |
$data=fileAccess::data($conf["fileAccess::data"]);
|
|
|
304 |
unset($conf["fileAccess::data"]);
|
| 226 |
liveuser |
305 |
|
| 3 |
liveuser |
306 |
#如果加密成base64失敗
|
|
|
307 |
if($data["status"]=="false"){
|
| 226 |
liveuser |
308 |
|
| 3 |
liveuser |
309 |
#設置錯誤識別
|
|
|
310 |
$result["status"]="false";
|
| 226 |
liveuser |
311 |
|
| 3 |
liveuser |
312 |
#設置錯誤訊息
|
|
|
313 |
$result["error"]=$data;
|
| 226 |
liveuser |
314 |
|
| 3 |
liveuser |
315 |
#回傳結果
|
|
|
316 |
return $result;
|
| 226 |
liveuser |
317 |
|
| 3 |
liveuser |
318 |
}#if end
|
| 226 |
liveuser |
319 |
|
| 3 |
liveuser |
320 |
#儲存用base64加密的嵌入flash語法
|
| 226 |
liveuser |
321 |
$result["contentBase64"]="<embed src = ".$data["content"]." ".$conf["width"]." ".$conf["height"]." wmode = transparent>";
|
|
|
322 |
|
| 3 |
liveuser |
323 |
#設置執行正常
|
|
|
324 |
$result["status"]="true";
|
| 226 |
liveuser |
325 |
|
| 3 |
liveuser |
326 |
#回傳結果
|
|
|
327 |
return $result;
|
| 226 |
liveuser |
328 |
|
| 3 |
liveuser |
329 |
}#function show end
|
|
|
330 |
|
|
|
331 |
}#class flash end
|
|
|
332 |
|
|
|
333 |
?>
|