Subversion Repositories php-qbpwcf

Rev

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

Rev Author Line No. Line
3 liveuser 1
#!/usr/bin/php
2
<?php
3
 
4
/*
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
226 liveuser 6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
3 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/>.
226 liveuser 22
 
3 liveuser 23
*/
24
 
25
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
28
#取得 lib path
29
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/libexec/folderOfUsrLib.php"),$output,$status);
30
 
31
#如果執行失敗
32
if($status!==0){
33
 
34
	#debug
35
	var_dump(__LINE__,$output);
36
 
37
	#結束執行,回傳shell 1.
38
	exit(1);
39
 
40
	}#if end
41
 
42
#儲存lib path
43
$folderOfUsrLib=$output[0];
44
 
45
#以該檔案的實際位置的 lib path 為 include path 首位
46
$output=array();
47
exec("cd ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../".$folderOfUsrLib."/qbpwcf").";pwd;",$output,$status);
48
 
49
#如果執行失敗
50
if($status!==0){
51
 
52
	#debug
53
	var_dump(__LINE__,$output);
54
 
55
	#結束執行,回傳shell 1.
56
	exit(1);
57
 
58
	}#if end
59
 
226 liveuser 60
#設置 include path
3 liveuser 61
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
62
 
63
#匯入外部套件
64
include("allInOne.php");
65
 
66
#如果不存在要處理的參數
67
if( !isset($_SERVER['argv'][1]) )
68
{
69
	#函式說明:
70
	#讀取標準I/O的一行輸入.並提供提示說明.
71
	#回傳結果:
72
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
73
	#$result["error"],錯誤訊息.
74
	#$result["function"],當前執行的函式名稱.
75
	#$result["content"],取得的輸入內容.
76
	#必填參數:
77
	#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
78
	$conf["commentsArray"]=array("");
79
	#可省略參數:
80
	#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
81
	$conf["newLineBreak"]="false";
82
	#備註:
83
	#無.
84
	$readLine=cmd::readLine($conf);
85
	unset($conf);
226 liveuser 86
 
3 liveuser 87
	#如果讀取 i/o 輸入失敗
88
	if($readLine["status"]==="false")
89
	{
90
		#印出結果
226 liveuser 91
		var_dump($readLine);
3 liveuser 92
 
93
		#停止執行
94
		exit;
226 liveuser 95
 
3 liveuser 96
	}#if end
226 liveuser 97
 
3 liveuser 98
	#如果沒有輸入
99
	if(empty($readLine["content"]))
100
	{
101
		#show help
102
		help();
103
 
104
		#停止執行
105
		exit;
106
	}
226 liveuser 107
 
3 liveuser 108
	#設置為第一個參數
109
	$_SERVER['argv'][1]=$readLine["content"];
110
}
111
 
112
#如果第參數為 "help" 或 "-h"
113
if( $_SERVER['argv'][1]==="help" || $_SERVER['argv'][1]==="-h" )
114
{
115
	#show help
116
	help();
117
 
118
	#停止執行
119
	exit;
120
 
121
}#if end
122
 
123
#如果不是"{"開頭
124
while(substr($_SERVER['argv'][1],0,1)!=="{")
125
{
126
	#剔除最後一個字
127
	$_SERVER['argv'][1]=substr($_SERVER['argv'][1],1);
128
}
129
 
130
#印出結果
131
var_dump(json_decode($_SERVER['argv'][1]));
132
 
133
#說明
134
function help()
135
{
136
	#說明
137
	echo $_SERVER['argv'][0]." string to json decode".PHP_EOL;
138
}
139
 
140
?>