Subversion Repositories php-qbpwcf

Rev

Blame | Last modification | View Log | RSS feed

<?php


/*

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

#初始化輸出
$output=array();

#取得 lib path
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);

#如果執行失敗
if($status!==0){

        #debug
        var_dump(__LINE__,$output);

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

        }#if end

#儲存lib path
$folderOfUsrLib=$output[0];

#初始化輸出
$output=array();

#以該檔案的實際位置的 lib path 為 include path 首位
exec("cd ".\escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../usr/".$folderOfUsrLib."/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";

/* test run by proc will end.

#迴圈
for($i=10;$i>0;$i--){

        #提示訊息
        echo $i." 秒後結束".PHP_EOL;
        
        #休息一秒
        sleep(1);

        }#for end

#break point
exit;

*/

#函式說明:
#存取快取服務.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["argu"],所使用的參數.
#$result["content"],得到的回應字串.
#必填參數:
#$conf["action"],字串,"read":代表要讀取資料;"write":代表要寫入資料.
$conf["action"]="write";
#$conf["type"],字串,"php_variable":php的變數;"proc",透過proc運行的程序,可透過標準輸入進行操作.
$conf["type"]="php_variable";
#可省略參數:
#$conf["value"],null,"action"參數為write時,資源的內容,形態不固定.
$conf["value"]=time();
#$conf["sock"],字串,unix domain socket的路徑與名稱,預設為相對於當前套件的 var/qbpwcf/resource.sock
$conf["sock"]="resource.sock";
#$conf["condition"],陣列,條件,預設為空陣列,代表沒有條件,通常是為新增資源,元素的key為"id"者代表目標資源的id;元素的key為"value"者代表目標資源是否相等於"value",且"type"為"php_variable";元素的key為"pid"者代表運行的資源程序pid,且"type"為"proc"
#$conf["condition"]=array();
#參考資料:
#無.
#備註:
#僅能在命令列環境下運行.
$client=resource::client($conf);
unset($conf);

#如果執行異常
if($client["status"]==="false"){

        #debug
        var_dump($client);

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

        }#if end

?>