Subversion Repositories qbpwcf-lib(archive)

Rev

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

Rev 941 Rev 944
Line 1954... Line 1954...
1954
			}#if end
1954
			}#if end
1955
	
1955
	
1956
		}#if end
1956
		}#if end
1957
 
1957
 
1958
	}#if end
1958
	}#if end
1959
	
-
 
1960
#systemctl daemon-reload
-
 
1961
#函式說明:
-
 
1962
#執行 systemd 程序來管理服務.
-
 
1963
#回傳結果:
-
 
1964
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1965
#$result["error"],錯誤訊息.
-
 
1966
#$result["function"],當前執行的函式名稱.
-
 
1967
#$result["argu"],所使用的參數.
-
 
1968
#$result["content"],執行的結果.
-
 
1969
#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
-
 
1970
#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
-
 
1971
#必填參數:
-
 
1972
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
1973
$conf["fileArgu"]=__FILE__;
-
 
1974
#$conf["name"],字串,服務名稱.
-
 
1975
$conf["name"]="daemon-reload";
-
 
1976
#可省略參數:
-
 
1977
#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
-
 
1978
#$conf["operation"]="";
-
 
1979
#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
-
 
1980
#$conf["username"]="";
-
 
1981
#$conf["password"],字串,使用者的密碼,預設不使用.
-
 
1982
#$conf["password"]="";
-
 
1983
#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
-
 
1984
$conf["daemonReload"]="true";
-
 
1985
#參考資料:
-
 
1986
#無.
-
 
1987
#備註:
-
 
1988
#無.
-
 
1989
$systemd=cmd::systemd($conf);
-
 
1990
unset($conf);
-
 
1991
 
-
 
1992
#如果執行失敗
-
 
1993
if($systemd["status"]==="false"){
-
 
1994
 
-
 
1995
	#函式說明:
-
 
1996
	#撰寫log
-
 
1997
	#回傳結果:
-
 
1998
	#$result["status"],狀態,"true"或"false".
-
 
1999
	#$result["error"],錯誤訊息陣列.
-
 
2000
	#$result["function"],當前函式的名稱.
-
 
2001
	#$result["argu"],使用的參數.
-
 
2002
	#必填參數:
-
 
2003
	#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2004
	$conf["path"]=$logFile;
-
 
2005
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2006
	$conf["content"]=$systemd;
-
 
2007
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2008
	$conf["fileArgu"]=__FILE__;
-
 
2009
	#可省略參數:
-
 
2010
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2011
	#$conf["rewrite"]="false";
-
 
2012
	#參考資料:
-
 
2013
	#無.
-
 
2014
	#備註:
-
 
2015
	#無.
-
 
2016
	$record=logs::record($conf);
-
 
2017
	
-
 
2018
	#如果執行失敗
-
 
2019
	if($record["status"]==="false"){
-
 
2020
	
-
 
2021
		#印出結果
-
 
2022
		var_dump($record);
-
 
2023
	
-
 
2024
		}#if end
-
 
2025
		
-
 
2026
	#異常結束執行
-
 
2027
	exit(1);
-
 
2028
 
-
 
2029
	}#if end
-
 
2030
 
-
 
2031
#enable and restart 於 $libOfRootPath.$name."/usr/lib/systemd/system" 底下的所有服務
-
 
2032
 
1959
 
2033
#函式說明:
1960
#函式說明:
2034
#取得目錄底下所有目錄與檔案清單.
1961
#取得用戶端的資訊,並依據需要寫入到資料表裡面
2035
#回傳結果:
1962
#回傳的結果:
2036
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1963
#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
2037
#$result["error"],錯誤訊息陣列.
1964
#$result["error"],錯誤訊息.
2038
#$result["function"],函數名稱.
1965
#$result["function"],檔前執行的函數名稱.
2039
#$result["content"],陣列,目錄底下的檔案與子目錄.
1966
#$result["mode"],當前的模式是"cmd"還是"web".
-
 
1967
#$result["userBrowserType"],爲使用者的瀏覽器資訊
-
 
1968
#$result["userIp"],爲使用者的IP
-
 
1969
#$result["serverIp"],為伺服器的IP
-
 
1970
#$result["server_name"],伺服器的 domain name
-
 
1971
#$result["scheme"],通訊協定
2040
#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
1972
#$result["serverPort"],伺服器給對外下載網頁的port
2041
#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
1973
#$result["requestUri"],爲使用者要求的網址/php檔案.
-
 
