Subversion Repositories php-qbpwcf

Rev

Rev 3 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 226
Line 1... Line 1...
1
#!/usr/bin/php
1
#!/usr/bin/php
2
<?php
2
<?php
3
 
3
 
4
/*
4
/*
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
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
11
    it under the terms of the GNU General Public License as published by
Line 17... Line 17...
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
18
    GNU General Public License for more details.
19
 
19
 
20
    You should have received a copy of the GNU General Public License
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/>.
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
    
22
 
23
*/
23
*/
24
 
24
 
25
/*
25
/*
26
說明:
26
說明:
27
輔助使用rsync指令
27
輔助使用rsync指令
28
 
28
 
29
範例:
29
範例:
30
rsync.php --source ~/Downloads/ --target ~/backupOfDownloads/ 
30
rsync.php --source ~/Downloads/ --target ~/backupOfDownloads/
31
*/
31
*/
32
 
32
 
33
#使用命名空間qbpwcf
33
#使用命名空間qbpwcf
34
namespace qbpwcf;
34
namespace qbpwcf;
35
 
35
 
Line 63... Line 63...
63
	#結束執行,回傳shell 1.
63
	#結束執行,回傳shell 1.
64
	exit(1);
64
	exit(1);
65
 
65
 
66
	}#if end
66
	}#if end
67
 
67
 
68
#設置 include path 
68
#設置 include path
69
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
69
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
70
 
70
 
71
#匯入外部套件
71
#匯入外部套件
72
include("allInOne.php");
72
include("allInOne.php");
73
 
73
 
74
#說明函式
74
#說明函式
75
function help()
75
function help()
76
{
76
{
77
	#印出指令說明
77
	#印出指令說明
78
	echo "Usage of ".basename(__FILE__).":".PHP_EOL; 
78
	echo "Usage of ".basename(__FILE__).":".PHP_EOL;
79
	echo "--source [path to source] 代表要複製的來源.".PHP_EOL;
79
	echo "--source [path to source] 代表要複製的來源.".PHP_EOL;
80
	echo "--target [path to target] 代表要複製到的目的地.".PHP_EOL;
80
	echo "--target [path to target] 代表要複製到的目的地.".PHP_EOL;
81
	echo "--recursive [on/off] 代表是否要包含目錄底下的所有內容,預設為on.".PHP_EOL;
81
	echo "--recursive [on/off] 代表是否要包含目錄底下的所有內容,預設為on.".PHP_EOL;
82
	echo "--exclude [path to excluded source] 代表要排除指定的檔案或目錄,若有多個請指定多次.".PHP_EOL;
82
	echo "--exclude [path to excluded source] 代表要排除指定的檔案或目錄,若有多個請指定多次.".PHP_EOL;
83
	echo "--excludeFileType [file type to exclude] 代表要排除指定的檔案類型,若有多個請指定多次.".PHP_EOL;
83
	echo "--excludeFileType [file type to exclude] 代表要排除指定的檔案類型,若有多個請指定多次.".PHP_EOL;
84
	echo "--bandWidthLimit [transfer bandwidth limit] 代表要指定傳輸的頻寬上限,單為可為K(KB)、M(MB)、G(GB).".PHP_EOL;
84
	echo "--bandWidthLimit [transfer bandwidth limit] 代表要指定傳輸的頻寬上限,單為可為K(KB)、M(MB)、G(GB).".PHP_EOL;
85
	echo "--newFileOnly [on/off] 代表是否只複製來源比目標新的檔案或目錄,預設為off.".PHP_EOL;
85
	echo "--newFileOnly [on/off] 代表是否只複製來源比目標新的檔案或目錄,預設為off.".PHP_EOL;
86
	echo "--appendMode [on/off] 代表是否要從檔案尾部新增不足的部分,預設為off.".PHP_EOL;
86
	echo "--appendMode [on/off] 代表是否要從檔案尾部新增不足的部分,預設為off.".PHP_EOL;
87
	
87
 
88
	#結束執行
88
	#結束執行
89
	exit;
89
	exit;
90
}
90
}
91
 
91
 
92
#函式說明:
92
#函式說明:
Line 113... Line 113...
113
#如果解析參數失敗
113
#如果解析參數失敗
114
if($parseArgu["status"]==="false")
114
if($parseArgu["status"]==="false")
115
{
115
{
116
	#印出結果
116
	#印出結果
117
	var_dump($parseArgu);
117
	var_dump($parseArgu);
118
	
118
 
119
	#結束執行
119
	#結束執行
120
	exit;
120
	exit;
121
	
121
 
122
}#if end
122
}#if end
123
 
123
 
124
#檢查參數
124
#檢查參數
125
#函式說明:
125
#函式說明:
126
#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
126
#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
Line 173... Line 173...
173
#若執行失敗
173
#若執行失敗
174
if($checkArguments["status"]==="false"){
174
if($checkArguments["status"]==="false"){
175
 
175
 
176
	#印出結果
176
	#印出結果
177
	var_dump($checkArguments);
177
	var_dump($checkArguments);
178
	
178
 
179
	#結束執行
179
	#結束執行
180
	exit;
180
	exit;
181
 
181
 
182
	}#if end
182
	}#if end
