Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 906 | Go to most recent revision | 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
 
466 liveuser 28
#以該檔案的實際位置的 lib path 為 include path 首位
925 liveuser 29
exec("cd ".pathinfo(__FILE__)["dirname"]."/../lib/qbpwcf;pwd;",$output,$status);
466 liveuser 30
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
31
 
1 liveuser 32
#匯入外部套件
466 liveuser 33
include("allInOne.php");
1 liveuser 34
 
35
#如果有參數
36
if(isset($_SERVER["argv"][1]))
37
{
38
	#解析成陣列
39
	$array=(array)json_decode(urldecode(base64_decode($_SERVER["argv"][1])));	
40
 
41
	#顯示目前的陣列結構
42
	var_dump($array);
43
 
44
}#if end
45
 
46
#初始化key
47
$key="";
48
 
49
#當 $key 等於 ""
50
while($key==="")
51
{
52
	#涵式說明:
53
	#讀取標準I/O的一行輸入.並提供提示說明.
54
	#回傳的結果:
55
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
56
	#$result["error"],錯誤訊息.
57
	#$result["function"],當前執行的函數名稱.
58
	#$result["content"],取得的輸入內容.
59
	#必填的參數:
60
	#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
61
	$conf["commentsArray"]=array("請輸入陣列的key");
62
	#可省略的參數:
63
	#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
64
	#$conf["newLineBreak"]="false";
65
	$readLine=cmd::readLine($conf);
66
	unset($conf);
67
 
68
	#如果讀取失敗
69
	if($readLine["status"]==="false")
70
	{
71
		#初始化結果
72
		$result=array();
73
 
74
		#設置執行失敗
75
		$result["status"]="false";
76
 
77
		#設置執行錯誤
78
		$result["error"]=$readLine;
79
 
80
		#印出結果
81
		var_dump($result);
82
 
83
	}#if end
84
 
85
	#讀取到的內容
86
	$key=$readLine["content"];
87
 
88
}#while end
89
 
90
#當 $value 不存在
91
while(!isset($value))
92
{
93
	#涵式說明:
94
	#讀取標準I/O的一行輸入.並提供提示說明.
95
	#回傳的結果:
96
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
97
	#$result["error"],錯誤訊息.
98
	#$result["function"],當前執行的函數名稱.
99
	#$result["content"],取得的輸入內容.
100
	#必填的參數:
101
	#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
102
	$conf["commentsArray"]=array("請輸入陣列的value");
103
	#可省略的參數:
104
	#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
105
	#$conf["newLineBreak"]="false";
106
	$readLine=cmd::readLine($conf);
107
	unset($conf);
108
 
109
	#如果讀取失敗
110
	if($readLine["status"]==="false")
111
	{
112
		#初始化結果
113
		$result=array();
114
 
115
		#設置執行失敗
116
		$result["status"]="false";
117
 
118
		#設置執行錯誤
119
		$result["error"]=$readLine;
120
 
121
		#印出結果
122
		var_dump($result);
123
 
124
	}#if end
125
 
126
	#讀取到的內容
127
	$value=$readLine["content"];
128
 
129
}#while end
130
 
131
#如果不存在 $array
132
if(!isset($array))
133
{
134
	#初始化陣列變數
135
	$array=array();
136
 
137
}#if end
138
 
139
#設置陣列變數數值
140
$array[$key]=$value;
141
 
142
#取得轉換成 json 格式且 urlencode 跟 base64_encode 後的資料
143
$output=base64_encode(urlencode(json_encode($array)));
144
 
145
#印出結果
146
echo $output.PHP_EOL;
147
 
148
#遞迴執行
149
system($_SERVER["argv"][0]." ".$output);
150
 
151
?>