Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 925 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
#!/bin/php
2
<?php
3
 
464 liveuser 4
/*
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
621 liveuser 6
    Copyright (C) 2015~2024 Min-Jhin,Chen
464 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/>.
22
 
23
*/
24
 
1 liveuser 25
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
955 liveuser 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
 
466 liveuser 45
#以該檔案的實際位置的 lib path 為 include path 首位
955 liveuser 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
 
60
#設置 include path 
466 liveuser 61
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
62
 
1 liveuser 63
#匯入外部套件
466 liveuser 64
include("allInOne.php");
1 liveuser 65
 
66
#如果有參數
67
if(isset($_SERVER["argv"][1]))
68
{
69
	#解析成陣列
70
	$array=(array)json_decode(urldecode(base64_decode($_SERVER["argv"][1])));	
71
 
72
	#顯示目前的陣列結構
73
	var_dump($array);
74
 
75
}#if end
76
 
77
#初始化key
78
$key="";
79
 
80
#當 $key 等於 ""
81
while($key==="")
82
{
83
	#涵式說明:
84
	#讀取標準I/O的一行輸入.並提供提示說明.
85
	#回傳的結果:
86
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
87
	#$result["error"],錯誤訊息.
88
	#$result["function"],當前執行的函數名稱.
89
	#$result["content"],取得的輸入內容.
90
	#必填的參數:
91
	#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
92
	$conf["commentsArray"]=array("請輸入陣列的key");
93
	#可省略的參數:
94
	#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
95
	#$conf["newLineBreak"]="false";
96
	$readLine=cmd::readLine($conf);
97
	unset($conf);
98
 
99
	#如果讀取失敗
100
	if($readLine["status"]==="false")
101
	{
102
		#初始化結果
103
		$result=array();
104
 
105
		#設置執行失敗
106
		$result["status"]="false";
107
 
108
		#設置執行錯誤
109
		$result["error"]=$readLine;
110
 
111
		#印出結果
112
		var_dump($result);
113
 
114
	}#if end
115
 
116
	#讀取到的內容
117
	$key=$readLine["content"];
118
 
119
}#while end
120
 
121
#當 $value 不存在
122
while(!isset($value))
123
{
124
	#涵式說明:
125
	#讀取標準I/O的一行輸入.並提供提示說明.
126
	#回傳的結果:
127
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
128
	#$result["error"],錯誤訊息.
129
	#$result["function"],當前執行的函數名稱.
130
	#$result["content"],取得的輸入內容.
131
	#必填的參數:
132
	#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
133
	$conf["commentsArray"]=array("請輸入陣列的value");
134
	#可省略的參數:
135
	#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
136
	#$conf["newLineBreak"]="false";
137
	$readLine=cmd::readLine($conf);
138
	unset($conf);
139
 
140
	#如果讀取失敗
141
	if($readLine["status"]==="false")
142
	{
143
		#初始化結果
144
		$result=array();
145
 
146
		#設置執行失敗
147
		$result["status"]="false";
148
 
149
		#設置執行錯誤
150
		$result["error"]=$readLine;
151
 
152
		#印出結果
153
		var_dump($result);
154
 
155
	}#if end
156
 
157
	#讀取到的內容
158
	$value=$readLine["content"];
159
 
160
}#while end
161
 
162
#如果不存在 $array
163
if(!isset($array))
164
{
165
	#初始化陣列變數
166
	$array=array();
167
 
168
}#if end
169
 
170
#設置陣列變數數值
171
$array[$key]=$value;
172
 
173
#取得轉換成 json 格式且 urlencode 跟 base64_encode 後的資料
174
$output=base64_encode(urlencode(json_encode($array)));
175
 
176
#印出結果
177
echo $output.PHP_EOL;
178
 
179
#遞迴執行
180
system($_SERVER["argv"][0]." ".$output);
181
 
182
?>