183
 
183
 
Line 187... Line 187...
187
	#debug
187
	#debug
188
	var_dump($checkArguments);
188
	var_dump($checkArguments);
189
 
189
 
190
	#提示用法
190
	#提示用法
191
	help();
191
	help();
192
	
192
 
193
	#結束執行
193
	#結束執行
194
	exit;
194
	exit;
195
 
195
 
196
	}#if end
196
	}#if end
197
 
197
 
Line 209... Line 209...
209
 
209
 
210
	#轉換為 "true"
210
	#轉換為 "true"
211
	$recursive="true";
211
	$recursive="true";
212
 
212
 
213
	}#if end
213
	}#if end
214
	
214
 
215
#反之
215
#反之
216
else{
216
else{
217
 
217
 
218
	#轉換為 "false"
218
	#轉換為 "false"
219
	$recursive="false";
219
	$recursive="false";
Line 228... Line 228...
228
 
228
 
229
	#轉換為 "true"
229
	#轉換為 "true"
230
	$newFileOnly="true";
230
	$newFileOnly="true";
231
 
231
 
232
	}#if end
232
	}#if end
233
	
233
 
234
#反之
234
#反之
235
else{
235
else{
236
 
236
 
237
	#轉換為 "false"
237
	#轉換為 "false"
238
	$newFileOnly="false";
238
	$newFileOnly="false";
Line 247... Line 247...
247
 
247
 
248
	#轉換為 "true"
248
	#轉換為 "true"
249
	$appendMode="true";
249
	$appendMode="true";
250
 
250
 
251
	}#if end
251
	}#if end
252
	
252
 
253
#反之
253
#反之
254
else{
254
else{
255
 
255
 
256
	#轉換為 "false"
256
	#轉換為 "false"
257
	$appendMode="false";
257
	$appendMode="false";
258
 
258
 
259
	}#else end
259
	}#else end
260
	
260
 
261
#如果有 exclude 參數
261
#如果有 exclude 參數
262
if(isset($parseArgu["content"]["exclude"])){
262
if(isset($parseArgu["content"]["exclude"])){
263
 
263
 
264
	#設置 exclude 變數
264
	#設置 exclude 變數
265
	$exclude=$parseArgu["content"]["exclude"];
265
	$exclude=$parseArgu["content"]["exclude"];
266
 
266
 
267
	}#if end
267
	}#if end
268
	
268
 
269
#如果有 excludeFileType 參數
269
#如果有 excludeFileType 參數
270
if(isset($parseArgu["content"]["excludeFileType"])){
270
if(isset($parseArgu["content"]["excludeFileType"])){
271
 
271
 
272
	#設置 excludeFileType 變數
272
	#設置 excludeFileType 變數
273
	$excludeFileType=$parseArgu["content"]["excludeFileType"];
273
	$excludeFileType=$parseArgu["content"]["excludeFileType"];
274
 
274
 
275
	}#if end
275
	}#if end
276
	
276
 
277
#如果有 bandWidthLimit 參數
277
#如果有 bandWidthLimit 參數
278
if(isset($parseArgu["content"]["bandWidthLimit"])){
278
if(isset($parseArgu["content"]["bandWidthLimit"])){
279
 
279
 
280
	#bandWidthLimit
280
	#bandWidthLimit
281
	$bandWidthLimit=$parseArgu["content"]["bandWidthLimit"][0];
281
	$bandWidthLimit=$parseArgu["content"]["bandWidthLimit"][0];
Line 311... Line 311...
311
#如果有 $excludeFileType 變數
311
#如果有 $excludeFileType 變數
312
if(isset($excludeFileType)){
312
if(isset($excludeFileType)){
313
 
313
 
314
	#$conf["excludeFileType"],字串陣列,每個元素代表要排除的副檔名,預設不指定.
314
	#$conf["excludeFileType"],字串陣列,每個元素代表要排除的副檔名,預設不指定.
315
	$conf["excludeFileType"]=$excludeFileType;
315
	$conf["excludeFileType"]=$excludeFileType;
316
	
316
 
317
	}#if end
317
	}#if end
318
 
318
 
319
#如果有 $bandWidthLimit 變數
319
#如果有 $bandWidthLimit 變數
320
if(isset($bandWidthLimit)){
320
if(isset($bandWidthLimit)){
321
 
321
 
Line 338... Line 338...
338
#若執行失敗
338
#若執行失敗
339
if($rsync["status"]==="false"){
339
if($rsync["status"]==="false"){
340
 
340
 
341
	#印出結果
341
	#印出結果
342
	var_dump($rsync);
342
	var_dump($rsync);
343
	
343
 
344
	#結束執行
344
	#結束執行
345
	exit;
345
	exit;
346
 
346
 
347
	}#if end
-
 
348
347
	}#if end
-
 
348