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
#如果不存在參數1跟2
67
if( !isset($_SERVER['argv'][1]) || !isset($_SERVER['argv'][2]) )
68
{
69
	#show help
70
	help();
71
 
72
	#停止執行
73
	exit;
74
}
75
 
76
#如果第參數為 "help" 或 "-h"
77
if( $_SERVER['argv'][1]==="help" || $_SERVER['argv'][1]==="-h" )
78
{
79
	#show help
80
	help();
81
 
82
	#停止執行
83
	exit;
84
 
85
}#if end
86
 
87
#涵式說明:
88
#變更word press網站的所有資訊為新的 domain name.
89
#回傳結果:
90
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
91
#$result["error"],錯誤訊息.
92
#$result["function"],當前執行的函數名稱.
93
#$result["argu"],所使用的參數.
94
#$result["content"],執行的結果.
95
#必填參數:
96
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
97
$conf["fileArgu"]=__FILE__;
98
#$conf["oldDomain"],字串,舊的domain名稱.
99
$conf["oldDomain"]=$_SERVER['argv'][1];
100
#$conf["newDomain"],字串,新的domain名稱.
101
$conf["newDomain"]=$_SERVER['argv'][2];
102
#可省略參數:
103
 
104
#如果有第三個參數
105
if(isset($_SERVER['argv'][3])){
106
 
107
	#$conf["wpConfig"],字串,wp-cofnig.php的位置與名稱,預設為"wp-config.php".
108
	$conf["wpConfig"]=$_SERVER['argv'][3];
109
 
110
	}#if end
111
 
112
$changeWordPressDomain=cmd::changeWordPressDomain($conf);
113
unset($conf);
114
 
115
#印出結果
116
var_dump($changeWordPressDomain);
117
 
118
#說明
119
function help()
120
{
121
	#說明
122
	echo "change wordpress's domain.".PHP_EOL;
123
	echo "db config file wp-cofnig.php should be here.".PHP_EOL;
124
	echo $_SERVER['argv'][0]." old-domain new-domain [position and name of wp-admin.php]".PHP_EOL;
125
}
126
 
127
?>