1974
#$result["requestUriFull"],為使用者要求的完整網址/php檔案路徑.
-
 
1975
#$result["clientRequestIP"],用戶端要求的ip與port
-
 
1976
#$result["username"],爲使用者目前的帳戶,若爲""則表示尚未登入成功
2042
#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
1977
#$result["phpUser"],運行該php的使用者帳戶.若為空字串則代表非使用者直接觸發.
-
 
1978
#$result["phpUserType"],運行該php的使用者帳戶類型,可能有"regular(no wheel member)","wheel(can use sudo)","intrinsic(root)","system(qemu,apache,...)".
-
 
1979
#$result["header"],接收到的 header 陣列.
2043
#$result["position"],目前的位置.
1980
#$result["body"],接收到的 body 字串.
2044
#必填參數:
1981
#必填參數:
2045
#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
1982
#$conf["getAccount"],字串,是否要取得帳號,"true"代表要;"false"代表不要.
-
 
1983
$conf["getAccount"]="true";
-
 
1984
#可省略參數:
-
 
1985
#$conf["accountVar"],字串,帳號儲存在哪個變數裏面,預設爲$_SESSION["username"].
2046
$conf["position"]=$libOfRootPath."usr/lib/systemd/system";
1986
#$conf["accountVar"]=$_SESSION["username"];
2047
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1987
#$conf["saveToDb"],字串,是否要除儲存到資料庫,"true"為要儲存",預設為"false"不儲存.
2048
$conf["fileArgu"]=__FILE__;
1988
#$conf["saveToDb"]="true";
-
 
1989
#$conf["dbAddress"],字串,爲mysql/mariadb server的位置,若saveToDb設為"true",則該參數為必填.
-
 
1990
#$conf["dbAddress"]=$dbAddress;
-
 
1991
#$conf["dbAccount"],字串,爲用於連入mysql/mariadb server時要使用的帳號,若saveToDb設為"true",則該參數為必填.
-
 
1992
#$conf["dbAccount"]=$dbAccount;
-
 
1993
#$conf["dbName"],字串,要選取的資料庫名稱,若saveToDb設為"true",則該參數為必填.
2049
#可省略參數:
1994
#$conf["dbName"]=$dbName;
-
 
1995
#$conf["tableName"],字串,爲要插入資料的資料表名稱,若saveToDb設為"true",則該參數為必填.
-
 
1996
#$conf["tableName"]="visitorInfo";
2050
#無
1997
#$conf["columnName"],字串陣列,爲資料表的項目名稱,例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);寫入的資料依序為,使用者帳戶、瀏覽器資訊、使用者IP、觀看的網址、當時的時間.若saveToDb設為"true",則該參數為必填.
-
 
1998
#$conf["columnName"]=array("username","userWebBrowser","userIp","requestUri","systemDateAndTime");
-
 
1999
#$conf["dbPassword"],字串,爲連線到mysql/mariadb server時要使用的密碼,可省略,若省略則代表不使用密碼.
-
 
2000
#$conf["dbPassword"]=$dbPassword;
2051
#參考資料:
2001
#參考資料:
2052
#opendir=>http://php.net/manual/en/function.opendir.php
2002
#$_SERVER=>http://php.net/manual/zh/reserved.variables.server.php
2053
#is_dir=>http://php.net/manual/en/function.is-dir.php
2003
#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
2054
#備註:
2004
#備註:
2055
#無.
2005
#無.
2056
$getList=fileAccess::getList($conf);
2006
$getConnectionInfo=cmd::getConnectionInfo($conf);
2057
unset($conf);
2007
unset($conf);
2058
 
2008
 
