Subversion Repositories qbpwcf-lib(archive)

Rev

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

#!/bin/php
<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2015~2024 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;

#以該檔案的實際位置的 lib path 為 include path 首位
exec("cd ".pathinfo(__FILE__)["dirname"]."/../qbpwcf;pwd;",$output,$status);
set_include_path($output[0].PATH_SEPARATOR.get_include_path());

#匯入套件
require_once("allInOne.php");

#建議的log位置
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";

#要使用的範例name
#$nameOfSample="initial";
#$nameOfSample="20240328";
$nameOfSample="20240401";

#存放範例的資料夾
$sampleFolder="config::client";

#設置範例檔案名稱與路徑
$fileNameOfSample=$sampleFolder."/".$nameOfSample.".php";

#初始化儲存範例代碼
$samples=array();

#增加 config::client 的範例資訊
$samples[]=array("name"=>"initial","comnent"=>"initial sample.");
$samples[]=array("name"=>"20240328","comnent"=>"get undefined config from cache");
$samples[]=array("name"=>"20240401","comnent"=>"get config string from cache");
#$samples[]=array("name"=>"20240401-1","comnent"=>"get config array from cache");

#針對每個範例資訊
foreach($samples as $sample){

        #如果找到對應的範例
        if($sample["name"]===$nameOfSample){
        
                #如果存放範例的資料夾不存在
                if(!file_exists($sampleFolder)){
                
                        #提示訊息
                        echo "存放範例的資料夾(".$sampleFolder.")不存在".PHP_EOL;
                
                        #結束執行,並回傳1給shell
                        exit(1);
                
                        }#if end
                        
                #如果對應的範例檔案不存在
                if(!file_exists($fileNameOfSample)){
                
                        #提示訊息
                        echo "範例檔案(".$fileNameOfSample.")不存在".PHP_EOL;
                
                        #結束執行,並回傳1給shell
                        exit(1);
                
                        }#if end
                        
                #匯入範例
                require_once($fileNameOfSample);
                
                #結束執行
                exit;
        
                }#if end

        }#foreach end
        
#執行到這邊代表沒有對應的範例

#提示範例不存在
echo "範例(".$nameOfSample.")不存在".PHP_EOL;

#結束執行,並回傳1給shell
exit(1);

?>