Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
369 liveuser 1
<?php
2
 
3
 
4
/*
5
 
6
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
7
    Copyright (C) 2014~2026 MIN ZHI, CHEN
8
 
9
    This file is part of QBPWCF.
10
 
11
    QBPWCF is free software: you can redistribute it and/or modify
12
    it under the terms of the GNU General Public License as published by
13
    the Free Software Foundation, either version 3 of the License, or
14
    (at your option) any later version.
15
 
16
    QBPWCF is distributed in the hope that it will be useful,
17
    but WITHOUT ANY WARRANTY; without even the implied warranty of
18
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
    GNU General Public License for more details.
20
 
21
    You should have received a copy of the GNU General Public License
22
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
23
 
24
*/
25
 
26
#使用命名空間qbpwcf
27
namespace qbpwcf;
28
 
29
#初始化輸出
30
$output=array();
31
 
32
#取得 lib path
33
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
34
 
35
#如果執行失敗
36
if($status!==0){
37
 
38
	#debug
39
	var_dump(__LINE__,$output);
40
 
41
	#結束執行,回傳shell 1.
42
	exit(1);
43
 
44
	}#if end
45
 
46
#儲存lib path
47
$folderOfUsrLib=$output[0];
48
 
49
#初始化輸出
50
$output=array();
51
 
52
#以該檔案的實際位置的 lib path 為 include path 首位
53
exec("cd ".\escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../../usr/".$folderOfUsrLib."/qbpwcf").";pwd;",$output,$status);
54
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
55
 
56
#匯入套件
57
require_once("allInOne.php");
58
 
59
#建議的log位置
60
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
61
 
62
#函式說明:
63
#建立快取服務.實質上為unix domain socket server.
64
#回傳結果:
65
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
66
#$reuslt["error"],執行不正常結束的錯訊息陣列.
67
#$result["function"],當前執行的函式名稱.
68
#$result["argu"],所使用的參數.
69
#必填參數:
70
#無.
71
#可省略參數:
72
#$conf["sock"],字串,unix domain socket的路徑與名稱,預設為相對於當前套件的 var/qbpwcf/resource.sock
73
$conf["sock"]="resource.sock";
74
#$conf["debug"],字串,"true"代表要啟用debug模式;反之預設為"false"不啟用.
75
$conf["debug"]="true";
76
#$conf["addOnProcessFunc"],陣列,收到訊息後,要依順執行的函式,預設為array("\qbpwcf\resource::addOnProcessFunc").
77
#$conf["addOnProcessFunc"]=array();
78
#$conf["funcToRunWhenIdle"],陣列,閒置時要依序執行的函式,預設為array("/qbpwcf/resource::funcToRunWhenIdle");
79
#$conf["funcToRunWhenIdle"]=array();
80
#$conf["deafaultLifeTime"],字串,資源沒被使用時,預設的存留時間秒數,預設為"300".
81
#$conf["deafaultLifeTime"]="300";
82
#參考資料:
83
#無.
84
#備註:
85
#僅能在命令列環境下運行.
86
$server=resource::server($conf);
87
unset($conf);
88
 
89
#如果執行失敗
90
if($server["status"]==="false"){
91
 
92
	#函式說明:
93
	#撰寫log
94
	#回傳結果:
95
	#$result["status"],狀態,"true"或"false".
96
	#$result["error"],錯誤訊息陣列.
97
	#$result["function"],當前函式的名稱.
98
	#$result["argu"],使用的參數.
99
	#必填參數:
100
	#$conf["path"],字串,log檔案的路徑與名稱.
101
	$conf["path"]=$logFile;
102
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
103
	$conf["content"]=$server;
104
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
105
	$conf["fileArgu"]=__FILE__;
106
	#可省略參數:
107
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
108
	#$conf["rewrite"]="false";
109
	#參考資料:
110
	#無.
111
	#備註:
112
	#無.
113
	$record=logs::record($conf);
114
	unset($conf);
115
 
116
	#如果寫log失敗
117
	if($record["status"]==="false"){
118
 
119
		#印出結果
120
		var_dump($record);
121
 
122
		}#if end
123
 
124
	#結束執行,回傳錯誤代碼1
125
	exit(1);
126
 
127
	}#if end
128
 
129
?>