2059
#如果執行失敗
2009
#如果執行失敗
2060
if($getList["status"]==="false"){
2010
if($getConnectionInfo["status"]==="false"){
2061
 
2011
 
2062
	#函式說明:
2012
	#函式說明:
2063
	#撰寫log
2013
	#撰寫log
2064
	#回傳結果:
2014
	#回傳結果:
2065
	#$result["status"],狀態,"true"或"false".
2015
	#$result["status"],狀態,"true"或"false".
Line 2068... Line 2018...
2068
	#$result["argu"],使用的參數.
2018
	#$result["argu"],使用的參數.
2069
	#必填參數:
2019
	#必填參數:
2070
	#$conf["path"],字串,log檔案的路徑與名稱.
2020
	#$conf["path"],字串,log檔案的路徑與名稱.
2071
	$conf["path"]=$logFile;
2021
	$conf["path"]=$logFile;
2072
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2022
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2073
	$conf["content"]=$getList;
2023
	$conf["content"]=$getConnectionInfo;
2074
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2024
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2075
	$conf["fileArgu"]=__FILE__;
2025
	$conf["fileArgu"]=__FILE__;
2076
	#可省略參數:
2026
	#可省略參數:
2077
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2027
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2078
	#$conf["rewrite"]="false";
2028
	#$conf["rewrite"]="false";
Line 2092... Line 2042...
2092
		
2042
		
2093
	#異常結束執行
2043
	#異常結束執行
2094
	exit(1);
2044
	exit(1);
2095
 
2045
 
2096
	}#if end
2046
	}#if end
2097
	
-
 
2098
#針對每個服務
-
 
2099
foreach($getList["content"] as $fileInfo){
-
 
2100
 
2047
 
2101
	#取得服務的名稱
2048
#如果不是沒有權限的一般使用者
2102
	$serviceName=$fileInfo["name"];
2049
if($getConnectionInfo["phpUserType"]!=="regular"){
2103
 
2050
 
-
 
2051
	#systemctl daemon-reload
2104
	#函式說明:
2052
	#函式說明:
2105
	#執行 systemd 程序來管理服務.
2053
	#執行 systemd 程序來管理服務.
2106
	#回傳結果:
2054
	#回傳結果:
2107
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2055
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2108
	#$result["error"],錯誤訊息.
2056
	#$result["error"],錯誤訊息.
Line 2113... Line 2061...
2113
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
2061
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
2114
	#必填參數:
2062
	#必填參數:
2115
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2063
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2116
	$conf["fileArgu"]=__FILE__;
2064
	$conf["fileArgu"]=__FILE__;
2117
	#$conf["name"],字串,服務名稱.
2065
	#$conf["name"],字串,服務名稱.
2118
	$conf["name"]=$serviceName;
2066
	$conf["name"]="daemon-reload";
2119
	#可省略參數:
2067
	#可省略參數:
2120
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
2068
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
2121
	$conf["operation"]="enable";
2069
	#$conf["operation"]="";
2122
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
2070
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
2123
	#$conf["username"]="";
2071
	#$conf["username"]="";
2124
	#$conf["password"],字串,使用者的密碼,預設不使用.
2072
	#$conf["password"],字串,使用者的密碼,預設不使用.
2125
	#$conf["password"]="";
2073
	#$conf["password"]="";
2126
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
2074
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
2127
	#$conf["daemonReload"]="true";
2075
	$conf["daemonReload"]="true";
2128
	#參考資料:
2076
	#參考資料:
2129
	#無.
2077
	#無.
2130
	#備註:
2078
	#備註:
2131
	#無.
2079
	#無.
2132
	$systemd=cmd::systemd($conf);
2080
	$systemd=cmd::systemd($conf);
Line 2168... Line 2116...
2168
			
2116
			
2169
		#異常結束執行
2117
		#異常結束執行
2170
		exit(1);
2118
		exit(1);
2171
 
2119
 
2172
		}#if end
2120
		}#if end
-
 
2121
 
-
 
2122
	#enable and restart 於 $libOfRootPath.$name."/usr/lib/systemd/system" 底下的所有服務
2173
		
2123
 
2174
	#函式說明:
2124
	#函式說明:
2175
	#執行 systemd 程序來管理服務.
2125
	#取得目錄底下所有目錄與檔案清單.
2176
	#回傳結果:
2126
	#回傳結果:
2177
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2127
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
2178
	#$result["error"],錯誤訊息.
2128
	#$result["error"],錯誤訊息陣列.
2179
	#$result["function"],當前執行的函式名稱.
2129
	#$result["function"],函數名稱.
2180
	#$result["argu"],所使用的參數.
2130
	#$result["content"],陣列,目錄底下的檔案與子目錄.
2181
	#$result["content"],執行的結果.
2131
	#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
2182
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
2132
	#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
2183
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
2133
	#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
-
 
2134
	#$result["position"],目前的位置.
2184
	#必填參數:
2135
	#必填參數:
-
 
2136
	#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
-
 
2137
	$conf["position"]=$libOfRootPath."usr/lib/systemd/system";
2185
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2138
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2186
	$conf["fileArgu"]=__FILE__;
