Subversion Repositories php-qbpwcf

Rev

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

Rev Author Line No. Line
47 liveuser 1
<?php
2
 
3
/*
4
 
5
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
226 liveuser 6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
47 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
#assets dir
29
$assetsDir="assets of fileAccess::checkMultiFileExist_20250627";
30
 
31
#函式說明:
32
#檢查多個檔案與資料夾是否存在.
33
#回傳的結果:
34
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
35
#$result["error"],錯誤訊息陣列.
36
#$resutl["function"],當前執行的涵式名稱.
37
#$result["argu"],使用的參數.
38
#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
39
#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
40
#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
41
#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
42
#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
43
#必填參數:
44
#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
45
$conf["fileArray"]=array("/usr/share/pear/Net/SMTP.php");
46
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
47
$conf["fileArgu"]=__FILE__;
48
#可省略參數:
49
#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
50
$conf["disableWebSearch"]="true";
51
#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
52
$conf["userDir"]="false";
53
#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
54
$conf["web"]="false";
55
#參考資料:
56
#http://php.net/manual/en/function.file-exists.php
57
#http://php.net/manual/en/control-structures.foreach.php
58
#備註:
59
#函數file_exists檢查的路徑為檔案系統的路徑
60
#$result["varName"][$i]結果未實作
61
$checkMultiFileExist=fileAccess::checkMultiFileExist($conf);
62
unset($conf);
63
 
64
#如果執行失敗
65
if($checkMultiFileExist["status"]==="false"){
66
 
67
	#函式說明:
68
	#撰寫log
69
	#回傳結果:
70
	#$result["status"],狀態,"true"或"false".
71
	#$result["error"],錯誤訊息陣列.
72
	#$result["function"],當前函式的名稱.
73
	#$result["argu"],使用的參數.
74
	#必填參數:
75
	#$conf["path"],字串,log檔案的路徑與名稱.
76
	$conf["path"]=$logFile;
77
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
78
	$conf["content"]=$checkMultiFileExist;
79
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
80
	$conf["fileArgu"]=__FILE__;
81
	#可省略參數:
82
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
83
	#$conf["rewrite"]="false";
84
	#參考資料:
85
	#無.
86
	#備註:
87
	#無.
88
	$record=logs::record($conf);
89
	unset($conf);
226 liveuser 90
 
47 liveuser 91
	#如果寫log失敗
92
	if($record["status"]==="false"){
226 liveuser 93
 
47 liveuser 94
		#印出結果
95
		var_dump($record);
226 liveuser 96
 
47 liveuser 97
		}#if end
226 liveuser 98
 
47 liveuser 99
	#結束執行,回傳錯誤代碼1
100
	exit(1);
101
 
102
	}#if end
226 liveuser 103
 
47 liveuser 104
#debug
226 liveuser 105
var_dump($checkMultiFileExist);