Subversion Repositories php-qbpwcf

Rev

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

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2025 Min-Jhin,Chen

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QBPWCF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/

#使用命名空間qbpwcf
namespace qbpwcf;

#assets dir
$assetsDir="assets of fileAccess::checkMultiFileExist_20250627";

#函式說明:
#檢查多個檔案與資料夾是否存在.
#回傳的結果:
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息陣列.
#$resutl["function"],當前執行的涵式名稱.
#$result["argu"],使用的參數.
#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
#必填參數:
#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
$conf["fileArray"]=array("/usr/share/pear/Net/SMTP.php");
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#可省略參數:
#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
$conf["disableWebSearch"]="true";
#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
$conf["userDir"]="false";
#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
$conf["web"]="false";
#參考資料:
#http://php.net/manual/en/function.file-exists.php
#http://php.net/manual/en/control-structures.foreach.php
#備註:
#函數file_exists檢查的路徑為檔案系統的路徑
#$result["varName"][$i]結果未實作
$checkMultiFileExist=fileAccess::checkMultiFileExist($conf);
unset($conf);

#如果執行失敗
if($checkMultiFileExist["status"]==="false"){

        #函式說明:
        #撰寫log
        #回傳結果:
        #$result["status"],狀態,"true"或"false".
        #$result["error"],錯誤訊息陣列.
        #$result["function"],當前函式的名稱.
        #$result["argu"],使用的參數.
        #必填參數:
        #$conf["path"],字串,log檔案的路徑與名稱.
        $conf["path"]=$logFile;
        #$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
        $conf["content"]=$checkMultiFileExist;
        #$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
        $conf["fileArgu"]=__FILE__;
        #可省略參數:
        #$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
        #$conf["rewrite"]="false";
        #參考資料:
        #無.
        #備註:
        #無.
        $record=logs::record($conf);
        unset($conf);
        
        #如果寫log失敗
        if($record["status"]==="false"){
        
                #印出結果
                var_dump($record);
        
                }#if end
        
        #結束執行,回傳錯誤代碼1
        exit(1);

        }#if end
        
#debug
var_dump($checkMultiFileExist);