2139
	$conf["fileArgu"]=__FILE__;
2187
	#$conf["name"],字串,服務名稱.
-
 
2188
	$conf["name"]=$serviceName;
-
 
2189
	#可省略參數:
2140
	#可省略參數:
2190
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
-
 
2191
	$conf["operation"]="restart";
-
 
2192
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
-
 
2193
	#$conf["username"]="";
-
 
2194
	#$conf["password"],字串,使用者的密碼,預設不使用.
-
 
2195
	#$conf["password"]="";
2141
	#無
2196
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
-
 
2197
	#$conf["daemonReload"]="true";
-
 
2198
	#參考資料:
2142
	#參考資料:
-
 
2143
	#opendir=>http://php.net/manual/en/function.opendir.php
2199
	#無.
2144
	#is_dir=>http://php.net/manual/en/function.is-dir.php
2200
	#備註:
2145
	#備註:
2201
	#無.
2146
	#無.
2202
	$systemd=cmd::systemd($conf);
2147
	$getList=fileAccess::getList($conf);
2203
	unset($conf);
2148
	unset($conf);
2204
 
2149
 
2205
	#如果執行失敗
2150
	#如果執行失敗
2206
	if($systemd["status"]==="false"){
2151
	if($getList["status"]==="false"){
2207
 
2152
 
2208
		#函式說明:
2153
		#函式說明:
2209
		#撰寫log
2154
		#撰寫log
2210
		#回傳結果:
2155
		#回傳結果:
2211
		#$result["status"],狀態,"true"或"false".
2156
		#$result["status"],狀態,"true"或"false".
Line 2214... Line 2159...
2214
		#$result["argu"],使用的參數.
2159
		#$result["argu"],使用的參數.
2215
		#必填參數:
2160
		#必填參數:
2216
		#$conf["path"],字串,log檔案的路徑與名稱.
2161
		#$conf["path"],字串,log檔案的路徑與名稱.
2217
		$conf["path"]=$logFile;
2162
		$conf["path"]=$logFile;
2218
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2163
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2219
		$conf["content"]=$systemd;
2164
		$conf["content"]=$getList;
2220
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2165
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2221
		$conf["fileArgu"]=__FILE__;
2166
		$conf["fileArgu"]=__FILE__;
2222
		#可省略參數:
2167
		#可省略參數:
2223
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2168
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2224
		#$conf["rewrite"]="false";
2169
		#$conf["rewrite"]="false";
Line 2238... Line 2183...
2238
			
2183
			
2239
		#異常結束執行
2184
		#異常結束執行
2240
		exit(1);
2185
		exit(1);
2241
 
2186
 
2242
		}#if end
2187
		}#if end
-
 
2188
		
-
 
2189
	#針對每個服務
-
 
2190
	foreach($getList["content"] as $fileInfo){
-
 
2191
 
-
 
2192
		#取得服務的名稱
-
 
2193
		$serviceName=$fileInfo["name"];
-
 
2194
 
-
 
2195
		#函式說明:
-
 
2196
		#執行 systemd 程序來管理服務.
-
 
2197
		#回傳結果:
-
 
2198
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2199
		#$result["error"],錯誤訊息.
-
 
2200
		#$result["function"],當前執行的函式名稱.
-
 
2201
		#$result["argu"],所使用的參數.
-
 
2202
		#$result["content"],執行的結果.
-
 
2203
		#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
-
 
2204
		#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
-
 
2205
		#必填參數:
-
 
2206
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2207
		$conf["fileArgu"]=__FILE__;
-
 
2208
		#$conf["name"],字串,服務名稱.
-
 
2209
		$conf["name"]=$serviceName;
-
 
2210
		#可省略參數:
-
 
2211
		#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
-
 
2212
		$conf["operation"]="enable";
-
 
2213
		#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
-
 
2214
		#$conf["username"]="";
-
 
2215
		#$conf["password"],字串,使用者的密碼,預設不使用.
-
 
2216
		#$conf["password"]="";
-
 
2217
		#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
-
 
2218
		#$conf["daemonReload"]="true";
-
 
2219
		#參考資料:
-
 
2220
		#無.
-
 
2221
		#備註:
-
 
2222
		#無.
-
 
2223
		$systemd=cmd::systemd($conf);
-
 
2224
		unset($conf);
-
 
2225
 
-
 
2226
		#如果執行失敗
-
 
2227
		if($systemd["status"]==="false"){
-
 
2228
 
-
 
2229
			#函式說明:
-
 
2230
			#撰寫log
-
 
2231
			#回傳結果:
-
 
2232
			#$result["status"],狀態,"true"或"false".
-
 
2233
			#$result["error"],錯誤訊息陣列.
-
 
2234
			#$result["function"],當前函式的名稱.
-
 
2235
			#$result["argu"],使用的參數.
-
 
2236
			#必填參數:
-
 
2237
			#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2238
			$conf["path"]=$logFile;
-
 
2239
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2240
			$conf["content"]=$systemd;
-
 
2241
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2242
			$conf["fileArgu"]=__FILE__;
-
 
2243
			#可省略參數:
-
 
2244
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2245
			#$conf["rewrite"]="false";
-
 
2246
			#參考資料:
-
 
2247
			#無.
-
 
2248
			#備註:
-
 
2249
			#無.
-
 
2250
			$record=logs::record($conf);
-
 
2251
			
-
 
2252
			#如果執行失敗
-
 
2253
			if($record["status"]==="false"){
-
 
2254
			
-
 
2255
				#印出結果
-
 
2256
				var_dump($record);
-
 
2257
			
-
 
2258
				}#if end
-
 
2259
				
-
 
2260
			#異常結束執行
-
 
2261
			exit(1);
-
 
2262
 
-
 
2263
			}#if end
-
 
2264
			
-
 
2265
		#函式說明:
-
 
2266
		#執行 systemd 程序來管理服務.
-
 
2267
		#回傳結果:
-
 
2268
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2269
		#$result["error"],錯誤訊息.
-
 
2270
		#$result["function"],當前執行的函式名稱.
-
 
2271
		#$result["argu"],所使用的參數.
-
 
2272
		#$result["content"],執行的結果.
-
 
2273
		#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
-
 
2274
		#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
-
 
2275
		#必填參數:
-
 
2276
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2277
		$conf["fileArgu"]=__FILE__;
-
 
2278
		#$conf["name"],字串,服務名稱.
-
 
2279
		$conf["name"]=$serviceName;
-
 
2280
		#可省略參數:
-
 
2281
		#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
-
 
2282
		$conf["operation"]="restart";
-
 
2283
		#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
-
 
2284
		#$conf["username"]="";
-
 
2285
		#$conf["password"],字串,使用者的密碼,預設不使用.
-
 
2286
		#$conf["password"]="";
-
 
2287
		#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
-
 
2288
		#$conf["daemonReload"]="true";
-
 
2289
		#參考資料:
-
 
2290
		#無.
-
 
2291
		#備註:
-
 
2292
		#無.
-
 
2293
		$systemd=cmd::systemd($conf);
-
 
2294
		unset($conf);
-
 
2295
 
-
 
2296
		#如果執行失敗
-
 
2297
		if($systemd["status"]==="false"){
-
 
2298
 
-
 
2299
			#函式說明:
-
 
2300
			#撰寫log
-
 
2301
			#回傳結果:
-
 
2302
			#$result["status"],狀態,"true"或"false".
-
 
2303
			#$result["error"],錯誤訊息陣列.
-
 
2304
			#$result["function"],當前函式的名稱.
-
 
2305
			#$result["argu"],使用的參數.
-
 
2306
			#必填參數:
-
 
2307
			#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2308
			$conf["path"]=$logFile;
-
 
2309
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2310
			$conf["content"]=$systemd;
-
 
2311
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2312
			$conf["fileArgu"]=__FILE__;
-
 
2313
			#可省略參數:
-
 
2314
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2315
			#$conf["rewrite"]="false";
-
 
2316
			#參考資料:
-
 
2317
			#無.
-
 
2318
			#備註:
-
 
2319
			#無.
-
 
2320
			$record=logs::record($conf);
-
 
2321
			
-
 
2322
			#如果執行失敗
-
 
2323
			if($record["status"]==="false"){
-
 
2324
			
-
 
2325
				#印出結果
-
 
2326
				var_dump($record);
-
 
2327
			
-
 
2328
				}#if end
-
 
2329
				
-
 
2330
			#異常結束執行
-
 
2331
			exit(1);
2243
 
2332
 
-
 
2333
			}#if end
-
 
2334
 
2244
	}#foreach end
2335
		}#foreach end
-
 
2336
 
-
 
2337
	}#if end
2245
 
2338
 
2246
?>
2339
?>
2247
2340