Subversion Repositories php-qbpwcf

Rev

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

Rev 220 Rev 226
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
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~2025 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
12
    the Free Software Foundation, either version 3 of the License, or
12
    the Free Software Foundation, either version 3 ciof the License, or
13
    (at your option) any later version.
13
    (at your option) any later version.
14
 
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Line 1518... Line 1518...
1518
	#回傳的結果:
1518
	#回傳的結果:
1519
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1519
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1520
	#$result["error"],錯誤訊息.
1520
	#$result["error"],錯誤訊息.
1521
	#$result["function"],當前執行的函式名稱.
1521
	#$result["function"],當前執行的函式名稱.
1522
	#$result["storePlace"],檔案輸出後的位置與名稱.
1522
	#$result["storePlace"],檔案輸出後的位置與名稱.
1523
	#必填參數:	
1523
	#必填參數:
1524
	#$conf["target"],字串,要打包的檔案.
1524
	#$conf["target"],字串,要打包的檔案.
1525
	$conf["target"]="";
1525
	$conf["target"]="";
1526
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
1526
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
1527
	$conf["fileArgu"]=__FILE__;
1527
	$conf["fileArgu"]=__FILE__;
1528
	#可省略參數:
1528
	#可省略參數:
Line 1540... Line 1540...
1540
	#無.
1540
	#無.
1541
	#備註:
1541
	#備註:
1542
	#無.
1542
	#無.
1543
	*/
1543
	*/
1544
	public static function makeZstFile(&$conf){
1544
	public static function makeZstFile(&$conf){
1545
	
1545
 
1546
		#初始化要回傳的內容
1546
		#初始化要回傳的內容
1547
		$result=array();
1547
		$result=array();
1548
 
1548
 
1549
		#取得當前函式的名稱
1549
		#取得當前函式的名稱
1550
		$result["function"]=__FUNCTION__;
1550
		$result["function"]=__FUNCTION__;
Line 1658... Line 1658...
1658
				echo PHP_EOL;
1658
				echo PHP_EOL;
1659
 
1659
 
1660
				}#if end
1660
				}#if end
1661
 
1661
 
1662
			}#foreach end
1662
			}#foreach end
1663
		
1663
 
1664
		#初始化儲存要壓縮的檔案名稱與位置
1664
		#初始化儲存要壓縮的檔案名稱與位置
1665
		$inputFile=$conf["target"];
1665
		$inputFile=$conf["target"];
1666
 
1666
 
1667
		#初始化原始要產生的壓縮檔案位置名稱
1667
		#初始化原始要產生的壓縮檔案位置名稱
1668
		$result["storePlace"]=$conf["target"].".zst";
1668
		$result["storePlace"]=$conf["target"].".zst";
1669
 
1669
 
1670
		#如果path不為"/"結束
1670
		#如果path不為"/"結束
1671
		if($conf["path"][strlen($conf["path"])-1]!=="/"){
1671
		if($conf["path"][strlen($conf["path"])-1]!=="/"){
1672
		
1672
 
1673
			#串接 "/" 到結尾
1673
			#串接 "/" 到結尾
1674
			$conf["path"]=$conf["path"]."/";
1674
			$conf["path"]=$conf["path"]."/";
1675
		
1675
 
1676
			}#if end
1676
			}#if end
1677
	
1677
 
1678
		#設置產生的檔案位置與名稱
1678
		#設置產生的檔案位置與名稱
1679
		$result["storePlace"]=$conf["path"].$result["storePlace"];
1679
		$result["storePlace"]=$conf["path"].$result["storePlace"];
1680
		
1680
 
1681
		#設置原始的檔案位置與名稱
1681
		#設置原始的檔案位置與名稱
1682
		$inputFile=$conf["path"].$inputFile;
1682
		$inputFile=$conf["path"].$inputFile;
1683
		
1683
 
1684
		#確認檔案有存在
1684
		#確認檔案有存在
1685
		#函式說明:
1685
		#函式說明:
1686
		#檢查多個檔案與資料夾是否存在.
1686
		#檢查多個檔案與資料夾是否存在.
1687
		#回傳的結果:
1687
		#回傳的結果:
1688
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1688
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 1712... Line 1712...
1712
		#備註:
1712
		#備註:
1713
		#函數file_exists檢查的路徑為檔案系統的路徑
1713
		#函數file_exists檢查的路徑為檔案系統的路徑
1714
		#$result["varName"][$i]結果未實作
1714
		#$result["varName"][$i]結果未實作
1715
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
1715
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
1716
		unset($conf["fileAccess::checkMultiFileExist"]);
1716
		unset($conf["fileAccess::checkMultiFileExist"]);
1717
	
1717
 
1718
		#如果失敗
1718
		#如果失敗
1719
		if($checkMultiFileExist["status"]==="false"){
1719
		if($checkMultiFileExist["status"]==="false"){
1720
		
1720
 
1721
			#設置執行錯誤識別
1721
			#設置執行錯誤識別
1722
			$result["status"]="false";
1722
			$result["status"]="false";
1723
 
1723
 
1724
			#取得錯誤訊息
1724
			#取得錯誤訊息
1725
			$result["error"]=$checkMultiFileExist;
1725
			$result["error"]=$checkMultiFileExist;
1726
 
1726
 
1727
			#回傳結果
1727
			#回傳結果
1728
			return $result;
1728
			return $result;
1729
		
1729
 
1730
			}#if end
1730
			}#if end
1731
			
1731
 
1732
		#如果壓縮檔已經存在
1732
		#如果壓縮檔已經存在
1733
		if($checkMultiFileExist["allExist"]==="true"){
1733
		if($checkMultiFileExist["allExist"]==="true"){
1734
		
1734
 
1735
			#如果不要覆蓋既有的檔案
1735
			#如果不要覆蓋既有的檔案
1736
			if($conf["overwrite"]==="false"){
1736
			if($conf["overwrite"]==="false"){
1737
			
1737
 
1738
				#設置執行錯誤識別
1738
				#設置執行錯誤識別
1739
				$result["status"]="false";
1739
				$result["status"]="false";
1740
 
1740
 
1741
				#取得錯誤訊息
1741
				#取得錯誤訊息
1742
				$result["error"][]="zst壓縮檔已經存在";
1742
				$result["error"][]="zst壓縮檔已經存在";
1743
 
1743
 
1744
				#回傳結果
1744
				#回傳結果
1745
				return $result;
1745
				return $result;
1746
			
1746
 
1747
				}#if end
1747
				}#if end
1748
		
1748
 
1749
			#反之
1749
			#反之
1750
			else{
1750
			else{
1751
			
1751
 
1752
				#移除已經存在的zst壓縮檔
1752
				#移除已經存在的zst壓縮檔
1753
				#函式說明:
1753
				#函式說明:
1754
				#移除檔案
1754
				#移除檔案
1755
				#回傳結果:
1755
				#回傳結果:
1756
				#$result["status"],"true"代表移除成功,"false"代表移除失敗.
1756
				#$result["status"],"true"代表移除成功,"false"代表移除失敗.
Line 1774... Line 1774...
1774
				#無.
1774
				#無.
1775
				#備註:
1775
				#備註:
1776
				#無.
1776
				#無.
1777
				$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
1777
				$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
1778
				unset($conf["fileAccess::delFile"]);
1778
				unset($conf["fileAccess::delFile"]);
1779
			
1779
 
1780
				#如果執行失敗
1780
				#如果執行失敗
1781
				if($delFile["status"]==="false"){
1781
				if($delFile["status"]==="false"){
1782
				
1782
 
1783
					#設置執行錯誤識別
1783
					#設置執行錯誤識別
1784
					$result["status"]="false";
1784
					$result["status"]="false";
1785
 
1785
 
1786
					#取得錯誤訊息
1786
					#取得錯誤訊息
1787
					$result["error"]=$delFile;
1787
					$result["error"]=$delFile;
1788
 
1788
 
1789
					#回傳結果
1789
					#回傳結果
1790
					return $result;
1790
					return $result;
1791
				
1791
 
1792
					}#if end
1792
					}#if end
1793
			
1793
 
1794
				}#else end
1794
				}#else end
1795
		
1795
 
1796
			}#if end
1796
			}#if end
1797
		
1797
 
1798
		#函式說明:
1798
		#函式說明:
1799
		#呼叫shell執行系統命令,並取得回傳的內容.
1799
		#呼叫shell執行系統命令,並取得回傳的內容.
1800
		#回傳結果:
1800
		#回傳結果:
1801
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1801
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1802
		#$result["error"],錯誤訊息陣列.
1802
		#$result["error"],錯誤訊息陣列.
Line 1848... Line 1848...
1848
		#exec=>http://php.net/manual/en/function.exec.php
1848
		#exec=>http://php.net/manual/en/function.exec.php
1849
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
1849
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
1850
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
1850
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
1851
		$callShell=external::callShell($conf["external::callShell"]);
1851
		$callShell=external::callShell($conf["external::callShell"]);
1852
		unset($conf["external::callShell"]);
1852
		unset($conf["external::callShell"]);
1853
	
1853
 
1854
		#如果執行外部程式失敗
1854
		#如果執行外部程式失敗
1855
		if($callShell["status"]==="false"){
1855
		if($callShell["status"]==="false"){
1856
 
1856
 
1857
			#設置執行錯誤識別
1857
			#設置執行錯誤識別
1858
			$result["status"]="false";
1858
			$result["status"]="false";
Line 1862... Line 1862...
1862
 
1862
 
1863
			#回傳結果
1863
			#回傳結果
1864
			return $result;
1864
			return $result;
1865
 
1865
 
1866
			}#if end
1866
			}#if end
1867
			
1867
 
1868
		#確認檔案有存在
1868
		#確認檔案有存在
1869
		#函式說明:
1869
		#函式說明:
1870
		#檢查多個檔案與資料夾是否存在.
1870
		#檢查多個檔案與資料夾是否存在.
1871
		#回傳的結果:
1871
		#回傳的結果:
1872
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1872
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 1896... Line 1896...
1896
		#備註:
1896
		#備註:
1897
		#函數file_exists檢查的路徑為檔案系統的路徑
1897
		#函數file_exists檢查的路徑為檔案系統的路徑
1898
		#$result["varName"][$i]結果未實作
1898
		#$result["varName"][$i]結果未實作
1899
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
1899
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
1900
		unset($conf["fileAccess::checkMultiFileExist"]);
1900
		unset($conf["fileAccess::checkMultiFileExist"]);
1901
	
1901
 
1902
		#如果失敗
1902
		#如果失敗
1903
		if($checkMultiFileExist["status"]==="false"){
1903
		if($checkMultiFileExist["status"]==="false"){
1904
		
1904
 
1905
			#設置執行錯誤識別
1905
			#設置執行錯誤識別
1906
			$result["status"]="false";
1906
			$result["status"]="false";
1907
 
1907
 
1908
			#取得錯誤訊息
1908
			#取得錯誤訊息
1909
			$result["error"]=$checkMultiFileExist;
1909
			$result["error"]=$checkMultiFileExist;
1910
 
1910
 
1911
			#回傳結果
1911
			#回傳結果
1912
			return $result;
1912
			return $result;
1913
		
1913
 
1914
			}#if end
1914
			}#if end
1915
			
1915
 
1916
		#如果壓縮檔產生失敗
1916
		#如果壓縮檔產生失敗
1917
		if($checkMultiFileExist["allExist"]==="false"){
1917
		if($checkMultiFileExist["allExist"]==="false"){
1918
		
1918
 
1919
			#設置執行錯誤識別
1919
			#設置執行錯誤識別
1920
			$result["status"]="false";
1920
			$result["status"]="false";
1921
 
1921
 
1922
			#取得錯誤訊息
1922
			#取得錯誤訊息
1923
			$result["error"]=$checkMultiFileExist;
1923
			$result["error"]=$checkMultiFileExist;
1924
 
1924
 
1925
			#回傳結果
1925
			#回傳結果
1926
			return $result;
1926
			return $result;
1927
		
1927
 
1928
			}#if end
1928
			}#if end
1929
			
1929
 
1930
		#如果要移除原始檔案
1930
		#如果要移除原始檔案
1931
		if($conf["delAfterSuc"]==="true"){
1931
		if($conf["delAfterSuc"]==="true"){
1932
		
1932
 
1933
			#函式說明:
1933
			#函式說明:
1934
			#移除檔案
1934
			#移除檔案
1935
			#回傳結果:
1935
			#回傳結果:
1936
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
1936
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
1937
			#$result["error"],錯誤訊息陣列
1937
			#$result["error"],錯誤訊息陣列
Line 1947... Line 1947...
1947
			#$conf["commentsArray"]=array("");
1947
			#$conf["commentsArray"]=array("");
1948
			#備註:
1948
			#備註:
1949
			#無.
1949
			#無.
1950
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
1950
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
1951
			unset($conf["fileAccess::delFile"]);
1951
			unset($conf["fileAccess::delFile"]);
1952
		
1952
 
1953
			#如果失敗
1953
			#如果失敗
1954
			if($delFile["status"]==="false"){
1954
			if($delFile["status"]==="false"){
1955
			
1955
 
1956
				#設置執行錯誤識別
1956
				#設置執行錯誤識別
1957
				$result["status"]="false";
1957
				$result["status"]="false";
1958
 
1958
 
1959
				#取得錯誤訊息
1959
				#取得錯誤訊息
1960
				$result["error"]=$delFile;
1960
				$result["error"]=$delFile;
1961
 
1961
 
1962
				#回傳結果
1962
				#回傳結果
1963
				return $result;
1963
				return $result;
1964
			
1964
 
1965
				}#if end
1965
				}#if end
1966
 
1966
 
1967
			}#if end
1967
			}#if end
1968
			
1968
 
1969
		#設置執行正常
1969
		#設置執行正常
1970
		$result["status"]="true";
1970
		$result["status"]="true";
1971
		
1971
 
1972
		#回傳結果
1972
		#回傳結果
1973
		return $result;
1973
		return $result;
1974
	
1974
 
1975
		}#function makeZstFile end
1975
		}#function makeZstFile end
1976
 
1976
 
1977
	/*
1977
	/*
1978
	#函式說明:
1978
	#函式說明:
1979
	#將資料夾打包成.tar檔案
1979
	#將資料夾打包成.tar檔案
Line 2002... Line 2002...
2002
	#無.
2002
	#無.
2003
	#備註:
2003
	#備註:
2004
	#無.
2004
	#無.
2005
	*/
2005
	*/
2006
	public static function makeTarFile(&$conf){
2006
	public static function makeTarFile(&$conf){
2007
	
2007
 
2008
		#初始化要回傳的內容
2008
		#初始化要回傳的內容
2009
		$result=array();
2009
		$result=array();
2010
 
2010
 
2011
		#取得當前函式的名稱
2011
		#取得當前函式的名稱
2012
		$result["function"]=__FUNCTION__;
2012
		$result["function"]=__FUNCTION__;
Line 2107... Line 2107...
2107
 
2107
 
2108
			}#if end
2108
			}#if end
2109
 
2109
 
2110
		#如果需要輸出提示
2110
		#如果需要輸出提示
2111
		if(isset($conf["commentsArray"])){
2111
		if(isset($conf["commentsArray"])){
2112
		
2112
 
2113
			#針對$commensArray的每個元素
2113
			#針對$commensArray的每個元素
2114
			foreach($conf["commentsArray"] as $comment){
2114
			foreach($conf["commentsArray"] as $comment){
2115
 
2115
 
2116
				#印出描述
2116
				#印出描述
2117
				echo $comment;
2117
				echo $comment;
Line 2123... Line 2123...
2123
					echo PHP_EOL;
2123
					echo PHP_EOL;
2124
 
2124
 
2125
					}#if end
2125
					}#if end
2126
 
2126
 
2127
				}#foreach end
2127
				}#foreach end
2128
		
2128
 
2129
			}#if end
2129
			}#if end
2130
		
2130
 
2131
		#初始化儲存要壓縮的檔案名稱與位置
2131
		#初始化儲存要壓縮的檔案名稱與位置
2132
		$inputFile=$conf["target"];
2132
		$inputFile=$conf["target"];
2133
 
2133
 
2134
		#初始化原始要產生的壓縮檔案位置名稱
2134
		#初始化原始要產生的壓縮檔案位置名稱
2135
		$result["storePlace"]=$conf["target"].".tar";
2135
		$result["storePlace"]=$conf["target"].".tar";
2136
 
2136
 
2137
		#如果路徑不是 "./" 也不是 "../"
2137
		#如果路徑不是 "./" 也不是 "../"
2138
		if($conf["path"]!=="./" && $conf["path"]!=="../"){
2138
		if($conf["path"]!=="./" && $conf["path"]!=="../"){
2139
		
2139
 
2140
			#檔案位置與名稱前面加上"/"
2140
			#檔案位置與名稱前面加上"/"
2141
			$result["storePlace"]="/".$result["storePlace"];
2141
			$result["storePlace"]="/".$result["storePlace"];
2142
		
2142
 
2143
			#檔案位置與名稱前面加上"/"
2143
			#檔案位置與名稱前面加上"/"
2144
			$inputFile="/".$inputFile;
2144
			$inputFile="/".$inputFile;
2145
		
2145
 
2146
			}#if end
2146
			}#if end
2147
 
2147
 
2148
		#設置產生的檔案位置與名稱
2148
		#設置產生的檔案位置與名稱
2149
		$result["storePlace"]=$conf["path"].$result["storePlace"];
2149
		$result["storePlace"]=$conf["path"].$result["storePlace"];
2150
		
2150
 
2151
		#設置原始的檔案位置與名稱
2151
		#設置原始的檔案位置與名稱
2152
		$inputFile=$conf["path"].$inputFile;
2152
		$inputFile=$conf["path"].$inputFile;
2153
		
2153
 
2154
		#確認檔案有存在
2154
		#確認檔案有存在
2155
		#函式說明:
2155
		#函式說明:
2156
		#檢查多個檔案與資料夾是否存在.
2156
		#檢查多個檔案與資料夾是否存在.
2157
		#回傳的結果:
2157
		#回傳的結果:
2158
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
2158
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 2182... Line 2182...
2182
		#備註:
2182
		#備註:
2183
		#函數file_exists檢查的路徑為檔案系統的路徑
2183
		#函數file_exists檢查的路徑為檔案系統的路徑
2184
		#$result["varName"][$i]結果未實作
2184
		#$result["varName"][$i]結果未實作
2185
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
2185
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
2186
		unset($conf["fileAccess::checkMultiFileExist"]);
2186
		unset($conf["fileAccess::checkMultiFileExist"]);
2187
	
2187
 
2188
		#如果失敗
2188
		#如果失敗
2189
		if($checkMultiFileExist["status"]==="false"){
2189
		if($checkMultiFileExist["status"]==="false"){
2190
		
2190
 
2191
			#設置執行錯誤識別
2191
			#設置執行錯誤識別
2192
			$result["status"]="false";
2192
			$result["status"]="false";
2193
 
2193
 
2194
			#取得錯誤訊息
2194
			#取得錯誤訊息
2195
			$result["error"]=$checkMultiFileExist;
2195
			$result["error"]=$checkMultiFileExist;
2196
 
2196
 
2197
			#回傳結果
2197
			#回傳結果
2198
			return $result;
2198
			return $result;
2199
		
2199
 
2200
			}#if end
2200
			}#if end
2201
			
2201
 
2202
		#如果壓縮檔已經存在
2202
		#如果壓縮檔已經存在
2203
		if($checkMultiFileExist["allExist"]==="true"){
2203
		if($checkMultiFileExist["allExist"]==="true"){
2204
		
2204
 
2205
			#如果不要覆蓋既有的檔案
2205
			#如果不要覆蓋既有的檔案
2206
			if($conf["overwrite"]==="false"){
2206
			if($conf["overwrite"]==="false"){
2207
			
2207
 
2208
				#設置執行錯誤識別
2208
				#設置執行錯誤識別
2209
				$result["status"]="false";
2209
				$result["status"]="false";
2210
 
2210
 
2211
				#取得錯誤訊息
2211
				#取得錯誤訊息
2212
				$result["error"][]="tar檔已經存在";
2212
				$result["error"][]="tar檔已經存在";
2213
 
2213
 
2214
				#回傳結果
2214
				#回傳結果
2215
				return $result;
2215
				return $result;
2216
			
2216
 
2217
				}#if end
2217
				}#if end
2218
		
2218
 
2219
			#反之
2219
			#反之
2220
			else{
2220
			else{
2221
			
2221
 
2222
				#移除已經存在的zst壓縮檔
2222
				#移除已經存在的zst壓縮檔
2223
				#函式說明:
2223
				#函式說明:
2224
				#移除檔案
2224
				#移除檔案
2225
				#回傳結果:
2225
				#回傳結果:
2226
				#$result["status"],"true"代表移除成功,"false"代表移除失敗.
2226
				#$result["status"],"true"代表移除成功,"false"代表移除失敗.
Line 2244... Line 2244...
2244
				#無.
2244
				#無.
2245
				#備註:
2245
				#備註:
2246
				#無.
2246
				#無.
2247
				$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
2247
				$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
2248
				unset($conf["fileAccess::delFile"]);
2248
				unset($conf["fileAccess::delFile"]);
2249
			
2249
 
2250
				#如果執行失敗
2250
				#如果執行失敗
2251
				if($delFile["status"]==="false"){
2251
				if($delFile["status"]==="false"){
2252
				
2252
 
2253
					#設置執行錯誤識別
2253
					#設置執行錯誤識別
2254
					$result["status"]="false";
2254
					$result["status"]="false";
2255
 
2255
 
2256
					#取得錯誤訊息
2256
					#取得錯誤訊息
2257
					$result["error"]=$delFile;
2257
					$result["error"]=$delFile;
2258
 
2258
 
2259
					#回傳結果
2259
					#回傳結果
2260
					return $result;
2260
					return $result;
2261
				
2261
 
2262
					}#if end
2262
					}#if end
2263
			
2263
 
2264
				}#else end
2264
				}#else end
2265
		
2265
 
2266
			}#if end
2266
			}#if end
2267
		
2267
 
2268
		#函式說明:
2268
		#函式說明:
2269
		#呼叫shell執行系統命令,並取得回傳的內容.
2269
		#呼叫shell執行系統命令,並取得回傳的內容.
2270
		#回傳結果:
2270
		#回傳結果:
2271
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2271
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2272
		#$result["error"],錯誤訊息陣列.
2272
		#$result["error"],錯誤訊息陣列.
Line 2318... Line 2318...
2318
		#exec=>http://php.net/manual/en/function.exec.php
2318
		#exec=>http://php.net/manual/en/function.exec.php
2319
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
2319
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
2320
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
2320
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
2321
		$callShell=external::callShell($conf["external::callShell"]);
2321
		$callShell=external::callShell($conf["external::callShell"]);
2322
		unset($conf["external::callShell"]);
2322
		unset($conf["external::callShell"]);
2323
	
2323
 
2324
		#如果執行外部程式失敗
2324
		#如果執行外部程式失敗
2325
		if($callShell["status"]==="false"){
2325
		if($callShell["status"]==="false"){
2326
 
2326
 
2327
			#設置執行錯誤識別
2327
			#設置執行錯誤識別
2328
			$result["status"]="false";
2328
			$result["status"]="false";
Line 2332... Line 2332...
2332
 
2332
 
2333
			#回傳結果
2333
			#回傳結果
2334
			return $result;
2334
			return $result;
2335
 
2335
 
2336
			}#if end
2336
			}#if end
2337
			
2337
 
2338
		#確認檔案有存在
2338
		#確認檔案有存在
2339
		#函式說明:
2339
		#函式說明:
2340
		#檢查多個檔案與資料夾是否存在.
2340
		#檢查多個檔案與資料夾是否存在.
2341
		#回傳的結果:
2341
		#回傳的結果:
2342
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
2342
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 2366... Line 2366...
2366
		#備註:
2366
		#備註:
2367
		#函數file_exists檢查的路徑為檔案系統的路徑
2367
		#函數file_exists檢查的路徑為檔案系統的路徑
2368
		#$result["varName"][$i]結果未實作
2368
		#$result["varName"][$i]結果未實作
2369
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
2369
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
2370
		unset($conf["fileAccess::checkMultiFileExist"]);
2370
		unset($conf["fileAccess::checkMultiFileExist"]);
2371
	
2371
 
2372
		#如果失敗
2372
		#如果失敗
2373
		if($checkMultiFileExist["status"]==="false"){
2373
		if($checkMultiFileExist["status"]==="false"){
2374
		
2374
 
2375
			#設置執行錯誤識別
2375
			#設置執行錯誤識別
2376
			$result["status"]="false";
2376
			$result["status"]="false";
2377
 
2377
 
2378
			#取得錯誤訊息
2378
			#取得錯誤訊息
2379
			$result["error"]=$checkMultiFileExist;
2379
			$result["error"]=$checkMultiFileExist;
2380
 
2380
 
2381
			#回傳結果
2381
			#回傳結果
2382
			return $result;
2382
			return $result;
2383
		
2383
 
2384
			}#if end
2384
			}#if end
2385
			
2385
 
2386
		#如果壓縮檔產生失敗
2386
		#如果壓縮檔產生失敗
2387
		if($checkMultiFileExist["allExist"]==="false"){
2387
		if($checkMultiFileExist["allExist"]==="false"){
2388
		
2388
 
2389
			#設置執行錯誤識別
2389
			#設置執行錯誤識別
2390
			$result["status"]="false";
2390
			$result["status"]="false";
2391
 
2391
 
2392
			#取得錯誤訊息
2392
			#取得錯誤訊息
2393
			$result["error"]=$checkMultiFileExist;
2393
			$result["error"]=$checkMultiFileExist;
2394
 
2394
 
2395
			#回傳結果
2395
			#回傳結果
2396
			return $result;
2396
			return $result;
2397
		
2397
 
2398
			}#if end
2398
			}#if end
2399
			
2399
 
2400
		#如果要移除原始檔案
2400
		#如果要移除原始檔案
2401
		if($conf["delAfterSuc"]==="true"){
2401
		if($conf["delAfterSuc"]==="true"){
2402
		
2402
 
2403
			#函式說明:
2403
			#函式說明:
2404
			#移除檔案
2404
			#移除檔案
2405
			#回傳結果:
2405
			#回傳結果:
2406
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
2406
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
2407
			#$result["error"],錯誤訊息陣列
2407
			#$result["error"],錯誤訊息陣列
Line 2417... Line 2417...
2417
			#$conf["commentsArray"]=array("");
2417
			#$conf["commentsArray"]=array("");
2418
			#備註:
2418
			#備註:
2419
			#無.
2419
			#無.
2420
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
2420
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
2421
			unset($conf["fileAccess::delFile"]);
2421
			unset($conf["fileAccess::delFile"]);
2422
		
2422
 
2423
			#如果失敗
2423
			#如果失敗
2424
			if($delFile["status"]==="false"){
2424
			if($delFile["status"]==="false"){
2425
			
2425
 
2426
				#設置執行錯誤識別
2426
				#設置執行錯誤識別
2427
				$result["status"]="false";
2427
				$result["status"]="false";
2428
 
2428
 
2429
				#取得錯誤訊息
2429
				#取得錯誤訊息
2430
				$result["error"]=$delFile;
2430
				$result["error"]=$delFile;
2431
 
2431
 
2432
				#回傳結果
2432
				#回傳結果
2433
				return $result;
2433
				return $result;
2434
			
2434
 
2435
				}#if end
2435
				}#if end
2436
 
2436
 
2437
			}#if end
2437
			}#if end
2438
			
2438
 
2439
		#設置執行正常
2439
		#設置執行正常
2440
		$result["status"]="true";
2440
		$result["status"]="true";
2441
		
2441
 
2442
		#回傳結果
2442
		#回傳結果
2443
		return $result;
2443
		return $result;
2444
	
2444
 
2445
		}#function makeTarFile end
2445
		}#function makeTarFile end
2446
 
2446
 
2447
	/*
2447
	/*
2448
	#函式說明:
2448
	#函式說明:
2449
	#將資料夾打包成.tar.zst檔案
2449
	#將資料夾打包成.tar.zst檔案
Line 2472... Line 2472...
2472
	#無.
2472
	#無.
2473
	#備註:
2473
	#備註:
2474
	#無.
2474
	#無.
2475
	*/
2475
	*/
2476
	public static function makeTarZstFile(&$conf){
2476
	public static function makeTarZstFile(&$conf){
2477
	
2477
 
2478
		#初始化要回傳的結果
2478
		#初始化要回傳的結果
2479
		$result=array();
2479
		$result=array();
2480
 
2480
 
2481
		#取得當前執行的函數名稱
2481
		#取得當前執行的函數名稱
2482
		$result["function"]=__FUNCTION__;
2482
		$result["function"]=__FUNCTION__;
Line 2517... Line 2517...
2517
 
2517
 
2518
			#回傳結果
2518
			#回傳結果
2519
			return $result;
2519
			return $result;
2520
 
2520
 
2521
			}#if end
2521
			}#if end
2522
	
2522
 
2523
		#函式說明:
2523
		#函式說明:
2524
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
2524
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
2525
		#回傳結果:
2525
		#回傳結果:
2526
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2526
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2527
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
2527
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 2570... Line 2570...
2570
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2570
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2571
		#備註:
2571
		#備註:
2572
		#無.
2572
		#無.
2573
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2573
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2574
		unset($conf["variableCheck::checkArguments"]);
2574
		unset($conf["variableCheck::checkArguments"]);
2575
	
2575
 
2576
		#如果 $checkArguments["status"] 等於 "false"
2576
		#如果 $checkArguments["status"] 等於 "false"
2577
		if($checkArguments["status"]==="false"){
2577
		if($checkArguments["status"]==="false"){
2578
 
2578
 
2579
			#設置執行錯誤識別
2579
			#設置執行錯誤識別
2580
			$result["status"]="false";
2580
			$result["status"]="false";
Line 2598... Line 2598...
2598
 
2598
 
2599
			#回傳結果
2599
			#回傳結果
2600
			return $result;
2600
			return $result;
2601
 
2601
 
2602
			}#if end
2602
			}#if end
2603
	
2603
 
2604
		#函式說明:
2604
		#函式說明:
2605
		#將資料夾打包成.tar檔案
2605
		#將資料夾打包成.tar檔案
2606
		#回傳的結果:
2606
		#回傳的結果:
2607
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2607
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2608
		#$result["error"],錯誤訊息.
2608
		#$result["error"],錯誤訊息.
Line 2612... Line 2612...
2612
		#$conf["target"],字串,要打包的檔案.
2612
		#$conf["target"],字串,要打包的檔案.
2613
		$conf["cmd::makeTarFile"]["target"]=$conf["target"];
2613
		$conf["cmd::makeTarFile"]["target"]=$conf["target"];
2614
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
2614
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
2615
		$conf["cmd::makeTarFile"]["fileArgu"]=__FILE__;
2615
		$conf["cmd::makeTarFile"]["fileArgu"]=__FILE__;
2616
		#可省略參數:
2616
		#可省略參數:
2617
		
2617
 
2618
		#如果有設置 $conf["commentsArrayForTar"]
2618
		#如果有設置 $conf["commentsArrayForTar"]
2619
		if(isset($conf["commentsArrayForTar"])){
2619
		if(isset($conf["commentsArrayForTar"])){
2620
		
2620
 
2621
			#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
2621
			#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
2622
			$conf["cmd::makeTarFile"]["commentsArray"]=$conf["commentsArrayForTar"];
2622
			$conf["cmd::makeTarFile"]["commentsArray"]=$conf["commentsArrayForTar"];
2623
		
2623
 
2624
			}#if end
2624
			}#if end
2625
		
2625
 
2626
		#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
2626
		#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
2627
		$conf["cmd::makeTarFile"]["newLineBreak"]=$conf["newLineBreak"];
2627
		$conf["cmd::makeTarFile"]["newLineBreak"]=$conf["newLineBreak"];
2628
		#$conf["path"],字串,要打包的檔案的路徑,預設為當前路徑.
2628
		#$conf["path"],字串,要打包的檔案的路徑,預設為當前路徑.
2629
		$conf["cmd::makeTarFile"]["path"]=$conf["path"];
2629
		$conf["cmd::makeTarFile"]["path"]=$conf["path"];
2630
		#$conf["delAfterSuc"],字串,是否壓縮後將原始檔案移除,預設為"false"代表不要;反之為"true"代表要.
2630
		#$conf["delAfterSuc"],字串,是否壓縮後將原始檔案移除,預設為"false"代表不要;反之為"true"代表要.
Line 2635... Line 2635...
2635
		#無.
2635
		#無.
2636
		#備註:
2636
		#備註:
2637
		#無.
2637
		#無.
2638
		$makeTarFile=cmd::makeTarFile($conf["cmd::makeTarFile"]);
2638
		$makeTarFile=cmd::makeTarFile($conf["cmd::makeTarFile"]);
2639
		unset($conf["cmd::makeTarFile"]);
2639
		unset($conf["cmd::makeTarFile"]);
2640
	
2640
 
2641
		#如果 $makeTarFile["status"] 等於 "false"
2641
		#如果 $makeTarFile["status"] 等於 "false"
2642
		if($makeTarFile["status"]==="false"){
2642
		if($makeTarFile["status"]==="false"){
2643
 
2643
 
2644
			#設置執行錯誤識別
2644
			#設置執行錯誤識別
2645
			$result["status"]="false";
2645
			$result["status"]="false";
Line 2649... Line 2649...
2649
 
2649
 
2650
			#回傳結果
2650
			#回傳結果
2651
			return $result;
2651
			return $result;
2652
 
2652
 
2653
			}#if end
2653
			}#if end
2654
			
2654
 
2655
		#函式說明:
2655
		#函式說明:
2656
		#將資料夾打包成.zst檔案
2656
		#將資料夾打包成.zst檔案
2657
		#回傳的結果:
2657
		#回傳的結果:
2658
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2658
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2659
		#$result["error"],錯誤訊息.
2659
		#$result["error"],錯誤訊息.
Line 2663... Line 2663...
2663
		#$conf["target"],字串,要打包的檔案.
2663
		#$conf["target"],字串,要打包的檔案.
2664
		$conf["cmd::makeZstFile"]["target"]=$conf["target"].".tar";
2664
		$conf["cmd::makeZstFile"]["target"]=$conf["target"].".tar";
2665
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
2665
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
2666
		$conf["cmd::makeZstFile"]["fileArgu"]=__FILE__;
2666
		$conf["cmd::makeZstFile"]["fileArgu"]=__FILE__;
2667
		#可省略參數:
2667
		#可省略參數:
2668
		
2668
 
2669
		#如果有設置 $conf["commentsArrayForZst"]
2669
		#如果有設置 $conf["commentsArrayForZst"]
2670
		if(isset($conf["commentsArrayForZst"])){
2670
		if(isset($conf["commentsArrayForZst"])){
2671
		
2671
 
2672
			#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
2672
			#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
2673
			$conf["cmd::makeZstFile"]["commentsArray"]=$conf["commentsArrayForZst"];
2673
			$conf["cmd::makeZstFile"]["commentsArray"]=$conf["commentsArrayForZst"];
2674
				
2674
 
2675
			}#if end
2675
			}#if end
2676
		
2676
 
2677
		#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
2677
		#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
2678
		$conf["cmd::makeZstFile"]["newLineBreak"]=$conf["newLineBreak"];
2678
		$conf["cmd::makeZstFile"]["newLineBreak"]=$conf["newLineBreak"];
2679
		#$conf["path"],字串,要打包的檔案的路徑,預設為當前路徑.
2679
		#$conf["path"],字串,要打包的檔案的路徑,預設為當前路徑.
2680
		$conf["cmd::makeZstFile"]["path"]=$conf["path"];
2680
		$conf["cmd::makeZstFile"]["path"]=$conf["path"];
2681
		#$conf["delAfterSuc"],字串,是否壓縮後將原始檔案移除,預設為"false"代表不要;反之為"true"代表要.
2681
		#$conf["delAfterSuc"],字串,是否壓縮後將原始檔案移除,預設為"false"代表不要;反之為"true"代表要.
Line 2686... Line 2686...
2686
		#無.
2686
		#無.
2687
		#備註:
2687
		#備註:
2688
		#無.
2688
		#無.
2689
		$makeZstFile=cmd::makeZstFile($conf["cmd::makeZstFile"]);
2689
		$makeZstFile=cmd::makeZstFile($conf["cmd::makeZstFile"]);
2690
		unset($conf["cmd::makeZstFile"]);
2690
		unset($conf["cmd::makeZstFile"]);
2691
	
2691
 
2692
		#如果 $makeZstFile["status"] 等於 "false"
2692
		#如果 $makeZstFile["status"] 等於 "false"
2693
		if($makeZstFile["status"]==="false"){
2693
		if($makeZstFile["status"]==="false"){
2694
 
2694
 
2695
			#設置執行錯誤識別
2695
			#設置執行錯誤識別
2696
			$result["status"]="false";
2696
			$result["status"]="false";
Line 2700... Line 2700...
2700
 
2700
 
2701
			#回傳結果
2701
			#回傳結果
2702
			return $result;
2702
			return $result;
2703
 
2703
 
2704
			}#if end
2704
			}#if end
2705
			
2705
 
2706
		#取得壓縮好的檔案路徑與名稱
2706
		#取得壓縮好的檔案路徑與名稱
2707
		$result["content"]=$makeZstFile["storePlace"];
2707
		$result["content"]=$makeZstFile["storePlace"];
2708
			
2708
 
2709
		#設置執行正常
2709
		#設置執行正常
2710
		$result["status"]="true";
2710
		$result["status"]="true";
2711
 
2711
 
2712
		#回傳結果
2712
		#回傳結果
2713
		return $result;
2713
		return $result;
2714
	
2714
 
2715
		}#function makeTarZstFile end
2715
		}#function makeTarZstFile end
2716
 
2716
 
2717
	/*
2717
	/*
2718
	#函式說明:
2718
	#函式說明:
2719
	#移動檔案並重新命名,過程會提供提示說明.
2719
	#移動檔案並重新命名,過程會提供提示說明.
Line 4149... Line 4149...
4149
 
4149
 
4150
			#回傳結果
4150
			#回傳結果
4151
			return $result;
4151
			return $result;
4152
 
4152
 
4153
			}#if end
4153
			}#if end
4154
		
4154
 
4155
		#設定要檢查的檔案
4155
		#設定要檢查的檔案
4156
		$target=\escapeshellarg($conf["fileName"]);
4156
		$target=\escapeshellarg($conf["fileName"]);
4157
				
4157
 
4158
		#$cmd="if [ -e ".$target." ]; then echo \"found\" ; else echo \"not found\"; fi;";
4158
		#$cmd="if [ -e ".$target." ]; then echo \"found\" ; else echo \"not found\"; fi;";
4159
 
4159
 
4160
		#debug
4160
		#debug
4161
		#var_dump(__LINE__,$cmd);
4161
		#var_dump(__LINE__,$cmd);
4162
 
4162
 
Line 4214... Line 4214...
4214
				$conf["external::callShell"]["password"]=$conf["password"];
4214
				$conf["external::callShell"]["password"]=$conf["password"];
4215
 
4215
 
4216
				}#if end
4216
				}#if end
4217
 
4217
 
4218
			}#if end
4218
			}#if end
4219
		
4219
 
4220
		#如果不要運行指令,只要取得要執行的指令
4220
		#如果不要運行指令,只要取得要執行的指令
4221
		if($conf["getCmdOnly"]==="true"){
4221
		if($conf["getCmdOnly"]==="true"){
4222
 
4222
 
4223
			#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
4223
			#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
4224
			$conf["external::callShell"]["doNotRun"]="false";
4224
			$conf["external::callShell"]["doNotRun"]="false";
4225
		
4225
 
4226
			}#if end
4226
			}#if end
4227
 
4227
 
4228
		#備註:
4228
		#備註:
4229
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
4229
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
4230
		#參考資料:
4230
		#參考資料:
Line 4245... Line 4245...
4245
 
4245
 
4246
			#回傳結果
4246
			#回傳結果
4247
			return $result;
4247
			return $result;
4248
 
4248
 
4249
			}#if end
4249
			}#if end
4250
 
4250
 
4251
 		#debug
4251
 		#debug
4252
 		#var_dump(__LINE__,$callShell);
4252
 		#var_dump(__LINE__,$callShell);
4253
 
4253
 
4254
		#儲存要執行的指令
4254
		#儲存要執行的指令
4255
		$result["cmdStr"]=$callShell["cmd"];
4255
		$result["cmdStr"]=$callShell["cmd"];
4256
		
4256
 
4257
		#用陣列儲存的指令與參數資訊
4257
		#用陣列儲存的指令與參數資訊
4258
		$result["escapedCmdArray"]=$callShell["noEscaped"];
4258
		$result["escapedCmdArray"]=$callShell["noEscaped"];
4259
 
4259
 
4260
		#如果不要運行指令,只要取得要執行的指令
4260
		#如果不要運行指令,只要取得要執行的指令
4261
		if($conf["getCmdOnly"]==="true"){
4261
		if($conf["getCmdOnly"]==="true"){
4262
		
4262
 
4263
			#設置執行正常的識別
4263
			#設置執行正常的識別
4264
			$result["status"]="true";
4264
			$result["status"]="true";
4265
			
4265
 
4266
			#因為沒有執行指令,所以設置為"?"
4266
			#因為沒有執行指令,所以設置為"?"
4267
			$result["founded"]="?";
4267
			$result["founded"]="?";
4268
			
4268
 
4269
			#回傳結果
4269
			#回傳結果
4270
			return $result;
4270
			return $result;
4271
		
4271
 
4272
			}#if end
4272
			}#if end
4273
 
4273
 
4274
		#如果有找到檔案
4274
		#如果有找到檔案
4275
		if($callShell["output"][0]==="found"){
4275
		if($callShell["output"][0]==="found"){
4276
 
4276
 
Line 7513... Line 7513...
7513
 
7513
 
7514
			#回傳結果
7514
			#回傳結果
7515
			return $result;
7515
			return $result;
7516
 
7516
 
7517
			}#if end
7517
			}#if end
7518
		
7518
 
7519
		#函式說明:
7519
		#函式說明:
7520
		#呼叫shell依序執行系統命令,並取得回傳的內容.
7520
		#呼叫shell依序執行系統命令,並取得回傳的內容.
7521
		#回傳結果:
7521
		#回傳結果:
7522
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7522
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7523
		#$result["error"],錯誤訊息陣列.
7523
		#$result["error"],錯誤訊息陣列.
7524
		#$result["function"],當前執行的函數名稱.	
7524
		#$result["function"],當前執行的函數名稱.
7525
		#$result["content"],爲執行完每個指令後的回傳結果.
7525
		#$result["content"],爲執行完每個指令後的回傳結果.
7526
		#$result["cmd"],執行的指令內容,若"sameShell"參數為"true",則會有該數值.
7526
		#$result["cmd"],執行的指令內容,若"sameShell"參數為"true",則會有該數值.
7527
		#$result["output"],執行後得到的輸出,若"sameShell"參數為"true",則會有該數值.
7527
		#$result["output"],執行後得到的輸出,若"sameShell"參數為"true",則會有該數值.
7528
		#必填參數:
7528
		#必填參數:
7529
		#$conf["command"],字串陣列,要執行的指令.
7529
		#$conf["command"],字串陣列,要執行的指令.
Line 8605... Line 8605...
8605
		#$conf["enablePrintDescription"]="true";
8605
		#$conf["enablePrintDescription"]="true";
8606
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
8606
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
8607
		#$conf["printDescription"]="";
8607
		#$conf["printDescription"]="";
8608
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
8608
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
8609
		$conf["checkCmdExist::callShell"]["escapeshellarg"]="true";
8609
		$conf["checkCmdExist::callShell"]["escapeshellarg"]="true";
8610
		
8610
 
8611
		#如果有設置 $conf["username"]
8611
		#如果有設置 $conf["username"]
8612
		if(isset($conf["username"])){
8612
		if(isset($conf["username"])){
8613
		
8613
 
8614
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
8614
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
8615
			$conf["checkCmdExist::callShell"]["username"]=$conf["username"];
8615
			$conf["checkCmdExist::callShell"]["username"]=$conf["username"];
8616
		
8616
 
8617
			}#if end
8617
			}#if end
8618
		
8618
 
8619
		#如果有設置 $conf["password"]
8619
		#如果有設置 $conf["password"]
8620
		if(isset($conf["password"])){
8620
		if(isset($conf["password"])){
8621
		
8621
 
8622
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
8622
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
8623
			$conf["checkCmdExist::callShell"]["password"]=$conf["password"];				
8623
			$conf["checkCmdExist::callShell"]["password"]=$conf["password"];
8624
			
8624
 
8625
			}#if end
8625
			}#if end
8626
		
8626
 
8627
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
8627
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
8628
		#$conf["useScript"]="";
8628
		#$conf["useScript"]="";
8629
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
8629
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
8630
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
8630
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
8631
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
8631
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
Line 8810... Line 8810...
8810
 
8810
 
8811
			#回傳結果
8811
			#回傳結果
8812
			return $result;
8812
			return $result;
8813
 
8813
 
8814
			}#if end
8814
			}#if end
8815
		
8815
 
8816
		#取得參數
8816
		#取得參數
8817
		$result["argu"]=$conf;
8817
		$result["argu"]=$conf;
8818
 
8818
 
8819
		#如果 $conf 不為陣列
8819
		#如果 $conf 不為陣列
8820
		if(gettype($conf)!=="array"){
8820
		if(gettype($conf)!=="array"){
Line 8911... Line 8911...
8911
 
8911
 
8912
			}#if end
8912
			}#if end
8913
 
8913
 
8914
		#初始化輸出
8914
		#初始化輸出
8915
		$output=array();
8915
		$output=array();
8916
		
8916
 
8917
		#取得 PATH
8917
		#取得 PATH
8918
		exec("echo \$PATH",$output,$status);
8918
		exec("echo \$PATH",$output,$status);
8919
		
8919
 
8920
		#如果執行失敗
8920
		#如果執行失敗
8921
		if($status!==0){
8921
		if($status!==0){
8922
		
8922
 
8923
			#設置執行失敗
8923
			#設置執行失敗
8924
			$result["status"]="false";
8924
			$result["status"]="false";
8925
			
8925
 
8926
			#設置執行錯誤訊息
8926
			#設置執行錯誤訊息
8927
			$result["error"]="取得系統環境變數 PATH 失敗";
8927
			$result["error"]="取得系統環境變數 PATH 失敗";
8928
			
8928
 
8929
			#回傳結果
8929
			#回傳結果
8930
			return $result;
8930
			return $result;
8931
		
8931
 
8932
			}#if end
8932
			}#if end
8933
		
8933
 
8934
		#取得 PATH 設定 
8934
		#取得 PATH 設定
8935
		$PATHS=$output[0];
8935
		$PATHS=$output[0];
8936
		
8936
 
8937
		#函式說明:
8937
		#函式說明:
8938
		#將固定格式的字串分開,並回傳分開的結果.
8938
		#將固定格式的字串分開,並回傳分開的結果.
8939
		#回傳結果:
8939
		#回傳結果:
8940
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8940
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8941
		#$result["error"],錯誤訊息陣列
8941
		#$result["error"],錯誤訊息陣列
Line 8957... Line 8957...
8957
		#無.
8957
		#無.
8958
		#備註:
8958
		#備註:
8959
		#無.
8959
		#無.
8960
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8960
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8961
		unset($conf["stringProcess::spiltString"]);
8961
		unset($conf["stringProcess::spiltString"]);
8962
		
8962
 
8963
		#如果分割字串失敗
8963
		#如果分割字串失敗
8964
		if($spiltString["status"]==="false"){
8964
		if($spiltString["status"]==="false"){
8965
		
8965
 
8966
			#設置執行失敗
8966
			#設置執行失敗
8967
			$result["status"]="false";
8967
			$result["status"]="false";
8968
			
8968
 
8969
			#設置執行錯誤訊息
8969
			#設置執行錯誤訊息
8970
			$result["error"]="取得系統環境變數 PATH 失敗";
8970
			$result["error"]="取得系統環境變數 PATH 失敗";
8971
			
8971
 
8972
			#回傳結果
8972
			#回傳結果
8973
			return $result;
8973
			return $result;
8974
		
8974
 
8975
			}#if end
8975
			}#if end
8976
			
8976
 
8977
		#取得PATH字串陣列
8977
		#取得PATH字串陣列
8978
		$PATHS=$spiltString["dataArray"];
8978
		$PATHS=$spiltString["dataArray"];
8979
		
8979
 
8980
		#預設沒有找到程式
8980
		#預設沒有找到程式
8981
		$cmdFound=false;
8981
		$cmdFound=false;
8982
		
8982
 
8983
		#針對每個 $PATHS
8983
		#針對每個 $PATHS
8984
		foreach($PATHS as $path){
8984
		foreach($PATHS as $path){
8985
		
8985
 
8986
			#要運行的指令
8986
			#要運行的指令
8987
			$cmd="targetToCheck='".$path."/".$conf["cmd"]."';".PHP_EOL."if [ -f \${targetToCheck} ]; then".PHP_EOL."exit;".PHP_EOL."else".PHP_EOL."exit 1;".PHP_EOL."fi";
8987
			$cmd="targetToCheck='".$path."/".$conf["cmd"]."';".PHP_EOL."if [ -f \${targetToCheck} ]; then".PHP_EOL."exit;".PHP_EOL."else".PHP_EOL."exit 1;".PHP_EOL."fi";
8988
			
8988
 
8989
			#初始化輸出
8989
			#初始化輸出
8990
			$output=array();
8990
			$output=array();
8991
			
8991
 
8992
			#執行指令
8992
			#執行指令
8993
			exec($cmd,$output,$status);
8993
			exec($cmd,$output,$status);
8994
				
8994
 
8995
			#如果執行正常
8995
			#如果執行正常
8996
			if($status===0){
8996
			if($status===0){
8997
			
8997
 
8998
				#代表有找到程式
8998
				#代表有找到程式
8999
				$cmdFound=true;
8999
				$cmdFound=true;
9000
				
9000
 
9001
				#設置完整的程式路徑
9001
				#設置完整的程式路徑
9002
				$result["cmdFullPath"]=$path."/".$conf["cmd"];
9002
				$result["cmdFullPath"]=$path."/".$conf["cmd"];
9003
				
9003
 
9004
				#跳離 foreach
9004
				#跳離 foreach
9005
				break;
9005
				break;
9006
			
9006
 
9007
				}#if end
9007
				}#if end
9008
		
9008
 
9009
			}#foreach end
9009
			}#foreach end
9010
 
9010
 
9011
		#設置找到指令
9011
		#設置找到指令
9012
		$result["founded"]=$cmdFound;
9012
		$result["founded"]=$cmdFound;
9013
 
9013
 
Line 9268... Line 9268...
9268
 
9268
 
9269
			}#if end
9269
			}#if end
9270
 
9270
 
9271
		#初始化儲存新的指令輸出
9271
		#初始化儲存新的指令輸出
9272
		$output=array();
9272
		$output=array();
9273
		
9273
 
9274
		#針對每行輸出
9274
		#針對每行輸出
9275
		foreach($callShell["output"] as $line){
9275
		foreach($callShell["output"] as $line){
9276
		
9276
 
9277
			#如果不是空白行
9277
			#如果不是空白行
9278
			if(trim($line)!==""){
9278
			if(trim($line)!==""){
9279
				
9279
 
9280
				#記錄該行
9280
				#記錄該行
9281
				$output[]=$line;
9281
				$output[]=$line;
9282
			
9282
 
9283
				}#if 
9283
				}#if
9284
		
9284
 
9285
			}#foreach end
9285
			}#foreach end
9286
			
9286
 
9287
		#取代成沒有空白行的輸出
9287
		#取代成沒有空白行的輸出
9288
		$callShell["output"]=$output;
9288
		$callShell["output"]=$output;
9289
 
9289
 
9290
		#如果輸出列數大於4
9290
		#如果輸出列數大於4
9291
		if(count($callShell["output"])>=4){
9291
		if(count($callShell["output"])>=4){
Line 9826... Line 9826...
9826
 
9826
 
9827
		#回傳結果
9827
		#回傳結果
9828
		return $result;
9828
		return $result;
9829
 
9829
 
9830
		}#function nmcli_list end
9830
		}#function nmcli_list end
9831
	
9831
 
9832
	/*
9832
	/*
9833
	#函式說明:
9833
	#函式說明:
9834
	#fedora的nmcli指令,重新連線指定的連線。
9834
	#fedora的nmcli指令,重新連線指定的連線。
9835
	#回傳結果:
9835
	#回傳結果:
9836
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9836
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 9847... Line 9847...
9847
	#無.
9847
	#無.
9848
	#參考資料:
9848
	#參考資料:
9849
	#無.
9849
	#無.
9850
	#備註:
9850
	#備註:
9851
	#僅能在命令列環境下執行.
9851
	#僅能在命令列環境下執行.
9852
	*/	
9852
	*/
9853
	public static function nmcli_reconnect($conf){
9853
	public static function nmcli_reconnect($conf){
9854
	
9854
 
9855
		#初始化要回傳的結果
9855
		#初始化要回傳的結果
9856
		$result=array();
9856
		$result=array();
9857
 
9857
 
9858
		#取得當前執行的函式名稱
9858
		#取得當前執行的函式名稱
9859
		$result["function"]=__FUNCTION__;
9859
		$result["function"]=__FUNCTION__;
Line 9972... Line 9972...
9972
			#回傳結果
9972
			#回傳結果
9973
			return $result;
9973
			return $result;
9974
 
9974
 
9975
			}#if end
9975
			}#if end
9976
 
9976
 
9977
	
9977
 
9978
		#函式說明:
9978
		#函式說明:
9979
		#呼叫shell執行系統命令,並取得回傳的內容.
9979
		#呼叫shell執行系統命令,並取得回傳的內容.
9980
		#回傳的結果:
9980
		#回傳的結果:
9981
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9981
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9982
		#$result["error"],錯誤訊息陣列.
9982
		#$result["error"],錯誤訊息陣列.
Line 9991... Line 9991...
9991
		#$result["statusCode"],執行結束後的代碼.
9991
		#$result["statusCode"],執行結束後的代碼.
9992
		#必填參數
9992
		#必填參數
9993
		#$conf["command"],字串,要執行的指令與.
9993
		#$conf["command"],字串,要執行的指令與.
9994
		$conf["external::callShell"]["command"]="nmcli";
9994
		$conf["external::callShell"]["command"]="nmcli";
9995
		#$conf["fileArgu"],字串,變數__FILE__的內容.
9995
		#$conf["fileArgu"],字串,變數__FILE__的內容.
9996
		$conf["external::callShell"]["fileArgu"]=__FILE__;		
9996
		$conf["external::callShell"]["fileArgu"]=__FILE__;
9997
		#可省略參數:
9997
		#可省略參數:
9998
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
9998
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
9999
		$conf["external::callShell"]["argu"]=array("c","down",$conf["name-uuid"]);
9999
		$conf["external::callShell"]["argu"]=array("c","down",$conf["name-uuid"]);
10000
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
10000
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
10001
		#$conf["arguIsAddr"]=array();	
10001
		#$conf["arguIsAddr"]=array();
10002
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
10002
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
10003
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
10003
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
10004
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
10004
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
10005
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
10005
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
10006
		#$conf["enablePrintDescription"]="true";
10006
		#$conf["enablePrintDescription"]="true";
Line 10023... Line 10023...
10023
		#參考資料:
10023
		#參考資料:
10024
		#exec=>http://php.net/manual/en/function.exec.php
10024
		#exec=>http://php.net/manual/en/function.exec.php
10025
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
10025
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
10026
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
10026
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
10027
		$callShell=external::callShell($conf["external::callShell"]);
10027
		$callShell=external::callShell($conf["external::callShell"]);
10028
	
10028
 
10029
		#如果執行失敗
10029
		#如果執行失敗
10030
		if($callShell["status"]==="false" && $callShell["error"][0]!==10 && $callShell["error"][0]!==4){
10030
		if($callShell["status"]==="false" && $callShell["error"][0]!==10 && $callShell["error"][0]!==4){
10031
		
10031
 
10032
			#設置執行失敗
10032
			#設置執行失敗
10033
			$result["status"]="false";
10033
			$result["status"]="false";
10034
 
10034
 
10035
			#設置執行錯誤訊息
10035
			#設置執行錯誤訊息
10036
			$result["error"]=$callShell;
10036
			$result["error"]=$callShell;
10037
 
10037
 
10038
			#回傳結果
10038
			#回傳結果
10039
			return $result;
10039
			return $result;
10040
		
10040
 
10041
			}#if end
10041
			}#if end
10042
			
10042
 
10043
		#函式說明:
10043
		#函式說明:
10044
		#呼叫shell執行系統命令,並取得回傳的內容.
10044
		#呼叫shell執行系統命令,並取得回傳的內容.
10045
		#回傳的結果:
10045
		#回傳的結果:
10046
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10046
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10047
		#$result["error"],錯誤訊息陣列.
10047
		#$result["error"],錯誤訊息陣列.
Line 10056... Line 10056...
10056
		#$result["statusCode"],執行結束後的代碼.
10056
		#$result["statusCode"],執行結束後的代碼.
10057
		#必填參數
10057
		#必填參數
10058
		#$conf["command"],字串,要執行的指令與.
10058
		#$conf["command"],字串,要執行的指令與.
10059
		$conf["external::callShell"]["command"]="nmcli";
10059
		$conf["external::callShell"]["command"]="nmcli";
10060
		#$conf["fileArgu"],字串,變數__FILE__的內容.
10060
		#$conf["fileArgu"],字串,變數__FILE__的內容.
10061
		$conf["external::callShell"]["fileArgu"]=__FILE__;		
10061
		$conf["external::callShell"]["fileArgu"]=__FILE__;
10062
		#可省略參數:
10062
		#可省略參數:
10063
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
10063
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
10064
		$conf["external::callShell"]["argu"]=array("c","up",$conf["name-uuid"]);
10064
		$conf["external::callShell"]["argu"]=array("c","up",$conf["name-uuid"]);
10065
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
10065
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
10066
		#$conf["arguIsAddr"]=array();	
10066
		#$conf["arguIsAddr"]=array();
10067
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
10067
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
10068
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
10068
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
10069
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
10069
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
10070
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
10070
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
10071
		#$conf["enablePrintDescription"]="true";
10071
		#$conf["enablePrintDescription"]="true";
Line 10088... Line 10088...
10088
		#參考資料:
10088
		#參考資料:
10089
		#exec=>http://php.net/manual/en/function.exec.php
10089
		#exec=>http://php.net/manual/en/function.exec.php
10090
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
10090
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
10091
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
10091
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
10092
		$callShell=external::callShell($conf["external::callShell"]);
10092
		$callShell=external::callShell($conf["external::callShell"]);
10093
	
10093
 
10094
		#如果執行失敗
10094
		#如果執行失敗
10095
		if($callShell["status"]==="false" && $callShell["error"][0]!==4){
10095
		if($callShell["status"]==="false" && $callShell["error"][0]!==4){
10096
		
10096
 
10097
			#設置執行失敗
10097
			#設置執行失敗
10098
			$result["status"]="false";
10098
			$result["status"]="false";
10099
 
10099
 
10100
			#設置執行錯誤訊息
10100
			#設置執行錯誤訊息
10101
			$result["error"]=$callShell;
10101
			$result["error"]=$callShell;
10102
 
10102
 
10103
			#回傳結果
10103
			#回傳結果
10104
			return $result;
10104
			return $result;
10105
		
10105
 
10106
			}#if end
10106
			}#if end
10107
	
10107
 
10108
		#設置執行正常
10108
		#設置執行正常
10109
		$result["status"]="true";
10109
		$result["status"]="true";
10110
 
10110
 
10111
		#記錄執行結果
10111
		#記錄執行結果
10112
		$result["content"]=$callShell;
10112
		$result["content"]=$callShell;
10113
 
10113
 
10114
		#回傳結果
10114
		#回傳結果
10115
		return $result;
10115
		return $result;
10116
	
10116
 
10117
		}#function nmcli_reconnect end
10117
		}#function nmcli_reconnect end
10118
 
10118
 
10119
	/*
10119
	/*
10120
	#函式說明:
10120
	#函式說明:
10121
	#抓取命令列的參數.
10121
	#抓取命令列的參數.
Line 10265... Line 10265...
10265
 
10265
 
10266
			#回傳結果
10266
			#回傳結果
10267
			return $result;
10267
			return $result;
10268
 
10268
 
10269
			}#if end
10269
			}#if end
10270
		
10270
 
10271
		#預設沒有參數
10271
		#預設沒有參數
10272
		$result["content"]=array();
10272
		$result["content"]=array();
10273
		
10273
 
10274
		#預設參數數量為0
10274
		#預設參數數量為0
10275
		$result["count"]=0;
10275
		$result["count"]=0;
10276
		
10276
 
10277
		#如果有 $_SERVER["argv"]
10277
		#如果有 $_SERVER["argv"]
10278
		if(isset($_SERVER["argv"])){
10278
		if(isset($_SERVER["argv"])){
10279
		
10279
 
10280
			#儲存參數
10280
			#儲存參數
10281
			$result["content"]=$_SERVER["argv"];
10281
			$result["content"]=$_SERVER["argv"];
10282
		
10282
 
10283
			}#if end
10283
			}#if end
10284
		
10284
 
10285
		#如果有 $_SERVER["argc"]
10285
		#如果有 $_SERVER["argc"]
10286
		if(isset($_SERVER["argc"])){
10286
		if(isset($_SERVER["argc"])){
10287
		
10287
 
10288
			#取得參數數量
10288
			#取得參數數量
10289
			$result["count"]=$_SERVER["argc"];
10289
			$result["count"]=$_SERVER["argc"];
10290
		
10290
 
10291
			}#if end
10291
			}#if end
10292
			
10292
 
10293
		#如果 arguEqual2http 為 "true" 且含有參數
10293
		#如果 arguEqual2http 為 "true" 且含有參數
10294
		if($conf["arguEqual2http"]==="true" && count($result["content"])>0 ){
10294
		if($conf["arguEqual2http"]==="true" && count($result["content"])>0 ){
10295
		
10295
 
10296
			#移除命令列的第一個參數(程式名稱)
10296
			#移除命令列的第一個參數(程式名稱)
10297
			$array_shift=array_shift($result["content"]);
10297
			$array_shift=array_shift($result["content"]);
10298
		
10298
 
10299
			#如果異常
10299
			#如果異常
10300
			if($array_shift===null){
10300
			if($array_shift===null){
10301
			
10301
 
10302
				#設置執行失敗
10302
				#設置執行失敗
10303
				$result["status"]="false";
10303
				$result["status"]="false";
10304
 
10304
 
10305
				#設置執行錯誤訊息
10305
				#設置執行錯誤訊息
10306
				$result["error"][]="shift first argu failed";
10306
				$result["error"][]="shift first argu failed";
10307
 
10307
 
10308
				#回傳結果
10308
				#回傳結果
10309
				return $result;
10309
				return $result;
10310
 
10310
 
10311
				}#if end
10311
				}#if end
10312
		
10312
 
10313
			}#if end
10313
			}#if end
10314
		
10314
 
10315
		#如果要將 http get 變成參數
10315
		#如果要將 http get 變成參數
10316
		if($conf["httpGetToArgu"]==="true"){
10316
		if($conf["httpGetToArgu"]==="true"){
10317
		
10317
 
10318
			#函式說明:
10318
			#函式說明:
10319
			#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
10319
			#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
10320
			#回傳結果:
10320
			#回傳結果:
10321
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
10321
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
10322
			#$result["error"],錯誤訊息陣列.
10322
			#$result["error"],錯誤訊息陣列.
Line 10357... Line 10357...
10357
			#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
10357
			#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
10358
			#備註:
10358
			#備註:
10359
			#表單變數的名稱若含有「.」,則會變成「-」。
10359
			#表單變數的名稱若含有「.」,則會變成「-」。
10360
			$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf["form::responseMultiInputDataSecurityEnhance"]);
10360
			$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf["form::responseMultiInputDataSecurityEnhance"]);
10361
			unset($conf["form::responseMultiInputDataSecurityEnhance"]);
10361
			unset($conf["form::responseMultiInputDataSecurityEnhance"]);
10362
				
10362
 
10363
			#若執行失敗
10363
			#若執行失敗
10364
			if($responseMultiInputDataSecurityEnhance["status"]==="false"){
10364
			if($responseMultiInputDataSecurityEnhance["status"]==="false"){
10365
 
10365
 
10366
				#設置執行失敗
10366
				#設置執行失敗
10367
				$result["status"]="false";
10367
				$result["status"]="false";
Line 10371... Line 10371...
10371
 
10371
 
10372
				#回傳結果
10372
				#回傳結果
10373
				return $result;
10373
				return $result;
10374
 
10374
 
10375
				}#if end
10375
				}#if end
10376
				
10376
 
10377
			#取得 GET 變數	
10377
			#取得 GET 變數
10378
			$result["_GET"]=$responseMultiInputDataSecurityEnhance["inputDataContent"];
10378
			$result["_GET"]=$responseMultiInputDataSecurityEnhance["inputDataContent"];
10379
			
10379
 
10380
			#函式說明:
10380
			#函式說明:
10381
			#將多個一維陣列串聯起來,key從0開始排序.
10381
			#將多個一維陣列串聯起來,key從0開始排序.
10382
			#回傳的結果:
10382
			#回傳的結果:
10383
			#$result["status"],"true"表執行正常,"false"代表執行不正常.
10383
			#$result["status"],"true"表執行正常,"false"代表執行不正常.
10384
			#$result["error"],錯誤訊息陣列.
10384
			#$result["error"],錯誤訊息陣列.
Line 10394... Line 10394...
10394
			#無.
10394
			#無.
10395
			#備註:
10395
			#備註:
10396
			#無.
10396
			#無.
10397
			$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
10397
			$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
10398
			unset($conf["arrays::mergeArray"]);
10398
			unset($conf["arrays::mergeArray"]);
10399
			
10399
 
10400
			#若執行失敗
10400
			#若執行失敗
10401
			if($mergeArray["status"]==="false"){
10401
			if($mergeArray["status"]==="false"){
10402
 
10402
 
10403
				#設置執行失敗
10403
				#設置執行失敗
10404
				$result["status"]="false";
10404
				$result["status"]="false";
Line 10408... Line 10408...
10408
 
10408
 
10409
				#回傳結果
10409
				#回傳結果
10410
				return $result;
10410
				return $result;
10411
 
10411
 
10412
				}#if end
10412
				}#if end
10413
			
10413
 
10414
			#取得合併好的參數陣列
10414
			#取得合併好的參數陣列
10415
			$result["content"]=$mergeArray["content"];
10415
			$result["content"]=$mergeArray["content"];
10416
			
10416
 
10417
			#更新參數的數量
10417
			#更新參數的數量
10418
			$result["count"]=count($result["content"]);
10418
			$result["count"]=count($result["content"]);
10419
			
10419
 
10420
			}#if end
10420
			}#if end
10421
 
10421
 
10422
		#如果要將 http post 變成參數
10422
		#如果要將 http post 變成參數
10423
		if($conf["httpPostToArgu"]==="true"){
10423
		if($conf["httpPostToArgu"]==="true"){
10424
		
10424
 
10425
			#函式說明:
10425
			#函式說明:
10426
			#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
10426
			#可以處理多個透過GET、POST而來的資訊,儲存成變數,同時限定傳送的方法、來源,來增加安全性,檢查有沒有皆收到必須要接收到的變數,沒有接收到的變數可以指定從session變數中取得.
10427
			#回傳結果:
10427
			#回傳結果:
10428
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
10428
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
10429
			#$result["error"],錯誤訊息陣列.
10429
			#$result["error"],錯誤訊息陣列.
Line 10464... Line 10464...
10464
			#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
10464
			#伺服器端的變數 -> http://php.net/manual/en/reserved.variables.server.php
10465
			#備註:
10465
			#備註:
10466
			#表單變數的名稱若含有「.」,則會變成「-」。
10466
			#表單變數的名稱若含有「.」,則會變成「-」。
10467
			$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf["form::responseMultiInputDataSecurityEnhance"]);
10467
			$responseMultiInputDataSecurityEnhance=form::responseMultiInputDataSecurityEnhance($conf["form::responseMultiInputDataSecurityEnhance"]);
10468
			unset($conf["form::responseMultiInputDataSecurityEnhance"]);
10468
			unset($conf["form::responseMultiInputDataSecurityEnhance"]);
10469
				
10469
 
10470
			#若執行失敗
10470
			#若執行失敗
10471
			if($responseMultiInputDataSecurityEnhance["status"]==="false"){
10471
			if($responseMultiInputDataSecurityEnhance["status"]==="false"){
10472
 
10472
 
10473
				#設置執行失敗
10473
				#設置執行失敗
10474
				$result["status"]="false";
10474
				$result["status"]="false";
Line 10478... Line 10478...
10478
 
10478
 
10479
				#回傳結果
10479
				#回傳結果
10480
				return $result;
10480
				return $result;
10481
 
10481
 
10482
				}#if end
10482
				}#if end
10483
				
10483
 
10484
			#取得 POST 變數	
10484
			#取得 POST 變數
10485
			$result["_POST"]=$responseMultiInputDataSecurityEnhance["inputDataContent"];
10485
			$result["_POST"]=$responseMultiInputDataSecurityEnhance["inputDataContent"];
10486
			
10486
 
10487
			#函式說明:
10487
			#函式說明:
10488
			#將多個一維陣列串聯起來,key從0開始排序.
10488
			#將多個一維陣列串聯起來,key從0開始排序.
10489
			#回傳的結果:
10489
			#回傳的結果:
10490
			#$result["status"],"true"表執行正常,"false"代表執行不正常.
10490
			#$result["status"],"true"表執行正常,"false"代表執行不正常.
10491
			#$result["error"],錯誤訊息陣列.
10491
			#$result["error"],錯誤訊息陣列.
Line 10501... Line 10501...
10501
			#無.
10501
			#無.
10502
			#備註:
10502
			#備註:
10503
			#無.
10503
			#無.
10504
			$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
10504
			$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
10505
			unset($conf["arrays::mergeArray"]);
10505
			unset($conf["arrays::mergeArray"]);
10506
			
10506
 
10507
			#若執行失敗
10507
			#若執行失敗
10508
			if($mergeArray["status"]==="false"){
10508
			if($mergeArray["status"]==="false"){
10509
 
10509
 
10510
				#設置執行失敗
10510
				#設置執行失敗
10511
				$result["status"]="false";
10511
				$result["status"]="false";
Line 10515... Line 10515...
10515
 
10515
 
10516
				#回傳結果
10516
				#回傳結果
10517
				return $result;
10517
				return $result;
10518
 
10518
 
10519
				}#if end
10519
				}#if end
10520
			
10520
 
10521
			#取得合併好的參數陣列
10521
			#取得合併好的參數陣列
10522
			$result["content"]=$mergeArray["content"];
10522
			$result["content"]=$mergeArray["content"];
10523
			
10523
 
10524
			#更新參數的數量
10524
			#更新參數的數量
10525
			$result["count"]=count($result["content"]);
10525
			$result["count"]=count($result["content"]);
10526
			
10526
 
10527
			}#if end
10527
			}#if end
10528
 
10528
 
10529
		#設置執行正常
10529
		#設置執行正常
10530
		$result["status"]="true";
10530
		$result["status"]="true";
10531
 
10531
 
Line 10715... Line 10715...
10715
		#無
10715
		#無
10716
		#可省略參數:
10716
		#可省略參數:
10717
		#$conf["echo"],"true"代表要將抓到的參數一個個印出來,"false"代表用回傳的方式,預設為"false".
10717
		#$conf["echo"],"true"代表要將抓到的參數一個個印出來,"false"代表用回傳的方式,預設為"false".
10718
		#$conf["echo"]="false";
10718
		#$conf["echo"]="false";
10719
		$conf["cmd::getArgu"]=array();
10719
		$conf["cmd::getArgu"]=array();
10720
		
10720
 
10721
		#如果要解析表單變數
10721
		#如果要解析表單變數
10722
		if($conf["parseFormVar"]==="true"){
10722
		if($conf["parseFormVar"]==="true"){
10723
		
10723
 
10724
			#$conf["httpGetToArgu"],字串,"true"代表要將 http get 參數變成參數來取得,像是 $_GET["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
10724
			#$conf["httpGetToArgu"],字串,"true"代表要將 http get 參數變成參數來取得,像是 $_GET["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
10725
			$conf["cmd::getArgu"]["httpGetToArgu"]="true";
10725
			$conf["cmd::getArgu"]["httpGetToArgu"]="true";
10726
			#$conf["httpPostToArgu"],字串,"true"代表要將 http post 參數變成參數來取得,像是 $_POST["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
10726
			#$conf["httpPostToArgu"],字串,"true"代表要將 http post 參數變成參數來取得,像是 $_POST["p1"] 會變成 $result["content"]["p1"] 回傳,預設為"false"代表不使用.
10727
			$conf["cmd::getArgu"]["httpPostToArgu"]="true";
10727
			$conf["cmd::getArgu"]["httpPostToArgu"]="true";
10728
		
10728
 
10729
			}#if end
10729
			}#if end
10730
		
10730
 
10731
		$getArgu=cmd::getArgu($conf["cmd::getArgu"]);
10731
		$getArgu=cmd::getArgu($conf["cmd::getArgu"]);
10732
		unset($conf["cmd::getArgu"]);
10732
		unset($conf["cmd::getArgu"]);
10733
 
10733
 
10734
		#如果解析失敗
10734
		#如果解析失敗
10735
		if($getArgu["status"]==="false"){
10735
		if($getArgu["status"]==="false"){
Line 10748... Line 10748...
10748
		#若參數若不成對
10748
		#若參數若不成對
10749
		if($getArgu["count"]%2===0){
10749
		if($getArgu["count"]%2===0){
10750
 
10750
 
10751
			#如果有設置 help function
10751
			#如果有設置 help function
10752
			if(isset($conf["helpFunc"])){
10752
			if(isset($conf["helpFunc"])){
10753
			
10753
 
10754
				#若help函式是可以呼叫的
10754
				#若help函式是可以呼叫的
10755
				if(is_callable("\qbpwcf\\".$conf["helpFunc"])){
10755
				if(is_callable("\qbpwcf\\".$conf["helpFunc"])){
10756
				
10756
 
10757
					#呼叫之
10757
					#呼叫之
10758
					call_user_func("\qbpwcf\\".$conf["helpFunc"]);
10758
					call_user_func("\qbpwcf\\".$conf["helpFunc"]);
10759
					
10759
 
10760
					}#if end
10760
					}#if end
10761
			
10761
 
10762
				}#if end
10762
				}#if end
10763
			
10763
 
10764
			#設置執行失敗
10764
			#設置執行失敗
10765
			$result["status"]="false";
10765
			$result["status"]="false";
10766
 
10766
 
10767
			#設置執行錯誤訊息
10767
			#設置執行錯誤訊息
10768
			$result["error"]=$getArgu;
10768
			$result["error"]=$getArgu;
Line 10872... Line 10872...
10872
 
10872
 
10873
		}#function parseArgu end
10873
		}#function parseArgu end
10874
 
10874
 
10875
	/*
10875
	/*
10876
	#函式說明:
10876
	#函式說明:
10877
	#將指令字串解析成陣列,方便給予 external::callShell 使用 
10877
	#將指令字串解析成陣列,方便給予 external::callShell 使用
10878
	#回傳結果:
10878
	#回傳結果:
10879
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10879
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10880
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
10880
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
10881
	#$result["function"],當前執行的函式名稱.
10881
	#$result["function"],當前執行的函式名稱.
10882
	#$result["content"],解析好的指令陣列.
10882
	#$result["content"],解析好的指令陣列.
Line 10892... Line 10892...
10892
	#無.
10892
	#無.
10893
	#備註:
10893
	#備註:
10894
	#無.
10894
	#無.
10895
	*/
10895
	*/
10896
	public static function parseCmdString(&$conf){
10896
	public static function parseCmdString(&$conf){
10897
	
10897
 
10898
		#初始化要回傳的結果
10898
		#初始化要回傳的結果
10899
		$result=array();
10899
		$result=array();
10900
 
10900
 
10901
		#取得當前執行的函式名稱
10901
		#取得當前執行的函式名稱
10902
		$result["function"]=__FUNCTION__;
10902
		$result["function"]=__FUNCTION__;
Line 10998... Line 10998...
10998
 
10998
 
10999
			#回傳結果
10999
			#回傳結果
11000
			return $result;
11000
			return $result;
11001
 
11001
 
11002
			}#if end
11002
			}#if end
11003
		
11003
 
11004
		#函式說明:
11004
		#函式說明:
11005
		#呼叫shell執行系統命令,並取得回傳的內容.
11005
		#呼叫shell執行系統命令,並取得回傳的內容.
11006
		#回傳結果:
11006
		#回傳結果:
11007
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11007
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11008
		#$result["error"],錯誤訊息陣列.
11008
		#$result["error"],錯誤訊息陣列.
Line 11062... Line 11062...
11062
		#備註:
11062
		#備註:
11063
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
11063
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
11064
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
11064
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
11065
		$callShell=external::callShell($conf["external::callShell"]);
11065
		$callShell=external::callShell($conf["external::callShell"]);
11066
		unset($conf["external::callShell"]);
11066
		unset($conf["external::callShell"]);
11067
	
11067
 
11068
		#debug
11068
		#debug
11069
		#var_dump(__FUNCTION__,__LINE__,$callShell);
11069
		#var_dump(__FUNCTION__,__LINE__,$callShell);
11070
	
11070
 
11071
		#如果執行失敗
11071
		#如果執行失敗
11072
		if($callShell["status"]==="false"){
11072
		if($callShell["status"]==="false"){
11073
		
11073
 
11074
			#設置執行失敗
11074
			#設置執行失敗
11075
			$result["status"]="false";
11075
			$result["status"]="false";
11076
			
11076
 
11077
			#設置錯誤訊息
11077
			#設置錯誤訊息
11078
			$result["error"]=$callShell;
11078
			$result["error"]=$callShell;
11079
			
11079
 
11080
			#回傳結果
11080
			#回傳結果
11081
			return $result;
11081
			return $result;
11082
		
11082
 
11083
			}#if end
11083
			}#if end
11084
		
11084
 
11085
		#設置執行正常
11085
		#設置執行正常
11086
		$result["status"]="true";
11086
		$result["status"]="true";
11087
	
11087
 
11088
		#初始化解析得到的參數
11088
		#初始化解析得到的參數
11089
		$result["argus"]=array();
11089
		$result["argus"]=array();
11090
		
11090
 
11091
		#如果有輸出
11091
		#如果有輸出
11092
		if(isset($callShell["output"][0])){
11092
		if(isset($callShell["output"][0])){
11093
		
11093
 
11094
			#如果輸出非 json
11094
			#如果輸出非 json
11095
			if(json_validate($callShell["output"][0])===false){
11095
			if(json_validate($callShell["output"][0])===false){
11096
			
11096
 
11097
				#設置執行失敗
11097
				#設置執行失敗
11098
				$result["status"]="false";
11098
				$result["status"]="false";
11099
				
11099
 
11100
				#設置錯誤訊息
11100
				#設置錯誤訊息
11101
				$result["error"]=$callShell;
11101
				$result["error"]=$callShell;
11102
				
11102
 
11103
				#回傳結果
11103
				#回傳結果
11104
				return $result;
11104
				return $result;
11105
			
11105
 
11106
				}#if end
11106
				}#if end
11107
			
11107
 
11108
			#取得解析的結果
11108
			#取得解析的結果
11109
			$parseResult=(array)(json_decode($callShell["output"][0]));
11109
			$parseResult=(array)(json_decode($callShell["output"][0]));
11110
		
11110
 
11111
			}#if end
11111
			}#if end
11112
		
11112
 
11113
		#針對執行結果輸出的每個元素
11113
		#針對執行結果輸出的每個元素
11114
		foreach($parseResult as $index=>$str){
11114
		foreach($parseResult as $index=>$str){
11115
		
11115
 
11116
			#如果是第1個元素
11116
			#如果是第1個元素
11117
			if($index<1){
11117
			if($index<1){
11118
			
11118
 
11119
				#忽略,換下一個元素
11119
				#忽略,換下一個元素
11120
				continue;
11120
				continue;
11121
			
11121
 
11122
				}#if end`
11122
				}#if end`
11123
		
11123
 
11124
			#如果是第2個元素
11124
			#如果是第2個元素
11125
			if($index===1){
11125
			if($index===1){
11126
			
11126
 
11127
				#設置為解析成的指令
11127
				#設置為解析成的指令
11128
				$result["cmd"]=$str;
11128
				$result["cmd"]=$str;
11129
			
11129
 
11130
				#設置為解析成連續的字串之一
11130
				#設置為解析成連續的字串之一
11131
				$result["content"][]=$str;
11131
				$result["content"][]=$str;
11132
			
11132
 
11133
				#下一個元素
11133
				#下一個元素
11134
				continue;
11134
				continue;
11135
			
11135
 
11136
				}#if end
11136
				}#if end
11137
				
11137
 
11138
			#取得參數
11138
			#取得參數
11139
			$result["argus"][]=$str;
11139
			$result["argus"][]=$str;
11140
			
11140
 
11141
			#設置為解析成連續的字串之一
11141
			#設置為解析成連續的字串之一
11142
			$result["content"][]=$str;
11142
			$result["content"][]=$str;
11143
		
11143
 
11144
			}#foreach end
11144
			}#foreach end
11145
		
11145
 
11146
		#回傳結果
11146
		#回傳結果
11147
		return $result;
11147
		return $result;
11148
	
11148
 
11149
		}#function parseCmdString end
11149
		}#function parseCmdString end
11150
 
11150
 
11151
	/*
11151
	/*
11152
	#函式說明:
11152
	#函式說明:
11153
	#搜尋特定目錄底下或檔案是否有關鍵字存在,其行數為何.
11153
	#搜尋特定目錄底下或檔案是否有關鍵字存在,其行數為何.
Line 12761... Line 12761...
12761
 
12761
 
12762
			}#if end
12762
			}#if end
12763
 
12763
 
12764
		#設置要執行的指令
12764
		#設置要執行的指令
12765
		$cmd="svn";
12765
		$cmd="svn";
12766
		
12766
 
12767
		#初始化給 svn 指令的參數
12767
		#初始化給 svn 指令的參數
12768
		$arguForSvn=array("status");
12768
		$arguForSvn=array("status");
12769
 
12769
 
12770
		#如果有設置要檢查的目標
12770
		#如果有設置要檢查的目標
12771
		if(isset($conf["target"])){
12771
		if(isset($conf["target"])){
Line 12849... Line 12849...
12849
			#未進入版本控制的軟連結到目錄,會出現類似以下警告訊息.
12849
			#未進入版本控制的軟連結到目錄,會出現類似以下警告訊息.
12850
			#svn: warning: W155010: The node '.../usr/lib64' was not found
12850
			#svn: warning: W155010: The node '.../usr/lib64' was not found
12851
 
12851
 
12852
			#如果遇到沒有進入版本控制的軟連結
12852
			#如果遇到沒有進入版本控制的軟連結
12853
			if( strpos($result["content"]["ori"][0]," W155010: ")!==false && strpos($result["content"]["ori"][0]," The node ")!==false && strpos($result["content"]["ori"][0]," was not found")!==false ){
12853
			if( strpos($result["content"]["ori"][0]," W155010: ")!==false && strpos($result["content"]["ori"][0]," The node ")!==false && strpos($result["content"]["ori"][0]," was not found")!==false ){
12854
			
12854
 
12855
				#設置該目標的 狀態(status), 路徑與名稱(target), 是否為目錄(is_dir).
12855
				#設置該目標的 狀態(status), 路徑與名稱(target), 是否為目錄(is_dir).
12856
				$result["content"]["status"][]=array(
12856
				$result["content"]["status"][]=array(
12857
					"status"=>"?",
12857
					"status"=>"?",
12858
					"target"=>$conf["target"],
12858
					"target"=>$conf["target"],
12859
					"is_dir"=>"false"
12859
					"is_dir"=>"false"
12860
					);
12860
					);
12861
			
12861
 
12862
				}#if end
12862
				}#if end
12863
			
12863
 
12864
			#反之
12864
			#反之
12865
			else{
12865
			else{
12866
			
12866
 
12867
				#針對每一列
12867
				#針對每一列
12868
				foreach($result["content"]["ori"] as $line){
12868
				foreach($result["content"]["ori"] as $line){
12869
 
12869
 
-
 
12870
					#解析
-
 
12871
					#函式說明:
-
 
12872
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
12873
					#回傳結果:
-
 
12874
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
12875
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
12876
					#$result["function"],當前執行的函式名稱.
-
 
12877
					#$result["argu"],所使用的參數.
-
 
12878
					#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
12879
					#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
12880
					#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
12881
					#必填參數:
-
 
12882
					#$conf["input"],字串,要檢查的字串.
-
 
12883
					$conf["search::findSpecifyStrFormat"]["input"]=$line;
-
 
12884
					#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
12885
					$conf["search::findSpecifyStrFormat"]["format"]="\${sta}       \${node}";
-
 
12886
					#可省略參數:
-
 
12887
					#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
12888
					#$conf["varEqual"]=array(null,"found");
12870
					#取得檔案的 status 與名稱
12889
					#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
12890
					#$conf["varCon"]=array("no_tail"=>" not");
-
 
12891
					#參考資料:
-
 
12892
					#無.
-
 
12893
					#備註:
-
 
12894
					#無.
-
 
12895
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
12896
					unset($conf["search::findSpecifyStrFormat"]);
-
 
12897
					
-
 
12898
					#如果執行異常
-
 
12899
					if($findSpecifyStrFormat["status"]==="false"){
-
 
12900
 
-
 
12901
						#設置執行失敗
12871
					sscanf($line,"%s %s",$sta,$fi);
12902
						$result["status"]="false";
-
 
12903
 
-
 
12904
						#設置執行錯誤訊息
-
 
12905
						$result["error"]=$findSpecifyStrFormat;
-
 
12906
 
-
 
12907
						#回傳結果
-
 
12908
						return $result;
-
 
12909
 
-
 
12910
						}#if end
-
 
12911
						
-
 
12912
					#如果有關鍵字
-
 
12913
					if($findSpecifyStrFormat["found"]==="true"){
-
 
12914
 
-
 
12915
						#取得 node status
-
 
12916
						$sta=$findSpecifyStrFormat["parsedVar"]["sta"][0];
-
 
12917
 
-
 
12918
						#取得 node path and name
-
 
12919
						$fi=$findSpecifyStrFormat["parsedVar"]["node"][0];
-
 
12920
 
-
 
12921
						}#if end
12872
 
12922
 
12873
					#設置該目標的 狀態(status), 路徑與名稱(target), 是否為目錄(is_dir).
12923
					#設置該目標的 狀態(status), 路徑與名稱(target), 是否為目錄(is_dir).
12874
					$result["content"]["status"][]=array(
12924
					$result["content"]["status"][]=array(
12875
						"status"=>$sta,
12925
						"status"=>$sta,
12876
						"target"=>$fi,
12926
						"target"=>$fi,
12877
						"is_dir"=>is_file($fi)?"false":"true"
12927
						"is_dir"=>is_file($fi)?"false":"true"
12878
						);
12928
						);
12879
 
12929
 
12880
					}#foreach end
12930
					}#foreach end
12881
			
12931
 
12882
				}#else end
12932
				}#else end
12883
 
12933
 
12884
			}#if end
12934
			}#if end
12885
 
12935
 
12886
		#設置執行正常
12936
		#設置執行正常
Line 13034... Line 13084...
13034
		$conf["cmd::getArgu"]=array();
13084
		$conf["cmd::getArgu"]=array();
13035
		$getArgu=cmd::getArgu($conf["cmd::getArgu"]);
13085
		$getArgu=cmd::getArgu($conf["cmd::getArgu"]);
13036
		unset($conf["cmd::getArgu"]);
13086
		unset($conf["cmd::getArgu"]);
13037
 
13087
 
13038
		#如果取得參數失敗
13088
		#如果取得參數失敗
13039
		if($getArgu["status"]==="false")
13089
		if($getArgu["status"]==="false"){
13040
		{
-
 
13041
		
13090
 
13042
			#設置執行失敗
13091
			#設置執行失敗
13043
			$result["status"]="false";
13092
			$result["status"]="false";
13044
 
13093
 
13045
			#設置執行錯誤
13094
			#設置執行錯誤
13046
			$result["error"]=$getArgu;
13095
			$result["error"]=$getArgu;
13047
 
13096
 
13048
			#回傳結果
13097
			#回傳結果
13049
			return $result;
13098
			return $result;
13050
		
13099
 
13051
		}#if end
13100
			}#if end
13052
 
13101
 
13053
		#如果有第一個參數
13102
		#如果有第一個參數
13054
		if(isset($getArgu["content"][1]))
13103
		if(isset($getArgu["content"][1])){
13055
		{
13104
		
13056
			#如果是 "-h" 跟 "--help"
13105
			#如果是 "-h" 跟 "--help"
13057
			if($getArgu["content"][1]==="-h" || $getArgu["content"][1]==="--help")
13106
			if($getArgu["content"][1]==="-h" || $getArgu["content"][1]==="--help"){
13058
			{
13107
			
13059
				#提示用法
13108
				#提示用法
13060
				echo "usage: ".basename($_SERVER["PHP_SELF"])." [--ssh-port=ssh connect port] [--ssh-key=ssh prive key] ".PHP_EOL;
13109
				echo "usage: ".basename($_SERVER["PHP_SELF"])." [--ssh-port=ssh connect port] [--ssh-key=ssh prive key] [--add-all-modified=comment for commit]".PHP_EOL;
13061
				echo "--ssh-port, 代表ssh連線的port.".PHP_EOL;
13110
				echo "--ssh-port, 代表 ssh 連線的 port.".PHP_EOL;
13062
				echo "--ssh-key, 代表ssh連線所要使用的私有金鑰.".PHP_EOL;
13111
				echo "--ssh-key, 代表 ssh 連線所要使用的私有金鑰.".PHP_EOL;
-
 
13112
				echo "--check-all, 代表要自動選擇所有異動的或新增的或兩者接是的檔案,異動的為 M 新增的為 ? 兩種都要為 A.".PHP_EOL;
13063
				exit;
13113
				exit;
-
 
13114
 
-
 
13115
				}#if end
13064
			
13116
 
13065
			}#if end
13117
			}#if end
13066
		
-
 
13067
		}#if end
-
 
13068
 
13118
 
13069
		#解析參數
13119
		#解析參數
13070
		#函式說明:
13120
		#函式說明:
13071
		#解析參數.
13121
		#解析參數.
13072
		#回傳結果:
13122
		#回傳結果:
Line 13115... Line 13165...
13115
				$sshOption=$sshOption." -p ".$parseArgu["content"]["ssh-port"][0];
13165
				$sshOption=$sshOption." -p ".$parseArgu["content"]["ssh-port"][0];
13116
 
13166
 
13117
				}#if end
13167
				}#if end
13118
 
13168
 
13119
			}#if end
13169
			}#if end
13120
		
13170
 
13121
		#如果有設定ssh key的參數
13171
		#如果有設定ssh key的參數
13122
		if(isset($parseArgu["content"]["ssh-key"])){
13172
		if(isset($parseArgu["content"]["ssh-key"])){
13123
		
13173
 
13124
			#如果有第一個參數
13174
			#如果有第一個參數
13125
			if(isset($parseArgu["content"]["ssh-key"][0])){
13175
			if(isset($parseArgu["content"]["ssh-key"][0])){
13126
 
13176
 
13127
				#設置 ssh 的 port
13177
				#設置 ssh 的 port
13128
				$sshOption=$sshOption." -i ".$parseArgu["content"]["ssh-key"][0];
13178
				$sshOption=$sshOption." -i ".$parseArgu["content"]["ssh-key"][0];
13129
 
13179
 
13130
				}#if end
13180
				}#if end
-
 
13181
 
-
 
13182
			}#if end
-
 
13183
		
-
 
13184
		#預設沒有指定 --check-all 參數
-
 
13185
		$checkAll=null;
-
 
13186
		
-
 
13187
		#如果有設置 --check-all
-
 
13188
		if(isset($parseArgu["content"]["check-all"])){
-
 
13189
		
-
 
13190
			#如果有第一個參數
-
 
13191
			if(isset($parseArgu["content"]["check-all"][0])){
-
 
13192
 
-
 
13193
				#取得 --check-all 的目標
-
 
13194
				$checkAll=$parseArgu["content"]["check-all"][0];
-
 
13195
 
-
 
13196
				}#if end
13131
		
13197
		
13132
			}#if end
13198
			}#if end
13133
 
13199
 
13134
		#函式說明:
13200
		#函式說明:
13135
		#檢查當前目錄是否在svn版本之下
13201
		#檢查當前目錄是否在svn版本之下
Line 13183... Line 13249...
13183
		#取得svn的repo
13249
		#取得svn的repo
13184
		$repo=$issvnworkdir["content"]["repo"];
13250
		$repo=$issvnworkdir["content"]["repo"];
13185
 
13251
 
13186
		#預設存放 svn 賬號密碼的 xml 檔案位置
13252
		#預設存放 svn 賬號密碼的 xml 檔案位置
13187
		$defaultSvnAcctXml=pathinfo(__FILE__)["dirname"]."/../../../etc/qbpwcf/qbpwcf.conf.xml";
13253
		$defaultSvnAcctXml=pathinfo(__FILE__)["dirname"]."/../../../etc/qbpwcf/qbpwcf.conf.xml";
13188
		
13254
 
13189
		#預設存放 svn 賬號密碼的 local xml 檔案位置
13255
		#預設存放 svn 賬號密碼的 local xml 檔案位置
13190
		$defaultLocalSvnAcctXml=$defaultSvnAcctXml;
13256
		$defaultLocalSvnAcctXml=$defaultSvnAcctXml;
13191
 
13257
 
13192
		#預設存放 svn 賬號密碼的 xml 檔案可能位置
13258
		#預設存放 svn 賬號密碼的 xml 檔案可能位置
13193
		$svnAcctXmlArray=array($defaultSvnAcctXml);
13259
		$svnAcctXmlArray=array($defaultSvnAcctXml);
13194
 
13260
 
13195
		#如果存在 include path
13261
		#如果存在 include path
13196
		if(get_include_path()!==false){
13262
		if(get_include_path()!==false){
13197
		
13263
 
13198
			#函式說明:
13264
			#函式說明:
13199
			#將固定格式的字串分開,並回傳分開的結果.
13265
			#將固定格式的字串分開,並回傳分開的結果.
13200
			#回傳結果:
13266
			#回傳結果:
13201
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13267
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13202
			#$result["error"],錯誤訊息陣列
13268
			#$result["error"],錯誤訊息陣列
Line 13221... Line 13287...
13221
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13287
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13222
			unset($conf["stringProcess::spiltString"]);
13288
			unset($conf["stringProcess::spiltString"]);
13223
 
13289
 
13224
			#如果執行失敗
13290
			#如果執行失敗
13225
			if($spiltString["status"]==="false"){
13291
			if($spiltString["status"]==="false"){
13226
			
13292
 
13227
				#設置執行失敗
13293
				#設置執行失敗
13228
				$result["status"]="false";
13294
				$result["status"]="false";
13229
 
13295
 
13230
				#設置執行錯誤
13296
				#設置執行錯誤
13231
				$result["error"]=$spiltString;
13297
				$result["error"]=$spiltString;
13232
 
13298
 
13233
				#回傳結果
13299
				#回傳結果
13234
				return $result;
13300
				return $result;
13235
			
13301
 
13236
				}#if end
13302
				}#if end
13237
				
13303
 
13238
			#如果沒有符合的分割符號
13304
			#如果沒有符合的分割符號
13239
			if($spiltString["found"]==="false"){
13305
			if($spiltString["found"]==="false"){
13240
			
13306
 
13241
				#設置執行失敗
13307
				#設置執行失敗
13242
				$result["status"]="false";
13308
				$result["status"]="false";
13243
 
13309
 
13244
				#設置執行錯誤
13310
				#設置執行錯誤
13245
				$result["error"]=$spiltString;
13311
				$result["error"]=$spiltString;
13246
 
13312
 
13247
				#回傳結果
13313
				#回傳結果
13248
				return $result;
13314
				return $result;
13249
			
13315
 
13250
				}#if end
13316
				}#if end
13251
				
13317
 
13252
			#如果沒有切割出東西
13318
			#如果沒有切割出東西
13253
			if($spiltString["dataCounts"]<1){
13319
			if($spiltString["dataCounts"]<1){
13254
			
13320
 
13255
				#設置執行失敗
13321
				#設置執行失敗
13256
				$result["status"]="false";
13322
				$result["status"]="false";
13257
 
13323
 
13258
				#設置執行錯誤
13324
				#設置執行錯誤
13259
				$result["error"]=$spiltString;
13325
				$result["error"]=$spiltString;
13260
 
13326
 
13261
				#回傳結果
13327
				#回傳結果
13262
				return $result;
13328
				return $result;
13263
			
13329
 
13264
				}#if end
13330
				}#if end
13265
			
13331
 
13266
			#如果 first php include path 不為 "/" 結尾
13332
			#如果 first php include path 不為 "/" 結尾
13267
			if($spiltString["dataArray"][0][strlen($spiltString["dataArray"][0])-1]!=="/"){
13333
			if($spiltString["dataArray"][0][strlen($spiltString["dataArray"][0])-1]!=="/"){
13268
			
13334
 
13269
				#開頭加上 "/"
13335
				#開頭加上 "/"
13270
				$defaultLocalSvnAcctXml="/".$defaultLocalSvnAcctXml;
13336
				$defaultLocalSvnAcctXml="/".$defaultLocalSvnAcctXml;
13271
			
13337
 
13272
				}#if end
13338
				}#if end
13273
			
13339
 
13274
			#增加 存放帳號密碼的xml檔案 位置
13340
			#增加 存放帳號密碼的xml檔案 位置
13275
			$svnAcctXmlArray[]=$spiltString["dataArray"][0].$defaultLocalSvnAcctXml;
13341
			$svnAcctXmlArray[]=$spiltString["dataArray"][0].$defaultLocalSvnAcctXml;
13276
 
13342
 
13277
			}#if end
13343
			}#if end
13278
	
13344
 
13279
		#針對每個可能的 存放帳號密碼的xml檔案 位置
13345
		#針對每個可能的 存放帳號密碼的xml檔案 位置
13280
		foreach($svnAcctXmlArray as $index=>$svnAcctXml){
13346
		foreach($svnAcctXmlArray as $index=>$svnAcctXml){
13281
		
13347
 
13282
			#如果存放帳號密碼的xml檔案不存在
13348
			#如果存放帳號密碼的xml檔案不存在
13283
			if(!file_exists($svnAcctXml)){
13349
			if(!file_exists($svnAcctXml)){
13284
 
13350
 
13285
				#如果是最後一個xml檔案了
13351
				#如果是最後一個xml檔案了
13286
				if($index===count($svnAcctXmlArray)-1){
13352
				if($index===count($svnAcctXmlArray)-1){
13287
				
13353
 
13288
					#設置執行失敗
13354
					#設置執行失敗
13289
					$result["status"]="false";
13355
					$result["status"]="false";
13290
 
13356
 
13291
					#設置執行錯誤
13357
					#設置執行錯誤
13292
					$result["error"]="存放帳號密碼的xml檔案(".$svnAcctXml.")不存在";
13358
					$result["error"]="存放帳號密碼的xml檔案(".$svnAcctXml.")不存在";
13293
 
13359
 
13294
					#回傳結果
13360
					#回傳結果
13295
					return $result;
13361
					return $result;
13296
 
13362
 
13297
				
-
 
13298
					}#if end
13363
					}#if end
13299
				
13364
 
13300
				}#if end
13365
				}#if end
13301
				
13366
 
13302
			#反之檔案存在
13367
			#反之檔案存在
13303
			else {
13368
			else {
13304
			
13369
 
13305
				#更新要使用的 存放帳號密碼的xml檔案
13370
				#更新要使用的 存放帳號密碼的xml檔案
13306
				$defaultSvnAcctXml=$svnAcctXml;
13371
				$defaultSvnAcctXml=$svnAcctXml;
13307
			
13372
 
13308
				#跳出 foreach
13373
				#跳出 foreach
13309
				break;
13374
				break;
13310
			
13375
 
13311
				}#else end
13376
				}#else end
13312
		
13377
 
13313
			}#foreach end
13378
			}#foreach end
13314
 
13379
 
13315
		#初始化要使用的svn+ssh帳號
13380
		#初始化要使用的svn+ssh帳號
13316
		$password="";
13381
		$password="";
13317
 
13382
 
13318
		#取得qbpwcf設定檔案的內容
13383
		#取得 qbpwcf 設定檔案的內容
13319
		#檢查是否有svn的URL上帳號對應的密碼是否存在
13384
		#檢查是否有svn的URL上帳號對應的密碼是否存在
13320
		#函式說明:
13385
		#函式說明:
13321
		#取得xml特定標籤的內容
13386
		#取得xml特定標籤的內容
13322
		#回傳結果:
13387
		#回傳結果:
13323
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13388
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 13692... Line 13757...
13692
						#設置密碼正確
13757
						#設置密碼正確
13693
						$passIsOk=true;
13758
						$passIsOk=true;
13694
 
13759
 
13695
						#儲存密碼
13760
						#儲存密碼
13696
						echo "svn密碼正確".PHP_EOL;
13761
						echo "svn密碼正確".PHP_EOL;
13697
						
13762
 
13698
						#跳出 while for
13763
						#跳出 while for
13699
						break 2;
13764
						break 2;
13700
 
13765
 
13701
						}#else end
13766
						}#else end
13702
 
13767
 
13703
					}#while end
13768
					}#while end
13704
 
13769
 
13705
				}#if end
13770
				}#if end
13706
 
13771
 
13707
			#如果已經是最後一筆帳號、密碼、repo對不上
13772
			#如果已經是最後一筆帳號、密碼、repo對不上
13708
			else if($i===$dataCount-1)
13773
			else if($i===$dataCount-1){
13709
			{
13774
			
13710
				#提示有找到既有的帳號與repo
13775
				#提示有找到既有的帳號與repo
13711
				echo "既有的帳號與repo都不符合".PHP_EOL;
13776
				echo "既有的帳號與repo都不符合".PHP_EOL;
13712
 
13777
 
13713
				#提示輸入密碼
13778
				#提示輸入密碼
13714
				#函式說明:
13779
				#函式說明:
Line 14048... Line 14113...
14048
		$fileShouldBeDeleted=array();
14113
		$fileShouldBeDeleted=array();
14049
 
14114
 
14050
		#初始化紀錄複製的清單
14115
		#初始化紀錄複製的清單
14051
		$copyList=array();
14116
		$copyList=array();
14052
 
14117
 
-
 
14118
		#判斷符合 --check-all 的參數
-
 
14119
		switch($checkAll){
-
 
14120
		
-
 
14121
			#如果是有異動的
-
 
14122
			case "M":
-
 
14123
			
-
 
14124
			#如果是新增的
-
 
14125
			case "?":
-
 
14126
			
-
 
14127
			#如果是有異動跟新增的都要
-
 
14128
			case "M&?":
-
 
14129
			
-
 
14130
				#取得當地與svn的差異
-
 
14131
				#取得當前目錄相對於repo的差異
-
 
14132
				#函式說明:
-
 
14133
				#執行svn status指令
-
 
14134
				#回傳結果:
-
 
14135
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
14136
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
14137
				#$result["function"],當前執行的函式名稱.
-
 
14138
				#$result["content"]["ori"],指令輸出的原始結果陣列.
-
 
14139
				#$result["content"]["status"][$i]["status"],第$i+1個目標的狀態.
-
 
14140
				#$result["content"]["status"][$i]["target"],第$i+1個目標的路徑與名稱.
-
 
14141
				#$result["content"]["status"][$i]["is_dir"],第$i+1個目標是否為目錄,"true"代表是,"false"代表不是.
-
 
14142
				#必填參數:
-
 
14143
				#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
14144
				$conf["cmd::svnsta"]["fileArgu"]=$conf["fileArgu"];
-
 
14145
				#可省略參數:
-
 
14146
				#$conf["target"],字串,要檢查status的目標.
-
 
14147
				#$conf["target"]="";
-
 
14148
				$svnsta=cmd::svnsta($conf["cmd::svnsta"]);
-
 
14149
				unset($conf["cmd::svnsta"]);
-
 
14150
 
-
 
14151
				#如果執行失敗
-
 
14152
				if($svnsta["status"]==="false"){
-
 
14153
 
-
 
14154
					#設置執行失敗
-
 
14155
					$result["status"]="false";
-
 
14156
 
-
 
14157
					#設置執行錯誤
-
 
14158
					$result["error"]=$svnsta;
-
 
14159
 
-
 
14160
					#回傳結果
-
 
14161
					return $result;
-
 
14162
 
-
 
14163
					}#if end
-
 
14164
 
-
 
14165
				#初始化儲存異動node的變數
-
 
14166
				$nodesSta=array();
-
 
14167
				
-
 
14168
				#針對每個異動的節點
-
 
14169
				foreach($svnsta["content"]["status"] as $node){
-
 
14170
 
-
 
14171
					#儲存 node 的狀態
-
 
14172
					$nodeSta=$node["status"];
-
 
14173
					
-
 
14174
					#儲存 node 的路徑與名稱
-
 
14175
					$nodePath=$node["target"];
-
 
14176
					
-
 
14177
					#儲存node狀態與路徑與名稱
-
 
14178
					$nodesSta[$nodeSta][]=$nodePath;
-
 
14179
					
-
 
14180
					#另存一份兩者都要的清單
-
 
14181
					$nodesSta["M&?"][]=$nodesSta[$nodeSta][count($nodesSta[$nodeSta])-1];
-
 
14182
					
-
 
14183
					}#foreach end
-
 
14184
 
-
 
14185
				#如果有要 commit 的異動 node
-
 
14186
				if(isset($nodesSta[$checkAll])){
-
 
14187
				
-
 
14188
					#debug
-
 
14189
					#var_dump(__LINE__,$nodesSta[$checkAll]);
-
 
14190
				
-
 
14191
					#如果要 commit node 包含不在版本控制上的
-
 
14192
					if($checkAll==="?" || $checkAll==="M&?"){
-
 
14193
					
-
 
14194
						#要用 svn add 的 node
-
 
14195
						#$nodesSta["?"];
-
 
14196
					
-
 
14197
						#針對每個要 add 的 node
-
 
14198
						foreach($nodesSta["?"] as $node){
-
 
14199
						
-
 
14200
							#函式說明:
-
 
14201
							#呼叫shell執行系統命令,並取得回傳的內容.
-
 
14202
							#回傳的結果:
-
 
14203
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
14204
							#$result["error"],錯誤訊息陣列.
-
 
14205
							#$result["function"],當前執行的函式名稱.
-
 
14206
							#$result["argu"],使用的參數.
-
 
14207
							#$result["cmd"],執行的指令內容.
-
 
14208
							#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
14209
							#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
-
 
14210
							#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
14211
							#$result["running"],是否還在執行.
-
 
14212
							#$result["pid"],pid.
-
 
14213
							#$result["statusCode"],執行結束後的代碼.
-
 
14214
							#必填參數:
-
 
14215
							#$conf["command"],字串,要執行的指令與.
-
 
14216
							$conf["external::callShell"]["command"]="svn";
-
 
14217
							#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
14218
							$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
-
 
14219
							#可省略參數:
-
 
14220
							#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
-
 
14221
							$conf["external::callShell"]["argu"]=array("add",$node);
-
 
14222
							#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
-
 
14223
							#$conf["arguIsAddr"]=array();
-
 
14224
							#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
-
 
14225
							#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
-
 
14226
							#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
-
 
14227
							#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
-
 
14228
							#$conf["enablePrintDescription"]="true";
-
 
14229
							#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
-
 
14230
							#$conf["printDescription"]="";
-
 
14231
							#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
-
 
14232
							$conf["external::callShell"]["escapeshellarg"]="true";
-
 
14233
							#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
-
 
14234
							#$conf["username"]="";
-
 
14235
							#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
-
 
14236
							#$conf["password"]="";
-
 
14237
							#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
-
 
14238
							#$conf["useScript"]="";
-
 
14239
							#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
-
 
14240
							#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
-
 
14241
							#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
-
 
14242
							#$conf["inBackGround"]="";
-
 
14243
							#備註:
-
 
14244
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
-
 
14245
							#參考資料:
-
 
14246
							#exec=>http://php.net/manual/en/function.exec.php
-
 
14247
							#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
-
 
14248
							#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
-
 
14249
							$callShell=external::callShell($conf["external::callShell"]);
-
 
14250
							unset($conf["external::callShell"]);
-
 
14251
 
-
 
14252
							#如果執行失敗
-
 
14253
							if($callShell["status"]==="false"){
-
 
14254
 
-
 
14255
								#設置執行失敗
-
 
14256
								$result["status"]="false";
-
 
14257
 
-
 
14258
								#設置執行錯誤
-
 
14259
								$result["error"]=$callShell;
-
 
14260
 
-
 
14261
								#回傳結果
-
 
14262
								return $result;
-
 
14263
 
-
 
14264
								}#if end
-
 
14265
						
-
 
14266
							}#foreach end
-
 
14267
					
-
 
14268
						}#if end
-
 
14269
					
-
 
14270
					#記錄要commit的新增檔案
-
 
14271
					$filesToCommit=$nodesSta[$checkAll];
-
 
14272
 
-
 
14273
					#記錄本次要新增的檔案
-
 
14274
					$fileAdded=$nodesSta[$checkAll];
-
 
14275
				
-
 
14276
					}#if end
-
 
14277
			
-
 
14278
				#跳出 switch
-
 
14279
				break;
-
 
14280
			
-
 
14281
			#其他
-
 
14282
			default:
-
 
14283
		
-
 
14284
				#do nothing
-
 
14285
		
-
 
14286
			}#switch end
-
 
14287
 
14053
		#當檔案未指定時
14288
		#當檔案未指定時
14054
		while(true){
14289
		while(true){
14055
 
14290
 
14056
			#提示輸入要commit的檔案
14291
			#提示輸入要commit的檔案
14057
			echo
14292
			echo
Line 14284... Line 14519...
14284
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
14519
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
14285
					$callShell=external::callShell($conf["external::callShell"]);
14520
					$callShell=external::callShell($conf["external::callShell"]);
14286
					unset($conf["external::callShell"]);
14521
					unset($conf["external::callShell"]);
14287
 
14522
 
14288
					#如果運行失敗
14523
					#如果運行失敗
14289
					if($callShell["status"]==="false")
14524
					if($callShell["status"]==="false"){
14290
					{
14525
					
14291
						#設置執行失敗
14526
						#設置執行失敗
14292
						$result["status"]="false";
14527
						$result["status"]="false";
14293
 
14528
 
14294
						#設置執行錯誤
14529
						#設置執行錯誤
14295
						$result["error"]=$callShell;
14530
						$result["error"]=$callShell;
14296
 
14531
 
14297
						#回傳結果
14532
						#回傳結果
14298
						return $result;
14533
						return $result;
14299
 
14534
 
14300
					}#if end
14535
						}#if end
14301
 
14536
 
14302
					#印出執行的cmd
14537
					#印出執行的cmd
14303
					echo "cmd:".$callShell["cmd"].PHP_EOL;
14538
					echo "cmd:".$callShell["cmd"].PHP_EOL;
14304
 
14539
 
14305
					#印出執行後的回傳代碼
14540
					#印出執行後的回傳代碼
Line 14396... Line 14631...
14396
					#繼續輸入要commit的檔案名稱
14631
					#繼續輸入要commit的檔案名稱
14397
					continue 2;
14632
					continue 2;
14398
 
14633
 
14399
				#如果是 "update"
14634
				#如果是 "update"
14400
				case "update":
14635
				case "update":
14401
				
14636
 
14402
					#運行 svn update
14637
					#運行 svn update
14403
					#函式說明:
14638
					#函式說明:
14404
					#呼叫shell執行系統命令,並取得回傳的內容.
14639
					#呼叫shell執行系統命令,並取得回傳的內容.
14405
					#回傳的結果:
14640
					#回傳的結果:
14406
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14641
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 14451... Line 14686...
14451
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
14686
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
14452
					$callShell=external::callShell($conf["external::callShell"]);
14687
					$callShell=external::callShell($conf["external::callShell"]);
14453
					unset($conf["external::callShell"]);
14688
					unset($conf["external::callShell"]);
14454
 
14689
 
14455
					#如果運行失敗
14690
					#如果運行失敗
14456
					if($callShell["status"]==="false")
14691
					if($callShell["status"]==="false"){
14457
					{
14692
						
14458
						#設置執行失敗
14693
						#設置執行失敗
14459
						$result["status"]="false";
14694
						$result["status"]="false";
14460
 
14695
 
14461
						#設置執行錯誤
14696
						#設置執行錯誤
14462
						$result["error"]=$callShell;
14697
						$result["error"]=$callShell;
14463
 
14698
 
14464
						#回傳結果
14699
						#回傳結果
14465
						return $result;
14700
						return $result;
14466
 
14701
 
14467
					}#if end
14702
						}#if end
14468
 
14703
 
14469
					#印出執行的cmd
14704
					#印出執行的cmd
14470
					echo "cmd:".$callShell["cmd"].PHP_EOL;
14705
					echo "cmd:".$callShell["cmd"].PHP_EOL;
14471
 
14706
 
14472
					#印出執行後的回傳代碼
14707
					#印出執行後的回傳代碼
Line 14507... Line 14742...
14507
 
14742
 
14508
						}#if end
14743
						}#if end
14509
 
14744
 
14510
					#印出結果
14745
					#印出結果
14511
					echo $multiLine["content"];
14746
					echo $multiLine["content"];
14512
				
14747
 
14513
					#繼續輸入要commit的檔案名稱
14748
					#繼續輸入要commit的檔案名稱
14514
					continue 2;
14749
					continue 2;
14515
 
14750
 
14516
				#如果是 "ls del"
14751
				#如果是 "ls del"
14517
				case "ls del":
14752
				case "ls del":
Line 14652... Line 14887...
14652
					#繼續讓使用者輸入要commit的檔案
14887
					#繼續讓使用者輸入要commit的檔案
14653
					continue 2;
14888
					continue 2;
14654
 
14889
 
14655
				#如果是其他數值
14890
				#如果是其他數值
14656
				default:
14891
				default:
14657
				
14892
 
14658
					#不做事
14893
					#不做事
14659
 
14894
 
14660
				}#switch end
14895
				}#switch end
14661
			
14896
 
14662
			#函式說明:
14897
			#函式說明:
14663
			#將字串進行解析,變成多個參數.
14898
			#將字串進行解析,變成多個參數.
14664
			#回傳結果:
14899
			#回傳結果:
14665
			#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
14900
			#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
14666
			#$result["function"],當前執行的函式內容.
14901
			#$result["function"],當前執行的函式內容.
Line 14685... Line 14920...
14685
				#debug
14920
				#debug
14686
				#var_dump(__FUNCITON__,__LINE__,$parse);
14921
				#var_dump(__FUNCITON__,__LINE__,$parse);
14687
 
14922
 
14688
				#如果是 bash 語法錯誤
14923
				#如果是 bash 語法錯誤
14689
				if($parse["error"][0]==="bash syntax error"){
14924
				if($parse["error"][0]==="bash syntax error"){
14690
				
14925
 
14691
					#提示錯誤訊息
14926
					#提示錯誤訊息
14692
					echo $parse["error"][0].PHP_EOL;
14927
					echo $parse["error"][0].PHP_EOL;
14693
					
14928
 
14694
					#提示錯誤訊息
14929
					#提示錯誤訊息
14695
					echo $parse["error"][1]["content"][0]["error"];
14930
					echo $parse["error"][1]["content"][0]["error"];
14696
				
14931
 
14697
					#debug
14932
					#debug
14698
					#var_dump($parse);
14933
					#var_dump($parse);
14699
				
14934
 
14700
					#繼續讓使用者輸入要commit的檔案
14935
					#繼續讓使用者輸入要commit的檔案
14701
					continue;
14936
					continue;
14702
				
14937
 
14703
					}#if end
14938
					}#if end
14704
 
14939
 
14705
				#設置錯誤訊息
14940
				#設置錯誤訊息
14706
				$result["error"]=$parse;
14941
				$result["error"]=$parse;
14707
 
14942
 
Line 14724... Line 14959...
14724
 
14959
 
14725
				#如果參數數量為3
14960
				#如果參數數量為3
14726
				case 3:
14961
				case 3:
14727
 
14962
 
14728
					#判斷 $argv[0] 的內容
14963
					#判斷 $argv[0] 的內容
14729
					switch($argv[0])
14964
					switch($argv[0]){
14730
					{
14965
					
14731
						#如果是 cp
14966
						#如果是 cp
14732
						case "cp":
14967
						case "cp":
14733
 
14968
 
14734
							#函式說明:
14969
							#函式說明:
14735
							#清除字串的「"」或「'」符號.
14970
							#清除字串的「"」或「'」符號.
Line 14747... Line 14982...
14747
							#無.
14982
							#無.
14748
							#備註:
14983
							#備註:
14749
							#無.
14984
							#無.
14750
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
14985
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
14751
							unset($conf["stringProcess::clearStrSymbol"]);
14986
							unset($conf["stringProcess::clearStrSymbol"]);
14752
							
14987
 
14753
							#如果失敗
14988
							#如果失敗
14754
							if($clearStrSymbol["status"]==="false"){
14989
							if($clearStrSymbol["status"]==="false"){
14755
 
14990
 
14756
								#設置執行失敗
14991
								#設置執行失敗
14757
								$result["status"]="false";
14992
								$result["status"]="false";
14758
								
14993
 
14759
								#設置執行失敗訊息
14994
								#設置執行失敗訊息
14760
								$result["error"]=$clearStrSymbol;
14995
								$result["error"]=$clearStrSymbol;
14761
								
14996
 
14762
								#回傳結果
14997
								#回傳結果
14763
								return $result;
14998
								return $result;
14764
							
14999
 
14765
								}#if end	
15000
								}#if end
14766
							
15001
 
14767
							#如果第二個參數代表的複製來源不存在
15002
							#如果第二個參數代表的複製來源不存在
14768
							if(!file_exists($clearStrSymbol["content"])){
15003
							if(!file_exists($clearStrSymbol["content"])){
14769
 
15004
 
14770
								#提示複製的來源檔案並不存在
15005
								#提示複製的來源檔案並不存在
14771
								echo "要複製的檔案「".$clearStrSymbol["content"]."」不存在!".PHP_EOL;
15006
								echo "要複製的檔案「".$clearStrSymbol["content"]."」不存在!".PHP_EOL;
14772
								
15007
 
14773
								#讓使用者繼續輸入要commit的項目
15008
								#讓使用者繼續輸入要commit的項目
14774
								#continue 2;
15009
								#continue 2;
14775
								break 2;
15010
								break 2;
14776
 
15011
 
14777
								}#if end
15012
								}#if end
14778
								
15013
 
14779
							#函式說明:
15014
							#函式說明:
14780
							#清除字串的「"」或「'」符號.
15015
							#清除字串的「"」或「'」符號.
14781
							#回傳結果:
15016
							#回傳結果:
14782
							#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
15017
							#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
14783
							#$result["function"],當前執行的函式內容.
15018
							#$result["function"],當前執行的函式內容.
14784
							#$result["error"],錯誤訊息陣列.
15019
							#$result["error"],錯誤訊息陣列.
14785
							#$result["content"],剔除「"」或「'」符號後的字串.
15020
							#$result["content"],剔除「"」或「'」符號後的字串.
14786
							#必填參數:
15021
							#必填參數:
14787
							#$conf["str"],字串,要處理的字串.
15022
							#$conf["str"],字串,要處理的字串.
14788
							$conf["stringProcess::clearStrSymbol"]["str"]=$argv[2];	
15023
							$conf["stringProcess::clearStrSymbol"]["str"]=$argv[2];
14789
							#可省略參數:
15024
							#可省略參數:
14790
							#無.
15025
							#無.
14791
							#參考資料:
15026
							#參考資料:
14792
							#無.
15027
							#無.
14793
							#備註:
15028
							#備註:
14794
							#無.
15029
							#無.
14795
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15030
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
14796
							unset($conf["stringProcess::clearStrSymbol"]);
15031
							unset($conf["stringProcess::clearStrSymbol"]);
14797
							
15032
 
14798
							#如果失敗
15033
							#如果失敗
14799
							if($clearStrSymbol["status"]==="false"){
15034
							if($clearStrSymbol["status"]==="false"){
14800
 
15035
 
14801
								#設置執行失敗
15036
								#設置執行失敗
14802
								$result["status"]="false";
15037
								$result["status"]="false";
14803
								
15038
 
14804
								#設置執行失敗訊息
15039
								#設置執行失敗訊息
14805
								$result["error"]=$clearStrSymbol;
15040
								$result["error"]=$clearStrSymbol;
14806
								
15041
 
14807
								#回傳結果
15042
								#回傳結果
14808
								return $result;
15043
								return $result;
14809
							
15044
 
14810
								}#if end
15045
								}#if end
14811
							
15046
 
14812
							#如果第三個參數代表的複製目的已經存在
15047
							#如果第三個參數代表的複製目的已經存在
14813
							if(file_exists($clearStrSymbol["content"])){
15048
							if(file_exists($clearStrSymbol["content"])){
14814
 
15049
 
14815
								#若不是目錄
15050
								#若不是目錄
14816
								if(!is_dir($clearStrSymbol["content"])){
15051
								if(!is_dir($clearStrSymbol["content"])){
Line 14819... Line 15054...
14819
									echo "要複製到的目的檔案「".$argv[2]."」已存在!".PHP_EOL;
15054
									echo "要複製到的目的檔案「".$argv[2]."」已存在!".PHP_EOL;
14820
 
15055
 
14821
									#讓使用者繼續輸入要commit的項目
15056
									#讓使用者繼續輸入要commit的項目
14822
									break 2;
15057
									break 2;
14823
 
15058
 
14824
									}#if end								
15059
									}#if end
14825
 
15060
 
14826
								#反之代表目的地是目錄
15061
								#反之代表目的地是目錄
14827
								else{
15062
								else{
14828
 
15063
 
14829
									#檢查目錄是否在版本控制中
15064
									#檢查目錄是否在版本控制中
Line 14889... Line 15124...
14889
									#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15124
									#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
14890
									$callShell=external::callShell($conf["external::callShell"]);
15125
									$callShell=external::callShell($conf["external::callShell"]);
14891
									unset($conf["external::callShell"]);
15126
									unset($conf["external::callShell"]);
14892
 
15127
 
14893
									#如果運行失敗
15128
									#如果運行失敗
14894
									if($callShell["status"]==="false")
15129
									if($callShell["status"]==="false"){
14895
									{
15130
									
14896
										#設置執行失敗
15131
										#設置執行失敗
14897
										$result["status"]="false";
15132
										$result["status"]="false";
14898
 
15133
 
14899
										#設置執行錯誤
15134
										#設置執行錯誤
14900
										$result["error"]=$callShell;
15135
										$result["error"]=$callShell;
14901
 
15136
 
14902
										#回傳結果
15137
										#回傳結果
14903
										return $result;
15138
										return $result;
14904
 
15139
 
14905
									}#if end
15140
										}#if end
14906
 
15141
 
14907
									#印出執行的cmd
15142
									#印出執行的cmd
14908
									echo "cmd:".$callShell["cmd"].PHP_EOL;
15143
									echo "cmd:".$callShell["cmd"].PHP_EOL;
14909
 
15144
 
14910
									#印出執行後的回傳代碼
15145
									#印出執行後的回傳代碼
Line 14932... Line 15167...
14932
 
15167
 
14933
									#提示複製過去的目標的目的已經存在
15168
									#提示複製過去的目標的目的已經存在
14934
									echo "要複製的「".$argv[1]."」會放到「".$argv[2]."」目錄底下!".PHP_EOL;
15169
									echo "要複製的「".$argv[1]."」會放到「".$argv[2]."」目錄底下!".PHP_EOL;
14935
 
15170
 
14936
									}#else end
15171
									}#else end
14937
								
15172
 
14938
								}#if end
15173
								}#if end
14939
 
15174
 
14940
							#函式說明:
15175
							#函式說明:
14941
							#呼叫shell執行系統命令,並取得回傳的內容.
15176
							#呼叫shell執行系統命令,並取得回傳的內容.
14942
							#回傳結果:
15177
							#回傳結果:
Line 14998... Line 15233...
14998
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15233
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
14999
							$callShell=external::callShell($conf["external::callShell"]);
15234
							$callShell=external::callShell($conf["external::callShell"]);
15000
							unset($conf["external::callShell"]);
15235
							unset($conf["external::callShell"]);
15001
 
15236
 
15002
							#如果運行失敗
15237
							#如果運行失敗
15003
							if($callShell["status"]==="false")
15238
							if($callShell["status"]==="false"){
15004
							{
15239
							
15005
								#設置執行失敗
15240
								#設置執行失敗
15006
								$result["status"]="false";
15241
								$result["status"]="false";
15007
 
15242
 
15008
								#設置執行錯誤
15243
								#設置執行錯誤
15009
								$result["error"]=$callShell;
15244
								$result["error"]=$callShell;
15010
 
15245
 
15011
								#回傳結果
15246
								#回傳結果
15012
								return $result;
15247
								return $result;
15013
 
15248
 
15014
							}#if end
15249
								}#if end
15015
 
15250
 
15016
							#印出執行的cmd
15251
							#印出執行的cmd
15017
							echo "cmd:".$callShell["cmd"].PHP_EOL;
15252
							echo "cmd:".$callShell["cmd"].PHP_EOL;
15018
 
15253
 
15019
							#印出執行後的回傳代碼
15254
							#印出執行後的回傳代碼
Line 15045... Line 15280...
15045
									#無.
15280
									#無.
15046
									#備註:
15281
									#備註:
15047
									#無.
15282
									#無.
15048
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15283
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15049
									unset($conf["stringProcess::clearStrSymbol"]);
15284
									unset($conf["stringProcess::clearStrSymbol"]);
15050
									
15285
 
15051
									#如果運行失敗
15286
									#如果運行失敗
15052
									if($clearStrSymbol["status"]==="false")
15287
									if($clearStrSymbol["status"]==="false"){
15053
									{
-
 
15054
										#設置執行失敗
15288
										#設置執行失敗
15055
										$result["status"]="false";
15289
										$result["status"]="false";
15056
										
15290
 
15057
										#設置執行失敗訊息
15291
										#設置執行失敗訊息
15058
										$result["error"]=$clearStrSymbol;
15292
										$result["error"]=$clearStrSymbol;
15059
										
15293
 
15060
										#回傳結果
15294
										#回傳結果
15061
										return $result;
15295
										return $result;
15062
 
15296
 
15063
									}#if end
15297
										}#if end
15064
									
15298
 
15065
									echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法複製".PHP_EOL;
15299
									echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法複製".PHP_EOL;
15066
 
15300
 
15067
									#繼續讓使用者輸入要commit的檔案
15301
									#繼續讓使用者輸入要commit的檔案
15068
									break 2;
15302
									break 2;
15069
 
15303
 
Line 15080... Line 15314...
15080
								#讓使用者繼續輸入要commit的項目
15314
								#讓使用者繼續輸入要commit的項目
15081
								break 2;
15315
								break 2;
15082
 
15316
 
15083
								}#if end
15317
								}#if end
15084
 
15318
 
15085
							#執行 svn cpoy 的指令
15319
							#執行 svn copy 的指令
15086
							#函式說明:
15320
							#函式說明:
15087
							#呼叫shell執行系統命令,並取得回傳的內容.
15321
							#呼叫shell執行系統命令,並取得回傳的內容.
15088
							#回傳結果:
15322
							#回傳結果:
15089
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15323
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15090
							#$result["error"],錯誤訊息陣列.
15324
							#$result["error"],錯誤訊息陣列.
Line 15144... Line 15378...
15144
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15378
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15145
							$callShell=external::callShell($conf["external::callShell"]);
15379
							$callShell=external::callShell($conf["external::callShell"]);
15146
							unset($conf["external::callShell"]);
15380
							unset($conf["external::callShell"]);
15147
 
15381
 
15148
							#如果運行失敗
15382
							#如果運行失敗
15149
							if($callShell["status"]==="false")
15383
							if($callShell["status"]==="false"){
15150
							{
15384
								
15151
								#設置執行失敗
15385
								#設置執行失敗
15152
								$result["status"]="false";
15386
								$result["status"]="false";
15153
 
15387
 
15154
								#設置執行錯誤
15388
								#設置執行錯誤
15155
								$result["error"]=$callShell;
15389
								$result["error"]=$callShell;
15156
 
15390
 
15157
								#回傳結果
15391
								#回傳結果
15158
								return $result;
15392
								return $result;
15159
								
15393
 
15160
							}#if end
15394
								}#if end
15161
 
15395
 
15162
							#印出執行的cmd
15396
							#印出執行的cmd
15163
							echo "cmd:".$callShell["cmd"].PHP_EOL;
15397
							echo "cmd:".$callShell["cmd"].PHP_EOL;
15164
 
15398
 
15165
							#印出執行後的回傳代碼
15399
							#印出執行後的回傳代碼
Line 15222... Line 15456...
15222
							#無.
15456
							#無.
15223
							#備註:
15457
							#備註:
15224
							#無.
15458
							#無.
15225
							$conf["stringProcess::clearStrSymbol"]["str"]=$argv[1];
15459
							$conf["stringProcess::clearStrSymbol"]["str"]=$argv[1];
15226
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15460
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15227
							unset($conf["stringProcess::clearStrSymbol"]);	
15461
							unset($conf["stringProcess::clearStrSymbol"]);
15228
 
15462
 
15229
							#如果運行失敗
15463
							#如果運行失敗
15230
							if($clearStrSymbol["status"]==="false"){
15464
							if($clearStrSymbol["status"]==="false"){
15231
							
15465
 
15232
								#設置執行失敗
15466
								#設置執行失敗
15233
								$result["status"]="false";
15467
								$result["status"]="false";
15234
								
15468
 
15235
								#設置執行失敗訊息
15469
								#設置執行失敗訊息
15236
								$result["error"]=$clearStrSymbol;
15470
								$result["error"]=$clearStrSymbol;
15237
								
15471
 
15238
								#回傳結果
15472
								#回傳結果
15239
								return $result;
15473
								return $result;
15240
 
15474
 
15241
								}#if end
15475
								}#if end
15242
 
15476
 
15243
							#如果存在第二個參數的檔案
15477
							#如果存在第二個參數的檔案
15244
							if(file_exists($clearStrSymbol["content"])){
15478
							if(file_exists($clearStrSymbol["content"])){
15245
							
15479
 
15246
								#執行command
15480
								#執行command
15247
								#函式說明:
15481
								#函式說明:
15248
								#呼叫shell執行系統命令,並取得回傳的內容.
15482
								#呼叫shell執行系統命令,並取得回傳的內容.
15249
								#回傳結果:
15483
								#回傳結果:
15250
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15484
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 15306... Line 15540...
15306
								$callShell=external::callShell($conf["external::callShell"]);
15540
								$callShell=external::callShell($conf["external::callShell"]);
15307
								unset($conf["external::callShell"]);
15541
								unset($conf["external::callShell"]);
15308
 
15542
 
15309
								#如果運行失敗
15543
								#如果運行失敗
15310
								if($callShell["status"]==="false"){
15544
								if($callShell["status"]==="false"){
15311
								
15545
 
15312
									#設置執行失敗
15546
									#設置執行失敗
15313
									$result["status"]="false";
15547
									$result["status"]="false";
15314
 
15548
 
15315
									#設置執行錯誤
15549
									#設置執行錯誤
15316
									$result["error"]=$callShell;
15550
									$result["error"]=$callShell;
Line 15339... Line 15573...
15339
 
15573
 
15340
								#繼續讓使用者輸入要commit的檔案
15574
								#繼續讓使用者輸入要commit的檔案
15341
								break 2;
15575
								break 2;
15342
 
15576
 
15343
								}#if end
15577
								}#if end
15344
								
15578
 
15345
							#反之
15579
							#反之
15346
							else{
15580
							else{
15347
							
15581
 
15348
								#提示錯誤
15582
								#提示錯誤
15349
								echo "檔案「".$clearStrSymbol["content"]."」不存在".PHP_EOL;
15583
								echo "檔案「".$clearStrSymbol["content"]."」不存在".PHP_EOL;
15350
								
15584
 
15351
								#繼續讓使用者輸入要commit的檔案
15585
								#繼續讓使用者輸入要commit的檔案
15352
								break 2;
15586
								break 2;
15353
							
15587
 
15354
								}#else end
15588
								}#else end
15355
 
15589
 
15356
							#跳出switch
15590
							#跳出switch
15357
							break;
15591
							break;
15358
 
15592
 
Line 15375... Line 15609...
15375
							#參考資料:
15609
							#參考資料:
15376
							#無.
15610
							#無.
15377
							#備註:
15611
							#備註:
15378
							#無.
15612
							#無.
15379
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15613
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15380
							
15614
 
15381
							#如果運行失敗
15615
							#如果運行失敗
15382
							if($clearStrSymbol["status"]==="false")
15616
							if($clearStrSymbol["status"]==="false"){
15383
							{
15617
								
15384
								#設置執行失敗
15618
								#設置執行失敗
15385
								$result["status"]="false";
15619
								$result["status"]="false";
15386
								
15620
 
15387
								#設置執行失敗訊息
15621
								#設置執行失敗訊息
15388
								$result["error"]=$clearStrSymbol;
15622
								$result["error"]=$clearStrSymbol;
15389
								
15623
 
15390
								#回傳結果
15624
								#回傳結果
15391
								return $result;
15625
								return $result;
15392
 
15626
 
15393
							}#if end
15627
								}#if end
15394
							
15628
 
15395
							#若第二個參數的名稱檔案存在
15629
							#若第二個參數的名稱檔案存在
15396
							if(file_exists($clearStrSymbol["content"])){
15630
							if(file_exists($clearStrSymbol["content"])){
15397
 
15631
 
15398
								#若該檔案存在於要新增檔案的清單中
15632
								#若該檔案存在於要新增檔案的清單中
15399
								if(in_array($argv[1],$fileAdded)){
15633
								if(in_array($argv[1],$fileAdded)){
15400
									
15634
 
15401
									#函式說明:
15635
									#函式說明:
15402
									#清除字串的「"」或「'」符號.
15636
									#清除字串的「"」或「'」符號.
15403
									#回傳結果:
15637
									#回傳結果:
15404
									#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
15638
									#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
15405
									#$result["function"],當前執行的函式內容.
15639
									#$result["function"],當前執行的函式內容.
Line 15416... Line 15650...
15416
									#無.
15650
									#無.
15417
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15651
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15418
									unset($conf["stringProcess::clearStrSymbol"]);
15652
									unset($conf["stringProcess::clearStrSymbol"]);
15419
 
15653
 
15420
									#如果運行失敗
15654
									#如果運行失敗
15421
									if($clearStrSymbol["status"]==="false")
15655
									if($clearStrSymbol["status"]==="false"){
15422
									{
15656
									
15423
										#設置執行失敗
15657
										#設置執行失敗
15424
										$result["status"]="false";
15658
										$result["status"]="false";
15425
										
15659
 
15426
										#設置執行失敗訊息
15660
										#設置執行失敗訊息
15427
										$result["error"]=$clearStrSymbol;
15661
										$result["error"]=$clearStrSymbol;
15428
										
15662
 
15429
										#回傳結果
15663
										#回傳結果
15430
										return $result;
15664
										return $result;
15431
 
15665
 
15432
									}#if end
15666
										}#if end
15433
 
15667
 
15434
									#提示要該檔案已經在移除的清單了
15668
									#提示要該檔案已經在移除的清單了
15435
									echo "檔案「".$clearStrSymbol["content"]."」已經在要新增的清單裡面了".PHP_EOL;
15669
									echo "檔案「".$clearStrSymbol["content"]."」已經在要新增的清單裡面了".PHP_EOL;
15436
 
15670
 
15437
									#繼續讓使用者輸入要commit的檔案
15671
									#繼續讓使用者輸入要commit的檔案
Line 15541... Line 15775...
15541
									#可省略參數:
15775
									#可省略參數:
15542
									#無.
15776
									#無.
15543
									#參考資料:
15777
									#參考資料:
15544
									#無.
15778
									#無.
15545
									#備註:
15779
									#備註:
15546
									#無.									
15780
									#無.
15547
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15781
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15548
									unset($conf["stringProcess::clearStrSymbol"]);
15782
									unset($conf["stringProcess::clearStrSymbol"]);
15549
 
15783
 
15550
									#如果執行失敗
15784
									#如果執行失敗
15551
									if($clearStrSymbol["status"]==="false"){
15785
									if($clearStrSymbol["status"]==="false"){
15552
 
15786
 
15553
										#設置執行失敗
15787
										#設置執行失敗
15554
										$result["status"]="false";
15788
										$result["status"]="false";
15555
										
15789
 
15556
										#設置執行失敗訊息
15790
										#設置執行失敗訊息
15557
										$result["error"]=$clearStrSymbol;
15791
										$result["error"]=$clearStrSymbol;
15558
										
15792
 
15559
										#回傳結果
15793
										#回傳結果
15560
										return $result;
15794
										return $result;
15561
 
15795
 
15562
										}#if end
15796
										}#if end
15563
 
15797
 
Line 15582... Line 15816...
15582
									#可省略參數:
15816
									#可省略參數:
15583
									#無.
15817
									#無.
15584
									#參考資料:
15818
									#參考資料:
15585
									#無.
15819
									#無.
15586
									#備註:
15820
									#備註:
15587
									#無									
15821
									#無
15588
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15822
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15589
									unset($conf["stringProcess::clearStrSymbol"]);
15823
									unset($conf["stringProcess::clearStrSymbol"]);
15590
 
15824
 
15591
									#如果執行失敗
15825
									#如果執行失敗
15592
									if($clearStrSymbol["status"]==="false"){
15826
									if($clearStrSymbol["status"]==="false"){
15593
 
15827
 
15594
										#設置執行失敗
15828
										#設置執行失敗
15595
										$result["status"]="false";
15829
										$result["status"]="false";
15596
										
15830
 
15597
										#設置執行失敗訊息
15831
										#設置執行失敗訊息
15598
										$result["error"]=$clearStrSymbol;
15832
										$result["error"]=$clearStrSymbol;
15599
										
15833
 
15600
										#回傳結果
15834
										#回傳結果
15601
										return $result;
15835
										return $result;
15602
 
15836
 
15603
										}#if end
15837
										}#if end
15604
 
15838
 
Line 15641... Line 15875...
15641
							#如果執行失敗
15875
							#如果執行失敗
15642
							if($clearStrSymbol["status"]==="false"){
15876
							if($clearStrSymbol["status"]==="false"){
15643
 
15877
 
15644
								#設置執行失敗
15878
								#設置執行失敗
15645
								$result["status"]="false";
15879
								$result["status"]="false";
15646
								
15880
 
15647
								#設置執行失敗訊息
15881
								#設置執行失敗訊息
15648
								$result["error"]=$clearStrSymbol;
15882
								$result["error"]=$clearStrSymbol;
15649
								
15883
 
15650
								#回傳結果
15884
								#回傳結果
15651
								return $result;
15885
								return $result;
15652
								
15886
 
15653
								}#if end
15887
								}#if end
15654
 
15888
 
15655
							#函式說明:
15889
							#函式說明:
15656
							#檢查多個檔案與資料夾是否存在.
15890
							#檢查多個檔案與資料夾是否存在.
15657
							#回傳的結果:
15891
							#回傳的結果:
Line 15682... Line 15916...
15682
							#備註:
15916
							#備註:
15683
							#函數file_exists檢查的路徑為檔案系統的路徑
15917
							#函數file_exists檢查的路徑為檔案系統的路徑
15684
							#$result["varName"][$i]結果未實作
15918
							#$result["varName"][$i]結果未實作
15685
							$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
15919
							$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
15686
							unset($conf["fileAccess::checkMultiFileExist"]);
15920
							unset($conf["fileAccess::checkMultiFileExist"]);
15687
							
15921
 
15688
							#如果執行失敗
15922
							#如果執行失敗
15689
							if($checkMultiFileExist["status"]==="false"){
15923
							if($checkMultiFileExist["status"]==="false"){
15690
							
15924
 
15691
								#設置執行失敗
15925
								#設置執行失敗
15692
								$result["status"]="false";
15926
								$result["status"]="false";
15693
								
15927
 
15694
								#設置執行失敗訊息
15928
								#設置執行失敗訊息
15695
								$result["error"]=$checkMultiFileExist;
15929
								$result["error"]=$checkMultiFileExist;
15696
								
15930
 
15697
								#回傳結果
15931
								#回傳結果
15698
								return $result;
15932
								return $result;
15699
							
15933
 
15700
								}#if end
15934
								}#if end
15701
								
15935
 
15702
							#如果檔案不存在
15936
							#如果檔案不存在
15703
							if($checkMultiFileExist["allExist"]==="false"){
15937
							if($checkMultiFileExist["allExist"]==="false"){
15704
							
15938
 
15705
								#函式說明:
15939
								#函式說明:
15706
								#清除字串的「"」或「'」符號.
15940
								#清除字串的「"」或「'」符號.
15707
								#回傳結果:
15941
								#回傳結果:
15708
								#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
15942
								#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
15709
								#$result["function"],當前執行的函式內容.
15943
								#$result["function"],當前執行的函式內容.
Line 15715... Line 15949...
15715
								#可省略參數:
15949
								#可省略參數:
15716
								#無.
15950
								#無.
15717
								#參考資料:
15951
								#參考資料:
15718
								#無.
15952
								#無.
15719
								#備註:
15953
								#備註:
15720
								#無.								
15954
								#無.
15721
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15955
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15722
								unset($conf["stringProcess::clearStrSymbol"]);
15956
								unset($conf["stringProcess::clearStrSymbol"]);
15723
 
15957
 
15724
								#如果運行失敗
15958
								#如果運行失敗
15725
								if($clearStrSymbol["status"]==="false")
15959
								if($clearStrSymbol["status"]==="false"){
15726
								{
15960
								
15727
									#設置執行失敗
15961
									#設置執行失敗
15728
									$result["status"]="false";
15962
									$result["status"]="false";
15729
									
15963
 
15730
									#設置執行失敗訊息
15964
									#設置執行失敗訊息
15731
									$result["error"]=$clearStrSymbol;
15965
									$result["error"]=$clearStrSymbol;
15732
									
15966
 
15733
									#回傳結果
15967
									#回傳結果
15734
									return $result;
15968
									return $result;
15735
 
15969
 
15736
								}#if end
15970
									}#if end
15737
 
15971
 
15738
								#提示新增檔案到版本控制失敗
15972
								#提示新增檔案到版本控制失敗
15739
								echo "檔案「".$clearStrSymbol["content"]."」不存在".PHP_EOL;
15973
								echo "檔案「".$clearStrSymbol["content"]."」不存在".PHP_EOL;
15740
 
15974
 
15741
								#繼續讓使用者輸入要commit的檔案
15975
								#繼續讓使用者輸入要commit的檔案
15742
								break 2;
15976
								break 2;
15743
							
15977
 
15744
								}#if end
15978
								}#if end
15745
							
15979
 
15746
							#若第二個參數的名稱檔案存在
15980
							#若第二個參數的名稱檔案存在
15747
							else{
15981
							else{
15748
 
15982
 
15749
								#如果要移除的檔案是本次要新增的版本控制的檔案
15983
								#如果要移除的檔案是本次要新增的版本控制的檔案
15750
								if(in_array($argv[1],$fileAdded)){
15984
								if(in_array($argv[1],$fileAdded)){
Line 15760... Line 15994...
15760
								#如果該檔案已經是要移除的了
15994
								#如果該檔案已經是要移除的了
15761
								if(in_array($argv[1],$fileShouldBeDeleted)){
15995
								if(in_array($argv[1],$fileShouldBeDeleted)){
15762
 
15996
 
15763
									#提示要該檔案已經在移除的清單了
15997
									#提示要該檔案已經在移除的清單了
15764
									echo "檔案「".$clearStrSymbol["content"]."」已經在移除的清單裡面了".PHP_EOL;
15998
									echo "檔案「".$clearStrSymbol["content"]."」已經在移除的清單裡面了".PHP_EOL;
15765
									
15999
 
15766
									#繼續讓使用者輸入要commit的檔案
16000
									#繼續讓使用者輸入要commit的檔案
15767
									break 2;
16001
									break 2;
15768
 
16002
 
15769
									}#if end
16003
									}#if end
15770
 
16004
 
Line 15830... Line 16064...
15830
								#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16064
								#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15831
								$callShell=external::callShell($conf["external::callShell"]);
16065
								$callShell=external::callShell($conf["external::callShell"]);
15832
								unset($conf["external::callShell"]);
16066
								unset($conf["external::callShell"]);
15833
 
16067
 
15834
								#如果運行失敗
16068
								#如果運行失敗
15835
								if($callShell["status"]==="false")
16069
								if($callShell["status"]==="false"){
15836
								{
16070
								
15837
									#設置執行失敗
16071
									#設置執行失敗
15838
									$result["status"]="false";
16072
									$result["status"]="false";
15839
 
16073
 
15840
									#設置執行錯誤
16074
									#設置執行錯誤
15841
									$result["error"]=$callShell;
16075
									$result["error"]=$callShell;
15842
 
16076
 
15843
									#回傳結果
16077
									#回傳結果
15844
									return $result;
16078
									return $result;
15845
 
16079
 
15846
								}#if end
16080
									}#if end
15847
 
16081
 
15848
								#印出執行的cmd
16082
								#印出執行的cmd
15849
								echo "cmd:".$callShell["cmd"].PHP_EOL;
16083
								echo "cmd:".$callShell["cmd"].PHP_EOL;
15850
 
16084
 
15851
								#印出執行後的回傳代碼
16085
								#印出執行後的回傳代碼
Line 15861... Line 16095...
15861
									sscanf($callShell["output"][0],"%s %s",$sta,$fi);
16095
									sscanf($callShell["output"][0],"%s %s",$sta,$fi);
15862
 
16096
 
15863
									#如果狀態等於 ?
16097
									#如果狀態等於 ?
15864
									if($sta==="?"){
16098
									if($sta==="?"){
15865
 
16099
 
15866
										
16100
 
15867
										#函式說明:
16101
										#函式說明:
15868
										#清除字串的「"」或「'」符號.
16102
										#清除字串的「"」或「'」符號.
15869
										#回傳結果:
16103
										#回傳結果:
15870
										#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
16104
										#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
15871
										#$result["function"],當前執行的函式內容.
16105
										#$result["function"],當前執行的函式內容.
Line 15879... Line 16113...
15879
										#參考資料:
16113
										#參考資料:
15880
										#無.
16114
										#無.
15881
										#備註:
16115
										#備註:
15882
										#無.
16116
										#無.
15883
										$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16117
										$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15884
										unset($conf["stringProcess::clearStrSymbol"]);	
16118
										unset($conf["stringProcess::clearStrSymbol"]);
15885
										
16119
 
15886
										#如果運行失敗
16120
										#如果運行失敗
15887
										if($clearStrSymbol["status"]==="false")
16121
										if($clearStrSymbol["status"]==="false"){
15888
										{
16122
										
15889
											#設置執行失敗
16123
											#設置執行失敗
15890
											$result["status"]="false";
16124
											$result["status"]="false";
15891
											
16125
 
15892
											#設置執行失敗訊息
16126
											#設置執行失敗訊息
15893
											$result["error"]=$clearStrSymbol;
16127
											$result["error"]=$clearStrSymbol;
15894
											
16128
 
15895
											#回傳結果
16129
											#回傳結果
15896
											return $result;
16130
											return $result;
15897
 
16131
 
15898
										}#if end
16132
											}#if end
15899
										
16133
 
15900
										#提示新增檔案到版本控制失敗
16134
										#提示新增檔案到版本控制失敗
15901
										echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法移除之".PHP_EOL;
16135
										echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法移除之".PHP_EOL;
15902
										
16136
 
15903
										#繼續讓使用者輸入要commit的檔案
16137
										#繼續讓使用者輸入要commit的檔案
15904
										break 2;
16138
										break 2;
15905
 
16139
 
15906
										}#if end
16140
										}#if end
15907
 
16141
 
Line 15967... Line 16201...
15967
								#可省略參數:
16201
								#可省略參數:
15968
								#無.
16202
								#無.
15969
								#參考資料:
16203
								#參考資料:
15970
								#無.
16204
								#無.
15971
								#備註:
16205
								#備註:
15972
								#無.								
16206
								#無.
15973
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16207
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
15974
								unset($conf["stringProcess::clearStrSymbol"]);
16208
								unset($conf["stringProcess::clearStrSymbol"]);
15975
								
16209
 
15976
								#如果運行失敗
16210
								#如果運行失敗
15977
								if($clearStrSymbol["status"]==="false")
16211
								if($clearStrSymbol["status"]==="false"){
15978
								{
16212
								
15979
									#設置執行失敗
16213
									#設置執行失敗
15980
									$result["status"]="false";
16214
									$result["status"]="false";
15981
									
16215
 
15982
									#設置執行失敗訊息
16216
									#設置執行失敗訊息
15983
									$result["error"]=$clearStrSymbol;
16217
									$result["error"]=$clearStrSymbol;
15984
									
16218
 
15985
									#回傳結果
16219
									#回傳結果
15986
									return $result;
16220
									return $result;
15987
 
16221
 
15988
								}#if end
16222
									}#if end
15989
								
16223
 
15990
								#提示目已經取消移除
16224
								#提示目已經取消移除
15991
								echo "檔案「".$clearStrSymbol["content"]."」已不在要移除的清單裡面了".PHP_EOL;
16225
								echo "檔案「".$clearStrSymbol["content"]."」已不在要移除的清單裡面了".PHP_EOL;
15992
 
16226
 
15993
								#繼續讓使用者輸入要commit的檔案
16227
								#繼續讓使用者輸入要commit的檔案
15994
								break 2;
16228
								break 2;
Line 16008... Line 16242...
16008
							#可省略參數:
16242
							#可省略參數:
16009
							#無.
16243
							#無.
16010
							#參考資料:
16244
							#參考資料:
16011
							#無.
16245
							#無.
16012
							#備註:
16246
							#備註:
16013
							#無.							
16247
							#無.
16014
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16248
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16015
							unset($conf["stringProcess::clearStrSymbol"]);
16249
							unset($conf["stringProcess::clearStrSymbol"]);
16016
 
16250
 
16017
							#如果運行失敗
16251
							#如果運行失敗
16018
							if($clearStrSymbol["status"]==="false")
16252
							if($clearStrSymbol["status"]==="false"){
16019
							{
16253
							
16020
								#設置執行失敗
16254
								#設置執行失敗
16021
								$result["status"]="false";
16255
								$result["status"]="false";
16022
								
16256
 
16023
								#設置執行失敗訊息
16257
								#設置執行失敗訊息
16024
								$result["error"]=$clearStrSymbol;
16258
								$result["error"]=$clearStrSymbol;
16025
								
16259
 
16026
								#回傳結果
16260
								#回傳結果
16027
								return $result;
16261
								return $result;
16028
 
16262
 
16029
							}#if end
16263
								}#if end
16030
 
16264
 
16031
							#提示目標沒有在要移除的清單裡面
16265
							#提示目標沒有在要移除的清單裡面
16032
							echo "檔案「".$clearStrSymbol["content"]."」不在要移除的清單裡面".PHP_EOL;
16266
							echo "檔案「".$clearStrSymbol["content"]."」不在要移除的清單裡面".PHP_EOL;
16033
 
16267
 
16034
							#繼續讓使用者輸入要commit的檔案
16268
							#繼續讓使用者輸入要commit的檔案
Line 16133... Line 16367...
16133
										#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16367
										#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16134
										$callShell=external::callShell($conf["external::callShell"]);
16368
										$callShell=external::callShell($conf["external::callShell"]);
16135
										unset($conf["external::callShell"]);
16369
										unset($conf["external::callShell"]);
16136
 
16370
 
16137
										#如果運行失敗
16371
										#如果運行失敗
16138
										if($callShell["status"]==="false")
16372
										if($callShell["status"]==="false"){
16139
										{
16373
										
16140
											#設置執行失敗
16374
											#設置執行失敗
16141
											$result["status"]="false";
16375
											$result["status"]="false";
16142
 
16376
 
16143
											#設置執行錯誤
16377
											#設置執行錯誤
16144
											$result["error"]=$callShell;
16378
											$result["error"]=$callShell;
16145
 
16379
 
16146
											#回傳結果
16380
											#回傳結果
16147
											return $result;
16381
											return $result;
16148
 
16382
 
16149
										}#if end
16383
											}#if end
16150
 
16384
 
16151
										#印出執行的cmd
16385
										#印出執行的cmd
16152
										echo "cmd:".$callShell["cmd"].PHP_EOL;
16386
										echo "cmd:".$callShell["cmd"].PHP_EOL;
16153
 
16387
 
16154
										#印出執行後的回傳代碼
16388
										#印出執行後的回傳代碼
Line 16179... Line 16413...
16179
								#無.
16413
								#無.
16180
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16414
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16181
								unset($conf["stringProcess::clearStrSymbol"]);
16415
								unset($conf["stringProcess::clearStrSymbol"]);
16182
 
16416
 
16183
								#如果運行失敗
16417
								#如果運行失敗
16184
								if($clearStrSymbol["status"]==="false")
16418
								if($clearStrSymbol["status"]==="false"){
16185
								{
16419
								
16186
									#設置執行失敗
16420
									#設置執行失敗
16187
									$result["status"]="false";
16421
									$result["status"]="false";
16188
									
16422
 
16189
									#設置執行失敗訊息
16423
									#設置執行失敗訊息
16190
									$result["error"]=$clearStrSymbol;
16424
									$result["error"]=$clearStrSymbol;
16191
									
16425
 
16192
									#回傳結果
16426
									#回傳結果
16193
									return $result;
16427
									return $result;
16194
									
16428
	
16195
								}#if end
16429
									}#if end
16196
 
16430
 
16197
								#提示目已經取消移除
16431
								#提示目已經取消移除
16198
								echo "檔案「".$clearStrSymbol["content"]."」已不在要commit的清單裡面了".PHP_EOL;
16432
								echo "檔案「".$clearStrSymbol["content"]."」已不在要commit的清單裡面了".PHP_EOL;
16199
 
16433
 
16200
								}#if end
16434
								}#if end
Line 16220... Line 16454...
16220
								#無.
16454
								#無.
16221
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16455
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16222
								unset($conf["stringProcess::clearStrSymbol"]);
16456
								unset($conf["stringProcess::clearStrSymbol"]);
16223
 
16457
 
16224
								#如果運行失敗
16458
								#如果運行失敗
16225
								if($clearStrSymbol["status"]==="false")
16459
								if($clearStrSymbol["status"]==="false"){
16226
								{
16460
								
16227
									#設置執行失敗
16461
									#設置執行失敗
16228
									$result["status"]="false";
16462
									$result["status"]="false";
16229
									
16463
 
16230
									#設置執行失敗訊息
16464
									#設置執行失敗訊息
16231
									$result["error"]=$clearStrSymbol;
16465
									$result["error"]=$clearStrSymbol;
16232
									
16466
 
16233
									#回傳結果
16467
									#回傳結果
16234
									return $result;
16468
									return $result;
16235
 
16469
 
16236
								}#if end
16470
									}#if end
16237
 
16471
 
16238
								#提示目標沒有在要移除的清單裡面
16472
								#提示目標沒有在要移除的清單裡面
16239
								echo "檔案「".$clearStrSymbol["content"]."」不在要commit的清單裡面".PHP_EOL;
16473
								echo "檔案「".$clearStrSymbol["content"]."」不在要commit的清單裡面".PHP_EOL;
16240
 
16474
 
16241
								}#else end
16475
								}#else end
Line 16266... Line 16500...
16266
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16500
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16267
							unset($conf["stringProcess::clearStrSymbol"]);
16501
							unset($conf["stringProcess::clearStrSymbol"]);
16268
 
16502
 
16269
							#如果運行失敗
16503
							#如果運行失敗
16270
							if($clearStrSymbol["status"]==="false"){
16504
							if($clearStrSymbol["status"]==="false"){
16271
							
16505
 
16272
								#設置執行失敗
16506
								#設置執行失敗
16273
								$result["status"]="false";
16507
								$result["status"]="false";
16274
								
16508
 
16275
								#設置執行失敗訊息
16509
								#設置執行失敗訊息
16276
								$result["error"]=$clearStrSymbol;
16510
								$result["error"]=$clearStrSymbol;
16277
								
16511
 
16278
								#回傳結果
16512
								#回傳結果
16279
								return $result;
16513
								return $result;
16280
 
16514
 
16281
								}#if end
16515
								}#if end
16282
 
16516
 
Line 16354... Line 16588...
16354
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16588
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16355
							$callShell=external::callShell($conf["external::callShell"]);
16589
							$callShell=external::callShell($conf["external::callShell"]);
16356
							unset($conf["external::callShell"]);
16590
							unset($conf["external::callShell"]);
16357
 
16591
 
16358
							#如果運行失敗
16592
							#如果運行失敗
16359
							if($callShell["status"]==="false")
16593
							if($callShell["status"]==="false"){
16360
							{
16594
							
16361
								#設置執行失敗
16595
								#設置執行失敗
16362
								$result["status"]="false";
16596
								$result["status"]="false";
16363
 
16597
 
16364
								#設置執行錯誤
16598
								#設置執行錯誤
16365
								$result["error"]=$callShell;
16599
								$result["error"]=$callShell;
16366
 
16600
 
16367
								#回傳結果
16601
								#回傳結果
16368
								return $result;
16602
								return $result;
16369
 
16603
 
16370
							}#if end
16604
								}#if end
16371
 
16605
 
16372
							#印出執行的cmd
16606
							#印出執行的cmd
16373
							echo "cmd:".$callShell["cmd"].PHP_EOL;
16607
							echo "cmd:".$callShell["cmd"].PHP_EOL;
16374
 
16608
 
16375
							#印出執行後的回傳代碼
16609
							#印出執行後的回傳代碼
Line 16402... Line 16636...
16402
									#無.
16636
									#無.
16403
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16637
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16404
									unset($conf["stringProcess::clearStrSymbol"]);
16638
									unset($conf["stringProcess::clearStrSymbol"]);
16405
 
16639
 
16406
									#如果運行失敗
16640
									#如果運行失敗
16407
									if($clearStrSymbol["status"]==="false")
16641
									if($clearStrSymbol["status"]==="false"){
16408
									{
16642
									
16409
										#設置執行失敗
16643
										#設置執行失敗
16410
										$result["status"]="false";
16644
										$result["status"]="false";
16411
										
16645
 
16412
										#設置執行失敗訊息
16646
										#設置執行失敗訊息
16413
										$result["error"]=$clearStrSymbol;
16647
										$result["error"]=$clearStrSymbol;
16414
										
16648
 
16415
										#回傳結果
16649
										#回傳結果
16416
										return $result;
16650
										return $result;
16417
 
16651
 
16418
									}#if end
16652
										}#if end
16419
 
16653
 
16420
									#提示新增檔案到版本控制失敗
16654
									#提示新增檔案到版本控制失敗
16421
									echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法查詢commit記錄".PHP_EOL;
16655
									echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法查詢commit記錄".PHP_EOL;
16422
 
16656
 
16423
									#繼續讓使用者輸入要commit的檔案
16657
									#繼續讓使用者輸入要commit的檔案
Line 16480... Line 16714...
16480
							$callShell=external::callShell($conf["external::callShell"]);
16714
							$callShell=external::callShell($conf["external::callShell"]);
16481
							unset($conf["external::callShell"]);
16715
							unset($conf["external::callShell"]);
16482
 
16716
 
16483
							#如果運行失敗
16717
							#如果運行失敗
16484
							if($callShell["status"]==="false"){
16718
							if($callShell["status"]==="false"){
16485
								
16719
 
16486
								#設置執行失敗
16720
								#設置執行失敗
16487
								$result["status"]="false";
16721
								$result["status"]="false";
16488
 
16722
 
16489
								#設置執行錯誤
16723
								#設置執行錯誤
16490
								$result["error"]=$callShell;
16724
								$result["error"]=$callShell;
16491
 
16725
 
16492
								#回傳結果
16726
								#回傳結果
16493
								return $result;
16727
								return $result;
16494
								
16728
 
16495
								}#if end
16729
								}#if end
16496
 
16730
 
16497
							#印出執行的cmd
16731
							#印出執行的cmd
16498
							echo "cmd:".$callShell["cmd"].PHP_EOL;
16732
							echo "cmd:".$callShell["cmd"].PHP_EOL;
16499
 
16733
 
Line 16641... Line 16875...
16641
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16875
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16642
							$callShell=external::callShell($conf["external::callShell"]);
16876
							$callShell=external::callShell($conf["external::callShell"]);
16643
							unset($conf["external::callShell"]);
16877
							unset($conf["external::callShell"]);
16644
 
16878
 
16645
							#如果運行失敗
16879
							#如果運行失敗
16646
							if($callShell["status"]==="false")
16880
							if($callShell["status"]==="false"){
16647
							{
16881
							
16648
								#設置執行失敗
16882
								#設置執行失敗
16649
								$result["status"]="false";
16883
								$result["status"]="false";
16650
 
16884
 
16651
								#設置執行錯誤
16885
								#設置執行錯誤
16652
								$result["error"]=$callShell;
16886
								$result["error"]=$callShell;
16653
 
16887
 
16654
								#回傳結果
16888
								#回傳結果
16655
								return $result;
16889
								return $result;
16656
 
16890
 
16657
							}#if end
16891
								}#if end
16658
 
16892
 
16659
							#印出執行的cmd
16893
							#印出執行的cmd
16660
							echo "cmd:".$callShell["cmd"].PHP_EOL;
16894
							echo "cmd:".$callShell["cmd"].PHP_EOL;
16661
 
16895
 
16662
							#印出執行後的回傳代碼
16896
							#印出執行後的回傳代碼
Line 16668... Line 16902...
16668
								#取得檔案的 status 與名稱
16902
								#取得檔案的 status 與名稱
16669
								sscanf($callShell["output"][0],"%s %s",$sta,$fi);
16903
								sscanf($callShell["output"][0],"%s %s",$sta,$fi);
16670
 
16904
 
16671
								#如果狀態等於 ?
16905
								#如果狀態等於 ?
16672
								if($sta==="?"){
16906
								if($sta==="?"){
16673
									
16907
 
16674
									#函式說明:
16908
									#函式說明:
16675
									#清除字串的「"」或「'」符號.
16909
									#清除字串的「"」或「'」符號.
16676
									#回傳結果:
16910
									#回傳結果:
16677
									#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
16911
									#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
16678
									#$result["function"],當前執行的函式內容.
16912
									#$result["function"],當前執行的函式內容.
Line 16687... Line 16921...
16687
									#無.
16921
									#無.
16688
									#備註:
16922
									#備註:
16689
									#無.
16923
									#無.
16690
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16924
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16691
									unset($conf["stringProcess::clearStrSymbol"]);
16925
									unset($conf["stringProcess::clearStrSymbol"]);
16692
									
16926
 
16693
									#如果運行失敗
16927
									#如果運行失敗
16694
									if($clearStrSymbol["status"]==="false")
16928
									if($clearStrSymbol["status"]==="false"){
16695
									{
16929
									
16696
										#設置執行失敗
16930
										#設置執行失敗
16697
										$result["status"]="false";
16931
										$result["status"]="false";
16698
										
16932
 
16699
										#設置執行失敗訊息
16933
										#設置執行失敗訊息
16700
										$result["error"]=$clearStrSymbol;
16934
										$result["error"]=$clearStrSymbol;
16701
										
16935
 
16702
										#回傳結果
16936
										#回傳結果
16703
										return $result;
16937
										return $result;
16704
 
16938
 
16705
									}#if end
16939
										}#if end
16706
									
16940
 
16707
									#提示不在版本控制裡面
16941
									#提示不在版本控制裡面
16708
									echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法還原".PHP_EOL;
16942
									echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法還原".PHP_EOL;
16709
 
16943
 
16710
									#繼續讓使用者輸入要commit的檔案
16944
									#繼續讓使用者輸入要commit的檔案
16711
									break 2;
16945
									break 2;
16712
								
16946
 
16713
									}#if end
16947
									}#if end
16714
 
16948
 
16715
								#如果狀態等於 ""
16949
								#如果狀態等於 ""
16716
								else if($sta===""){
16950
								else if($sta===""){
16717
 
16951
 
Line 16731... Line 16965...
16731
									#無.
16965
									#無.
16732
									#備註:
16966
									#備註:
16733
									#無.
16967
									#無.
16734
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16968
									$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16735
									unset($conf["stringProcess::clearStrSymbol"]);
16969
									unset($conf["stringProcess::clearStrSymbol"]);
16736
									
16970
 
16737
									#如果運行失敗
16971
									#如果運行失敗
16738
									if($clearStrSymbol["status"]==="false")
16972
									if($clearStrSymbol["status"]==="false"){
16739
									{
16973
									
16740
										#設置執行失敗
16974
										#設置執行失敗
16741
										$result["status"]="false";
16975
										$result["status"]="false";
16742
										
16976
 
16743
										#設置執行失敗訊息
16977
										#設置執行失敗訊息
16744
										$result["error"]=$clearStrSymbol;
16978
										$result["error"]=$clearStrSymbol;
16745
										
16979
 
16746
										#回傳結果
16980
										#回傳結果
16747
										return $result;
16981
										return $result;
16748
 
16982
 
16749
									}#if end
16983
										}#if end
16750
									
16984
 
16751
									#提示新增檔案到版本控制失敗
16985
									#提示新增檔案到版本控制失敗
16752
									echo "檔案「".$clearStrSymbol["content"]."」跟當前svn版本無差異".PHP_EOL;
16986
									echo "檔案「".$clearStrSymbol["content"]."」跟當前svn版本無差異".PHP_EOL;
16753
 
16987
 
16754
									#繼續讓使用者輸入要commit的檔案
16988
									#繼續讓使用者輸入要commit的檔案
16755
									break 2;
16989
									break 2;
Line 16820... Line 17054...
16820
									#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
17054
									#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16821
									$callShell=external::callShell($conf["external::callShell"]);
17055
									$callShell=external::callShell($conf["external::callShell"]);
16822
									unset($conf["external::callShell"]);
17056
									unset($conf["external::callShell"]);
16823
 
17057
 
16824
									#如果運行失敗
17058
									#如果運行失敗
16825
									if($callShell["status"]==="false")
17059
									if($callShell["status"]==="false"){
16826
									{
17060
									
16827
										#設置執行失敗
17061
										#設置執行失敗
16828
										$result["status"]="false";
17062
										$result["status"]="false";
16829
 
17063
 
16830
										#設置執行錯誤
17064
										#設置執行錯誤
16831
										$result["error"]=$callShell;
17065
										$result["error"]=$callShell;
16832
 
17066
 
16833
										#回傳結果
17067
										#回傳結果
16834
										return $result;
17068
										return $result;
16835
 
17069
 
16836
									}#if end
17070
										}#if end
16837
 
17071
 
16838
									#印出執行的cmd
17072
									#印出執行的cmd
16839
									echo "cmd:".$callShell["cmd"].PHP_EOL;
17073
									echo "cmd:".$callShell["cmd"].PHP_EOL;
16840
 
17074
 
16841
									#印出執行後的回傳代碼
17075
									#印出執行後的回傳代碼
Line 16844... Line 17078...
16844
									#如果運行正常
17078
									#如果運行正常
16845
									if($callShell["statusCode"]===0){
17079
									if($callShell["statusCode"]===0){
16846
 
17080
 
16847
										#如果該檔案是被rm指令刪除的
17081
										#如果該檔案是被rm指令刪除的
16848
										if($sta==="!"){
17082
										if($sta==="!"){
16849
											
17083
 
16850
											#函式說明:
17084
											#函式說明:
16851
											#清除字串的「"」或「'」符號.
17085
											#清除字串的「"」或「'」符號.
16852
											#回傳結果:
17086
											#回傳結果:
16853
											#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
17087
											#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
16854
											#$result["function"],當前執行的函式內容.
17088
											#$result["function"],當前執行的函式內容.
Line 16863... Line 17097...
16863
											#無.
17097
											#無.
16864
											#備註:
17098
											#備註:
16865
											#無.
17099
											#無.
16866
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17100
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16867
											unset($conf["stringProcess::clearStrSymbol"]);
17101
											unset($conf["stringProcess::clearStrSymbol"]);
16868
											
17102
 
16869
											#如果運行失敗
17103
											#如果運行失敗
16870
											if($clearStrSymbol["status"]==="false")
17104
											if($clearStrSymbol["status"]==="false"){
16871
											{
17105
												
16872
												#設置執行失敗
17106
												#設置執行失敗
16873
												$result["status"]="false";
17107
												$result["status"]="false";
16874
												
17108
 
16875
												#設置執行失敗訊息
17109
												#設置執行失敗訊息
16876
												$result["error"]=$clearStrSymbol;
17110
												$result["error"]=$clearStrSymbol;
16877
												
17111
 
16878
												#回傳結果
17112
												#回傳結果
16879
												return $result;
17113
												return $result;
16880
 
17114
 
16881
											}#if end
17115
												}#if end
16882
											
17116
 
16883
											#提示已經還原變更了
17117
											#提示已經還原變更了
16884
											echo "已還原被移除的「".$clearStrSymbol["content"]."」".PHP_EOL;
17118
											echo "已還原被移除的「".$clearStrSymbol["content"]."」".PHP_EOL;
16885
 
17119
 
16886
											#繼續讓使用者輸入要commit的檔案
17120
											#繼續讓使用者輸入要commit的檔案
16887
											break 2;
17121
											break 2;
Line 16938... Line 17172...
16938
											#無.
17172
											#無.
16939
											#備註:
17173
											#備註:
16940
											#無.
17174
											#無.
16941
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17175
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
16942
											unset($conf["stringProcess::clearStrSymbol"]);
17176
											unset($conf["stringProcess::clearStrSymbol"]);
16943
											
17177
 
16944
											#如果運行失敗
17178
											#如果運行失敗
16945
											if($clearStrSymbol["status"]==="false")
17179
											if($clearStrSymbol["status"]==="false"){
16946
											{
17180
											
16947
												#設置執行失敗
17181
												#設置執行失敗
16948
												$result["status"]="false";
17182
												$result["status"]="false";
16949
												
17183
 
16950
												#設置執行失敗訊息
17184
												#設置執行失敗訊息
16951
												$result["error"]=$clearStrSymbol;
17185
												$result["error"]=$clearStrSymbol;
16952
												
17186
 
16953
												#回傳結果
17187
												#回傳結果
16954
												return $result;
17188
												return $result;
16955
 
17189
 
16956
											}#if end
17190
												}#if end
16957
											
17191
 
16958
											#提示已經還原變更了
17192
											#提示已經還原變更了
16959
											echo "已取消新增「".$clearStrSymbol["content"]."」到版本控制".PHP_EOL;
17193
											echo "已取消新增「".$clearStrSymbol["content"]."」到版本控制".PHP_EOL;
16960
											
17194
 
16961
											#初始化儲存暫存的複製清單
17195
											#初始化儲存暫存的複製清單
16962
											$tempCpList=array();
17196
											$tempCpList=array();
16963
 
17197
 
16964
											#針對每個複製的清單
17198
											#針對每個複製的清單
16965
											foreach($copyList as $index=>$info){
17199
											foreach($copyList as $index=>$info){
Line 17033... Line 17267...
17033
											#無.
17267
											#無.
17034
											#備註:
17268
											#備註:
17035
											#無.
17269
											#無.
17036
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17270
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17037
											unset($conf["stringProcess::clearStrSymbol"]);
17271
											unset($conf["stringProcess::clearStrSymbol"]);
17038
											
17272
 
17039
											#如果運行失敗
17273
											#如果運行失敗
17040
											if($clearStrSymbol["status"]==="false")
17274
											if($clearStrSymbol["status"]==="false"){
17041
											{
17275
											
17042
												#設置執行失敗
17276
												#設置執行失敗
17043
												$result["status"]="false";
17277
												$result["status"]="false";
17044
												
17278
 
17045
												#設置執行失敗訊息
17279
												#設置執行失敗訊息
17046
												$result["error"]=$clearStrSymbol;
17280
												$result["error"]=$clearStrSymbol;
17047
												
17281
 
17048
												#回傳結果
17282
												#回傳結果
17049
												return $result;
17283
												return $result;
17050
 
17284
 
17051
											}#if end
17285
												}#if end
17052
											
17286
 
17053
											#提示已經還原變更了
17287
											#提示已經還原變更了
17054
											echo "已還原被移除版本控制的「".$clearStrSymbol["content"]."」".PHP_EOL;
17288
											echo "已還原被移除版本控制的「".$clearStrSymbol["content"]."」".PHP_EOL;
17055
 
17289
 
17056
											#繼續讓使用者輸入要commit的檔案
17290
											#繼續讓使用者輸入要commit的檔案
17057
											break 2;
17291
											break 2;
Line 17095... Line 17329...
17095
											#無.
17329
											#無.
17096
											#備註:
17330
											#備註:
17097
											#無.
17331
											#無.
17098
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17332
											$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17099
											unset($conf["stringProcess::clearStrSymbol"]);
17333
											unset($conf["stringProcess::clearStrSymbol"]);
17100
											
17334
 
17101
											#如果運行失敗
17335
											#如果運行失敗
17102
											if($clearStrSymbol["status"]==="false")
17336
											if($clearStrSymbol["status"]==="false"){
17103
											{
17337
											
17104
												#設置執行失敗
17338
												#設置執行失敗
17105
												$result["status"]="false";
17339
												$result["status"]="false";
17106
												
17340
 
17107
												#設置執行失敗訊息
17341
												#設置執行失敗訊息
17108
												$result["error"]=$clearStrSymbol;
17342
												$result["error"]=$clearStrSymbol;
17109
												
17343
 
17110
												#回傳結果
17344
												#回傳結果
17111
												return $result;
17345
												return $result;
17112
 
17346
 
17113
											}#if end
17347
												}#if end
17114
											
17348
 
17115
											#提示已經還原變更了
17349
											#提示已經還原變更了
17116
											echo "已還原「".$clearStrSymbol["content"]."」的修改".PHP_EOL;
17350
											echo "已還原「".$clearStrSymbol["content"]."」的修改".PHP_EOL;
17117
 
17351
 
17118
											#繼續讓使用者輸入要commit的檔案
17352
											#繼續讓使用者輸入要commit的檔案
17119
											break 2;
17353
											break 2;
Line 17142... Line 17376...
17142
								#可省略參數:
17376
								#可省略參數:
17143
								#無.
17377
								#無.
17144
								#參考資料:
17378
								#參考資料:
17145
								#無.
17379
								#無.
17146
								#備註:
17380
								#備註:
17147
								#無.								
17381
								#無.
17148
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17382
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17149
								unset($conf["stringProcess::clearStrSymbol"]);
17383
								unset($conf["stringProcess::clearStrSymbol"]);
17150
 
17384
 
17151
								#如果運行失敗
17385
								#如果運行失敗
17152
								if($clearStrSymbol["status"]==="false")
17386
								if($clearStrSymbol["status"]==="false"){
17153
								{
17387
								
17154
									#設置執行失敗
17388
									#設置執行失敗
17155
									$result["status"]="false";
17389
									$result["status"]="false";
17156
									
17390
 
17157
									#設置執行失敗訊息
17391
									#設置執行失敗訊息
17158
									$result["error"]=$clearStrSymbol;
17392
									$result["error"]=$clearStrSymbol;
17159
									
17393
 
17160
									#回傳結果
17394
									#回傳結果
17161
									return $result;
17395
									return $result;
17162
 
17396
 
17163
								}#if end
17397
									}#if end
17164
 
17398
 
17165
								#提示已經還原變更了
17399
								#提示已經還原變更了
17166
								echo "目標「".$clearStrSymbol."」跟svn上的版本並無不同,或並不存在".PHP_EOL;
17400
								echo "目標「".$clearStrSymbol."」跟svn上的版本並無不同,或並不存在".PHP_EOL;
17167
 
17401
 
17168
								#繼續讓使用者輸入要commit的檔案
17402
								#繼續讓使用者輸入要commit的檔案
Line 17189... Line 17423...
17189
							#可省略參數:
17423
							#可省略參數:
17190
							#無.
17424
							#無.
17191
							#參考資料:
17425
							#參考資料:
17192
							#無.
17426
							#無.
17193
							#備註:
17427
							#備註:
17194
							#無.							
17428
							#無.
17195
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17429
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17196
							unset($conf["stringProcess::clearStrSymbol"]);
17430
							unset($conf["stringProcess::clearStrSymbol"]);
17197
 
17431
 
17198
							#如果運行失敗
17432
							#如果運行失敗
17199
							if($clearStrSymbol["status"]==="false")
17433
							if($clearStrSymbol["status"]==="false"){
17200
							{
17434
							
17201
								#設置執行失敗
17435
								#設置執行失敗
17202
								$result["status"]="false";
17436
								$result["status"]="false";
17203
								
17437
 
17204
								#設置執行失敗訊息
17438
								#設置執行失敗訊息
17205
								$result["error"]=$clearStrSymbol;
17439
								$result["error"]=$clearStrSymbol;
17206
								
17440
 
17207
								#回傳結果
17441
								#回傳結果
17208
								return $result;
17442
								return $result;
17209
 
17443
 
17210
							}#if end
17444
								}#if end
17211
 
17445
 
17212
							#如果檔案不存在
17446
							#如果檔案不存在
17213
							if(!file_exists($clearStrSymbol["content"])){
17447
							if(!file_exists($clearStrSymbol["content"])){
17214
 
17448
 
17215
								#提示檔案不存在
17449
								#提示檔案不存在
Line 17481... Line 17715...
17481
							#無.
17715
							#無.
17482
							#備註:
17716
							#備註:
17483
							#無.
17717
							#無.
17484
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17718
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17485
							unset($conf["stringProcess::clearStrSymbol"]);
17719
							unset($conf["stringProcess::clearStrSymbol"]);
17486
							
17720
 
17487
							#如過執行失敗
17721
							#如過執行失敗
17488
							if($clearStrSymbol["status"]==="false"){
17722
							if($clearStrSymbol["status"]==="false"){
17489
 
17723
 
17490
								#設置執行失敗
17724
								#設置執行失敗
17491
								$result["status"]="false";
17725
								$result["status"]="false";
17492
								
17726
 
17493
								#設置執行失敗訊息
17727
								#設置執行失敗訊息
17494
								$result["error"]=$clearStrSymbol;
17728
								$result["error"]=$clearStrSymbol;
17495
								
17729
 
17496
								#回傳結果
17730
								#回傳結果
17497
								return $result;
17731
								return $result;
17498
 
17732
 
17499
								}#if end
17733
								}#if end
17500
							
17734
 
17501
							#提示命令 $argv[1] 不存在
17735
							#提示命令 $argv[1] 不存在
17502
							echo "命令 「".$clearStrSymbol["content"]."」 不存在".PHP_EOL;
17736
							echo "命令 「".$clearStrSymbol["content"]."」 不存在".PHP_EOL;
17503
 
17737
 
17504
							#繼續讓使用者輸入要commit的檔案
17738
							#繼續讓使用者輸入要commit的檔案
17505
							break 2;
17739
							break 2;
Line 17532... Line 17766...
17532
					#無.
17766
					#無.
17533
					#備註:
17767
					#備註:
17534
					#無.
17768
					#無.
17535
					$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17769
					$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17536
					unset($conf["stringProcess::clearStrSymbol"]);
17770
					unset($conf["stringProcess::clearStrSymbol"]);
17537
					
17771
 
17538
					#如果執行失敗
17772
					#如果執行失敗
17539
					if($clearStrSymbol["status"]==="false"){
17773
					if($clearStrSymbol["status"]==="false"){
17540
 
17774
 
17541
						#設置執行失敗
17775
						#設置執行失敗
17542
						$result["status"]="false";
17776
						$result["status"]="false";
17543
						
17777
 
17544
						#設置執行失敗訊息
17778
						#設置執行失敗訊息
17545
						$result["error"]=$clearStrSymbol;
17779
						$result["error"]=$clearStrSymbol;
17546
						
17780
 
17547
						#回傳結果
17781
						#回傳結果
17548
						return $result;
17782
						return $result;
17549
 
17783
 
17550
						}#if end
17784
						}#if end
17551
				
17785
 
17552
					#提示檢查檔案是否存在
17786
					#提示檢查檔案是否存在
17553
					echo "檢查檔案 ".$clearStrSymbol["content"]." 是否存在".PHP_EOL;
17787
					echo "檢查檔案 ".$clearStrSymbol["content"]." 是否存在".PHP_EOL;
17554
					
17788
 
17555
					#函式說明:
17789
					#函式說明:
17556
					#檢查多個檔案與資料夾是否存在.
17790
					#檢查多個檔案與資料夾是否存在.
17557
					#回傳的結果:
17791
					#回傳的結果:
17558
					#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
17792
					#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
17559
					#$result["error"],錯誤訊息陣列.
17793
					#$result["error"],錯誤訊息陣列.
Line 17582... Line 17816...
17582
					#備註:
17816
					#備註:
17583
					#函數file_exists檢查的路徑為檔案系統的路徑
17817
					#函數file_exists檢查的路徑為檔案系統的路徑
17584
					#$result["varName"][$i]結果未實作
17818
					#$result["varName"][$i]結果未實作
17585
					$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
17819
					$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
17586
					unset($conf["fileAccess::checkMultiFileExist"]);
17820
					unset($conf["fileAccess::checkMultiFileExist"]);
17587
					
17821
 
17588
					#如果執行失敗
17822
					#如果執行失敗
17589
					if($checkMultiFileExist["status"]==="false"){
17823
					if($checkMultiFileExist["status"]==="false"){
17590
 
17824
 
17591
						#設置執行失敗
17825
						#設置執行失敗
17592
						$result["status"]="false";
17826
						$result["status"]="false";
17593
						
17827
 
17594
						#設置執行失敗訊息
17828
						#設置執行失敗訊息
17595
						$result["error"]=$checkMultiFileExist;
17829
						$result["error"]=$checkMultiFileExist;
17596
						
17830
 
17597
						#回傳結果
17831
						#回傳結果
17598
						return $result;
17832
						return $result;
17599
 
17833
 
17600
						}#if end
17834
						}#if end
17601
					
17835
 
17602
					#如果檔案不存在
17836
					#如果檔案不存在
17603
					if($checkMultiFileExist["allExist"]==="false"){
17837
					if($checkMultiFileExist["allExist"]==="false"){
17604
					
17838
 
17605
						#提示檔案不存在
17839
						#提示檔案不存在
17606
						echo "檔案".$clearStrSymbol["content"]."不存在".PHP_EOL;
17840
						echo "檔案".$clearStrSymbol["content"]."不存在".PHP_EOL;
17607
 
17841
 
17608
						#繼續輸入要commit的檔案名稱
17842
						#繼續輸入要commit的檔案名稱
17609
						break;
17843
						break;
17610
					
17844
 
17611
						}#if end
17845
						}#if end
17612
						
17846
 
17613
					#檢查檔案 $input 是否處於版本控制中
17847
					#檢查檔案 $input 是否處於版本控制中
17614
					
17848
 
17615
					#函式說明:
17849
					#函式說明:
17616
					#執行svn status指令
17850
					#執行svn status指令
17617
					#回傳結果:
17851
					#回傳結果:
17618
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17852
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17619
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
17853
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 17632... Line 17866...
17632
					#無.
17866
					#無.
17633
					#備註:
17867
					#備註:
17634
					#無.
17868
					#無.
17635
					$svnsta=cmd::svnsta($conf["cmd::svnsta"]);
17869
					$svnsta=cmd::svnsta($conf["cmd::svnsta"]);
17636
					unset($conf["cmd::svnsta"]);
17870
					unset($conf["cmd::svnsta"]);
17637
					
17871
 
17638
					#如果執行失敗
17872
					#如果執行失敗
17639
					if($svnsta["status"]==="false"){
17873
					if($svnsta["status"]==="false"){
17640
 
17874
 
17641
						#設置執行失敗
17875
						#設置執行失敗
17642
						$result["status"]="false";
17876
						$result["status"]="false";
17643
						
17877
 
17644
						#設置執行失敗訊息
17878
						#設置執行失敗訊息
17645
						$result["error"]=$svnsta;
17879
						$result["error"]=$svnsta;
17646
						
17880
 
17647
						#回傳結果
17881
						#回傳結果
17648
						return $result;
17882
						return $result;
17649
 
17883
 
17650
						}#if end
17884
						}#if end
17651
					
17885
 
17652
					#var_dump(__LINE__,$svnsta);
17886
					#var_dump(__LINE__,$svnsta);
17653
					
17887
 
17654
					#如果沒有版本控制記錄
17888
					#如果沒有版本控制記錄
17655
					if($svnsta["content"]["status"][0]["status"]==="?"){
17889
					if($svnsta["content"]["status"][0]["status"]==="?"){
17656
					
17890
 
17657
						#函式說明:
17891
						#函式說明:
17658
						#呼叫shell執行系統命令,並取得回傳的內容.
17892
						#呼叫shell執行系統命令,並取得回傳的內容.
17659
						#回傳結果:
17893
						#回傳結果:
17660
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17894
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17661
						#$result["error"],錯誤訊息陣列.
17895
						#$result["error"],錯誤訊息陣列.
Line 17716... Line 17950...
17716
						$callShell=external::callShell($conf["external::callShell"]);
17950
						$callShell=external::callShell($conf["external::callShell"]);
17717
						unset($conf["external::callShell"]);
17951
						unset($conf["external::callShell"]);
17718
 
17952
 
17719
						#如果執行失敗
17953
						#如果執行失敗
17720
						if($callShell["status"]==="false"){
17954
						if($callShell["status"]==="false"){
17721
						
17955
 
17722
							#設置執行失敗
17956
							#設置執行失敗
17723
							$result["status"]="false";
17957
							$result["status"]="false";
17724
							
17958
 
17725
							#設置執行失敗訊息
17959
							#設置執行失敗訊息
17726
							$result["error"]=$callShell;
17960
							$result["error"]=$callShell;
17727
							
17961
 
17728
							#回傳結果
17962
							#回傳結果
17729
							return $result;
17963
							return $result;
17730
						
17964
 
17731
							}#if end
17965
							}#if end
17732
						
17966
 
17733
						#印出執行的cmd
17967
						#印出執行的cmd
17734
						echo "cmd:".$callShell["cmd"].PHP_EOL;
17968
						echo "cmd:".$callShell["cmd"].PHP_EOL;
17735
 
17969
 
17736
						#印出執行後的回傳代碼
17970
						#印出執行後的回傳代碼
17737
						echo "status:".$callShell["statusCode"].PHP_EOL;
17971
						echo "status:".$callShell["statusCode"].PHP_EOL;
Line 17772... Line 18006...
17772
							#無.
18006
							#無.
17773
							#備註:
18007
							#備註:
17774
							#無.
18008
							#無.
17775
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
18009
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17776
							unset($conf["stringProcess::clearStrSymbol"]);
18010
							unset($conf["stringProcess::clearStrSymbol"]);
17777
							
18011
 
17778
							#如果執行失敗
18012
							#如果執行失敗
17779
							if($clearStrSymbol["status"]==="false"){
18013
							if($clearStrSymbol["status"]==="false"){
17780
							
18014
 
17781
								#設置執行失敗
18015
								#設置執行失敗
17782
								$result["status"]="false";
18016
								$result["status"]="false";
17783
								
18017
 
17784
								#設置執行失敗訊息
18018
								#設置執行失敗訊息
17785
								$result["error"]=$clearStrSymbol;
18019
								$result["error"]=$clearStrSymbol;
17786
								
18020
 
17787
								#回傳結果
18021
								#回傳結果
17788
								return $result;
18022
								return $result;
17789
							
18023
 
17790
								}#if end
18024
								}#if end
17791
							
18025
 
17792
							#提示已經新增
18026
							#提示已經新增
17793
							echo "已新增檔案「".$clearStrSymbol["content"]."」到版本控制".PHP_EOL;
18027
							echo "已新增檔案「".$clearStrSymbol["content"]."」到版本控制".PHP_EOL;
17794
 
18028
 
17795
							#繼續讓使用者輸入要commit的檔案
18029
							#繼續讓使用者輸入要commit的檔案
17796
							break;
18030
							break;
Line 17805... Line 18039...
17805
 
18039
 
17806
							#繼續讓使用者輸入要commit的檔案
18040
							#繼續讓使用者輸入要commit的檔案
17807
							break;
18041
							break;
17808
 
18042
 
17809
							}#else end
18043
							}#else end
17810
					
18044
 
17811
						}#if end
18045
						}#if end
17812
								
18046
 
17813
					#反之有異動過
18047
					#反之有異動過
17814
					else if( $svnsta["content"]["status"][0]["status"]==="M" || $svnsta["content"]["status"][0]["status"]==="A" ){
18048
					else if( $svnsta["content"]["status"][0]["status"]==="M" || $svnsta["content"]["status"][0]["status"]==="A" ){
17815
					
18049
 
17816
						#如果有在commit清單裡面了
18050
						#如果有在commit清單裡面了
17817
						if(in_array($argv[0],$filesToCommit)){
18051
						if(in_array($argv[0],$filesToCommit)){
17818
						
18052
 
17819
							#提示新增檔案到版本控制失敗
18053
							#提示新增檔案到版本控制失敗
17820
							echo "檔案「".$argv[0]."」的異動已記錄(".$callShell["statusCode"].")".PHP_EOL;
18054
							echo "檔案「".$argv[0]."」的異動已記錄(".$callShell["statusCode"].")".PHP_EOL;
17821
 
18055
 
17822
							#繼續讓使用者輸入要commit的檔案
18056
							#繼續讓使用者輸入要commit的檔案
17823
							break;
18057
							break;
17824
						
18058
 
17825
							}#if end
18059
							}#if end
17826
					
18060
 
17827
						#記錄要commit的新增檔案
18061
						#記錄要commit的新增檔案
17828
						$filesToCommit[]=$argv[0];
18062
						$filesToCommit[]=$argv[0];
17829
 
18063
 
17830
						#記錄本次要新增的檔案
18064
						#記錄本次要新增的檔案
17831
						$fileAdded[]=$argv[0];
18065
						$fileAdded[]=$argv[0];
Line 17846... Line 18080...
17846
						#無.
18080
						#無.
17847
						#備註:
18081
						#備註:
17848
						#無.
18082
						#無.
17849
						$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
18083
						$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17850
						unset($conf["stringProcess::clearStrSymbol"]);
18084
						unset($conf["stringProcess::clearStrSymbol"]);
17851
						
18085
 
17852
						#如果執行失敗
18086
						#如果執行失敗
17853
						if($clearStrSymbol["status"]==="false"){
18087
						if($clearStrSymbol["status"]==="false"){
17854
						
18088
 
17855
							#設置執行失敗
18089
							#設置執行失敗
17856
							$result["status"]="false";
18090
							$result["status"]="false";
17857
							
18091
 
17858
							#設置執行失敗訊息
18092
							#設置執行失敗訊息
17859
							$result["error"]=$clearStrSymbol;
18093
							$result["error"]=$clearStrSymbol;
17860
							
18094
 
17861
							#回傳結果
18095
							#回傳結果
17862
							return $result;
18096
							return $result;
17863
						
18097
 
17864
							}#if end
18098
							}#if end
17865
						
18099
 
17866
						#提示已經新增
18100
						#提示已經新增
17867
						echo "已將檔案「".$clearStrSymbol["content"]."」的異動加到版本控制".PHP_EOL;
18101
						echo "已將檔案「".$clearStrSymbol["content"]."」的異動加到版本控制".PHP_EOL;
17868
 
18102
 
17869
						#繼續讓使用者輸入要commit的檔案
18103
						#繼續讓使用者輸入要commit的檔案
17870
						break;
18104
						break;
17871
				
18105
 
17872
						}#if end
18106
						}#if end
17873
					
18107
 
17874
					#反之
18108
					#反之
17875
					else{
18109
					else{
17876
 
18110
 
17877
						#提示node無異動,所以無法加入為commit的清單
18111
						#提示node無異動,所以無法加入為commit的清單
17878
						echo "檔案「".$argv[0]."」無異動".PHP_EOL;
18112
						echo "檔案「".$argv[0]."」無異動".PHP_EOL;
17879
 
18113
 
17880
						#繼續讓使用者輸入要commit的檔案
18114
						#繼續讓使用者輸入要commit的檔案
17881
						break;
18115
						break;
17882
 
18116
 
17883
						}#else end
18117
						}#else end
17884
					
18118
 
17885
					#繼續輸入要commit的檔案名稱
18119
					#繼續輸入要commit的檔案名稱
17886
					break;
18120
					break;
17887
 
18121
 
17888
				#如果參數數量為0
18122
				#如果參數數量為0
17889
				case 0:
18123
				case 0:
Line 17917... Line 18151...
17917
							#無.
18151
							#無.
17918
							#備註:
18152
							#備註:
17919
							#無.
18153
							#無.
17920
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
18154
							$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
17921
							unset($conf["stringProcess::clearStrSymbol"]);
18155
							unset($conf["stringProcess::clearStrSymbol"]);
17922
							
18156
 
17923
							#如果執行失敗
18157
							#如果執行失敗
17924
							if($clearStrSymbol["status"]==="false"){
18158
							if($clearStrSymbol["status"]==="false"){
17925
							
18159
 
17926
								#設置執行失敗
18160
								#設置執行失敗
17927
								$result["status"]="false";
18161
								$result["status"]="false";
17928
								
18162
 
17929
								#設置執行失敗訊息
18163
								#設置執行失敗訊息
17930
								$result["error"]=$clearStrSymbol;
18164
								$result["error"]=$clearStrSymbol;
17931
								
18165
 
17932
								#回傳結果
18166
								#回傳結果
17933
								return $result;
18167
								return $result;
17934
							
18168
 
17935
								}#if end
18169
								}#if end
17936
							
18170
 
17937
							#如果最後一個參數代表的複製目的已經存在
18171
							#如果最後一個參數代表的複製目的已經存在
17938
							if(file_exists($clearStrSymbol["content"])){
18172
							if(file_exists($clearStrSymbol["content"])){
17939
 
18173
 
17940
								#不是目錄
18174
								#不是目錄
17941
								if(!is_dir($clearStrSymbol["content"])){
18175
								if(!is_dir($clearStrSymbol["content"])){
Line 18015... Line 18249...
18015
									$callShell=external::callShell($conf["external::callShell"]);
18249
									$callShell=external::callShell($conf["external::callShell"]);
18016
									unset($conf["external::callShell"]);
18250
									unset($conf["external::callShell"]);
18017
 
18251
 
18018
									#如果執行失敗
18252
									#如果執行失敗
18019
									if($callShell["status"]==="false"){
18253
									if($callShell["status"]==="false"){
18020
									
18254
 
18021
										#設置執行失敗
18255
										#設置執行失敗
18022
										$result["status"]="false";
18256
										$result["status"]="false";
18023
										
18257
 
18024
										#設置執行失敗訊息
18258
										#設置執行失敗訊息
18025
										$result["error"]=$callShell;
18259
										$result["error"]=$callShell;
18026
										
18260
 
18027
										#回傳結果
18261
										#回傳結果
18028
										return $result;
18262
										return $result;
18029
									
18263
 
18030
										}#if end
18264
										}#if end
18031
 
18265
 
18032
									#印出執行的cmd
18266
									#印出執行的cmd
18033
									echo "cmd:".$callShell["cmd"].PHP_EOL;
18267
									echo "cmd:".$callShell["cmd"].PHP_EOL;
18034
 
18268
 
Line 18156... Line 18390...
18156
								$callShell=external::callShell($conf["external::callShell"]);
18390
								$callShell=external::callShell($conf["external::callShell"]);
18157
								unset($conf["external::callShell"]);
18391
								unset($conf["external::callShell"]);
18158
 
18392
 
18159
								#如果執行失敗
18393
								#如果執行失敗
18160
								if($callShell["status"]==="false"){
18394
								if($callShell["status"]==="false"){
18161
								
18395
 
18162
									#設置執行失敗
18396
									#設置執行失敗
18163
									$result["status"]="false";
18397
									$result["status"]="false";
18164
									
18398
 
18165
									#設置執行失敗訊息
18399
									#設置執行失敗訊息
18166
									$result["error"]=$callShell;
18400
									$result["error"]=$callShell;
18167
									
18401
 
18168
									#回傳結果
18402
									#回傳結果
18169
									return $result;
18403
									return $result;
18170
								
18404
 
18171
									}#if end
18405
									}#if end
18172
 
18406
 
18173
								#印出執行的cmd
18407
								#印出執行的cmd
18174
								echo "cmd:".$callShell["cmd"].PHP_EOL;
18408
								echo "cmd:".$callShell["cmd"].PHP_EOL;
18175
 
18409
 
Line 18202... Line 18436...
18202
										#無.
18436
										#無.
18203
										#備註:
18437
										#備註:
18204
										#無.
18438
										#無.
18205
										$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
18439
										$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
18206
										unset($conf["stringProcess::clearStrSymbol"]);
18440
										unset($conf["stringProcess::clearStrSymbol"]);
18207
										
18441
 
18208
										#如果執行失敗
18442
										#如果執行失敗
18209
										if($clearStrSymbol["status"]==="false"){
18443
										if($clearStrSymbol["status"]==="false"){
18210
										
18444
 
18211
											#設置執行失敗
18445
											#設置執行失敗
18212
											$result["status"]="false";
18446
											$result["status"]="false";
18213
											
18447
 
18214
											#設置執行失敗訊息
18448
											#設置執行失敗訊息
18215
											$result["error"]=$clearStrSymbol;
18449
											$result["error"]=$clearStrSymbol;
18216
											
18450
 
18217
											#回傳結果
18451
											#回傳結果
18218
											return $result;
18452
											return $result;
18219
										
18453
 
18220
											}#if end
18454
											}#if end
18221
										
18455
 
18222
										echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法複製".PHP_EOL;
18456
										echo "檔案「".$clearStrSymbol["content"]."」不在版本控制裡面,因此無法複製".PHP_EOL;
18223
 
18457
 
18224
										#繼續讓使用者輸入要commit的檔案
18458
										#繼續讓使用者輸入要commit的檔案
18225
										break 3;
18459
										break 3;
18226
 
18460
 
Line 18302... Line 18536...
18302
								$callShell=external::callShell($conf["external::callShell"]);
18536
								$callShell=external::callShell($conf["external::callShell"]);
18303
								unset($conf["external::callShell"]);
18537
								unset($conf["external::callShell"]);
18304
 
18538
 
18305
								#如果執行失敗
18539
								#如果執行失敗
18306
								if($callShell["status"]==="false"){
18540
								if($callShell["status"]==="false"){
18307
								
18541
 
18308
									#設置執行失敗
18542
									#設置執行失敗
18309
									$result["status"]="false";
18543
									$result["status"]="false";
18310
									
18544
 
18311
									#設置執行失敗訊息
18545
									#設置執行失敗訊息
18312
									$result["error"]=$callShell;
18546
									$result["error"]=$callShell;
18313
									
18547
 
18314
									#回傳結果
18548
									#回傳結果
18315
									return $result;
18549
									return $result;
18316
								
18550
 
18317
									}#if end
18551
									}#if end
18318
 
18552
 
18319
								#印出執行的cmd
18553
								#印出執行的cmd
18320
								echo "cmd:".$callShell["cmd"].PHP_EOL;
18554
								echo "cmd:".$callShell["cmd"].PHP_EOL;
18321
 
18555
 
Line 18672... Line 18906...
18672
					#如果處理錯誤
18906
					#如果處理錯誤
18673
					if($parse["status"]==="false"){
18907
					if($parse["status"]==="false"){
18674
 
18908
 
18675
						#如果是 bash 語法錯誤
18909
						#如果是 bash 語法錯誤
18676
						if($parse["error"][0]==="bash syntax error"){
18910
						if($parse["error"][0]==="bash syntax error"){
18677
						
18911
 
18678
							#提示錯誤訊息
18912
							#提示錯誤訊息
18679
							echo $parse["error"][0].PHP_EOL;
18913
							echo $parse["error"][0].PHP_EOL;
18680
							
18914
 
18681
							#提示錯誤訊息
18915
							#提示錯誤訊息
18682
							echo $parse["error"][1]["content"][0]["error"];
18916
							echo $parse["error"][1]["content"][0]["error"];
18683
						
18917
 
18684
							#debug
18918
							#debug
18685
							#var_dump($parse);
18919
							#var_dump($parse);
18686
						
18920
 
18687
							#等待下個commit的註解
18921
							#等待下個commit的註解
18688
							break;
18922
							break;
18689
						
18923
 
18690
							}#if end
18924
							}#if end
18691
 
18925
 
18692
						#設置錯誤訊息
18926
						#設置錯誤訊息
18693
						$result["error"]=$parse;
18927
						$result["error"]=$parse;
18694
 
18928
 
Line 18712... Line 18946...
18712
						#兩個參數
18946
						#兩個參數
18713
						case "2":
18947
						case "2":
18714
 
18948
 
18715
							#如果第一個字串為 "diff" ,第二個字串代表要比較的目標檔案.
18949
							#如果第一個字串為 "diff" ,第二個字串代表要比較的目標檔案.
18716
							if($param[0]==="diff"){
18950
							if($param[0]==="diff"){
18717
							
18951
 
18718
								#更新目標檔案名稱
18952
								#更新目標檔案名稱
18719
								#函式說明:
18953
								#函式說明:
18720
								#清除字串的「"」或「'」符號.
18954
								#清除字串的「"」或「'」符號.
18721
								#回傳結果:
18955
								#回傳結果:
18722
								#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
18956
								#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
Line 18733... Line 18967...
18733
								#備註:
18967
								#備註:
18734
								#無.
18968
								#無.
18735
								$conf["stringProcess::clearStrSymbol"]["str"]=$param[1];
18969
								$conf["stringProcess::clearStrSymbol"]["str"]=$param[1];
18736
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
18970
								$clearStrSymbol=stringProcess::clearStrSymbol($conf["stringProcess::clearStrSymbol"]);
18737
								unset($conf["stringProcess::clearStrSymbol"]);
18971
								unset($conf["stringProcess::clearStrSymbol"]);
18738
								
18972
 
18739
								#如果parse字串失敗
18973
								#如果parse字串失敗
18740
								if($clearStrSymbol["status"]==="false"){
18974
								if($clearStrSymbol["status"]==="false"){
18741
 
18975
 
18742
									#設置執行失敗
18976
									#設置執行失敗
18743
									$result["status"]="false";
18977
									$result["status"]="false";
Line 18747... Line 18981...
18747
 
18981
 
18748
									#回傳結果
18982
									#回傳結果
18749
									return $result;
18983
									return $result;
18750
 
18984
 
18751
									}#if end
18985
									}#if end
18752
								
18986
 
18753
								#如果目標檔案存在
18987
								#如果目標檔案存在
18754
								if(file_exists($clearStrSymbol["content"])){
18988
								if(file_exists($clearStrSymbol["content"])){
18755
								
18989
 
18756
									#函式說明:
18990
									#函式說明:
18757
									#呼叫shell執行系統命令,並取得回傳的內容.
18991
									#呼叫shell執行系統命令,並取得回傳的內容.
18758
									#回傳結果:
18992
									#回傳結果:
18759
									#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
18993
									#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
18760
									#$result["error"],錯誤訊息陣列.
18994
									#$result["error"],錯誤訊息陣列.
Line 18815... Line 19049...
18815
									$callShell=external::callShell($conf["external::callShell"]);
19049
									$callShell=external::callShell($conf["external::callShell"]);
18816
									unset($conf["external::callShell"]);
19050
									unset($conf["external::callShell"]);
18817
 
19051
 
18818
									#如果執行失敗
19052
									#如果執行失敗
18819
									if($callShell["status"]==="false"){
19053
									if($callShell["status"]==="false"){
18820
									
19054
 
18821
										#設置執行失敗
19055
										#設置執行失敗
18822
										$result["status"]="false";
19056
										$result["status"]="false";
18823
										
19057
 
18824
										#設置執行失敗訊息
19058
										#設置執行失敗訊息
18825
										$result["error"]=$callShell;
19059
										$result["error"]=$callShell;
18826
										
19060
 
18827
										#回傳結果
19061
										#回傳結果
18828
										return $result;
19062
										return $result;
18829
									
19063
 
18830
										}#if end
19064
										}#if end
18831
 
19065
 
18832
									#印出執行的cmd
19066
									#印出執行的cmd
18833
									echo "cmd:".$callShell["cmd"].PHP_EOL;
19067
									echo "cmd:".$callShell["cmd"].PHP_EOL;
18834
 
19068
 
Line 18840... Line 19074...
18840
 
19074
 
18841
										#印出內容
19075
										#印出內容
18842
										echo $line.PHP_EOL;
19076
										echo $line.PHP_EOL;
18843
 
19077
 
18844
										}#foreach end
19078
										}#foreach end
18845
								
19079
 
18846
									}#if end
19080
									}#if end
18847
	
19081
 
18848
								#反之代表目標檔案不存在
19082
								#反之代表目標檔案不存在
18849
								else{
19083
								else{
18850
								
19084
 
18851
									#題書目標檔案不存在
19085
									#題書目標檔案不存在
18852
									echo "目標檔案「".$clearStrSymbol["content"]."」不存在!".PHP_EOL;
19086
									echo "目標檔案「".$clearStrSymbol["content"]."」不存在!".PHP_EOL;
18853
								
19087
 
18854
									}#else end
19088
									}#else end
18855
 
19089
 
18856
								#繼續讓使用者輸入註解
19090
								#繼續讓使用者輸入註解
18857
								continue 3;
19091
								continue 3;
18858
 
19092
 
18859
								}#if end
19093
								}#if end
18860
							
19094
 
18861
							#如果第一個字串為 "to" ,第二個字串代表要去的列(整數)
19095
							#如果第一個字串為 "to" ,第二個字串代表要去的列(整數)
18862
							else if($param[0]==="to" && is_int(intval($param[1]))){
19096
							else if($param[0]==="to" && is_int(intval($param[1]))){
18863
 
19097
 
18864
								#如果目標列存在
19098
								#如果目標列存在
18865
								if(isset($comment[$param[1]])){
19099
								if(isset($comment[$param[1]])){
Line 18991... Line 19225...
18991
		#如果有要移除的檔案
19225
		#如果有要移除的檔案
18992
		if(count($fileShouldBeDeleted)>0){
19226
		if(count($fileShouldBeDeleted)>0){
18993
 
19227
 
18994
			#針對每個要移除的檔案
19228
			#針對每個要移除的檔案
18995
			foreach($fileShouldBeDeleted as $delFile){
19229
			foreach($fileShouldBeDeleted as $delFile){
18996
				
19230
 
18997
				#函式說明:
19231
				#函式說明:
18998
				#呼叫shell執行系統命令,並取得回傳的內容.
19232
				#呼叫shell執行系統命令,並取得回傳的內容.
18999
				#回傳結果:
19233
				#回傳結果:
19000
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
19234
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
19001
				#$result["error"],錯誤訊息陣列.
19235
				#$result["error"],錯誤訊息陣列.
Line 19056... Line 19290...
19056
				$callShell=external::callShell($conf["external::callShell"]);
19290
				$callShell=external::callShell($conf["external::callShell"]);
19057
				unset($conf["external::callShell"]);
19291
				unset($conf["external::callShell"]);
19058
 
19292
 
19059
				#如果執行失敗
19293
				#如果執行失敗
19060
				if($callShell["status"]==="false"){
19294
				if($callShell["status"]==="false"){
19061
				
19295
 
19062
					#設置執行失敗
19296
					#設置執行失敗
19063
					$result["status"]="false";
19297
					$result["status"]="false";
19064
					
19298
 
19065
					#設置執行失敗訊息
19299
					#設置執行失敗訊息
19066
					$result["error"]=$callShell;
19300
					$result["error"]=$callShell;
19067
					
19301
 
19068
					#回傳結果
19302
					#回傳結果
19069
					return $result;
19303
					return $result;
19070
				
19304
 
19071
					}#if end
19305
					}#if end
19072
 
19306
 
19073
				#印出執行的cmd
19307
				#印出執行的cmd
19074
				echo "cmd:".$callShell["cmd"].PHP_EOL;
19308
				echo "cmd:".$callShell["cmd"].PHP_EOL;
19075
 
19309
 
Line 19079... Line 19313...
19079
				}#foreach end
19313
				}#foreach end
19080
 
19314
 
19081
			}#if end
19315
			}#if end
19082
 
19316
 
19083
		#函式說明:
19317
		#函式說明:
19084
		#建立暫存目錄與回傳暫存檔案名稱路徑 
19318
		#建立暫存目錄與回傳暫存檔案名稱路徑
19085
		#回傳結果:
19319
		#回傳結果:
19086
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
19320
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
19087
		#$result["error"],錯誤訊息.
19321
		#$result["error"],錯誤訊息.
19088
		#$result["function"],當前執行的函數名稱.
19322
		#$result["function"],當前執行的函數名稱.
19089
		#$result["content"],暫存檔案的路徑與名稱.
19323
		#$result["content"],暫存檔案的路徑與名稱.
Line 19096... Line 19330...
19096
		#備註:
19330
		#備註:
19097
		#無.
19331
		#無.
19098
		$conf["conffileAccess::createTempFile"]=array();
19332
		$conf["conffileAccess::createTempFile"]=array();
19099
		$createTempFile=fileAccess::createTempFile($conf["conffileAccess::createTempFile"]);
19333
		$createTempFile=fileAccess::createTempFile($conf["conffileAccess::createTempFile"]);
19100
		unset($conf["conffileAccess::createTempFile"]);
19334
		unset($conf["conffileAccess::createTempFile"]);
19101
		
19335
 
19102
		#如果執行失敗
19336
		#如果執行失敗
19103
		if($createTempFile["status"]==="false"){
19337
		if($createTempFile["status"]==="false"){
19104
		
19338
 
19105
			#設置執行失敗
19339
			#設置執行失敗
19106
			$result["status"]="false";
19340
			$result["status"]="false";
19107
			
19341
 
19108
			#設置執行失敗訊息
19342
			#設置執行失敗訊息
19109
			$result["error"]=$createTempFile;
19343
			$result["error"]=$createTempFile;
19110
			
19344
 
19111
			#回傳結果
19345
			#回傳結果
19112
			return $result;
19346
			return $result;
19113
		
19347
 
19114
			}#if end
19348
			}#if end
19115
		
19349
 
19116
		#指定 commit log file
19350
		#指定 commit log file
19117
		$commitLogFile=$createTempFile["content"];
19351
		$commitLogFile=$createTempFile["content"];
19118
			
19352
 
19119
		#函式說明:
19353
		#函式說明:
19120
		#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
19354
		#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
19121
		#回傳的結果:
19355
		#回傳的結果:
19122
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
19356
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
19123
		#$result["function"],當前執行的function名稱
19357
		#$result["function"],當前執行的function名稱
Line 19139... Line 19373...
19139
		$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
19373
		$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
19140
		unset($conf["arrays::arrayToString"]);
19374
		unset($conf["arrays::arrayToString"]);
19141
 
19375
 
19142
		#如果執行失敗
19376
		#如果執行失敗
19143
		if($arrayToString["status"]==="false"){
19377
		if($arrayToString["status"]==="false"){
19144
		
19378
 
19145
			#設置執行失敗
19379
			#設置執行失敗
19146
			$result["status"]="false";
19380
			$result["status"]="false";
19147
			
19381
 
19148
			#設置執行失敗訊息
19382
			#設置執行失敗訊息
19149
			$result["error"]=$arrayToString;
19383
			$result["error"]=$arrayToString;
19150
			
19384
 
19151
			#回傳結果
19385
			#回傳結果
19152
			return $result;
19386
			return $result;
19153
		
19387
 
19154
			}#if end
19388
			}#if end
19155
			
19389
 
19156
		#取得註解字串
19390
		#取得註解字串
19157
		$commentStr=$arrayToString["content"];
19391
		$commentStr=$arrayToString["content"];
19158
 
19392
 
19159
		#函式說明:
19393
		#函式說明:
19160
		#將字串寫入到檔案
19394
		#將字串寫入到檔案
Line 19192... Line 19426...
19192
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAcceess::writeTextIntoFile"]);
19426
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAcceess::writeTextIntoFile"]);
19193
		unset($conf["fileAcceess::writeTextIntoFile"]);
19427
		unset($conf["fileAcceess::writeTextIntoFile"]);
19194
 
19428
 
19195
		#如果執行失敗
19429
		#如果執行失敗
19196
		if($writeTextIntoFile["status"]==="false"){
19430
		if($writeTextIntoFile["status"]==="false"){
19197
		
19431
 
19198
			#設置執行失敗
19432
			#設置執行失敗
19199
			$result["status"]="false";
19433
			$result["status"]="false";
19200
			
19434
 
19201
			#設置執行失敗訊息
19435
			#設置執行失敗訊息
19202
			$result["error"]=$writeTextIntoFile;
19436
			$result["error"]=$writeTextIntoFile;
19203
			
19437
 
19204
			#回傳結果
19438
			#回傳結果
19205
			return $result;
19439
			return $result;
19206
		
19440
 
19207
			}#if end
19441
			}#if end
19208
 
19442
 
19209
		#函式說明:
19443
		#函式說明:
19210
		#將多個一維陣列串聯起來,key從0開始排序.
19444
		#將多個一維陣列串聯起來,key從0開始排序.
19211
		#回傳的結果:
19445
		#回傳的結果:
Line 19222... Line 19456...
19222
		$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
19456
		$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
19223
		unset($conf["arrays::mergeArray"]);
19457
		unset($conf["arrays::mergeArray"]);
19224
 
19458
 
19225
		#如果建立新陣列失敗
19459
		#如果建立新陣列失敗
19226
		if($mergeArray["status"]==="false"){
19460
		if($mergeArray["status"]==="false"){
19227
		
19461
 
19228
			#設置執行錯誤
19462
			#設置執行錯誤
19229
			$result["error"]=$mergeArray;
19463
			$result["error"]=$mergeArray;
19230
 
19464
 
19231
			#設置執行不正常
19465
			#設置執行不正常
19232
			$result["status"]="false";
19466
			$result["status"]="false";
19233
 
19467
 
19234
			#回傳結果
19468
			#回傳結果
19235
			return $result;
19469
			return $result;
19236
		
19470
 
19237
			}#if end
19471
			}#if end
19238
 
19472
 
19239
		#函式說明:
19473
		#函式說明:
19240
		#呼叫shell執行系統命令,並取得回傳的內容.
19474
		#呼叫shell執行系統命令,並取得回傳的內容.
19241
		#回傳的結果:
19475
		#回傳的結果:
Line 19317... Line 19551...
19317
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
19551
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
19318
		unset($conf["fileAccess::delFile"]);
19552
		unset($conf["fileAccess::delFile"]);
19319
 
19553
 
19320
		#如果移除暫存檔案失敗
19554
		#如果移除暫存檔案失敗
19321
		if($delFile["status"]==="false"){
19555
		if($delFile["status"]==="false"){
19322
		
19556
 
19323
			#設置執行錯誤
19557
			#設置執行錯誤
19324
			$result["error"]=$delFile;
19558
			$result["error"]=$delFile;
19325
 
19559
 
19326
			#設置執行不正常
19560
			#設置執行不正常
19327
			$result["status"]="false";
19561
			$result["status"]="false";
19328
 
19562
 
19329
			#回傳結果
19563
			#回傳結果
19330
			return $result;
19564
			return $result;
19331
		
19565
 
19332
			}#if end
19566
			}#if end
19333
 
19567
 
19334
		#紀錄 commit 的結果
19568
		#紀錄 commit 的結果
19335
		$result["content"]["content"]=$callShell["output"];
19569
		$result["content"]["content"]=$callShell["output"];
19336
 
19570
 
Line 19971... Line 20205...
19971
	#無.
20205
	#無.
19972
	#備註:
20206
	#備註:
19973
	#無.
20207
	#無.
19974
	*/
20208
	*/
19975
	public static function ipAddrShow(&$conf){
20209
	public static function ipAddrShow(&$conf){
19976
	
20210
 
19977
		#初始化要回傳的結果
20211
		#初始化要回傳的結果
19978
		$result=array();
20212
		$result=array();
19979
 
20213
 
19980
		#取得當前執行的函式名稱
20214
		#取得當前執行的函式名稱
19981
		$result["function"]=__FUNCTION__;
20215
		$result["function"]=__FUNCTION__;
Line 20079... Line 20313...
20079
 
20313
 
20080
			#回傳結果
20314
			#回傳結果
20081
			return $result;
20315
			return $result;
20082
 
20316
 
20083
			}#if end
20317
			}#if end
20084
		
20318
 
20085
		/*
20319
		/*
20086
		#輸出參考
20320
		#輸出參考
20087
		3: ens2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
20321
		3: ens2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
20088
		    link/ether 52:54:11:12:35:02 brd ff:ff:ff:ff:ff:ff
20322
		    link/ether 52:54:11:12:35:02 brd ff:ff:ff:ff:ff:ff
20089
		    altname enp3s2
20323
		    altname enp3s2
20090
		    altname enx525411123502
20324
		    altname enx525411123502
20091
		    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute ens2
20325
		    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute ens2
20092
		       valid_lft 74728sec preferred_lft 74728sec
20326
		       valid_lft 74728sec preferred_lft 74728sec
20093
		    inet6 fec0::5054:11ff:fe12:3502/64 scope site dynamic noprefixroute 
20327
		    inet6 fec0::5054:11ff:fe12:3502/64 scope site dynamic noprefixroute
20094
		       valid_lft 86029sec preferred_lft 14029sec
20328
		       valid_lft 86029sec preferred_lft 14029sec
20095
		    inet6 fe80::5054:11ff:fe12:3502/64 scope link noprefixroute 
20329
		    inet6 fe80::5054:11ff:fe12:3502/64 scope link noprefixroute
20096
		       valid_lft forever preferred_lft forever
20330
		       valid_lft forever preferred_lft forever
20097
		*/
20331
		*/
20098
	
20332
 
20099
		#函式說明:
20333
		#函式說明:
20100
		#呼叫shell執行系統命令,並取得回傳的內容.
20334
		#呼叫shell執行系統命令,並取得回傳的內容.
20101
		#回傳結果:
20335
		#回傳結果:
20102
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20336
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20103
		#$result["error"],錯誤訊息陣列.
20337
		#$result["error"],錯誤訊息陣列.
Line 20153... Line 20387...
20153
		#備註:
20387
		#備註:
20154
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
20388
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
20155
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
20389
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
20156
		$callShell=external::callShell($conf["external::callShell"]);
20390
		$callShell=external::callShell($conf["external::callShell"]);
20157
		unset($conf["external::callShell"]);
20391
		unset($conf["external::callShell"]);
20158
	
20392
 
20159
		#如果檢查參數失敗
20393
		#如果檢查參數失敗
20160
		if($callShell["status"]==="false"){
20394
		if($callShell["status"]==="false"){
20161
 
20395
 
20162
			#設置執行失敗
20396
			#設置執行失敗
20163
			$result["status"]="false";
20397
			$result["status"]="false";
Line 20167... Line 20401...
20167
 
20401
 
20168
			#回傳結果
20402
			#回傳結果
20169
			return $result;
20403
			return $result;
20170
 
20404
 
20171
			}#if end
20405
			}#if end
20172
		
20406
 
20173
		#ip addr show [Network Interface name]
20407
		#ip addr show [Network Interface name]
20174
		#$callShell["output"];
20408
		#$callShell["output"];
20175
	
20409
 
20176
		#函式說明:
20410
		#函式說明:
20177
		#尋找多個字串中是否含有符合多個格式之一的內容,且回傳解析好的變數數值.
20411
		#尋找多個字串中是否含有符合多個格式之一的內容,且回傳解析好的變數數值.
20178
		#回傳結果:
20412
		#回傳結果:
20179
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20413
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20180
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
20414
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 20193... Line 20427...
20193
		#無.
20427
		#無.
20194
		#備註:
20428
		#備註:
20195
		#無.
20429
		#無.
20196
		$getMatchFormatsStrings=search::getMatchFormatsStrings($conf["search::getMatchFormatsStrings"]);
20430
		$getMatchFormatsStrings=search::getMatchFormatsStrings($conf["search::getMatchFormatsStrings"]);
20197
		unset($conf["search::getMatchFormatsStrings"]);
20431
		unset($conf["search::getMatchFormatsStrings"]);
20198
	
20432
 
20199
		#如果執行出錯
20433
		#如果執行出錯
20200
		if($getMatchFormatsStrings["status"]==="false"){
20434
		if($getMatchFormatsStrings["status"]==="false"){
20201
		
20435
 
20202
			#設置執行失敗
20436
			#設置執行失敗
20203
			$result["status"]="false";
20437
			$result["status"]="false";
20204
 
20438
 
20205
			#設置執行錯誤訊息
20439
			#設置執行錯誤訊息
20206
			$result["error"]=$getMatchFormatsStrings;
20440
			$result["error"]=$getMatchFormatsStrings;
20207
 
20441
 
20208
			#回傳結果
20442
			#回傳結果
20209
			return $result;
20443
			return $result;
20210
		
20444
 
20211
			}#if end
20445
			}#if end
20212
			
20446
 
20213
		#如果沒有ip的關鍵字
20447
		#如果沒有ip的關鍵字
20214
		if($getMatchFormatsStrings["found"]==="false"){
20448
		if($getMatchFormatsStrings["found"]==="false"){
20215
		
20449
 
20216
			#設置執行失敗
20450
			#設置執行失敗
20217
			$result["status"]="false";
20451
			$result["status"]="false";
20218
 
20452
 
20219
			#設置執行錯誤訊息
20453
			#設置執行錯誤訊息
20220
			$result["error"]=$getMatchFormatsStrings;
20454
			$result["error"]=$getMatchFormatsStrings;
20221
 
20455
 
20222
			#回傳結果
20456
			#回傳結果
20223
			return $result;
20457
			return $result;
20224
		
20458
 
20225
			}#if end
20459
			}#if end
20226
		
20460
 
20227
		#初始化儲存ip地址的陣列
20461
		#初始化儲存ip地址的陣列
20228
		$result["content"]=array();
20462
		$result["content"]=array();
20229
		
20463
 
20230
		#針對每個符合的行結果
20464
		#針對每個符合的行結果
20231
		foreach($getMatchFormatsStrings["content"] as $ipInfo){
20465
		foreach($getMatchFormatsStrings["content"] as $ipInfo){
20232
		
20466
 
20233
			#var_dump(__LINE__,$ipInfo);
20467
			#var_dump(__LINE__,$ipInfo);
20234
		
20468
 
20235
			#針對每個ip資訊
20469
			#針對每個ip資訊
20236
			foreach($ipInfo["content"] as $ip){
20470
			foreach($ipInfo["content"] as $ip){
20237
			
20471
 
20238
				#儲存 ip 地址
20472
				#儲存 ip 地址
20239
				$result["content"][]=$ip[1]."/".$ip[2];
20473
				$result["content"][]=$ip[1]."/".$ip[2];
20240
			
20474
 
20241
				}#foreach end
20475
				}#foreach end
20242
		
20476
 
20243
			}#foreach end
20477
			}#foreach end
20244
		
20478
 
20245
		#設置執行正常
20479
		#設置執行正常
20246
		$result["status"]="true";
20480
		$result["status"]="true";
20247
	
20481
 
20248
		#回傳結果
20482
		#回傳結果
20249
		return $result;
20483
		return $result;
20250
	
20484
 
20251
		}#function ipAddrShow end
20485
		}#function ipAddrShow end
20252
	
20486
 
20253
	/*
20487
	/*
20254
	#函式說明:
20488
	#函式說明:
20255
	#建立腳本檔案.
20489
	#建立腳本檔案.
20256
	#回傳結果:
20490
	#回傳結果:
20257
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20491
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 20272... Line 20506...
20272
	#無.
20506
	#無.
20273
	#備註:
20507
	#備註:
20274
	#無.
20508
	#無.
20275
	*/
20509
	*/
20276
	public static function createBatch(&$conf){
20510
	public static function createBatch(&$conf){
20277
	
20511
 
20278
		#初始化要回傳的結果
20512
		#初始化要回傳的結果
20279
		$result=array();
20513
		$result=array();
20280
 
20514
 
20281
		#取得當前執行的函數名稱
20515
		#取得當前執行的函數名稱
20282
		$result["function"]=__FUNCTION__;
20516
		$result["function"]=__FUNCTION__;
Line 20317... Line 20551...
20317
 
20551
 
20318
			#回傳結果
20552
			#回傳結果
20319
			return $result;
20553
			return $result;
20320
 
20554
 
20321
			}#if end
20555
			}#if end
20322
	
20556
 
20323
		#函式說明:
20557
		#函式說明:
20324
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
20558
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
20325
		#回傳結果:
20559
		#回傳結果:
20326
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20560
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20327
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
20561
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 20370... Line 20604...
20370
		#array_keys=>http://php.net/manual/en/function.array-keys.php
20604
		#array_keys=>http://php.net/manual/en/function.array-keys.php
20371
		#備註:
20605
		#備註:
20372
		#無.
20606
		#無.
20373
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
20607
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
20374
		unset($conf["variableCheck::checkArguments"]);
20608
		unset($conf["variableCheck::checkArguments"]);
20375
	
20609
 
20376
		#如果執行失敗
20610
		#如果執行失敗
20377
		if($callShell["status"]==="false"){
20611
		if($callShell["status"]==="false"){
20378
 
20612
 
20379
			#設置執行失敗
20613
			#設置執行失敗
20380
			$result["status"]="false";
20614
			$result["status"]="false";
Line 20384... Line 20618...
20384
 
20618
 
20385
			#回傳結果
20619
			#回傳結果
20386
			return $result;
20620
			return $result;
20387
 
20621
 
20388
			}#if end
20622
			}#if end
20389
			
20623
 
20390
		#如果未通過檢查
20624
		#如果未通過檢查
20391
		if($callShell["passed"]==="false"){
20625
		if($callShell["passed"]==="false"){
20392
 
20626
 
20393
			#設置執行失敗
20627
			#設置執行失敗
20394
			$result["status"]="false";
20628
			$result["status"]="false";
Line 20398... Line 20632...
20398
 
20632
 
20399
			#回傳結果
20633
			#回傳結果
20400
			return $result;
20634
			return $result;
20401
 
20635
 
20402
			}#if end
20636
			}#if end
20403
	
20637
 
20404
		#初始化要執行的執行字串陣列
20638
		#初始化要執行的執行字串陣列
20405
		$multiLineCmdStr="";
20639
		$multiLineCmdStr="";
20406
		
20640
 
20407
		#如果有設定 $conf["excuteBy"]
20641
		#如果有設定 $conf["excuteBy"]
20408
		if(isset($conf["excuteBy"])){
20642
		if(isset($conf["excuteBy"])){
20409
		
20643
 
20410
			#檢查 $conf["excuteBy"] 是否存在
20644
			#檢查 $conf["excuteBy"] 是否存在
20411
			#函式說明:
20645
			#函式說明:
20412
			#檢查指令是否存在
20646
			#檢查指令是否存在
20413
			#回傳結果:
20647
			#回傳結果:
20414
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20648
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 20417... Line 20651...
20417
			#$result["argu"],使用的參數.
20651
			#$result["argu"],使用的參數.
20418
			#$result["founded"],指令是否存在,"true"代表存在,"false"代表存在.
20652
			#$result["founded"],指令是否存在,"true"代表存在,"false"代表存在.
20419
			#$result["cmdFullPath"],指令的絕對路徑.
20653
			#$result["cmdFullPath"],指令的絕對路徑.
20420
			#必填參數:
20654
			#必填參數:
20421
			#$conf["cmd"],"字串",要查詢的指令.
20655
			#$conf["cmd"],"字串",要查詢的指令.
20422
			$conf["cmd::checkCmdExist"]["cmd"]=$conf["excuteBy"];			
20656
			$conf["cmd::checkCmdExist"]["cmd"]=$conf["excuteBy"];
20423
			#可省略參數:
20657
			#可省略參數:
20424
			#無.
20658
			#無.
20425
			#參考資料:
20659
			#參考資料:
20426
			#無.
20660
			#無.
20427
			#備註:
20661
			#備註:
20428
			#無.
20662
			#無.
20429
			$checkCmdExist=cmd::checkCmdExist($conf["cmd::checkCmdExist"]);
20663
			$checkCmdExist=cmd::checkCmdExist($conf["cmd::checkCmdExist"]);
20430
			unset($conf["cmd::checkCmdExist"]);
20664
			unset($conf["cmd::checkCmdExist"]);
20431
		
20665
 
20432
			#若執行失敗
20666
			#若執行失敗
20433
			if($checkCmdExist["status"]==="false"){
20667
			if($checkCmdExist["status"]==="false"){
20434
			
20668
 
20435
				#設置執行失敗
20669
				#設置執行失敗
20436
				$result["status"]="false";
20670
				$result["status"]="false";
20437
 
20671
 
20438
				#設置執行錯誤訊息
20672
				#設置執行錯誤訊息
20439
				$result["error"]=$checkCmdExist;
20673
				$result["error"]=$checkCmdExist;
20440
 
20674
 
20441
				#回傳結果
20675
				#回傳結果
20442
				return $result;
20676
				return $result;
20443
			
20677
 
20444
				}#if end
20678
				}#if end
20445
				
20679
 
20446
			#若指令不存在
20680
			#若指令不存在
20447
			if($checkCmdExist["founded"]==="false"){
20681
			if($checkCmdExist["founded"]==="false"){
20448
			
20682
 
20449
				#設置執行失敗
20683
				#設置執行失敗
20450
				$result["status"]="false";
20684
				$result["status"]="false";
20451
 
20685
 
20452
				#設置執行錯誤訊息
20686
				#設置執行錯誤訊息
20453
				$result["error"]=$checkCmdExist;
20687
				$result["error"]=$checkCmdExist;
20454
 
20688
 
20455
				#回傳結果
20689
				#回傳結果
20456
				return $result;
20690
				return $result;
20457
			
20691
 
20458
				}#if end
20692
				}#if end
20459
		
20693
 
20460
			#設置要透過哪個程式執行
20694
			#設置要透過哪個程式執行
20461
			$multiLineCmdStr=$multiLineCmdStr."#!".$checkCmdExist["cmdFullPath"].PHP_EOL;
20695
			$multiLineCmdStr=$multiLineCmdStr."#!".$checkCmdExist["cmdFullPath"].PHP_EOL;
20462
		
20696
 
20463
			}#if end
20697
			}#if end
20464
		
20698
 
20465
		#針對每行指令
20699
		#針對每行指令
20466
		foreach($conf["cmd"] as $index=>$cmd){
20700
		foreach($conf["cmd"] as $index=>$cmd){
20467
		
20701
 
20468
			#函式說明:
20702
			#函式說明:
20469
			#呼叫shell執行系統命令,並取得回傳的內容.
20703
			#呼叫shell執行系統命令,並取得回傳的內容.
20470
			#回傳結果:
20704
			#回傳結果:
20471
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20705
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
20472
			#$result["error"],錯誤訊息陣列.
20706
			#$result["error"],錯誤訊息陣列.
Line 20522... Line 20756...
20522
			#備註:
20756
			#備註:
20523
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
20757
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
20524
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
20758
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
20525
			$callShell=external::callShell($conf["external::callShell"]);
20759
			$callShell=external::callShell($conf["external::callShell"]);
20526
			unset($conf["external::callShell"]);
20760
			unset($conf["external::callShell"]);
20527
		
20761
 
20528
			#如果分割字串失敗
20762
			#如果分割字串失敗
20529
			if($callShell["status"]==="false"){
20763
			if($callShell["status"]==="false"){
20530
 
20764
 
20531
				#設置執行失敗
20765
				#設置執行失敗
20532
				$result["status"]="false";
20766
				$result["status"]="false";
Line 20536... Line 20770...
20536
 
20770
 
20537
				#回傳結果
20771
				#回傳結果
20538
				return $result;
20772
				return $result;
20539
 
20773
 
20540
				}#if end
20774
				}#if end
20541
		
20775
 
20542
			#儲存要執行的指令字串
20776
			#儲存要執行的指令字串
20543
			$multiLineCmdStr=$multiLineCmdStr.$callShell["cmd"].PHP_EOL;
20777
			$multiLineCmdStr=$multiLineCmdStr.$callShell["cmd"].PHP_EOL;
20544
		
20778
 
20545
			}#foreach end
20779
			}#foreach end
20546
	
20780
 
20547
		#函式說明:
20781
		#函式說明:
20548
		#將字串寫入到檔案
20782
		#將字串寫入到檔案
20549
		#回傳結果:
20783
		#回傳結果:
20550
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
20784
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
20551
		#$result["error"],錯誤訊息陣列.
20785
		#$result["error"],錯誤訊息陣列.
Line 20557... Line 20791...
20557
		#$result["argu"],使用的參數.
20791
		#$result["argu"],使用的參數.
20558
		#必填參數:
20792
		#必填參數:
20559
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
20793
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
20560
		$conf["fileAccess::writeTextIntoFile"]["fileArgu"]=__FILE__;
20794
		$conf["fileAccess::writeTextIntoFile"]["fileArgu"]=__FILE__;
20561
		#可省略參數:
20795
		#可省略參數:
20562
		
20796
 
20563
		#如果有設置 fileName
20797
		#如果有設置 fileName
20564
		if(isset($conf["fileName"])){
20798
		if(isset($conf["fileName"])){
20565
		
20799
 
20566
			#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
20800
			#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
20567
			$conf["fileAccess::writeTextIntoFile"]["fileName"]=$conf["fileName"];
20801
			$conf["fileAccess::writeTextIntoFile"]["fileName"]=$conf["fileName"];
20568
		
20802
 
20569
			}#if end
20803
			}#if end
20570
		
20804
 
20571
		#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
20805
		#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
20572
		$conf["fileAccess::writeTextIntoFile"]["inputString"]=$multiLineCmdStr;
20806
		$conf["fileAccess::writeTextIntoFile"]["inputString"]=$multiLineCmdStr;
20573
		#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
20807
		#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
20574
		#$conf["writeMethod"]="a";
20808
		#$conf["writeMethod"]="a";
20575
		#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
20809
		#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
Line 20584... Line 20818...
20584
		#無.
20818
		#無.
20585
		#備註:
20819
		#備註:
20586
		#無.
20820
		#無.
20587
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
20821
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
20588
		unset($conf["fileAccess::writeTextIntoFile"]);
20822
		unset($conf["fileAccess::writeTextIntoFile"]);
20589
	
20823
 
20590
		#如果執行失敗
20824
		#如果執行失敗
20591
		if($writeTextIntoFile["status"]==="false"){
20825
		if($writeTextIntoFile["status"]==="false"){
20592
		
20826
 
20593
			#設置執行失敗
20827
			#設置執行失敗
20594
			$result["status"]="false";
20828
			$result["status"]="false";
20595
 
20829
 
20596
			#設置執行錯誤訊息
20830
			#設置執行錯誤訊息
20597
			$result["error"]=$callShell;
20831
			$result["error"]=$callShell;
20598
 
20832
 
20599
			#回傳結果
20833
			#回傳結果
20600
			return $result;
20834
			return $result;
20601
 
20835
 
20602
			}#if end
20836
			}#if end
20603
			
20837
 
20604
		#設置 腳本檔案 的位置與名稱
20838
		#設置 腳本檔案 的位置與名稱
20605
		$result["content"]=$writeTextIntoFile["fileInfo"]["createdFilePathAndName"];
20839
		$result["content"]=$writeTextIntoFile["fileInfo"]["createdFilePathAndName"];
20606
		
20840
 
20607
		#設置執行正常
20841
		#設置執行正常
20608
		$result["status"]="true";
20842
		$result["status"]="true";
20609
	
20843
 
20610
		#回傳結果
20844
		#回傳結果
20611
		return $result;
20845
		return $result;
20612
	
20846
 
20613
		}#function createBatch end
20847
		}#function createBatch end
20614
 
20848
 
20615
	/*
20849
	/*
20616
	#函式說明:
20850
	#函式說明:
20617
	#export svn 上的檔案目錄,進行打包放到遠端伺服器上並進行安裝或更新的動作.
20851
	#export svn 上的檔案目錄,進行打包放到遠端伺服器上並進行安裝或更新的動作.
Line 20906... Line 21140...
20906
 
21140
 
20907
					#寫設定檔
21141
					#寫設定檔
20908
 
21142
 
20909
					#取得新設定檔的名稱
21143
					#取得新設定檔的名稱
20910
					$ncn=$conf["newConfFile"]["val"];
21144
					$ncn=$conf["newConfFile"]["val"];
20911
					
21145
 
20912
					#卸除新設定檔的變數陣列
21146
					#卸除新設定檔的變數陣列
20913
					unset($conf["newConfFile"]);
21147
					unset($conf["newConfFile"]);
20914
					
21148
 
20915
					#初始化新設定檔的內容
21149
					#初始化新設定檔的內容
20916
					$ncc="";
21150
					$ncc="";
20917
					
21151
 
20918
					#針對每個conf
21152
					#針對每個conf
20919
					foreach($conf as $varInPhp=>$info){
21153
					foreach($conf as $varInPhp=>$info){
20920
 
21154
 
20921
						#如果是陣列
21155
						#如果是陣列
20922
						if(is_array($info["val"])){
21156
						if(is_array($info["val"])){
Line 20954... Line 21188...
20954
								}#else end
21188
								}#else end
20955
 
21189
 
20956
							}#else end
21190
							}#else end
20957
 
21191
 
20958
						}#foreach end
21192
						}#foreach end
20959
					
21193
 
20960
					#函式說明:
21194
					#函式說明:
20961
					#將字串寫入到檔案
21195
					#將字串寫入到檔案
20962
					#回傳結果:
21196
					#回傳結果:
20963
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
21197
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
20964
					#$result["error"],錯誤訊息陣列.
21198
					#$result["error"],錯誤訊息陣列.
Line 20993... Line 21227...
20993
					$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
21227
					$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
20994
					unset($conf["fileAccess::writeTextIntoFile"]);
21228
					unset($conf["fileAccess::writeTextIntoFile"]);
20995
 
21229
 
20996
					#如果執行失敗
21230
					#如果執行失敗
20997
					if($writeTextIntoFile["status"]==="false"){
21231
					if($writeTextIntoFile["status"]==="false"){
20998
					
21232
 
20999
						#設置執行失敗
21233
						#設置執行失敗
21000
						$result["status"]="false";
21234
						$result["status"]="false";
21001
 
21235
 
21002
						#設置執行錯誤訊息
21236
						#設置執行錯誤訊息
21003
						$result["error"]=$writeTextIntoFile;
21237
						$result["error"]=$writeTextIntoFile;
21004
 
21238
 
21005
						#回傳結果
21239
						#回傳結果
21006
						return $result;
21240
						return $result;
21007
					
21241
 
21008
						}#if end
21242
						}#if end
21009
 
21243
 
21010
					#提示建立設定檔案完成
21244
					#提示建立設定檔案完成
21011
					echo "設定檔「".$ncn."」建立完成".PHP_EOL;
21245
					echo "設定檔「".$ncn."」建立完成".PHP_EOL;
21012
 
21246
 
Line 21144... Line 21378...
21144
		$callShell=external::callShell($conf["external::callShell"]);
21378
		$callShell=external::callShell($conf["external::callShell"]);
21145
		unset($conf["external::callShell"]);
21379
		unset($conf["external::callShell"]);
21146
 
21380
 
21147
		#如果執行失敗
21381
		#如果執行失敗
21148
		if($callShell["status"]==="false"){
21382
		if($callShell["status"]==="false"){
21149
		
21383
 
21150
			#設置執行失敗
21384
			#設置執行失敗
21151
			$result["status"]="false";
21385
			$result["status"]="false";
21152
 
21386
 
21153
			#設置執行錯誤訊息
21387
			#設置執行錯誤訊息
21154
			$result["error"]=$callShell;
21388
			$result["error"]=$callShell;
21155
 
21389
 
21156
			#回傳結果
21390
			#回傳結果
21157
			return $result;
21391
			return $result;
21158
		
21392
 
21159
			}#if end
21393
			}#if end
21160
 
21394
 
21161
		#初始化要是給 callShellHelper 的指令與參數陣列
21395
		#初始化要是給 callShellHelper 的指令與參數陣列
21162
		$paramsToCallShellHelper=array();
21396
		$paramsToCallShellHelper=array();
21163
 
21397
 
21164
		#如果 $svnPass 有數值
21398
		#如果 $svnPass 有數值
21165
		if($svnPass!==""){
21399
		if($svnPass!==""){
21166
		
21400
 
21167
			#設置要使用 ssh 密碼
21401
			#設置要使用 ssh 密碼
21168
			$paramsToCallShellHelper[]="sshpass";
21402
			$paramsToCallShellHelper[]="sshpass";
21169
			
21403
 
21170
			#設置密碼參數
21404
			#設置密碼參數
21171
			$paramsToCallShellHelper[]="-p";
21405
			$paramsToCallShellHelper[]="-p";
21172
			
21406
 
21173
			#設置密碼
21407
			#設置密碼
21174
			$paramsToCallShellHelper[]=$svnPass;
21408
			$paramsToCallShellHelper[]=$svnPass;
21175
		
21409
 
21176
			}#if end
21410
			}#if end
21177
			
21411
 
21178
		#設置要使用 svn
21412
		#設置要使用 svn
21179
		$paramsToCallShellHelper[]="svn";
21413
		$paramsToCallShellHelper[]="svn";
21180
		
21414
 
21181
		#設置要 export
21415
		#設置要 export
21182
		$paramsToCallShellHelper[]="export";
21416
		$paramsToCallShellHelper[]="export";
21183
 
21417
 
21184
		#設置 svn+ssh 的路徑
21418
		#設置 svn+ssh 的路徑
21185
		$paramsToCallShellHelper[]=$svnUrl;
21419
		$paramsToCallShellHelper[]=$svnUrl;
21186
		
21420
 
21187
		#初始化給svn+ssh使用的ssh參數
21421
		#初始化給svn+ssh使用的ssh參數
21188
		$sshOptionsForSvn=array();
21422
		$sshOptionsForSvn=array();
21189
		
21423
 
21190
		#如果有指定 svnSshPrivateKey
21424
		#如果有指定 svnSshPrivateKey
21191
		if($svnSshPrivateKey!==""){
21425
		if($svnSshPrivateKey!==""){
21192
		
21426
 
21193
			#如果 給svn+ssh使用的ssh參數 預設為空
21427
			#如果 給svn+ssh使用的ssh參數 預設為空
21194
			if($sshOptionsForSvn===array()){
21428
			if($sshOptionsForSvn===array()){
21195
			
21429
 
21196
				#設置要指定 ssh 參數. 
21430
				#設置要指定 ssh 參數.
21197
				$sshOptionsForSvn[]="--config-option=config:tunnels:ssh=ssh";
21431
				$sshOptionsForSvn[]="--config-option=config:tunnels:ssh=ssh";
21198
			
21432
 
21199
				}#if end
21433
				}#if end
21200
				
21434
 
21201
			#設置 private key 的參數.
21435
			#設置 private key 的參數.
21202
			$sshOptionsForSvn[]="-i";
21436
			$sshOptionsForSvn[]="-i";
21203
			
21437
 
21204
			#設置 private key 的路徑與名稱.
21438
			#設置 private key 的路徑與名稱.
21205
			$sshOptionsForSvn[]=$svnSshPrivateKey;
21439
			$sshOptionsForSvn[]=$svnSshPrivateKey;
21206
		
21440
 
21207
			}#if end
21441
			}#if end
21208
			
21442
 
21209
		#如果有指定 svnPort
21443
		#如果有指定 svnPort
21210
		if($svnPort!==""){
21444
		if($svnPort!==""){
21211
		
21445
 
21212
			#如果 給svn+ssh使用的ssh參數 預設為空
21446
			#如果 給svn+ssh使用的ssh參數 預設為空
21213
			if($sshOptionsForSvn===array()){
21447
			if($sshOptionsForSvn===array()){
21214
			
21448
 
21215
				#設置要指定 ssh 參數. 
21449
				#設置要指定 ssh 參數.
21216
				$sshOptionsForSvn[]="--config-option=config:tunnels:ssh=ssh";
21450
				$sshOptionsForSvn[]="--config-option=config:tunnels:ssh=ssh";
21217
			
21451
 
21218
				}#if end
21452
				}#if end
21219
				
21453
 
21220
			#設置 port 的參數.
21454
			#設置 port 的參數.
21221
			$sshOptionsForSvn[]="-p";
21455
			$sshOptionsForSvn[]="-p";
21222
			
21456
 
21223
			#設置 port.
21457
			#設置 port.
21224
			$sshOptionsForSvn[]=$svnPort;
21458
			$sshOptionsForSvn[]=$svnPort;
21225
		
21459
 
21226
			}#if end
21460
			}#if end
21227
			
21461
 
21228
		#Merge $paramsToCallShellHelper 跟 $sshOptionsForSvn
21462
		#Merge $paramsToCallShellHelper 跟 $sshOptionsForSvn
21229
		#函式說明:
21463
		#函式說明:
21230
		#將多個一維陣列串聯起來,key從0開始排序.
21464
		#將多個一維陣列串聯起來,key從0開始排序.
21231
		#回傳的結果:
21465
		#回傳的結果:
21232
		#$result["status"],"true"表執行正常,"false"代表執行不正常.
21466
		#$result["status"],"true"表執行正常,"false"代表執行不正常.
Line 21246... Line 21480...
21246
		$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
21480
		$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
21247
		unset($conf["arrays::mergeArray"]);
21481
		unset($conf["arrays::mergeArray"]);
21248
 
21482
 
21249
		#如果執行失敗
21483
		#如果執行失敗
21250
		if($mergeArray["status"]==="false"){
21484
		if($mergeArray["status"]==="false"){
21251
		
21485
 
21252
			#設置執行失敗
21486
			#設置執行失敗
21253
			$result["status"]="false";
21487
			$result["status"]="false";
21254
 
21488
 
21255
			#設置執行錯誤訊息
21489
			#設置執行錯誤訊息
21256
			$result["error"]=$mergeArray;
21490
			$result["error"]=$mergeArray;
21257
 
21491
 
21258
			#回傳結果
21492
			#回傳結果
21259
			return $result;
21493
			return $result;
21260
		
21494
 
21261
			}#if end
21495
			}#if end
21262
			
21496
 
21263
		#函式說明:
21497
		#函式說明:
21264
		#解析指令與參數,回傳指令與參數給 callShell 函式使用.
21498
		#解析指令與參數,回傳指令與參數給 callShell 函式使用.
21265
		#回傳結果:
21499
		#回傳結果:
21266
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
21500
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
21267
		#$result["error"],錯誤訊息陣列.
21501
		#$result["error"],錯誤訊息陣列.
Line 21278... Line 21512...
21278
		#array_shift=>https://www.php.net/manual/en/function.array-shift.php
21512
		#array_shift=>https://www.php.net/manual/en/function.array-shift.php
21279
		#備註:
21513
		#備註:
21280
		#無.
21514
		#無.
21281
		$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
21515
		$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
21282
		unset($conf["external::callShellHelper"]);
21516
		unset($conf["external::callShellHelper"]);
21283
	
21517
 
21284
		#如果執行失敗
21518
		#如果執行失敗
21285
		if($callShellHelper["status"]==="false"){
21519
		if($callShellHelper["status"]==="false"){
21286
		
21520
 
21287
			#設置執行失敗
21521
			#設置執行失敗
21288
			$result["status"]="false";
21522
			$result["status"]="false";
21289
 
21523
 
21290
			#設置執行錯誤訊息
21524
			#設置執行錯誤訊息
21291
			$result["error"]=$callShellHelper;
21525
			$result["error"]=$callShellHelper;
21292
 
21526
 
21293
			#回傳結果
21527
			#回傳結果
21294
			return $result;
21528
			return $result;
21295
		
21529
 
21296
			}#if end
21530
			}#if end
21297
	
21531
 
21298
		#輸出位於 $svnUrl 上的svn code,使用的密碼為 $svnPass
21532
		#輸出位於 $svnUrl 上的svn code,使用的密碼為 $svnPass
21299
		#函式說明:
21533
		#函式說明:
21300
		#呼叫shell執行系統命令,並取得回傳的內容.
21534
		#呼叫shell執行系統命令,並取得回傳的內容.
21301
		#回傳結果:
21535
		#回傳結果:
21302
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
21536
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 21356... Line 21590...
21356
		$callShell=external::callShell($conf["external::callShell"]);
21590
		$callShell=external::callShell($conf["external::callShell"]);
21357
		unset($conf["external::callShell"]);
21591
		unset($conf["external::callShell"]);
21358
 
21592
 
21359
		#如果執行失敗
21593
		#如果執行失敗
21360
		if($callShell["status"]==="false"){
21594
		if($callShell["status"]==="false"){
21361
		
21595
 
21362
			#設置執行失敗
21596
			#設置執行失敗
21363
			$result["status"]="false";
21597
			$result["status"]="false";
21364
 
21598
 
21365
			#設置執行錯誤訊息
21599
			#設置執行錯誤訊息
21366
			$result["error"]=$callShell;
21600
			$result["error"]=$callShell;
21367
 
21601
 
21368
			#回傳結果
21602
			#回傳結果
21369
			return $result;
21603
			return $result;
21370
		
21604
 
21371
			}#if end
21605
			}#if end
21372
		
21606
 
21373
		#複製要包的版本
21607
		#複製要包的版本
21374
		#函式說明:
21608
		#函式說明:
21375
		#呼叫shell執行系統命令,並取得回傳的內容.
21609
		#呼叫shell執行系統命令,並取得回傳的內容.
21376
		#回傳結果:
21610
		#回傳結果:
21377
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
21611
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 21431... Line 21665...
21431
		$callShell=external::callShell($conf["external::callShell"]);
21665
		$callShell=external::callShell($conf["external::callShell"]);
21432
		unset($conf["external::callShell"]);
21666
		unset($conf["external::callShell"]);
21433
 
21667
 
21434
		#如果執行失敗
21668
		#如果執行失敗
21435
		if($callShell["status"]==="false"){
21669
		if($callShell["status"]==="false"){
21436
		
21670
 
21437
			#設置執行失敗
21671
			#設置執行失敗
21438
			$result["status"]="false";
21672
			$result["status"]="false";
21439
 
21673
 
21440
			#設置執行錯誤訊息
21674
			#設置執行錯誤訊息
21441
			$result["error"]=$callShell;
21675
			$result["error"]=$callShell;
21442
 
21676
 
21443
			#回傳結果
21677
			#回傳結果
21444
			return $result;
21678
			return $result;
21445
		
21679
 
21446
			}#if end
21680
			}#if end
21447
 
21681
 
21448
		#設置複製到網頁Server前要移除的檔案(不覆蓋到Server上既有的檔案)
21682
		#設置複製到網頁Server前要移除的檔案(不覆蓋到Server上既有的檔案)
21449
 
21683
 
21450
		#移除不需要包出去的目錄
21684
		#移除不需要包出去的目錄
Line 21515... Line 21749...
21515
			$callShell=external::callShell($conf["external::callShell"]);
21749
			$callShell=external::callShell($conf["external::callShell"]);
21516
			unset($conf["external::callShell"]);
21750
			unset($conf["external::callShell"]);
21517
 
21751
 
21518
			#如果執行失敗
21752
			#如果執行失敗
21519
			if($callShell["status"]==="false"){
21753
			if($callShell["status"]==="false"){
21520
			
21754
 
21521
				#設置執行失敗
21755
				#設置執行失敗
21522
				$result["status"]="false";
21756
				$result["status"]="false";
21523
 
21757
 
21524
				#設置執行錯誤訊息
21758
				#設置執行錯誤訊息
21525
				$result["error"]=$callShell;
21759
				$result["error"]=$callShell;
21526
 
21760
 
21527
				#回傳結果
21761
				#回傳結果
21528
				return $result;
21762
				return $result;
21529
			
21763
 
21530
				}#if end
21764
				}#if end
21531
 
21765
 
21532
			}#foreach end
21766
			}#foreach end
21533
 
21767
 
21534
		#打包目標 $target 成 $target.'tar.xz'
21768
		#打包目標 $target 成 $target.'tar.xz'
Line 21562... Line 21796...
21562
		$makeTarZstFile=cmd::makeTarZstFile($conf["cmd::makeTarZstFile"]);
21796
		$makeTarZstFile=cmd::makeTarZstFile($conf["cmd::makeTarZstFile"]);
21563
		unset($conf["cmd::makeTarZstFile"]);
21797
		unset($conf["cmd::makeTarZstFile"]);
21564
 
21798
 
21565
		#如果執行失敗
21799
		#如果執行失敗
21566
		if($makeTarZstFile["status"]==="false"){
21800
		if($makeTarZstFile["status"]==="false"){
21567
		
21801
 
21568
			#設置執行失敗
21802
			#設置執行失敗
21569
			$result["status"]="false";
21803
			$result["status"]="false";
21570
 
21804
 
21571
			#設置執行錯誤訊息
21805
			#設置執行錯誤訊息
21572
			$result["error"]=$callShell;
21806
			$result["error"]=$callShell;
21573
 
21807
 
21574
			#回傳結果
21808
			#回傳結果
21575
			return $result;
21809
			return $result;
21576
		
21810
 
21577
			}#if end
21811
			}#if end
21578
 
21812
 
21579
		#建立將打包好的壓縮檔放到 Server 的腳本
21813
		#建立將打包好的壓縮檔放到 Server 的腳本
21580
		#建立temp目錄
21814
		#建立temp目錄
21581
		#進入 temp 目錄
21815
		#進入 temp 目錄
21582
		#把包好的程式放到伺服器端
21816
		#把包好的程式放到伺服器端
21583
		
21817
 
21584
		#函式說明:
21818
		#函式說明:
21585
		#建立腳本檔案.
21819
		#建立腳本檔案.
21586
		#回傳結果:
21820
		#回傳結果:
21587
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
21821
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
21588
		#$result["error"],錯誤訊息陣列.
21822
		#$result["error"],錯誤訊息陣列.
Line 21602... Line 21836...
21602
		#無.
21836
		#無.
21603
		#備註:
21837
		#備註:
21604
		#無.
21838
		#無.
21605
		$createBatch=cmd::createBatch($conf["cmd::createBatch"]);
21839
		$createBatch=cmd::createBatch($conf["cmd::createBatch"]);
21606
		unset($conf["cmd::createBatch"]);
21840
		unset($conf["cmd::createBatch"]);
21607
		
21841
 
21608
		#如果執行失敗
21842
		#如果執行失敗
21609
		if($createBatch["status"]==="false"){
21843
		if($createBatch["status"]==="false"){
21610
		
21844
 
21611
			#設置執行失敗
21845
			#設置執行失敗
21612
			$result["status"]="false";
21846
			$result["status"]="false";
21613
 
21847
 
21614
			#設置執行錯誤訊息
21848
			#設置執行錯誤訊息
21615
			$result["error"]=$callShell;
21849
			$result["error"]=$callShell;
21616
 
21850
 
21617
			#回傳結果
21851
			#回傳結果
21618
			return $result;
21852
			return $result;
21619
		
21853
 
21620
			}#if end
21854
			}#if end
21621
		
21855
 
21622
		#取得腳本
21856
		#取得腳本
21623
		$batchFile=$createBatch["content"];
21857
		$batchFile=$createBatch["content"];
21624
 
21858
 
21625
		#初始化給 sftp 使用的指令跟參數
21859
		#初始化給 sftp 使用的指令跟參數
21626
		$paramsForSshServer=array();
21860
		$paramsForSshServer=array();
21627
 
21861
 
21628
		#如果有指定 $sshServerPassword
21862
		#如果有指定 $sshServerPassword
21629
		if($sshServerPassword!==""){
21863
		if($sshServerPassword!==""){
21630
		
21864
 
21631
			#使用 sshpass 指令
21865
			#使用 sshpass 指令
21632
			$paramsForSshServer[]="sshpass";
21866
			$paramsForSshServer[]="sshpass";
21633
			
21867
 
21634
			#設置要指定密碼
21868
			#設置要指定密碼
21635
			$paramsForSshServer[]="-p";
21869
			$paramsForSshServer[]="-p";
21636
			
21870
 
21637
			#設置要使用的密碼
21871
			#設置要使用的密碼
21638
			$paramsForSshServer[]=$sshServerPassword;
21872
			$paramsForSshServer[]=$sshServerPassword;
21639
		
21873
 
21640
			}#if end
21874
			}#if end
21641
			
21875
 
21642
		#設置使用 sftp 指令
21876
		#設置使用 sftp 指令
21643
		$paramsForSshServer[]="sftp";
21877
		$paramsForSshServer[]="sftp";
21644
 
21878
 
21645
		#如果 $sshServerPort 不為空
21879
		#如果 $sshServerPort 不為空
21646
		if($sshServerPort!==""){
21880
		if($sshServerPort!==""){
21647
		
21881
 
21648
			#設置要指定 port 
21882
			#設置要指定 port
21649
			$paramsForSshServer[]="-P";
21883
			$paramsForSshServer[]="-P";
21650
			
21884
 
21651
			#設置 port
21885
			#設置 port
21652
			$paramsForSshServer[]=$sshServerPort;
21886
			$paramsForSshServer[]=$sshServerPort;
21653
		
21887
 
21654
			}#if end
21888
			}#if end
21655
			
21889
 
21656
		#如果 sshServerPrivateKey 不為空
21890
		#如果 sshServerPrivateKey 不為空
21657
		if($sshServerPrivateKey!==""){
21891
		if($sshServerPrivateKey!==""){
21658
		
21892
 
21659
			#設置要指定 ssh private key
21893
			#設置要指定 ssh private key
21660
			$paramsForSshServer[]="-i";
21894
			$paramsForSshServer[]="-i";
21661
			
21895
 
21662
			#設置 ssh private key
21896
			#設置 ssh private key
21663
			$paramsForSshServer[]=$sshServerPrivateKey;
21897
			$paramsForSshServer[]=$sshServerPrivateKey;
21664
		
21898
 
21665
			}#if end
21899
			}#if end
21666
 
21900
 
21667
		#設置 sftp 的url以及要使用的賬號
21901
		#設置 sftp 的url以及要使用的賬號
21668
		$paramsForSshServer[]=$sshServerAccount."@".$sshServerDns;
21902
		$paramsForSshServer[]=$sshServerAccount."@".$sshServerDns;
21669
 
21903
 
21670
		#設置要倒入腳本
21904
		#設置要倒入腳本
21671
		$paramsForSshServer[]="<";
21905
		$paramsForSshServer[]="<";
21672
		
21906
 
21673
		#設置要倒入的腳本
21907
		#設置要倒入的腳本
21674
		$paramsForSshServer[]=$batchFile;
21908
		$paramsForSshServer[]=$batchFile;
21675
 
21909
 
21676
		#函式說明:
21910
		#函式說明:
21677
		#解析指令與參數,回傳指令與參數給 callShell 函式使用.
21911
		#解析指令與參數,回傳指令與參數給 callShell 函式使用.
Line 21691... Line 21925...
21691
		#array_shift=>https://www.php.net/manual/en/function.array-shift.php
21925
		#array_shift=>https://www.php.net/manual/en/function.array-shift.php
21692
		#備註:
21926
		#備註:
21693
		#無.
21927
		#無.
21694
		$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
21928
		$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
21695
		unset($conf["external::callShellHelper"]);
21929
		unset($conf["external::callShellHelper"]);
21696
	
21930
 
21697
		#如果執行失敗
21931
		#如果執行失敗
21698
		if($callShellHelper["status"]==="false"){
21932
		if($callShellHelper["status"]==="false"){
21699
		
21933
 
21700
			#設置執行失敗
21934
			#設置執行失敗
21701
			$result["status"]="false";
21935
			$result["status"]="false";
21702
 
21936
 
21703
			#設置執行錯誤訊息
21937
			#設置執行錯誤訊息
21704
			$result["error"]=$callShellHelper;
21938
			$result["error"]=$callShellHelper;
21705
 
21939
 
21706
			#回傳結果
21940
			#回傳結果
21707
			return $result;
21941
			return $result;
21708
		
21942
 
21709
			}#if end
21943
			}#if end
21710
	
21944
 
21711
		#輸出位於 $svnUrl 上的svn code,使用的密碼為 $svnPass
21945
		#輸出位於 $svnUrl 上的svn code,使用的密碼為 $svnPass
21712
		#函式說明:
21946
		#函式說明:
21713
		#呼叫shell執行系統命令,並取得回傳的內容.
21947
		#呼叫shell執行系統命令,並取得回傳的內容.
21714
		#回傳結果:
21948
		#回傳結果:
21715
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
21949
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 21769... Line 22003...
21769
		$callShell=external::callShell($conf["external::callShell"]);
22003
		$callShell=external::callShell($conf["external::callShell"]);
21770
		unset($conf["external::callShell"]);
22004
		unset($conf["external::callShell"]);
21771
 
22005
 
21772
		#如果執行失敗
22006
		#如果執行失敗
21773
		if($callShell["status"]==="false"){
22007
		if($callShell["status"]==="false"){
21774
		
22008
 
21775
			#設置執行失敗
22009
			#設置執行失敗
21776
			$result["status"]="false";
22010
			$result["status"]="false";
21777
 
22011
 
21778
			#設置執行錯誤訊息
22012
			#設置執行錯誤訊息
21779
			$result["error"]=$callShell;
22013
			$result["error"]=$callShell;
21780
 
22014
 
21781
			#回傳結果
22015
			#回傳結果
21782
			return $result;
22016
			return $result;
21783
		
22017
 
21784
			}#if end
22018
			}#if end
21785
 
22019
 
21786
		/*
22020
		/*
21787
		建立連線到Server要做的cmd
22021
		建立連線到Server要做的cmd
21788
		1.將打包好的檔案解壓縮
22022
		1.將打包好的檔案解壓縮
Line 21819... Line 22053...
21819
		#無.
22053
		#無.
21820
		#備註:
22054
		#備註:
21821
		#無.
22055
		#無.
21822
		$createBatch=cmd::createBatch($conf["cmd::createBatch"]);
22056
		$createBatch=cmd::createBatch($conf["cmd::createBatch"]);
21823
		unset($conf["cmd::createBatch"]);
22057
		unset($conf["cmd::createBatch"]);
21824
		
22058
 
21825
		#如果執行失敗
22059
		#如果執行失敗
21826
		if($createBatch["status"]==="false"){
22060
		if($createBatch["status"]==="false"){
21827
		
22061
 
21828
			#設置執行失敗
22062
			#設置執行失敗
21829
			$result["status"]="false";
22063
			$result["status"]="false";
21830
 
22064
 
21831
			#設置執行錯誤訊息
22065
			#設置執行錯誤訊息
21832
			$result["error"]=$createBatch;
22066
			$result["error"]=$createBatch;
21833
 
22067
 
21834
			#回傳結果
22068
			#回傳結果
21835
			return $result;
22069
			return $result;
21836
		
22070
 
21837
			}#if end
22071
			}#if end
21838
		
22072
 
21839
		#取得腳本檔案名稱
22073
		#取得腳本檔案名稱
21840
		$batchFile=$createBatch["content"];
22074
		$batchFile=$createBatch["content"];
21841
 
22075
 
21842
		#初始化給 ssh 使用的指令跟參數
22076
		#初始化給 ssh 使用的指令跟參數
21843
		$paramsForSshServer=array();
22077
		$paramsForSshServer=array();
21844
 
22078
 
21845
		#如果有指定 $sshServerPassword
22079
		#如果有指定 $sshServerPassword
21846
		if($sshServerPassword!==""){
22080
		if($sshServerPassword!==""){
21847
		
22081
 
21848
			#使用 sshpass 指令
22082
			#使用 sshpass 指令
21849
			$paramsForSshServer[]="sshpass";
22083
			$paramsForSshServer[]="sshpass";
21850
			
22084
 
21851
			#設置要指定密碼
22085
			#設置要指定密碼
21852
			$paramsForSshServer[]="-p";
22086
			$paramsForSshServer[]="-p";
21853
			
22087
 
21854
			#設置要使用的密碼
22088
			#設置要使用的密碼
21855
			$paramsForSshServer[]=$sshServerPassword;
22089
			$paramsForSshServer[]=$sshServerPassword;
21856
		
22090
 
21857
			}#if end
22091
			}#if end
21858
			
22092
 
21859
		#設置使用 sftp 指令
22093
		#設置使用 sftp 指令
21860
		$paramsForSshServer[]="ssh";
22094
		$paramsForSshServer[]="ssh";
21861
 
22095
 
21862
		#如果 $sshServerPort 不為空
22096
		#如果 $sshServerPort 不為空
21863
		if($sshServerPort!==""){
22097
		if($sshServerPort!==""){
21864
		
22098
 
21865
			#設置要指定 port 
22099
			#設置要指定 port
21866
			$paramsForSshServer[]="-p";
22100
			$paramsForSshServer[]="-p";
21867
			
22101
 
21868
			#設置 port
22102
			#設置 port
21869
			$paramsForSshServer[]=$sshServerPort;
22103
			$paramsForSshServer[]=$sshServerPort;
21870
		
22104
 
21871
			}#if end
22105
			}#if end
21872
			
22106
 
21873
		#如果 sshServerPrivateKey 不為空
22107
		#如果 sshServerPrivateKey 不為空
21874
		if($sshServerPrivateKey!==""){
22108
		if($sshServerPrivateKey!==""){
21875
		
22109
 
21876
			#設置要指定 ssh private key
22110
			#設置要指定 ssh private key
21877
			$paramsForSshServer[]="-i";
22111
			$paramsForSshServer[]="-i";
21878
			
22112
 
21879
			#設置 ssh private key
22113
			#設置 ssh private key
21880
			$paramsForSshServer[]=$sshServerPrivateKey;
22114
			$paramsForSshServer[]=$sshServerPrivateKey;
21881
		
22115
 
21882
			}#if end
22116
			}#if end
21883
 
22117
 
21884
		#設置 sftp 的url以及要使用的賬號
22118
		#設置 sftp 的url以及要使用的賬號
21885
		$paramsForSshServer[]=$sshServerAccount."@".$sshServerDns;
22119
		$paramsForSshServer[]=$sshServerAccount."@".$sshServerDns;
21886
 
22120
 
21887
		#設置要倒入腳本
22121
		#設置要倒入腳本
21888
		$paramsForSshServer[]="<";
22122
		$paramsForSshServer[]="<";
21889
		
22123
 
21890
		#設置要倒入的腳本
22124
		#設置要倒入的腳本
21891
		$paramsForSshServer[]=$batchFile;
22125
		$paramsForSshServer[]=$batchFile;
21892
 
22126
 
21893
		#函式說明:
22127
		#函式說明:
21894
		#解析指令與參數,回傳指令與參數給 callShell 函式使用.
22128
		#解析指令與參數,回傳指令與參數給 callShell 函式使用.
Line 21908... Line 22142...
21908
		#array_shift=>https://www.php.net/manual/en/function.array-shift.php
22142
		#array_shift=>https://www.php.net/manual/en/function.array-shift.php
21909
		#備註:
22143
		#備註:
21910
		#無.
22144
		#無.
21911
		$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
22145
		$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
21912
		unset($conf["external::callShellHelper"]);
22146
		unset($conf["external::callShellHelper"]);
21913
	
22147
 
21914
		#如果執行失敗
22148
		#如果執行失敗
21915
		if($callShellHelper["status"]==="false"){
22149
		if($callShellHelper["status"]==="false"){
21916
		
22150
 
21917
			#設置執行失敗
22151
			#設置執行失敗
21918
			$result["status"]="false";
22152
			$result["status"]="false";
21919
 
22153
 
21920
			#設置執行錯誤訊息
22154
			#設置執行錯誤訊息
21921
			$result["error"]=$callShellHelper;
22155
			$result["error"]=$callShellHelper;
21922
 
22156
 
21923
			#回傳結果
22157
			#回傳結果
21924
			return $result;
22158
			return $result;
21925
		
22159
 
21926
			}#if end
22160
			}#if end
21927
 
22161
 
21928
		#連線到遠端將檔案解壓縮放到指定的目錄
22162
		#連線到遠端將檔案解壓縮放到指定的目錄
21929
		#函式說明:
22163
		#函式說明:
21930
		#呼叫shell執行系統命令,並取得回傳的內容.
22164
		#呼叫shell執行系統命令,並取得回傳的內容.
Line 21986... Line 22220...
21986
		$callShell=external::callShell($conf["external::callShell"]);
22220
		$callShell=external::callShell($conf["external::callShell"]);
21987
		unset($conf["external::callShell"]);
22221
		unset($conf["external::callShell"]);
21988
 
22222
 
21989
		#如果執行失敗
22223
		#如果執行失敗
21990
		if($callShell["status"]==="false"){
22224
		if($callShell["status"]==="false"){
21991
		
22225
 
21992
			#設置執行失敗
22226
			#設置執行失敗
21993
			$result["status"]="false";
22227
			$result["status"]="false";
21994
 
22228
 
21995
			#設置執行錯誤訊息
22229
			#設置執行錯誤訊息
21996
			$result["error"]=$callShell;
22230
			$result["error"]=$callShell;
21997
 
22231
 
21998
			#回傳結果
22232
			#回傳結果
21999
			return $result;
22233
			return $result;
22000
		
22234
 
22001
			}#if end
22235
			}#if end
22002
 
22236
 
22003
		#建立移除本機上檔案的腳本
22237
		#建立移除本機上檔案的腳本
22004
		/*
22238
		/*
22005
		#移除包code的目錄
22239
		#移除包code的目錄
Line 22028... Line 22262...
22028
		#無.
22262
		#無.
22029
		#備註:
22263
		#備註:
22030
		#無.
22264
		#無.
22031
		$createBatch=cmd::createBatch($conf["cmd::createBatch"]);
22265
		$createBatch=cmd::createBatch($conf["cmd::createBatch"]);
22032
		unset($conf["cmd::createBatch"]);
22266
		unset($conf["cmd::createBatch"]);
22033
		
22267
 
22034
		#如果執行失敗
22268
		#如果執行失敗
22035
		if($createBatch["status"]==="false"){
22269
		if($createBatch["status"]==="false"){
22036
		
22270
 
22037
			#設置執行失敗
22271
			#設置執行失敗
22038
			$result["status"]="false";
22272
			$result["status"]="false";
22039
 
22273
 
22040
			#設置執行錯誤訊息
22274
			#設置執行錯誤訊息
22041
			$result["error"]=$createBatch;
22275
			$result["error"]=$createBatch;
22042
 
22276
 
22043
			#回傳結果
22277
			#回傳結果
22044
			return $result;
22278
			return $result;
22045
		
22279
 
22046
			}#if end
22280
			}#if end
22047
 
22281
 
22048
		#運行腳本檔案
22282
		#運行腳本檔案
22049
		#函式說明:
22283
		#函式說明:
22050
		#呼叫shell執行編譯過的2元碼程式或具備執行權限的檔案後回傳的結果
22284
		#呼叫shell執行編譯過的2元碼程式或具備執行權限的檔案後回傳的結果
Line 22066... Line 22300...
22066
		$execByteCode=external::execByteCode($conf);
22300
		$execByteCode=external::execByteCode($conf);
22067
		unset($conf);
22301
		unset($conf);
22068
 
22302
 
22069
		#如果執行失敗
22303
		#如果執行失敗
22070
		if($execByteCode["status"]==="false"){
22304
		if($execByteCode["status"]==="false"){
22071
		
22305
 
22072
			#設置執行失敗
22306
			#設置執行失敗
22073
			$result["status"]="false";
22307
			$result["status"]="false";
22074
 
22308
 
22075
			#設置執行錯誤訊息
22309
			#設置執行錯誤訊息
22076
			$result["error"]=$execByteCode;
22310
			$result["error"]=$execByteCode;
22077
 
22311
 
22078
			#回傳結果
22312
			#回傳結果
22079
			return $result;
22313
			return $result;
22080
		
22314
 
22081
			}#if end
22315
			}#if end
22082
 
22316
 
22083
		}#function packetFromSvnToRemoteServer end
22317
		}#function packetFromSvnToRemoteServer end
22084
 
22318
 
22085
	/*
22319
	/*
Line 22545... Line 22779...
22545
 
22779
 
22546
		#回傳結果
22780
		#回傳結果
22547
		return $result;
22781
		return $result;
22548
 
22782
 
22549
		}#function find end
22783
		}#function find end
22550
		
22784
 
22551
	/*
22785
	/*
22552
	#函式說明:
22786
	#函式說明:
22553
	#檢查 httpd 與 postfix/smtp 與 dovecot/imap 與 named 與 sshd 的 log 把惡意連線的 IP 用防火牆阻阻擋.
22787
	#檢查 httpd 與 postfix/smtp 與 dovecot/imap 與 named 與 sshd 的 log 把惡意連線的 IP 用防火牆阻阻擋.
22554
	#回傳結果:
22788
	#回傳結果:
22555
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
22789
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 22578... Line 22812...
22578
	#無.
22812
	#無.
22579
	#備註:
22813
	#備註:
22580
	#無.
22814
	#無.
22581
	*/
22815
	*/
22582
	public static function blockAcctackIp(&$conf){
22816
	public static function blockAcctackIp(&$conf){
22583
	
22817
 
22584
		#初始化要回傳的結果
22818
		#初始化要回傳的結果
22585
		$result=array();
22819
		$result=array();
22586
 
22820
 
22587
		#取得當前執行的函式名稱
22821
		#取得當前執行的函式名稱
22588
		$result["function"]=__FUNCTION__;
22822
		$result["function"]=__FUNCTION__;
Line 22686... Line 22920...
22686
 
22920
 
22687
			#回傳結果
22921
			#回傳結果
22688
			return $result;
22922
			return $result;
22689
 
22923
 
22690
			}#if end
22924
			}#if end
22691
		
22925
 
22692
		#取得 http 存取記錄的 log
22926
		#取得 http 存取記錄的 log
22693
		#函式說明:
22927
		#函式說明:
22694
		#檢查指令的輸出是否含有關鍵字
22928
		#檢查指令的輸出是否含有關鍵字
22695
		#回傳結果:
22929
		#回傳結果:
22696
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
22930
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 22713... Line 22947...
22713
		#$conf["binPath"]="";
22947
		#$conf["binPath"]="";
22714
		#$conf["argu"],陣列字串,指令搭配的參數,預設不使用.
22948
		#$conf["argu"],陣列字串,指令搭配的參數,預設不使用.
22715
		$conf["cmd::searchOutPut"]["argu"]=array($conf["logPath"]."/access_log");
22949
		$conf["cmd::searchOutPut"]["argu"]=array($conf["logPath"]."/access_log");
22716
		#$conf["excludeGrep"],字串,"true"代表排除含有 " | grep ".$conf["keyWord"] 字樣的輸出;預設為"false",不排除.
22950
		#$conf["excludeGrep"],字串,"true"代表排除含有 " | grep ".$conf["keyWord"] 字樣的輸出;預設為"false",不排除.
22717
		#$conf["excludeGrep"]="false";
22951
		#$conf["excludeGrep"]="false";
22718
		
22952
 
22719
		#如果有設置 username
22953
		#如果有設置 username
22720
		if(isset($conf["username"])){
22954
		if(isset($conf["username"])){
22721
		
22955
 
22722
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
22956
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
22723
			$conf["cmd::searchOutPut"]["username"]=$conf["username"];
22957
			$conf["cmd::searchOutPut"]["username"]=$conf["username"];
22724
		
22958
 
22725
			}#if end
22959
			}#if end
22726
		
22960
 
22727
		#如果有設置 password
22961
		#如果有設置 password
22728
		if(isset($conf["password"])){
22962
		if(isset($conf["password"])){
22729
		
22963
 
22730
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
22964
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
22731
			$conf["cmd::searchOutPut"]["password"]=$conf["password"];
22965
			$conf["cmd::searchOutPut"]["password"]=$conf["password"];
22732
		
22966
 
22733
			}#if end
22967
			}#if end
22734
				
22968
 
22735
		$searchOutPut=cmd::searchOutPut($conf["cmd::searchOutPut"]);
22969
		$searchOutPut=cmd::searchOutPut($conf["cmd::searchOutPut"]);
22736
		unset($conf["cmd::searchOutPut"]);
22970
		unset($conf["cmd::searchOutPut"]);
22737
		
22971
 
22738
		#如果執行失敗
22972
		#如果執行失敗
22739
		if($searchOutPut["status"]==="false"){
22973
		if($searchOutPut["status"]==="false"){
22740
		
22974
 
22741
			#設置執行失敗
22975
			#設置執行失敗
22742
			$result["status"]="false";
22976
			$result["status"]="false";
22743
 
22977
 
22744
			#設置錯誤訊息
22978
			#設置錯誤訊息
22745
			$result["error"]=$searchOutPut;
22979
			$result["error"]=$searchOutPut;
22746
 
22980
 
22747
			#回傳結果
22981
			#回傳結果
22748
			return $result;
22982
			return $result;
22749
		
22983
 
22750
			}#if end
22984
			}#if end
22751
		
22985
 
22752
		#過濾掉對於含有 ".css" ".js" "favicon.ico" ".jpg" ".png" 關鍵字串的結果.
22986
		#過濾掉對於含有 ".css" ".js" "favicon.ico" ".jpg" ".png" 關鍵字串的結果.
22753
		#函式說明:
22987
		#函式說明:
22754
		#檢查多個字串中的每個字串是否有多個關鍵字
22988
		#檢查多個字串中的每個字串是否有多個關鍵字
22755
		#回傳的結果:
22989
		#回傳的結果:
22756
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
22990
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
Line 22767... Line 23001...
22767
		$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$searchOutPut["content"];#要被搜尋的字串內容陣列
23001
		$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$searchOutPut["content"];#要被搜尋的字串內容陣列
22768
		#可省略參數:
23002
		#可省略參數:
22769
		#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
23003
		#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
22770
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
23004
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
22771
		unset($conf["search::findManyKeyWordsFromManyString"]);
23005
		unset($conf["search::findManyKeyWordsFromManyString"]);
22772
		
23006
 
22773
		#如果執行出錯
23007
		#如果執行出錯
22774
		if($findManyKeyWordsFromManyString["status"]==="false"){
23008
		if($findManyKeyWordsFromManyString["status"]==="false"){
22775
			
23009
 
22776
			#設置執行失敗
23010
			#設置執行失敗
22777
			$result["status"]="false";
23011
			$result["status"]="false";
22778
 
23012
 
22779
			#設置錯誤訊息
23013
			#設置錯誤訊息
22780
			$result["error"]=$findManyKeyWordsFromManyString;
23014
			$result["error"]=$findManyKeyWordsFromManyString;
22781
 
23015
 
22782
			#回傳結果
23016
			#回傳結果
22783
			return $result;
23017
			return $result;
22784
			
23018
 
22785
			}#if end
23019
			}#if end
22786
			
23020
 
22787
		#取得不含有 ".css" ".js" "favicon.ico" ".jpg" ".png" 關鍵字串的結果.
23021
		#取得不含有 ".css" ".js" "favicon.ico" ".jpg" ".png" 關鍵字串的結果.
22788
		$searchOutPut["content"]=$findManyKeyWordsFromManyString["foundedFalseKey"];	
23022
		$searchOutPut["content"]=$findManyKeyWordsFromManyString["foundedFalseKey"];
22789
		
23023
 
22790
		#更新計數
23024
		#更新計數
22791
		$searchOutPut["count"]=count($searchOutPut["content"]);
23025
		$searchOutPut["count"]=count($searchOutPut["content"]);
22792
		
23026
 
22793
		#用空格分割字串
23027
		#用空格分割字串
22794
		#函式說明:
23028
		#函式說明:
22795
		#將多個固定格式的字串分開,並回傳分開的結果
23029
		#將多個固定格式的字串分開,並回傳分開的結果
22796
		#回傳的參數:
23030
		#回傳的參數:
22797
		#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
23031
		#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 22806... Line 23040...
22806
		$conf["stringProcess::spiltMutiString"]["stringIn"]=$searchOutPut["content"];
23040
		$conf["stringProcess::spiltMutiString"]["stringIn"]=$searchOutPut["content"];
22807
		#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
23041
		#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
22808
		$conf["stringProcess::spiltMutiString"]["spiltSymbol"]=" ";
23042
		$conf["stringProcess::spiltMutiString"]["spiltSymbol"]=" ";
22809
		$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
23043
		$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
22810
		unset($conf["stringProcess::spiltMutiString"]);
23044
		unset($conf["stringProcess::spiltMutiString"]);
22811
		
23045
 
22812
		#如果分割失敗
23046
		#如果分割失敗
22813
		if($spiltMutiString["status"]==="false"){
23047
		if($spiltMutiString["status"]==="false"){
22814
		
23048
 
22815
			#設置執行失敗
23049
			#設置執行失敗
22816
			$result["status"]="false";
23050
			$result["status"]="false";
22817
 
23051
 
22818
			#設置錯誤訊息
23052
			#設置錯誤訊息
22819
			$result["error"]=$spiltMutiString;
23053
			$result["error"]=$spiltMutiString;
22820
 
23054
 
22821
			#回傳結果
23055
			#回傳結果
22822
			return $result;
23056
			return $result;
22823
			
23057
 
22824
			}#if end
23058
			}#if end
22825
			
23059
 
22826
		#初始化儲存有問題IP的陣列
23060
		#初始化儲存有問題IP的陣列
22827
		$ips=array();
23061
		$ips=array();
22828
		
23062
 
22829
		#初始化儲存可能有問題的IP陣列
23063
		#初始化儲存可能有問題的IP陣列
22830
		$ips_byIp=array();
23064
		$ips_byIp=array();
22831
		
23065
 
22832
		#針對每行內容
23066
		#針對每行內容
22833
		for($i=0;$i<$searchOutPut["count"];$i++){
23067
		for($i=0;$i<$searchOutPut["count"];$i++){
22834
		
23068
 
22835
			#如果沒有分割出來的內容
23069
			#如果沒有分割出來的內容
22836
			if($spiltMutiString["spiltString"][$i]["dataCounts"]===0){
23070
			if($spiltMutiString["spiltString"][$i]["dataCounts"]===0){
22837
			
23071
 
22838
				#換下一個
23072
				#換下一個
22839
				continue;
23073
				continue;
22840
			
23074
 
22841
				}#if end
23075
				}#if end
22842
			
23076
 
22843
			#有問題的資訊
23077
			#有問題的資訊
22844
			$info=array();
23078
			$info=array();
22845
			
23079
 
22846
			#設置問題對應的log行內容
23080
			#設置問題對應的log行內容
22847
			$info["log"]=$spiltMutiString["spiltString"][$i]["oriStr"];
23081
			$info["log"]=$spiltMutiString["spiltString"][$i]["oriStr"];
22848
			
23082
 
22849
			#設置問題時間點
23083
			#設置問題時間點
22850
			$info["time"]=$spiltMutiString["spiltString"][$i]["dataArray"][3];
23084
			$info["time"]=$spiltMutiString["spiltString"][$i]["dataArray"][3];
22851
			
23085
 
22852
			#記錄有問題的ip
23086
			#記錄有問題的ip
22853
			$info["ip"]=$spiltMutiString["spiltString"][$i]["dataArray"][0];
23087
			$info["ip"]=$spiltMutiString["spiltString"][$i]["dataArray"][0];
22854
				
23088
 
22855
			#取得可能有問題的IP位置資訊
23089
			#取得可能有問題的IP位置資訊
22856
			$ips_byIp[$spiltMutiString["spiltString"][$i]["dataArray"][0]][]=$info;
23090
			$ips_byIp[$spiltMutiString["spiltString"][$i]["dataArray"][0]][]=$info;
22857
		
23091
 
22858
			}#for end
23092
			}#for end
22859
			
23093
 
22860
		#針對每個可能有問題的IP
23094
		#針對每個可能有問題的IP
22861
		foreach($ips_byIp as $ip => $infos){
23095
		foreach($ips_byIp as $ip => $infos){
22862
		
23096
 
22863
			#計數 ip 於同時間前來的計數
23097
			#計數 ip 於同時間前來的計數
22864
			$ipSameTimeCount=0;
23098
			$ipSameTimeCount=0;
22865
			
23099
 
22866
			#用來存放來存取的同一時間
23100
			#用來存放來存取的同一時間
22867
			$ipSameTime="";
23101
			$ipSameTime="";
22868
			
23102
 
22869
			#看來拜訪的時間點
23103
			#看來拜訪的時間點
22870
			foreach($infos as $info){
23104
			foreach($infos as $info){
22871
			
23105
 
22872
				#如果是初次
23106
				#如果是初次
22873
				if($ipSameTime===""){
23107
				if($ipSameTime===""){
22874
				
23108
 
22875
					#記錄時間點
23109
					#記錄時間點
22876
					$ipSameTime=$info["time"];
23110
					$ipSameTime=$info["time"];
22877
					
23111
 
22878
					#同時間點計數加1
23112
					#同時間點計數加1
22879
					$ipSameTimeCount++;
23113
					$ipSameTimeCount++;
22880
				
23114
 
22881
					}#if end
23115
					}#if end
22882
				
23116
 
22883
				#反之如果時間點相同
23117
				#反之如果時間點相同
22884
				else if($ipSameTime===$info["time"]){
23118
				else if($ipSameTime===$info["time"]){
22885
				
23119
 
22886
					#同時間點計數加1
23120
					#同時間點計數加1
22887
					$ipSameTimeCount++;
23121
					$ipSameTimeCount++;
22888
				
23122
 
22889
					}#if end
23123
					}#if end
22890
					
23124
 
22891
				#反之時間點不相同
23125
				#反之時間點不相同
22892
				else{
23126
				else{
22893
				
23127
 
22894
					#記錄時間點
23128
					#記錄時間點
22895
					$ipSameTime=$info["time"];
23129
					$ipSameTime=$info["time"];
22896
					
23130
 
22897
					#同時間點計數重設為1
23131
					#同時間點計數重設為1
22898
					$ipSameTimeCount=1;
23132
					$ipSameTimeCount=1;
22899
				
23133
 
22900
					}#else end
23134
					}#else end
22901
					
23135
 
22902
				#如果同時間的計數達到3
23136
				#如果同時間的計數達到3
22903
				if($ipSameTimeCount===3){
23137
				if($ipSameTimeCount===3){
22904
				
23138
 
22905
					#取得有問題的IP
23139
					#取得有問題的IP
22906
					$ips[]=$info;
23140
					$ips[]=$info;
22907
					
23141
 
22908
					#換檢查下一個IP
23142
					#換檢查下一個IP
22909
					continue 2;
23143
					continue 2;
22910
				
23144
 
22911
					}#if end
23145
					}#if end
22912
			
23146
 
22913
				}#foreach end
23147
				}#foreach end
22914
		
23148
 
22915
			}#foreach end
23149
			}#foreach end
22916
				
23150
 
22917
		#取得 https 存取記錄的 log
23151
		#取得 https 存取記錄的 log
22918
		#函式說明:
23152
		#函式說明:
22919
		#檢查指令的輸出是否含有關鍵字
23153
		#檢查指令的輸出是否含有關鍵字
22920
		#回傳結果:
23154
		#回傳結果:
22921
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
23155
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 22938... Line 23172...
22938
		#$conf["binPath"]="";
23172
		#$conf["binPath"]="";
22939
		#$conf["argu"],陣列字串,指令搭配的參數,預設不使用.
23173
		#$conf["argu"],陣列字串,指令搭配的參數,預設不使用.
22940
		$conf["cmd::searchOutPut"]["argu"]=array($conf["logPath"]."/ssl_access_log");
23174
		$conf["cmd::searchOutPut"]["argu"]=array($conf["logPath"]."/ssl_access_log");
22941
		#$conf["excludeGrep"],字串,"true"代表排除含有 " | grep ".$conf["keyWord"] 字樣的輸出;預設為"false",不排除.
23175
		#$conf["excludeGrep"],字串,"true"代表排除含有 " | grep ".$conf["keyWord"] 字樣的輸出;預設為"false",不排除.
22942
		#$conf["excludeGrep"]="false";
23176
		#$conf["excludeGrep"]="false";
22943
		
23177
 
22944
		#如果有設置 username
23178
		#如果有設置 username
22945
		if(isset($conf["username"])){
23179
		if(isset($conf["username"])){
22946
		
23180
 
22947
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
23181
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
22948
			$conf["cmd::searchOutPut"]["username"]=$conf["username"];
23182
			$conf["cmd::searchOutPut"]["username"]=$conf["username"];
22949
		
23183
 
22950
			}#if end
23184
			}#if end
22951
		
23185
 
22952
		#如果有設置 password
23186
		#如果有設置 password
22953
		if(isset($conf["password"])){
23187
		if(isset($conf["password"])){
22954
		
23188
 
22955
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
23189
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
22956
			$conf["cmd::searchOutPut"]["password"]=$conf["password"];
23190
			$conf["cmd::searchOutPut"]["password"]=$conf["password"];
22957
		
23191
 
22958
			}#if end
23192
			}#if end
22959
				
23193
 
22960
		$searchOutPut=cmd::searchOutPut($conf["cmd::searchOutPut"]);
23194
		$searchOutPut=cmd::searchOutPut($conf["cmd::searchOutPut"]);
22961
		unset($conf["cmd::searchOutPut"]);
23195
		unset($conf["cmd::searchOutPut"]);
22962
		
23196
 
22963
		#如果執行失敗
23197
		#如果執行失敗
22964
		if($searchOutPut["status"]==="false"){
23198
		if($searchOutPut["status"]==="false"){
22965
		
23199
 
22966
			#設置執行失敗
23200
			#設置執行失敗
22967
			$result["status"]="false";
23201
			$result["status"]="false";
22968
 
23202
 
22969
			#設置錯誤訊息
23203
			#設置錯誤訊息
22970
			$result["error"]=$searchOutPut;
23204
			$result["error"]=$searchOutPut;
22971
 
23205
 
22972
			#回傳結果
23206
			#回傳結果
22973
			return $result;
23207
			return $result;
22974
		
23208
 
22975
			}#if end
23209
			}#if end
22976
		
23210
 
22977
		#過濾掉對於含有 ".css",".js","favicon.ico",".jpg",".png" 關鍵字串的結果.  	
23211
		#過濾掉對於含有 ".css",".js","favicon.ico",".jpg",".png" 關鍵字串的結果.
22978
		#函式說明:
23212
		#函式說明:
22979
		#檢查多個字串中的每個字串是否有多個關鍵字
23213
		#檢查多個字串中的每個字串是否有多個關鍵字
22980
		#回傳的結果:
23214
		#回傳的結果:
22981
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
23215
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
22982
		#$result["function"],當前執行的函式名稱.
23216
		#$result["function"],當前執行的函式名稱.
Line 22992... Line 23226...
22992
		$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$searchOutPut["content"];#要被搜尋的字串內容陣列
23226
		$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$searchOutPut["content"];#要被搜尋的字串內容陣列
22993
		#可省略參數:
23227
		#可省略參數:
22994
		#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
23228
		#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
22995
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
23229
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
22996
		unset($conf["search::findManyKeyWordsFromManyString"]);
23230
		unset($conf["search::findManyKeyWordsFromManyString"]);
22997
		
23231
 
22998
		#如果執行出錯
23232
		#如果執行出錯
22999
		if($findManyKeyWordsFromManyString["status"]==="false"){
23233
		if($findManyKeyWordsFromManyString["status"]==="false"){
23000
			
23234
 
23001
			#設置執行失敗
23235
			#設置執行失敗
23002
			$result["status"]="false";
23236
			$result["status"]="false";
23003
 
23237
 
23004
			#設置錯誤訊息
23238
			#設置錯誤訊息
23005
			$result["error"]=$findManyKeyWordsFromManyString;
23239
			$result["error"]=$findManyKeyWordsFromManyString;
23006
 
23240
 
23007
			#回傳結果
23241
			#回傳結果
23008
			return $result;
23242
			return $result;
23009
			
23243
 
23010
			}#if end
23244
			}#if end
23011
		
23245
 
23012
		#取得不含有 ".css",".js","favicon.ico",".jpg",".png" 關鍵字串的結果.
23246
		#取得不含有 ".css",".js","favicon.ico",".jpg",".png" 關鍵字串的結果.
23013
		$searchOutPut["content"]=$findManyKeyWordsFromManyString["foundedFalseKey"];
23247
		$searchOutPut["content"]=$findManyKeyWordsFromManyString["foundedFalseKey"];
23014
		
23248
 
23015
		#更新計數
23249
		#更新計數
23016
		$searchOutPut["count"]=count($searchOutPut["content"]);
23250
		$searchOutPut["count"]=count($searchOutPut["content"]);
23017
		
23251
 
23018
		#用空格分割字串
23252
		#用空格分割字串
23019
		#函式說明:
23253
		#函式說明:
23020
		#將多個固定格式的字串分開,並回傳分開的結果
23254
		#將多個固定格式的字串分開,並回傳分開的結果
23021
		#回傳的參數:
23255
		#回傳的參數:
23022
		#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
23256
		#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 23031... Line 23265...
23031
		$conf["stringProcess::spiltMutiString"]["stringIn"]=$searchOutPut["content"];
23265
		$conf["stringProcess::spiltMutiString"]["stringIn"]=$searchOutPut["content"];
23032
		#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
23266
		#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
23033
		$conf["stringProcess::spiltMutiString"]["spiltSymbol"]=" ";
23267
		$conf["stringProcess::spiltMutiString"]["spiltSymbol"]=" ";
23034
		$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
23268
		$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
23035
		unset($conf["stringProcess::spiltMutiString"]);
23269
		unset($conf["stringProcess::spiltMutiString"]);
23036
		
23270
 
23037
		#如果分割失敗
23271
		#如果分割失敗
23038
		if($spiltMutiString["status"]==="false"){
23272
		if($spiltMutiString["status"]==="false"){
23039
		
23273
 
23040
			#設置執行失敗
23274
			#設置執行失敗
23041
			$result["status"]="false";
23275
			$result["status"]="false";
23042
 
23276
 
23043
			#設置錯誤訊息
23277
			#設置錯誤訊息
23044
			$result["error"]=$spiltMutiString;
23278
			$result["error"]=$spiltMutiString;
23045
 
23279
 
23046
			#回傳結果
23280
			#回傳結果
23047
			return $result;
23281
			return $result;
23048
			
23282
 
23049
			}#if end
23283
			}#if end
23050
 
23284
 
23051
		#初始化儲存有問題IP的陣列
23285
		#初始化儲存有問題IP的陣列
23052
		$ips_https=array();
23286
		$ips_https=array();
23053
		
23287
 
23054
		#初始化儲存可能有問題的IP陣列
23288
		#初始化儲存可能有問題的IP陣列
23055
		$ips_byIp_https=array();
23289
		$ips_byIp_https=array();
23056
		
23290
 
23057
		#針對每行內容
23291
		#針對每行內容
23058
		for($i=0;$i<$searchOutPut["count"];$i++){
23292
		for($i=0;$i<$searchOutPut["count"];$i++){
23059
		
23293
 
23060
			#如果沒有分割出來的內容
23294
			#如果沒有分割出來的內容
23061
			if($spiltMutiString["spiltString"][$i]["dataCounts"]===0){
23295
			if($spiltMutiString["spiltString"][$i]["dataCounts"]===0){
23062
			
23296
 
23063
				#換下一個
23297
				#換下一個
23064
				continue;
23298
				continue;
23065
			
23299
 
23066
				}#if end
23300
				}#if end
23067
			
23301
 
23068
			#有問題的資訊
23302
			#有問題的資訊
23069
			$info=array();
23303
			$info=array();
23070
			
23304
 
23071
			#設置問題對應的log行內容
23305
			#設置問題對應的log行內容
23072
			$info["log"]=$spiltMutiString["spiltString"][$i]["oriStr"];
23306
			$info["log"]=$spiltMutiString["spiltString"][$i]["oriStr"];
23073
			
23307
 
23074
			#設置問題時間點
23308
			#設置問題時間點
23075
			$info["time"]=$spiltMutiString["spiltString"][$i]["dataArray"][3];
23309
			$info["time"]=$spiltMutiString["spiltString"][$i]["dataArray"][3];
23076
			
23310
 
23077
			#記錄有問題的ip
23311
			#記錄有問題的ip
23078
			$info["ip"]=$spiltMutiString["spiltString"][$i]["dataArray"][0];
23312
			$info["ip"]=$spiltMutiString["spiltString"][$i]["dataArray"][0];
23079
			
23313
 
23080
			#取得可能有問題的IP位置,key為[ip][int]
23314
			#取得可能有問題的IP位置,key為[ip][int]
23081
			$ips_byIp_https[$spiltMutiString["spiltString"][$i]["dataArray"][0]][]=$info;
23315
			$ips_byIp_https[$spiltMutiString["spiltString"][$i]["dataArray"][0]][]=$info;
23082
		
23316
 
23083
			}#for end
23317
			}#for end
23084
		
23318
 
23085
		#debug
23319
		#debug
23086
		#var_dump(__LINE__,"http待整理的可能有問題IP清單",$ips_byIp_https);
23320
		#var_dump(__LINE__,"http待整理的可能有問題IP清單",$ips_byIp_https);
23087
		
23321
 
23088
		#針對每個可能有問題的IP
23322
		#針對每個可能有問題的IP
23089
		foreach($ips_byIp_https as $infos){
23323
		foreach($ips_byIp_https as $infos){
23090
		
23324
 
23091
			#計數 ip 於同時間前來的計數
23325
			#計數 ip 於同時間前來的計數
23092
			$ipSameTimeCount=0;
23326
			$ipSameTimeCount=0;
23093
			
23327
 
23094
			#用來存放來存取的同一時間
23328
			#用來存放來存取的同一時間
23095
			$ipSameTime="";
23329
			$ipSameTime="";
23096
			
23330
 
23097
			#看來拜訪的時間點
23331
			#看來拜訪的時間點
23098
			foreach($infos as $info){
23332
			foreach($infos as $info){
23099
			
23333
 
23100
				#如果是初次
23334
				#如果是初次
23101
				if($ipSameTime===""){
23335
				if($ipSameTime===""){
23102
				
23336
 
23103
					#記錄時間點
23337
					#記錄時間點
23104
					$ipSameTime=$info["time"];
23338
					$ipSameTime=$info["time"];
23105
					
23339
 
23106
					#同時間點計數加1
23340
					#同時間點計數加1
23107
					$ipSameTimeCount++;
23341
					$ipSameTimeCount++;
23108
				
23342
 
23109
					}#if end
23343
					}#if end
23110
				
23344
 
23111
				#反之如果時間點相同
23345
				#反之如果時間點相同
23112
				else if($ipSameTime===$info["time"]){
23346
				else if($ipSameTime===$info["time"]){
23113
				
23347
 
23114
					#同時間點計數加1
23348
					#同時間點計數加1
23115
					$ipSameTimeCount++;
23349
					$ipSameTimeCount++;
23116
				
23350
 
23117
					}#if end
23351
					}#if end
23118
					
23352
 
23119
				#反之時間點不相同
23353
				#反之時間點不相同
23120
				else{
23354
				else{
23121
				
23355
 
23122
					#記錄時間點
23356
					#記錄時間點
23123
					$ipSameTime=$info["time"];
23357
					$ipSameTime=$info["time"];
23124
					
23358
 
23125
					#同時間點計數重設為1
23359
					#同時間點計數重設為1
23126
					$ipSameTimeCount=1;
23360
					$ipSameTimeCount=1;
23127
				
23361
 
23128
					}#else end
23362
					}#else end
23129
					
23363
 
23130
				#如果同時間的計數達到3
23364
				#如果同時間的計數達到3
23131
				if($ipSameTimeCount===3){
23365
				if($ipSameTimeCount===3){
23132
				
23366
 
23133
					#取得有問題的IP
23367
					#取得有問題的IP
23134
					$ips_https[]=$info;
23368
					$ips_https[]=$info;
23135
					
23369
 
23136
					#換檢查下一個IP
23370
					#換檢查下一個IP
23137
					continue 2;
23371
					continue 2;
23138
				
23372
 
23139
					}#if end
23373
					}#if end
23140
			
23374
 
23141
				}#foreach end
23375
				}#foreach end
23142
		
23376
 
23143
			}#foreach end
23377
			}#foreach end
23144
		
23378
 
23145
		#debug
23379
		#debug
23146
		#var_dump(__LINE__,"http有問題IP清單",$ips_https);
23380
		#var_dump(__LINE__,"http有問題IP清單",$ips_https);
23147
		
23381
 
23148
		#透過 journalctl -a -e -f --unit=postfix.service | grep "SASL LOGIN authentication failed" 來取得認證失敗的 ip
23382
		#透過 journalctl -a -e -f --unit=postfix.service | grep "SASL LOGIN authentication failed" 來取得認證失敗的 ip
23149
		#函式說明:
23383
		#函式說明:
23150
		#呼叫shell執行系統命令,並取得回傳的內容.
23384
		#呼叫shell執行系統命令,並取得回傳的內容.
23151
		#回傳的結果:
23385
		#回傳的結果:
23152
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
23386
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 23167... Line 23401...
23167
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
23401
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
23168
		#可省略參數:
23402
		#可省略參數:
23169
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
23403
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
23170
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=postfix.service","|","grep","SASL LOGIN authentication failed");
23404
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=postfix.service","|","grep","SASL LOGIN authentication failed");
23171
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
23405
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
23172
		#$conf["arguIsAddr"]=array();	
23406
		#$conf["arguIsAddr"]=array();
23173
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
23407
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
23174
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
23408
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
23175
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
23409
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
23176
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
23410
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
23177
		#$conf["enablePrintDescription"]="true";
23411
		#$conf["enablePrintDescription"]="true";
Line 23197... Line 23431...
23197
		#exec=>http://php.net/manual/en/function.exec.php
23431
		#exec=>http://php.net/manual/en/function.exec.php
23198
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
23432
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
23199
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
23433
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
23200
		$callShell=external::callShell($conf["external::callShell"]);
23434
		$callShell=external::callShell($conf["external::callShell"]);
23201
		unset($conf["external::callShell"]);
23435
		unset($conf["external::callShell"]);
23202
		
23436
 
23203
		#如果執行失敗
23437
		#如果執行失敗
23204
		if($callShell["status"]==="false" && ( $callShell["statusCode"]!==0 && $callShell["statusCode"]!==1 ) ){
23438
		if($callShell["status"]==="false" && ( $callShell["statusCode"]!==0 && $callShell["statusCode"]!==1 ) ){
23205
		
23439
 
23206
			#設置執行失敗
23440
			#設置執行失敗
23207
			$result["status"]="false";
23441
			$result["status"]="false";
23208
 
23442
 
23209
			#設置錯誤訊息
23443
			#設置錯誤訊息
23210
			$result["error"]=$callShell;
23444
			$result["error"]=$callShell;
23211
 
23445
 
23212
			#回傳結果
23446
			#回傳結果
23213
			return $result;
23447
			return $result;
23214
			
23448
 
23215
			}#if end
23449
			}#if end
23216
		
23450
 
23217
		#儲存有問題的smtp IP
23451
		#儲存有問題的smtp IP
23218
		$ips_smtp=array();
23452
		$ips_smtp=array();
23219
		
23453
 
23220
		#狀態碼不為1才執行
23454
		#狀態碼不為1才執行
23221
		if($callShell["statusCode"]!==1){
23455
		if($callShell["statusCode"]!==1){
23222
			
23456
 
23223
			#截取出的格式
23457
			#截取出的格式
23224
			#Sep 28 07:54:16 qbpwcf.org postfix/smtpd[2766456]: warning: unknown[158.94.208.72]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=1q2w
23458
			#Sep 28 07:54:16 qbpwcf.org postfix/smtpd[2766456]: warning: unknown[158.94.208.72]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=1q2w
23225
			#Sep 28 07:57:15 qbpwcf.org postfix/smtpd[2768441]: warning: unknown[213.209.157.249]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=sybase
23459
			#Sep 28 07:57:15 qbpwcf.org postfix/smtpd[2768441]: warning: unknown[213.209.157.249]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=sybase
23226
			#Sep 28 08:01:09 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[213.209.157.165]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=spam
23460
			#Sep 28 08:01:09 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[213.209.157.165]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=spam
23227
			#Sep 28 08:01:51 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[103.109.20.174]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=print@qbpwcf.org
23461
			#Sep 28 08:01:51 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[103.109.20.174]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=print@qbpwcf.org
Line 23232... Line 23466...
23232
			#Sep 28 08:17:06 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=hualing@qbpwcf.org
23466
			#Sep 28 08:17:06 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=hualing@qbpwcf.org
23233
			#Sep 28 08:17:16 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: Connection lost to authentication server, sasl_username=hualing@qbpwcf.org
23467
			#Sep 28 08:17:16 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]: SASL LOGIN authentication failed: Connection lost to authentication server, sasl_username=hualing@qbpwcf.org
23234
			#Sep 28 08:20:28 qbpwcf.org postfix/smtpd[2784204]: warning: unknown[158.94.208.72]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=1q2w1q2w
23468
			#Sep 28 08:20:28 qbpwcf.org postfix/smtpd[2784204]: warning: unknown[158.94.208.72]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=1q2w1q2w
23235
			#Sep 28 08:23:09 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[213.209.157.249]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=informix
23469
			#Sep 28 08:23:09 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[213.209.157.249]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=informix
23236
			#Sep 28 08:23:39 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[62.60.130.148]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=admin3
23470
			#Sep 28 08:23:39 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[62.60.130.148]: SASL LOGIN authentication failed: (reason unavailable), sasl_username=admin3
23237
			
23471
 
23238
			#分割用的關鍵字
23472
			#分割用的關鍵字
23239
			$keyword=": SASL LOGIN authentication failed: ";
23473
			$keyword=": SASL LOGIN authentication failed: ";
23240
			
23474
 
23241
			#分割字串
23475
			#分割字串
23242
			#函式說明:
23476
			#函式說明:
23243
			#將多個固定格式的字串分開,並回傳分開的結果
23477
			#將多個固定格式的字串分開,並回傳分開的結果
23244
			#回傳的參數:
23478
			#回傳的參數:
23245
			#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
23479
			#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 23254... Line 23488...
23254
			$conf["stringProcess::spiltMutiString"]["stringIn"]=$callShell["output"];
23488
			$conf["stringProcess::spiltMutiString"]["stringIn"]=$callShell["output"];
23255
			#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
23489
			#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
23256
			$conf["stringProcess::spiltMutiString"]["spiltSymbol"]=$keyword;
23490
			$conf["stringProcess::spiltMutiString"]["spiltSymbol"]=$keyword;
23257
			$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
23491
			$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
23258
			unset($conf["stringProcess::spiltMutiString"]);
23492
			unset($conf["stringProcess::spiltMutiString"]);
23259
			
23493
 
23260
			#如果分割失敗
23494
			#如果分割失敗
23261
			if($spiltMutiString["status"]==="false"){
23495
			if($spiltMutiString["status"]==="false"){
23262
			
23496
 
23263
				#設置執行失敗
23497
				#設置執行失敗
23264
				$result["status"]="false";
23498
				$result["status"]="false";
23265
 
23499
 
23266
				#設置錯誤訊息
23500
				#設置錯誤訊息
23267
				$result["error"]=$spiltMutiString;
23501
				$result["error"]=$spiltMutiString;
23268
 
23502
 
23269
				#回傳結果
23503
				#回傳結果
23270
				return $result;
23504
				return $result;
23271
				
23505
 
23272
				}#if end
23506
				}#if end
23273
				
23507
 
23274
			#初始化記錄每行log的時間點
23508
			#初始化記錄每行log的時間點
23275
			$occurTime=array();
23509
			$occurTime=array();
23276
				
23510
 
23277
			#初始化儲存log行資訊的變數
23511
			#初始化儲存log行資訊的變數
23278
			$oriLog=array();
23512
			$oriLog=array();
23279
				
23513
 
23280
			#根據每筆記錄
23514
			#根據每筆記錄
23281
			foreach($spiltMutiString["spiltString"] as $index => $splitStr){
23515
			foreach($spiltMutiString["spiltString"] as $index => $splitStr){
23282
				
23516
 
23283
				#分段1的內容範例
23517
				#分段1的內容範例
23284
				#Sep 28 07:54:16 qbpwcf.org postfix/smtpd[2766456]: warning: unknown[158.94.208.72]
23518
				#Sep 28 07:54:16 qbpwcf.org postfix/smtpd[2766456]: warning: unknown[158.94.208.72]
23285
				#Sep 28 07:57:15 qbpwcf.org postfix/smtpd[2768441]: warning: unknown[213.209.157.249]
23519
				#Sep 28 07:57:15 qbpwcf.org postfix/smtpd[2768441]: warning: unknown[213.209.157.249]
23286
				#Sep 28 08:01:09 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[213.209.157.165]
23520
				#Sep 28 08:01:09 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[213.209.157.165]
23287
				#Sep 28 08:01:51 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[103.109.20.174]
23521
				#Sep 28 08:01:51 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[103.109.20.174]
Line 23292... Line 23526...
23292
				#Sep 28 08:17:06 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]
23526
				#Sep 28 08:17:06 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]
23293
				#Sep 28 08:17:16 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]
23527
				#Sep 28 08:17:16 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]
23294
				#Sep 28 08:20:28 qbpwcf.org postfix/smtpd[2784204]: warning: unknown[158.94.208.72]
23528
				#Sep 28 08:20:28 qbpwcf.org postfix/smtpd[2784204]: warning: unknown[158.94.208.72]
23295
				#Sep 28 08:23:09 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[213.209.157.249]
23529
				#Sep 28 08:23:09 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[213.209.157.249]
23296
				#Sep 28 08:23:39 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[62.60.130.148]
23530
				#Sep 28 08:23:39 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[62.60.130.148]
23297
				
23531
 
23298
				#分段2的內容範例
23532
				#分段2的內容範例
23299
				#(reason unavailable), sasl_username=1q2w
23533
				#(reason unavailable), sasl_username=1q2w
23300
				#(reason unavailable), sasl_username=sybase
23534
				#(reason unavailable), sasl_username=sybase
23301
				#(reason unavailable), sasl_username=spam
23535
				#(reason unavailable), sasl_username=spam
23302
				#(reason unavailable), sasl_username=print@qbpwcf.org
23536
				#(reason unavailable), sasl_username=print@qbpwcf.org
Line 23307... Line 23541...
23307
				#(reason unavailable), sasl_username=hualing@qbpwcf.org
23541
				#(reason unavailable), sasl_username=hualing@qbpwcf.org
23308
				#Connection lost to authentication server, sasl_username=hualing@qbpwcf.org
23542
				#Connection lost to authentication server, sasl_username=hualing@qbpwcf.org
23309
				#(reason unavailable), sasl_username=1q2w1q2w
23543
				#(reason unavailable), sasl_username=1q2w1q2w
23310
				#(reason unavailable), sasl_username=informix
23544
				#(reason unavailable), sasl_username=informix
23311
				#(reason unavailable), sasl_username=admin3
23545
				#(reason unavailable), sasl_username=admin3
23312
				
23546
 
23313
				#用 " " 分割 分段1,以取得 月日時分秒
23547
				#用 " " 分割 分段1,以取得 月日時分秒
23314
				#函式說明:
23548
				#函式說明:
23315
				#將固定格式的字串分開,並回傳分開的結果.
23549
				#將固定格式的字串分開,並回傳分開的結果.
23316
				#回傳結果:
23550
				#回傳結果:
23317
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
23551
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 23334... Line 23568...
23334
				#無.
23568
				#無.
23335
				#備註:
23569
				#備註:
23336
				#無.
23570
				#無.
23337
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
23571
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
23338
				unset($conf["stringProcess::spiltString"]);
23572
				unset($conf["stringProcess::spiltString"]);
23339
				
23573
 
23340
				#如果分割失敗
23574
				#如果分割失敗
23341
				if($spiltString["status"]==="false"){
23575
				if($spiltString["status"]==="false"){
23342
				
23576
 
23343
					#設置執行失敗
23577
					#設置執行失敗
23344
					$result["status"]="false";
23578
					$result["status"]="false";
23345
 
23579
 
23346
					#設置錯誤訊息
23580
					#設置錯誤訊息
23347
					$result["error"]=$spiltString;
23581
					$result["error"]=$spiltString;
23348
 
23582
 
23349
					#回傳結果
23583
					#回傳結果
23350
					return $result;
23584
					return $result;
23351
					
23585
 
23352
					}#if end
23586
					}#if end
23353
					
23587
 
23354
				#如果分割失敗
23588
				#如果分割失敗
23355
				if($spiltString["dataCounts"]<3){
23589
				if($spiltString["dataCounts"]<3){
23356
				
23590
 
23357
					#設置執行失敗
23591
					#設置執行失敗
23358
					$result["status"]="false";
23592
					$result["status"]="false";
23359
 
23593
 
23360
					#設置錯誤訊息
23594
					#設置錯誤訊息
23361
					$result["error"]=$spiltString;
23595
					$result["error"]=$spiltString;
23362
 
23596
 
23363
					#回傳結果
23597
					#回傳結果
23364
					return $result;
23598
					return $result;
23365
					
23599
 
23366
					}#if end
23600
					}#if end
23367
				
23601
 
23368
				#儲存時間
23602
				#儲存時間
23369
				$occurTime[$index]=strtotime($spiltString["dataArray"][0]." ".$spiltString["dataArray"][1]." ".$spiltString["dataArray"][2]);
23603
				$occurTime[$index]=strtotime($spiltString["dataArray"][0]." ".$spiltString["dataArray"][1]." ".$spiltString["dataArray"][2]);
23370
				
23604
 
23371
				#含有IP的內容範例
23605
				#含有IP的內容範例
23372
				#Sep 28 07:54:16 qbpwcf.org postfix/smtpd[2766456]: warning: unknown[158.94.208.72]
23606
				#Sep 28 07:54:16 qbpwcf.org postfix/smtpd[2766456]: warning: unknown[158.94.208.72]
23373
				#Sep 28 07:57:15 qbpwcf.org postfix/smtpd[2768441]: warning: unknown[213.209.157.249]
23607
				#Sep 28 07:57:15 qbpwcf.org postfix/smtpd[2768441]: warning: unknown[213.209.157.249]
23374
				#Sep 28 08:01:09 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[213.209.157.165]
23608
				#Sep 28 08:01:09 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[213.209.157.165]
23375
				#Sep 28 08:01:51 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[103.109.20.174]
23609
				#Sep 28 08:01:51 qbpwcf.org postfix/smtpd[2771112]: warning: unknown[103.109.20.174]
Line 23381... Line 23615...
23381
				#Sep 28 08:17:16 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]
23615
				#Sep 28 08:17:16 qbpwcf.org postfix/smtpd[2781279]: warning: unknown[178.16.53.142]
23382
				#Sep 28 08:20:28 qbpwcf.org postfix/smtpd[2784204]: warning: unknown[158.94.208.72]
23616
				#Sep 28 08:20:28 qbpwcf.org postfix/smtpd[2784204]: warning: unknown[158.94.208.72]
23383
				#Sep 28 08:23:09 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[213.209.157.249]
23617
				#Sep 28 08:23:09 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[213.209.157.249]
23384
				#Sep 28 08:23:39 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[62.60.130.148]
23618
				#Sep 28 08:23:39 qbpwcf.org postfix/smtpd[2785986]: warning: unknown[62.60.130.148]
23385
				#"${doNotNeed} postfix/smtpd[${pid}]${doNotNeed}[${ip}]"
23619
				#"${doNotNeed} postfix/smtpd[${pid}]${doNotNeed}[${ip}]"
23386
				
23620
 
23387
				#取得 ip
23621
				#取得 ip
23388
				#函式說明:
23622
				#函式說明:
23389
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
23623
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
23390
				#回傳結果:
23624
				#回傳結果:
23391
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
23625
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 23409... Line 23643...
23409
				#無.
23643
				#無.
23410
				#備註:
23644
				#備註:
23411
				#無.
23645
				#無.
23412
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
23646
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
23413
				unset($conf["search::findSpecifyStrFormat"]);
23647
				unset($conf["search::findSpecifyStrFormat"]);
23414
				
23648
 
23415
				#如果分割失敗
23649
				#如果分割失敗
23416
				if($findSpecifyStrFormat["status"]==="false"){
23650
				if($findSpecifyStrFormat["status"]==="false"){
23417
				
23651
 
23418
					#設置執行失敗
23652
					#設置執行失敗
23419
					$result["status"]="false";
23653
					$result["status"]="false";
23420
 
23654
 
23421
					#設置錯誤訊息
23655
					#設置錯誤訊息
23422
					$result["error"]=$findSpecifyStrFormat;
23656
					$result["error"]=$findSpecifyStrFormat;
23423
 
23657
 
23424
					#回傳結果
23658
					#回傳結果
23425
					return $result;
23659
					return $result;
23426
					
23660
 
23427
					}#if end
23661
					}#if end
23428
				
23662
 
23429
				#如果沒有符合格式
23663
				#如果沒有符合格式
23430
				if($findSpecifyStrFormat["found"]==="false"){
23664
				if($findSpecifyStrFormat["found"]==="false"){
23431
				
23665
 
23432
					#剔除時間點 記錄
23666
					#剔除時間點 記錄
23433
					array_pop($occurTime);
23667
					array_pop($occurTime);
23434
				
23668
 
23435
					#跳過該行
23669
					#跳過該行
23436
					continue;
23670
					continue;
23437
				
23671
 
23438
					}#if end
23672
					}#if end
23439
				
23673
 
23440
				#取得解析好的ip
23674
				#取得解析好的ip
23441
				$ip=$findSpecifyStrFormat["parsedVar"]["ip"];
23675
				$ip=$findSpecifyStrFormat["parsedVar"]["ip"];
23442
				
23676
 
23443
				#儲存原始的log行內容
23677
				#儲存原始的log行內容
23444
				$oriLog[$index]=$spiltMutiString["spiltString"][$index ]["oriStr"];
23678
				$oriLog[$index]=$spiltMutiString["spiltString"][$index ]["oriStr"];
23445
				
23679
 
23446
				#初始化儲存有問題的資訊
23680
				#初始化儲存有問題的資訊
23447
				$info=array();
23681
				$info=array();
23448
				
23682
 
23449
				#設置問題對應的log行內容
23683
				#設置問題對應的log行內容
23450
				$info["log"]=$oriLog[$index];
23684
				$info["log"]=$oriLog[$index];
23451
				
23685
 
23452
				#設置問題時間點
23686
				#設置問題時間點
23453
				$info["time"]=$occurTime[$index];
23687
				$info["time"]=$occurTime[$index];
23454
				
23688
 
23455
				#記錄有問題的ip
23689
				#記錄有問題的ip
23456
				$info["ip"]=$ip;
23690
				$info["ip"]=$ip;
23457
				
23691
 
23458
				#取得所需的有問題的IP
23692
				#取得所需的有問題的IP
23459
				$ips_smtp[]=$info;
23693
				$ips_smtp[]=$info;
23460
				
23694
 
23461
				}#foreach end
23695
				}#foreach end
23462
			
23696
 
23463
			}#if end
23697
			}#if end
23464
		
23698
 
23465
		#透過 journalctl -a -e -f --unit=named.service | grep ' query ' 來取得 IP
23699
		#透過 journalctl -a -e -f --unit=named.service | grep ' query ' 來取得 IP
23466
		#函式說明:
23700
		#函式說明:
23467
		#呼叫shell執行系統命令,並取得回傳的內容.
23701
		#呼叫shell執行系統命令,並取得回傳的內容.
23468
		#回傳的結果:
23702
		#回傳的結果:
23469
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
23703
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 23484... Line 23718...
23484
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
23718
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
23485
		#可省略參數:
23719
		#可省略參數:
23486
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
23720
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
23487
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=named.service","|","grep"," query ");
23721
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=named.service","|","grep"," query ");
23488
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
23722
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
23489
		#$conf["arguIsAddr"]=array();	
23723
		#$conf["arguIsAddr"]=array();
23490
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
23724
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
23491
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
23725
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
23492
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
23726
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
23493
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
23727
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
23494
		#$conf["enablePrintDescription"]="true";
23728
		#$conf["enablePrintDescription"]="true";
Line 23514... Line 23748...
23514
		#exec=>http://php.net/manual/en/function.exec.php
23748
		#exec=>http://php.net/manual/en/function.exec.php
23515
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
23749
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
23516
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
23750
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
23517
		$callShell=external::callShell($conf["external::callShell"]);
23751
		$callShell=external::callShell($conf["external::callShell"]);
23518
		unset($conf["external::callShell"]);
23752
		unset($conf["external::callShell"]);
23519
		
23753
 
23520
		#如果執行失敗
23754
		#如果執行失敗
23521
		if($callShell["status"]==="false" && ( $callShell["statusCode"]!==0 && $callShell["statusCode"]!==1 ) ){
23755
		if($callShell["status"]==="false" && ( $callShell["statusCode"]!==0 && $callShell["statusCode"]!==1 ) ){
23522
		
23756
 
23523
			#設置執行失敗
23757
			#設置執行失敗
23524
			$result["status"]="false";
23758
			$result["status"]="false";
23525
 
23759
 
23526
			#設置錯誤訊息
23760
			#設置錯誤訊息
23527
			$result["error"]=$callShell;
23761
			$result["error"]=$callShell;
23528
 
23762
 
23529
			#回傳結果
23763
			#回傳結果
23530
			return $result;
23764
			return $result;
23531
			
23765
 
23532
			}#if end
23766
			}#if end
23533
			
23767
 
23534
		#記錄攻擊者的IP
23768
		#記錄攻擊者的IP
23535
		$attacker_ips_namd=array();
23769
		$attacker_ips_namd=array();
23536
			
23770
 
23537
		#狀態碼不為1才執行
23771
		#狀態碼不為1才執行
23538
		if($callShell["statusCode"]!==1){
23772
		if($callShell["statusCode"]!==1){
23539
			
23773
 
23540
			#截取出的格式
23774
			#截取出的格式
23541
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
23775
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
23542
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f77180297c0 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
23776
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f77180297c0 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
23543
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
23777
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f7714041d10 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
23544
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f77180297c0 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
23778
			#Nov 24 20:55:15 localhost.localdomain named[99512]: client @0x7f77180297c0 191.7.219.100#6238 (PEACECORPS.GOV): query (cache) 'PEACECORPS.GOV/ANY/IN' denied
Line 23582... Line 23816...
23582
			#Sep 29 04:20:28 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23816
			#Sep 29 04:20:28 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23583
			#Sep 29 04:24:20 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23817
			#Sep 29 04:24:20 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23584
			#Sep 29 04:24:59 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23818
			#Sep 29 04:24:59 dns.qbpwcf.org named[94]: client @0x7f60e0060a28 76.20.229.207#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23585
			#Sep 29 04:40:48 dns.qbpwcf.org named[94]: client @0x7f60f9377888 174.96.56.126#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23819
			#Sep 29 04:40:48 dns.qbpwcf.org named[94]: client @0x7f60f9377888 174.96.56.126#80 (sl): query failed (REFUSED) for sl/IN/ANY at ../../../lib/ns/query.c:5691
23586
			#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} client ${doNotNeed} ${ip}#${remoteRevPort} (${$queryTarget}): ${doNotNeed}
23820
			#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} client ${doNotNeed} ${ip}#${remoteRevPort} (${$queryTarget}): ${doNotNeed}
23587
		
23821
 
23588
			#函式說明:
23822
			#函式說明:
23589
			#檢查多個字串中的每個字串是否有多個關鍵字
23823
			#檢查多個字串中的每個字串是否有多個關鍵字
23590
			#回傳結果:
23824
			#回傳結果:
23591
			#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
23825
			#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
23592
			#$result["function"],當前執行的函數名稱.
23826
			#$result["function"],當前執行的函數名稱.
Line 23610... Line 23844...
23610
			#無.
23844
			#無.
23611
			#備註:
23845
			#備註:
23612
			#無.
23846
			#無.
23613
			$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
23847
			$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
23614
			unset($conf["search::findManyKeyWordsFromManyString"]);
23848
			unset($conf["search::findManyKeyWordsFromManyString"]);
23615
			
23849
 
23616
			#如果執行失敗
23850
			#如果執行失敗
23617
			if($findManyKeyWordsFromManyString["status"]==="false"){
23851
			if($findManyKeyWordsFromManyString["status"]==="false"){
23618
			
23852
 
23619
				#設置執行失敗
23853
				#設置執行失敗
23620
				$result["status"]="false";
23854
				$result["status"]="false";
23621
 
23855
 
23622
				#設置錯誤訊息
23856
				#設置錯誤訊息
23623
				$result["error"]=$findManyKeyWordsFromManyString;
23857
				$result["error"]=$findManyKeyWordsFromManyString;
23624
 
23858
 
23625
				#回傳結果
23859
				#回傳結果
23626
				return $result;
23860
				return $result;
23627
				
23861
 
23628
				}#if end
23862
				}#if end
23629
			
23863
 
23630
			#初始化儲存原始log行內容
23864
			#初始化儲存原始log行內容
23631
			#$oriLog=array();
23865
			#$oriLog=array();
23632
			
23866
 
23633
			#儲存疑似有問題的IP
23867
			#儲存疑似有問題的IP
23634
			$ips_named=array();
23868
			$ips_named=array();
23635
			
23869
 
23636
			#初始化儲存確定有問題的ip
23870
			#初始化儲存確定有問題的ip
23637
			$attacker_ips_namd=array();
23871
			$attacker_ips_namd=array();
23638
			
23872
 
23639
			#針對每個符合的行
23873
			#針對每個符合的行
23640
			foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $oriLog){
23874
			foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $oriLog){
23641
 
23875
 
23642
				#初始化儲存資訊的暫存陣列
23876
				#初始化儲存資訊的暫存陣列
23643
				$info=array();
23877
				$info=array();
Line 23667... Line 23901...
23667
				#無.
23901
				#無.
23668
				#備註:
23902
				#備註:
23669
				#無.
23903
				#無.
23670
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
23904
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
23671
				unset($conf["search::findSpecifyStrFormat"]);
23905
				unset($conf["search::findSpecifyStrFormat"]);
23672
				
23906
 
23673
				#如果分割失敗
23907
				#如果分割失敗
23674
				if($findSpecifyStrFormat["status"]==="false"){
23908
				if($findSpecifyStrFormat["status"]==="false"){
23675
				
23909
 
23676
					#設置執行失敗
23910
					#設置執行失敗
23677
					$result["status"]="false";
23911
					$result["status"]="false";
23678
 
23912
 
23679
					#設置錯誤訊息
23913
					#設置錯誤訊息
23680
					$result["error"]=$findSpecifyStrFormat;
23914
					$result["error"]=$findSpecifyStrFormat;
23681
 
23915
 
23682
					#回傳結果
23916
					#回傳結果
23683
					return $result;
23917
					return $result;
23684
					
23918
 
23685
					}#if end
23919
					}#if end
23686
				
23920
 
23687
				#如果沒有符合格式
23921
				#如果沒有符合格式
23688
				if($findSpecifyStrFormat["found"]==="false"){
23922
				if($findSpecifyStrFormat["found"]==="false"){
23689
					
23923
 
23690
					#跳過該行
23924
					#跳過該行
23691
					continue;
23925
					continue;
23692
				
23926
 
23693
					}#if end
23927
					}#if end
23694
					
23928
 
23695
				#儲存時間點
23929
				#儲存時間點
23696
				$info["time"]=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
23930
				$info["time"]=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
23697
			
23931
 
23698
				#儲存ip
23932
				#儲存ip
23699
				$info["ip"]=$findSpecifyStrFormat["parsedVar"]["ip"][0];
23933
				$info["ip"]=$findSpecifyStrFormat["parsedVar"]["ip"][0];
23700
			
23934
 
23701
				#儲存查詢的目標
23935
				#儲存查詢的目標
23702
				$info["queryTarget"]=$findSpecifyStrFormat["parsedVar"]["queryTarget"][0];
23936
				$info["queryTarget"]=$findSpecifyStrFormat["parsedVar"]["queryTarget"][0];
23703
				
23937
 
23704
				#儲存疑似有問題的ip
23938
				#儲存疑似有問題的ip
23705
				$ips_named[$info["ip"]][]=$info;
23939
				$ips_named[$info["ip"]][]=$info;
23706
			
23940
 
23707
				}#foreach end
23941
				}#foreach end
23708
			
23942
 
23709
			/*
23943
			/*
23710
			
23944
 
23711
			#暫存可能有問題的ip資訊
23945
			#暫存可能有問題的ip資訊
23712
			$risky_ips=array();
23946
			$risky_ips=array();
23713
			
23947
 
23714
			#針對每個ip
23948
			#針對每個ip
23715
			foreach($ips_named as $ip => $info){
23949
			foreach($ips_named as $ip => $info){
23716
			
23950
 
23717
				#如果同樣ip不到3次
23951
				#如果同樣ip不到3次
23718
				if(count($ips_named[$ip])<3){
23952
				if(count($ips_named[$ip])<3){
23719
				
23953
 
23720
					#換看下個ip
23954
					#換看下個ip
23721
					continue;
23955
					continue;
23722
				
23956
 
23723
					}#if end
23957
					}#if end
23724
					
23958
 
23725
				#儲存可能有問題的ip資訊
23959
				#儲存可能有問題的ip資訊
23726
				$risky_ips[]=$ips_named[$ip];
23960
				$risky_ips[]=$ips_named[$ip];
23727
				
23961
 
23728
				}#foreach end
23962
				}#foreach end
23729
				
23963
 
23730
			*/
23964
			*/
23731
			
23965
 
23732
			#針對每個可能有問題ip的每個log行
23966
			#針對每個可能有問題ip的每個log行
23733
			foreach($ips_named as $ip => $infos){
23967
			foreach($ips_named as $ip => $infos){
23734
			
23968
 
23735
				#初始化記錄ip來訪不大於1分鐘的計數
23969
				#初始化記錄ip來訪不大於1分鐘的計數
23736
				$count=0;
23970
				$count=0;
23737
				
23971
 
23738
				#針對每個log行資訊
23972
				#針對每個log行資訊
23739
				foreach($infos as $index => $info){
23973
				foreach($infos as $index => $info){
23740
				
23974
 
23741
					#unixtime
23975
					#unixtime
23742
					$time=strtotime($info["time"]);
23976
					$time=strtotime($info["time"]);
23743
				
23977
 
23744
					#如果沒有下筆記錄
23978
					#如果沒有下筆記錄
23745
					if(!isset($infos[$index+1])){
23979
					if(!isset($infos[$index+1])){
23746
					
23980
 
23747
						#結束 foreach
23981
						#結束 foreach
23748
						break;
23982
						break;
23749
						
23983
 
23750
						}#if end
23984
						}#if end
23751
				
23985
 
23752
					#取得unixtime
23986
					#取得unixtime
23753
					$next_time=strtotime($infos[$index+1]["time"]);
23987
					$next_time=strtotime($infos[$index+1]["time"]);
23754
				
23988
 
23755
					#如果時間間隔大於60秒
23989
					#如果時間間隔大於60秒
23756
					if($next_time-$time>60){
23990
					if($next_time-$time>60){
23757
					
23991
 
23758
						#跳過,看下筆記錄
23992
						#跳過,看下筆記錄
23759
						continue;
23993
						continue;
23760
					
23994
 
23761
						}#if end
23995
						}#if end
23762
						
23996
 
23763
					#計數+1
23997
					#計數+1
23764
					$count++;
23998
					$count++;
23765
				
23999
 
23766
					}#foreach end
24000
					}#foreach end
23767
					
24001
 
23768
				#如果有達到3次
24002
				#如果有達到3次
23769
				if($count>=3){
24003
				if($count>=3){
23770
				
24004
 
23771
					#記錄攻擊者的IP
24005
					#記錄攻擊者的IP
23772
					$attacker_ips_namd[]=$ip;
24006
					$attacker_ips_namd[]=$ip;
23773
				
24007
 
23774
					}#if end
24008
					}#if end
23775
			
24009
 
23776
				}#foreach end
24010
				}#foreach end
23777
			
24011
 
23778
			}#if end
24012
			}#if end
23779
		
24013
 
23780
		#透過 journalctl -a -e --unit=dovecot.service 來取得 IP
24014
		#透過 journalctl -a -e --unit=dovecot.service 來取得 IP
23781
		#函式說明:
24015
		#函式說明:
23782
		#呼叫shell執行系統命令,並取得回傳的內容.
24016
		#呼叫shell執行系統命令,並取得回傳的內容.
23783
		#回傳的結果:
24017
		#回傳的結果:
23784
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24018
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 23799... Line 24033...
23799
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
24033
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
23800
		#可省略參數:
24034
		#可省略參數:
23801
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
24035
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
23802
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=dovecot.service");
24036
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=dovecot.service");
23803
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
24037
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
23804
		#$conf["arguIsAddr"]=array();	
24038
		#$conf["arguIsAddr"]=array();
23805
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
24039
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
23806
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
24040
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
23807
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
24041
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
23808
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
24042
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
23809
		#$conf["enablePrintDescription"]="true";
24043
		#$conf["enablePrintDescription"]="true";
Line 23829... Line 24063...
23829
		#exec=>http://php.net/manual/en/function.exec.php
24063
		#exec=>http://php.net/manual/en/function.exec.php
23830
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
24064
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
23831
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
24065
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
23832
		$callShell=external::callShell($conf["external::callShell"]);
24066
		$callShell=external::callShell($conf["external::callShell"]);
23833
		unset($conf["external::callShell"]);
24067
		unset($conf["external::callShell"]);
23834
		
24068
 
23835
		#如果執行失敗
24069
		#如果執行失敗
23836
		if($callShell["status"]==="false"){
24070
		if($callShell["status"]==="false"){
23837
		
24071
 
23838
			#設置執行失敗
24072
			#設置執行失敗
23839
			$result["status"]="false";
24073
			$result["status"]="false";
23840
 
24074
 
23841
			#設置錯誤訊息
24075
			#設置錯誤訊息
23842
			$result["error"]=$callShell;
24076
			$result["error"]=$callShell;
23843
 
24077
 
23844
			#回傳結果
24078
			#回傳結果
23845
			return $result;
24079
			return $result;
23846
			
24080
 
23847
			}#if end
24081
			}#if end
23848
			
24082
 
23849
		#記錄攻擊者的IP
24083
		#記錄攻擊者的IP
23850
		$attacker_ips_imap=array();
24084
		$attacker_ips_imap=array();
23851
		
24085
 
23852
		/* $callShell["output"] 範例截取結果
24086
		/* $callShell["output"] 範例截取結果
23853
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<MxQuPu+73xpliNc9>
24087
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<MxQuPu+73xpliNc9>
23854
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<hH8xPu+7dBtliNc9>
24088
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<hH8xPu+7dBtliNc9>
23855
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<nmI0Pu+7zhtliNc9>
24089
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<nmI0Pu+7zhtliNc9>
23856
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<1GU2Pu+7NBhliNc9>
24090
		Feb 23 00:24:58 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<1GU2Pu+7NBhliNc9>
Line 24001... Line 24235...
24001
		Sep 29 08:40:44 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): check pass; user unknown
24235
		Sep 29 08:40:44 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): check pass; user unknown
24002
		Sep 29 08:40:44 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=1q2w3e4r5t4567 rhost=158.94.208.72
24236
		Sep 29 08:40:44 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=1q2w3e4r5t4567 rhost=158.94.208.72
24003
		Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): check pass; user unknown
24237
		Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): check pass; user unknown
24004
		Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=spam rhost=62.60.130.148
24238
		Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=spam rhost=62.60.130.148
24005
		*/
24239
		*/
24006
		
24240
 
24007
		#認證失敗的關鍵字
24241
		#認證失敗的關鍵字
24008
		$keyWordAF="authentication failure";
24242
		$keyWordAF="authentication failure";
24009
		
24243
 
24010
		#未認證或SSL錯誤
24244
		#未認證或SSL錯誤
24011
		$keyWordNAA="no auth attempts";
24245
		$keyWordNAA="no auth attempts";
24012
		
24246
 
24013
		#搜尋符合關鍵字的log行
24247
		#搜尋符合關鍵字的log行
24014
		#函式說明:
24248
		#函式說明:
24015
		#檢查多個字串中的每個字串是否有多個關鍵字
24249
		#檢查多個字串中的每個字串是否有多個關鍵字
24016
		#回傳結果:
24250
		#回傳結果:
24017
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
24251
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
Line 24036... Line 24270...
24036
		#無.
24270
		#無.
24037
		#備註:
24271
		#備註:
24038
		#無.
24272
		#無.
24039
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
24273
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
24040
		unset($conf["search::findManyKeyWordsFromManyString"]);
24274
		unset($conf["search::findManyKeyWordsFromManyString"]);
24041
		
24275
 
24042
		#如果執行失敗
24276
		#如果執行失敗
24043
		if($findManyKeyWordsFromManyString["status"]==="false"){
24277
		if($findManyKeyWordsFromManyString["status"]==="false"){
24044
		
24278
 
24045
			#設置執行失敗
24279
			#設置執行失敗
24046
			$result["status"]="false";
24280
			$result["status"]="false";
24047
 
24281
 
24048
			#設置錯誤訊息
24282
			#設置錯誤訊息
24049
			$result["error"]=$findManyKeyWordsFromManyString;
24283
			$result["error"]=$findManyKeyWordsFromManyString;
24050
 
24284
 
24051
			#回傳結果
24285
			#回傳結果
24052
			return $result;
24286
			return $result;
24053
			
24287
 
24054
			}#if end
24288
			}#if end
24055
		
24289
 
24056
		#初始化儲存可能有問題的存取Dovecot服務遠端ip
24290
		#初始化儲存可能有問題的存取Dovecot服務遠端ip
24057
		$rickyIpsOfDocecot=array();
24291
		$rickyIpsOfDocecot=array();
24058
		
24292
 
24059
		#針對每個符合的log行
24293
		#針對每個符合的log行
24060
		foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $index => $oriLog){
24294
		foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $index => $oriLog){
24061
		
24295
 
24062
			#找到的關鍵字
24296
			#找到的關鍵字
24063
			$foundKeyWord=$findManyKeyWordsFromManyString["foundedTrueKeyWords"][$index][0];
24297
			$foundKeyWord=$findManyKeyWordsFromManyString["foundedTrueKeyWords"][$index][0];
24064
			
24298
 
24065
			#依照符合的關鍵字
24299
			#依照符合的關鍵字
24066
			switch($foundKeyWord){
24300
			switch($foundKeyWord){
24067
			
24301
 
24068
				#如果是認證失敗
24302
				#如果是認證失敗
24069
				case $keyWordAF:
24303
				case $keyWordAF:
24070
		
24304
 
24071
					#範例
24305
					#範例
24072
					#Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=spam rhost=62.60.130.148
24306
					#Sep 29 08:41:18 qbpwcf.org auth[3776113]: pam_unix(dovecot:auth): authentication failure; logname=liveuser uid=0 euid=0 tty=dovecot ruser=spam rhost=62.60.130.148
24073
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} : authentication failure; logname=${account} ${doNotNeed} rhost=${ip}
24307
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} : authentication failure; logname=${account} ${doNotNeed} rhost=${ip}
24074
		
24308
 
24075
					#取得時間點跟遠端IP
24309
					#取得時間點跟遠端IP
24076
					#函式說明:
24310
					#函式說明:
24077
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24311
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24078
					#回傳結果:
24312
					#回傳結果:
24079
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24313
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 24097... Line 24331...
24097
					#無.
24331
					#無.
24098
					#備註:
24332
					#備註:
24099
					#無.
24333
					#無.
24100
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24334
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24101
					unset($conf["search::findSpecifyStrFormat"]);
24335
					unset($conf["search::findSpecifyStrFormat"]);
24102
					
24336
 
24103
					#如果分割失敗
24337
					#如果分割失敗
24104
					if($findSpecifyStrFormat["status"]==="false"){
24338
					if($findSpecifyStrFormat["status"]==="false"){
24105
					
24339
 
24106
						#設置執行失敗
24340
						#設置執行失敗
24107
						$result["status"]="false";
24341
						$result["status"]="false";
24108
 
24342
 
24109
						#設置錯誤訊息
24343
						#設置錯誤訊息
24110
						$result["error"]=$findSpecifyStrFormat;
24344
						$result["error"]=$findSpecifyStrFormat;
24111
 
24345
 
24112
						#回傳結果
24346
						#回傳結果
24113
						return $result;
24347
						return $result;
24114
						
24348
 
24115
						}#if end
24349
						}#if end
24116
					
24350
 
24117
					#如果沒有符合格式
24351
					#如果沒有符合格式
24118
					if($findSpecifyStrFormat["found"]==="false"){
24352
					if($findSpecifyStrFormat["found"]==="false"){
24119
						
24353
 
24120
						#跳過該行
24354
						#跳過該行
24121
						continue 2;
24355
						continue 2;
24122
					
24356
 
24123
						}#if end
24357
						}#if end
24124
					
24358
 
24125
					#取得時間點
24359
					#取得時間點
24126
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24360
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24127
				
24361
 
24128
					#取得ip
24362
					#取得ip
24129
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24363
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24130
					
24364
 
24131
					#儲存其資訊
24365
					#儲存其資訊
24132
					$rickyIpsOfDocecot[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24366
					$rickyIpsOfDocecot[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24133
				
24367
 
24134
					#跳出  switch
24368
					#跳出  switch
24135
					break;
24369
					break;
24136
				
24370
 
24137
				#如果是未認證或SSL錯誤
24371
				#如果是未認證或SSL錯誤
24138
				case $keyWordNAA:
24372
				case $keyWordNAA:
24139
				
24373
 
24140
					#範例
24374
					#範例
24141
					#Feb 23 07:59:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<70q2l/W7PBhliNc9>
24375
					#Feb 23 07:59:30 localhost.localdomain dovecot[1427]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=101.136.215.61, lip=169.254.1.1, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<70q2l/W7PBhliNc9>
24142
					#Sep 29 06:53:42 qbpwcf.org dovecot[98]: imap-login: Disconnected: Connection closed (no auth attempts in 0 secs): user=<>, rip=3.231.151.171, lip=169.254.2.1, TLS, session=<MaKQGOs/wIMD55er>
24376
					#Sep 29 06:53:42 qbpwcf.org dovecot[98]: imap-login: Disconnected: Connection closed (no auth attempts in 0 secs): user=<>, rip=3.231.151.171, lip=169.254.2.1, TLS, session=<MaKQGOs/wIMD55er>
24143
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} ( no auth attempts in ${doNotNeed} user=<${account}>, rip=${ip}, ${doNotNeed}
24377
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} ( no auth attempts in ${doNotNeed} user=<${account}>, rip=${ip}, ${doNotNeed}
24144
					
24378
 
24145
					#取得時間點跟遠端IP
24379
					#取得時間點跟遠端IP
24146
					#函式說明:
24380
					#函式說明:
24147
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24381
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24148
					#回傳結果:
24382
					#回傳結果:
24149
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24383
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 24167... Line 24401...
24167
					#無.
24401
					#無.
24168
					#備註:
24402
					#備註:
24169
					#無.
24403
					#無.
24170
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24404
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24171
					unset($conf["search::findSpecifyStrFormat"]);
24405
					unset($conf["search::findSpecifyStrFormat"]);
24172
					
24406
 
24173
					#如果分割失敗
24407
					#如果分割失敗
24174
					if($findSpecifyStrFormat["status"]==="false"){
24408
					if($findSpecifyStrFormat["status"]==="false"){
24175
					
24409
 
24176
						#設置執行失敗
24410
						#設置執行失敗
24177
						$result["status"]="false";
24411
						$result["status"]="false";
24178
 
24412
 
24179
						#設置錯誤訊息
24413
						#設置錯誤訊息
24180
						$result["error"]=$findSpecifyStrFormat;
24414
						$result["error"]=$findSpecifyStrFormat;
24181
 
24415
 
24182
						#回傳結果
24416
						#回傳結果
24183
						return $result;
24417
						return $result;
24184
						
24418
 
24185
						}#if end
24419
						}#if end
24186
					
24420
 
24187
					#如果沒有符合格式
24421
					#如果沒有符合格式
24188
					if($findSpecifyStrFormat["found"]==="false"){
24422
					if($findSpecifyStrFormat["found"]==="false"){
24189
						
24423
 
24190
						#跳過該行
24424
						#跳過該行
24191
						continue 2;
24425
						continue 2;
24192
					
24426
 
24193
						}#if end
24427
						}#if end
24194
					
24428
 
24195
					#取得時間點
24429
					#取得時間點
24196
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24430
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24197
				
24431
 
24198
					#取得ip
24432
					#取得ip
24199
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24433
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24200
					
24434
 
24201
					#儲存其資訊
24435
					#儲存其資訊
24202
					$rickyIpsOfDocecot[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24436
					$rickyIpsOfDocecot[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24203
					
24437
 
24204
					#跳出  switch
24438
					#跳出  switch
24205
					break;
24439
					break;
24206
					
24440
 
24207
				#不應該執行到這邊
24441
				#不應該執行到這邊
24208
				default:
24442
				default:
24209
			
24443
 
24210
					#設置執行失敗
24444
					#設置執行失敗
24211
					$result["status"]="false";
24445
					$result["status"]="false";
24212
 
24446
 
24213
					#設置錯誤訊息
24447
					#設置錯誤訊息
24214
					$result["error"][]="unexpected error";
24448
					$result["error"][]="unexpected error";
Line 24216... Line 24450...
24216
					#設置錯誤訊息
24450
					#設置錯誤訊息
24217
					$result["error"][]=$findManyKeyWordsFromManyString;
24451
					$result["error"][]=$findManyKeyWordsFromManyString;
24218
 
24452
 
24219
					#回傳結果
24453
					#回傳結果
24220
					return $result;
24454
					return $result;
24221
			
24455
 
24222
				}#switch end
24456
				}#switch end
24223
			
24457
 
24224
			}#foreach end
24458
			}#foreach end
24225
		
24459
 
24226
		#初始化儲存可能有問題的ip資訊
24460
		#初始化儲存可能有問題的ip資訊
24227
		$risky_ips=array();
24461
		$risky_ips=array();
24228
		
24462
 
24229
		#針對每個ip
24463
		#針對每個ip
24230
		foreach($rickyIpsOfDocecot as $ip => $info){
24464
		foreach($rickyIpsOfDocecot as $ip => $info){
24231
		
24465
 
24232
			#如果同樣ip不到3次
24466
			#如果同樣ip不到3次
24233
			if(count($rickyIpsOfDocecot[$ip])<3){
24467
			if(count($rickyIpsOfDocecot[$ip])<3){
24234
			
24468
 
24235
				#換看下個ip
24469
				#換看下個ip
24236
				continue;
24470
				continue;
24237
			
24471
 
24238
				}#if end
24472
				}#if end
24239
				
24473
 
24240
			#儲存可能有問題的ip資訊
24474
			#儲存可能有問題的ip資訊
24241
			$risky_ips[]=$rickyIpsOfDocecot[$ip];
24475
			$risky_ips[]=$rickyIpsOfDocecot[$ip];
24242
			
24476
 
24243
			}#foreach end
24477
			}#foreach end
24244
		
24478
 
24245
		#針對每個可能有問題ip的每個log行
24479
		#針對每個可能有問題ip的每個log行
24246
		foreach($risky_ips as $ip => $infos){
24480
		foreach($risky_ips as $ip => $infos){
24247
		
24481
 
24248
			#初始化記錄ip來訪不大於1分鐘的計數
24482
			#初始化記錄ip來訪不大於1分鐘的計數
24249
			$count=0;
24483
			$count=0;
24250
			
24484
 
24251
			#針對每個log行資訊
24485
			#針對每個log行資訊
24252
			foreach($infos as $index => $info){
24486
			foreach($infos as $index => $info){
24253
			
24487
 
24254
				#unixtime
24488
				#unixtime
24255
				$time=strtotime($info["time"]);
24489
				$time=strtotime($info["time"]);
24256
			
24490
 
24257
				#如果沒有下筆記錄
24491
				#如果沒有下筆記錄
24258
				if(!isset($risky_ips[$index+1])){
24492
				if(!isset($risky_ips[$index+1])){
24259
				
24493
 
24260
					#結束 foreach
24494
					#結束 foreach
24261
					break;
24495
					break;
24262
					
24496
 
24263
					}#if end
24497
					}#if end
24264
			
24498
 
24265
				#取得unixtime
24499
				#取得unixtime
24266
				$next_time=strtotime($risky_ips[$index+1]["time"]);
24500
				$next_time=strtotime($risky_ips[$index+1]["time"]);
24267
			
24501
 
24268
				#如果時間間隔大於60秒
24502
				#如果時間間隔大於60秒
24269
				if($next_time-$time>60){
24503
				if($next_time-$time>60){
24270
				
24504
 
24271
					#跳過,看下筆記錄
24505
					#跳過,看下筆記錄
24272
					continue;
24506
					continue;
24273
				
24507
 
24274
					}#if end
24508
					}#if end
24275
					
24509
 
24276
				#計數+1
24510
				#計數+1
24277
				$count++;
24511
				$count++;
24278
			
24512
 
24279
				}#foreach end
24513
				}#foreach end
24280
				
24514
 
24281
			#如果有達到3次
24515
			#如果有達到3次
24282
			if($count>=3){
24516
			if($count>=3){
24283
			
24517
 
24284
				#記錄攻擊者的IP
24518
				#記錄攻擊者的IP
24285
				$$attacker_ips_imap[]=$ip;
24519
				$$attacker_ips_imap[]=$ip;
24286
			
24520
 
24287
				}#if end
24521
				}#if end
24288
		
24522
 
24289
			}#foreach end
24523
			}#foreach end
24290
				
24524
 
24291
		#記錄ssh攻擊者的IP
24525
		#記錄ssh攻擊者的IP
24292
		$attacker_ips_ssh=array();
24526
		$attacker_ips_ssh=array();
24293
		
24527
 
24294
		#透過 journalctl -a -e --unit=sshd.service來取得 ssh 攻擊者的 IP
24528
		#透過 journalctl -a -e --unit=sshd.service來取得 ssh 攻擊者的 IP
24295
		#函式說明:
24529
		#函式說明:
24296
		#呼叫shell執行系統命令,並取得回傳的內容.
24530
		#呼叫shell執行系統命令,並取得回傳的內容.
24297
		#回傳的結果:
24531
		#回傳的結果:
24298
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24532
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 24313... Line 24547...
24313
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
24547
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
24314
		#可省略參數:
24548
		#可省略參數:
24315
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
24549
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
24316
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=sshd.service");
24550
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=sshd.service");
24317
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
24551
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
24318
		#$conf["arguIsAddr"]=array();	
24552
		#$conf["arguIsAddr"]=array();
24319
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
24553
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
24320
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
24554
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
24321
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
24555
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
24322
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
24556
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
24323
		#$conf["enablePrintDescription"]="true";
24557
		#$conf["enablePrintDescription"]="true";
Line 24343... Line 24577...
24343
		#exec=>http://php.net/manual/en/function.exec.php
24577
		#exec=>http://php.net/manual/en/function.exec.php
24344
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
24578
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
24345
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
24579
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
24346
		$callShell=external::callShell($conf["external::callShell"]);
24580
		$callShell=external::callShell($conf["external::callShell"]);
24347
		unset($conf["external::callShell"]);
24581
		unset($conf["external::callShell"]);
24348
		
24582
 
24349
		#如果執行失敗
24583
		#如果執行失敗
24350
		if($callShell["status"]==="false"){
24584
		if($callShell["status"]==="false"){
24351
		
24585
 
24352
			#設置執行失敗
24586
			#設置執行失敗
24353
			$result["status"]="false";
24587
			$result["status"]="false";
24354
 
24588
 
24355
			#設置錯誤訊息
24589
			#設置錯誤訊息
24356
			$result["error"]=$callShell;
24590
			$result["error"]=$callShell;
24357
 
24591
 
24358
			#回傳結果
24592
			#回傳結果
24359
			return $result;
24593
			return $result;
24360
			
24594
 
24361
			}#if end
24595
			}#if end
24362
			
24596
 
24363
		/*
24597
		/*
24364
		得到的範例輸出
24598
		得到的範例輸出
24365
		Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: Invalid user lizepeng from 60.213.10.69 port 39156
24599
		Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: Invalid user lizepeng from 60.213.10.69 port 39156
24366
		Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: pam_unix(sshd:auth): check pass; user unknown
24600
		Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: pam_unix(sshd:auth): check pass; user unknown
24367
		Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=60.213.10.69
24601
		Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=60.213.10.69
Line 24384... Line 24618...
24384
		Sep 30 08:10:13 silverblue-guest.qbpwcf.org sshd-session[2663658]: Connection closed by authenticating user root 183.13.207.69 port 17293 [preauth]
24618
		Sep 30 08:10:13 silverblue-guest.qbpwcf.org sshd-session[2663658]: Connection closed by authenticating user root 183.13.207.69 port 17293 [preauth]
24385
		*/
24619
		*/
24386
 
24620
 
24387
		#認證失敗的關鍵字
24621
		#認證失敗的關鍵字
24388
		$keyWordFP=" Failed password ";
24622
		$keyWordFP=" Failed password ";
24389
		
24623
 
24390
		#不存在使用者的關鍵字
24624
		#不存在使用者的關鍵字
24391
		$keyWordIU=" Invalid user ";
24625
		$keyWordIU=" Invalid user ";
24392
		
24626
 
24393
		#搜尋符合關鍵字的log行
24627
		#搜尋符合關鍵字的log行
24394
		#函式說明:
24628
		#函式說明:
24395
		#檢查多個字串中的每個字串是否有多個關鍵字
24629
		#檢查多個字串中的每個字串是否有多個關鍵字
24396
		#回傳結果:
24630
		#回傳結果:
24397
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
24631
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
Line 24416... Line 24650...
24416
		#無.
24650
		#無.
24417
		#備註:
24651
		#備註:
24418
		#無.
24652
		#無.
24419
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
24653
		$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
24420
		unset($conf["search::findManyKeyWordsFromManyString"]);
24654
		unset($conf["search::findManyKeyWordsFromManyString"]);
24421
		
24655
 
24422
		#如果執行失敗
24656
		#如果執行失敗
24423
		if($findManyKeyWordsFromManyString["status"]==="false"){
24657
		if($findManyKeyWordsFromManyString["status"]==="false"){
24424
		
24658
 
24425
			#設置執行失敗
24659
			#設置執行失敗
24426
			$result["status"]="false";
24660
			$result["status"]="false";
24427
 
24661
 
24428
			#設置錯誤訊息
24662
			#設置錯誤訊息
24429
			$result["error"]=$findManyKeyWordsFromManyString;
24663
			$result["error"]=$findManyKeyWordsFromManyString;
24430
 
24664
 
24431
			#回傳結果
24665
			#回傳結果
24432
			return $result;
24666
			return $result;
24433
			
24667
 
24434
			}#if end
24668
			}#if end
24435
		
24669
 
24436
		#初始化儲存可能有問題的存取ssh服務遠端ip
24670
		#初始化儲存可能有問題的存取ssh服務遠端ip
24437
		$risky_ips=array();
24671
		$risky_ips=array();
24438
		
24672
 
24439
		#針對每個符合的log行
24673
		#針對每個符合的log行
24440
		foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $index => $oriLog){
24674
		foreach($findManyKeyWordsFromManyString["foundedTrueKey"] as $index => $oriLog){
24441
		
24675
 
24442
			#找到的關鍵字
24676
			#找到的關鍵字
24443
			$foundKeyWord=$findManyKeyWordsFromManyString["foundedTrueKeyWords"][$index][0];
24677
			$foundKeyWord=$findManyKeyWordsFromManyString["foundedTrueKeyWords"][$index][0];
24444
			
24678
 
24445
			#依照符合的關鍵字
24679
			#依照符合的關鍵字
24446
			switch($foundKeyWord){
24680
			switch($foundKeyWord){
24447
			
24681
 
24448
				#如果是秘密碼錯誤
24682
				#如果是秘密碼錯誤
24449
				case $keyWordFP:
24683
				case $keyWordFP:
24450
		
24684
 
24451
					#範例
24685
					#範例
24452
					#Sep 30 08:10:13 silverblue-guest.qbpwcf.org sshd-session[2663658]: Failed password for root from 183.13.207.69 port 17293 ssh2
24686
					#Sep 30 08:10:13 silverblue-guest.qbpwcf.org sshd-session[2663658]: Failed password for root from 183.13.207.69 port 17293 ssh2
24453
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} Failed password for ${account} from ${ip} ${doNotNeed}
24687
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} Failed password for ${account} from ${ip} ${doNotNeed}
24454
		
24688
 
24455
					#取得時間點跟遠端IP
24689
					#取得時間點跟遠端IP
24456
					#函式說明:
24690
					#函式說明:
24457
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24691
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24458
					#回傳結果:
24692
					#回傳結果:
24459
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24693
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 24477... Line 24711...
24477
					#無.
24711
					#無.
24478
					#備註:
24712
					#備註:
24479
					#無.
24713
					#無.
24480
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24714
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24481
					unset($conf["search::findSpecifyStrFormat"]);
24715
					unset($conf["search::findSpecifyStrFormat"]);
24482
					
24716
 
24483
					#如果分割失敗
24717
					#如果分割失敗
24484
					if($findSpecifyStrFormat["status"]==="false"){
24718
					if($findSpecifyStrFormat["status"]==="false"){
24485
					
24719
 
24486
						#設置執行失敗
24720
						#設置執行失敗
24487
						$result["status"]="false";
24721
						$result["status"]="false";
24488
 
24722
 
24489
						#設置錯誤訊息
24723
						#設置錯誤訊息
24490
						$result["error"]=$findSpecifyStrFormat;
24724
						$result["error"]=$findSpecifyStrFormat;
24491
 
24725
 
24492
						#回傳結果
24726
						#回傳結果
24493
						return $result;
24727
						return $result;
24494
						
24728
 
24495
						}#if end
24729
						}#if end
24496
					
24730
 
24497
					#如果沒有符合格式
24731
					#如果沒有符合格式
24498
					if($findSpecifyStrFormat["found"]==="false"){
24732
					if($findSpecifyStrFormat["found"]==="false"){
24499
						
24733
 
24500
						#跳過該行
24734
						#跳過該行
24501
						continue 2;
24735
						continue 2;
24502
					
24736
 
24503
						}#if end
24737
						}#if end
24504
					
24738
 
24505
					#取得時間點
24739
					#取得時間點
24506
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24740
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24507
				
24741
 
24508
					#取得ip
24742
					#取得ip
24509
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24743
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24510
					
24744
 
24511
					#儲存其資訊
24745
					#儲存其資訊
24512
					$risky_ips[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24746
					$risky_ips[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24513
				
24747
 
24514
					#跳出  switch
24748
					#跳出  switch
24515
					break;
24749
					break;
24516
				
24750
 
24517
				#如果是不存在的使用者
24751
				#如果是不存在的使用者
24518
				case $keyWordIU:
24752
				case $keyWordIU:
24519
				
24753
 
24520
					#範例
24754
					#範例
24521
					#Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: Invalid user lizepeng from 60.213.10.69 port 39156
24755
					#Sep 30 00:36:36 silverblue-guest.qbpwcf.org sshd-session[1607010]: Invalid user lizepeng from 60.213.10.69 port 39156
24522
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} Invalid user ${account} from ${ip} port ${doNotNeed}
24756
					#${month} ${day} ${hour}:${min}:${sec} ${doNotNeed} Invalid user ${account} from ${ip} port ${doNotNeed}
24523
					
24757
 
24524
					#取得時間點跟遠端IP
24758
					#取得時間點跟遠端IP
24525
					#函式說明:
24759
					#函式說明:
24526
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24760
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
24527
					#回傳結果:
24761
					#回傳結果:
24528
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24762
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 24546... Line 24780...
24546
					#無.
24780
					#無.
24547
					#備註:
24781
					#備註:
24548
					#無.
24782
					#無.
24549
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24783
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
24550
					unset($conf["search::findSpecifyStrFormat"]);
24784
					unset($conf["search::findSpecifyStrFormat"]);
24551
					
24785
 
24552
					#如果分割失敗
24786
					#如果分割失敗
24553
					if($findSpecifyStrFormat["status"]==="false"){
24787
					if($findSpecifyStrFormat["status"]==="false"){
24554
					
24788
 
24555
						#設置執行失敗
24789
						#設置執行失敗
24556
						$result["status"]="false";
24790
						$result["status"]="false";
24557
 
24791
 
24558
						#設置錯誤訊息
24792
						#設置錯誤訊息
24559
						$result["error"]=$findSpecifyStrFormat;
24793
						$result["error"]=$findSpecifyStrFormat;
24560
 
24794
 
24561
						#回傳結果
24795
						#回傳結果
24562
						return $result;
24796
						return $result;
24563
						
24797
 
24564
						}#if end
24798
						}#if end
24565
					
24799
 
24566
					#如果沒有符合格式
24800
					#如果沒有符合格式
24567
					if($findSpecifyStrFormat["found"]==="false"){
24801
					if($findSpecifyStrFormat["found"]==="false"){
24568
						
24802
 
24569
						#跳過該行
24803
						#跳過該行
24570
						continue 2;
24804
						continue 2;
24571
					
24805
 
24572
						}#if end
24806
						}#if end
24573
					
24807
 
24574
					#取得時間點
24808
					#取得時間點
24575
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24809
					$time=$findSpecifyStrFormat["parsedVar"]["month"][0]." ".$findSpecifyStrFormat["parsedVar"]["day"][0]." ".$findSpecifyStrFormat["parsedVar"]["hour"][0].":".$findSpecifyStrFormat["parsedVar"]["min"][0].":".$findSpecifyStrFormat["parsedVar"]["sec"][0];
24576
				
24810
 
24577
					#取得ip
24811
					#取得ip
24578
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24812
					$ip=$findSpecifyStrFormat["parsedVar"]["ip"][0];
24579
					
24813
 
24580
					#儲存其資訊
24814
					#儲存其資訊
24581
					$risky_ips[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24815
					$risky_ips[$ip][]=array("time"=>$time,"ip"=>$ip,"log"=>$oriLog);
24582
					
24816
 
24583
					#跳出  switch
24817
					#跳出  switch
24584
					break;
24818
					break;
24585
					
24819
 
24586
				#不應該執行到這邊
24820
				#不應該執行到這邊
24587
				default:
24821
				default:
24588
			
24822
 
24589
					#設置執行失敗
24823
					#設置執行失敗
24590
					$result["status"]="false";
24824
					$result["status"]="false";
24591
 
24825
 
24592
					#設置錯誤訊息
24826
					#設置錯誤訊息
24593
					$result["error"][]="unexpected error";
24827
					$result["error"][]="unexpected error";
Line 24595... Line 24829...
24595
					#設置錯誤訊息
24829
					#設置錯誤訊息
24596
					$result["error"][]=$findManyKeyWordsFromManyString;
24830
					$result["error"][]=$findManyKeyWordsFromManyString;
24597
 
24831
 
24598
					#回傳結果
24832
					#回傳結果
24599
					return $result;
24833
					return $result;
24600
			
24834
 
24601
				}#switch end
24835
				}#switch end
24602
				
24836
 
24603
			}#foreach end
24837
			}#foreach end
24604
			
24838
 
24605
		#針對每個可能有問題ip的每個log行
24839
		#針對每個可能有問題ip的每個log行
24606
		foreach($risky_ips as $ip => $infos){
24840
		foreach($risky_ips as $ip => $infos){
24607
		
24841
 
24608
			#初始化記錄ip來訪不大於1分鐘的計數
24842
			#初始化記錄ip來訪不大於1分鐘的計數
24609
			$count=0;
24843
			$count=0;
24610
			
24844
 
24611
			#針對每個log行資訊
24845
			#針對每個log行資訊
24612
			foreach($infos as $index => $info){
24846
			foreach($infos as $index => $info){
24613
			
24847
 
24614
				#unixtime
24848
				#unixtime
24615
				$time=strtotime($info["time"]);
24849
				$time=strtotime($info["time"]);
24616
			
24850
 
24617
				#如果沒有下筆記錄
24851
				#如果沒有下筆記錄
24618
				if(!isset($risky_ips[$index+1])){
24852
				if(!isset($risky_ips[$index+1])){
24619
				
24853
 
24620
					#結束 foreach
24854
					#結束 foreach
24621
					break;
24855
					break;
24622
					
24856
 
24623
					}#if end
24857
					}#if end
24624
			
24858
 
24625
				#取得unixtime
24859
				#取得unixtime
24626
				$next_time=strtotime($risky_ips[$index+1]["time"]);
24860
				$next_time=strtotime($risky_ips[$index+1]["time"]);
24627
			
24861
 
24628
				#如果時間間隔大於60秒
24862
				#如果時間間隔大於60秒
24629
				if($next_time-$time>60){
24863
				if($next_time-$time>60){
24630
				
24864
 
24631
					#跳過,看下筆記錄
24865
					#跳過,看下筆記錄
24632
					continue;
24866
					continue;
24633
				
24867
 
24634
					}#if end
24868
					}#if end
24635
					
24869
 
24636
				#計數+1
24870
				#計數+1
24637
				$count++;
24871
				$count++;
24638
			
24872
 
24639
				}#foreach end
24873
				}#foreach end
24640
				
24874
 
24641
			#如果有達到3次
24875
			#如果有達到3次
24642
			if($count>=3){
24876
			if($count>=3){
24643
			
24877
 
24644
				#記錄攻擊者的IP
24878
				#記錄攻擊者的IP
24645
				$attacker_ips_ssh[]=$ip;
24879
				$attacker_ips_ssh[]=$ip;
24646
			
24880
 
24647
				}#if end
24881
				}#if end
24648
		
24882
 
24649
			}#foreach end
24883
			}#foreach end
24650
		
24884
 
24651
		#合併取得的有問題IP集合
24885
		#合併取得的有問題IP集合
24652
		#$ips,$ips_https,$ips_smtp,$attacker_ips_imap,$attacker_ips_namd,$attacker_ips_ssh
24886
		#$ips,$ips_https,$ips_smtp,$attacker_ips_imap,$attacker_ips_namd,$attacker_ips_ssh
24653
		
24887
 
24654
		#函式說明:
24888
		#函式說明:
24655
		#將多個一維陣列串聯起來,key從0開始排序.
24889
		#將多個一維陣列串聯起來,key從0開始排序.
24656
		#回傳的結果:
24890
		#回傳的結果:
24657
		#$result["status"],"true"表執行正常,"false"代表執行不正常.
24891
		#$result["status"],"true"表執行正常,"false"代表執行不正常.
24658
		#$result["error"],錯誤訊息陣列.
24892
		#$result["error"],錯誤訊息陣列.
Line 24664... Line 24898...
24664
		#可省略參數:
24898
		#可省略參數:
24665
		#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
24899
		#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
24666
		$conf["arrays::mergeArray"]["allowRepeat"]="false";
24900
		$conf["arrays::mergeArray"]["allowRepeat"]="false";
24667
		$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
24901
		$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
24668
		unset($conf["arrays::mergeArray"]);
24902
		unset($conf["arrays::mergeArray"]);
24669
		
24903
 
24670
		#如果分割失敗
24904
		#如果分割失敗
24671
		if($mergeArray["status"]==="false"){
24905
		if($mergeArray["status"]==="false"){
24672
		
24906
 
24673
			#設置執行失敗
24907
			#設置執行失敗
24674
			$result["status"]="false";
24908
			$result["status"]="false";
24675
 
24909
 
24676
			#設置錯誤訊息
24910
			#設置錯誤訊息
24677
			$result["error"]=$mergeArray;
24911
			$result["error"]=$mergeArray;
24678
 
24912
 
24679
			#回傳結果
24913
			#回傳結果
24680
			return $result;
24914
			return $result;
24681
			
24915
 
24682
			}#if end
24916
			}#if end
24683
			
24917
 
24684
		#取得不重複的IP
24918
		#取得不重複的IP
24685
		$ips=$mergeArray["content"];
24919
		$ips=$mergeArray["content"];
24686
		
24920
 
24687
		#取得防火牆的IP block清單
24921
		#取得防火牆的IP block清單
24688
		#cmd:firewall-cmd --list-rich-rule
24922
		#cmd:firewall-cmd --list-rich-rule
24689
		
24923
 
24690
		#函式說明:
24924
		#函式說明:
24691
		#檢查指令的輸出是否含有關鍵字
24925
		#檢查指令的輸出是否含有關鍵字
24692
		#回傳結果:
24926
		#回傳結果:
24693
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24927
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24694
		#$result["error"],錯誤訊息.
24928
		#$result["error"],錯誤訊息.
Line 24709... Line 24943...
24709
		#$conf["binPath"]="";
24943
		#$conf["binPath"]="";
24710
		#$conf["argu"],陣列字串,指令搭配的參數,預設不使用.
24944
		#$conf["argu"],陣列字串,指令搭配的參數,預設不使用.
24711
		$conf["cmd::searchOutPut"]["argu"]=array("--list-rich-rule");
24945
		$conf["cmd::searchOutPut"]["argu"]=array("--list-rich-rule");
24712
		#$conf["excludeGrep"],字串,"true"代表排除含有 " | grep ".$conf["keyWord"] 字樣的輸出;預設為"false",不排除.
24946
		#$conf["excludeGrep"],字串,"true"代表排除含有 " | grep ".$conf["keyWord"] 字樣的輸出;預設為"false",不排除.
24713
		#$conf["excludeGrep"]="false";
24947
		#$conf["excludeGrep"]="false";
24714
		
24948
 
24715
		#如果有設置 username
24949
		#如果有設置 username
24716
		if(isset($conf["username"])){
24950
		if(isset($conf["username"])){
24717
		
24951
 
24718
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
24952
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
24719
			$conf["cmd::searchOutPut"]["username"]=$conf["username"];
24953
			$conf["cmd::searchOutPut"]["username"]=$conf["username"];
24720
		
24954
 
24721
			}#if end
24955
			}#if end
24722
		
24956
 
24723
		#如果有設置 password
24957
		#如果有設置 password
24724
		if(isset($conf["password"])){
24958
		if(isset($conf["password"])){
24725
		
24959
 
24726
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
24960
			#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
24727
			$conf["cmd::searchOutPut"]["password"]=$conf["password"];
24961
			$conf["cmd::searchOutPut"]["password"]=$conf["password"];
24728
		
24962
 
24729
			}#if end
24963
			}#if end
24730
			
24964
 
24731
		$searchOutPut=cmd::searchOutPut($conf["cmd::searchOutPut"]);
24965
		$searchOutPut=cmd::searchOutPut($conf["cmd::searchOutPut"]);
24732
		unset($conf["cmd::searchOutPut"]);
24966
		unset($conf["cmd::searchOutPut"]);
24733
		
24967
 
24734
		#如果執行失敗
24968
		#如果執行失敗
24735
		if($searchOutPut["status"]==="false"){
24969
		if($searchOutPut["status"]==="false"){
24736
		
24970
 
24737
			#設置執行失敗
24971
			#設置執行失敗
24738
			$result["status"]="false";
24972
			$result["status"]="false";
24739
 
24973
 
24740
			#設置錯誤訊息
24974
			#設置錯誤訊息
24741
			$result["error"]=$searchOutPut;
24975
			$result["error"]=$searchOutPut;
24742
 
24976
 
24743
			#回傳結果
24977
			#回傳結果
24744
			return $result;
24978
			return $result;
24745
		
24979
 
24746
			}#if end
24980
			}#if end
24747
			
24981
 
24748
		#初始化儲存已封鎖IP的陣列
24982
		#初始化儲存已封鎖IP的陣列
24749
		$ips_blocked=array();	
24983
		$ips_blocked=array();
24750
			
24984
 
24751
		#如果有找到關鍵字 " reject"
24985
		#如果有找到關鍵字 " reject"
24752
		if($searchOutPut["founded"]==="true"){
24986
		if($searchOutPut["founded"]==="true"){
24753
			
24987
 
24754
			#用 " 來分割每列字串
24988
			#用 " 來分割每列字串
24755
			#函式說明:
24989
			#函式說明:
24756
			#將多個固定格式的字串分開,並回傳分開的結果
24990
			#將多個固定格式的字串分開,並回傳分開的結果
24757
			#回傳的參數:
24991
			#回傳的參數:
24758
			#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
24992
			#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 24767... Line 25001...
24767
			$conf["stringProcess::spiltMutiString"]["stringIn"]=$searchOutPut["content"];
25001
			$conf["stringProcess::spiltMutiString"]["stringIn"]=$searchOutPut["content"];
24768
			#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
25002
			#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
24769
			$conf["stringProcess::spiltMutiString"]["spiltSymbol"]="\"";
25003
			$conf["stringProcess::spiltMutiString"]["spiltSymbol"]="\"";
24770
			$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
25004
			$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
24771
			unset($conf["stringProcess::spiltMutiString"]);
25005
			unset($conf["stringProcess::spiltMutiString"]);
24772
			
25006
 
24773
			#如果分割失敗
25007
			#如果分割失敗
24774
			if($spiltMutiString["status"]==="false"){
25008
			if($spiltMutiString["status"]==="false"){
24775
			
25009
 
24776
				#設置執行失敗
25010
				#設置執行失敗
24777
				$result["status"]="false";
25011
				$result["status"]="false";
24778
 
25012
 
24779
				#設置錯誤訊息
25013
				#設置錯誤訊息
24780
				$result["error"]=$spiltMutiString;
25014
				$result["error"]=$spiltMutiString;
24781
 
25015
 
24782
				#回傳結果
25016
				#回傳結果
24783
				return $result;
25017
				return $result;
24784
				
25018
 
24785
				}#if end
25019
				}#if end
24786
			
25020
 
24787
			#針對每行分割出來的內容
25021
			#針對每行分割出來的內容
24788
			for($i=0;$i<$searchOutPut["count"];$i++){
25022
			for($i=0;$i<$searchOutPut["count"];$i++){
24789
			
25023
 
24790
				#如果不存在 IP
25024
				#如果不存在 IP
24791
				if(!isset($spiltMutiString["spiltString"][$i]["dataArray"][3])){
25025
				if(!isset($spiltMutiString["spiltString"][$i]["dataArray"][3])){
24792
				
25026
 
24793
					#跳過
25027
					#跳過
24794
					continue;
25028
					continue;
24795
				
25029
 
24796
					}#if end
25030
					}#if end
24797
			
25031
 
24798
				#取得封鎖的IP位置
25032
				#取得封鎖的IP位置
24799
				$ips_blocked[]=$spiltMutiString["spiltString"][$i]["dataArray"][3];
25033
				$ips_blocked[]=$spiltMutiString["spiltString"][$i]["dataArray"][3];
24800
			
25034
 
24801
				}#for end
25035
				}#for end
24802
		
25036
 
24803
			}#if end
25037
			}#if end
24804
		
25038
 
24805
		#儲存有問題的IP資訊陣列
25039
		#儲存有問題的IP資訊陣列
24806
		#$ips;	
25040
		#$ips;
24807
		
25041
 
24808
		#儲存已封鎖IP的陣列
25042
		#儲存已封鎖IP的陣列
24809
		#$ips_blocked;
25043
		#$ips_blocked;
24810
		
25044
 
24811
		#初始化要封鎖的ip資訊
25045
		#初始化要封鎖的ip資訊
24812
		$ips_to_block=array();
25046
		$ips_to_block=array();
24813
		
25047
 
24814
		#留下未阻擋的有問題IP
25048
		#留下未阻擋的有問題IP
24815
		
25049
 
24816
		#針對每個有問題的ip資訊
25050
		#針對每個有問題的ip資訊
24817
		foreach($ips as $info){
25051
		foreach($ips as $info){
24818
		
25052
 
24819
			#函式說明:
25053
			#函式說明:
24820
			#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
25054
			#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
24821
			#回傳結果:
25055
			#回傳結果:
24822
			#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
25056
			#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
24823
			#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
25057
			#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
Line 24837... Line 25071...
24837
			#無.
25071
			#無.
24838
			#備註:
25072
			#備註:
24839
			#無.
25073
			#無.
24840
			$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
25074
			$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
24841
			unset($conf["search::getEqualVar"]);
25075
			unset($conf["search::getEqualVar"]);
24842
		
25076
 
24843
			#如果執行失敗
25077
			#如果執行失敗
24844
			if($getEqualVar["status"]==="false"){
25078
			if($getEqualVar["status"]==="false"){
24845
			
25079
 
24846
				#設置執行失敗
25080
				#設置執行失敗
24847
				$result["status"]="false";
25081
				$result["status"]="false";
24848
 
25082
 
24849
				#設置錯誤訊息
25083
				#設置錯誤訊息
24850
				$result["error"]=$getEqualVar;
25084
				$result["error"]=$getEqualVar;
24851
 
25085
 
24852
				#回傳結果
25086
				#回傳結果
24853
				return $result;
25087
				return $result;
24854
			
25088
 
24855
				}#if end
25089
				}#if end
24856
				
25090
 
24857
			#如果ip尚未被封鎖
25091
			#如果ip尚未被封鎖
24858
			if($getEqualVar["founded"]==="false"){
25092
			if($getEqualVar["founded"]==="false"){
24859
			
25093
 
24860
				#儲存要封鎖的ip資訊
25094
				#儲存要封鎖的ip資訊
24861
				$ips_to_block[]=$info;
25095
				$ips_to_block[]=$info;
24862
			
25096
 
24863
				}#if end
25097
				}#if end
24864
		
25098
 
24865
			}#foreach end
25099
			}#foreach end
24866
	
25100
 
24867
		#如果沒有未阻擋的有問題 IP
25101
		#如果沒有未阻擋的有問題 IP
24868
		if(count($ips_to_block)===0){
25102
		if(count($ips_to_block)===0){
24869
		
25103
 
24870
			#設置執行成功
25104
			#設置執行成功
24871
			$result["status"]="true";
25105
			$result["status"]="true";
24872
 
25106
 
24873
			#回傳結果
25107
			#回傳結果
24874
			return $result;
25108
			return $result;
24875
		
25109
 
24876
			}#if end
25110
			}#if end
24877
		
25111
 
24878
		#如果要阻擋IP
25112
		#如果要阻擋IP
24879
		if($conf["getIplistOnly"]==="false"){
25113
		if($conf["getIplistOnly"]==="false"){
24880
		
25114
 
24881
			#針對每個有問題的IP資訊
25115
			#針對每個有問題的IP資訊
24882
			foreach($ips_to_block as $info){
25116
			foreach($ips_to_block as $info){
24883
			
25117
 
24884
				#檢查該ip是否在白名單裡面
25118
				#檢查該ip是否在白名單裡面
24885
				#函式說明:
25119
				#函式說明:
24886
				#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
25120
				#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
24887
				#回傳結果:
25121
				#回傳結果:
24888
				#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
25122
				#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
Line 24899... Line 25133...
24899
				#無.
25133
				#無.
24900
				#備註:
25134
				#備註:
24901
				#無.
25135
				#無.
24902
				$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
25136
				$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
24903
				unset($conf["search::getEqualVar"]);
25137
				unset($conf["search::getEqualVar"]);
24904
			
25138
 
24905
				#如果執行失敗
25139
				#如果執行失敗
24906
				if($getEqualVar["status"]==="false"){
25140
				if($getEqualVar["status"]==="false"){
24907
				
25141
 
24908
					#設置執行失敗
25142
					#設置執行失敗
24909
					$result["status"]="false";
25143
					$result["status"]="false";
24910
 
25144
 
24911
					#設置錯誤訊息
25145
					#設置錯誤訊息
24912
					$result["error"]=$getEqualVar;
25146
					$result["error"]=$getEqualVar;
24913
 
25147
 
24914
					#回傳結果
25148
					#回傳結果
24915
					return $result;
25149
					return $result;
24916
				
25150
 
24917
					}#if end
25151
					}#if end
24918
			
25152
 
24919
				#如果在白名單ip裡面
25153
				#如果在白名單ip裡面
24920
				if($getEqualVar["founded"]==="true"){
25154
				if($getEqualVar["founded"]==="true"){
24921
				
25155
 
24922
					#跳過該ip
25156
					#跳過該ip
24923
					continue;
25157
					continue;
24924
				
25158
 
24925
					}#if end
25159
					}#if end
24926
			
25160
 
24927
				#如果不是要動態阻擋
25161
				#如果不是要動態阻擋
24928
				if($conf["dynamic"]==="false"){
25162
				if($conf["dynamic"]==="false"){
24929
				
25163
 
24930
					#函式說明:
25164
					#函式說明:
24931
					#呼叫shell依序執行系統命令,並取得回傳的內容.
25165
					#呼叫shell依序執行系統命令,並取得回傳的內容.
24932
					#回傳的結果:
25166
					#回傳的結果:
24933
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25167
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
24934
					#$result["error"],錯誤訊息陣列.
25168
					#$result["error"],錯誤訊息陣列.
Line 24937... Line 25171...
24937
					#$result["output"],爲執行完每個指令後的輸出陣列.
25171
					#$result["output"],爲執行完每個指令後的輸出陣列.
24938
					#必填參數:
25172
					#必填參數:
24939
					#$conf["command"],字串陣列,要執行的指令.
25173
					#$conf["command"],字串陣列,要執行的指令.
24940
					$conf["external::callShellMulti"]["command"]=array("echo");
25174
					$conf["external::callShellMulti"]["command"]=array("echo");
24941
					#$conf["fileArgu"],字串,變數__FILE__的內容,預設為當前檔案的路徑與名稱.
25175
					#$conf["fileArgu"],字串,變數__FILE__的內容,預設為當前檔案的路徑與名稱.
24942
					$conf["external::callShellMulti"]["fileArgu"]=$conf["fileArgu"];		
25176
					$conf["external::callShellMulti"]["fileArgu"]=$conf["fileArgu"];
24943
					#可省略參數:
25177
					#可省略參數:
24944
					#$conf["argu"],陣字串列,執行各個$conf["command"]時指令搭配的參數,預設為空陣列.
25178
					#$conf["argu"],陣字串列,執行各個$conf["command"]時指令搭配的參數,預設為空陣列.
24945
					$conf["external::callShellMulti"]["argu"]=array(array($info["ip"],"|","block_ip.sh"));
25179
					$conf["external::callShellMulti"]["argu"]=array(array($info["ip"],"|","block_ip.sh"));
24946
					#$conf["enablePrintDescription"],字串陣列,執行各個$conf["command"]時是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25180
					#$conf["enablePrintDescription"],字串陣列,執行各個$conf["command"]時是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
24947
					#$conf["enablePrintDescription"]=array("false");
25181
					#$conf["enablePrintDescription"]=array("false");
24948
					#$conf["printDescription"],字串陣列,執行各個$conf["command"]前要印出來的的文字,預設為$conf["command"]的內容,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25182
					#$conf["printDescription"],字串陣列,執行各個$conf["command"]前要印出來的的文字,預設為$conf["command"]的內容,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
24949
					#$conf["printDescription"]=array("");
25183
					#$conf["printDescription"]=array("");
24950
					#$conf["escapeshellarg"],字串陣列,執行各個$conf["command"]時是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false",其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25184
					#$conf["escapeshellarg"],字串陣列,執行各個$conf["command"]時是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false",其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
24951
					$conf["external::callShellMulti"]["escapeshellarg"]=array("true");
25185
					$conf["external::callShellMulti"]["escapeshellarg"]=array("true");
24952
					
25186
 
24953
					#如果有設置 username
25187
					#如果有設置 username
24954
					if(isset($conf["username"])){
25188
					if(isset($conf["username"])){
24955
						
25189
 
24956
						#$conf["username"],陣列字串,每個指令要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25190
						#$conf["username"],陣列字串,每個指令要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
24957
						$conf["external::callShellMulti"]["username"]=array($conf["username"]);
25191
						$conf["external::callShellMulti"]["username"]=array($conf["username"]);
24958
					
25192
 
24959
						}#if end
25193
						}#if end
24960
					
25194
 
24961
					#如果有設置 password
25195
					#如果有設置 password
24962
					if(isset($conf["password"])){
25196
					if(isset($conf["password"])){
24963
					
25197
 
24964
						#$conf["password"],陣列字串,每個指令與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25198
						#$conf["password"],陣列字串,每個指令與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
24965
						$conf["external::callShellMulti"]["password"]=array($conf["password"]);
25199
						$conf["external::callShellMulti"]["password"]=array($conf["password"]);
24966
					
25200
 
24967
						}#if end
25201
						}#if end
24968
 
25202
 
24969
					#$conf["useScript"],字串,每個指令的執行是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
25203
					#$conf["useScript"],字串,每個指令的執行是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
24970
					#$conf["useScript"]="";
25204
					#$conf["useScript"]="";
24971
					#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
25205
					#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
Line 24975... Line 25209...
24975
					#備註:
25209
					#備註:
24976
					#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
25210
					#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
24977
					#參考資料:
25211
					#參考資料:
24978
					#exec=>http://php.net/manual/en/function.exec.php
25212
					#exec=>http://php.net/manual/en/function.exec.php
24979
					#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25213
					#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
24980
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php	
25214
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
24981
					$callShellMulti=external::callShellMulti($conf["external::callShellMulti"]);
25215
					$callShellMulti=external::callShellMulti($conf["external::callShellMulti"]);
24982
					unset($conf["external::callShellMulti"]);
25216
					unset($conf["external::callShellMulti"]);
24983
				
25217
 
24984
					#如果執行失敗
25218
					#如果執行失敗
24985
					if($callShellMulti["status"]==="false"){
25219
					if($callShellMulti["status"]==="false"){
24986
					
25220
 
24987
						#設置執行失敗
25221
						#設置執行失敗
24988
						$result["status"]="false";
25222
						$result["status"]="false";
24989
 
25223
 
24990
						#設置錯誤訊息
25224
						#設置錯誤訊息
24991
						$result["error"]=$callShellMulti;
25225
						$result["error"]=$callShellMulti;
24992
 
25226
 
24993
						#回傳結果
25227
						#回傳結果
24994
						return $result;
25228
						return $result;
24995
					
25229
 
24996
						}#if end
25230
						}#if end
24997
				
25231
 
24998
					}#if end
25232
					}#if end
24999
			
25233
 
25000
				#反之是要動態阻擋
25234
				#反之是要動態阻擋
25001
				else{
25235
				else{
25002
				
25236
 
25003
					#函式說明:
25237
					#函式說明:
25004
					#呼叫shell依序執行系統命令,並取得回傳的內容.
25238
					#呼叫shell依序執行系統命令,並取得回傳的內容.
25005
					#回傳的結果:
25239
					#回傳的結果:
25006
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25240
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25007
					#$result["error"],錯誤訊息陣列.
25241
					#$result["error"],錯誤訊息陣列.
Line 25010... Line 25244...
25010
					#$result["output"],爲執行完每個指令後的輸出陣列.
25244
					#$result["output"],爲執行完每個指令後的輸出陣列.
25011
					#必填參數:
25245
					#必填參數:
25012
					#$conf["command"],字串陣列,要執行的指令.
25246
					#$conf["command"],字串陣列,要執行的指令.
25013
					$conf["external::callShellMulti"]["command"]=array("echo");
25247
					$conf["external::callShellMulti"]["command"]=array("echo");
25014
					#$conf["fileArgu"],字串,變數__FILE__的內容,預設為當前檔案的路徑與名稱.
25248
					#$conf["fileArgu"],字串,變數__FILE__的內容,預設為當前檔案的路徑與名稱.
25015
					$conf["external::callShellMulti"]["fileArgu"]=$conf["fileArgu"];		
25249
					$conf["external::callShellMulti"]["fileArgu"]=$conf["fileArgu"];
25016
					#可省略參數:
25250
					#可省略參數:
25017
					#$conf["argu"],陣字串列,執行各個$conf["command"]時指令搭配的參數,預設為空陣列.
25251
					#$conf["argu"],陣字串列,執行各個$conf["command"]時指令搭配的參數,預設為空陣列.
25018
					$conf["external::callShellMulti"]["argu"]=array(array($info["ip"],"|","block_ip_tmp.sh"));
25252
					$conf["external::callShellMulti"]["argu"]=array(array($info["ip"],"|","block_ip_tmp.sh"));
25019
					#$conf["enablePrintDescription"],字串陣列,執行各個$conf["command"]時是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25253
					#$conf["enablePrintDescription"],字串陣列,執行各個$conf["command"]時是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25020
					#$conf["enablePrintDescription"]=array("false");
25254
					#$conf["enablePrintDescription"]=array("false");
25021
					#$conf["printDescription"],字串陣列,執行各個$conf["command"]前要印出來的的文字,預設為$conf["command"]的內容,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25255
					#$conf["printDescription"],字串陣列,執行各個$conf["command"]前要印出來的的文字,預設為$conf["command"]的內容,其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25022
					#$conf["printDescription"]=array("");
25256
					#$conf["printDescription"]=array("");
25023
					#$conf["escapeshellarg"],字串陣列,執行各個$conf["command"]時是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false",其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25257
					#$conf["escapeshellarg"],字串陣列,執行各個$conf["command"]時是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false",其數量須與$conf["command"]的元素數量相同,若只有一個元素,則代表是每個$conf["command"]執行時都用此參數.
25024
					$conf["external::callShellMulti"]["escapeshellarg"]=array("true");
25258
					$conf["external::callShellMulti"]["escapeshellarg"]=array("true");
25025
					
25259
 
25026
					#如果有設置 username
25260
					#如果有設置 username
25027
					if(isset($conf["username"])){
25261
					if(isset($conf["username"])){
25028
						
25262
 
25029
						#$conf["username"],陣列字串,每個指令要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25263
						#$conf["username"],陣列字串,每個指令要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25030
						$conf["external::callShellMulti"]["username"]=array($conf["username"]);
25264
						$conf["external::callShellMulti"]["username"]=array($conf["username"]);
25031
					
25265
 
25032
						}#if end
25266
						}#if end
25033
					
25267
 
25034
					#如果有設置 password
25268
					#如果有設置 password
25035
					if(isset($conf["password"])){
25269
					if(isset($conf["password"])){
25036
					
25270
 
25037
						#$conf["password"],陣列字串,每個指令與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25271
						#$conf["password"],陣列字串,每個指令與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25038
						$conf["external::callShellMulti"]["password"]=array($conf["password"]);
25272
						$conf["external::callShellMulti"]["password"]=array($conf["password"]);
25039
					
25273
 
25040
						}#if end
25274
						}#if end
25041
 
25275
 
25042
					#$conf["useScript"],字串,每個指令的執行是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
25276
					#$conf["useScript"],字串,每個指令的執行是否要啟用Linux的script指令來記錄輸出,"true"代表要;"false"代表不要,預設為"false".
25043
					#$conf["useScript"]="";
25277
					#$conf["useScript"]="";
25044
					#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
25278
					#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 ".qbpwcf_tmp/external/callShell/".
Line 25048... Line 25282...
25048
					#備註:
25282
					#備註:
25049
					#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
25283
					#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
25050
					#參考資料:
25284
					#參考資料:
25051
					#exec=>http://php.net/manual/en/function.exec.php
25285
					#exec=>http://php.net/manual/en/function.exec.php
25052
					#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25286
					#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25053
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php	
25287
					#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
25054
					$callShellMulti=external::callShellMulti($conf["external::callShellMulti"]);
25288
					$callShellMulti=external::callShellMulti($conf["external::callShellMulti"]);
25055
					unset($conf["external::callShellMulti"]);
25289
					unset($conf["external::callShellMulti"]);
25056
				
25290
 
25057
					}#else end
25291
					}#else end
25058
			
25292
 
25059
				#如果執行失敗
25293
				#如果執行失敗
25060
				if($callShellMulti["status"]==="false"){
25294
				if($callShellMulti["status"]==="false"){
25061
				
25295
 
25062
					#設置執行失敗
25296
					#設置執行失敗
25063
					$result["status"]="false";
25297
					$result["status"]="false";
25064
 
25298
 
25065
					#設置錯誤訊息
25299
					#設置錯誤訊息
25066
					$result["error"]=$callShellMulti;
25300
					$result["error"]=$callShellMulti;
25067
 
25301
 
25068
					#回傳結果
25302
					#回傳結果
25069
					return $result;
25303
					return $result;
25070
				
25304
 
25071
					}#if end
25305
					}#if end
25072
					
25306
 
25073
				#取得每次執行的結果
25307
				#取得每次執行的結果
25074
				$result["content"][]=$callShellMulti;
25308
				$result["content"][]=$callShellMulti;
25075
				
25309
 
25076
				#儲存特定ip被阻擋的資訊
25310
				#儲存特定ip被阻擋的資訊
25077
				$result["reason"][$info["ip"]]=$info;
25311
				$result["reason"][$info["ip"]]=$info;
25078
			
25312
 
25079
				}#foreach end
25313
				}#foreach end
25080
				
25314
 
25081
			}#if end
25315
			}#if end
25082
			
25316
 
25083
		#反之
25317
		#反之
25084
		else{
25318
		else{
25085
		
25319
 
25086
			#取得有問題的IP資訊清單
25320
			#取得有問題的IP資訊清單
25087
			$result["content"]=$ips_to_block;
25321
			$result["content"]=$ips_to_block;
25088
			
25322
 
25089
			}#else end
25323
			}#else end
25090
			
25324
 
25091
		#設置執行正常
25325
		#設置執行正常
25092
		$result["status"]="true";
25326
		$result["status"]="true";
25093
 
25327
 
25094
		#回傳結果
25328
		#回傳結果
25095
		return $result;
25329
		return $result;
25096
	
25330
 
25097
		}#function blockAcctackIp end
25331
		}#function blockAcctackIp end
25098
		
25332
 
25099
	/*
25333
	/*
25100
	#函式說明:
25334
	#函式說明:
25101
	#執行 systemd 程序來管理服務.
25335
	#執行 systemd 程序來管理服務.
25102
	#回傳結果:
25336
	#回傳結果:
25103
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25337
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25104
	#$result["error"],錯誤訊息.
25338
	#$result["error"],錯誤訊息.
25105
	#$result["function"],當前執行的函式名稱.
25339
	#$result["function"],當前執行的函式名稱.
25106
	#$result["argu"],所使用的參數.
25340
	#$result["argu"],所使用的參數.
25107
	#$result["content"],執行的結果.
25341
	#$result["content"],執行的結果.
25108
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
25342
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
25109
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
25343
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
25110
	#必填參數:
25344
	#必填參數:
25111
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
25345
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
25112
	$conf["fileArgu"]=__FILE__;
25346
	$conf["fileArgu"]=__FILE__;
25113
	#$conf["name"],字串,服務名稱.
25347
	#$conf["name"],字串,服務名稱.
25114
	$conf["name"]="";
25348
	$conf["name"]="";
Line 25125... Line 25359...
25125
	#無.
25359
	#無.
25126
	#備註:
25360
	#備註:
25127
	#無.
25361
	#無.
25128
	*/
25362
	*/
25129
	public static function systemd(&$conf){
25363
	public static function systemd(&$conf){
25130
	
25364
 
25131
		#初始化要回傳的結果
25365
		#初始化要回傳的結果
25132
		$result=array();
25366
		$result=array();
25133
 
25367
 
25134
		#取得當前執行的函式名稱
25368
		#取得當前執行的函式名稱
25135
		$result["function"]=__FUNCTION__;
25369
		$result["function"]=__FUNCTION__;
Line 25233... Line 25467...
25233
 
25467
 
25234
			#回傳結果
25468
			#回傳結果
25235
			return $result;
25469
			return $result;
25236
 
25470
 
25237
			}#if end
25471
			}#if end
25238
		
25472
 
25239
		#如果要 reload daemon
25473
		#如果要 reload daemon
25240
		if($conf["daemonReload"]==="true"){
25474
		if($conf["daemonReload"]==="true"){
25241
		
25475
 
25242
			#函式說明:
25476
			#函式說明:
25243
			#呼叫shell執行系統命令,並取得回傳的內容.
25477
			#呼叫shell執行系統命令,並取得回傳的內容.
25244
			#回傳的結果:
25478
			#回傳的結果:
25245
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25479
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25246
			#$result["error"],錯誤訊息陣列.
25480
			#$result["error"],錯誤訊息陣列.
Line 25255... Line 25489...
25255
			#$result["statusCode"],執行結束後的代碼.
25489
			#$result["statusCode"],執行結束後的代碼.
25256
			#必填參數:
25490
			#必填參數:
25257
			#$conf["command"],字串,要執行的指令與.
25491
			#$conf["command"],字串,要執行的指令與.
25258
			$conf["external::callShell"]["command"]="systemctl";
25492
			$conf["external::callShell"]["command"]="systemctl";
25259
			#$conf["fileArgu"],字串,變數__FILE__的內容.
25493
			#$conf["fileArgu"],字串,變數__FILE__的內容.
25260
			$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
25494
			$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
25261
			#可省略參數:
25495
			#可省略參數:
25262
			#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
25496
			#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
25263
			$conf["external::callShell"]["argu"]=array("daemon-reload");
25497
			$conf["external::callShell"]["argu"]=array("daemon-reload");
25264
			#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
25498
			#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
25265
			#$conf["arguIsAddr"]=array();	
25499
			#$conf["arguIsAddr"]=array();
25266
			#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
25500
			#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
25267
			#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
25501
			#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
25268
			#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
25502
			#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
25269
			#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
25503
			#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
25270
			#$conf["enablePrintDescription"]="true";
25504
			#$conf["enablePrintDescription"]="true";
25271
			#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
25505
			#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
25272
			#$conf["printDescription"]="";
25506
			#$conf["printDescription"]="";
25273
			#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
25507
			#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
25274
			$conf["external::callShell"]["escapeshellarg"]="true";
25508
			$conf["external::callShell"]["escapeshellarg"]="true";
25275
			
25509
 
25276
			#如果有設置 $conf["username"]
25510
			#如果有設置 $conf["username"]
25277
			if(isset($conf["username"])){
25511
			if(isset($conf["username"])){
25278
				
25512
 
25279
				#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25513
				#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25280
				$conf["external::callShell"]["username"]=$conf["username"];
25514
				$conf["external::callShell"]["username"]=$conf["username"];
25281
 
25515
 
25282
				}#if end		
25516
				}#if end
25283
			
25517
 
25284
			#如果有設置 $conf["password"]
25518
			#如果有設置 $conf["password"]
25285
			if(isset($conf["password"])){
25519
			if(isset($conf["password"])){
25286
			
25520
 
25287
				#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25521
				#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25288
				$conf["external::callShell"]["password"]=$conf["password"];
25522
				$conf["external::callShell"]["password"]=$conf["password"];
25289
			
25523
 
25290
				}#if end
25524
				}#if end
25291
				
25525
 
25292
			#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
25526
			#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
25293
			#$conf["useScript"]="";
25527
			#$conf["useScript"]="";
25294
			#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
25528
			#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
25295
			#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
25529
			#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
25296
			#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
25530
			#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
Line 25301... Line 25535...
25301
			#exec=>http://php.net/manual/en/function.exec.php
25535
			#exec=>http://php.net/manual/en/function.exec.php
25302
			#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25536
			#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25303
			#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
25537
			#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
25304
			$callShell=external::callShell($conf["external::callShell"]);
25538
			$callShell=external::callShell($conf["external::callShell"]);
25305
			unset($conf["external::callShell"]);
25539
			unset($conf["external::callShell"]);
25306
	
25540
 
25307
			#如果運行失敗
25541
			#如果運行失敗
25308
			if($callShell["status"]==="false"){
25542
			if($callShell["status"]==="false"){
25309
			
25543
 
25310
				#設置執行失敗
25544
				#設置執行失敗
25311
				$result["status"]="false";
25545
				$result["status"]="false";
25312
 
25546
 
25313
				#設置錯誤訊息
25547
				#設置錯誤訊息
25314
				$result["error"]=$callShell;
25548
				$result["error"]=$callShell;
25315
 
25549
 
25316
				#回傳結果
25550
				#回傳結果
25317
				return $result;
25551
				return $result;
25318
				
25552
 
25319
							
25553
 
25320
				}#if end
25554
				}#if end
25321
				
25555
 
25322
			#取得運行結果
25556
			#取得運行結果
25323
			$result["content"]=$callShell["output"];
25557
			$result["content"]=$callShell["output"];
25324
			
25558
 
25325
			#設置執行成功
25559
			#設置執行成功
25326
			$result["status"]="true";
25560
			$result["status"]="true";
25327
			
25561
 
25328
			#回傳結果
25562
			#回傳結果
25329
			return $result;
25563
			return $result;
25330
		
25564
 
25331
			}#if end
25565
			}#if end
25332
		
25566
 
25333
		#判斷 $conf["operation"]
25567
		#判斷 $conf["operation"]
25334
		switch($conf["operation"]){
25568
		switch($conf["operation"]){
25335
		
25569
 
25336
			#如果是 list
25570
			#如果是 list
25337
			case "list":
25571
			case "list":
25338
		
25572
 
25339
				#函式說明:
25573
				#函式說明:
25340
				#呼叫shell執行系統命令,並取得回傳的內容.
25574
				#呼叫shell執行系統命令,並取得回傳的內容.
25341
				#回傳的結果:
25575
				#回傳的結果:
25342
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25576
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25343
				#$result["error"],錯誤訊息陣列.
25577
				#$result["error"],錯誤訊息陣列.
Line 25352... Line 25586...
25352
				#$result["statusCode"],執行結束後的代碼.
25586
				#$result["statusCode"],執行結束後的代碼.
25353
				#必填參數:
25587
				#必填參數:
25354
				#$conf["command"],字串,要執行的指令與.
25588
				#$conf["command"],字串,要執行的指令與.
25355
				$conf["external::callShell"]["command"]="systemctl";
25589
				$conf["external::callShell"]["command"]="systemctl";
25356
				#$conf["fileArgu"],字串,變數__FILE__的內容.
25590
				#$conf["fileArgu"],字串,變數__FILE__的內容.
25357
				$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
25591
				$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
25358
				#可省略參數:
25592
				#可省略參數:
25359
				#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
25593
				#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
25360
				#$conf["external::callShell"]["argu"]=array("2>&1");
25594
				#$conf["external::callShell"]["argu"]=array("2>&1");
25361
				#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
25595
				#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
25362
				#$conf["arguIsAddr"]=array();	
25596
				#$conf["arguIsAddr"]=array();
25363
				#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
25597
				#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
25364
				#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
25598
				#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
25365
				#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
25599
				#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
25366
				#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
25600
				#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
25367
				#$conf["enablePrintDescription"]="true";
25601
				#$conf["enablePrintDescription"]="true";
25368
				#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
25602
				#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
25369
				#$conf["printDescription"]="";
25603
				#$conf["printDescription"]="";
25370
				#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
25604
				#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
25371
				$conf["external::callShell"]["escapeshellarg"]="true";
25605
				$conf["external::callShell"]["escapeshellarg"]="true";
25372
				
25606
 
25373
				#如果有設置 $conf["username"]
25607
				#如果有設置 $conf["username"]
25374
				if(isset($conf["username"])){
25608
				if(isset($conf["username"])){
25375
					
25609
 
25376
					#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25610
					#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25377
					$conf["external::callShell"]["username"]=$conf["username"];
25611
					$conf["external::callShell"]["username"]=$conf["username"];
25378
 
25612
 
25379
					}#if end		
25613
					}#if end
25380
				
25614
 
25381
				#如果有設置 $conf["password"]
25615
				#如果有設置 $conf["password"]
25382
				if(isset($conf["password"])){
25616
				if(isset($conf["password"])){
25383
				
25617
 
25384
					#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25618
					#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25385
					$conf["external::callShell"]["password"]=$conf["password"];
25619
					$conf["external::callShell"]["password"]=$conf["password"];
25386
				
25620
 
25387
					}#if end
25621
					}#if end
25388
					
25622
 
25389
				#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
25623
				#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
25390
				#$conf["useScript"]="";
25624
				#$conf["useScript"]="";
25391
				#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
25625
				#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
25392
				#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
25626
				#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
25393
				#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
25627
				#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
Line 25400... Line 25634...
25400
				#exec=>http://php.net/manual/en/function.exec.php
25634
				#exec=>http://php.net/manual/en/function.exec.php
25401
				#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25635
				#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25402
				#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
25636
				#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
25403
				$callShell=external::callShell($conf["external::callShell"]);
25637
				$callShell=external::callShell($conf["external::callShell"]);
25404
				unset($conf["external::callShell"]);
25638
				unset($conf["external::callShell"]);
25405
		
25639
 
25406
				#如果運行失敗
25640
				#如果運行失敗
25407
				if($callShell["status"]==="false"){
25641
				if($callShell["status"]==="false"){
25408
				
25642
 
25409
					#設置執行失敗
25643
					#設置執行失敗
25410
					$result["status"]="false";
25644
					$result["status"]="false";
25411
 
25645
 
25412
					#設置錯誤訊息
25646
					#設置錯誤訊息
25413
					$result["error"]=$callShell;
25647
					$result["error"]=$callShell;
25414
 
25648
 
25415
					#回傳結果
25649
					#回傳結果
25416
					return $result;
25650
					return $result;
25417
					
25651
 
25418
								
25652
 
25419
					}#if end
25653
					}#if end
25420
					
25654
 
25421
				#取得運行結果
25655
				#取得運行結果
25422
				$result["content"]=$callShell["output"];
25656
				$result["content"]=$callShell["output"];
25423
				
25657
 
25424
				#設置執行成功
25658
				#設置執行成功
25425
				$result["status"]="true";
25659
				$result["status"]="true";
25426
				
25660
 
25427
				#回傳結果
25661
				#回傳結果
25428
				return $result;
25662
				return $result;
25429
		
25663
 
25430
				#跳出 switch
25664
				#跳出 switch
25431
				break;
25665
				break;
25432
				
25666
 
25433
			#其他操作
25667
			#其他操作
25434
			case "enable":
25668
			case "enable":
25435
			case "disable":
25669
			case "disable":
25436
			case "start":
25670
			case "start":
25437
			case "stop":
25671
			case "stop":
25438
			case "restart":
25672
			case "restart":
25439
			case "status":
25673
			case "status":
25440
			
25674
 
25441
				#函式說明:
25675
				#函式說明:
25442
				#呼叫shell執行系統命令,並取得回傳的內容.
25676
				#呼叫shell執行系統命令,並取得回傳的內容.
25443
				#回傳的結果:
25677
				#回傳的結果:
25444
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25678
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25445
				#$result["error"],錯誤訊息陣列.
25679
				#$result["error"],錯誤訊息陣列.
Line 25454... Line 25688...
25454
				#$result["statusCode"],執行結束後的代碼.
25688
				#$result["statusCode"],執行結束後的代碼.
25455
				#必填參數:
25689
				#必填參數:
25456
				#$conf["command"],字串,要執行的指令與.
25690
				#$conf["command"],字串,要執行的指令與.
25457
				$conf["external::callShell"]["command"]="systemctl";
25691
				$conf["external::callShell"]["command"]="systemctl";
25458
				#$conf["fileArgu"],字串,變數__FILE__的內容.
25692
				#$conf["fileArgu"],字串,變數__FILE__的內容.
25459
				$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
25693
				$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
25460
				#可省略參數:
25694
				#可省略參數:
25461
				#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
25695
				#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
25462
				$conf["external::callShell"]["argu"]=array($conf["operation"],$conf["name"]);
25696
				$conf["external::callShell"]["argu"]=array($conf["operation"],$conf["name"]);
25463
				#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
25697
				#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
25464
				#$conf["arguIsAddr"]=array();	
25698
				#$conf["arguIsAddr"]=array();
25465
				#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
25699
				#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
25466
				#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
25700
				#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
25467
				#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
25701
				#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
25468
				#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
25702
				#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
25469
				#$conf["enablePrintDescription"]="true";
25703
				#$conf["enablePrintDescription"]="true";
25470
				#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
25704
				#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
25471
				#$conf["printDescription"]="";
25705
				#$conf["printDescription"]="";
25472
				#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
25706
				#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
25473
				$conf["external::callShell"]["escapeshellarg"]="true";
25707
				$conf["external::callShell"]["escapeshellarg"]="true";
25474
				
25708
 
25475
				#如果有設置 $conf["username"]
25709
				#如果有設置 $conf["username"]
25476
				if(isset($conf["username"])){
25710
				if(isset($conf["username"])){
25477
					
25711
 
25478
					#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25712
					#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
25479
					$conf["external::callShell"]["username"]=$conf["username"];
25713
					$conf["external::callShell"]["username"]=$conf["username"];
25480
 
25714
 
25481
					}#if end
25715
					}#if end
25482
				
25716
 
25483
				#如果有設置 $conf["password"]
25717
				#如果有設置 $conf["password"]
25484
				if(isset($conf["password"])){
25718
				if(isset($conf["password"])){
25485
				
25719
 
25486
					#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25720
					#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
25487
					$conf["external::callShell"]["password"]=$conf["password"];
25721
					$conf["external::callShell"]["password"]=$conf["password"];
25488
				
25722
 
25489
					}#if end
25723
					}#if end
25490
					
25724
 
25491
				#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
25725
				#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
25492
				#$conf["useScript"]="";
25726
				#$conf["useScript"]="";
25493
				#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
25727
				#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
25494
				#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
25728
				#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
25495
				#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
25729
				#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
Line 25502... Line 25736...
25502
				#exec=>http://php.net/manual/en/function.exec.php
25736
				#exec=>http://php.net/manual/en/function.exec.php
25503
				#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25737
				#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
25504
				#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
25738
				#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
25505
				$callShell=external::callShell($conf["external::callShell"]);
25739
				$callShell=external::callShell($conf["external::callShell"]);
25506
				unset($conf["external::callShell"]);
25740
				unset($conf["external::callShell"]);
25507
		
25741
 
25508
				#如果運行失敗
25742
				#如果運行失敗
25509
				if($callShell["status"]==="false"){
25743
				if($callShell["status"]==="false"){
25510
				
25744
 
25511
					if($callShell["statusCode"]!==1 && $callShell["statusCode"]!==3){
25745
					if($callShell["statusCode"]!==1 && $callShell["statusCode"]!==3){
25512
				
25746
 
25513
						#設置執行失敗
25747
						#設置執行失敗
25514
						$result["status"]="false";
25748
						$result["status"]="false";
25515
 
25749
 
25516
						#設置錯誤訊息
25750
						#設置錯誤訊息
25517
						$result["error"]=$callShell;
25751
						$result["error"]=$callShell;
25518
 
25752
 
25519
						#回傳結果
25753
						#回傳結果
25520
						return $result;
25754
						return $result;
25521
						
25755
 
25522
						}#if end
25756
						}#if end
25523
				
25757
 
25524
					}#if end
25758
					}#if end
25525
					
25759
 
25526
				#取得運行結果
25760
				#取得運行結果
25527
				$result["content"]=$callShell["output"];
25761
				$result["content"]=$callShell["output"];
25528
				
25762
 
25529
				#如果運作參數是 "status" 
25763
				#如果運作參數是 "status"
25530
				if($conf["operation"]==="status"){
25764
				if($conf["operation"]==="status"){
25531
				
25765
 
25532
					#"Active: inactive (dead)"
25766
					#"Active: inactive (dead)"
25533
					#"Active: active (running)"
25767
					#"Active: active (running)"
25534
					#"Active: failed"
25768
					#"Active: failed"
25535
					#"service; enabled; "
25769
					#"service; enabled; "
25536
					#"service; disabled; "
25770
					#"service; disabled; "
Line 25549... Line 25783...
25549
					$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$result["content"];#要被搜尋的字串內容陣列
25783
					$conf["search::findManyKeyWordsFromManyString"]["stringArray"]=$result["content"];#要被搜尋的字串內容陣列
25550
					#可省略參數:
25784
					#可省略參數:
25551
					#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
25785
					#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為"false"不需要完全符合.
25552
					$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
25786
					$findManyKeyWordsFromManyString=search::findManyKeyWordsFromManyString($conf["search::findManyKeyWordsFromManyString"]);
25553
					unset($conf["search::findManyKeyWordsFromManyString"]);
25787
					unset($conf["search::findManyKeyWordsFromManyString"]);
25554
					
25788
 
25555
					#如果執行失敗
25789
					#如果執行失敗
25556
					if($findManyKeyWordsFromManyString["status"]==="false"){
25790
					if($findManyKeyWordsFromManyString["status"]==="false"){
25557
				
25791
 
25558
						#設置執行失敗
25792
						#設置執行失敗
25559
						$result["status"]="false";
25793
						$result["status"]="false";
25560
 
25794
 
25561
						#設置錯誤訊息
25795
						#設置錯誤訊息
25562
						$result["error"]=$findManyKeyWordsFromManyString;
25796
						$result["error"]=$findManyKeyWordsFromManyString;
25563
 
25797
 
25564
						#回傳結果
25798
						#回傳結果
25565
						return $result;
25799
						return $result;
25566
					
25800
 
25567
						}#if end
25801
						}#if end
25568
					
25802
 
25569
					#服務狀態的計數
25803
					#服務狀態的計數
25570
					$serverStaCount=count($findManyKeyWordsFromManyString["foundedTrueKey"]);
25804
					$serverStaCount=count($findManyKeyWordsFromManyString["foundedTrueKey"]);
25571
					
25805
 
25572
					#如果沒有剛好取得服務的兩個狀態
25806
					#如果沒有剛好取得服務的兩個狀態
25573
					if($serverStaCount!==2){
25807
					if($serverStaCount!==2){
25574
					
25808
 
25575
						#設置執行失敗
25809
						#設置執行失敗
25576
						$result["status"]="false";
25810
						$result["status"]="false";
25577
 
25811
 
25578
						#提示錯誤
25812
						#提示錯誤
25579
						$result["error"][]="取得啟動狀態與啟用狀態失敗";
25813
						$result["error"][]="取得啟動狀態與啟用狀態失敗";
Line 25581... Line 25815...
25581
						#設置錯誤訊息
25815
						#設置錯誤訊息
25582
						$result["error"][]=$findManyKeyWordsFromManyString;
25816
						$result["error"][]=$findManyKeyWordsFromManyString;
25583
 
25817
 
25584
						#回傳結果
25818
						#回傳結果
25585
						return $result;
25819
						return $result;
25586
					
25820
 
25587
						}#if end
25821
						}#if end
25588
					
25822
 
25589
					#針對每個服務狀態
25823
					#針對每個服務狀態
25590
					foreach($findManyKeyWordsFromManyString["foundedKeyWords"] as $statusDesc){
25824
					foreach($findManyKeyWordsFromManyString["foundedKeyWords"] as $statusDesc){
25591
						
25825
 
25592
						#判斷服務狀態
25826
						#判斷服務狀態
25593
						switch($statusDesc){
25827
						switch($statusDesc){
25594
						
25828
 
25595
							#未啟動
25829
							#未啟動
25596
							case "Active: inactive (dead)":
25830
							case "Active: inactive (dead)":
25597
							case "Active: failed":
25831
							case "Active: failed":
25598
							case "Active: deactivating":
25832
							case "Active: deactivating":
25599
							
25833
 
25600
								#設置未啟動的識別
25834
								#設置未啟動的識別
25601
								$result["content"]["srerviceInfo"]["on"]="false";
25835
								$result["content"]["srerviceInfo"]["on"]="false";
25602
							
25836
 
25603
								#跳出 switch
25837
								#跳出 switch
25604
								break;
25838
								break;
25605
								
25839
 
25606
							#啟動
25840
							#啟動
25607
							case "Active: active (running)":
25841
							case "Active: active (running)":
25608
				
25842
 
25609
								#設置啟動的識別
25843
								#設置啟動的識別
25610
								$result["content"]["srerviceInfo"]["on"]="true";
25844
								$result["content"]["srerviceInfo"]["on"]="true";
25611
									
25845
 
25612
								#跳出 switch
25846
								#跳出 switch
25613
								break;
25847
								break;
25614
							
25848
 
25615
							#啟用,開機自動啟動
25849
							#啟用,開機自動啟動
25616
							case "service; enabled;":
25850
							case "service; enabled;":
25617
							
25851
 
25618
								#設置啟動的識別
25852
								#設置啟動的識別
25619
								$result["content"]["srerviceInfo"]["auto"]="true";
25853
								$result["content"]["srerviceInfo"]["auto"]="true";
25620
							
25854
 
25621
								#跳出 switch
25855
								#跳出 switch
25622
								break;
25856
								break;
25623
								
25857
 
25624
							#未啟用,開機不啟動
25858
							#未啟用,開機不啟動
25625
							case "service; disabled;":
25859
							case "service; disabled;":
25626
							
25860
 
25627
								#設置啟動的識別
25861
								#設置啟動的識別
25628
								$result["content"]["srerviceInfo"]["auto"]="false";
25862
								$result["content"]["srerviceInfo"]["auto"]="false";
25629
								
25863
 
25630
								#跳出 switch
25864
								#跳出 switch
25631
								break;
25865
								break;
25632
								
25866
 
25633
							#無法判斷的服務狀態
25867
							#無法判斷的服務狀態
25634
							default:
25868
							default:
25635
							
25869
 
25636
								#設置執行失敗
25870
								#設置執行失敗
25637
								$result["status"]="false";
25871
								$result["status"]="false";
25638
 
25872
 
25639
								#提示錯誤
25873
								#提示錯誤
25640
								$result["error"][]="無法識別的內容「".$statusDesc."」";
25874
								$result["error"][]="無法識別的內容「".$statusDesc."」";
Line 25642... Line 25876...
25642
								#設置錯誤訊息
25876
								#設置錯誤訊息
25643
								$result["error"][]=$findManyKeyWordsFromManyString;
25877
								$result["error"][]=$findManyKeyWordsFromManyString;
25644
 
25878
 
25645
								#回傳結果
25879
								#回傳結果
25646
								return $result;
25880
								return $result;
25647
						
25881
 
25648
							}#switch end
25882
							}#switch end
25649
					
25883
 
25650
						}#for end
25884
						}#for end
25651
							
25885
 
25652
					}#if end
25886
					}#if end
25653
							
25887
 
25654
				#設置執行成功
25888
				#設置執行成功
25655
				$result["status"]="true";
25889
				$result["status"]="true";
25656
				
25890
 
25657
				#回傳結果
25891
				#回傳結果
25658
				return $result;
25892
				return $result;
25659
			
25893
 
25660
				#跳出 switch
25894
				#跳出 switch
25661
				break;
25895
				break;
25662
			
25896
 
25663
			#不允許的操作
25897
			#不允許的操作
25664
			default :
25898
			default :
25665
			
25899
 
25666
				#設置執行失敗識別
25900
				#設置執行失敗識別
25667
				$result["status"]="false";
25901
				$result["status"]="false";
25668
				
25902
 
25669
				#設置錯誤訊息
25903
				#設置錯誤訊息
25670
				$result["error"][]="operatio \"".$conf["operation"]."\" is not allowed.";
25904
				$result["error"][]="operatio \"".$conf["operation"]."\" is not allowed.";
25671
		
25905
 
25672
				#回傳結果
25906
				#回傳結果
25673
				return $result;
25907
				return $result;
25674
			
25908
 
25675
			}#switch end
25909
			}#switch end
25676
	
25910
 
25677
		}#function systemd end
25911
		}#function systemd end
25678
	
25912
 
25679
	/*
25913
	/*
25680
	#函式說明:
25914
	#函式說明:
25681
	#執行 systemd 程序來確保服務是運行中.
25915
	#執行 systemd 程序來確保服務是運行中.
25682
	#回傳結果:
25916
	#回傳結果:
25683
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25917
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 25709... Line 25943...
25709
	#無.
25943
	#無.
25710
	#備註:
25944
	#備註:
25711
	#無.
25945
	#無.
25712
	*/
25946
	*/
25713
	public static function keepServiceUp(&$conf){
25947
	public static function keepServiceUp(&$conf){
25714
	
25948
 
25715
		#初始化要回傳的結果
25949
		#初始化要回傳的結果
25716
		$result=array();
25950
		$result=array();
25717
 
25951
 
25718
		#取得當前執行的函式名稱
25952
		#取得當前執行的函式名稱
25719
		$result["function"]=__FUNCTION__;
25953
		$result["function"]=__FUNCTION__;
Line 25817... Line 26051...
25817
 
26051
 
25818
			#回傳結果
26052
			#回傳結果
25819
			return $result;
26053
			return $result;
25820
 
26054
 
25821
			}#if end
26055
			}#if end
25822
			
26056
 
25823
		#無窮迴圈
26057
		#無窮迴圈
25824
		while(true){
26058
		while(true){
25825
			
26059
 
25826
			#如果有啟用 verbose
26060
			#如果有啟用 verbose
25827
			if($conf["verbose"]==="true"){
26061
			if($conf["verbose"]==="true"){
25828
			
26062
 
25829
				#提示正在檢查
26063
				#提示正在檢查
25830
				echo "start checking...".PHP_EOL;
26064
				echo "start checking...".PHP_EOL;
25831
			
26065
 
25832
				}#if end
26066
				}#if end
25833
			
26067
 
25834
			#查詢服務啟動沒
26068
			#查詢服務啟動沒
25835
			#函式說明:
26069
			#函式說明:
25836
			#執行 systemd 程序來管理服務.
26070
			#執行 systemd 程序來管理服務.
25837
			#回傳結果:
26071
			#回傳結果:
25838
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26072
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25839
			#$result["error"],錯誤訊息.
26073
			#$result["error"],錯誤訊息.
25840
			#$result["function"],當前執行的函式名稱.
26074
			#$result["function"],當前執行的函式名稱.
25841
			#$result["argu"],所使用的參數.
26075
			#$result["argu"],所使用的參數.
25842
			#$result["content"],執行的結果.
26076
			#$result["content"],執行的結果.
25843
			#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
26077
			#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
25844
			#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
26078
			#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
25845
			#必填參數:
26079
			#必填參數:
25846
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
26080
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
25847
			$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
26081
			$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
25848
			#$conf["name"],字串,服務名稱.
26082
			#$conf["name"],字串,服務名稱.
25849
			$conf["cmd::systemd"]["name"]=$conf["name"];
26083
			$conf["cmd::systemd"]["name"]=$conf["name"];
25850
			#可省略參數:
26084
			#可省略參數:
25851
			#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
26085
			#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
25852
			$conf["cmd::systemd"]["operation"]="status";
26086
			$conf["cmd::systemd"]["operation"]="status";
25853
			#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
26087
			#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
25854
			#$conf["cmd::systemd"]["username"]="";
26088
			#$conf["cmd::systemd"]["username"]="";
25855
			
26089
 
25856
			#如果有設定密碼
26090
			#如果有設定密碼
25857
			if(isset($conf["password"])){
26091
			if(isset($conf["password"])){
25858
			
26092
 
25859
				#$conf["password"],字串,使用者的密碼,預設不使用.
26093
				#$conf["password"],字串,使用者的密碼,預設不使用.
25860
				$conf["cmd::systemd"]["password"]=$conf["password"];
26094
				$conf["cmd::systemd"]["password"]=$conf["password"];
25861
			
26095
 
25862
				}#if end
26096
				}#if end
25863
			
26097
 
25864
			$systemd=cmd::systemd($conf["cmd::systemd"]);
26098
			$systemd=cmd::systemd($conf["cmd::systemd"]);
25865
			unset($conf["cmd::systemd"]);
26099
			unset($conf["cmd::systemd"]);
25866
			
26100
 
25867
			#若運行出錯
26101
			#若運行出錯
25868
			if($systemd["status"]==="false"){
26102
			if($systemd["status"]==="false"){
25869
			
26103
 
25870
				#設置執行失敗
26104
				#設置執行失敗
25871
				$result["status"]="false";
26105
				$result["status"]="false";
25872
 
26106
 
25873
				#設置錯誤訊息
26107
				#設置錯誤訊息
25874
				$result["error"]=$systemd;
26108
				$result["error"]=$systemd;
25875
 
26109
 
25876
				#回傳結果
26110
				#回傳結果
25877
				return $result;
26111
				return $result;
25878
			
26112
 
25879
				}#if end
26113
				}#if end
25880
			
26114
 
25881
			#如果只處理有設置enable的服務
26115
			#如果只處理有設置enable的服務
25882
			if($conf["onlyWhenEnable"]==="true"){
26116
			if($conf["onlyWhenEnable"]==="true"){
25883
			
26117
 
25884
				#如果服務沒有 enable
26118
				#如果服務沒有 enable
25885
				if($systemd["content"]["srerviceInfo"]["auto"]==="false"){
26119
				if($systemd["content"]["srerviceInfo"]["auto"]==="false"){
25886
				
26120
 
25887
					#過30秒再檢查一次
26121
					#過30秒再檢查一次
25888
					sleep($conf["interval"]);
26122
					sleep($conf["interval"]);
25889
					
26123
 
25890
					#下一輪
26124
					#下一輪
25891
					continue;
26125
					continue;
25892
				
26126
 
25893
					}#if end
26127
					}#if end
25894
			
26128
 
25895
				}#if end
26129
				}#if end
25896
			
26130
 
25897
			#如果服務沒啟動
26131
			#如果服務沒啟動
25898
			if($systemd["content"]["srerviceInfo"]["on"]==="false"){
26132
			if($systemd["content"]["srerviceInfo"]["on"]==="false"){
25899
			
26133
 
25900
				#如果 verbose 為 "true"
26134
				#如果 verbose 為 "true"
25901
				if($conf["verbose"]==="true"){
26135
				if($conf["verbose"]==="true"){
25902
				
26136
 
25903
					#印出提示
26137
					#印出提示
25904
					echo "service ".$conf["name"]." down.".PHP_EOL;
26138
					echo "service ".$conf["name"]." down.".PHP_EOL;
25905
				
26139
 
25906
					}#if end
26140
					}#if end
25907
			
26141
 
25908
				#如果只要 Report
26142
				#如果只要 Report
25909
				if($conf["reportOnly"]==="true"){
26143
				if($conf["reportOnly"]==="true"){
25910
				
26144
 
25911
					#輸出
26145
					#輸出
25912
					echo "service ".$conf["name"]." need to start!";
26146
					echo "service ".$conf["name"]." need to start!";
25913
					
26147
 
25914
					#下一輪
26148
					#下一輪
25915
					continue;
26149
					continue;
25916
				
26150
 
25917
					}#if end
26151
					}#if end
25918
			
26152
 
25919
				#啟動服務
26153
				#啟動服務
25920
				#函式說明:
26154
				#函式說明:
25921
				#執行 systemd 程序來管理服務.
26155
				#執行 systemd 程序來管理服務.
25922
				#回傳結果:
26156
				#回傳結果:
25923
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26157
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
25924
				#$result["error"],錯誤訊息.
26158
				#$result["error"],錯誤訊息.
25925
				#$result["function"],當前執行的函式名稱.
26159
				#$result["function"],當前執行的函式名稱.
25926
				#$result["argu"],所使用的參數.
26160
				#$result["argu"],所使用的參數.
25927
				#$result["content"],執行的結果.
26161
				#$result["content"],執行的結果.
25928
				#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
26162
				#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
25929
				#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
26163
				#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
25930
				#必填參數:
26164
				#必填參數:
25931
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
26165
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
25932
				$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
26166
				$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
25933
				#$conf["name"],字串,服務名稱.
26167
				#$conf["name"],字串,服務名稱.
25934
				$conf["cmd::systemd"]["name"]=$conf["name"];
26168
				$conf["cmd::systemd"]["name"]=$conf["name"];
Line 25939... Line 26173...
25939
				#$conf["username"]="";
26173
				#$conf["username"]="";
25940
				#$conf["password"],字串,使用者的密碼,預設不使用.
26174
				#$conf["password"],字串,使用者的密碼,預設不使用.
25941
				#$conf["password"]="";
26175
				#$conf["password"]="";
25942
				$systemd=cmd::systemd($conf["cmd::systemd"]);
26176
				$systemd=cmd::systemd($conf["cmd::systemd"]);
25943
				unset($conf["cmd::systemd"]);
26177
				unset($conf["cmd::systemd"]);
25944
				
26178
 
25945
				#若運行出錯
26179
				#若運行出錯
25946
				if($systemd["status"]==="false"){
26180
				if($systemd["status"]==="false"){
25947
				
26181
 
25948
					#設置執行失敗
26182
					#設置執行失敗
25949
					$result["status"]="false";
26183
					$result["status"]="false";
25950
 
26184
 
25951
					#設置錯誤訊息
26185
					#設置錯誤訊息
25952
					$result["error"]=$systemd;
26186
					$result["error"]=$systemd;
25953
 
26187
 
25954
					#回傳結果
26188
					#回傳結果
25955
					return $result;
26189
					return $result;
25956
				
26190
 
25957
					}#if end
26191
					}#if end
25958
			
26192
 
25959
				#如果 verbose 為 "true"
26193
				#如果 verbose 為 "true"
25960
				if($conf["verbose"]==="true"){
26194
				if($conf["verbose"]==="true"){
25961
				
26195
 
25962
					#印出提示
26196
					#印出提示
25963
					echo "service ".$conf["name"]." started.".PHP_EOL;
26197
					echo "service ".$conf["name"]." started.".PHP_EOL;
25964
				
26198
 
25965
					}#if end
26199
					}#if end
25966
			
26200
 
25967
				#下一輪
26201
				#下一輪
25968
				continue;
26202
				continue;
25969
			
26203
 
25970
				}#if end
26204
				}#if end
25971
			
26205
 
25972
			#如果有啟用 verbose
26206
			#如果有啟用 verbose
25973
			if($conf["verbose"]==="true"){
26207
			if($conf["verbose"]==="true"){
25974
			
26208
 
25975
				#提示正在檢查
26209
				#提示正在檢查
25976
				echo "service seems up.".PHP_EOL;
26210
				echo "service seems up.".PHP_EOL;
25977
			
26211
 
25978
				}#if end
26212
				}#if end
25979
			
26213
 
25980
			#如果有指定 checkListen陣列
26214
			#如果有指定 checkListen陣列
25981
			if(isset($conf["checkListen"])){
26215
			if(isset($conf["checkListen"])){
25982
			
26216
 
25983
				#如果有指定 socket info 的條件
26217
				#如果有指定 socket info 的條件
25984
				if(count($conf["checkListen"])>0){
26218
				if(count($conf["checkListen"])>0){
25985
				
26219
 
25986
					#如果有啟用 verbose
26220
					#如果有啟用 verbose
25987
					if($conf["verbose"]==="true"){
26221
					if($conf["verbose"]==="true"){
25988
					
26222
 
25989
						#提示正在檢查
26223
						#提示正在檢查
25990
						echo "need check socket info.".PHP_EOL;
26224
						echo "need check socket info.".PHP_EOL;
25991
					
26225
 
25992
						}#if end
26226
						}#if end
25993
				
26227
 
25994
					#針對每個 socket 的 infos
26228
					#針對每個 socket 的 infos
25995
					foreach($conf["checkListen"] as $checkListen){
26229
					foreach($conf["checkListen"] as $checkListen){
25996
					
26230
 
25997
						#如果有啟用 verbose
26231
						#如果有啟用 verbose
25998
						if($conf["verbose"]==="true"){
26232
						if($conf["verbose"]==="true"){
25999
						
26233
 
26000
							#提示正在檢查
26234
							#提示正在檢查
26001
							echo "parse socket condition...".PHP_EOL;
26235
							echo "parse socket condition...".PHP_EOL;
26002
						
26236
 
26003
							}#if end
26237
							}#if end
26004
					
26238
 
26005
						#函式說明:
26239
						#函式說明:
26006
						#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
26240
						#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
26007
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26241
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26008
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
26242
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
26009
						#$result["function"],當前執行的函式名稱.
26243
						#$result["function"],當前執行的函式名稱.
Line 26076... Line 26310...
26076
 
26310
 
26077
							#回傳結果
26311
							#回傳結果
26078
							return $result;
26312
							return $result;
26079
 
26313
 
26080
							}#if end
26314
							}#if end
26081
						
26315
 
26082
						#debug
26316
						#debug
26083
						#echo "check arguments ok!".PHP_EOL;
26317
						#echo "check arguments ok!".PHP_EOL;
26084
						
26318
 
26085
						#初始化找到的 socket 資訊
26319
						#初始化找到的 socket 資訊
26086
						$foundSocketInfo=array();
26320
						$foundSocketInfo=array();
26087
					
26321
 
26088
						#連線到 usr/bin/qbpwcf-usock.php 產生的  unix domain socket,運行指定的指令.
26322
						#連線到 usr/bin/qbpwcf-usock.php 產生的  unix domain socket,運行指定的指令.
26089
						#回傳結果:
26323
						#回傳結果:
26090
						#$result["status"],"true"代表執行正常;"false"代表執行不正常.
26324
						#$result["status"],"true"代表執行正常;"false"代表執行不正常.
26091
						#$result["error"],錯誤訊息陣列.
26325
						#$result["error"],錯誤訊息陣列.
26092
						#$result["function"],當前執行的函式名稱.
26326
						#$result["function"],當前執行的函式名稱.
Line 26105... Line 26339...
26105
						#無.
26339
						#無.
26106
						#備註:
26340
						#備註:
26107
						#無.
26341
						#無.
26108
						$execAnyCmdbyQBPWCFunixSocket=sock::execAnyCmdByQBPWCFunixSocket($conf["sock::execAnyCmdbyQBPWCFunixSocket"]);
26342
						$execAnyCmdbyQBPWCFunixSocket=sock::execAnyCmdByQBPWCFunixSocket($conf["sock::execAnyCmdbyQBPWCFunixSocket"]);
26109
						unset($conf["sock::execAnyCmdbyQBPWCFunixSocket"]);
26343
						unset($conf["sock::execAnyCmdbyQBPWCFunixSocket"]);
26110
						
26344
 
26111
						#如果執行失敗
26345
						#如果執行失敗
26112
						if($execAnyCmdbyQBPWCFunixSocket["status"]==="false"){
26346
						if($execAnyCmdbyQBPWCFunixSocket["status"]==="false"){
26113
						
26347
 
26114
							#設置執行失敗
26348
							#設置執行失敗
26115
							$result["status"]="false";
26349
							$result["status"]="false";
26116
 
26350
 
26117
							#設置錯誤訊息
26351
							#設置錯誤訊息
26118
							$result["error"]=$execAnyCmdbyQBPWCFunixSocket;
26352
							$result["error"]=$execAnyCmdbyQBPWCFunixSocket;
26119
 
26353
 
26120
							#回傳結果
26354
							#回傳結果
26121
							return $result;
26355
							return $result;
26122
						
26356
 
26123
							}#if end
26357
							}#if end
26124
						
26358
 
26125
						#debug
26359
						#debug
26126
						#var_dump(__LINE__,$execAnyCmdbyQBPWCFunixSocket["content"]);
26360
						#var_dump(__LINE__,$execAnyCmdbyQBPWCFunixSocket["content"]);
26127
						
26361
 
26128
						#函式說明:
26362
						#函式說明:
26129
						#解析 ss 指令的輸出
26363
						#解析 ss 指令的輸出
26130
						#回傳結果:
26364
						#回傳結果:
26131
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26365
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26132
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
26366
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 26143... Line 26377...
26143
						#無.
26377
						#無.
26144
						#備註:
26378
						#備註:
26145
						#無.
26379
						#無.
26146
						$ss=parser::ss($conf["parser::ss"]);
26380
						$ss=parser::ss($conf["parser::ss"]);
26147
						unset($conf["parser::ss"]);
26381
						unset($conf["parser::ss"]);
26148
						
26382
 
26149
						#如果執行失敗
26383
						#如果執行失敗
26150
						if($ss["status"]==="false"){
26384
						if($ss["status"]==="false"){
26151
						
26385
 
26152
							#設置執行失敗
26386
							#設置執行失敗
26153
							$result["status"]="false";
26387
							$result["status"]="false";
26154
 
26388
 
26155
							#設置錯誤訊息
26389
							#設置錯誤訊息
26156
							$result["error"]=$ss;
26390
							$result["error"]=$ss;
26157
 
26391
 
26158
							#回傳結果
26392
							#回傳結果
26159
							return $result;
26393
							return $result;
26160
						
26394
 
26161
							}#if end
26395
							}#if end
26162
							
26396
 
26163
						#debug
26397
						#debug
26164
						#var_dump($ss);	
26398
						#var_dump($ss);
26165
							
26399
 
26166
						#如果沒有 Netid 欄位
26400
						#如果沒有 Netid 欄位
26167
						if(!isset($ss["content"]["Netid"])){
26401
						if(!isset($ss["content"]["Netid"])){
26168
						
26402
 
26169
							#設置執行失敗
26403
							#設置執行失敗
26170
							$result["status"]="false";
26404
							$result["status"]="false";
26171
 
26405
 
26172
							#設置錯誤訊息
26406
							#設置錯誤訊息
26173
							$result["error"][]="Netid column data not found";
26407
							$result["error"][]="Netid column data not found";
26174
							
26408
 
26175
							#設置錯誤訊息
26409
							#設置錯誤訊息
26176
							$result["error"][]=$ss;
26410
							$result["error"][]=$ss;
26177
 
26411
 
26178
							#回傳結果
26412
							#回傳結果
26179
							return $result;
26413
							return $result;
26180
						
26414
 
26181
							}#if end
26415
							}#if end
26182
						
26416
 
26183
						#如果有ip條件
26417
						#如果有ip條件
26184
						if(isset($checkListen["ip"])){
26418
						if(isset($checkListen["ip"])){
26185
							
26419
 
26186
							#取得ip條件
26420
							#取得ip條件
26187
							$listenInfo=$checkListen["ip"];
26421
							$listenInfo=$checkListen["ip"];
26188
							
26422
 
26189
							#函式說明:
26423
							#函式說明:
26190
							#將固定格式的字串分開,並回傳分開的結果.
26424
							#將固定格式的字串分開,並回傳分開的結果.
26191
							#回傳結果:
26425
							#回傳結果:
26192
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26426
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26193
							#$result["error"],錯誤訊息陣列
26427
							#$result["error"],錯誤訊息陣列
Line 26209... Line 26443...
26209
							#無.
26443
							#無.
26210
							#備註:
26444
							#備註:
26211
							#無.
26445
							#無.
26212
							$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
26446
							$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
26213
							unset($conf["stringProcess::spiltString"]);
26447
							unset($conf["stringProcess::spiltString"]);
26214
						
26448
 
26215
							#如果執行失敗
26449
							#如果執行失敗
26216
							if($spiltString["status"]==="false"){
26450
							if($spiltString["status"]==="false"){
26217
						
26451
 
26218
								#設置執行失敗
26452
								#設置執行失敗
26219
								$result["status"]="false";
26453
								$result["status"]="false";
26220
 
26454
 
26221
								#設置錯誤訊息
26455
								#設置錯誤訊息
26222
								$result["error"]=$spiltString;
26456
								$result["error"]=$spiltString;
26223
 
26457
 
26224
								#回傳結果
26458
								#回傳結果
26225
								return $result;
26459
								return $result;
26226
								
26460
 
26227
								}#if end
26461
								}#if end
26228
								
26462
 
26229
							#如果沒有分割用的關鍵字
26463
							#如果沒有分割用的關鍵字
26230
							if($spiltString["found"]==="false"){
26464
							if($spiltString["found"]==="false"){
26231
						
26465
 
26232
								#設置執行失敗
26466
								#設置執行失敗
26233
								$result["status"]="false";
26467
								$result["status"]="false";
26234
 
26468
 
26235
								#設置錯誤訊息
26469
								#設置錯誤訊息
26236
								$result["error"]=$spiltString;
26470
								$result["error"]=$spiltString;
26237
 
26471
 
26238
								#回傳結果
26472
								#回傳結果
26239
								return $result;
26473
								return $result;
26240
								
26474
 
26241
								}#if end
26475
								}#if end
26242
								
26476
 
26243
							#如果沒有切成兩段	
26477
							#如果沒有切成兩段
26244
							if($spiltString["dataCounts"]!==2){
26478
							if($spiltString["dataCounts"]!==2){
26245
						
26479
 
26246
								#設置執行失敗
26480
								#設置執行失敗
26247
								$result["status"]="false";
26481
								$result["status"]="false";
26248
 
26482
 
26249
								#設置錯誤訊息
26483
								#設置錯誤訊息
26250
								$result["error"]=$spiltString;
26484
								$result["error"]=$spiltString;
26251
 
26485
 
26252
								#回傳結果
26486
								#回傳結果
26253
								return $result;
26487
								return $result;
26254
								
26488
 
26255
								}#if end
26489
								}#if end
26256
								
26490
 
26257
							#取得 listen ip
26491
							#取得 listen ip
26258
							$ip=$spiltString["dataArray"][0];
26492
							$ip=$spiltString["dataArray"][0];
26259
							
26493
 
26260
							#函式說明:
26494
							#函式說明:
26261
							#將固定格式的字串分開,並回傳分開的結果.
26495
							#將固定格式的字串分開,並回傳分開的結果.
26262
							#回傳結果:
26496
							#回傳結果:
26263
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26497
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26264
							#$result["error"],錯誤訊息陣列
26498
							#$result["error"],錯誤訊息陣列
Line 26280... Line 26514...
26280
							#無.
26514
							#無.
26281
							#備註:
26515
							#備註:
26282
							#無.
26516
							#無.
26283
							$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
26517
							$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
26284
							unset($conf["stringProcess::spiltString"]);
26518
							unset($conf["stringProcess::spiltString"]);
26285
						
26519
 
26286
							#如果執行失敗
26520
							#如果執行失敗
26287
							if($spiltString["status"]==="false"){
26521
							if($spiltString["status"]==="false"){
26288
						
26522
 
26289
								#設置執行失敗
26523
								#設置執行失敗
26290
								$result["status"]="false";
26524
								$result["status"]="false";
26291
 
26525
 
26292
								#設置錯誤訊息
26526
								#設置錯誤訊息
26293
								$result["error"]=$spiltString;
26527
								$result["error"]=$spiltString;
26294
 
26528
 
26295
								#回傳結果
26529
								#回傳結果
26296
								return $result;
26530
								return $result;
26297
								
26531
 
26298
								}#if end
26532
								}#if end
26299
								
26533
 
26300
							#如果沒有分割用的關鍵字
26534
							#如果沒有分割用的關鍵字
26301
							if($spiltString["found"]==="false"){
26535
							if($spiltString["found"]==="false"){
26302
						
26536
 
26303
								#設置執行失敗
26537
								#設置執行失敗
26304
								$result["status"]="false";
26538
								$result["status"]="false";
26305
 
26539
 
26306
								#設置錯誤訊息
26540
								#設置錯誤訊息
26307
								$result["error"]=$spiltString;
26541
								$result["error"]=$spiltString;
26308
 
26542
 
26309
								#回傳結果
26543
								#回傳結果
26310
								return $result;
26544
								return $result;
26311
								
26545
 
26312
								}#if end
26546
								}#if end
26313
								
26547
 
26314
							#如果沒有切成兩段	
26548
							#如果沒有切成兩段
26315
							if($spiltString["dataCounts"]!==2){
26549
							if($spiltString["dataCounts"]!==2){
26316
						
26550
 
26317
								#設置執行失敗
26551
								#設置執行失敗
26318
								$result["status"]="false";
26552
								$result["status"]="false";
26319
 
26553
 
26320
								#設置錯誤訊息
26554
								#設置錯誤訊息
26321
								$result["error"]=$spiltString;
26555
								$result["error"]=$spiltString;
26322
 
26556
 
26323
								#回傳結果
26557
								#回傳結果
26324
								return $result;
26558
								return $result;
26325
								
26559
 
26326
								}#if end
26560
								}#if end
26327
								
26561
 
26328
							#取得 listen port
26562
							#取得 listen port
26329
							$port=$spiltString["dataArray"][0];
26563
							$port=$spiltString["dataArray"][0];
26330
							
26564
 
26331
							#取得 listen protocol
26565
							#取得 listen protocol
26332
							$protocol=$spiltString["dataArray"][1];
26566
							$protocol=$spiltString["dataArray"][1];
26333
							
26567
 
26334
							#如果 verbose 為 "true"
26568
							#如果 verbose 為 "true"
26335
							if($conf["verbose"]==="true"){
26569
							if($conf["verbose"]==="true"){
26336
							
26570
 
26337
								#印出提示
26571
								#印出提示
26338
								echo "check ip=".$ip." of service ".$conf["name"].PHP_EOL;
26572
								echo "check ip=".$ip." of service ".$conf["name"].PHP_EOL;
26339
								
26573
 
26340
								#印出提示
26574
								#印出提示
26341
								echo "check port=".$port." of service ".$conf["name"].PHP_EOL;
26575
								echo "check port=".$port." of service ".$conf["name"].PHP_EOL;
26342
								
26576
 
26343
								#印出提示
26577
								#印出提示
26344
								echo "check protocol=".$protocol." of service ".$conf["name"].PHP_EOL;
26578
								echo "check protocol=".$protocol." of service ".$conf["name"].PHP_EOL;
26345
							
26579
 
26346
								}#if end
26580
								}#if end
26347
							
26581
 
26348
							#如果 protocol 不是 tcp 也不是 udp
26582
							#如果 protocol 不是 tcp 也不是 udp
26349
							if($protocol!=="tcp" && $protocol!=="udp"){
26583
							if($protocol!=="tcp" && $protocol!=="udp"){
26350
							
26584
 
26351
								#設置執行失敗
26585
								#設置執行失敗
26352
								$result["status"]="false";
26586
								$result["status"]="false";
26353
 
26587
 
26354
								#設置錯誤訊息
26588
								#設置錯誤訊息
26355
								$result["error"][]="protocol should be tcp or udp";
26589
								$result["error"][]="protocol should be tcp or udp";
26356
								
26590
 
26357
								#設置錯誤訊息
26591
								#設置錯誤訊息
26358
								$result["error"][]=$spiltString;
26592
								$result["error"][]=$spiltString;
26359
 
26593
 
26360
								#回傳結果
26594
								#回傳結果
26361
								return $result;
26595
								return $result;
26362
							
26596
 
26363
								}#if end
26597
								}#if end
26364
							
26598
 
26365
							#如果沒有 "Local Address:Port" 欄位
26599
							#如果沒有 "Local Address:Port" 欄位
26366
							if(!isset($ss["content"]["Local Address:Port"])){
26600
							if(!isset($ss["content"]["Local Address:Port"])){
26367
							
26601
 
26368
								#設置執行失敗
26602
								#設置執行失敗
26369
								$result["status"]="false";
26603
								$result["status"]="false";
26370
 
26604
 
26371
								#設置錯誤訊息
26605
								#設置錯誤訊息
26372
								$result["error"][]="Local Address:Port column data not found";
26606
								$result["error"][]="Local Address:Port column data not found";
26373
								
26607
 
26374
								#設置錯誤訊息
26608
								#設置錯誤訊息
26375
								$result["error"][]=$ss;
26609
								$result["error"][]=$ss;
26376
 
26610
 
26377
								#回傳結果
26611
								#回傳結果
26378
								return $result;
26612
								return $result;
26379
							
26613
 
26380
								}#if end
26614
								}#if end
26381
					
26615
 
26382
							#預設沒有通過檢查
26616
							#預設沒有通過檢查
26383
							$pass="false";
26617
							$pass="false";
26384
					
26618
 
26385
							#要搜尋的ip
26619
							#要搜尋的ip
26386
							$ips=array();
26620
							$ips=array();
26387
							
26621
 
26388
							#要搜尋的ip關鍵字
26622
							#要搜尋的ip關鍵字
26389
							$ips[]=$ip;
26623
							$ips[]=$ip;
26390
					
26624
 
26391
							#如果不是 ipv6,亦即為ipv4.
26625
							#如果不是 ipv6,亦即為ipv4.
26392
							if(strpos($ip,":")!==false){
26626
							if(strpos($ip,":")!==false){
26393
							
26627
 
26394
								#函式說明:
26628
								#函式說明:
26395
								#將ipv4轉換成ipv6
26629
								#將ipv4轉換成ipv6
26396
								#回傳結果:
26630
								#回傳結果:
26397
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26631
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26398
								#$result["error"],錯誤訊息陣列.
26632
								#$result["error"],錯誤訊息陣列.
Line 26409... Line 26643...
26409
								#https://www.ultratools.com/tools/ipv4toipv6
26643
								#https://www.ultratools.com/tools/ipv4toipv6
26410
								#備註:
26644
								#備註:
26411
								#無.
26645
								#無.
26412
								$ipv4toipv6=csInformation::ipv4toipv6($Conf["csInformation::ipv4toipv6"]);
26646
								$ipv4toipv6=csInformation::ipv4toipv6($Conf["csInformation::ipv4toipv6"]);
26413
								unset($Conf["csInformation::ipv4toipv6"]);
26647
								unset($Conf["csInformation::ipv4toipv6"]);
26414
							
26648
 
26415
								#如果執行失敗
26649
								#如果執行失敗
26416
								if($ipv4toipv6["status"]==="false"){
26650
								if($ipv4toipv6["status"]==="false"){
26417
								
26651
 
26418
									#設置執行失敗
26652
									#設置執行失敗
26419
									$result["status"]="false";
26653
									$result["status"]="false";
26420
 
26654
 
26421
									#設置錯誤訊息
26655
									#設置錯誤訊息
26422
									$result["error"]=$ipv4toipv6;
26656
									$result["error"]=$ipv4toipv6;
26423
 
26657
 
26424
									#回傳結果
26658
									#回傳結果
26425
									return $result;
26659
									return $result;
26426
								
26660
 
26427
									}#if end
26661
									}#if end
26428
								
26662
 
26429
								#要搜尋的ipv6關鍵字
26663
								#要搜尋的ipv6關鍵字
26430
								$ips[]=$ipv4toipv6["content"];
26664
								$ips[]=$ipv4toipv6["content"];
26431
							
26665
 
26432
								}#if end
26666
								}#if end
26433
					
26667
 
26434
							#針對每筆資料
26668
							#針對每筆資料
26435
							foreach($ss["content"]["Local Address:Port"] as $index => $localAddrPort){
26669
							foreach($ss["content"]["Local Address:Port"] as $index => $localAddrPort){
26436
								
26670
 
26437
								#尋找符合的 Local Address
26671
								#尋找符合的 Local Address
26438
								#函式說明:
26672
								#函式說明:
26439
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
26673
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
26440
								#回傳結果:
26674
								#回傳結果:
26441
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
26675
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
Line 26456... Line 26690...
26456
								#無.
26690
								#無.
26457
								#備註:
26691
								#備註:
26458
								#無.
26692
								#無.
26459
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
26693
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
26460
								unset($conf["search::getEqualVar"]);
26694
								unset($conf["search::getEqualVar"]);
26461
								
26695
 
26462
								#如果執行失敗
26696
								#如果執行失敗
26463
								if($getEqualVar["status"]==="false"){
26697
								if($getEqualVar["status"]==="false"){
26464
								
26698
 
26465
									#設置執行失敗
26699
									#設置執行失敗
26466
									$result["status"]="false";
26700
									$result["status"]="false";
26467
 
26701
 
26468
									#設置錯誤訊息
26702
									#設置錯誤訊息
26469
									$result["error"]=$getEqualVar;
26703
									$result["error"]=$getEqualVar;
26470
 
26704
 
26471
									#回傳結果
26705
									#回傳結果
26472
									return $result;
26706
									return $result;
26473
								
26707
 
26474
									}#if end
26708
									}#if end
26475
									
26709
 
26476
								#如果無找到同 addr 的資料
26710
								#如果無找到同 addr 的資料
26477
								if($getEqualVar["founded"]==="fasle"){
26711
								if($getEqualVar["founded"]==="fasle"){
26478
							
26712
 
26479
									#下一輪
26713
									#下一輪
26480
									continue;
26714
									continue;
26481
									
26715
 
26482
									}#if end
26716
									}#if end
26483
									
26717
 
26484
								#尋找符合的 Port
26718
								#尋找符合的 Port
26485
								#函式說明:
26719
								#函式說明:
26486
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
26720
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
26487
								#回傳結果:
26721
								#回傳結果:
26488
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
26722
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
Line 26503... Line 26737...
26503
								#無.
26737
								#無.
26504
								#備註:
26738
								#備註:
26505
								#無.
26739
								#無.
26506
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
26740
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
26507
								unset($conf["search::getEqualVar"]);
26741
								unset($conf["search::getEqualVar"]);
26508
								
26742
 
26509
								#如果執行失敗
26743
								#如果執行失敗
26510
								if($getEqualVar["status"]==="false"){
26744
								if($getEqualVar["status"]==="false"){
26511
								
26745
 
26512
									#設置執行失敗
26746
									#設置執行失敗
26513
									$result["status"]="false";
26747
									$result["status"]="false";
26514
 
26748
 
26515
									#設置錯誤訊息
26749
									#設置錯誤訊息
26516
									$result["error"]=$getEqualVar;
26750
									$result["error"]=$getEqualVar;
26517
 
26751
 
26518
									#回傳結果
26752
									#回傳結果
26519
									return $result;
26753
									return $result;
26520
								
26754
 
26521
									}#if end
26755
									}#if end
26522
									
26756
 
26523
								#如果無找到同 port 的資料
26757
								#如果無找到同 port 的資料
26524
								if($getEqualVar["founded"]==="fasle"){
26758
								if($getEqualVar["founded"]==="fasle"){
26525
							
26759
 
26526
									#下一輪
26760
									#下一輪
26527
									continue;
26761
									continue;
26528
									
26762
 
26529
									}#if end
26763
									}#if end
26530
									
26764
 
26531
								#執行到這邊代表有找到同 ip:port 的資料
26765
								#執行到這邊代表有找到同 ip:port 的資料
26532
								
26766
 
26533
								#若 protocol 正確
26767
								#若 protocol 正確
26534
								if($ss["content"]["Netid"][$index]===$protocol){
26768
								if($ss["content"]["Netid"][$index]===$protocol){
26535
								
26769
 
26536
									#設置通過檢查
26770
									#設置通過檢查
26537
									$pass="true";
26771
									$pass="true";
26538
									
26772
 
26539
									}#if end
26773
									}#if end
26540
								
26774
 
26541
								}#foreach end
26775
								}#foreach end
26542
							
26776
 
26543
							#如果沒有符合的 ip:port
26777
							#如果沒有符合的 ip:port
26544
							if($pass==="false"){
26778
							if($pass==="false"){
26545
							
26779
 
26546
								#提示問題
26780
								#提示問題
26547
								echo "service ".$conf["name"]." ip and port not match!".PHP_EOL;
26781
								echo "service ".$conf["name"]." ip and port not match!".PHP_EOL;
26548
							
26782
 
26549
								#如果 verbose 為 "true"
26783
								#如果 verbose 為 "true"
26550
								if($conf["verbose"]==="true"){
26784
								if($conf["verbose"]==="true"){
26551
								
26785
 
26552
									#提示搜尋過的內容
26786
									#提示搜尋過的內容
26553
									echo "searched socket list:".PHP_EOL;
26787
									echo "searched socket list:".PHP_EOL;
26554
									var_dump($ss["content"]["Local Address:Port"]);
26788
									var_dump($ss["content"]["Local Address:Port"]);
26555
								
26789
 
26556
									}#if end
26790
									}#if end
26557
								
26791
 
26558
								#如果只要 Report
26792
								#如果只要 Report
26559
								if($conf["reportOnly"]==="true"){
26793
								if($conf["reportOnly"]==="true"){
26560
								
26794
 
26561
									#輸出
26795
									#輸出
26562
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;
26796
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;
26563
									
26797
 
26564
									#下一輪
26798
									#下一輪
26565
									continue;
26799
									continue;
26566
								
26800
 
26567
									}#if end
26801
									}#if end
26568
							
26802
 
26569
								#啟動服務
26803
								#啟動服務
26570
								#函式說明:
26804
								#函式說明:
26571
								#執行 systemd 程序來管理服務.
26805
								#執行 systemd 程序來管理服務.
26572
								#回傳結果:
26806
								#回傳結果:
26573
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26807
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26574
								#$result["error"],錯誤訊息.
26808
								#$result["error"],錯誤訊息.
26575
								#$result["function"],當前執行的函式名稱.
26809
								#$result["function"],當前執行的函式名稱.
26576
								#$result["argu"],所使用的參數.
26810
								#$result["argu"],所使用的參數.
26577
								#$result["content"],執行的結果.
26811
								#$result["content"],執行的結果.
26578
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
26812
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
26579
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
26813
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
26580
								#必填參數:
26814
								#必填參數:
26581
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
26815
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
26582
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
26816
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
26583
								#$conf["name"],字串,服務名稱.
26817
								#$conf["name"],字串,服務名稱.
26584
								$conf["cmd::systemd"]["name"]=$conf["name"];
26818
								$conf["cmd::systemd"]["name"]=$conf["name"];
Line 26589... Line 26823...
26589
								#$conf["username"]="";
26823
								#$conf["username"]="";
26590
								#$conf["password"],字串,使用者的密碼,預設不使用.
26824
								#$conf["password"],字串,使用者的密碼,預設不使用.
26591
								#$conf["password"]="";
26825
								#$conf["password"]="";
26592
								$systemd=cmd::systemd($conf["cmd::systemd"]);
26826
								$systemd=cmd::systemd($conf["cmd::systemd"]);
26593
								unset($conf["cmd::systemd"]);
26827
								unset($conf["cmd::systemd"]);
26594
								
26828
 
26595
								#若運行出錯
26829
								#若運行出錯
26596
								if($systemd["status"]==="false"){
26830
								if($systemd["status"]==="false"){
26597
								
26831
 
26598
									#設置執行失敗
26832
									#設置執行失敗
26599
									$result["status"]="false";
26833
									$result["status"]="false";
26600
 
26834
 
26601
									#設置錯誤訊息
26835
									#設置錯誤訊息
26602
									$result["error"]=$systemd;
26836
									$result["error"]=$systemd;
26603
 
26837
 
26604
									#回傳結果
26838
									#回傳結果
26605
									return $result;
26839
									return $result;
26606
								
26840
 
26607
									}#if end
26841
									}#if end
26608
							
26842
 
26609
								#下一輪
26843
								#下一輪
26610
								continue;
26844
								continue;
26611
							
26845
 
26612
								}#if end
26846
								}#if end
26613
							
26847
 
26614
							}#if end, ip condition end
26848
							}#if end, ip condition end
26615
							
26849
 
26616
						#如果有指定 addr
26850
						#如果有指定 addr
26617
						if(isset($checkListen["addr"])){
26851
						if(isset($checkListen["addr"])){
26618
						
26852
 
26619
							#取得addr資訊
26853
							#取得addr資訊
26620
							$listenInfo=$checkListen["addr"];
26854
							$listenInfo=$checkListen["addr"];
26621
							
26855
 
26622
							#如果沒有 "Local Address:Port" 欄位
26856
							#如果沒有 "Local Address:Port" 欄位
26623
							if(!isset($ss["content"]["Local Address:Port"])){
26857
							if(!isset($ss["content"]["Local Address:Port"])){
26624
							
26858
 
26625
								#設置執行失敗
26859
								#設置執行失敗
26626
								$result["status"]="false";
26860
								$result["status"]="false";
26627
 
26861
 
26628
								#設置錯誤訊息
26862
								#設置錯誤訊息
26629
								$result["error"][]="Local Address:Port column data not found";
26863
								$result["error"][]="Local Address:Port column data not found";
26630
								
26864
 
26631
								#設置錯誤訊息
26865
								#設置錯誤訊息
26632
								$result["error"][]=$ss;
26866
								$result["error"][]=$ss;
26633
 
26867
 
26634
								#回傳結果
26868
								#回傳結果
26635
								return $result;
26869
								return $result;
26636
							
26870
 
26637
								}#if end
26871
								}#if end
26638
								
26872
 
26639
							#預設沒有通過檢查
26873
							#預設沒有通過檢查
26640
							$pass="false";
26874
							$pass="false";
26641
					
26875
 
26642
							#初始化關鍵字
26876
							#初始化關鍵字
26643
							$keyWord=array();
26877
							$keyWord=array();
26644
							
26878
 
26645
							#新增關鍵字  unix socket domain
26879
							#新增關鍵字  unix socket domain
26646
							$keyWord[]=$listenInfo;
26880
							$keyWord[]=$listenInfo;
26647
						
26881
 
26648
							#針對每筆資料
26882
							#針對每筆資料
26649
							foreach($ss["content"]["Local Address:Port"] as $index => $localAddrPort){
26883
							foreach($ss["content"]["Local Address:Port"] as $index => $localAddrPort){
26650
								
26884
 
26651
								#如果是字串
26885
								#如果是字串
26652
								if(gettype($localAddrPort)==="string"){
26886
								if(gettype($localAddrPort)==="string"){
26653
								
26887
 
26654
									#置換成陣列
26888
									#置換成陣列
26655
									$localAddrPort=array($localAddrPort);
26889
									$localAddrPort=array($localAddrPort);
26656
								
26890
 
26657
									}#if end
26891
									}#if end
26658
								
26892
 
26659
								#尋找符合的 Local Address:Port
26893
								#尋找符合的 Local Address:Port
26660
								#函式說明:
26894
								#函式說明:
26661
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
26895
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
26662
								#回傳結果:
26896
								#回傳結果:
26663
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
26897
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
Line 26678... Line 26912...
26678
								#無.
26912
								#無.
26679
								#備註:
26913
								#備註:
26680
								#無.
26914
								#無.
26681
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
26915
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
26682
								unset($conf["search::getEqualVar"]);
26916
								unset($conf["search::getEqualVar"]);
26683
								
26917
 
26684
								#如果執行失敗
26918
								#如果執行失敗
26685
								if($getEqualVar["status"]==="false"){
26919
								if($getEqualVar["status"]==="false"){
26686
								
26920
 
26687
									#設置執行失敗
26921
									#設置執行失敗
26688
									$result["status"]="false";
26922
									$result["status"]="false";
26689
 
26923
 
26690
									#設置錯誤訊息
26924
									#設置錯誤訊息
26691
									$result["error"]=$getEqualVar;
26925
									$result["error"]=$getEqualVar;
26692
 
26926
 
26693
									#回傳結果
26927
									#回傳結果
26694
									return $result;
26928
									return $result;
26695
								
26929
 
26696
									}#if end
26930
									}#if end
26697
									
26931
 
26698
								#如果有找到同 unix domain socket 的資料
26932
								#如果有找到同 unix domain socket 的資料
26699
								if($getEqualVar["founded"]==="true"){
26933
								if($getEqualVar["founded"]==="true"){
26700
								
26934
 
26701
									#初始化 剩下要搜尋的 socket list 資訊
26935
									#初始化 剩下要搜尋的 socket list 資訊
26702
									$new_ss["content"]=array();
26936
									$new_ss["content"]=array();
26703
									
26937
 
26704
									#針對每個欄位
26938
									#針對每個欄位
26705
									foreach($ss["columns"] as $columnName){
26939
									foreach($ss["columns"] as $columnName){
26706
									
26940
 
26707
										#取得欄位對應的資料內容
26941
										#取得欄位對應的資料內容
26708
										$new_ss["content"][$columnName][]=$ss["content"][$columnName][$index];
26942
										$new_ss["content"][$columnName][]=$ss["content"][$columnName][$index];
26709
									
26943
 
26710
										}#foreach end
26944
										}#foreach end
26711
										
26945
 
26712
									#更新要搜尋的 socket list 資訊
26946
									#更新要搜尋的 socket list 資訊
26713
									$ss["content"]=$new_ss["content"];
26947
									$ss["content"]=$new_ss["content"];
26714
									
26948
 
26715
									#設置通過檢查
26949
									#設置通過檢查
26716
									$pass="true";
26950
									$pass="true";
26717
									
26951
 
26718
									}#if end
26952
									}#if end
26719
								
26953
 
26720
								}#foreach end
26954
								}#foreach end
26721
							
26955
 
26722
							#如果沒有符合的 unix domain socket
26956
							#如果沒有符合的 unix domain socket
26723
							if($pass==="false"){
26957
							if($pass==="false"){
26724
							
26958
 
26725
								#提示問題
26959
								#提示問題
26726
								echo "service ".$conf["name"]." unix domain socket not match!".PHP_EOL;
26960
								echo "service ".$conf["name"]." unix domain socket not match!".PHP_EOL;
26727
								
26961
 
26728
								#如果 verbose 為 "true"
26962
								#如果 verbose 為 "true"
26729
								if($conf["verbose"]==="true"){
26963
								if($conf["verbose"]==="true"){
26730
								
26964
 
26731
									#提示搜尋過的內容
26965
									#提示搜尋過的內容
26732
									echo "searched socket list:".PHP_EOL;
26966
									echo "searched socket list:".PHP_EOL;
26733
									var_dump($ss["content"]["Local Address:Port"]);
26967
									var_dump($ss["content"]["Local Address:Port"]);
26734
								
26968
 
26735
									}#if end
26969
									}#if end
26736
							
26970
 
26737
								#如果只要 Report
26971
								#如果只要 Report
26738
								if($conf["reportOnly"]==="true"){
26972
								if($conf["reportOnly"]==="true"){
26739
								
26973
 
26740
									#輸出
26974
									#輸出
26741
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;
26975
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;
26742
									
26976
 
26743
									#下一輪
26977
									#下一輪
26744
									continue;
26978
									continue;
26745
								
26979
 
26746
									}#if end
26980
									}#if end
26747
							
26981
 
26748
								#啟動服務
26982
								#啟動服務
26749
								#函式說明:
26983
								#函式說明:
26750
								#執行 systemd 程序來管理服務.
26984
								#執行 systemd 程序來管理服務.
26751
								#回傳結果:
26985
								#回傳結果:
26752
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26986
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26753
								#$result["error"],錯誤訊息.
26987
								#$result["error"],錯誤訊息.
26754
								#$result["function"],當前執行的函式名稱.
26988
								#$result["function"],當前執行的函式名稱.
26755
								#$result["argu"],所使用的參數.
26989
								#$result["argu"],所使用的參數.
26756
								#$result["content"],執行的結果.
26990
								#$result["content"],執行的結果.
26757
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
26991
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
26758
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
26992
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
26759
								#必填參數:
26993
								#必填參數:
26760
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
26994
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
26761
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
26995
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
26762
								#$conf["name"],字串,服務名稱.
26996
								#$conf["name"],字串,服務名稱.
26763
								$conf["cmd::systemd"]["name"]=$conf["name"];
26997
								$conf["cmd::systemd"]["name"]=$conf["name"];
Line 26768... Line 27002...
26768
								#$conf["username"]="";
27002
								#$conf["username"]="";
26769
								#$conf["password"],字串,使用者的密碼,預設不使用.
27003
								#$conf["password"],字串,使用者的密碼,預設不使用.
26770
								#$conf["password"]="";
27004
								#$conf["password"]="";
26771
								$systemd=cmd::systemd($conf["cmd::systemd"]);
27005
								$systemd=cmd::systemd($conf["cmd::systemd"]);
26772
								unset($conf["cmd::systemd"]);
27006
								unset($conf["cmd::systemd"]);
26773
								
27007
 
26774
								#若運行出錯
27008
								#若運行出錯
26775
								if($systemd["status"]==="false"){
27009
								if($systemd["status"]==="false"){
26776
								
27010
 
26777
									#設置執行失敗
27011
									#設置執行失敗
26778
									$result["status"]="false";
27012
									$result["status"]="false";
26779
 
27013
 
26780
									#設置錯誤訊息
27014
									#設置錯誤訊息
26781
									$result["error"]=$systemd;
27015
									$result["error"]=$systemd;
26782
 
27016
 
26783
									#回傳結果
27017
									#回傳結果
26784
									return $result;
27018
									return $result;
26785
								
27019
 
26786
									}#if end
27020
									}#if end
26787
							
27021
 
26788
								#下一輪
27022
								#下一輪
26789
								continue;
27023
								continue;
26790
							
27024
 
26791
								}#if end
27025
								}#if end
26792
						
27026
 
26793
							}#if end
27027
							}#if end
26794
							
27028
 
26795
						#如果有指定 name
27029
						#如果有指定 name
26796
						if(isset($checkListen["name"])){
27030
						if(isset($checkListen["name"])){
26797
						
27031
 
26798
							#取得name資訊
27032
							#取得name資訊
26799
							$listenInfo=$checkListen["name"];
27033
							$listenInfo=$checkListen["name"];
26800
							
27034
 
26801
							#如果沒有 "Process" 欄位
27035
							#如果沒有 "Process" 欄位
26802
							if(!isset($ss["content"]["Process"])){
27036
							if(!isset($ss["content"]["Process"])){
26803
							
27037
 
26804
								#設置執行失敗
27038
								#設置執行失敗
26805
								$result["status"]="false";
27039
								$result["status"]="false";
26806
 
27040
 
26807
								#設置錯誤訊息
27041
								#設置錯誤訊息
26808
								$result["error"][]="Process column data not found";
27042
								$result["error"][]="Process column data not found";
26809
								
27043
 
26810
								#設置錯誤訊息
27044
								#設置錯誤訊息
26811
								$result["error"][]=$ss;
27045
								$result["error"][]=$ss;
26812
 
27046
 
26813
								#回傳結果
27047
								#回傳結果
26814
								return $result;
27048
								return $result;
26815
							
27049
 
26816
								}#if end
27050
								}#if end
26817
								
27051
 
26818
							#預設沒有通過檢查
27052
							#預設沒有通過檢查
26819
							$pass="false";
27053
							$pass="false";
26820
							
27054
 
26821
							#針對每筆資料
27055
							#針對每筆資料
26822
							foreach($ss["content"]["Process"] as $index => $Process){
27056
							foreach($ss["content"]["Process"] as $index => $Process){
26823
								
27057
 
26824
								#尋找符合的 Process
27058
								#尋找符合的 Process
26825
								#函式說明:
27059
								#函式說明:
26826
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
27060
								#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
26827
								#回傳結果:
27061
								#回傳結果:
26828
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
27062
								#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
Line 26843... Line 27077...
26843
								#無.
27077
								#無.
26844
								#備註:
27078
								#備註:
26845
								#無.
27079
								#無.
26846
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
27080
								$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
26847
								unset($conf["search::getEqualVar"]);
27081
								unset($conf["search::getEqualVar"]);
26848
								
27082
 
26849
								#如果執行失敗
27083
								#如果執行失敗
26850
								if($getEqualVar["status"]==="false"){
27084
								if($getEqualVar["status"]==="false"){
26851
								
27085
 
26852
									#設置執行失敗
27086
									#設置執行失敗
26853
									$result["status"]="false";
27087
									$result["status"]="false";
26854
 
27088
 
26855
									#設置錯誤訊息
27089
									#設置錯誤訊息
26856
									$result["error"]=$getEqualVar;
27090
									$result["error"]=$getEqualVar;
26857
 
27091
 
26858
									#回傳結果
27092
									#回傳結果
26859
									return $result;
27093
									return $result;
26860
								
27094
 
26861
									}#if end
27095
									}#if end
26862
									
27096
 
26863
								#如果有找到同 Process 的資料
27097
								#如果有找到同 Process 的資料
26864
								if($getEqualVar["founded"]==="true"){
27098
								if($getEqualVar["founded"]==="true"){
26865
								
27099
 
26866
									#設置通過檢查
27100
									#設置通過檢查
26867
									$pass="true";
27101
									$pass="true";
26868
									
27102
 
26869
									}#if end
27103
									}#if end
26870
								
27104
 
26871
								}#foreach end
27105
								}#foreach end
26872
							
27106
 
26873
							#如果沒有符合的 process program name
27107
							#如果沒有符合的 process program name
26874
							if($pass==="false"){
27108
							if($pass==="false"){
26875
							
27109
 
26876
								#提示問題
27110
								#提示問題
26877
								echo "service ".$conf["name"]." process program name not match!".PHP_EOL;
27111
								echo "service ".$conf["name"]." process program name not match!".PHP_EOL;
26878
							
27112
 
26879
								#如果只要 Report
27113
								#如果只要 Report
26880
								if($conf["reportOnly"]==="true"){
27114
								if($conf["reportOnly"]==="true"){
26881
								
27115
 
26882
									#輸出
27116
									#輸出
26883
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;
27117
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;
26884
									
27118
 
26885
									#下一輪
27119
									#下一輪
26886
									continue;
27120
									continue;
26887
								
27121
 
26888
									}#if end
27122
									}#if end
26889
							
27123
 
26890
								#啟動服務
27124
								#啟動服務
26891
								#函式說明:
27125
								#函式說明:
26892
								#執行 systemd 程序來管理服務.
27126
								#執行 systemd 程序來管理服務.
26893
								#回傳結果:
27127
								#回傳結果:
26894
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27128
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26895
								#$result["error"],錯誤訊息.
27129
								#$result["error"],錯誤訊息.
26896
								#$result["function"],當前執行的函式名稱.
27130
								#$result["function"],當前執行的函式名稱.
26897
								#$result["argu"],所使用的參數.
27131
								#$result["argu"],所使用的參數.
26898
								#$result["content"],執行的結果.
27132
								#$result["content"],執行的結果.
26899
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
27133
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
26900
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
27134
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
26901
								#必填參數:
27135
								#必填參數:
26902
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
27136
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
26903
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
27137
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
26904
								#$conf["name"],字串,服務名稱.
27138
								#$conf["name"],字串,服務名稱.
26905
								$conf["cmd::systemd"]["name"]=$conf["name"];
27139
								$conf["cmd::systemd"]["name"]=$conf["name"];
Line 26910... Line 27144...
26910
								#$conf["username"]="";
27144
								#$conf["username"]="";
26911
								#$conf["password"],字串,使用者的密碼,預設不使用.
27145
								#$conf["password"],字串,使用者的密碼,預設不使用.
26912
								#$conf["password"]="";
27146
								#$conf["password"]="";
26913
								$systemd=cmd::systemd($conf["cmd::systemd"]);
27147
								$systemd=cmd::systemd($conf["cmd::systemd"]);
26914
								unset($conf["cmd::systemd"]);
27148
								unset($conf["cmd::systemd"]);
26915
								
27149
 
26916
								#若運行出錯
27150
								#若運行出錯
26917
								if($systemd["status"]==="false"){
27151
								if($systemd["status"]==="false"){
26918
								
27152
 
26919
									#設置執行失敗
27153
									#設置執行失敗
26920
									$result["status"]="false";
27154
									$result["status"]="false";
26921
 
27155
 
26922
									#設置錯誤訊息
27156
									#設置錯誤訊息
26923
									$result["error"]=$systemd;
27157
									$result["error"]=$systemd;
26924
 
27158
 
26925
									#回傳結果
27159
									#回傳結果
26926
									return $result;
27160
									return $result;
26927
								
27161
 
26928
									}#if end
27162
									}#if end
26929
							
27163
 
26930
								#下一輪
27164
								#下一輪
26931
								continue;
27165
								continue;
26932
							
27166
 
26933
								}#if end
27167
								}#if end
26934
								
27168
 
26935
							}#if end
27169
							}#if end
26936
					
27170
 
26937
						#如果有指定 cmd
27171
						#如果有指定 cmd
26938
						if(isset($checkListen["cmd"])){
27172
						if(isset($checkListen["cmd"])){
26939
						
27173
 
26940
							#檢查參數
27174
							#檢查參數
26941
							#函式說明:
27175
							#函式說明:
26942
							#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
27176
							#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
26943
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27177
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
26944
							#$reuslt["error"],執行不正常結束的錯訊息陣列.
27178
							#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 27012... Line 27246...
27012
 
27246
 
27013
								#回傳結果
27247
								#回傳結果
27014
								return $result;
27248
								return $result;
27015
 
27249
 
27016
								}#if end
27250
								}#if end
27017
							
27251
 
27018
							#預設檢查不通過
27252
							#預設檢查不通過
27019
							$pass="false";
27253
							$pass="false";
27020
							
27254
 
27021
							#透過 proc 運行 cmd,並最多等待 timeout 秒.
27255
							#透過 proc 運行 cmd,並最多等待 timeout 秒.
27022
							#函式說明:
27256
							#函式說明:
27023
							#透過proc來多執行序運作.
27257
							#透過proc來多執行序運作.
27024
							#回傳結果:
27258
							#回傳結果:
27025
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27259
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 27031... Line 27265...
27031
							#$conf["cmds"],字串陣列,每個元素代表單一程序要執行的指令與參數.
27265
							#$conf["cmds"],字串陣列,每個元素代表單一程序要執行的指令與參數.
27032
							$conf["threads::proc"]["cmds"]=array($checkListen["cmd"]["cmd"]);
27266
							$conf["threads::proc"]["cmds"]=array($checkListen["cmd"]["cmd"]);
27033
							#可省略參數:
27267
							#可省略參數:
27034
							#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
27268
							#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
27035
							$conf["threads::proc"]["wait"]="true";
27269
							$conf["threads::proc"]["wait"]="true";
27036
							
27270
 
27037
							#如果有設置 timeout
27271
							#如果有設置 timeout
27038
							if(isset($checkListen["cmd"]["timeout"])){
27272
							if(isset($checkListen["cmd"]["timeout"])){
27039
							
27273
 
27040
								#$conf["timeout"],字串陣列,每個元素代表單一程序執行的最大等待秒數,超過後將會強迫停止執行,僅當wait參數為"true"時生效.
27274
								#$conf["timeout"],字串陣列,每個元素代表單一程序執行的最大等待秒數,超過後將會強迫停止執行,僅當wait參數為"true"時生效.
27041
								$conf["threads::proc"]["timeout"]=array($checkListen["cmd"]["timeout"]);
27275
								$conf["threads::proc"]["timeout"]=array($checkListen["cmd"]["timeout"]);
27042
							
27276
 
27043
								}#if end
27277
								}#if end
27044
							
27278
 
27045
							#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
27279
							#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
27046
							#$conf["workingDir"]=array("path");
27280
							#$conf["workingDir"]=array("path");
27047
							#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
27281
							#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
27048
							#$conf["envs"]=array(array("key"=>"value"));
27282
							#$conf["envs"]=array(array("key"=>"value"));
27049
							#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
27283
							#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
Line 27053... Line 27287...
27053
							#https://www.php.net/manual/en/function.proc-get-status.php
27287
							#https://www.php.net/manual/en/function.proc-get-status.php
27054
							#備註:
27288
							#備註:
27055
							#若需要取得當下的執行狀況,請使用 self::proc_update 來更新.
27289
							#若需要取得當下的執行狀況,請使用 self::proc_update 來更新.
27056
							$proc=threads::proc($conf["threads::proc"]);
27290
							$proc=threads::proc($conf["threads::proc"]);
27057
							unset($conf["threads::proc"]);
27291
							unset($conf["threads::proc"]);
27058
						
27292
 
27059
							#如果執行異常
27293
							#如果執行異常
27060
							if($proc["status"]==="false"){
27294
							if($proc["status"]==="false"){
27061
 
27295
 
27062
								#設置執行失敗
27296
								#設置執行失敗
27063
								$result["status"]="false";
27297
								$result["status"]="false";
Line 27067... Line 27301...
27067
 
27301
 
27068
								#回傳結果
27302
								#回傳結果
27069
								return $result;
27303
								return $result;
27070
 
27304
 
27071
								}#if end
27305
								}#if end
27072
							
27306
 
27073
							#如果程序結束代碼為0
27307
							#如果程序結束代碼為0
27074
							if($proc["content"][0]["statusCode"]===0){
27308
							if($proc["content"][0]["statusCode"]===0){
27075
							
27309
 
27076
								#設置檢查通過
27310
								#設置檢查通過
27077
								$pass="true";
27311
								$pass="true";
27078
							
27312
 
27079
								}#if end
27313
								}#if end
27080
							
27314
 
27081
							#如果檢查不通過
27315
							#如果檢查不通過
27082
							if($pass==="false"){
27316
							if($pass==="false"){
27083
							
27317
 
27084
								#提示問題
27318
								#提示問題
27085
								echo "service ".$conf["name"]." not pass test by commamd(".$checkListen["cmd"]["cmd"].")!".PHP_EOL;
27319
								echo "service ".$conf["name"]." not pass test by commamd(".$checkListen["cmd"]["cmd"].")!".PHP_EOL;
27086
							
27320
 
27087
								#如果要 verbose
27321
								#如果要 verbose
27088
								if($conf["verbose"]==="true"){
27322
								if($conf["verbose"]==="true"){
27089
									
27323
 
27090
									#debug
27324
									#debug
27091
									var_dump($proc);
27325
									var_dump($proc);
27092
								
27326
 
27093
									}#if end
27327
									}#if end
27094
							
27328
 
27095
								#如果只要 Report
27329
								#如果只要 Report
27096
								if($conf["reportOnly"]==="true"){
27330
								if($conf["reportOnly"]==="true"){
27097
								
27331
 
27098
									#輸出
27332
									#輸出
27099
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;;
27333
									echo "service ".$conf["name"]." need to restart!".PHP_EOL;;
27100
									
27334
 
27101
									#下一輪
27335
									#下一輪
27102
									continue;
27336
									continue;
27103
								
27337
 
27104
									}#if end
27338
									}#if end
27105
							
27339
 
27106
								#啟動服務
27340
								#啟動服務
27107
								#函式說明:
27341
								#函式說明:
27108
								#執行 systemd 程序來管理服務.
27342
								#執行 systemd 程序來管理服務.
27109
								#回傳結果:
27343
								#回傳結果:
27110
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27344
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27111
								#$result["error"],錯誤訊息.
27345
								#$result["error"],錯誤訊息.
27112
								#$result["function"],當前執行的函式名稱.
27346
								#$result["function"],當前執行的函式名稱.
27113
								#$result["argu"],所使用的參數.
27347
								#$result["argu"],所使用的參數.
27114
								#$result["content"],執行的結果.
27348
								#$result["content"],執行的結果.
27115
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
27349
								#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
27116
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
27350
								#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
27117
								#必填參數:
27351
								#必填參數:
27118
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
27352
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
27119
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
27353
								$conf["cmd::systemd"]["fileArgu"]=$conf["fileArgu"];
27120
								#$conf["name"],字串,服務名稱.
27354
								#$conf["name"],字串,服務名稱.
27121
								$conf["cmd::systemd"]["name"]=$conf["name"];
27355
								$conf["cmd::systemd"]["name"]=$conf["name"];
Line 27126... Line 27360...
27126
								#$conf["username"]="";
27360
								#$conf["username"]="";
27127
								#$conf["password"],字串,使用者的密碼,預設不使用.
27361
								#$conf["password"],字串,使用者的密碼,預設不使用.
27128
								#$conf["password"]="";
27362
								#$conf["password"]="";
27129
								$systemd=cmd::systemd($conf["cmd::systemd"]);
27363
								$systemd=cmd::systemd($conf["cmd::systemd"]);
27130
								unset($conf["cmd::systemd"]);
27364
								unset($conf["cmd::systemd"]);
27131
								
27365
 
27132
								#若運行出錯
27366
								#若運行出錯
27133
								if($systemd["status"]==="false"){
27367
								if($systemd["status"]==="false"){
27134
								
27368
 
27135
									#設置執行失敗
27369
									#設置執行失敗
27136
									$result["status"]="false";
27370
									$result["status"]="false";
27137
 
27371
 
27138
									#設置錯誤訊息
27372
									#設置錯誤訊息
27139
									$result["error"]=$systemd;
27373
									$result["error"]=$systemd;
27140
 
27374
 
27141
									#回傳結果
27375
									#回傳結果
27142
									return $result;
27376
									return $result;
27143
								
27377
 
27144
									}#if end
27378
									}#if end
27145
							
27379
 
27146
								#下一輪
27380
								#下一輪
27147
								continue;
27381
								continue;
27148
							
27382
 
27149
								}#if end
27383
								}#if end
27150
							
27384
 
27151
							}#if end
27385
							}#if end
27152
					
27386
 
27153
						#如果有 verbose
27387
						#如果有 verbose
27154
						if($conf["verbose"]==="true"){
27388
						if($conf["verbose"]==="true"){
27155
						
27389
 
27156
							#提示什麼條件檢查通過
27390
							#提示什麼條件檢查通過
27157
							echo " condition "; 
27391
							echo " condition ";
27158
							
27392
 
27159
							#針對每個條件
27393
							#針對每個條件
27160
							foreach($checkListen as $name => $value){
27394
							foreach($checkListen as $name => $value){
27161
							
27395
 
27162
								#函式說明:
27396
								#函式說明:
27163
								#回傳變數的解析結果.
27397
								#回傳變數的解析結果.
27164
								#回傳結果:
27398
								#回傳結果:
27165
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27399
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27166
								#$result["content"],變數的解析結果.
27400
								#$result["content"],變數的解析結果.
Line 27175... Line 27409...
27175
								#無.
27409
								#無.
27176
								#備註:
27410
								#備註:
27177
								#無.
27411
								#無.
27178
								$toSource=variableCheck::toSource($conf["variableCheck::toSource"]);
27412
								$toSource=variableCheck::toSource($conf["variableCheck::toSource"]);
27179
								unset($conf["variableCheck::toSource"]);
27413
								unset($conf["variableCheck::toSource"]);
27180
							
27414
 
27181
								#若運行出錯
27415
								#若運行出錯
27182
								if($toSource["status"]==="false"){
27416
								if($toSource["status"]==="false"){
27183
								
27417
 
27184
									#設置執行失敗
27418
									#設置執行失敗
27185
									$result["status"]="false";
27419
									$result["status"]="false";
27186
 
27420
 
27187
									#設置錯誤訊息
27421
									#設置錯誤訊息
27188
									$result["error"]=$toSource;
27422
									$result["error"]=$toSource;
27189
 
27423
 
27190
									#回傳結果
27424
									#回傳結果
27191
									return $result;
27425
									return $result;
27192
								
27426
 
27193
									}#if end
27427
									}#if end
27194
							
27428
 
27195
								#印出條件
27429
								#印出條件
27196
								echo $name." = ".$toSource["content"];
27430
								echo $name." = ".$toSource["content"];
27197
							
27431
 
27198
								}#for end
27432
								}#for end
27199
							
27433
 
27200
							#印出結果
27434
							#印出結果
27201
							echo " passed".PHP_EOL;
27435
							echo " passed".PHP_EOL;
27202
						
27436
 
27203
							}#if end
27437
							}#if end
27204
					
27438
 
27205
						}#foreach end
27439
						}#foreach end
27206
					
27440
 
27207
					}#if end
27441
					}#if end
27208
				
27442
 
27209
				}#if end
27443
				}#if end
27210
			
27444
 
27211
			#過30秒再檢查一次
27445
			#過30秒再檢查一次
27212
			sleep($conf["interval"]);
27446
			sleep($conf["interval"]);
27213
			
27447
 
27214
			#下一輪
27448
			#下一輪
27215
			continue;
27449
			continue;
27216
			
27450
 
27217
			}#while end
27451
			}#while end
27218
	
27452
 
27219
		}#function keepServiceUp end
27453
		}#function keepServiceUp end
27220
 
27454
 
27221
	/*
27455
	/*
27222
	#函式說明:
27456
	#函式說明:
27223
	#將要執行的程式變成透過 systemd 來運行.
27457
	#將要執行的程式變成透過 systemd 來運行.
Line 27251... Line 27485...
27251
	#無.
27485
	#無.
27252
	#備註:
27486
	#備註:
27253
	#無.
27487
	#無.
27254
	*/
27488
	*/
27255
	public static function registerService(&$conf){
27489
	public static function registerService(&$conf){
27256
	
27490
 
27257
		#初始化要回傳的結果
27491
		#初始化要回傳的結果
27258
		$result=array();
27492
		$result=array();
27259
 
27493
 
27260
		#取得當前執行的函式名稱
27494
		#取得當前執行的函式名稱
27261
		$result["function"]=__FUNCTION__;
27495
		$result["function"]=__FUNCTION__;
Line 27359... Line 27593...
27359
 
27593
 
27360
			#回傳結果
27594
			#回傳結果
27361
			return $result;
27595
			return $result;
27362
 
27596
 
27363
			}#if end
27597
			}#if end
27364
		
27598
 
27365
		#初始化要寫入到服務檔案的內容陣列
27599
		#初始化要寫入到服務檔案的內容陣列
27366
		$serviceFileContent=array();
27600
		$serviceFileContent=array();
27367
		
27601
 
27368
		#服務的 Unit 識別
27602
		#服務的 Unit 識別
27369
		$serviceFileContent[]="[Unit]";
27603
		$serviceFileContent[]="[Unit]";
27370
		
27604
 
27371
		#服務的描述
27605
		#服務的描述
27372
		$serviceFileContent[]="Description= ".$conf["description"];
27606
		$serviceFileContent[]="Description= ".$conf["description"];
27373
		
27607
 
27374
		#空一行
27608
		#空一行
27375
		$serviceFileContent[]="";
27609
		$serviceFileContent[]="";
27376
		
27610
 
27377
		#網路連線後才執行該服務
27611
		#網路連線後才執行該服務
27378
		$serviceFileContent[]="After=network-pre.target dbus.service network.target network.service httpd.service";
27612
		$serviceFileContent[]="After=network-pre.target dbus.service network.target network.service httpd.service";
27379
		
27613
 
27380
		#空一行
27614
		#空一行
27381
		$serviceFileContent[]="";
27615
		$serviceFileContent[]="";
27382
		
27616
 
27383
		#服務的 Service 識別
27617
		#服務的 Service 識別
27384
		$serviceFileContent[]="[Service]";
27618
		$serviceFileContent[]="[Service]";
27385
		
27619
 
27386
		#服務類型
27620
		#服務類型
27387
		$serviceFileContent[]="Type=simple";
27621
		$serviceFileContent[]="Type=simple";
27388
		
27622
 
27389
		#用root身份執行
27623
		#用root身份執行
27390
		$serviceFileContent[]="User=root";
27624
		$serviceFileContent[]="User=root";
27391
		
27625
 
27392
		#指定要用/bin/bash來執行腳本
27626
		#指定要用/bin/bash來執行腳本
27393
		$fullCmd="#!/bin/bash";
27627
		$fullCmd="#!/bin/bash";
27394
		
27628
 
27395
		#針對每的程式
27629
		#針對每的程式
27396
		foreach($conf["cmds"] as $index => $bin){
27630
		foreach($conf["cmds"] as $index => $bin){
27397
		
27631
 
27398
			#函式說明:
27632
			#函式說明:
27399
			#呼叫shell執行系統命令,並取得回傳的內容.
27633
			#呼叫shell執行系統命令,並取得回傳的內容.
27400
			#回傳結果:
27634
			#回傳結果:
27401
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27635
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27402
			#$result["error"],錯誤訊息陣列.
27636
			#$result["error"],錯誤訊息陣列.
Line 27414... Line 27648...
27414
			#$conf["command"],字串,要執行的指令.
27648
			#$conf["command"],字串,要執行的指令.
27415
			$conf["external::callShell"]["command"]=$bin;
27649
			$conf["external::callShell"]["command"]=$bin;
27416
			#$conf["fileArgu"],字串,變數__FILE__的內容.
27650
			#$conf["fileArgu"],字串,變數__FILE__的內容.
27417
			$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
27651
			$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
27418
			#可省略參數:
27652
			#可省略參數:
27419
			
27653
 
27420
			#如果有指定參數
27654
			#如果有指定參數
27421
			if(isset($conf["params"])){
27655
			if(isset($conf["params"])){
27422
			
27656
 
27423
				#如果該程式有對應的參數陣列
27657
				#如果該程式有對應的參數陣列
27424
				if(isset($conf["params"][$index])){
27658
				if(isset($conf["params"][$index])){
27425
				
27659
 
27426
					#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
27660
					#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
27427
					$conf["external::callShell"]["argu"]=$conf["params"][$index];
27661
					$conf["external::callShell"]["argu"]=$conf["params"][$index];
27428
				
27662
 
27429
					}#if end
27663
					}#if end
27430
				
27664
 
27431
				}#if end
27665
				}#if end
27432
			
27666
 
27433
			#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
27667
			#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
27434
			#$conf["arguIsAddr"]=array();
27668
			#$conf["arguIsAddr"]=array();
27435
			#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
27669
			#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
27436
			#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
27670
			#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
27437
			#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
27671
			#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
Line 27464... Line 27698...
27464
			#備註:
27698
			#備註:
27465
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
27699
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
27466
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
27700
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
27467
			$callShell=external::callShell($conf["external::callShell"]);
27701
			$callShell=external::callShell($conf["external::callShell"]);
27468
			unset($conf["external::callShell"]);
27702
			unset($conf["external::callShell"]);
27469
			
27703
 
27470
			#如果檢查參數失敗
27704
			#如果檢查參數失敗
27471
			if($callShell["status"]==="false"){
27705
			if($callShell["status"]==="false"){
27472
 
27706
 
27473
				#設置執行失敗
27707
				#設置執行失敗
27474
				$result["status"]="false";
27708
				$result["status"]="false";
Line 27478... Line 27712...
27478
 
27712
 
27479
				#回傳結果
27713
				#回傳結果
27480
				return $result;
27714
				return $result;
27481
 
27715
 
27482
				}#if end
27716
				}#if end
27483
			
27717
 
27484
			#組合完整指令字串
27718
			#組合完整指令字串
27485
			#函式說明:
27719
			#函式說明:
27486
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
27720
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
27487
			#回傳的結果:
27721
			#回傳的結果:
27488
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27722
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 27504... Line 27738...
27504
			#無.
27738
			#無.
27505
			#備註:
27739
			#備註:
27506
			#無.
27740
			#無.
27507
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
27741
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
27508
			unset($conf["arrays::arrayToString"]);
27742
			unset($conf["arrays::arrayToString"]);
27509
			
27743
 
27510
			#如果轉換成字串失敗
27744
			#如果轉換成字串失敗
27511
			if($arrayToString["status"]==="false"){
27745
			if($arrayToString["status"]==="false"){
27512
 
27746
 
27513
				#設置執行失敗
27747
				#設置執行失敗
27514
				$result["status"]="false";
27748
				$result["status"]="false";
Line 27518... Line 27752...
27518
 
27752
 
27519
				#回傳結果
27753
				#回傳結果
27520
				return $result;
27754
				return $result;
27521
 
27755
 
27522
				}#if end
27756
				}#if end
27523
			
27757
 
27524
			#串接指令
27758
			#串接指令
27525
			$fullCmd=$fullCmd.PHP_EOL.$arrayToString["content"];
27759
			$fullCmd=$fullCmd.PHP_EOL.$arrayToString["content"];
27526
		
27760
 
27527
			}#foreach end
27761
			}#foreach end
27528
		
27762
 
27529
		#path of bin for systemctl 
27763
		#path of bin for systemctl
27530
		$pathOfBinForSystemctl="/var/qbpwcf/bin_for_systemctl/";
27764
		$pathOfBinForSystemctl="/var/qbpwcf/bin_for_systemctl/";
27531
 
27765
 
27532
		#bin of service path
27766
		#bin of service path
27533
		$binOfServicePath=$pathOfBinForSystemctl.$conf["name"].".sh";
27767
		$binOfServicePath=$pathOfBinForSystemctl.$conf["name"].".sh";
27534
		
27768
 
27535
		#建立啟動該服務的腳本
27769
		#建立啟動該服務的腳本
27536
		#函式說明:
27770
		#函式說明:
27537
		#將字串寫入到檔案
27771
		#將字串寫入到檔案
27538
		#回傳結果:
27772
		#回傳結果:
27539
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
27773
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 27566... Line 27800...
27566
		#無.
27800
		#無.
27567
		#備註:
27801
		#備註:
27568
		#無.
27802
		#無.
27569
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
27803
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
27570
		unset($conf["fileAccess::writeTextIntoFile"]);
27804
		unset($conf["fileAccess::writeTextIntoFile"]);
27571
		
27805
 
27572
		#如果建立腳本檔案失敗
27806
		#如果建立腳本檔案失敗
27573
		if($writeTextIntoFile["status"]==="false"){
27807
		if($writeTextIntoFile["status"]==="false"){
27574
 
27808
 
27575
			#設置執行失敗
27809
			#設置執行失敗
27576
			$result["status"]="false";
27810
			$result["status"]="false";
Line 27580... Line 27814...
27580
 
27814
 
27581
			#回傳結果
27815
			#回傳結果
27582
			return $result;
27816
			return $result;
27583
 
27817
 
27584
			}#if end
27818
			}#if end
27585
			
27819
 
27586
		#設置該腳本可以被執行
27820
		#設置該腳本可以被執行
27587
		#函式說明:
27821
		#函式說明:
27588
		#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
27822
		#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
27589
		#回傳結果:
27823
		#回傳結果:
27590
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27824
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 27605... Line 27839...
27605
		#無.
27839
		#無.
27606
		#備註:
27840
		#備註:
27607
		#無.
27841
		#無.
27608
		$chmod=cmd::chmod($conf["cmd::chmod"]);
27842
		$chmod=cmd::chmod($conf["cmd::chmod"]);
27609
		unset($conf["cmd::chmod"]);
27843
		unset($conf["cmd::chmod"]);
27610
		
27844
 
27611
		#如果執行異常
27845
		#如果執行異常
27612
		if($chmod["status"]==="false"){
27846
		if($chmod["status"]==="false"){
27613
 
27847
 
27614
			#設置執行失敗
27848
			#設置執行失敗
27615
			$result["status"]="false";
27849
			$result["status"]="false";
Line 27619... Line 27853...
27619
 
27853
 
27620
			#回傳結果
27854
			#回傳結果
27621
			return $result;
27855
			return $result;
27622
 
27856
 
27623
			}#if end
27857
			}#if end
27624
		
27858
 
27625
		#要執行的程式與參數
27859
		#要執行的程式與參數
27626
		$serviceFileContent[]="ExecStart=".$binOfServicePath;
27860
		$serviceFileContent[]="ExecStart=".$binOfServicePath;
27627
		
27861
 
27628
		#重新執行的程式與參數
27862
		#重新執行的程式與參數
27629
		$serviceFileContent[]="ExecReload=killall ".$binOfServicePath."; sleep 10; ".$binOfServicePath;
27863
		$serviceFileContent[]="ExecReload=killall ".$binOfServicePath."; sleep 10; ".$binOfServicePath;
27630
		
27864
 
27631
		#執行失敗後,會再次嘗試執行
27865
		#執行失敗後,會再次嘗試執行
27632
		$serviceFileContent[]="Restart=on-failure";
27866
		$serviceFileContent[]="Restart=on-failure";
27633
		
27867
 
27634
		#沒有timeout
27868
		#沒有timeout
27635
		$serviceFileContent[]="TimeoutSec=infinity";
27869
		$serviceFileContent[]="TimeoutSec=infinity";
27636
		
27870
 
27637
		#空一行
27871
		#空一行
27638
		$serviceFileContent[]="";
27872
		$serviceFileContent[]="";
27639
		
27873
 
27640
		#服務的 Install 識別
27874
		#服務的 Install 識別
27641
		$serviceFileContent[]="[Install]";
27875
		$serviceFileContent[]="[Install]";
27642
		
27876
 
27643
		#預設為 multi-user.target
27877
		#預設為 multi-user.target
27644
		$serviceFileContent[]="WantedBy=multi-user.target";
27878
		$serviceFileContent[]="WantedBy=multi-user.target";
27645
		
27879
 
27646
		#建立 service 檔案 
27880
		#建立 service 檔案
27647
		#函式說明:
27881
		#函式說明:
27648
		#將多行字串寫入到檔案
27882
		#將多行字串寫入到檔案
27649
		#回傳結果:
27883
		#回傳結果:
27650
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
27884
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
27651
		#$result["error"],錯誤訊息陣列.
27885
		#$result["error"],錯誤訊息陣列.
Line 27663... Line 27897...
27663
		#無.
27897
		#無.
27664
		#備註:
27898
		#備註:
27665
		#無.
27899
		#無.
27666
		$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
27900
		$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
27667
		unset($conf["fileAccess::writeMultiLine"]);
27901
		unset($conf["fileAccess::writeMultiLine"]);
27668
		
27902
 
27669
		#如果建立服務檔案失敗
27903
		#如果建立服務檔案失敗
27670
		if($writeMultiLine["status"]==="false"){
27904
		if($writeMultiLine["status"]==="false"){
27671
 
27905
 
27672
			#設置執行失敗
27906
			#設置執行失敗
27673
			$result["status"]="false";
27907
			$result["status"]="false";
Line 27677... Line 27911...
27677
 
27911
 
27678
			#回傳結果
27912
			#回傳結果
27679
			return $result;
27913
			return $result;
27680
 
27914
 
27681
			}#if end
27915
			}#if end
27682
		
27916
 
27683
		#如果要 enable 服務
27917
		#如果要 enable 服務
27684
		if($conf["enable"]==="true"){
27918
		if($conf["enable"]==="true"){
27685
		
27919
 
27686
			#啟用服務
27920
			#啟用服務
27687
			#函式說明:
27921
			#函式說明:
27688
			#呼叫shell執行系統命令,並取得回傳的內容.
27922
			#呼叫shell執行系統命令,並取得回傳的內容.
27689
			#回傳結果:
27923
			#回傳結果:
27690
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27924
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 27741... Line 27975...
27741
			#備註:
27975
			#備註:
27742
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
27976
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
27743
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
27977
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
27744
			$callShell=external::callShell($conf["external::callShell"]);
27978
			$callShell=external::callShell($conf["external::callShell"]);
27745
			unset($conf["external::callShell"]);
27979
			unset($conf["external::callShell"]);
27746
		
27980
 
27747
			#如果執行失敗
27981
			#如果執行失敗
27748
			if($callShell["status"]==="false"){
27982
			if($callShell["status"]==="false"){
27749
 
27983
 
27750
				#設置執行失敗
27984
				#設置執行失敗
27751
				$result["status"]="false";
27985
				$result["status"]="false";
Line 27755... Line 27989...
27755
 
27989
 
27756
				#回傳結果
27990
				#回傳結果
27757
				return $result;
27991
				return $result;
27758
 
27992
 
27759
				}#if end
27993
				}#if end
27760
		
27994
 
27761
			}#if end
27995
			}#if end
27762
		
27996
 
27763
		#如果要馬上 start 服務
27997
		#如果要馬上 start 服務
27764
		if($conf["startNow"]){
27998
		if($conf["startNow"]){
27765
		
27999
 
27766
			#啟動服務
28000
			#啟動服務
27767
			#函式說明:
28001
			#函式說明:
27768
			#呼叫shell執行系統命令,並取得回傳的內容.
28002
			#呼叫shell執行系統命令,並取得回傳的內容.
27769
			#回傳結果:
28003
			#回傳結果:
27770
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28004
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 27821... Line 28055...
27821
			#備註:
28055
			#備註:
27822
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
28056
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
27823
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
28057
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
27824
			$callShell=external::callShell($conf["external::callShell"]);
28058
			$callShell=external::callShell($conf["external::callShell"]);
27825
			unset($conf["external::callShell"]);
28059
			unset($conf["external::callShell"]);
27826
		
28060
 
27827
			#如果執行失敗
28061
			#如果執行失敗
27828
			if($callShell["status"]==="false"){
28062
			if($callShell["status"]==="false"){
27829
 
28063
 
27830
				#設置執行失敗
28064
				#設置執行失敗
27831
				$result["status"]="false";
28065
				$result["status"]="false";
Line 27835... Line 28069...
27835
 
28069
 
27836
				#回傳結果
28070
				#回傳結果
27837
				return $result;
28071
				return $result;
27838
 
28072
 
27839
				}#if end
28073
				}#if end
27840
		
28074
 
27841
			}#if end
28075
			}#if end
27842
		
28076
 
27843
		#如果 keepServiceUp 為 "true"
28077
		#如果 keepServiceUp 為 "true"
27844
		if($conf["keepServiceUp"]==="true"){
28078
		if($conf["keepServiceUp"]==="true"){
27845
			
28079
 
27846
			#檢查用於 cmd::keepServiceUp 的參數
28080
			#檢查用於 cmd::keepServiceUp 的參數
27847
			#函式說明:
28081
			#函式說明:
27848
			#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
28082
			#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
27849
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28083
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
27850
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
28084
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 27918... Line 28152...
27918
 
28152
 
27919
				#回傳結果
28153
				#回傳結果
27920
				return $result;
28154
				return $result;
27921
 
28155
 
27922
				}#if end
28156
				}#if end
27923
	
28157
 
27924
			#取得 lib folder
28158
			#取得 lib folder
27925
			exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../bin/libexec/folderOfUsrLib.php"),$output,$status);
28159
			exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../bin/libexec/folderOfUsrLib.php"),$output,$status);
27926
 
28160
 
27927
			#如果執行失敗
28161
			#如果執行失敗
27928
			if($status!==0){
28162
			if($status!==0){
Line 27950... Line 28184...
27950
 
28184
 
27951
				#結束執行,回傳shell 1.
28185
				#結束執行,回傳shell 1.
27952
				exit(1);
28186
				exit(1);
27953
 
28187
 
27954
				}#if end
28188
				}#if end
27955
				
28189
 
27956
			#儲存base64 encode 後 lib 的 path
28190
			#儲存base64 encode 後 lib 的 path
27957
			$base64EncodedLibIncludePath=base64_encode($output[0]);
28191
			$base64EncodedLibIncludePath=base64_encode($output[0]);
27958
				
28192
 
27959
			#要執行的php程式內容
28193
			#要執行的php程式內容
27960
			$phpScript2run=<<<'PHP'
28194
			$phpScript2run=<<<'PHP'
27961
		
28195
 
27962
#用於確保服務在線的程式 - start
28196
#用於確保服務在線的程式 - start
27963
 
28197
 
27964
#宣告命名空間
28198
#宣告命名空間
27965
namespace qbpwcf;
28199
namespace qbpwcf;
27966
 
28200
 
27967
#設置 include path 
28201
#設置 include path
27968
set_include_path(base64_decode("
28202
set_include_path(base64_decode("
27969
PHP;
28203
PHP;
27970
 
28204
 
27971
#串接 base64 encode 後 lib 的 path
28205
#串接 base64 encode 後 lib 的 path
27972
$phpScript2run=$phpScript2run.$base64EncodedLibIncludePath;
28206
$phpScript2run=$phpScript2run.$base64EncodedLibIncludePath;
Line 28048... Line 28282...
28048
 
28282
 
28049
	}#if end
28283
	}#if end
28050
 
28284
 
28051
#用於確保服務在線的程式 - end
28285
#用於確保服務在線的程式 - end
28052
PHP;
28286
PHP;
28053
			
28287
 
28054
			#遞迴呼叫,建立用於確保 $conf[name] 服務在線的服務
28288
			#遞迴呼叫,建立用於確保 $conf[name] 服務在線的服務
28055
			#函式說明:
28289
			#函式說明:
28056
			#將要執行的程式變成透過 systemd 來運行.
28290
			#將要執行的程式變成透過 systemd 來運行.
28057
			#回傳結果:
28291
			#回傳結果:
28058
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28292
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 28083... Line 28317...
28083
			#參考資料:
28317
			#參考資料:
28084
			#無.
28318
			#無.
28085
			#備註:
28319
			#備註:
28086
			#無.
28320
			#無.
28087
			$registerService=cmd::registerService($paramsOfRegisterService);
28321
			$registerService=cmd::registerService($paramsOfRegisterService);
28088
		
28322
 
28089
			#如果執行異常
28323
			#如果執行異常
28090
			if($registerService["status"]==="false"){
28324
			if($registerService["status"]==="false"){
28091
 
28325
 
28092
				#設置執行失敗
28326
				#設置執行失敗
28093
				$result["status"]="false";
28327
				$result["status"]="false";
Line 28097... Line 28331...
28097
 
28331
 
28098
				#回傳結果
28332
				#回傳結果
28099
				return $result;
28333
				return $result;
28100
 
28334
 
28101
				}#if end
28335
				}#if end
28102
		
28336
 
28103
			#記錄運行 cmd::keepServiceUp 的回傳結果
28337
			#記錄運行 cmd::keepServiceUp 的回傳結果
28104
			$result["content"]=$registerService;
28338
			$result["content"]=$registerService;
28105
		
28339
 
28106
			}#if end
28340
			}#if end
28107
		
28341
 
28108
		#設置執行正常
28342
		#設置執行正常
28109
		$result["status"]="true";
28343
		$result["status"]="true";
28110
		
28344
 
28111
		#回傳結果
28345
		#回傳結果
28112
		return $result;
28346
		return $result;
28113
	
28347
 
28114
		}#function registerService end
28348
		}#function registerService end
28115
 
28349
 
28116
	/*
28350
	/*
28117
	#函式說明:
28351
	#函式說明:
28118
	#透過 ping -c 3 -I [ppp0/網路界面名稱] 1.1.1.1 ,來判斷是否該界面有跟外部連線。
28352
	#透過 ping -c 3 -I [ppp0/網路界面名稱] 1.1.1.1 ,來判斷是否該界面有跟外部連線。
Line 28134... Line 28368...
28134
	#無.
28368
	#無.
28135
	#備註:
28369
	#備註:
28136
	#無.
28370
	#無.
28137
	*/
28371
	*/
28138
	public static function pingOutsideTest(&$conf){
28372
	public static function pingOutsideTest(&$conf){
28139
	
28373
 
28140
		#初始化要回傳的結果
28374
		#初始化要回傳的結果
28141
		$result=array();
28375
		$result=array();
28142
 
28376
 
28143
		#取得當前執行的函式名稱
28377
		#取得當前執行的函式名稱
28144
		$result["function"]=__FUNCTION__;
28378
		$result["function"]=__FUNCTION__;
Line 28242... Line 28476...
28242
 
28476
 
28243
			#回傳結果
28477
			#回傳結果
28244
			return $result;
28478
			return $result;
28245
 
28479
 
28246
			}#if end
28480
			}#if end
28247
			
28481
 
28248
		#函式說明:
28482
		#函式說明:
28249
		#呼叫shell執行系統命令,並取得回傳的內容.
28483
		#呼叫shell執行系統命令,並取得回傳的內容.
28250
		#回傳的結果:
28484
		#回傳的結果:
28251
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28485
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28252
		#$result["error"],錯誤訊息陣列.
28486
		#$result["error"],錯誤訊息陣列.
Line 28261... Line 28495...
28261
		#$result["statusCode"],執行結束後的代碼.
28495
		#$result["statusCode"],執行結束後的代碼.
28262
		#必填參數
28496
		#必填參數
28263
		#$conf["command"],字串,要執行的指令與.
28497
		#$conf["command"],字串,要執行的指令與.
28264
		$conf["external::callShell"]["command"]="ping";
28498
		$conf["external::callShell"]["command"]="ping";
28265
		#$conf["fileArgu"],字串,變數__FILE__的內容.
28499
		#$conf["fileArgu"],字串,變數__FILE__的內容.
28266
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
28500
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
28267
		#可省略參數:
28501
		#可省略參數:
28268
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
28502
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
28269
		$conf["external::callShell"]["argu"]=array("-c","3","-I",$conf["interface"],$conf["pingTarget"]);
28503
		$conf["external::callShell"]["argu"]=array("-c","3","-I",$conf["interface"],$conf["pingTarget"]);
28270
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
28504
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
28271
		#$conf["arguIsAddr"]=array();	
28505
		#$conf["arguIsAddr"]=array();
28272
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
28506
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
28273
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
28507
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
28274
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
28508
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
28275
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
28509
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
28276
		#$conf["enablePrintDescription"]="true";
28510
		#$conf["enablePrintDescription"]="true";
Line 28299... Line 28533...
28299
		$callShell=external::callShell($conf["external::callShell"]);
28533
		$callShell=external::callShell($conf["external::callShell"]);
28300
		unset($conf["external::callShell"]);
28534
		unset($conf["external::callShell"]);
28301
 
28535
 
28302
		#如果運行失敗
28536
		#如果運行失敗
28303
		if($callShell["status"]==="false"){
28537
		if($callShell["status"]==="false"){
28304
		
28538
 
28305
			#設置執行失敗
28539
			#設置執行失敗
28306
			$result["status"]="false";
28540
			$result["status"]="false";
28307
 
28541
 
28308
			#設置錯誤訊息
28542
			#設置錯誤訊息
28309
			$result["error"]=$callShell;
28543
			$result["error"]=$callShell;
28310
 
28544
 
28311
			#回傳結果
28545
			#回傳結果
28312
			return $result;
28546
			return $result;
28313
			
28547
 
28314
						
28548
 
28315
			}#if end
28549
			}#if end
28316
			
28550
 
28317
		#取得運行結果
28551
		#取得運行結果
28318
		$result["content"]=$callShell["output"];
28552
		$result["content"]=$callShell["output"];
28319
		
28553
 
28320
		#設置執行成功
28554
		#設置執行成功
28321
		$result["status"]="true";
28555
		$result["status"]="true";
28322
		
28556
 
28323
		#回傳結果
28557
		#回傳結果
28324
		return $result;
28558
		return $result;
28325
		
28559
 
28326
		}#function pingOutsideTest end
28560
		}#function pingOutsideTest end
28327
	
28561
 
28328
	/*
28562
	/*
28329
	#函式說明:
28563
	#函式說明:
28330
	#變更word press網站的所有資訊為新的 domain name.
28564
	#變更word press網站的所有資訊為新的 domain name.
28331
	#回傳結果:
28565
	#回傳結果:
28332
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28566
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 28348... Line 28582...
28348
	#無.
28582
	#無.
28349
	#備註:
28583
	#備註:
28350
	#建構中...
28584
	#建構中...
28351
	*/
28585
	*/
28352
	public static function changeWordPressDomain(&$conf){
28586
	public static function changeWordPressDomain(&$conf){
28353
	
28587
 
28354
		#初始化要回傳的結果
28588
		#初始化要回傳的結果
28355
		$result=array();
28589
		$result=array();
28356
 
28590
 
28357
		#取得當前執行的函式名稱
28591
		#取得當前執行的函式名稱
28358
		$result["function"]=__FUNCTION__;
28592
		$result["function"]=__FUNCTION__;
Line 28455... Line 28689...
28455
			$result["error"]=$checkArguments;
28689
			$result["error"]=$checkArguments;
28456
 
28690
 
28457
			#回傳結果
28691
			#回傳結果
28458
			return $result;
28692
			return $result;
28459
 
28693
 
28460
			}#if end	
28694
			}#if end
28461
			
28695
 
28462
		#要尋找的db參數
28696
		#要尋找的db參數
28463
		$dbParams=array("DB_NAME","DB_USER","DB_PASSWORD","DB_HOST");	
28697
		$dbParams=array("DB_NAME","DB_USER","DB_PASSWORD","DB_HOST");
28464
			
28698
 
28465
		#函式說明:
28699
		#函式說明:
28466
		#解析PHP檔案裡面的變數.
28700
		#解析PHP檔案裡面的變數.
28467
		#回傳結果:
28701
		#回傳結果:
28468
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28702
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28469
		#$result["error"],錯誤訊息.
28703
		#$result["error"],錯誤訊息.
28470
		#$result["function"],當前執行的函式名稱.
28704
		#$result["function"],當前執行的函式名稱.
28471
		#$result["argu"],所使用的參數.	
28705
		#$result["argu"],所使用的參數.
28472
		#$result["content"],找到的變數內容陣列.
28706
		#$result["content"],找到的變數內容陣列.
28473
		#$result["content"]["value"],依找到變數順序的數值.
28707
		#$result["content"]["value"],依找到變數順序的數值.
28474
		#$result["content"]["struc"],依找到變數順序的階層結構.
28708
		#$result["content"]["struc"],依找到變數順序的階層結構.
28475
		#$result["content"]["direct],變數名稱對應的數值內容.
28709
		#$result["content"]["direct],變數名稱對應的數值內容.
28476
		#必填參數:
28710
		#必填參數:
Line 28485... Line 28719...
28485
		#$conf["web"]="true";
28719
		#$conf["web"]="true";
28486
		#參考資料:
28720
		#參考資料:
28487
		#https://www.php.net/manual/en/function.parse-str.php
28721
		#https://www.php.net/manual/en/function.parse-str.php
28488
		$parseVaraiableInPHPfile=fileAccess::parseVaraiableInPHPfile($conf["fileAccess::parseVaraiableInPHPfile"]);
28722
		$parseVaraiableInPHPfile=fileAccess::parseVaraiableInPHPfile($conf["fileAccess::parseVaraiableInPHPfile"]);
28489
		unset($conf["fileAccess::parseVaraiableInPHPfile"]);
28723
		unset($conf["fileAccess::parseVaraiableInPHPfile"]);
28490
	
28724
 
28491
		#如果解析 php 變數失敗
28725
		#如果解析 php 變數失敗
28492
		if($parseVaraiableInPHPfile["status"]==="false"){
28726
		if($parseVaraiableInPHPfile["status"]==="false"){
28493
		
28727
 
28494
			#設置執行失敗
28728
			#設置執行失敗
28495
			$result["status"]="false";
28729
			$result["status"]="false";
28496
 
28730
 
28497
			#設置錯誤訊息
28731
			#設置錯誤訊息
28498
			$result["error"]=$parseVaraiableInPHPfile;
28732
			$result["error"]=$parseVaraiableInPHPfile;
28499
 
28733
 
28500
			#回傳結果
28734
			#回傳結果
28501
			return $result;
28735
			return $result;
28502
		
28736
 
28503
			}#if end
28737
			}#if end
28504
			
28738
 
28505
		#針對每個要尋找的資料庫連線變數
28739
		#針對每個要尋找的資料庫連線變數
28506
		foreach($dbParams as $varName){
28740
		foreach($dbParams as $varName){
28507
		
28741
 
28508
			#如果要尋找的資料庫參數不存在
28742
			#如果要尋找的資料庫參數不存在
28509
			if(!isset($parseVaraiableInPHPfile["content"]["direct"][$varName])){
28743
			if(!isset($parseVaraiableInPHPfile["content"]["direct"][$varName])){
28510
			
28744
 
28511
				#設置執行失敗
28745
				#設置執行失敗
28512
				$result["status"]="false";
28746
				$result["status"]="false";
28513
 
28747
 
28514
				#設置錯誤訊息
28748
				#設置錯誤訊息
28515
				$result["error"]=$parseVaraiableInPHPfile;
28749
				$result["error"]=$parseVaraiableInPHPfile;
28516
 
28750
 
28517
				#回傳結果
28751
				#回傳結果
28518
				return $result;
28752
				return $result;
28519
			
28753
 
28520
				}#if end
28754
				}#if end
28521
		
28755
 
28522
			#設置變數名稱
28756
			#設置變數名稱
28523
			$$varName=$parseVaraiableInPHPfile["content"]["direct"][$varName];
28757
			$$varName=$parseVaraiableInPHPfile["content"]["direct"][$varName];
28524
		
28758
 
28525
			}#foreach end
28759
			}#foreach end
28526
		
28760
 
28527
		#update wp_options table start
28761
		#update wp_options table start
28528
			
28762
 
28529
		#函式說明:
28763
		#函式說明:
28530
		#一次取得資料庫、表的資料
28764
		#一次取得資料庫、表的資料
28531
		#回傳的結果
28765
		#回傳的結果
28532
		#$result["status"],執行結果"true"為成功;"false"為執行失敗。
28766
		#$result["status"],執行結果"true"為成功;"false"為執行失敗。
28533
		#$result["error"],錯誤訊息陣列。
28767
		#$result["error"],錯誤訊息陣列。
Line 28581... Line 28815...
28581
		#$conf["numLimit"]="30";
28815
		#$conf["numLimit"]="30";
28582
		#$conf["groupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
28816
		#$conf["groupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
28583
		#$conf["groupBy"]=array("");
28817
		#$conf["groupBy"]=array("");
28584
		$fastGetDbData=db::fastGetDbData($conf["db::fastGetDbData"]);
28818
		$fastGetDbData=db::fastGetDbData($conf["db::fastGetDbData"]);
28585
		unset($conf["db::fastGetDbData"]);
28819
		unset($conf["db::fastGetDbData"]);
28586
	
28820
 
28587
		#如果查詢失敗
28821
		#如果查詢失敗
28588
		if($fastGetDbData["status"]==="false"){
28822
		if($fastGetDbData["status"]==="false"){
28589
		
28823
 
28590
			#設置執行失敗
28824
			#設置執行失敗
28591
			$result["status"]="false";
28825
			$result["status"]="false";
28592
 
28826
 
28593
			#設置錯誤訊息
28827
			#設置錯誤訊息
28594
			$result["error"]=$fastGetDbData;
28828
			$result["error"]=$fastGetDbData;
28595
 
28829
 
28596
			#回傳結果
28830
			#回傳結果
28597
			return $result;
28831
			return $result;
28598
		
28832
 
28599
			}#if end
28833
			}#if end
28600
			
28834
 
28601
		#針對每筆資料
28835
		#針對每筆資料
28602
		foreach($fastGetDbData["dataContent"]["option_value"] as $index=>$value){
28836
		foreach($fastGetDbData["dataContent"]["option_value"] as $index=>$value){
28603
			
28837
 
28604
			#遇到空字串
28838
			#遇到空字串
28605
			if($value===""){
28839
			if($value===""){
28606
			
28840
 
28607
				#跳過
28841
				#跳過
28608
				continue;
28842
				continue;
28609
			
28843
 
28610
				}#if end
28844
				}#if end
28611
		
28845
 
28612
			#函式說明:
28846
			#函式說明:
28613
			#處理字串避免網頁出錯
28847
			#處理字串避免網頁出錯
28614
			#回傳的結果:
28848
			#回傳的結果:
28615
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28849
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28616
			#$result["function"],當前執行的函式.
28850
			#$result["function"],當前執行的函式.
28617
			#$result["content"],爲處理好的字串.
28851
			#$result["content"],爲處理好的字串.
28618
			#$result["error"],錯誤訊息陣列.
28852
			#$result["error"],錯誤訊息陣列.
28619
			#$result["argu"],使用的參數. 
28853
			#$result["argu"],使用的參數.
28620
			#必填參數:
28854
			#必填參數:
28621
			$conf["stringProcess::correctCharacter"]["stringIn"]=$value;#爲要處理的字串
28855
			$conf["stringProcess::correctCharacter"]["stringIn"]=$value;#爲要處理的字串
28622
			#可省略參數:
28856
			#可省略參數:
28623
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array($conf["oldDomain"]);#爲被選擇要處理的字串/字元,須爲陣列值。
28857
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array($conf["oldDomain"]);#爲被選擇要處理的字串/字元,須爲陣列值。
28624
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
28858
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
Line 28626... Line 28860...
28626
			$conf["stringProcess::correctCharacter"]["changeTo"]=array($conf["newDomain"]);#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
28860
			$conf["stringProcess::correctCharacter"]["changeTo"]=array($conf["newDomain"]);#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
28627
			#備註:
28861
			#備註:
28628
			#無.
28862
			#無.
28629
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
28863
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
28630
			unset($conf["stringProcess::correctCharacter"]);
28864
			unset($conf["stringProcess::correctCharacter"]);
28631
		
28865
 
28632
			#如果查詢失敗
28866
			#如果查詢失敗
28633
			if($correctCharacter["status"]==="false"){
28867
			if($correctCharacter["status"]==="false"){
28634
			
28868
 
28635
				#設置執行失敗
28869
				#設置執行失敗
28636
				$result["status"]="false";
28870
				$result["status"]="false";
28637
 
28871
 
28638
				#設置錯誤訊息
28872
				#設置錯誤訊息
28639
				$result["error"]=$correctCharacter;
28873
				$result["error"]=$correctCharacter;
28640
 
28874
 
28641
				#回傳結果
28875
				#回傳結果
28642
				return $result;
28876
				return $result;
28643
			
28877
 
28644
				}#if end
28878
				}#if end
28645
		
28879
 
28646
			#取得處理好的內容
28880
			#取得處理好的內容
28647
			$value=$correctCharacter["content"];
28881
			$value=$correctCharacter["content"];
28648
		
28882
 
28649
			#函式說明:	
28883
			#函式說明:
28650
			#更新資料表裏面的資料
28884
			#更新資料表裏面的資料
28651
			#回傳的結果:	
28885
			#回傳的結果:
28652
			#$result["status"],爲查詢是否成功,若爲0則成功,若爲1則表示失敗了
28886
			#$result["status"],爲查詢是否成功,若爲0則成功,若爲1則表示失敗了
28653
			#$result["error"],錯誤訊息
28887
			#$result["error"],錯誤訊息
28654
			#$result["function"],當前執行的函式名稱
28888
			#$result["function"],當前執行的函式名稱
28655
			#$result["sql"],執行的sql語法.
28889
			#$result["sql"],執行的sql語法.
28656
			#必填參數:
28890
			#必填參數:
Line 28677... Line 28911...
28677
			$conf["db::updateDataTableContent"]["dbPassword"]=$DB_PASSWORD;
28911
			$conf["db::updateDataTableContent"]["dbPassword"]=$DB_PASSWORD;
28678
			#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的port 3306.
28912
			#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的port 3306.
28679
			#$conf["dbPort"]=$dbPort;
28913
			#$conf["dbPort"]=$dbPort;
28680
			$updateDataTableContent=db::updateDataTableContent($conf["db::updateDataTableContent"]);
28914
			$updateDataTableContent=db::updateDataTableContent($conf["db::updateDataTableContent"]);
28681
			unset($conf["db::updateDataTableContent"]);
28915
			unset($conf["db::updateDataTableContent"]);
28682
		
28916
 
28683
			#如果更新失敗
28917
			#如果更新失敗
28684
			if($updateDataTableContent["status"]==="false"){
28918
			if($updateDataTableContent["status"]==="false"){
28685
			
28919
 
28686
				#設置執行失敗
28920
				#設置執行失敗
28687
				$result["status"]="false";
28921
				$result["status"]="false";
28688
 
28922
 
28689
				#設置錯誤訊息
28923
				#設置錯誤訊息
28690
				$result["error"]=$updateDataTableContent;
28924
				$result["error"]=$updateDataTableContent;
28691
 
28925
 
28692
				#回傳結果
28926
				#回傳結果
28693
				return $result;
28927
				return $result;
28694
			
28928
 
28695
				}#if end
28929
				}#if end
28696
				
28930
 
28697
			}#foreach end
28931
			}#foreach end
28698
	
28932
 
28699
		#update wp_options table end
28933
		#update wp_options table end
28700
		
28934
 
28701
		#update wp_posts table post_content col start
28935
		#update wp_posts table post_content col start
28702
			
28936
 
28703
		#函式說明:
28937
		#函式說明:
28704
		#一次取得資料庫、表的資料
28938
		#一次取得資料庫、表的資料
28705
		#回傳的結果
28939
		#回傳的結果
28706
		#$result["status"],執行結果"true"為成功;"false"為執行失敗。
28940
		#$result["status"],執行結果"true"為成功;"false"為執行失敗。
28707
		#$result["error"],錯誤訊息陣列。
28941
		#$result["error"],錯誤訊息陣列。
Line 28755... Line 28989...
28755
		#$conf["numLimit"]="30";
28989
		#$conf["numLimit"]="30";
28756
		#$conf["groupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
28990
		#$conf["groupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
28757
		#$conf["groupBy"]=array("");
28991
		#$conf["groupBy"]=array("");
28758
		$fastGetDbData=db::fastGetDbData($conf["db::fastGetDbData"]);
28992
		$fastGetDbData=db::fastGetDbData($conf["db::fastGetDbData"]);
28759
		unset($conf["db::fastGetDbData"]);
28993
		unset($conf["db::fastGetDbData"]);
28760
	
28994
 
28761
		#如果查詢失敗
28995
		#如果查詢失敗
28762
		if($fastGetDbData["status"]==="false"){
28996
		if($fastGetDbData["status"]==="false"){
28763
		
28997
 
28764
			#設置執行失敗
28998
			#設置執行失敗
28765
			$result["status"]="false";
28999
			$result["status"]="false";
28766
 
29000
 
28767
			#設置錯誤訊息
29001
			#設置錯誤訊息
28768
			$result["error"]=$fastGetDbData;
29002
			$result["error"]=$fastGetDbData;
28769
 
29003
 
28770
			#回傳結果
29004
			#回傳結果
28771
			return $result;
29005
			return $result;
28772
		
29006
 
28773
			}#if end
29007
			}#if end
28774
			
29008
 
28775
		#針對每筆資料
29009
		#針對每筆資料
28776
		foreach($fastGetDbData["dataContent"]["post_content"] as $index=>$value){
29010
		foreach($fastGetDbData["dataContent"]["post_content"] as $index=>$value){
28777
		
29011
 
28778
			#函式說明:
29012
			#函式說明:
28779
			#處理字串避免網頁出錯
29013
			#處理字串避免網頁出錯
28780
			#回傳的結果:
29014
			#回傳的結果:
28781
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29015
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28782
			#$result["function"],當前執行的函式.
29016
			#$result["function"],當前執行的函式.
28783
			#$result["content"],爲處理好的字串.
29017
			#$result["content"],爲處理好的字串.
28784
			#$result["error"],錯誤訊息陣列.
29018
			#$result["error"],錯誤訊息陣列.
28785
			#$result["argu"],使用的參數. 
29019
			#$result["argu"],使用的參數.
28786
			#必填參數:
29020
			#必填參數:
28787
			$conf["stringProcess::correctCharacter"]["stringIn"]=$value;#爲要處理的字串
29021
			$conf["stringProcess::correctCharacter"]["stringIn"]=$value;#爲要處理的字串
28788
			#可省略參數:
29022
			#可省略參數:
28789
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array($conf["oldDomain"]);#爲被選擇要處理的字串/字元,須爲陣列值。
29023
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array($conf["oldDomain"]);#爲被選擇要處理的字串/字元,須爲陣列值。
28790
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
29024
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
Line 28792... Line 29026...
28792
			$conf["stringProcess::correctCharacter"]["changeTo"]=array($conf["newDomain"]);#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
29026
			$conf["stringProcess::correctCharacter"]["changeTo"]=array($conf["newDomain"]);#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
28793
			#備註:
29027
			#備註:
28794
			#無.
29028
			#無.
28795
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
29029
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
28796
			unset($conf["stringProcess::correctCharacter"]);
29030
			unset($conf["stringProcess::correctCharacter"]);
28797
		
29031
 
28798
			#如果查詢失敗
29032
			#如果查詢失敗
28799
			if($correctCharacter["status"]==="false"){
29033
			if($correctCharacter["status"]==="false"){
28800
			
29034
 
28801
				#設置執行失敗
29035
				#設置執行失敗
28802
				$result["status"]="false";
29036
				$result["status"]="false";
28803
 
29037
 
28804
				#設置錯誤訊息
29038
				#設置錯誤訊息
28805
				$result["error"]=$correctCharacter;
29039
				$result["error"]=$correctCharacter;
28806
 
29040
 
28807
				#回傳結果
29041
				#回傳結果
28808
				return $result;
29042
				return $result;
28809
			
29043
 
28810
				}#if end
29044
				}#if end
28811
		
29045
 
28812
			#取得處理好的內容
29046
			#取得處理好的內容
28813
			$value=$correctCharacter["content"];
29047
			$value=$correctCharacter["content"];
28814
		
29048
 
28815
			#函式說明:	
29049
			#函式說明:
28816
			#更新資料表裏面的資料
29050
			#更新資料表裏面的資料
28817
			#回傳的結果:	
29051
			#回傳的結果:
28818
			#$result["status"],爲查詢是否成功,若爲0則成功,若爲1則表示失敗了
29052
			#$result["status"],爲查詢是否成功,若爲0則成功,若爲1則表示失敗了
28819
			#$result["error"],錯誤訊息
29053
			#$result["error"],錯誤訊息
28820
			#$result["function"],當前執行的函式名稱
29054
			#$result["function"],當前執行的函式名稱
28821
			#$result["sql"],執行的sql語法.
29055
			#$result["sql"],執行的sql語法.
28822
			#必填參數:
29056
			#必填參數:
Line 28843... Line 29077...
28843
			$conf["db::updateDataTableContent"]["dbPassword"]=$DB_PASSWORD;
29077
			$conf["db::updateDataTableContent"]["dbPassword"]=$DB_PASSWORD;
28844
			#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的port 3306.
29078
			#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的port 3306.
28845
			#$conf["dbPort"]=$dbPort;
29079
			#$conf["dbPort"]=$dbPort;
28846
			$updateDataTableContent=db::updateDataTableContent($conf["db::updateDataTableContent"]);
29080
			$updateDataTableContent=db::updateDataTableContent($conf["db::updateDataTableContent"]);
28847
			unset($conf["db::updateDataTableContent"]);
29081
			unset($conf["db::updateDataTableContent"]);
28848
		
29082
 
28849
			#如果更新失敗
29083
			#如果更新失敗
28850
			if($updateDataTableContent["status"]==="false"){
29084
			if($updateDataTableContent["status"]==="false"){
28851
			
29085
 
28852
				#設置執行失敗
29086
				#設置執行失敗
28853
				$result["status"]="false";
29087
				$result["status"]="false";
28854
 
29088
 
28855
				#設置錯誤訊息
29089
				#設置錯誤訊息
28856
				$result["error"]=$updateDataTableContent;
29090
				$result["error"]=$updateDataTableContent;
28857
 
29091
 
28858
				#回傳結果
29092
				#回傳結果
28859
				return $result;
29093
				return $result;
28860
			
29094
 
28861
				}#if end
29095
				}#if end
28862
				
29096
 
28863
			}#foreach end
29097
			}#foreach end
28864
	
29098
 
28865
		#update wp_posts table post_content col end
29099
		#update wp_posts table post_content col end
28866
		
29100
 
28867
		#update wp_posts table guid col start
29101
		#update wp_posts table guid col start
28868
			
29102
 
28869
		#函式說明:
29103
		#函式說明:
28870
		#一次取得資料庫、表的資料
29104
		#一次取得資料庫、表的資料
28871
		#回傳的結果
29105
		#回傳的結果
28872
		#$result["status"],執行結果"true"為成功;"false"為執行失敗。
29106
		#$result["status"],執行結果"true"為成功;"false"為執行失敗。
28873
		#$result["error"],錯誤訊息陣列。
29107
		#$result["error"],錯誤訊息陣列。
Line 28921... Line 29155...
28921
		#$conf["numLimit"]="30";
29155
		#$conf["numLimit"]="30";
28922
		#$conf["groupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
29156
		#$conf["groupBy"],字串陣列,爲要以哪幾個欄爲作爲分羣的依據(欄位相同的數值僅會取出一筆)。
28923
		#$conf["groupBy"]=array("");
29157
		#$conf["groupBy"]=array("");
28924
		$fastGetDbData=db::fastGetDbData($conf["db::fastGetDbData"]);
29158
		$fastGetDbData=db::fastGetDbData($conf["db::fastGetDbData"]);
28925
		unset($conf["db::fastGetDbData"]);
29159
		unset($conf["db::fastGetDbData"]);
28926
	
29160
 
28927
		#如果查詢失敗
29161
		#如果查詢失敗
28928
		if($fastGetDbData["status"]==="false"){
29162
		if($fastGetDbData["status"]==="false"){
28929
		
29163
 
28930
			#設置執行失敗
29164
			#設置執行失敗
28931
			$result["status"]="false";
29165
			$result["status"]="false";
28932
 
29166
 
28933
			#設置錯誤訊息
29167
			#設置錯誤訊息
28934
			$result["error"]=$fastGetDbData;
29168
			$result["error"]=$fastGetDbData;
28935
 
29169
 
28936
			#回傳結果
29170
			#回傳結果
28937
			return $result;
29171
			return $result;
28938
		
29172
 
28939
			}#if end
29173
			}#if end
28940
			
29174
 
28941
		#針對每筆資料
29175
		#針對每筆資料
28942
		foreach($fastGetDbData["dataContent"]["guid"] as $index=>$value){
29176
		foreach($fastGetDbData["dataContent"]["guid"] as $index=>$value){
28943
		
29177
 
28944
			#函式說明:
29178
			#函式說明:
28945
			#處理字串避免網頁出錯
29179
			#處理字串避免網頁出錯
28946
			#回傳的結果:
29180
			#回傳的結果:
28947
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29181
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
28948
			#$result["function"],當前執行的函式.
29182
			#$result["function"],當前執行的函式.
28949
			#$result["content"],爲處理好的字串.
29183
			#$result["content"],爲處理好的字串.
28950
			#$result["error"],錯誤訊息陣列.
29184
			#$result["error"],錯誤訊息陣列.
28951
			#$result["argu"],使用的參數. 
29185
			#$result["argu"],使用的參數.
28952
			#必填參數:
29186
			#必填參數:
28953
			$conf["stringProcess::correctCharacter"]["stringIn"]=$value;#爲要處理的字串
29187
			$conf["stringProcess::correctCharacter"]["stringIn"]=$value;#爲要處理的字串
28954
			#可省略參數:
29188
			#可省略參數:
28955
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array($conf["oldDomain"]);#爲被選擇要處理的字串/字元,須爲陣列值。
29189
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array($conf["oldDomain"]);#爲被選擇要處理的字串/字元,須爲陣列值。
28956
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
29190
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
Line 28958... Line 29192...
28958
			$conf["stringProcess::correctCharacter"]["changeTo"]=array($conf["newDomain"]);#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
29192
			$conf["stringProcess::correctCharacter"]["changeTo"]=array($conf["newDomain"]);#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
28959
			#備註:
29193
			#備註:
28960
			#無.
29194
			#無.
28961
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
29195
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
28962
			unset($conf["stringProcess::correctCharacter"]);
29196
			unset($conf["stringProcess::correctCharacter"]);
28963
		
29197
 
28964
			#如果查詢失敗
29198
			#如果查詢失敗
28965
			if($correctCharacter["status"]==="false"){
29199
			if($correctCharacter["status"]==="false"){
28966
			
29200
 
28967
				#設置執行失敗
29201
				#設置執行失敗
28968
				$result["status"]="false";
29202
				$result["status"]="false";
28969
 
29203
 
28970
				#設置錯誤訊息
29204
				#設置錯誤訊息
28971
				$result["error"]=$correctCharacter;
29205
				$result["error"]=$correctCharacter;
28972
 
29206
 
28973
				#回傳結果
29207
				#回傳結果
28974
				return $result;
29208
				return $result;
28975
			
29209
 
28976
				}#if end
29210
				}#if end
28977
		
29211
 
28978
			#取得處理好的內容
29212
			#取得處理好的內容
28979
			$value=$correctCharacter["content"];
29213
			$value=$correctCharacter["content"];
28980
		
29214
 
28981
			#函式說明:	
29215
			#函式說明:
28982
			#更新資料表裏面的資料
29216
			#更新資料表裏面的資料
28983
			#回傳的結果:	
29217
			#回傳的結果:
28984
			#$result["status"],爲查詢是否成功,若爲0則成功,若爲1則表示失敗了
29218
			#$result["status"],爲查詢是否成功,若爲0則成功,若爲1則表示失敗了
28985
			#$result["error"],錯誤訊息
29219
			#$result["error"],錯誤訊息
28986
			#$result["function"],當前執行的函式名稱
29220
			#$result["function"],當前執行的函式名稱
28987
			#$result["sql"],執行的sql語法.
29221
			#$result["sql"],執行的sql語法.
28988
			#必填參數:
29222
			#必填參數:
Line 29009... Line 29243...
29009
			$conf["db::updateDataTableContent"]["dbPassword"]=$DB_PASSWORD;
29243
			$conf["db::updateDataTableContent"]["dbPassword"]=$DB_PASSWORD;
29010
			#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的port 3306.
29244
			#$conf["dbPort"],字串,爲連線到mysql-Server時要使用的port,可省略,若省略則代表使用預設的port 3306.
29011
			#$conf["dbPort"]=$dbPort;
29245
			#$conf["dbPort"]=$dbPort;
29012
			$updateDataTableContent=db::updateDataTableContent($conf["db::updateDataTableContent"]);
29246
			$updateDataTableContent=db::updateDataTableContent($conf["db::updateDataTableContent"]);
29013
			unset($conf["db::updateDataTableContent"]);
29247
			unset($conf["db::updateDataTableContent"]);
29014
		
29248
 
29015
			#如果更新失敗
29249
			#如果更新失敗
29016
			if($updateDataTableContent["status"]==="false"){
29250
			if($updateDataTableContent["status"]==="false"){
29017
			
29251
 
29018
				#設置執行失敗
29252
				#設置執行失敗
29019
				$result["status"]="false";
29253
				$result["status"]="false";
29020
 
29254
 
29021
				#設置錯誤訊息
29255
				#設置錯誤訊息
29022
				$result["error"]=$updateDataTableContent;
29256
				$result["error"]=$updateDataTableContent;
29023
 
29257
 
29024
				#回傳結果
29258
				#回傳結果
29025
				return $result;
29259
				return $result;
29026
			
29260
 
29027
				}#if end
29261
				}#if end
29028
				
29262
 
29029
			}#foreach end
29263
			}#foreach end
29030
	
29264
 
29031
		#update wp_posts table guid col end
29265
		#update wp_posts table guid col end
29032
		
29266
 
29033
		#設置執行正常
29267
		#設置執行正常
29034
		$result["status"]="true";
29268
		$result["status"]="true";
29035
	
29269
 
29036
		#回傳結果
29270
		#回傳結果
29037
		return $reuslt;
29271
		return $reuslt;
29038
	
29272
 
29039
		}#functino changeWordPressDomain
29273
		}#functino changeWordPressDomain
29040
 
29274
 
29041
	/*
29275
	/*
29042
	#函式說明:
29276
	#函式說明:
29043
	#使用 linux 的 groups 指令來查詢使用者所屬的群組清單.
29277
	#使用 linux 的 groups 指令來查詢使用者所屬的群組清單.
Line 29055... Line 29289...
29055
	#無.
29289
	#無.
29056
	#備註:
29290
	#備註:
29057
	#無.
29291
	#無.
29058
	*/
29292
	*/
29059
	public static function getUserGroups(&$conf){
29293
	public static function getUserGroups(&$conf){
29060
	
29294
 
29061
		#初始化要回傳的結果
29295
		#初始化要回傳的結果
29062
		$result=array();
29296
		$result=array();
29063
 
29297
 
29064
		#取得當前執行的函數名稱
29298
		#取得當前執行的函數名稱
29065
		$result["function"]=__FUNCTION__;
29299
		$result["function"]=__FUNCTION__;
Line 29100... Line 29334...
29100
 
29334
 
29101
			#回傳結果
29335
			#回傳結果
29102
			return $result;
29336
			return $result;
29103
 
29337
 
29104
			}#if end
29338
			}#if end
29105
	
29339
 
29106
		#函式說明:
29340
		#函式說明:
29107
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
29341
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
29108
		#回傳結果:
29342
		#回傳結果:
29109
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29343
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29110
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
29344
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 29152... Line 29386...
29152
		#array_keys=>http://php.net/manual/en/function.array-keys.php
29386
		#array_keys=>http://php.net/manual/en/function.array-keys.php
29153
		#備註:
29387
		#備註:
29154
		#無.
29388
		#無.
29155
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
29389
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
29156
		unset($conf["variableCheck::checkArguments"]);
29390
		unset($conf["variableCheck::checkArguments"]);
29157
	
29391
 
29158
		#如果執行失敗
29392
		#如果執行失敗
29159
		if($checkArguments["status"]==="false"){
29393
		if($checkArguments["status"]==="false"){
29160
		
29394
 
29161
			#設置執行失敗
29395
			#設置執行失敗
29162
			$result["status"]="false";
29396
			$result["status"]="false";
29163
 
29397
 
29164
			#設置錯誤訊息
29398
			#設置錯誤訊息
29165
			$result["error"]=$checkArguments;
29399
			$result["error"]=$checkArguments;
29166
 
29400
 
29167
			#回傳結果
29401
			#回傳結果
29168
			return $result;
29402
			return $result;
29169
		
29403
 
29170
			}#if end
29404
			}#if end
29171
			
29405
 
29172
		#如果檢查不通過
29406
		#如果檢查不通過
29173
		if($checkArguments["passed"]==="false"){
29407
		if($checkArguments["passed"]==="false"){
29174
		
29408
 
29175
			#設置執行失敗
29409
			#設置執行失敗
29176
			$result["status"]="false";
29410
			$result["status"]="false";
29177
 
29411
 
29178
			#設置錯誤訊息
29412
			#設置錯誤訊息
29179
			$result["error"]=$checkArguments;
29413
			$result["error"]=$checkArguments;
29180
 
29414
 
29181
			#回傳結果
29415
			#回傳結果
29182
			return $result;
29416
			return $result;
29183
		
29417
 
29184
			}#if end
29418
			}#if end
29185
	
29419
 
29186
		#如果沒有指定 user
29420
		#如果沒有指定 user
29187
		if(!isset($conf["users"])){
29421
		if(!isset($conf["users"])){
29188
		
29422
 
29189
			#函式說明:
29423
			#函式說明:
29190
			#取得用戶端的資訊,並依據需要寫入到資料表裡面
29424
			#取得用戶端的資訊,並依據需要寫入到資料表裡面
29191
			#回傳的結果:
29425
			#回傳的結果:
29192
			#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
29426
			#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
29193
			#$result["error"],錯誤訊息.
29427
			#$result["error"],錯誤訊息.
Line 29232... Line 29466...
29232
			#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
29466
			#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
29233
			#備註:
29467
			#備註:
29234
			#無.
29468
			#無.
29235
			$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
29469
			$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
29236
			unset($conf["csInformation::getConnectionInfo"]);
29470
			unset($conf["csInformation::getConnectionInfo"]);
29237
			
29471
 
29238
			#如果執行失敗
29472
			#如果執行失敗
29239
			if($getConnectionInfo["status"]==="false"){
29473
			if($getConnectionInfo["status"]==="false"){
29240
			
29474
 
29241
				#設置執行失敗
29475
				#設置執行失敗
29242
				$result["status"]="false";
29476
				$result["status"]="false";
29243
 
29477
 
29244
				#設置錯誤訊息
29478
				#設置錯誤訊息
29245
				$result["error"]=$getConnectionInfo;
29479
				$result["error"]=$getConnectionInfo;
29246
 
29480
 
29247
				#回傳結果
29481
				#回傳結果
29248
				return $result;
29482
				return $result;
29249
			
29483
 
29250
				}#if end
29484
				}#if end
29251
		
29485
 
29252
			#設置預設使用者為自己
29486
			#設置預設使用者為自己
29253
			$conf["users"]=$getConnectionInfo["phpUser"];
29487
			$conf["users"]=$getConnectionInfo["phpUser"];
29254
		
29488
 
29255
			}#if end
29489
			}#if end
29256
	
29490
 
29257
		#函式說明:
29491
		#函式說明:
29258
		#呼叫shell執行系統命令,並取得回傳的內容.
29492
		#呼叫shell執行系統命令,並取得回傳的內容.
29259
		#回傳結果:
29493
		#回傳結果:
29260
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29494
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29261
		#$result["error"],錯誤訊息陣列.
29495
		#$result["error"],錯誤訊息陣列.
Line 29311... Line 29545...
29311
		#備註:
29545
		#備註:
29312
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
29546
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
29313
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
29547
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
29314
		$callShell=external::callShell($conf["external::callShell"]);
29548
		$callShell=external::callShell($conf["external::callShell"]);
29315
		unset($conf["external::callShell"]);
29549
		unset($conf["external::callShell"]);
29316
	
29550
 
29317
		#如果執行失敗
29551
		#如果執行失敗
29318
		if($callShell["status"]==="false"){
29552
		if($callShell["status"]==="false"){
29319
		
29553
 
29320
			#設置執行失敗
29554
			#設置執行失敗
29321
			$result["status"]="false";
29555
			$result["status"]="false";
29322
 
29556
 
29323
			#設置錯誤訊息
29557
			#設置錯誤訊息
29324
			$result["error"]=$callShell;
29558
			$result["error"]=$callShell;
29325
 
29559
 
29326
			#回傳結果
29560
			#回傳結果
29327
			return $result;
29561
			return $result;
29328
		
29562
 
29329
			}#if end
29563
			}#if end
29330
 
29564
 
29331
		#取得群組清單
29565
		#取得群組清單
29332
		#函式說明:
29566
		#函式說明:
29333
		#將字串特定關鍵字與其前面的內容剔除
29567
		#將字串特定關鍵字與其前面的內容剔除
Line 29337... Line 29571...
29337
		#$result["warning"],警告訊息鎮列.
29571
		#$result["warning"],警告訊息鎮列.
29338
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
29572
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
29339
		#$result["function"],當前執行的函數名稱.
29573
		#$result["function"],當前執行的函數名稱.
29340
		#$result["argu"],使用的參數.
29574
		#$result["argu"],使用的參數.
29341
		#$result["oriStr"],要處理的原始字串內容.
29575
		#$result["oriStr"],要處理的原始字串內容.
29342
		#$result["content"],處理好的的字串內容.	
29576
		#$result["content"],處理好的的字串內容.
29343
		#必填參數:
29577
		#必填參數:
29344
		#$conf["stringIn"],字串,要處理的字串.
29578
		#$conf["stringIn"],字串,要處理的字串.
29345
		$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$callShell["output"][0];
29579
		$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$callShell["output"][0];
29346
		#$conf["keyWord"],字串,特定字串.
29580
		#$conf["keyWord"],字串,特定字串.
29347
		$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" : ";
29581
		$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" : ";
Line 29354... Line 29588...
29354
		#無.
29588
		#無.
29355
		#備註:
29589
		#備註:
29356
		#無.
29590
		#無.
29357
		$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
29591
		$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
29358
		unset($conf["stringProcess::delStrBeforeKeyWord"]);
29592
		unset($conf["stringProcess::delStrBeforeKeyWord"]);
29359
	
29593
 
29360
		#如果執行失敗
29594
		#如果執行失敗
29361
		if($delStrBeforeKeyWord["status"]==="false"){
29595
		if($delStrBeforeKeyWord["status"]==="false"){
29362
		
29596
 
29363
			#設置執行失敗
29597
			#設置執行失敗
29364
			$result["status"]="false";
29598
			$result["status"]="false";
29365
 
29599
 
29366
			#設置錯誤訊息
29600
			#設置錯誤訊息
29367
			$result["error"]=$delStrBeforeKeyWord;
29601
			$result["error"]=$delStrBeforeKeyWord;
29368
 
29602
 
29369
			#回傳結果
29603
			#回傳結果
29370
			return $result;
29604
			return $result;
29371
		
29605
 
29372
			}#if end
29606
			}#if end
29373
			
29607
 
29374
		#如果沒有該有的關鍵字
29608
		#如果沒有該有的關鍵字
29375
		if($delStrBeforeKeyWord["founded"]==="false"){
29609
		if($delStrBeforeKeyWord["founded"]==="false"){
29376
		
29610
 
29377
			#設置執行失敗
29611
			#設置執行失敗
29378
			$result["status"]="false";
29612
			$result["status"]="false";
29379
 
29613
 
29380
			#設置錯誤訊息
29614
			#設置錯誤訊息
29381
			$result["error"]=$delStrBeforeKeyWord;
29615
			$result["error"]=$delStrBeforeKeyWord;
29382
 
29616
 
29383
			#回傳結果
29617
			#回傳結果
29384
			return $result;
29618
			return $result;
29385
		
29619
 
29386
			}#if end	
29620
			}#if end
29387
		
29621
 
29388
		#函式說明:
29622
		#函式說明:
29389
		#將固定格式的字串分開,並回傳分開的結果.
29623
		#將固定格式的字串分開,並回傳分開的結果.
29390
		#回傳結果:
29624
		#回傳結果:
29391
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29625
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29392
		#$result["error"],錯誤訊息陣列
29626
		#$result["error"],錯誤訊息陣列
Line 29408... Line 29642...
29408
		#無.
29642
		#無.
29409
		#備註:
29643
		#備註:
29410
		#無.
29644
		#無.
29411
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
29645
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
29412
		unset($conf["stringProcess::spiltString"]);
29646
		unset($conf["stringProcess::spiltString"]);
29413
		
29647
 
29414
		#如果執行失敗
29648
		#如果執行失敗
29415
		if($spiltString["status"]==="false"){
29649
		if($spiltString["status"]==="false"){
29416
		
29650
 
29417
			#設置執行失敗
29651
			#設置執行失敗
29418
			$result["status"]="false";
29652
			$result["status"]="false";
29419
 
29653
 
29420
			#設置錯誤訊息
29654
			#設置錯誤訊息
29421
			$result["error"]=$spiltString;
29655
			$result["error"]=$spiltString;
29422
 
29656
 
29423
			#回傳結果
29657
			#回傳結果
29424
			return $result;
29658
			return $result;
29425
		
29659
 
29426
			}#if end
29660
			}#if end
29427
		
29661
 
29428
		#如果沒有結果
29662
		#如果沒有結果
29429
		if($spiltString["dataCounts"]===0){
29663
		if($spiltString["dataCounts"]===0){
29430
		
29664
 
29431
			#設置執行失敗
29665
			#設置執行失敗
29432
			$result["status"]="false";
29666
			$result["status"]="false";
29433
 
29667
 
29434
			#設置錯誤訊息
29668
			#設置錯誤訊息
29435
			$result["error"]=$spiltString;
29669
			$result["error"]=$spiltString;
29436
 
29670
 
29437
			#回傳結果
29671
			#回傳結果
29438
			return $result;
29672
			return $result;
29439
		
29673
 
29440
			}#if end
29674
			}#if end
29441
		
29675
 
29442
		#設置結果
29676
		#設置結果
29443
		$result["content"]=$spiltString["dataArray"];
29677
		$result["content"]=$spiltString["dataArray"];
29444
		
29678
 
29445
		#設置執行正常
29679
		#設置執行正常
29446
		$result["status"]="true";
29680
		$result["status"]="true";
29447
	
29681
 
29448
		#回傳結果
29682
		#回傳結果
29449
		return $reuslt;
29683
		return $reuslt;
29450
	
29684
 
29451
		}#function getUserGroups end
29685
		}#function getUserGroups end
29452
 
29686
 
29453
	/*
29687
	/*
29454
	#函式說明:
29688
	#函式說明:
29455
	#使用 linux 的 chown 指令來修改目標檔案或目錄的擁有者跟群組擁有者資訊.
29689
	#使用 linux 的 chown 指令來修改目標檔案或目錄的擁有者跟群組擁有者資訊.
Line 29474... Line 29708...
29474
	#無.
29708
	#無.
29475
	#備註:
29709
	#備註:
29476
	#無.
29710
	#無.
29477
	*/
29711
	*/
29478
	public static function chown(&$conf){
29712
	public static function chown(&$conf){
29479
	
29713
 
29480
		#初始化要回傳的結果
29714
		#初始化要回傳的結果
29481
		$result=array();
29715
		$result=array();
29482
 
29716
 
29483
		#取得當前執行的函數名稱
29717
		#取得當前執行的函數名稱
29484
		$result["function"]=__FUNCTION__;
29718
		$result["function"]=__FUNCTION__;
Line 29519... Line 29753...
29519
 
29753
 
29520
			#回傳結果
29754
			#回傳結果
29521
			return $result;
29755
			return $result;
29522
 
29756
 
29523
			}#if end
29757
			}#if end
29524
	
29758
 
29525
		#函式說明:
29759
		#函式說明:
29526
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
29760
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
29527
		#回傳結果:
29761
		#回傳結果:
29528
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29762
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29529
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
29763
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 29571... Line 29805...
29571
		#array_keys=>http://php.net/manual/en/function.array-keys.php
29805
		#array_keys=>http://php.net/manual/en/function.array-keys.php
29572
		#備註:
29806
		#備註:
29573
		#無.
29807
		#無.
29574
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
29808
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
29575
		unset($conf["variableCheck::checkArguments"]);
29809
		unset($conf["variableCheck::checkArguments"]);
29576
	
29810
 
29577
		#如果執行失敗
29811
		#如果執行失敗
29578
		if($checkArguments["status"]==="false"){
29812
		if($checkArguments["status"]==="false"){
29579
		
29813
 
29580
			#設置執行失敗
29814
			#設置執行失敗
29581
			$result["status"]="false";
29815
			$result["status"]="false";
29582
 
29816
 
29583
			#設置錯誤訊息
29817
			#設置錯誤訊息
29584
			$result["error"]=$checkArguments;
29818
			$result["error"]=$checkArguments;
29585
 
29819
 
29586
			#回傳結果
29820
			#回傳結果
29587
			return $result;
29821
			return $result;
29588
		
29822
 
29589
			}#if end
29823
			}#if end
29590
			
29824
 
29591
		#如果檢查不通過
29825
		#如果檢查不通過
29592
		if($checkArguments["passed"]==="false"){
29826
		if($checkArguments["passed"]==="false"){
29593
		
29827
 
29594
			#設置執行失敗
29828
			#設置執行失敗
29595
			$result["status"]="false";
29829
			$result["status"]="false";
29596
 
29830
 
29597
			#設置錯誤訊息
29831
			#設置錯誤訊息
29598
			$result["error"]=$checkArguments;
29832
			$result["error"]=$checkArguments;
29599
 
29833
 
29600
			#回傳結果
29834
			#回傳結果
29601
			return $result;
29835
			return $result;
29602
		
29836
 
29603
			}#if end
29837
			}#if end
29604
		
29838
 
29605
		#確認 $conf["target"] 存在
29839
		#確認 $conf["target"] 存在
29606
		#函式說明:
29840
		#函式說明:
29607
		#檢查多個檔案與資料夾是否存在.
29841
		#檢查多個檔案與資料夾是否存在.
29608
		#回傳的結果:
29842
		#回傳的結果:
29609
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
29843
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 29633... Line 29867...
29633
		#備註:
29867
		#備註:
29634
		#函數file_exists檢查的路徑為檔案系統的路徑
29868
		#函數file_exists檢查的路徑為檔案系統的路徑
29635
		#$result["varName"][$i]結果未實作
29869
		#$result["varName"][$i]結果未實作
29636
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
29870
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
29637
		unset($conf["fileAccess::checkMultiFileExist"]);
29871
		unset($conf["fileAccess::checkMultiFileExist"]);
29638
	
29872
 
29639
		#如果執行失敗
29873
		#如果執行失敗
29640
		if($checkMultiFileExist["status"]==="false"){
29874
		if($checkMultiFileExist["status"]==="false"){
29641
		
29875
 
29642
			#設置執行失敗
29876
			#設置執行失敗
29643
			$result["status"]="false";
29877
			$result["status"]="false";
29644
 
29878
 
29645
			#設置錯誤訊息
29879
			#設置錯誤訊息
29646
			$result["error"]=$checkMultiFileExist;
29880
			$result["error"]=$checkMultiFileExist;
29647
 
29881
 
29648
			#回傳結果
29882
			#回傳結果
29649
			return $result;
29883
			return $result;
29650
		
29884
 
29651
			}#if end
29885
			}#if end
29652
	
29886
 
29653
		#如果 target 不存在
29887
		#如果 target 不存在
29654
		if($checkMultiFileExist["allExist"]==="false"){
29888
		if($checkMultiFileExist["allExist"]==="false"){
29655
		
29889
 
29656
			#設置執行失敗
29890
			#設置執行失敗
29657
			$result["status"]="false";
29891
			$result["status"]="false";
29658
 
29892
 
29659
			#設置錯誤訊息
29893
			#設置錯誤訊息
29660
			$result["error"]=$checkMultiFileExist;
29894
			$result["error"]=$checkMultiFileExist;
29661
 
29895
 
29662
			#回傳結果
29896
			#回傳結果
29663
			return $result;
29897
			return $result;
29664
		
29898
 
29665
			}#if end
29899
			}#if end
29666
	
29900
 
29667
		#初始化給 chown 的參數
29901
		#初始化給 chown 的參數
29668
		$paramsForChown=array($conf["owner"].":".$conf["group"]);
29902
		$paramsForChown=array($conf["owner"].":".$conf["group"]);
29669
	
29903
 
29670
		#如果底下的內容也要一起做設定
29904
		#如果底下的內容也要一起做設定
29671
		if($conf["recursive"]==="true"){
29905
		if($conf["recursive"]==="true"){
29672
		
29906
 
29673
			#加上 -R 參數
29907
			#加上 -R 參數
29674
			$paramsForChown[]="-R";
29908
			$paramsForChown[]="-R";
29675
			
29909
 
29676
			#取得目標資訊
29910
			#取得目標資訊
29677
			#函式說明:
29911
			#函式說明:
29678
			#取得節點的資訊.
29912
			#取得節點的資訊.
29679
			#回傳結果:
29913
			#回傳結果:
29680
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
29914
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
29681
			#$result["error"],錯誤訊息陣列.
29915
			#$result["error"],錯誤訊息陣列.
29682
			#$result["function"],函數名稱. 
29916
			#$result["function"],函數名稱.
29683
			#$result["content"],檔案資訊陣列.
29917
			#$result["content"],檔案資訊陣列.
29684
			#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
29918
			#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
29685
			#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
29919
			#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
29686
			#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
29920
			#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
29687
			#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
29921
			#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
29688
			#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
29922
			#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
29689
			#$result["content"]["ownerName"],檔案擁有着資訊.
29923
			#$result["content"]["ownerName"],檔案擁有着資訊.
Line 29706... Line 29940...
29706
			#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
29940
			#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
29707
			#備註:
29941
			#備註:
29708
			#無.
29942
			#無.
29709
			$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
29943
			$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
29710
			unset($conf["fileAccess::fileInfo"]);
29944
			unset($conf["fileAccess::fileInfo"]);
29711
		
29945
 
29712
			#如果執行失敗
29946
			#如果執行失敗
29713
			if($fileInfo["status"]==="false"){
29947
			if($fileInfo["status"]==="false"){
29714
			
29948
 
29715
				#設置執行失敗
29949
				#設置執行失敗
29716
				$result["status"]="false";
29950
				$result["status"]="false";
29717
 
29951
 
29718
				#設置錯誤訊息
29952
				#設置錯誤訊息
29719
				$result["error"]=$fileInfo;
29953
				$result["error"]=$fileInfo;
29720
 
29954
 
29721
				#回傳結果
29955
				#回傳結果
29722
				return $result;
29956
				return $result;
29723
			
29957
 
29724
				}#if end
29958
				}#if end
29725
		
29959
 
29726
			#如果目標是資料夾
29960
			#如果目標是資料夾
29727
			if($fileInfo["content"]["is_folder"]==="true"){
29961
			if($fileInfo["content"]["is_folder"]==="true"){
29728
			
29962
 
29729
				#如果要排除目標資料夾或軟連結之類的
29963
				#如果要排除目標資料夾或軟連結之類的
29730
				if($conf["excludeSelf"]==="true"){
29964
				if($conf["excludeSelf"]==="true"){
29731
					
29965
 
29732
					#函式說明:
29966
					#函式說明:
29733
					#開啟特定目錄,取得底下的檔案路徑清單.
29967
					#開啟特定目錄,取得底下的檔案路徑清單.
29734
					#回傳結果:
29968
					#回傳結果:
29735
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29969
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29736
					#$result["error"],錯誤訊息.
29970
					#$result["error"],錯誤訊息.
29737
					#$result["function"],當前執行的函數名稱.
29971
					#$result["function"],當前執行的函數名稱.
29738
					#$result["argu"],所使用的參數.	
29972
					#$result["argu"],所使用的參數.
29739
					#$result["content"],讀取到的內容陣列.
29973
					#$result["content"],讀取到的內容陣列.
29740
					#$result["content"][$i],第$i+1個結果.
29974
					#$result["content"][$i],第$i+1個結果.
29741
					#$result["content"][$i]["name"],第$i+1個名稱.
29975
					#$result["content"][$i]["name"],第$i+1個名稱.
29742
					#$result["content"][$i]["dir"],第$i+1個檔案是否為資料夾.		
29976
					#$result["content"][$i]["dir"],第$i+1個檔案是否為資料夾.
29743
					#$result["content"][$i]["info"],第$i+1個檔案的額外資訊.
29977
					#$result["content"][$i]["info"],第$i+1個檔案的額外資訊.
29744
					#$result["content"][$i]["size"],第$i+1個檔案的大小(bytes).
29978
					#$result["content"][$i]["size"],第$i+1個檔案的大小(bytes).
29745
					#必填參數:
29979
					#必填參數:
29746
					#$conf["path"],字串,要取得檔案資訊的所屬路徑.
29980
					#$conf["path"],字串,要取得檔案資訊的所屬路徑.
29747
					$conf["fileAccess::listInfo"]["path"]=$conf["target"];
29981
					$conf["fileAccess::listInfo"]["path"]=$conf["target"];
Line 29751... Line 29985...
29751
					#無.
29985
					#無.
29752
					#備註:
29986
					#備註:
29753
					#無.
29987
					#無.
29754
					$listInfo=fileAccess::listInfo($conf["fileAccess::listInfo"]);
29988
					$listInfo=fileAccess::listInfo($conf["fileAccess::listInfo"]);
29755
					unset($conf["fileAccess::listInfo"]);
29989
					unset($conf["fileAccess::listInfo"]);
29756
				
29990
 
29757
					#如果執行失敗
29991
					#如果執行失敗
29758
					if($listInfo["status"]==="false"){
29992
					if($listInfo["status"]==="false"){
29759
				
29993
 
29760
						#設置執行失敗
29994
						#設置執行失敗
29761
						$result["status"]="false";
29995
						$result["status"]="false";
29762
 
29996
 
29763
						#設置錯誤訊息
29997
						#設置錯誤訊息
29764
						$result["error"]=$listInfo;
29998
						$result["error"]=$listInfo;
29765
 
29999
 
29766
						#回傳結果
30000
						#回傳結果
29767
						return $result;
30001
						return $result;
29768
						
30002
 
29769
						}#if end
30003
						}#if end
29770
							
30004
 
29771
					#針對每個目標
30005
					#針對每個目標
29772
					foreach($listInfo["content"] as $fileInfo){
30006
					foreach($listInfo["content"] as $fileInfo){
29773
					
30007
 
29774
						#忽略當前目錄與上層目錄
30008
						#忽略當前目錄與上層目錄
29775
						if($fileInfo["content"]["name"]==="." || $fileInfo["content"]["name"]===".."){
30009
						if($fileInfo["content"]["name"]==="." || $fileInfo["content"]["name"]===".."){
29776
						
30010
 
29777
							#跳過
30011
							#跳過
29778
							continue;
30012
							continue;
29779
						
30013
 
29780
							}#if end
30014
							}#if end
29781
						
30015
 
29782
						#函式說明:
30016
						#函式說明:
29783
						#使用 linux 的 chown 指令來修改目標檔案或目錄的擁有者跟群組擁有者資訊.
30017
						#使用 linux 的 chown 指令來修改目標檔案或目錄的擁有者跟群組擁有者資訊.
29784
						#回傳結果:
30018
						#回傳結果:
29785
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30019
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
29786
						#$result["error"],錯誤訊息.
30020
						#$result["error"],錯誤訊息.
Line 29803... Line 30037...
29803
						#無.
30037
						#無.
29804
						#備註:
30038
						#備註:
29805
						#無.
30039
						#無.
29806
						$chown=cmd::chown($conf["cmd::chown"]);
30040
						$chown=cmd::chown($conf["cmd::chown"]);
29807
						unset($conf["cmd::chown"]);
30041
						unset($conf["cmd::chown"]);
29808
					
30042
 
29809
						#如果執行失敗
30043
						#如果執行失敗
29810
						if($chown["status"]==="false"){
30044
						if($chown["status"]==="false"){
29811
					
30045
 
29812
							#設置執行失敗
30046
							#設置執行失敗
29813
							$result["status"]="false";
30047
							$result["status"]="false";
29814
 
30048
 
29815
							#設置錯誤訊息
30049
							#設置錯誤訊息
29816
							$result["error"]=$chown;
30050
							$result["error"]=$chown;
29817
 
30051
 
29818
							#回傳結果
30052
							#回傳結果
29819
							return $result;
30053
							return $result;
29820
							
30054
 
29821
							}#if end
30055
							}#if end
29822
							
30056
 
29823
						#記錄結果
30057
						#記錄結果
29824
						$result["content"][]=$chown;
30058
						$result["content"][]=$chown;
29825
							
30059
 
29826
						}#foreach end
30060
						}#foreach end
29827
				
30061
 
29828
					#設置執行正常
30062
					#設置執行正常
29829
					$result["status"]="true";
30063
					$result["status"]="true";
29830
					
30064
 
29831
					#回傳結果
30065
					#回傳結果
29832
					return $result;
30066
					return $result;
29833
				
30067
 
29834
					}#if end
30068
					}#if end
29835
					
30069
 
29836
				#執行到這邊代表不用對底下內容做異動
30070
				#執行到這邊代表不用對底下內容做異動
29837
				
30071
 
29838
				}#if end
30072
				}#if end
29839
		
30073
 
29840
			#執行到這邊代表目標不是目錄
30074
			#執行到這邊代表目標不是目錄
29841
				
30075
 
29842
			}#if end
30076
			}#if end
29843
		
30077
 
29844
		#取得目標資訊
30078
		#取得目標資訊
29845
		#函式說明:
30079
		#函式說明:
29846
		#取得節點的資訊.
30080
		#取得節點的資訊.
29847
		#回傳結果:
30081
		#回傳結果:
29848
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
30082
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
29849
		#$result["error"],錯誤訊息陣列.
30083
		#$result["error"],錯誤訊息陣列.
29850
		#$result["function"],函數名稱. 
30084
		#$result["function"],函數名稱.
29851
		#$result["content"],檔案資訊陣列.
30085
		#$result["content"],檔案資訊陣列.
29852
		#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
30086
		#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
29853
		#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
30087
		#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
29854
		#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
30088
		#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
29855
		#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
30089
		#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
29856
		#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
30090
		#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
29857
		#$result["content"]["ownerName"],檔案擁有着資訊.
30091
		#$result["content"]["ownerName"],檔案擁有着資訊.
Line 29874... Line 30108...
29874
		#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
30108
		#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
29875
		#備註:
30109
		#備註:
29876
		#無.
30110
		#無.
29877
		$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
30111
		$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
29878
		unset($conf["fileAccess::fileInfo"]);
30112
		unset($conf["fileAccess::fileInfo"]);
29879
	
30113
 
29880
		#如果執行失敗
30114
		#如果執行失敗
29881
		if($fileInfo["status"]==="false"){
30115
		if($fileInfo["status"]==="false"){
29882
		
30116
 
29883
			#設置執行失敗
30117
			#設置執行失敗
29884
			$result["status"]="false";
30118
			$result["status"]="false";
29885
 
30119
 
29886
			#設置錯誤訊息
30120
			#設置錯誤訊息
29887
			$result["error"]=$fileInfo;
30121
			$result["error"]=$fileInfo;
29888
 
30122
 
29889
			#回傳結果
30123
			#回傳結果
29890
			return $result;
30124
			return $result;
29891
		
30125
 
29892
			}#if end
30126
			}#if end
29893
		
30127
 
29894
		#函式說明:
30128
		#函式說明:
29895
		#取得用戶端的資訊,並依據需要寫入到資料表裡面
30129
		#取得用戶端的資訊,並依據需要寫入到資料表裡面
29896
		#回傳的結果:
30130
		#回傳的結果:
29897
		#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
30131
		#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
29898
		#$result["error"],錯誤訊息.
30132
		#$result["error"],錯誤訊息.
Line 29937... Line 30171...
29937
		#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
30171
		#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
29938
		#備註:
30172
		#備註:
29939
		#無.
30173
		#無.
29940
		$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
30174
		$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
29941
		unset($conf["csInformation::getConnectionInfo"]);
30175
		unset($conf["csInformation::getConnectionInfo"]);
29942
		
30176
 
29943
		#如果執行失敗
30177
		#如果執行失敗
29944
		if($getConnectionInfo["status"]==="false"){
30178
		if($getConnectionInfo["status"]==="false"){
29945
	
30179
 
29946
			#設置執行失敗
30180
			#設置執行失敗
29947
			$result["status"]="false";
30181
			$result["status"]="false";
29948
 
30182
 
29949
			#設置錯誤訊息
30183
			#設置錯誤訊息
29950
			$result["error"]=$getConnectionInfo;
30184
			$result["error"]=$getConnectionInfo;
29951
 
30185
 
29952
			#回傳結果
30186
			#回傳結果
29953
			return $result;
30187
			return $result;
29954
			
30188
 
29955
			}#if end
30189
			}#if end
29956
		
30190
 
29957
		#初始化 chown 指令
30191
		#初始化 chown 指令
29958
		$chown="chown";
30192
		$chown="chown";
29959
		
30193
 
29960
		#debug
30194
		#debug
29961
		#var_dump(__LINE__,$getConnectionInfo);
30195
		#var_dump(__LINE__,$getConnectionInfo);
29962
		
30196
 
29963
		#如果不是root賬戶在運行
30197
		#如果不是root賬戶在運行
29964
		if($getConnectionInfo["phpUserType"]!=="intrinsic"){
30198
		if($getConnectionInfo["phpUserType"]!=="intrinsic"){
29965
			
30199
 
29966
			#如果不是擁有者的檔案/目錄 或是要變成自己以外的擁有者
30200
			#如果不是擁有者的檔案/目錄 或是要變成自己以外的擁有者
29967
			if($getConnectionInfo["phpUser"]!==$fileInfo["content"]["ownerName"] || $getConnectionInfo["phpUser"]!==$conf["owner"]){
30201
			if($getConnectionInfo["phpUser"]!==$fileInfo["content"]["ownerName"] || $getConnectionInfo["phpUser"]!==$conf["owner"]){
29968
		
30202
 
29969
				#如果是wheel成員
30203
				#如果是wheel成員
29970
				if($getConnectionInfo["phpUserType"]==="wheel"){
30204
				if($getConnectionInfo["phpUserType"]==="wheel"){
29971
				
30205
 
29972
					#代表要 sudo 在前
30206
					#代表要 sudo 在前
29973
					$chown="sudo";
30207
					$chown="sudo";
29974
					
30208
 
29975
					#函式說明:
30209
					#函式說明:
29976
					#將多個多維陣列串聯起來,key從0開始排序.
30210
					#將多個多維陣列串聯起來,key從0開始排序.
29977
					#回傳的結果:
30211
					#回傳的結果:
29978
					#$result["status"],"true"表執行正常,"false"代表執行不正常.
30212
					#$result["status"],"true"表執行正常,"false"代表執行不正常.
29979
					#$result["error"],錯誤訊息陣列.
30213
					#$result["error"],錯誤訊息陣列.
Line 29992... Line 30226...
29992
					#無.
30226
					#無.
29993
					#備註:
30227
					#備註:
29994
					#無.
30228
					#無.
29995
					$mergeMultiDimensionArray=arrays::mergeMultiDimensionArray($conf["arrays::mergeMultiDimensionArray"]);
30229
					$mergeMultiDimensionArray=arrays::mergeMultiDimensionArray($conf["arrays::mergeMultiDimensionArray"]);
29996
					unset($conf["arrays::mergeMultiDimensionArray"]);
30230
					unset($conf["arrays::mergeMultiDimensionArray"]);
29997
				
30231
 
29998
					#如果執行失敗
30232
					#如果執行失敗
29999
					if($mergeMultiDimensionArray["status"]==="false"){
30233
					if($mergeMultiDimensionArray["status"]==="false"){
30000
				
30234
 
30001
						#設置執行失敗
30235
						#設置執行失敗
30002
						$result["status"]="false";
30236
						$result["status"]="false";
30003
 
30237
 
30004
						#設置錯誤訊息
30238
						#設置錯誤訊息
30005
						$result["error"]=$mergeMultiDimensionArray;
30239
						$result["error"]=$mergeMultiDimensionArray;
30006
 
30240
 
30007
						#回傳結果
30241
						#回傳結果
30008
						return $result;
30242
						return $result;
30009
						
30243
 
30010
						}#if end
30244
						}#if end
30011
				
30245
 
30012
					#chown 在後
30246
					#chown 在後
30013
					$paramsForChown=$mergeMultiDimensionArray["content"];
30247
					$paramsForChown=$mergeMultiDimensionArray["content"];
30014
				
30248
 
30015
					}#if end
30249
					}#if end
30016
		
30250
 
30017
				#反之
30251
				#反之
30018
				else{
30252
				else{
30019
				
30253
 
30020
					#設置執行失敗
30254
					#設置執行失敗
30021
					$result["status"]="false";
30255
					$result["status"]="false";
30022
 
30256
 
30023
					#設置錯誤訊息
30257
					#設置錯誤訊息
30024
					$result["error"][]="你沒有權限變更 ".$conf["target"]." 的  file mode bits";
30258
					$result["error"][]="你沒有權限變更 ".$conf["target"]." 的  file mode bits";
Line 30026... Line 30260...
30026
					#設置錯誤訊息
30260
					#設置錯誤訊息
30027
					$result["error"][]=$getConnectionInfo;
30261
					$result["error"][]=$getConnectionInfo;
30028
 
30262
 
30029
					#回傳結果
30263
					#回傳結果
30030
					return $result;
30264
					return $result;
30031
					
30265
 
30032
					}#else end
30266
					}#else end
30033
		
30267
 
30034
				}#if end
30268
				}#if end
30035
		
30269
 
30036
			}#if end
30270
			}#if end
30037
		
30271
 
30038
		#加上要變更的目標
30272
		#加上要變更的目標
30039
		$paramsForChown[]=$conf["target"];
30273
		$paramsForChown[]=$conf["target"];
30040
	
30274
 
30041
		#函式說明:
30275
		#函式說明:
30042
		#呼叫shell執行系統命令,並取得回傳的內容.
30276
		#呼叫shell執行系統命令,並取得回傳的內容.
30043
		#回傳結果:
30277
		#回傳結果:
30044
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30278
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30045
		#$result["error"],錯誤訊息陣列.
30279
		#$result["error"],錯誤訊息陣列.
Line 30098... Line 30332...
30098
		#備註:
30332
		#備註:
30099
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
30333
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
30100
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
30334
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
30101
		$callShell=external::callShell($conf["external::callShell"]);
30335
		$callShell=external::callShell($conf["external::callShell"]);
30102
		unset($conf["external::callShell"]);
30336
		unset($conf["external::callShell"]);
30103
	
30337
 
30104
		#如果執行失敗
30338
		#如果執行失敗
30105
		if($callShell["status"]==="false"){
30339
		if($callShell["status"]==="false"){
30106
		
30340
 
30107
			#設置執行失敗
30341
			#設置執行失敗
30108
			$result["status"]="false";
30342
			$result["status"]="false";
30109
 
30343
 
30110
			#設置錯誤訊息
30344
			#設置錯誤訊息
30111
			$result["error"]=$callShell;
30345
			$result["error"]=$callShell;
30112
 
30346
 
30113
			#回傳結果
30347
			#回傳結果
30114
			return $result;
30348
			return $result;
30115
		
30349
 
30116
			}#if end
30350
			}#if end
30117
	
30351
 
30118
		#設置執行的指令
30352
		#設置執行的指令
30119
		$result["cmd"]=$callShell["cmd"];
30353
		$result["cmd"]=$callShell["cmd"];
30120
	
30354
 
30121
		#設置執行正常
30355
		#設置執行正常
30122
		$result["status"]="true";
30356
		$result["status"]="true";
30123
		
30357
 
30124
		#回傳結果
30358
		#回傳結果
30125
		return $result;
30359
		return $result;
30126
	
30360
 
30127
		}#functino chown end
30361
		}#functino chown end
30128
 
30362
 
30129
	/*
30363
	/*
30130
	#函式說明:
30364
	#函式說明:
30131
	#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
30365
	#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
Line 30148... Line 30382...
30148
	#無.
30382
	#無.
30149
	#備註:
30383
	#備註:
30150
	#無.
30384
	#無.
30151
	*/
30385
	*/
30152
	public static function chmod(&$conf){
30386
	public static function chmod(&$conf){
30153
	
30387
 
30154
		#初始化要回傳的結果
30388
		#初始化要回傳的結果
30155
		$result=array();
30389
		$result=array();
30156
 
30390
 
30157
		#取得當前執行的函數名稱
30391
		#取得當前執行的函數名稱
30158
		$result["function"]=__FUNCTION__;
30392
		$result["function"]=__FUNCTION__;
Line 30193... Line 30427...
30193
 
30427
 
30194
			#回傳結果
30428
			#回傳結果
30195
			return $result;
30429
			return $result;
30196
 
30430
 
30197
			}#if end
30431
			}#if end
30198
	
30432
 
30199
		#函式說明:
30433
		#函式說明:
30200
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
30434
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
30201
		#回傳結果:
30435
		#回傳結果:
30202
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30436
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30203
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
30437
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 30245... Line 30479...
30245
		#array_keys=>http://php.net/manual/en/function.array-keys.php
30479
		#array_keys=>http://php.net/manual/en/function.array-keys.php
30246
		#備註:
30480
		#備註:
30247
		#無.
30481
		#無.
30248
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
30482
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
30249
		unset($conf["variableCheck::checkArguments"]);
30483
		unset($conf["variableCheck::checkArguments"]);
30250
	
30484
 
30251
		#如果執行失敗
30485
		#如果執行失敗
30252
		if($checkArguments["status"]==="false"){
30486
		if($checkArguments["status"]==="false"){
30253
		
30487
 
30254
			#設置執行失敗
30488
			#設置執行失敗
30255
			$result["status"]="false";
30489
			$result["status"]="false";
30256
 
30490
 
30257
			#設置錯誤訊息
30491
			#設置錯誤訊息
30258
			$result["error"]=$checkArguments;
30492
			$result["error"]=$checkArguments;
30259
 
30493
 
30260
			#回傳結果
30494
			#回傳結果
30261
			return $result;
30495
			return $result;
30262
		
30496
 
30263
			}#if end
30497
			}#if end
30264
			
30498
 
30265
		#如果檢查不通過
30499
		#如果檢查不通過
30266
		if($checkArguments["passed"]==="false"){
30500
		if($checkArguments["passed"]==="false"){
30267
		
30501
 
30268
			#設置執行失敗
30502
			#設置執行失敗
30269
			$result["status"]="false";
30503
			$result["status"]="false";
30270
 
30504
 
30271
			#設置錯誤訊息
30505
			#設置錯誤訊息
30272
			$result["error"]=$checkArguments;
30506
			$result["error"]=$checkArguments;
30273
 
30507
 
30274
			#回傳結果
30508
			#回傳結果
30275
			return $result;
30509
			return $result;
30276
		
30510
 
30277
			}#if end
30511
			}#if end
30278
	
30512
 
30279
		#確認 $conf["target"] 存在
30513
		#確認 $conf["target"] 存在
30280
		#函式說明:
30514
		#函式說明:
30281
		#檢查多個檔案與資料夾是否存在.
30515
		#檢查多個檔案與資料夾是否存在.
30282
		#回傳的結果:
30516
		#回傳的結果:
30283
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
30517
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 30307... Line 30541...
30307
		#備註:
30541
		#備註:
30308
		#函數file_exists檢查的路徑為檔案系統的路徑
30542
		#函數file_exists檢查的路徑為檔案系統的路徑
30309
		#$result["varName"][$i]結果未實作
30543
		#$result["varName"][$i]結果未實作
30310
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
30544
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
30311
		unset($conf["fileAccess::checkMultiFileExist"]);
30545
		unset($conf["fileAccess::checkMultiFileExist"]);
30312
	
30546
 
30313
		#如果執行失敗
30547
		#如果執行失敗
30314
		if($checkMultiFileExist["status"]==="false"){
30548
		if($checkMultiFileExist["status"]==="false"){
30315
		
30549
 
30316
			#設置執行失敗
30550
			#設置執行失敗
30317
			$result["status"]="false";
30551
			$result["status"]="false";
30318
 
30552
 
30319
			#設置錯誤訊息
30553
			#設置錯誤訊息
30320
			$result["error"]=$checkMultiFileExist;
30554
			$result["error"]=$checkMultiFileExist;
30321
 
30555
 
30322
			#回傳結果
30556
			#回傳結果
30323
			return $result;
30557
			return $result;
30324
		
30558
 
30325
			}#if end
30559
			}#if end
30326
	
30560
 
30327
		#如果 target 不存在
30561
		#如果 target 不存在
30328
		if($checkMultiFileExist["allExist"]==="false"){
30562
		if($checkMultiFileExist["allExist"]==="false"){
30329
		
30563
 
30330
			#設置執行失敗
30564
			#設置執行失敗
30331
			$result["status"]="false";
30565
			$result["status"]="false";
30332
 
30566
 
30333
			#設置錯誤訊息
30567
			#設置錯誤訊息
30334
			$result["error"]=$checkMultiFileExist;
30568
			$result["error"]=$checkMultiFileExist;
30335
 
30569
 
30336
			#回傳結果
30570
			#回傳結果
30337
			return $result;
30571
			return $result;
30338
		
30572
 
30339
			}#if end
30573
			}#if end
30340
	
30574
 
30341
		#初始化給 chmod 的參數
30575
		#初始化給 chmod 的參數
30342
		$paramsForChmod=array($conf["mode"]);
30576
		$paramsForChmod=array($conf["mode"]);
30343
		
30577
 
30344
		#如果底下的內容也要一起做設定
30578
		#如果底下的內容也要一起做設定
30345
		if($conf["recursive"]==="true"){
30579
		if($conf["recursive"]==="true"){
30346
		
30580
 
30347
			#加上 -R 參數
30581
			#加上 -R 參數
30348
			$paramsForChmod[]="-R";
30582
			$paramsForChmod[]="-R";
30349
		
30583
 
30350
			#取得目標資訊
30584
			#取得目標資訊
30351
			#函式說明:
30585
			#函式說明:
30352
			#取得節點的資訊.
30586
			#取得節點的資訊.
30353
			#回傳結果:
30587
			#回傳結果:
30354
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
30588
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
30355
			#$result["error"],錯誤訊息陣列.
30589
			#$result["error"],錯誤訊息陣列.
30356
			#$result["function"],函數名稱. 
30590
			#$result["function"],函數名稱.
30357
			#$result["content"],檔案資訊陣列.
30591
			#$result["content"],檔案資訊陣列.
30358
			#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
30592
			#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
30359
			#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
30593
			#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
30360
			#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
30594
			#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
30361
			#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
30595
			#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
30362
			#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
30596
			#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
30363
			#$result["content"]["ownerName"],檔案擁有着資訊.
30597
			#$result["content"]["ownerName"],檔案擁有着資訊.
Line 30380... Line 30614...
30380
			#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
30614
			#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
30381
			#備註:
30615
			#備註:
30382
			#無.
30616
			#無.
30383
			$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
30617
			$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
30384
			unset($conf["fileAccess::fileInfo"]);
30618
			unset($conf["fileAccess::fileInfo"]);
30385
		
30619
 
30386
			#如果執行失敗
30620
			#如果執行失敗
30387
			if($fileInfo["status"]==="false"){
30621
			if($fileInfo["status"]==="false"){
30388
			
30622
 
30389
				#設置執行失敗
30623
				#設置執行失敗
30390
				$result["status"]="false";
30624
				$result["status"]="false";
30391
 
30625
 
30392
				#設置錯誤訊息
30626
				#設置錯誤訊息
30393
				$result["error"]=$fileInfo;
30627
				$result["error"]=$fileInfo;
30394
 
30628
 
30395
				#回傳結果
30629
				#回傳結果
30396
				return $result;
30630
				return $result;
30397
			
30631
 
30398
				}#if end
30632
				}#if end
30399
		
30633
 
30400
			#如果目標是資料夾
30634
			#如果目標是資料夾
30401
			if($fileInfo["content"]["is_folder"]==="true"){
30635
			if($fileInfo["content"]["is_folder"]==="true"){
30402
			
30636
 
30403
				#如果要排除目標資料夾或軟連結之類的
30637
				#如果要排除目標資料夾或軟連結之類的
30404
				if($conf["excludeSelf"]==="true"){
30638
				if($conf["excludeSelf"]==="true"){
30405
					
30639
 
30406
					#函式說明:
30640
					#函式說明:
30407
					#開啟特定目錄,取得底下的檔案路徑清單.
30641
					#開啟特定目錄,取得底下的檔案路徑清單.
30408
					#回傳結果:
30642
					#回傳結果:
30409
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30643
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30410
					#$result["error"],錯誤訊息.
30644
					#$result["error"],錯誤訊息.
30411
					#$result["function"],當前執行的函數名稱.
30645
					#$result["function"],當前執行的函數名稱.
30412
					#$result["argu"],所使用的參數.	
30646
					#$result["argu"],所使用的參數.
30413
					#$result["content"],讀取到的內容陣列.
30647
					#$result["content"],讀取到的內容陣列.
30414
					#$result["content"][$i],第$i+1個結果.
30648
					#$result["content"][$i],第$i+1個結果.
30415
					#$result["content"][$i]["name"],第$i+1個名稱.
30649
					#$result["content"][$i]["name"],第$i+1個名稱.
30416
					#$result["content"][$i]["dir"],第$i+1個檔案是否為資料夾.		
30650
					#$result["content"][$i]["dir"],第$i+1個檔案是否為資料夾.
30417
					#$result["content"][$i]["info"],第$i+1個檔案的額外資訊.
30651
					#$result["content"][$i]["info"],第$i+1個檔案的額外資訊.
30418
					#$result["content"][$i]["size"],第$i+1個檔案的大小(bytes).
30652
					#$result["content"][$i]["size"],第$i+1個檔案的大小(bytes).
30419
					#必填參數:
30653
					#必填參數:
30420
					#$conf["path"],字串,要取得檔案資訊的所屬路徑.
30654
					#$conf["path"],字串,要取得檔案資訊的所屬路徑.
30421
					$conf["fileAccess::listInfo"]["path"]=$conf["target"];
30655
					$conf["fileAccess::listInfo"]["path"]=$conf["target"];
Line 30425... Line 30659...
30425
					#無.
30659
					#無.
30426
					#備註:
30660
					#備註:
30427
					#無.
30661
					#無.
30428
					$listInfo=fileAccess::listInfo($conf["fileAccess::listInfo"]);
30662
					$listInfo=fileAccess::listInfo($conf["fileAccess::listInfo"]);
30429
					unset($conf["fileAccess::listInfo"]);
30663
					unset($conf["fileAccess::listInfo"]);
30430
				
30664
 
30431
					#如果執行失敗
30665
					#如果執行失敗
30432
					if($listInfo["status"]==="false"){
30666
					if($listInfo["status"]==="false"){
30433
				
30667
 
30434
						#設置執行失敗
30668
						#設置執行失敗
30435
						$result["status"]="false";
30669
						$result["status"]="false";
30436
 
30670
 
30437
						#設置錯誤訊息
30671
						#設置錯誤訊息
30438
						$result["error"]=$listInfo;
30672
						$result["error"]=$listInfo;
30439
 
30673
 
30440
						#回傳結果
30674
						#回傳結果
30441
						return $result;
30675
						return $result;
30442
						
30676
 
30443
						}#if end
30677
						}#if end
30444
					
30678
 
30445
					#如果底下有資料
30679
					#如果底下有資料
30446
					if(!empty($listInfo["content"])){
30680
					if(!empty($listInfo["content"])){
30447
					
30681
 
30448
						#針對每個目標
30682
						#針對每個目標
30449
						foreach($listInfo["content"] as $fileInfo){
30683
						foreach($listInfo["content"] as $fileInfo){
30450
						
30684
 
30451
							#忽略當前目錄與上層目錄
30685
							#忽略當前目錄與上層目錄
30452
							if($fileInfo["name"]==="." || $fileInfo["name"]===".."){
30686
							if($fileInfo["name"]==="." || $fileInfo["name"]===".."){
30453
							
30687
 
30454
								#跳過
30688
								#跳過
30455
								continue;
30689
								continue;
30456
							
30690
 
30457
								}#if end
30691
								}#if end
30458
							
30692
 
30459
							#函式說明:
30693
							#函式說明:
30460
							#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
30694
							#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
30461
							#回傳結果:
30695
							#回傳結果:
30462
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30696
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30463
							#$result["error"],錯誤訊息.
30697
							#$result["error"],錯誤訊息.
Line 30476... Line 30710...
30476
							#無.
30710
							#無.
30477
							#備註:
30711
							#備註:
30478
							#無.
30712
							#無.
30479
							$chmod=cmd::chmod($conf["fileAccess::chmod"]);
30713
							$chmod=cmd::chmod($conf["fileAccess::chmod"]);
30480
							unset($conf["fileAccess::chmod"]);
30714
							unset($conf["fileAccess::chmod"]);
30481
						
30715
 
30482
							#如果執行失敗
30716
							#如果執行失敗
30483
							if($chmod["status"]==="false"){
30717
							if($chmod["status"]==="false"){
30484
						
30718
 
30485
								#設置執行失敗
30719
								#設置執行失敗
30486
								$result["status"]="false";
30720
								$result["status"]="false";
30487
 
30721
 
30488
								#設置錯誤訊息
30722
								#設置錯誤訊息
30489
								$result["error"]=$chmod;
30723
								$result["error"]=$chmod;
30490
 
30724
 
30491
								#回傳結果
30725
								#回傳結果
30492
								return $result;
30726
								return $result;
30493
								
30727
 
30494
								}#if end
30728
								}#if end
30495
								
30729
 
30496
							#記錄結果
30730
							#記錄結果
30497
							$result["content"][]=$chmod;
30731
							$result["content"][]=$chmod;
30498
								
30732
 
30499
							}#foreach end
30733
							}#foreach end
30500
					
30734
 
30501
						}#if end
30735
						}#if end
30502
					
30736
 
30503
					#設置執行正常
30737
					#設置執行正常
30504
					$result["status"]="true";
30738
					$result["status"]="true";
30505
					
30739
 
30506
					#回傳結果
30740
					#回傳結果
30507
					return $result;
30741
					return $result;
30508
				
30742
 
30509
					}#if end
30743
					}#if end
30510
					
30744
 
30511
				#執行到這邊代表不用對底下內容做異動
30745
				#執行到這邊代表不用對底下內容做異動
30512
				
30746
 
30513
				}#if end
30747
				}#if end
30514
		
30748
 
30515
			#執行到這邊代表目標不是目錄
30749
			#執行到這邊代表目標不是目錄
30516
				
30750
 
30517
			}#if end
30751
			}#if end
30518
		
30752
 
30519
		#函式說明:
30753
		#函式說明:
30520
		#取得用戶端的資訊,並依據需要寫入到資料表裡面
30754
		#取得用戶端的資訊,並依據需要寫入到資料表裡面
30521
		#回傳的結果:
30755
		#回傳的結果:
30522
		#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
30756
		#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
30523
		#$result["error"],錯誤訊息.
30757
		#$result["error"],錯誤訊息.
Line 30562... Line 30796...
30562
		#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
30796
		#取得伺服器名稱與IP=>http://php.net/manual/en/function.gethostname.php
30563
		#備註:
30797
		#備註:
30564
		#無.
30798
		#無.
30565
		$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
30799
		$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
30566
		unset($conf["csInformation::getConnectionInfo"]);
30800
		unset($conf["csInformation::getConnectionInfo"]);
30567
		
30801
 
30568
		#如果執行失敗
30802
		#如果執行失敗
30569
		if($getConnectionInfo["status"]==="false"){
30803
		if($getConnectionInfo["status"]==="false"){
30570
	
30804
 
30571
			#設置執行失敗
30805
			#設置執行失敗
30572
			$result["status"]="false";
30806
			$result["status"]="false";
30573
 
30807
 
30574
			#設置錯誤訊息
30808
			#設置錯誤訊息
30575
			$result["error"]=$getConnectionInfo;
30809
			$result["error"]=$getConnectionInfo;
30576
 
30810
 
30577
			#回傳結果
30811
			#回傳結果
30578
			return $result;
30812
			return $result;
30579
			
30813
 
30580
			}#if end
30814
			}#if end
30581
		
30815
 
30582
		#取得目標資訊
30816
		#取得目標資訊
30583
		#函式說明:
30817
		#函式說明:
30584
		#取得節點的資訊.
30818
		#取得節點的資訊.
30585
		#回傳結果:
30819
		#回傳結果:
30586
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
30820
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
30587
		#$result["error"],錯誤訊息陣列.
30821
		#$result["error"],錯誤訊息陣列.
30588
		#$result["function"],函數名稱. 
30822
		#$result["function"],函數名稱.
30589
		#$result["content"],檔案資訊陣列.
30823
		#$result["content"],檔案資訊陣列.
30590
		#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
30824
		#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
30591
		#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
30825
		#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
30592
		#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
30826
		#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
30593
		#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
30827
		#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
30594
		#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
30828
		#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
30595
		#$result["content"]["ownerName"],檔案擁有着資訊.
30829
		#$result["content"]["ownerName"],檔案擁有着資訊.
Line 30612... Line 30846...
30612
		#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
30846
		#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
30613
		#備註:
30847
		#備註:
30614
		#無.
30848
		#無.
30615
		$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
30849
		$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
30616
		unset($conf["fileAccess::fileInfo"]);
30850
		unset($conf["fileAccess::fileInfo"]);
30617
	
30851
 
30618
		#如果執行失敗
30852
		#如果執行失敗
30619
		if($fileInfo["status"]==="false"){
30853
		if($fileInfo["status"]==="false"){
30620
		
30854
 
30621
			#設置執行失敗
30855
			#設置執行失敗
30622
			$result["status"]="false";
30856
			$result["status"]="false";
30623
 
30857
 
30624
			#設置錯誤訊息
30858
			#設置錯誤訊息
30625
			$result["error"]=$fileInfo;
30859
			$result["error"]=$fileInfo;
30626
 
30860
 
30627
			#回傳結果
30861
			#回傳結果
30628
			return $result;
30862
			return $result;
30629
		
30863
 
30630
			}#if end
30864
			}#if end
30631
		
30865
 
30632
		/*
30866
		/*
30633
		#debug
30867
		#debug
30634
		$fsock=fopen("/tmp/test.log","w");
30868
		$fsock=fopen("/tmp/test.log","w");
30635
		fwrite($fsock,$getConnectionInfo["phpUser"]);
30869
		fwrite($fsock,$getConnectionInfo["phpUser"]);
30636
		fwrite($fsock,$fileInfo["content"]["ownerName"]);
30870
		fwrite($fsock,$fileInfo["content"]["ownerName"]);
30637
		*/
30871
		*/
30638
		
30872
 
30639
		#初始化 chmod 指令
30873
		#初始化 chmod 指令
30640
		$chmod="chmod";
30874
		$chmod="chmod";
30641
		
30875
 
30642
		#如果不是root賬戶在運行
30876
		#如果不是root賬戶在運行
30643
		if($getConnectionInfo["phpUserType"]!=="intrinsic"){
30877
		if($getConnectionInfo["phpUserType"]!=="intrinsic"){
30644
		
30878
 
30645
			#如果不是擁有者的檔案/目錄
30879
			#如果不是擁有者的檔案/目錄
30646
			if($getConnectionInfo["phpUser"]!==$fileInfo["content"]["ownerName"]){
30880
			if($getConnectionInfo["phpUser"]!==$fileInfo["content"]["ownerName"]){
30647
		
30881
 
30648
				#如果是wheel成員
30882
				#如果是wheel成員
30649
				if($getConnectionInfo["phpUserType"]==="wheel"){
30883
				if($getConnectionInfo["phpUserType"]==="wheel"){
30650
				
30884
 
30651
					#代表要 sudo 在前
30885
					#代表要 sudo 在前
30652
					$chmod="sudo";
30886
					$chmod="sudo";
30653
				
30887
 
30654
					#函式說明:
30888
					#函式說明:
30655
					#將多個多維陣列串聯起來,key從0開始排序.
30889
					#將多個多維陣列串聯起來,key從0開始排序.
30656
					#回傳的結果:
30890
					#回傳的結果:
30657
					#$result["status"],"true"表執行正常,"false"代表執行不正常.
30891
					#$result["status"],"true"表執行正常,"false"代表執行不正常.
30658
					#$result["error"],錯誤訊息陣列.
30892
					#$result["error"],錯誤訊息陣列.
Line 30671... Line 30905...
30671
					#無.
30905
					#無.
30672
					#備註:
30906
					#備註:
30673
					#無.
30907
					#無.
30674
					$mergeMultiDimensionArray=arrays::mergeMultiDimensionArray($conf["arrays::mergeMultiDimensionArray"]);
30908
					$mergeMultiDimensionArray=arrays::mergeMultiDimensionArray($conf["arrays::mergeMultiDimensionArray"]);
30675
					unset($conf["arrays::mergeMultiDimensionArray"]);
30909
					unset($conf["arrays::mergeMultiDimensionArray"]);
30676
				
30910
 
30677
					#如果執行失敗
30911
					#如果執行失敗
30678
					if($mergeMultiDimensionArray["status"]==="false"){
30912
					if($mergeMultiDimensionArray["status"]==="false"){
30679
				
30913
 
30680
						#設置執行失敗
30914
						#設置執行失敗
30681
						$result["status"]="false";
30915
						$result["status"]="false";
30682
 
30916
 
30683
						#設置錯誤訊息
30917
						#設置錯誤訊息
30684
						$result["error"]=$mergeMultiDimensionArray;
30918
						$result["error"]=$mergeMultiDimensionArray;
30685
 
30919
 
30686
						#回傳結果
30920
						#回傳結果
30687
						return $result;
30921
						return $result;
30688
						
30922
 
30689
						}#if end
30923
						}#if end
30690
				
30924
 
30691
					#chmod 在後
30925
					#chmod 在後
30692
					$paramsForChmod=$mergeMultiDimensionArray["content"];
30926
					$paramsForChmod=$mergeMultiDimensionArray["content"];
30693
				
30927
 
30694
					}#if end
30928
					}#if end
30695
		
30929
 
30696
				#反之
30930
				#反之
30697
				else{
30931
				else{
30698
				
30932
 
30699
					#設置執行失敗
30933
					#設置執行失敗
30700
					$result["status"]="false";
30934
					$result["status"]="false";
30701
 
30935
 
30702
					#設置錯誤訊息
30936
					#設置錯誤訊息
30703
					$result["error"][]="你沒有權限變更 ".$conf["target"]." 的  file mode bits";
30937
					$result["error"][]="你沒有權限變更 ".$conf["target"]." 的  file mode bits";
Line 30708... Line 30942...
30708
					#設置錯誤訊息
30942
					#設置錯誤訊息
30709
					$result["error"][]=$fileInfo["content"];
30943
					$result["error"][]=$fileInfo["content"];
30710
 
30944
 
30711
					#回傳結果
30945
					#回傳結果
30712
					return $result;
30946
					return $result;
30713
					
30947
 
30714
					}#else end
30948
					}#else end
30715
		
30949
 
30716
				}#if end
30950
				}#if end
30717
		
30951
 
30718
			}#if end
30952
			}#if end
30719
		
30953
 
30720
		#加上要變更的目標
30954
		#加上要變更的目標
30721
		$paramsForChmod[]=$conf["target"];
30955
		$paramsForChmod[]=$conf["target"];
30722
		
30956
 
30723
		#函式說明:
30957
		#函式說明:
30724
		#呼叫shell執行系統命令,並取得回傳的內容.
30958
		#呼叫shell執行系統命令,並取得回傳的內容.
30725
		#回傳結果:
30959
		#回傳結果:
30726
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30960
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30727
		#$result["error"],錯誤訊息陣列.
30961
		#$result["error"],錯誤訊息陣列.
Line 30780... Line 31014...
30780
		#備註:
31014
		#備註:
30781
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
31015
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
30782
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
31016
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
30783
		$callShell=external::callShell($conf["external::callShell"]);
31017
		$callShell=external::callShell($conf["external::callShell"]);
30784
		unset($conf["external::callShell"]);
31018
		unset($conf["external::callShell"]);
30785
	
31019
 
30786
		#如果執行失敗
31020
		#如果執行失敗
30787
		if($callShell["status"]==="false"){
31021
		if($callShell["status"]==="false"){
30788
		
31022
 
30789
			#設置執行失敗
31023
			#設置執行失敗
30790
			$result["status"]="false";
31024
			$result["status"]="false";
30791
 
31025
 
30792
			#設置錯誤訊息
31026
			#設置錯誤訊息
30793
			$result["error"]=$callShell;
31027
			$result["error"]=$callShell;
30794
 
31028
 
30795
			#回傳結果
31029
			#回傳結果
30796
			return $result;
31030
			return $result;
30797
		
31031
 
30798
			}#if end
31032
			}#if end
30799
	
31033
 
30800
		#設置執行的指令
31034
		#設置執行的指令
30801
		$result["cmd"]=$callShell["cmd"];
31035
		$result["cmd"]=$callShell["cmd"];
30802
	
31036
 
30803
		#設置執行正常
31037
		#設置執行正常
30804
		$result["status"]="true";
31038
		$result["status"]="true";
30805
		
31039
 
30806
		#回傳結果
31040
		#回傳結果
30807
		return $result;
31041
		return $result;
30808
	
31042
 
30809
		}#function chmod end
31043
		}#function chmod end
30810
 
31044
 
30811
	/*
31045
	/*
30812
	#函式說明:
31046
	#函式說明:
30813
	#使用 linux 的 uuid 指令來產生 uuid 字串
31047
	#使用 linux 的 uuid 指令來產生 uuid 字串
Line 30824... Line 31058...
30824
	#無.
31058
	#無.
30825
	#備註:
31059
	#備註:
30826
	#無.
31060
	#無.
30827
	*/
31061
	*/
30828
	public static function uuid(){
31062
	public static function uuid(){
30829
	
31063
 
30830
		#初始化要回傳的結果
31064
		#初始化要回傳的結果
30831
		$result=array();
31065
		$result=array();
30832
 
31066
 
30833
		#取得當前執行的函數名稱
31067
		#取得當前執行的函數名稱
30834
		$result["function"]=__FUNCTION__;
31068
		$result["function"]=__FUNCTION__;
30835
		
31069
 
30836
		#函式說明:
31070
		#函式說明:
30837
		#呼叫shell執行系統命令,並取得回傳的內容.
31071
		#呼叫shell執行系統命令,並取得回傳的內容.
30838
		#回傳結果:
31072
		#回傳結果:
30839
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31073
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
30840
		#$result["error"],錯誤訊息陣列.
31074
		#$result["error"],錯誤訊息陣列.
Line 30893... Line 31127...
30893
		#備註:
31127
		#備註:
30894
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
31128
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
30895
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
31129
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
30896
		$callShell=external::callShell($conf["external::callShell"]);
31130
		$callShell=external::callShell($conf["external::callShell"]);
30897
		unset($conf["external::callShell"]);
31131
		unset($conf["external::callShell"]);
30898
	
31132
 
30899
		#如果執行失敗
31133
		#如果執行失敗
30900
		if($callShell["status"]==="false"){
31134
		if($callShell["status"]==="false"){
30901
		
31135
 
30902
			#設置執行失敗
31136
			#設置執行失敗
30903
			$result["status"]="false";
31137
			$result["status"]="false";
30904
 
31138
 
30905
			#設置錯誤訊息
31139
			#設置錯誤訊息
30906
			$result["error"]=$callShell;
31140
			$result["error"]=$callShell;
30907
 
31141
 
30908
			#回傳結果
31142
			#回傳結果
30909
			return $result;
31143
			return $result;
30910
		
31144
 
30911
			}#if end
31145
			}#if end
30912
		
31146
 
30913
		#如果沒有預期的 uuid 結果
31147
		#如果沒有預期的 uuid 結果
30914
		if(!isset($callShell["output"][0])){
31148
		if(!isset($callShell["output"][0])){
30915
		
31149
 
30916
			#設置執行失敗
31150
			#設置執行失敗
30917
			$result["status"]="false";
31151
			$result["status"]="false";
30918
 
31152
 
30919
			#設置錯誤訊息
31153
			#設置錯誤訊息
30920
			$result["error"][]="沒有預期的 uuid 輸出";
31154
			$result["error"][]="沒有預期的 uuid 輸出";
Line 30922... Line 31156...
30922
			#設置錯誤訊息
31156
			#設置錯誤訊息
30923
			$result["error"][]=$callShell;
31157
			$result["error"][]=$callShell;
30924
 
31158
 
30925
			#回傳結果
31159
			#回傳結果
30926
			return $result;
31160
			return $result;
30927
		
31161
 
30928
			}#if end
31162
			}#if end
30929
			
31163
 
30930
		#取得結果	
31164
		#取得結果
30931
		$result["content"]=$callShell["output"][0];
31165
		$result["content"]=$callShell["output"][0];
30932
	
31166
 
30933
		#設置執行正常
31167
		#設置執行正常
30934
		$result["status"]="true";
31168
		$result["status"]="true";
30935
	
31169
 
30936
		#回傳結果
31170
		#回傳結果
30937
		return $result;
31171
		return $result;
30938
	
31172
 
30939
		}#function uuid end
31173
		}#function uuid end
30940
 
31174
 
30941
	/*
31175
	/*
30942
	#函式說明:
31176
	#函式說明:
30943
	#將 freeplane 軟體支持的 mm 格式檔案跨平台.
31177
	#將 freeplane 軟體支持的 mm 格式檔案跨平台.
Line 30960... Line 31194...
30960
	#https://www.php.net/manual/en/simplexmlelement.tostring.php
31194
	#https://www.php.net/manual/en/simplexmlelement.tostring.php
30961
	#備註:
31195
	#備註:
30962
	#無.
31196
	#無.
30963
	*/
31197
	*/
30964
	public static function msPortable(&$conf){
31198
	public static function msPortable(&$conf){
30965
	
31199
 
30966
		#初始化要回傳的結果
31200
		#初始化要回傳的結果
30967
		$result=array();
31201
		$result=array();
30968
 
31202
 
30969
		#取得當前執行的函數名稱
31203
		#取得當前執行的函數名稱
30970
		$result["function"]=__FUNCTION__;
31204
		$result["function"]=__FUNCTION__;
Line 31005... Line 31239...
31005
 
31239
 
31006
			#回傳結果
31240
			#回傳結果
31007
			return $result;
31241
			return $result;
31008
 
31242
 
31009
			}#if end
31243
			}#if end
31010
	
31244
 
31011
		#函式說明:
31245
		#函式說明:
31012
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
31246
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
31013
		#回傳結果:
31247
		#回傳結果:
31014
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31248
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31015
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
31249
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 31057... Line 31291...
31057
		#array_keys=>http://php.net/manual/en/function.array-keys.php
31291
		#array_keys=>http://php.net/manual/en/function.array-keys.php
31058
		#備註:
31292
		#備註:
31059
		#無.
31293
		#無.
31060
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
31294
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
31061
		unset($conf["variableCheck::checkArguments"]);
31295
		unset($conf["variableCheck::checkArguments"]);
31062
	
31296
 
31063
		#如果執行失敗
31297
		#如果執行失敗
31064
		if($checkArguments["status"]==="false"){
31298
		if($checkArguments["status"]==="false"){
31065
		
31299
 
31066
			#設置執行失敗
31300
			#設置執行失敗
31067
			$result["status"]="false";
31301
			$result["status"]="false";
31068
 
31302
 
31069
			#設置錯誤訊息
31303
			#設置錯誤訊息
31070
			$result["error"]=$checkArguments;
31304
			$result["error"]=$checkArguments;
31071
 
31305
 
31072
			#回傳結果
31306
			#回傳結果
31073
			return $result;
31307
			return $result;
31074
		
31308
 
31075
			}#if end
31309
			}#if end
31076
			
31310
 
31077
		#如果檢查不通過
31311
		#如果檢查不通過
31078
		if($checkArguments["passed"]==="false"){
31312
		if($checkArguments["passed"]==="false"){
31079
		
31313
 
31080
			#設置執行失敗
31314
			#設置執行失敗
31081
			$result["status"]="false";
31315
			$result["status"]="false";
31082
 
31316
 
31083
			#設置錯誤訊息
31317
			#設置錯誤訊息
31084
			$result["error"]=$checkArguments;
31318
			$result["error"]=$checkArguments;
31085
 
31319
 
31086
			#回傳結果
31320
			#回傳結果
31087
			return $result;
31321
			return $result;
31088
		
31322
 
31089
			}#if end
31323
			}#if end
31090
	
31324
 
31091
		#如果沒有設置輸出的檔案位置與名稱
31325
		#如果沒有設置輸出的檔案位置與名稱
31092
		if(!isset($conf["output"])){
31326
		if(!isset($conf["output"])){
31093
		
31327
 
31094
			#函式說明:
31328
			#函式說明:
31095
			#將字串特定關鍵字與其後面的內容剔除
31329
			#將字串特定關鍵字與其後面的內容剔除
31096
			#回傳結果:
31330
			#回傳結果:
31097
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31331
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31098
			#$result["error"],錯誤訊息陣列.
31332
			#$result["error"],錯誤訊息陣列.
Line 31113... Line 31347...
31113
			#無.
31347
			#無.
31114
			#備註:
31348
			#備註:
31115
			#無.
31349
			#無.
31116
			$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
31350
			$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
31117
			unset($conf["stringProcess::delStrAfterKeyWord"]);
31351
			unset($conf["stringProcess::delStrAfterKeyWord"]);
31118
		
31352
 
31119
			#如果執行失敗
31353
			#如果執行失敗
31120
			if($delStrAfterKeyWord["status"]==="false"){
31354
			if($delStrAfterKeyWord["status"]==="false"){
31121
			
31355
 
31122
				#設置執行失敗
31356
				#設置執行失敗
31123
				$result["status"]="false";
31357
				$result["status"]="false";
31124
 
31358
 
31125
				#設置錯誤訊息
31359
				#設置錯誤訊息
31126
				$result["error"]=$delStrAfterKeyWord;
31360
				$result["error"]=$delStrAfterKeyWord;
31127
 
31361
 
31128
				#回傳結果
31362
				#回傳結果
31129
				return $result;
31363
				return $result;
31130
			
31364
 
31131
				}#if end
31365
				}#if end
31132
		
31366
 
31133
			#如果沒有符合的關鍵字 ".mm"
31367
			#如果沒有符合的關鍵字 ".mm"
31134
			if($delStrAfterKeyWord["founded"]==="false"){
31368
			if($delStrAfterKeyWord["founded"]==="false"){
31135
			
31369
 
31136
				#設置執行失敗
31370
				#設置執行失敗
31137
				$result["status"]="false";
31371
				$result["status"]="false";
31138
 
31372
 
31139
				#設置錯誤訊息
31373
				#設置錯誤訊息
31140
				$result["error"]=$delStrAfterKeyWord;
31374
				$result["error"]=$delStrAfterKeyWord;
31141
 
31375
 
31142
				#回傳結果
31376
				#回傳結果
31143
				return $result;
31377
				return $result;
31144
			
31378
 
31145
				}#if end
31379
				}#if end
31146
		
31380
 
31147
			#設置預設的輸出檔案路徑與名稱
31381
			#設置預設的輸出檔案路徑與名稱
31148
			$conf["output"]=$delStrAfterKeyWord["content"]."-1.mm";
31382
			$conf["output"]=$delStrAfterKeyWord["content"]."-1.mm";
31149
		
31383
 
31150
			}#if end
31384
			}#if end
31151
		
31385
 
31152
		#確認 $conf["target"] 存在
31386
		#確認 $conf["target"] 存在
31153
		#函式說明:
31387
		#函式說明:
31154
		#檢查多個檔案與資料夾是否存在.
31388
		#檢查多個檔案與資料夾是否存在.
31155
		#回傳的結果:
31389
		#回傳的結果:
31156
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
31390
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 31180... Line 31414...
31180
		#備註:
31414
		#備註:
31181
		#函數file_exists檢查的路徑為檔案系統的路徑
31415
		#函數file_exists檢查的路徑為檔案系統的路徑
31182
		#$result["varName"][$i]結果未實作
31416
		#$result["varName"][$i]結果未實作
31183
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
31417
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
31184
		unset($conf["fileAccess::checkMultiFileExist"]);
31418
		unset($conf["fileAccess::checkMultiFileExist"]);
31185
	
31419
 
31186
		#如果執行失敗
31420
		#如果執行失敗
31187
		if($checkMultiFileExist["status"]==="false"){
31421
		if($checkMultiFileExist["status"]==="false"){
31188
		
31422
 
31189
			#設置執行失敗
31423
			#設置執行失敗
31190
			$result["status"]="false";
31424
			$result["status"]="false";
31191
 
31425
 
31192
			#設置錯誤訊息
31426
			#設置錯誤訊息
31193
			$result["error"]=$checkMultiFileExist;
31427
			$result["error"]=$checkMultiFileExist;
31194
 
31428
 
31195
			#回傳結果
31429
			#回傳結果
31196
			return $result;
31430
			return $result;
31197
		
31431
 
31198
			}#if end
31432
			}#if end
31199
	
31433
 
31200
		#如果 target 不存在
31434
		#如果 target 不存在
31201
		if($checkMultiFileExist["allExist"]==="false"){
31435
		if($checkMultiFileExist["allExist"]==="false"){
31202
		
31436
 
31203
			#設置執行失敗
31437
			#設置執行失敗
31204
			$result["status"]="false";
31438
			$result["status"]="false";
31205
 
31439
 
31206
			#設置錯誤訊息
31440
			#設置錯誤訊息
31207
			$result["error"]=$checkMultiFileExist;
31441
			$result["error"]=$checkMultiFileExist;
31208
 
31442
 
31209
			#回傳結果
31443
			#回傳結果
31210
			return $result;
31444
			return $result;
31211
		
31445
 
31212
			}#if end
31446
			}#if end
31213
			
31447
 
31214
		#函式說明:
31448
		#函式說明:
31215
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
31449
		#讀取xml檔案,儲存所有標籤的內容,目前尚不能讀取屬性的資訊
31216
		#回傳結果:
31450
		#回傳結果:
31217
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31451
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31218
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
31452
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 31235... Line 31469...
31235
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
31469
		#取得處理xml的錯誤訊息=>http://php.net/manual/en/function.libxml-get-errors.php
31236
		#備註:
31470
		#備註:
31237
		#無.
31471
		#無.
31238
		$getContent=xml::getContent($conf["xml::getContent"]);
31472
		$getContent=xml::getContent($conf["xml::getContent"]);
31239
		unset($conf["xml::getContent"]);
31473
		unset($conf["xml::getContent"]);
31240
		
31474
 
31241
		#如果執行失敗
31475
		#如果執行失敗
31242
		if($getContent["status"]==="false"){
31476
		if($getContent["status"]==="false"){
31243
		
31477
 
31244
			#設置執行失敗
31478
			#設置執行失敗
31245
			$result["status"]="false";
31479
			$result["status"]="false";
31246
 
31480
 
31247
			#設置錯誤訊息
31481
			#設置錯誤訊息
31248
			$result["error"]=$getContent;
31482
			$result["error"]=$getContent;
31249
 
31483
 
31250
			#回傳結果
31484
			#回傳結果
31251
			return $result;
31485
			return $result;
31252
		
31486
 
31253
			}#if end
31487
			}#if end
31254
			
31488
 
31255
		#如果xml檔案不存在
31489
		#如果xml檔案不存在
31256
		if($getContent["founded"]==="false"){
31490
		if($getContent["founded"]==="false"){
31257
		
31491
 
31258
			#設置執行失敗
31492
			#設置執行失敗
31259
			$result["status"]="false";
31493
			$result["status"]="false";
31260
 
31494
 
31261
			#設置錯誤訊息
31495
			#設置錯誤訊息
31262
			$result["error"]=$getContent;
31496
			$result["error"]=$getContent;
31263
 
31497
 
31264
			#回傳結果
31498
			#回傳結果
31265
			return $result;
31499
			return $result;
31266
		
31500
 
31267
			}#if end
31501
			}#if end
31268
		
31502
 
31269
		#初始化要解析的 simeple xml object
31503
		#初始化要解析的 simeple xml object
31270
		$searchArray=array(&$getContent["content"]);
31504
		$searchArray=array(&$getContent["content"]);
31271
			
31505
 
31272
		#有幾個要解析的 simeple xml object 就執行幾次
31506
		#有幾個要解析的 simeple xml object 就執行幾次
31273
		for($i=0;$i<count($searchArray);$i++){
31507
		for($i=0;$i<count($searchArray);$i++){
31274
			
31508
 
31275
			#初始化基準點
31509
			#初始化基準點
31276
			$base=&$searchArray[$i];
31510
			$base=&$searchArray[$i];
31277
		
31511
 
31278
			#如果存在node子階層
31512
			#如果存在node子階層
31279
			if(isset($base->node)){
31513
			if(isset($base->node)){
31280
								
31514
 
31281
				#針對每個同名的node階層
31515
				#針對每個同名的node階層
31282
				for($j=0;$j<count($base->node);$j++){
31516
				for($j=0;$j<count($base->node);$j++){
31283
				
31517
 
31284
					#取得階層的位置
31518
					#取得階層的位置
31285
					$tempLayer=&($base->node)[$j];
31519
					$tempLayer=&($base->node)[$j];
31286
				
31520
 
31287
					#如果下一層有 hook
31521
					#如果下一層有 hook
31288
					if(isset($tempLayer->hook)){
31522
					if(isset($tempLayer->hook)){
31289
					
31523
 
31290
						#針對底下的屬性
31524
						#針對底下的屬性
31291
						foreach($tempLayer->hook->attributes() as $attrName => $attrValue){
31525
						foreach($tempLayer->hook->attributes() as $attrName => $attrValue){
31292
						
31526
 
31293
							#如果有指定 URI
31527
							#如果有指定 URI
31294
							if($attrName==="URI" && $attrValue!==""){
31528
							if($attrName==="URI" && $attrValue!==""){
31295
																	
-
 
-
 
31529
 
31296
								#更新 URI 位置
31530
								#更新 URI 位置
31297
								$tempLayer->hook->attributes()->$attrName=$conf["imgFolder"]."/".basename($attrValue);
31531
								$tempLayer->hook->attributes()->$attrName=$conf["imgFolder"]."/".basename($attrValue);
31298
							
31532
 
31299
								#設置 SIZE 為 1.0
31533
								#設置 SIZE 為 1.0
31300
								$tempLayer->hook->attributes()->SIZE="1.0";
31534
								$tempLayer->hook->attributes()->SIZE="1.0";
31301
								
31535
 
31302
								}#if end
31536
								}#if end
31303
						
31537
 
31304
							}#foreach end
31538
							}#foreach end
31305
					
31539
 
31306
						}#if end
31540
						}#if end
31307
						
31541
 
31308
					#保存待處理的 simple xml object
31542
					#保存待處理的 simple xml object
31309
					$searchArray[]=&$tempLayer;
31543
					$searchArray[]=&$tempLayer;
31310
					
31544
 
31311
					}#for end
31545
					}#for end
31312
									
31546
 
31313
				}#if end
31547
				}#if end
31314
		
31548
 
31315
			}#for end		
31549
			}#for end
31316
		
31550
 
31317
		#取得更新後的 simple xml object
31551
		#取得更新後的 simple xml object
31318
		$result["content"]=$getContent["content"];
31552
		$result["content"]=$getContent["content"];
31319
		
31553
 
31320
		#建立新 mm 檔案
31554
		#建立新 mm 檔案
31321
		#函式說明:
31555
		#函式說明:
31322
		#將字串寫入到檔案
31556
		#將字串寫入到檔案
31323
		#回傳結果:
31557
		#回傳結果:
31324
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
31558
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 31351... Line 31585...
31351
		#無.
31585
		#無.
31352
		#備註:
31586
		#備註:
31353
		#無.
31587
		#無.
31354
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
31588
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
31355
		unset($conf["fileAccess::writeTextIntoFile"]);
31589
		unset($conf["fileAccess::writeTextIntoFile"]);
31356
		
31590
 
31357
		#如果執行失敗
31591
		#如果執行失敗
31358
		if($writeTextIntoFile["status"]==="false"){
31592
		if($writeTextIntoFile["status"]==="false"){
31359
		
31593
 
31360
			#設置執行失敗
31594
			#設置執行失敗
31361
			$result["status"]="false";
31595
			$result["status"]="false";
31362
 
31596
 
31363
			#設置錯誤訊息
31597
			#設置錯誤訊息
31364
			$result["error"]=$writeTextIntoFile;
31598
			$result["error"]=$writeTextIntoFile;
31365
 
31599
 
31366
			#回傳結果
31600
			#回傳結果
31367
			return $result;
31601
			return $result;
31368
		
31602
 
31369
			}#if end
31603
			}#if end
31370
		
31604
 
31371
		#設置執行正常
31605
		#設置執行正常
31372
		$result["status"]="true";
31606
		$result["status"]="true";
31373
				
31607
 
31374
		#回傳結果
31608
		#回傳結果
31375
		return $result;
31609
		return $result;
31376
		
31610
 
31377
		}#function msPortable end
31611
		}#function msPortable end
31378
 
31612
 
31379
	/*
31613
	/*
31380
	#函式說明:
31614
	#函式說明:
31381
	#使用 linux 的 rsync 指令來進行備份檔案.
31615
	#使用 linux 的 rsync 指令來進行備份檔案.
Line 31408... Line 31642...
31408
	#無
31642
	#無
31409
	#備註:
31643
	#備註:
31410
	#無.
31644
	#無.
31411
	*/
31645
	*/
31412
	public static function rsync(&$conf){
31646
	public static function rsync(&$conf){
31413
	
31647
 
31414
		#初始化要回傳的結果
31648
		#初始化要回傳的結果
31415
		$result=array();
31649
		$result=array();
31416
 
31650
 
31417
		#取得當前執行的函數名稱
31651
		#取得當前執行的函數名稱
31418
		$result["function"]=__FUNCTION__;
31652
		$result["function"]=__FUNCTION__;
Line 31453... Line 31687...
31453
 
31687
 
31454
			#回傳結果
31688
			#回傳結果
31455
			return $result;
31689
			return $result;
31456
 
31690
 
31457
			}#if end
31691
			}#if end
31458
	
31692
 
31459
		#函式說明:
31693
		#函式說明:
31460
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
31694
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
31461
		#回傳結果:
31695
		#回傳結果:
31462
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31696
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
31463
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
31697
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 31505... Line 31739...
31505
		#array_keys=>http://php.net/manual/en/function.array-keys.php
31739
		#array_keys=>http://php.net/manual/en/function.array-keys.php
31506
		#備註:
31740
		#備註:
31507
		#無.
31741
		#無.
31508
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
31742
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
31509
		unset($conf["variableCheck::checkArguments"]);
31743
		unset($conf["variableCheck::checkArguments"]);
31510
	
31744
 
31511
		#如果執行失敗
31745
		#如果執行失敗
31512
		if($checkArguments["status"]==="false"){
31746
		if($checkArguments["status"]==="false"){
31513
		
31747
 
31514
			#設置執行失敗
31748
			#設置執行失敗
31515
			$result["status"]="false";
31749
			$result["status"]="false";
31516
 
31750
 
31517
			#設置錯誤訊息
31751
			#設置錯誤訊息
31518
			$result["error"]=$checkArguments;
31752
			$result["error"]=$checkArguments;
31519
 
31753
 
31520
			#回傳結果
31754
			#回傳結果
31521
			return $result;
31755
			return $result;
31522
		
31756
 
31523
			}#if end
31757
			}#if end
31524
			
31758
 
31525
		#如果檢查不通過
31759
		#如果檢查不通過
31526
		if($checkArguments["passed"]==="false"){
31760
		if($checkArguments["passed"]==="false"){
31527
		
31761
 
31528
			#設置執行失敗
31762
			#設置執行失敗
31529
			$result["status"]="false";
31763
			$result["status"]="false";
31530
 
31764
 
31531
			#設置錯誤訊息
31765
			#設置錯誤訊息
31532
			$result["error"]=$checkArguments;
31766
			$result["error"]=$checkArguments;
31533
 
31767
 
31534
			#回傳結果
31768
			#回傳結果
31535
			return $result;
31769
			return $result;
31536
		
31770
 
31537
			}#if end
31771
			}#if end
31538
	
31772
 
31539
		#確認 $conf["source"] 存在
31773
		#確認 $conf["source"] 存在
31540
		#函式說明:
31774
		#函式說明:
31541
		#檢查多個檔案與資料夾是否存在.
31775
		#檢查多個檔案與資料夾是否存在.
31542
		#回傳的結果:
31776
		#回傳的結果:
31543
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
31777
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 31567... Line 31801...
31567
		#備註:
31801
		#備註:
31568
		#函數file_exists檢查的路徑為檔案系統的路徑
31802
		#函數file_exists檢查的路徑為檔案系統的路徑
31569
		#$result["varName"][$i]結果未實作
31803
		#$result["varName"][$i]結果未實作
31570
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
31804
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
31571
		unset($conf["fileAccess::checkMultiFileExist"]);
31805
		unset($conf["fileAccess::checkMultiFileExist"]);
31572
	
31806
 
31573
		#如果執行失敗
31807
		#如果執行失敗
31574
		if($checkMultiFileExist["status"]==="false"){
31808
		if($checkMultiFileExist["status"]==="false"){
31575
		
31809
 
31576
			#設置執行失敗
31810
			#設置執行失敗
31577
			$result["status"]="false";
31811
			$result["status"]="false";
31578
 
31812
 
31579
			#設置錯誤訊息
31813
			#設置錯誤訊息
31580
			$result["error"]=$checkMultiFileExist;
31814
			$result["error"]=$checkMultiFileExist;
31581
 
31815
 
31582
			#回傳結果
31816
			#回傳結果
31583
			return $result;
31817
			return $result;
31584
		
31818
 
31585
			}#if end
31819
			}#if end
31586
	
31820
 
31587
		#如果 source 不存在
31821
		#如果 source 不存在
31588
		if($checkMultiFileExist["allExist"]==="false"){
31822
		if($checkMultiFileExist["allExist"]==="false"){
31589
		
31823
 
31590
			#設置執行失敗
31824
			#設置執行失敗
31591
			$result["status"]="false";
31825
			$result["status"]="false";
31592
 
31826
 
31593
			#設置錯誤訊息
31827
			#設置錯誤訊息
31594
			$result["error"]=$checkMultiFileExist;
31828
			$result["error"]=$checkMultiFileExist;
31595
 
31829
 
31596
			#回傳結果
31830
			#回傳結果
31597
			return $result;
31831
			return $result;
31598
		
31832
 
31599
			}#if end
31833
			}#if end
31600
	
31834
 
31601
		#如果要複製的目標不為 "/" 結尾
31835
		#如果要複製的目標不為 "/" 結尾
31602
		#函式說明:
31836
		#函式說明:
31603
		#取得符合特定字首與字尾的字串
31837
		#取得符合特定字首與字尾的字串
31604
		#回傳結果:
31838
		#回傳結果:
31605
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
31839
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 31621... Line 31855...
31621
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
31855
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
31622
		#備註:
31856
		#備註:
31623
		#無.
31857
		#無.
31624
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
31858
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
31625
		unset($conf["search::getMeetConditionsString"]);
31859
		unset($conf["search::getMeetConditionsString"]);
31626
		
31860
 
31627
		#如果執行失敗
31861
		#如果執行失敗
31628
		if($getMeetConditionsString["status"]==="false"){
31862
		if($getMeetConditionsString["status"]==="false"){
31629
		
31863
 
31630
			#設置執行失敗
31864
			#設置執行失敗
31631
			$result["status"]="false";
31865
			$result["status"]="false";
31632
 
31866
 
31633
			#設置錯誤訊息
31867
			#設置錯誤訊息
31634
			$result["error"]=$getMeetConditionsString;
31868
			$result["error"]=$getMeetConditionsString;
31635
 
31869
 
31636
			#回傳結果
31870
			#回傳結果
31637
			return $result;
31871
			return $result;
31638
		
31872
 
31639
			}#if end
31873
			}#if end
31640
			
31874
 
31641
		#如果不是"/"結尾
31875
		#如果不是"/"結尾
31642
		if($getMeetConditionsString["founded"]==="false"){
31876
		if($getMeetConditionsString["founded"]==="false"){
31643
			
31877
 
31644
			#來源不是資料夾
31878
			#來源不是資料夾
31645
			$sourceIsFolder="false";
31879
			$sourceIsFolder="false";
31646
		
31880
 
31647
			#取得來源目錄或檔案的資訊
31881
			#取得來源目錄或檔案的資訊
31648
			#函式說明:
31882
			#函式說明:
31649
			#取得節點的資訊.
31883
			#取得節點的資訊.
31650
			#回傳結果:
31884
			#回傳結果:
31651
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
31885
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
31652
			#$result["error"],錯誤訊息陣列.
31886
			#$result["error"],錯誤訊息陣列.
31653
			#$result["function"],函數名稱. 
31887
			#$result["function"],函數名稱.
31654
			#$result["content"],檔案資訊陣列.
31888
			#$result["content"],檔案資訊陣列.
31655
			#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
31889
			#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
31656
			#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
31890
			#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
31657
			#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
31891
			#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
31658
			#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
31892
			#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
31659
			#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
31893
			#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
31660
			#$result["content"]["ownerName"],檔案擁有着資訊.
31894
			#$result["content"]["ownerName"],檔案擁有着資訊.
Line 31676... Line 31910...
31676
			#fileowner=>http://php.net/manual/en/function.fileowner.php
31910
			#fileowner=>http://php.net/manual/en/function.fileowner.php
31677
			#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
31911
			#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
31678
			#備註:
31912
			#備註:
31679
			$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
31913
			$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
31680
			unset($conf["fileAccess::fileInfo"]);
31914
			unset($conf["fileAccess::fileInfo"]);
31681
		
31915
 
31682
			#如果執行失敗
31916
			#如果執行失敗
31683
			if($fileInfo["status"]==="false"){
31917
			if($fileInfo["status"]==="false"){
31684
			
31918
 
31685
				#設置執行失敗
31919
				#設置執行失敗
31686
				$result["status"]="false";
31920
				$result["status"]="false";
31687
 
31921
 
31688
				#設置錯誤訊息
31922
				#設置錯誤訊息
31689
				$result["error"]=$fileInfo;
31923
				$result["error"]=$fileInfo;
31690
 
31924
 
31691
				#回傳結果
31925
				#回傳結果
31692
				return $result;
31926
				return $result;
31693
			
31927
 
31694
				}#if end
31928
				}#if end
31695
				
31929
 
31696
			#如果要複製的目標為目錄
31930
			#如果要複製的目標為目錄
31697
			if($fileInfo["content"]["is_folder"]==="true"){
31931
			if($fileInfo["content"]["is_folder"]==="true"){
31698
			
31932
 
31699
				#來源是資料夾
31933
				#來源是資料夾
31700
				$sourceIsFolder="true";
31934
				$sourceIsFolder="true";
31701
			
31935
 
31702
				#結尾加上"/"
31936
				#結尾加上"/"
31703
				$conf["source"]=$conf["source"]."/";
31937
				$conf["source"]=$conf["source"]."/";
31704
			
31938
 
31705
				}#if end
31939
				}#if end
31706
		
31940
 
31707
			}#if end
31941
			}#if end
31708
			
31942
 
31709
		#反之來源為資料夾
31943
		#反之來源為資料夾
31710
		else{
31944
		else{
31711
		
31945
 
31712
			#來源是資料夾
31946
			#來源是資料夾
31713
			$sourceIsFolder="true";
31947
			$sourceIsFolder="true";
31714
		
31948
 
31715
			}#else end
31949
			}#else end
31716
		
31950
 
31717
		#函式說明:
31951
		#函式說明:
31718
		#取得符合特定字首與字尾的字串
31952
		#取得符合特定字首與字尾的字串
31719
		#回傳結果:
31953
		#回傳結果:
31720
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
31954
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
31721
		#$result["function"],當前執行的函數名稱.
31955
		#$result["function"],當前執行的函數名稱.
Line 31736... Line 31970...
31736
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
31970
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
31737
		#備註:
31971
		#備註:
31738
		#無.
31972
		#無.
31739
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
31973
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
31740
		unset($conf["search::getMeetConditionsString"]);
31974
		unset($conf["search::getMeetConditionsString"]);
31741
		
31975
 
31742
		#如果執行失敗
31976
		#如果執行失敗
31743
		if($getMeetConditionsString["status"]==="false"){
31977
		if($getMeetConditionsString["status"]==="false"){
31744
		
31978
 
31745
			#設置執行失敗
31979
			#設置執行失敗
31746
			$result["status"]="false";
31980
			$result["status"]="false";
31747
 
31981
 
31748
			#設置錯誤訊息
31982
			#設置錯誤訊息
31749
			$result["error"]=$getMeetConditionsString;
31983
			$result["error"]=$getMeetConditionsString;
31750
 
31984
 
31751
			#回傳結果
31985
			#回傳結果
31752
			return $result;
31986
			return $result;
31753
		
31987
 
31754
			}#if end
31988
			}#if end
31755
			
31989
 
31756
		#如果不是 "/" 結尾
31990
		#如果不是 "/" 結尾
31757
		if($getMeetConditionsString["founded"]==="false"){
31991
		if($getMeetConditionsString["founded"]==="false"){
31758
		
31992
 
31759
			#檢查要複製到的目標所屬路徑是否存在
31993
			#檢查要複製到的目標所屬路徑是否存在
31760
			#函式說明:
31994
			#函式說明:
31761
			#檢查路徑是否存在.
31995
			#檢查路徑是否存在.
31762
			#回傳結果:
31996
			#回傳結果:
31763
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
31997
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 31778... Line 32012...
31778
			#無.
32012
			#無.
31779
			#備註:
32013
			#備註:
31780
			#無.
32014
			#無.
31781
			$checkPathExist=fileAccess::checkPathExist($conf["fileAccess::checkPathExist"]);
32015
			$checkPathExist=fileAccess::checkPathExist($conf["fileAccess::checkPathExist"]);
31782
			unset($conf["fileAccess::checkPathExist"]);
32016
			unset($conf["fileAccess::checkPathExist"]);
31783
		
32017
 
31784
			#如果執行失敗
32018
			#如果執行失敗
31785
			if($checkPathExist["status"]==="false"){
32019
			if($checkPathExist["status"]==="false"){
31786
			
32020
 
31787
				#設置執行失敗
32021
				#設置執行失敗
31788
				$result["status"]="false";
32022
				$result["status"]="false";
31789
 
32023
 
31790
				#設置錯誤訊息
32024
				#設置錯誤訊息
31791
				$result["error"]=$checkPathExist;
32025
				$result["error"]=$checkPathExist;
31792
 
32026
 
31793
				#回傳結果
32027
				#回傳結果
31794
				return $result;
32028
				return $result;
31795
			
32029
 
31796
				}#if end
32030
				}#if end
31797
			
32031
 
31798
			#目的不是資料夾
32032
			#目的不是資料夾
31799
			$targetIsFolder="false";
32033
			$targetIsFolder="false";
31800
			
32034
 
31801
			#如果路徑都存在
32035
			#如果路徑都存在
31802
			if($checkPathExist["found"]==="true"){
32036
			if($checkPathExist["found"]==="true"){
31803
			
32037
 
31804
				#取得目標檔案的資訊
32038
				#取得目標檔案的資訊
31805
				#函式說明:
32039
				#函式說明:
31806
				#取得節點的資訊.
32040
				#取得節點的資訊.
31807
				#回傳結果:
32041
				#回傳結果:
31808
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
32042
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
31809
				#$result["error"],錯誤訊息陣列.
32043
				#$result["error"],錯誤訊息陣列.
31810
				#$result["function"],函數名稱. 
32044
				#$result["function"],函數名稱.
31811
				#$result["content"],檔案資訊陣列.
32045
				#$result["content"],檔案資訊陣列.
31812
				#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
32046
				#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
31813
				#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
32047
				#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
31814
				#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
32048
				#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
31815
				#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
32049
				#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
31816
				#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
32050
				#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
31817
				#$result["content"]["ownerName"],檔案擁有着資訊.
32051
				#$result["content"]["ownerName"],檔案擁有着資訊.
Line 31833... Line 32067...
31833
				#fileowner=>http://php.net/manual/en/function.fileowner.php
32067
				#fileowner=>http://php.net/manual/en/function.fileowner.php
31834
				#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
32068
				#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
31835
				#備註:
32069
				#備註:
31836
				$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
32070
				$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
31837
				unset($conf["fileAccess::fileInfo"]);
32071
				unset($conf["fileAccess::fileInfo"]);
31838
			
32072
 
31839
				#如果執行失敗
32073
				#如果執行失敗
31840
				if($fileInfo["status"]==="false"){
32074
				if($fileInfo["status"]==="false"){
31841
				
32075
 
31842
					#設置執行失敗
32076
					#設置執行失敗
31843
					$result["status"]="false";
32077
					$result["status"]="false";
31844
 
32078
 
31845
					#設置錯誤訊息
32079
					#設置錯誤訊息
31846
					$result["error"]=$fileInfo;
32080
					$result["error"]=$fileInfo;
31847
 
32081
 
31848
					#回傳結果
32082
					#回傳結果
31849
					return $result;
32083
					return $result;
31850
				
32084
 
31851
					}#if end
32085
					}#if end
31852
					
32086
 
31853
				#如果要複製到的目標為目錄
32087
				#如果要複製到的目標為目錄
31854
				if($fileInfo["content"]["is_folder"]==="true"){
32088
				if($fileInfo["content"]["is_folder"]==="true"){
31855
				
32089
 
31856
					#目的是資料夾
32090
					#目的是資料夾
31857
					$targetIsFolder="true";
32091
					$targetIsFolder="true";
31858
				
32092
 
31859
					#結尾加上"/"
32093
					#結尾加上"/"
31860
					$conf["target"]=$conf["target"]."/";
32094
					$conf["target"]=$conf["target"]."/";
31861
				
32095
 
31862
					}#if end
32096
					}#if end
31863
			
32097
 
31864
				}#if end
32098
				}#if end
31865
		
32099
 
31866
			}#if end
32100
			}#if end
31867
		
32101
 
31868
		#反之
32102
		#反之
31869
		else{
32103
		else{
31870
		
32104
 
31871
			#目的是資料夾
32105
			#目的是資料夾
31872
			$targetIsFolder="true";
32106
			$targetIsFolder="true";
31873
		
32107
 
31874
			}#else end
32108
			}#else end
31875
		
32109
 
31876
		#如果來源跟目標不同為檔案為目錄
32110
		#如果來源跟目標不同為檔案為目錄
31877
		if($sourceIsFolder!==$targetIsFolder){
32111
		if($sourceIsFolder!==$targetIsFolder){
31878
		
32112
 
31879
			#設置執行失敗
32113
			#設置執行失敗
31880
			$result["status"]="false";
32114
			$result["status"]="false";
31881
 
32115
 
31882
			#設置錯誤訊息
32116
			#設置錯誤訊息
31883
			$result["error"][]="複製的來源與目標須同樣為目錄或檔案";
32117
			$result["error"][]="複製的來源與目標須同樣為目錄或檔案";
31884
 
32118
 
31885
			#回傳結果
32119
			#回傳結果
31886
			return $result;
32120
			return $result;
31887
		
32121
 
31888
			}#if end
32122
			}#if end
31889
		
32123
 
31890
		#初始化給 rsync 的參數
32124
		#初始化給 rsync 的參數
31891
		$params_for_rsync=array("-v","--progress","--links");
32125
		$params_for_rsync=array("-v","--progress","--links");
31892
	
32126
 
31893
		#如果目錄底下的內容也要複製
32127
		#如果目錄底下的內容也要複製
31894
		if($conf["recursive"]==="true"){
32128
		if($conf["recursive"]==="true"){
31895
		
32129
 
31896
			#設置目錄底下的內容也要複製
32130
			#設置目錄底下的內容也要複製
31897
			$params_for_rsync[]="-r";
32131
			$params_for_rsync[]="-r";
31898
		
32132
 
31899
			}#if end
32133
			}#if end
31900
			
32134
 
31901
		#如果有設置頻寬限制
32135
		#如果有設置頻寬限制
31902
		if(isset($conf["bandWidthLimit"])){
32136
		if(isset($conf["bandWidthLimit"])){
31903
		
32137
 
31904
			#設置頻寬限制參數
32138
			#設置頻寬限制參數
31905
			$params_for_rsync[]="--bwlimit";
32139
			$params_for_rsync[]="--bwlimit";
31906
			
32140
 
31907
			#設置頻寬限制參數數值
32141
			#設置頻寬限制參數數值
31908
			$params_for_rsync[]=$conf["bandWidthLimit"];
32142
			$params_for_rsync[]=$conf["bandWidthLimit"];
31909
		
32143
 
31910
			}#if end
32144
			}#if end
31911
			
32145
 
31912
		#如果有設置只要複製比較新的檔案
32146
		#如果有設置只要複製比較新的檔案
31913
		if($conf["newFileOnly"]==="true"){
32147
		if($conf["newFileOnly"]==="true"){
31914
		
32148
 
31915
			#設置只要複製比較新的檔案
32149
			#設置只要複製比較新的檔案
31916
			$params_for_rsync[]="--update";
32150
			$params_for_rsync[]="--update";
31917
			
32151
 
31918
			}#if end
32152
			}#if end
31919
			
32153
 
31920
		#如果要用append的方法
32154
		#如果要用append的方法
31921
		if($conf["appendMode"]==="true"){
32155
		if($conf["appendMode"]==="true"){
31922
		
32156
 
31923
			#設置要用append的方法
32157
			#設置要用append的方法
31924
			$params_for_rsync[]="--append";
32158
			$params_for_rsync[]="--append";
31925
		
32159
 
31926
			}#if end
32160
			}#if end
31927
	
32161
 
31928
		#如果有排除特定檔案或目錄
32162
		#如果有排除特定檔案或目錄
31929
		if(isset($conf["exclude"])){
32163
		if(isset($conf["exclude"])){
31930
		
32164
 
31931
			#針對每個要排除的檔案或目錄
32165
			#針對每個要排除的檔案或目錄
31932
			foreach($conf["exclude"] as $excludeSource){
32166
			foreach($conf["exclude"] as $excludeSource){
31933
			
32167
 
31934
				#設置要排除的檔案或目錄
32168
				#設置要排除的檔案或目錄
31935
				$params_for_rsync[]="--exclude=".$excludeSource;
32169
				$params_for_rsync[]="--exclude=".$excludeSource;
31936
			
32170
 
31937
				}#foreach end
32171
				}#foreach end
31938
		
32172
 
31939
			}#if end
32173
			}#if end
31940
			
32174
 
31941
		#如果有排除特定檔案類型
32175
		#如果有排除特定檔案類型
31942
		if(isset($conf["excludeFileType"])){
32176
		if(isset($conf["excludeFileType"])){
31943
		
32177
 
31944
			#針對每個要排除的檔案類型
32178
			#針對每個要排除的檔案類型
31945
			foreach($conf["excludeFileType"] as $excludeSource){
32179
			foreach($conf["excludeFileType"] as $excludeSource){
31946
			
32180
 
31947
				#設置要排除的檔案類型
32181
				#設置要排除的檔案類型
31948
				$params_for_rsync[]="--exclude=\"*.".$excludeSource."\"";
32182
				$params_for_rsync[]="--exclude=\"*.".$excludeSource."\"";
31949
			
32183
 
31950
				}#foreach end
32184
				}#foreach end
31951
		
32185
 
31952
			}#if end
32186
			}#if end
31953
	
32187
 
31954
		#如果要複製的目標不是 ./ 開頭
32188
		#如果要複製的目標不是 ./ 開頭
31955
		#函式說明:
32189
		#函式說明:
31956
		#取得符合特定字首與字尾的字串
32190
		#取得符合特定字首與字尾的字串
31957
		#回傳結果:
32191
		#回傳結果:
31958
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
32192
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 31974... Line 32208...
31974
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
32208
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
31975
		#備註:
32209
		#備註:
31976
		#無.
32210
		#無.
31977
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
32211
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
31978
		unset($conf["search::getMeetConditionsString"]);
32212
		unset($conf["search::getMeetConditionsString"]);
31979
	
32213
 
31980
		#如果執行失敗
32214
		#如果執行失敗
31981
		if($getMeetConditionsString["status"]==="false"){
32215
		if($getMeetConditionsString["status"]==="false"){
31982
		
32216
 
31983
			#設置執行失敗
32217
			#設置執行失敗
31984
			$result["status"]="false";
32218
			$result["status"]="false";
31985
 
32219
 
31986
			#設置錯誤訊息
32220
			#設置錯誤訊息
31987
			$result["error"]=$getMeetConditionsString;
32221
			$result["error"]=$getMeetConditionsString;
31988
 
32222
 
31989
			#回傳結果
32223
			#回傳結果
31990
			return $result;
32224
			return $result;
31991
		
32225
 
31992
			}#if end
32226
			}#if end
31993
			
32227
 
31994
		#如果沒有符合
32228
		#如果沒有符合
31995
		if($getMeetConditionsString["founded"]==="false"){
32229
		if($getMeetConditionsString["founded"]==="false"){
31996
		
32230
 
31997
			#如果要複製的目標不是 / 開頭
32231
			#如果要複製的目標不是 / 開頭
31998
			#函式說明:
32232
			#函式說明:
31999
			#取得符合特定字首與字尾的字串
32233
			#取得符合特定字首與字尾的字串
32000
			#回傳結果:
32234
			#回傳結果:
32001
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
32235
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 32017... Line 32251...
32017
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
32251
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
32018
			#備註:
32252
			#備註:
32019
			#無.
32253
			#無.
32020
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
32254
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
32021
			unset($conf["search::getMeetConditionsString"]);
32255
			unset($conf["search::getMeetConditionsString"]);
32022
		
32256
 
32023
			#如果執行失敗
32257
			#如果執行失敗
32024
			if($getMeetConditionsString["status"]==="false"){
32258
			if($getMeetConditionsString["status"]==="false"){
32025
			
32259
 
32026
				#設置執行失敗
32260
				#設置執行失敗
32027
				$result["status"]="false";
32261
				$result["status"]="false";
32028
 
32262
 
32029
				#設置錯誤訊息
32263
				#設置錯誤訊息
32030
				$result["error"]=$getMeetConditionsString;
32264
				$result["error"]=$getMeetConditionsString;
32031
 
32265
 
32032
				#回傳結果
32266
				#回傳結果
32033
				return $result;
32267
				return $result;
32034
			
32268
 
32035
				}#if end
32269
				}#if end
32036
				
32270
 
32037
			#如果沒有符合
32271
			#如果沒有符合
32038
			if($getMeetConditionsString["founded"]==="false"){
32272
			if($getMeetConditionsString["founded"]==="false"){
32039
			
32273
 
32040
				#加上 "./" 變成絕對位置,避免"::"被視為其他含義
32274
				#加上 "./" 變成絕對位置,避免"::"被視為其他含義
32041
				$conf["source"]="./".$conf["source"];
32275
				$conf["source"]="./".$conf["source"];
32042
			
32276
 
32043
				}#if end
32277
				}#if end
32044
		
32278
 
32045
			}#if end
32279
			}#if end
32046
	
32280
 
32047
		#設置要複製的目標
32281
		#設置要複製的目標
32048
		$params_for_rsync[]=$conf["source"];
32282
		$params_for_rsync[]=$conf["source"];
32049
		
32283
 
32050
		#如果要複製的目標不是 ./ 開頭
32284
		#如果要複製的目標不是 ./ 開頭
32051
		#函式說明:
32285
		#函式說明:
32052
		#取得符合特定字首與字尾的字串
32286
		#取得符合特定字首與字尾的字串
32053
		#回傳結果:
32287
		#回傳結果:
32054
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
32288
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 32070... Line 32304...
32070
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
32304
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
32071
		#備註:
32305
		#備註:
32072
		#無.
32306
		#無.
32073
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
32307
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
32074
		unset($conf["search::getMeetConditionsString"]);
32308
		unset($conf["search::getMeetConditionsString"]);
32075
	
32309
 
32076
		#如果執行失敗
32310
		#如果執行失敗
32077
		if($getMeetConditionsString["status"]==="false"){
32311
		if($getMeetConditionsString["status"]==="false"){
32078
		
32312
 
32079
			#設置執行失敗
32313
			#設置執行失敗
32080
			$result["status"]="false";
32314
			$result["status"]="false";
32081
 
32315
 
32082
			#設置錯誤訊息
32316
			#設置錯誤訊息
32083
			$result["error"]=$getMeetConditionsString;
32317
			$result["error"]=$getMeetConditionsString;
32084
 
32318
 
32085
			#回傳結果
32319
			#回傳結果
32086
			return $result;
32320
			return $result;
32087
		
32321
 
32088
			}#if end
32322
			}#if end
32089
			
32323
 
32090
		#如果沒有符合
32324
		#如果沒有符合
32091
		if($getMeetConditionsString["founded"]==="false"){
32325
		if($getMeetConditionsString["founded"]==="false"){
32092
		
32326
 
32093
			#如果要複製的目標不是 / 開頭
32327
			#如果要複製的目標不是 / 開頭
32094
			#函式說明:
32328
			#函式說明:
32095
			#取得符合特定字首與字尾的字串
32329
			#取得符合特定字首與字尾的字串
32096
			#回傳結果:
32330
			#回傳結果:
32097
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
32331
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 32113... Line 32347...
32113
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
32347
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
32114
			#備註:
32348
			#備註:
32115
			#無.
32349
			#無.
32116
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
32350
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
32117
			unset($conf["search::getMeetConditionsString"]);
32351
			unset($conf["search::getMeetConditionsString"]);
32118
		
32352
 
32119
			#如果執行失敗
32353
			#如果執行失敗
32120
			if($getMeetConditionsString["status"]==="false"){
32354
			if($getMeetConditionsString["status"]==="false"){
32121
			
32355
 
32122
				#設置執行失敗
32356
				#設置執行失敗
32123
				$result["status"]="false";
32357
				$result["status"]="false";
32124
 
32358
 
32125
				#設置錯誤訊息
32359
				#設置錯誤訊息
32126
				$result["error"]=$getMeetConditionsString;
32360
				$result["error"]=$getMeetConditionsString;
32127
 
32361
 
32128
				#回傳結果
32362
				#回傳結果
32129
				return $result;
32363
				return $result;
32130
			
32364
 
32131
				}#if end
32365
				}#if end
32132
				
32366
 
32133
			#如果沒有符合
32367
			#如果沒有符合
32134
			if($getMeetConditionsString["founded"]==="false"){
32368
			if($getMeetConditionsString["founded"]==="false"){
32135
			
32369
 
32136
				#加上 "./" 變成絕對位置,避免"::"被視為其他含義
32370
				#加上 "./" 變成絕對位置,避免"::"被視為其他含義
32137
				$conf["target"]="./".$conf["target"];
32371
				$conf["target"]="./".$conf["target"];
32138
			
32372
 
32139
				}#if end
32373
				}#if end
32140
		
32374
 
32141
			}#if end
32375
			}#if end
32142
		
32376
 
32143
		#設置要備份到的位置或檔案名稱
32377
		#設置要備份到的位置或檔案名稱
32144
		$params_for_rsync[]=$conf["target"];
32378
		$params_for_rsync[]=$conf["target"];
32145
	
32379
 
32146
		#執行rsync指令
32380
		#執行rsync指令
32147
		#函式說明:
32381
		#函式說明:
32148
		#呼叫shell執行系統命令,並取得回傳的內容.
32382
		#呼叫shell執行系統命令,並取得回傳的內容.
32149
		#回傳結果:
32383
		#回傳結果:
32150
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32384
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 32201... Line 32435...
32201
		#備註:
32435
		#備註:
32202
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
32436
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
32203
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
32437
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
32204
		$callShell=external::callShell($conf["external::callShell"]);
32438
		$callShell=external::callShell($conf["external::callShell"]);
32205
		unset($conf["external::callShell"]);
32439
		unset($conf["external::callShell"]);
32206
	
32440
 
32207
		#如果執行失敗
32441
		#如果執行失敗
32208
		if($callShell["status"]==="false"){
32442
		if($callShell["status"]==="false"){
32209
		
32443
 
32210
			#設置執行失敗
32444
			#設置執行失敗
32211
			$result["status"]="false";
32445
			$result["status"]="false";
32212
 
32446
 
32213
			#設置錯誤訊息
32447
			#設置錯誤訊息
32214
			$result["error"]=$callShell;
32448
			$result["error"]=$callShell;
32215
 
32449
 
32216
			#回傳結果
32450
			#回傳結果
32217
			return $result;
32451
			return $result;
32218
		
32452
 
32219
			}#if end
32453
			}#if end
32220
			
32454
 
32221
		#設置執行正常
32455
		#設置執行正常
32222
		$result["status"]="true";
32456
		$result["status"]="true";
32223
	
32457
 
32224
		#設置執行完的回應
32458
		#設置執行完的回應
32225
		$result["content"]=$callShell["output"];
32459
		$result["content"]=$callShell["output"];
32226
	
32460
 
32227
		#回傳結果
32461
		#回傳結果
32228
		return $result;
32462
		return $result;
32229
	
32463
 
32230
		}#function rsync end
32464
		}#function rsync end
32231
 
32465
 
32232
	/*
32466
	/*
32233
	#函式說明:
32467
	#函式說明:
32234
	#使用 linux 的 httpd 指令來取得 vhost 資訊.
32468
	#使用 linux 的 httpd 指令來取得 vhost 資訊.
Line 32247... Line 32481...
32247
	#無
32481
	#無
32248
	#備註:
32482
	#備註:
32249
	#無.
32483
	#無.
32250
	*/
32484
	*/
32251
	public static function httpdGetVhostInfo(&$conf){
32485
	public static function httpdGetVhostInfo(&$conf){
32252
	
32486
 
32253
		#初始化要回傳的結果
32487
		#初始化要回傳的結果
32254
		$result=array();
32488
		$result=array();
32255
 
32489
 
32256
		#取得當前執行的函數名稱
32490
		#取得當前執行的函數名稱
32257
		$result["function"]=__FUNCTION__;
32491
		$result["function"]=__FUNCTION__;
Line 32292... Line 32526...
32292
 
32526
 
32293
			#回傳結果
32527
			#回傳結果
32294
			return $result;
32528
			return $result;
32295
 
32529
 
32296
			}#if end
32530
			}#if end
32297
	
32531
 
32298
		#函式說明:
32532
		#函式說明:
32299
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
32533
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
32300
		#回傳結果:
32534
		#回傳結果:
32301
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32535
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32302
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
32536
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 32344... Line 32578...
32344
		#array_keys=>http://php.net/manual/en/function.array-keys.php
32578
		#array_keys=>http://php.net/manual/en/function.array-keys.php
32345
		#備註:
32579
		#備註:
32346
		#無.
32580
		#無.
32347
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
32581
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
32348
		unset($conf["variableCheck::checkArguments"]);
32582
		unset($conf["variableCheck::checkArguments"]);
32349
	
32583
 
32350
		#如果執行失敗
32584
		#如果執行失敗
32351
		if($checkArguments["status"]==="false"){
32585
		if($checkArguments["status"]==="false"){
32352
		
32586
 
32353
			#設置執行失敗
32587
			#設置執行失敗
32354
			$result["status"]="false";
32588
			$result["status"]="false";
32355
 
32589
 
32356
			#設置錯誤訊息
32590
			#設置錯誤訊息
32357
			$result["error"]=$checkArguments;
32591
			$result["error"]=$checkArguments;
32358
 
32592
 
32359
			#回傳結果
32593
			#回傳結果
32360
			return $result;
32594
			return $result;
32361
		
32595
 
32362
			}#if end
32596
			}#if end
32363
			
32597
 
32364
		#如果檢查不通過
32598
		#如果檢查不通過
32365
		if($checkArguments["passed"]==="false"){
32599
		if($checkArguments["passed"]==="false"){
32366
		
32600
 
32367
			#設置執行失敗
32601
			#設置執行失敗
32368
			$result["status"]="false";
32602
			$result["status"]="false";
32369
 
32603
 
32370
			#設置錯誤訊息
32604
			#設置錯誤訊息
32371
			$result["error"]=$checkArguments;
32605
			$result["error"]=$checkArguments;
32372
 
32606
 
32373
			#回傳結果
32607
			#回傳結果
32374
			return $result;
32608
			return $result;
32375
		
32609
 
32376
			}#if end
32610
			}#if end
32377
		
32611
 
32378
		#取得設定檔的內容
32612
		#取得設定檔的內容
32379
		#函式說明:
32613
		#函式說明:
32380
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
32614
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
32381
		#回傳的變數說明:
32615
		#回傳的變數說明:
32382
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
32616
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 32409... Line 32643...
32409
		#無.
32643
		#無.
32410
		#備註:
32644
		#備註:
32411
		#無.
32645
		#無.
32412
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
32646
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
32413
		unset($conf["fileAccess::getFileContent"]);
32647
		unset($conf["fileAccess::getFileContent"]);
32414
		
32648
 
32415
		#如果執行失敗
32649
		#如果執行失敗
32416
		if($getFileContent["status"]==="false"){
32650
		if($getFileContent["status"]==="false"){
32417
		
32651
 
32418
			#設置執行失敗
32652
			#設置執行失敗
32419
			$result["status"]="false";
32653
			$result["status"]="false";
32420
 
32654
 
32421
			#設置錯誤訊息
32655
			#設置錯誤訊息
32422
			$result["error"]=$getFileContent;
32656
			$result["error"]=$getFileContent;
32423
 
32657
 
32424
			#回傳結果
32658
			#回傳結果
32425
			return $result;
32659
			return $result;
32426
		
32660
 
32427
			}#if end
32661
			}#if end
32428
		
32662
 
32429
		#取得 default Listen Add、port - start
32663
		#取得 default Listen Add、port - start
32430
		
32664
 
32431
		/*
32665
		/*
32432
		#ipv4+port
32666
		#ipv4+port
32433
		Listen 12.34.56.78:80
32667
		Listen 12.34.56.78:80
32434
		*/
32668
		*/
32435
		
32669
 
32436
		/*
32670
		/*
32437
		#port only
32671
		#port only
32438
		Listen 80
32672
		Listen 80
32439
		*/
32673
		*/
32440
		
32674
 
32441
		#函式說明:
32675
		#函式說明:
32442
		#取得符合多個特定字首與字尾之一的字串們
32676
		#取得符合多個特定字首與字尾之一的字串們
32443
		#回傳結果:
32677
		#回傳結果:
32444
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
32678
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
32445
		#$result["function"],當前執行的函數名稱.
32679
		#$result["function"],當前執行的函數名稱.
Line 32458... Line 32692...
32458
		#無.
32692
		#無.
32459
		#備註:
32693
		#備註:
32460
		#無.
32694
		#無.
32461
		$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
32695
		$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
32462
		unset($conf["search::getMeetMultiConditionsStrings"]);
32696
		unset($conf["search::getMeetMultiConditionsStrings"]);
32463
		
32697
 
32464
		#如果執行失敗
32698
		#如果執行失敗
32465
		if($getMeetMultiConditionsStrings["status"]==="false"){
32699
		if($getMeetMultiConditionsStrings["status"]==="false"){
32466
		
32700
 
32467
			#設置執行失敗
32701
			#設置執行失敗
32468
			$result["status"]="false";
32702
			$result["status"]="false";
32469
 
32703
 
32470
			#設置錯誤訊息
32704
			#設置錯誤訊息
32471
			$result["error"]=$getMeetMultiConditionsStrings;
32705
			$result["error"]=$getMeetMultiConditionsStrings;
32472
 
32706
 
32473
			#回傳結果
32707
			#回傳結果
32474
			return $result;
32708
			return $result;
32475
		
32709
 
32476
			}#if end
32710
			}#if end
32477
		
32711
 
32478
		#如果沒有需要的關鍵字存在
32712
		#如果沒有需要的關鍵字存在
32479
		if($getMeetMultiConditionsStrings["found"]==="false"){
32713
		if($getMeetMultiConditionsStrings["found"]==="false"){
32480
		
32714
 
32481
			#設置執行失敗
32715
			#設置執行失敗
32482
			$result["status"]="false";
32716
			$result["status"]="false";
32483
 
32717
 
32484
			#設置錯誤訊息
32718
			#設置錯誤訊息
32485
			$result["error"]=$getMeetMultiConditionsStrings;
32719
			$result["error"]=$getMeetMultiConditionsStrings;
32486
 
32720
 
32487
			#回傳結果
32721
			#回傳結果
32488
			return $result;
32722
			return $result;
32489
		
32723
 
32490
			}#if end
32724
			}#if end
32491
			
32725
 
32492
		#解析 Listen and port and Document string
32726
		#解析 Listen and port and Document string
32493
		
32727
 
32494
		#針對每個 section
32728
		#針對每個 section
32495
		foreach($getMeetMultiConditionsStrings["content"] as $section){
32729
		foreach($getMeetMultiConditionsStrings["content"] as $section){
32496
		
32730
 
32497
			#取得區段名稱
32731
			#取得區段名稱
32498
			$name=$section["meetConditions"]["front"];
32732
			$name=$section["meetConditions"]["front"];
32499
			
32733
 
32500
			#取得設定檔中該行的內容
32734
			#取得設定檔中該行的內容
32501
			$lineDef=$section["oriStr"];
32735
			$lineDef=$section["oriStr"];
32502
			
32736
 
32503
			#取得設定檔中該行定義的數值
32737
			#取得設定檔中該行定義的數值
32504
			$lineVal=$section["content"];
32738
			$lineVal=$section["content"];
32505
		
32739
 
32506
			#判斷是哪個區段名稱
32740
			#判斷是哪個區段名稱
32507
			switch($name){
32741
			switch($name){
32508
			
32742
 
32509
				#如果是 Listen 區段
32743
				#如果是 Listen 區段
32510
				case "Listen ":
32744
				case "Listen ":
32511
				
32745
 
32512
					#函式說明:
32746
					#函式說明:
32513
					#將固定格式的字串分開,並回傳分開的結果.
32747
					#將固定格式的字串分開,並回傳分開的結果.
32514
					#回傳結果:
32748
					#回傳結果:
32515
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32749
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32516
					#$result["error"],錯誤訊息陣列
32750
					#$result["error"],錯誤訊息陣列
Line 32532... Line 32766...
32532
					#無.
32766
					#無.
32533
					#備註:
32767
					#備註:
32534
					#無.
32768
					#無.
32535
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
32769
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
32536
					unset($conf["stringProcess::spiltString"]);
32770
					unset($conf["stringProcess::spiltString"]);
32537
					
32771
 
32538
					#如果執行失敗
32772
					#如果執行失敗
32539
					if($spiltString["status"]==="false"){
32773
					if($spiltString["status"]==="false"){
32540
					
32774
 
32541
						#設置執行失敗
32775
						#設置執行失敗
32542
						$result["status"]="false";
32776
						$result["status"]="false";
32543
 
32777
 
32544
						#設置錯誤訊息
32778
						#設置錯誤訊息
32545
						$result["error"]=$spiltString;
32779
						$result["error"]=$spiltString;
32546
 
32780
 
32547
						#回傳結果
32781
						#回傳結果
32548
						return $result;
32782
						return $result;
32549
					
32783
 
32550
						}#if end
32784
						}#if end
32551
					
32785
 
32552
					#如果沒有需要的關鍵字存在
32786
					#如果沒有需要的關鍵字存在
32553
					if($spiltString["found"]==="false"){
32787
					if($spiltString["found"]==="false"){
32554
					
32788
 
32555
						#代表只有設定 port
32789
						#代表只有設定 port
32556
					
32790
 
32557
						#如果沒有 port 存在
32791
						#如果沒有 port 存在
32558
						if(!isset($spiltString["dataArray"][0])){
32792
						if(!isset($spiltString["dataArray"][0])){
32559
							
32793
 
32560
							#設置執行失敗
32794
							#設置執行失敗
32561
							$result["status"]="false";
32795
							$result["status"]="false";
32562
 
32796
 
32563
							#設置錯誤訊息
32797
							#設置錯誤訊息
32564
							$result["error"][]="main configuration of httpd seems not right!";
32798
							$result["error"][]="main configuration of httpd seems not right!";
Line 32566... Line 32800...
32566
							#設置錯誤訊息
32800
							#設置錯誤訊息
32567
							$result["error"][]=$spiltString;
32801
							$result["error"][]=$spiltString;
32568
 
32802
 
32569
							#回傳結果
32803
							#回傳結果
32570
							return $result;
32804
							return $result;
32571
							
32805
 
32572
							}#if end
32806
							}#if end
32573
					
32807
 
32574
						#確認是否為 只有 listen port
32808
						#確認是否為 只有 listen port
32575
						#函式說明:
32809
						#函式說明:
32576
						#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
32810
						#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
32577
						#回傳結果:
32811
						#回傳結果:
32578
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32812
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 32592... Line 32826...
32592
						#無.
32826
						#無.
32593
						#備註:
32827
						#備註:
32594
						#無.
32828
						#無.
32595
						$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
32829
						$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
32596
						unset($conf["search::findSpecifyStrFormat"]);
32830
						unset($conf["search::findSpecifyStrFormat"]);
32597
						
32831
 
32598
						#若執行失敗
32832
						#若執行失敗
32599
						if($findSpecifyStrFormat["status"]==="false"){
32833
						if($findSpecifyStrFormat["status"]==="false"){
32600
							
32834
 
32601
							#設置執行失敗
32835
							#設置執行失敗
32602
							$result["status"]="false";
32836
							$result["status"]="false";
32603
 
32837
 
32604
							#設置錯誤訊息
32838
							#設置錯誤訊息
32605
							$result["error"]=$findSpecifyStrFormat;
32839
							$result["error"]=$findSpecifyStrFormat;
32606
 
32840
 
32607
							#回傳結果
32841
							#回傳結果
32608
							return $result;
32842
							return $result;
32609
							
32843
 
32610
							}#if end
32844
							}#if end
32611
							
32845
 
32612
						#若符合格式
32846
						#若符合格式
32613
						if($findSpecifyStrFormat["found"]==="true"){
32847
						if($findSpecifyStrFormat["found"]==="true"){
32614
						
32848
 
32615
							#設置預設ip
32849
							#設置預設ip
32616
							$defaultIp="*";
32850
							$defaultIp="*";
32617
						
32851
 
32618
							#設置預設 port
32852
							#設置預設 port
32619
							$defaultPort=$findSpecifyStrFormat["content"][0];
32853
							$defaultPort=$findSpecifyStrFormat["content"][0];
32620
						
32854
 
32621
							}#if end
32855
							}#if end
32622
					
32856
 
32623
						}#if end
32857
						}#if end
32624
						
32858
 
32625
					#反之如果分成兩段
32859
					#反之如果分成兩段
32626
					else if($spiltString["dataCounts"]===2){
32860
					else if($spiltString["dataCounts"]===2){
32627
					
32861
 
32628
						#判斷是否為IPv4+port
32862
						#判斷是否為IPv4+port
32629
						#函式說明:
32863
						#函式說明:
32630
						#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
32864
						#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
32631
						#回傳結果:
32865
						#回傳結果:
32632
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32866
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 32646... Line 32880...
32646
						#無.
32880
						#無.
32647
						#備註:
32881
						#備註:
32648
						#無.
32882
						#無.
32649
						$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
32883
						$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
32650
						unset($conf["search::findSpecifyStrFormat"]);
32884
						unset($conf["search::findSpecifyStrFormat"]);
32651
						
32885
 
32652
						#若執行失敗
32886
						#若執行失敗
32653
						if($findSpecifyStrFormat["status"]==="false"){
32887
						if($findSpecifyStrFormat["status"]==="false"){
32654
							
32888
 
32655
							#設置執行失敗
32889
							#設置執行失敗
32656
							$result["status"]="false";
32890
							$result["status"]="false";
32657
 
32891
 
32658
							#設置錯誤訊息
32892
							#設置錯誤訊息
32659
							$result["error"]=$findSpecifyStrFormat;
32893
							$result["error"]=$findSpecifyStrFormat;
32660
 
32894
 
32661
							#回傳結果
32895
							#回傳結果
32662
							return $result;
32896
							return $result;
32663
							
32897
 
32664
							}#if end
32898
							}#if end
32665
							
32899
 
32666
						#若符合格式
32900
						#若符合格式
32667
						if($findSpecifyStrFormat["found"]==="true"){
32901
						if($findSpecifyStrFormat["found"]==="true"){
32668
							
32902
 
32669
							#設置預設的listen ip
32903
							#設置預設的listen ip
32670
							$defaultIp=$findSpecifyStrFormat[0].".".$findSpecifyStrFormat[1].".".$findSpecifyStrFormat[2].".".$findSpecifyStrFormat[3];
32904
							$defaultIp=$findSpecifyStrFormat[0].".".$findSpecifyStrFormat[1].".".$findSpecifyStrFormat[2].".".$findSpecifyStrFormat[3];
32671
						
32905
 
32672
							#設置預設的listen port
32906
							#設置預設的listen port
32673
							$defaultPort=$findSpecifyStrFormat[4];
32907
							$defaultPort=$findSpecifyStrFormat[4];
32674
							
32908
 
32675
							}#if end
32909
							}#if end
32676
					
32910
 
32677
						#反之非 ipv4+port 的格式
32911
						#反之非 ipv4+port 的格式
32678
						else{
32912
						else{
32679
						
32913
 
32680
							#確認是否為 ipv6 + port
32914
							#確認是否為 ipv6 + port
32681
							#函式說明:
32915
							#函式說明:
32682
							#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
32916
							#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
32683
							#回傳結果:
32917
							#回傳結果:
32684
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32918
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 32698... Line 32932...
32698
							#無.
32932
							#無.
32699
							#備註:
32933
							#備註:
32700
							#無.
32934
							#無.
32701
							$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
32935
							$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
32702
							unset($conf["search::findSpecifyStrFormat"]);
32936
							unset($conf["search::findSpecifyStrFormat"]);
32703
							
32937
 
32704
							#若執行失敗
32938
							#若執行失敗
32705
							if($findSpecifyStrFormat["status"]==="false"){
32939
							if($findSpecifyStrFormat["status"]==="false"){
32706
								
32940
 
32707
								#設置執行失敗
32941
								#設置執行失敗
32708
								$result["status"]="false";
32942
								$result["status"]="false";
32709
 
32943
 
32710
								#設置錯誤訊息
32944
								#設置錯誤訊息
32711
								$result["error"]=$findSpecifyStrFormat;
32945
								$result["error"]=$findSpecifyStrFormat;
32712
 
32946
 
32713
								#回傳結果
32947
								#回傳結果
32714
								return $result;
32948
								return $result;
32715
								
32949
 
32716
								}#if end
32950
								}#if end
32717
								
32951
 
32718
							#若符合格式
32952
							#若符合格式
32719
							if($findSpecifyStrFormat["found"]==="true"){
32953
							if($findSpecifyStrFormat["found"]==="true"){
32720
							
32954
 
32721
								#設置預設ip
32955
								#設置預設ip
32722
								$defaultIp=$findSpecifyStrFormat["content"][0];
32956
								$defaultIp=$findSpecifyStrFormat["content"][0];
32723
							
32957
 
32724
								#設置預設 port
32958
								#設置預設 port
32725
								$defaultPort=$findSpecifyStrFormat["content"][1];
32959
								$defaultPort=$findSpecifyStrFormat["content"][1];
32726
							
32960
 
32727
								}#if end
32961
								}#if end
32728
								
32962
 
32729
							#反之,格式錯誤
32963
							#反之,格式錯誤
32730
							else{
32964
							else{
32731
							
32965
 
32732
								#設置執行失敗
32966
								#設置執行失敗
32733
								$result["status"]="false";
32967
								$result["status"]="false";
32734
 
32968
 
32735
								#設置錯誤訊息
32969
								#設置錯誤訊息
32736
								$result["error"][]="main configuration of httpd seems not right!";
32970
								$result["error"][]="main configuration of httpd seems not right!";
Line 32738... Line 32972...
32738
								#設置錯誤訊息
32972
								#設置錯誤訊息
32739
								$result["error"][]=$findSpecifyStrFormat;
32973
								$result["error"][]=$findSpecifyStrFormat;
32740
 
32974
 
32741
								#回傳結果
32975
								#回傳結果
32742
								return $result;
32976
								return $result;
32743
							
32977
 
32744
								}#else end
32978
								}#else end
32745
							
32979
 
32746
							}#else end
32980
							}#else end
32747
					
32981
 
32748
						}#if end
32982
						}#if end
32749
					
32983
 
32750
					#反之
32984
					#反之
32751
					else{
32985
					else{
32752
					
32986
 
32753
						#設置執行失敗
32987
						#設置執行失敗
32754
						$result["status"]="false";
32988
						$result["status"]="false";
32755
 
32989
 
32756
						#設置錯誤訊息
32990
						#設置錯誤訊息
32757
						$result["error"][]="main configuration of httpd seems not right!";
32991
						$result["error"][]="main configuration of httpd seems not right!";
Line 32759... Line 32993...
32759
						#設置錯誤訊息
32993
						#設置錯誤訊息
32760
						$result["error"][]=$findSpecifyStrFormat;
32994
						$result["error"][]=$findSpecifyStrFormat;
32761
 
32995
 
32762
						#回傳結果
32996
						#回傳結果
32763
						return $result;
32997
						return $result;
32764
					
32998
 
32765
						}#else end
32999
						}#else end
32766
					
33000
 
32767
					#跳出  switch
33001
					#跳出  switch
32768
					break;
33002
					break;
32769
				
33003
 
32770
				#如果是 DocumentRoot 區段
33004
				#如果是 DocumentRoot 區段
32771
				case "DocumentRoot ":
33005
				case "DocumentRoot ":
32772
				
33006
 
32773
					#函式說明:
33007
					#函式說明:
32774
					#將固定格式的字串分開,並回傳分開的結果.
33008
					#將固定格式的字串分開,並回傳分開的結果.
32775
					#回傳結果:
33009
					#回傳結果:
32776
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33010
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
32777
					#$result["error"],錯誤訊息陣列
33011
					#$result["error"],錯誤訊息陣列
Line 32793... Line 33027...
32793
					#無.
33027
					#無.
32794
					#備註:
33028
					#備註:
32795
					#無.
33029
					#無.
32796
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
33030
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
32797
					unset($conf["stringProcess::spiltString"]);
33031
					unset($conf["stringProcess::spiltString"]);
32798
					
33032
 
32799
					#如果執行失敗
33033
					#如果執行失敗
32800
					if($spiltString["status"]==="false"){
33034
					if($spiltString["status"]==="false"){
32801
					
33035
 
32802
						#設置執行失敗
33036
						#設置執行失敗
32803
						$result["status"]="false";
33037
						$result["status"]="false";
32804
 
33038
 
32805
						#設置錯誤訊息
33039
						#設置錯誤訊息
32806
						$result["error"]=$spiltString;
33040
						$result["error"]=$spiltString;
32807
 
33041
 
32808
						#回傳結果
33042
						#回傳結果
32809
						return $result;
33043
						return $result;
32810
					
33044
 
32811
						}#if end
33045
						}#if end
32812
						
33046
 
32813
					#如果沒有關鍵字存在
33047
					#如果沒有關鍵字存在
32814
					if($spiltString["found"]==="false"){
33048
					if($spiltString["found"]==="false"){
32815
					
33049
 
32816
						#設置執行失敗
33050
						#設置執行失敗
32817
						$result["status"]="false";
33051
						$result["status"]="false";
32818
 
33052
 
32819
						#設置錯誤訊息
33053
						#設置錯誤訊息
32820
						$result["error"]=$spiltString;
33054
						$result["error"]=$spiltString;
32821
 
33055
 
32822
						#回傳結果
33056
						#回傳結果
32823
						return $result;
33057
						return $result;
32824
					
33058
 
32825
						}#if end
33059
						}#if end
32826
						
33060
 
32827
					#如果沒有剛好切割成兩段
33061
					#如果沒有剛好切割成兩段
32828
					if($spiltString["dataCounts"]!==2){
33062
					if($spiltString["dataCounts"]!==2){
32829
					
33063
 
32830
						#設置執行失敗
33064
						#設置執行失敗
32831
						$result["status"]="false";
33065
						$result["status"]="false";
32832
 
33066
 
32833
						#設置錯誤訊息
33067
						#設置錯誤訊息
32834
						$result["error"]=$spiltString;
33068
						$result["error"]=$spiltString;
32835
 
33069
 
32836
						#回傳結果
33070
						#回傳結果
32837
						return $result;
33071
						return $result;
32838
					
33072
 
32839
						}#if end
33073
						}#if end
32840
					
33074
 
32841
					#取得預設的 document root
33075
					#取得預設的 document root
32842
					eval("\$documentRoot=".$spiltString["dataArray"][1].";");
33076
					eval("\$documentRoot=".$spiltString["dataArray"][1].";");
32843
					
33077
 
32844
					#另存一分預設的 document root
33078
					#另存一分預設的 document root
32845
					$defaultDocumentRoot=$documentRoot;
33079
					$defaultDocumentRoot=$documentRoot;
32846
				
33080
 
32847
					#跳出  switch
33081
					#跳出  switch
32848
					break;
33082
					break;
32849
				
33083
 
32850
				#其他不支援的區段
33084
				#其他不支援的區段
32851
				default:
33085
				default:
32852
			
33086
 
32853
					#設置執行失敗
33087
					#設置執行失敗
32854
					$result["status"]="false";
33088
					$result["status"]="false";
32855
 
33089
 
32856
					#設置錯誤訊息
33090
					#設置錯誤訊息
32857
					$result["error"][]="unsupported section:".$getMeetMultiConditionsStrings["content"][0]["meetConditions"]["front"];
33091
					$result["error"][]="unsupported section:".$getMeetMultiConditionsStrings["content"][0]["meetConditions"]["front"];
Line 32859... Line 33093...
32859
					#設置錯誤訊息
33093
					#設置錯誤訊息
32860
					$result["error"][]=$getMeetMultiConditionsStrings;
33094
					$result["error"][]=$getMeetMultiConditionsStrings;
32861
 
33095
 
32862
					#回傳結果
33096
					#回傳結果
32863
					return $result;
33097
					return $result;
32864
			
33098
 
32865
				}#switch end
33099
				}#switch end
32866
		
33100
 
32867
			}#foreach end
33101
			}#foreach end
32868
		
33102
 
32869
		#取得 defaut Listen Add、port - end
33103
		#取得 defaut Listen Add、port - end
32870
		
33104
 
32871
		#取得 ServerName、ServerAlias、DocumentRoot - start
33105
		#取得 ServerName、ServerAlias、DocumentRoot - start
32872
		
33106
 
32873
		#函式說明:
33107
		#函式說明:
32874
		#取得符合多個特定字首與字尾之一的字串們
33108
		#取得符合多個特定字首與字尾之一的字串們
32875
		#回傳結果:
33109
		#回傳結果:
32876
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
33110
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
32877
		#$result["function"],當前執行的函數名稱.
33111
		#$result["function"],當前執行的函數名稱.
Line 32890... Line 33124...
32890
		#無.
33124
		#無.
32891
		#備註:
33125
		#備註:
32892
		#無.
33126
		#無.
32893
		$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
33127
		$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
32894
		unset($conf["search::getMeetMultiConditionsStrings"]);
33128
		unset($conf["search::getMeetMultiConditionsStrings"]);
32895
		
33129
 
32896
		#如果執行失敗
33130
		#如果執行失敗
32897
		if($getMeetMultiConditionsStrings["status"]==="false"){
33131
		if($getMeetMultiConditionsStrings["status"]==="false"){
32898
		
33132
 
32899
			#設置執行失敗
33133
			#設置執行失敗
32900
			$result["status"]="false";
33134
			$result["status"]="false";
32901
 
33135
 
32902
			#設置錯誤訊息
33136
			#設置錯誤訊息
32903
			$result["error"]=$getMeetMultiConditionsStrings;
33137
			$result["error"]=$getMeetMultiConditionsStrings;
32904
 
33138
 
32905
			#回傳結果
33139
			#回傳結果
32906
			return $result;
33140
			return $result;
32907
		
33141
 
32908
			}#if end
33142
			}#if end
32909
		
33143
 
32910
		#如果沒有需要的關鍵字存在
33144
		#如果沒有需要的關鍵字存在
32911
		if($getMeetMultiConditionsStrings["found"]==="false"){
33145
		if($getMeetMultiConditionsStrings["found"]==="false"){
32912
		
33146
 
32913
			#設置執行失敗
33147
			#設置執行失敗
32914
			$result["status"]="false";
33148
			$result["status"]="false";
32915
 
33149
 
32916
			#設置錯誤訊息
33150
			#設置錯誤訊息
32917
			$result["error"]=$getMeetMultiConditionsStrings;
33151
			$result["error"]=$getMeetMultiConditionsStrings;
32918
 
33152
 
32919
			#回傳結果
33153
			#回傳結果
32920
			return $result;
33154
			return $result;
32921
		
33155
 
32922
			}#if end
33156
			}#if end
32923
		
33157
 
32924
		#如果預設的ip跟port跟document root有缺少任何一個
33158
		#如果預設的ip跟port跟document root有缺少任何一個
32925
		if( !isset($defaultIp) || !isset($defaultPort) || !isset($defaultDocumentRoot) ){
33159
		if( !isset($defaultIp) || !isset($defaultPort) || !isset($defaultDocumentRoot) ){
32926
		
33160
 
32927
			#設置執行失敗
33161
			#設置執行失敗
32928
			$result["status"]="false";
33162
			$result["status"]="false";
32929
 
33163
 
32930
			#設置錯誤訊息
33164
			#設置錯誤訊息
32931
			$result["error"][]="main configuration of httpd seems not right!";
33165
			$result["error"][]="main configuration of httpd seems not right!";
Line 32933... Line 33167...
32933
			#設置錯誤訊息
33167
			#設置錯誤訊息
32934
			$result["error"][]=$findSpecifyStrFormat;
33168
			$result["error"][]=$findSpecifyStrFormat;
32935
 
33169
 
32936
			#回傳結果
33170
			#回傳結果
32937
			return $result;
33171
			return $result;
32938
		
33172
 
32939
			}#if end
33173
			}#if end
32940
		
33174
 
32941
		#初始化vhost的資訊
33175
		#初始化vhost的資訊
32942
		$vhostInfo=array("ip"=>$defaultIp,"port"=>$defaultPort,"DocumentRoot"=>$defaultDocumentRoot);
33176
		$vhostInfo=array("ip"=>$defaultIp,"port"=>$defaultPort,"DocumentRoot"=>$defaultDocumentRoot);
32943
		
33177
 
32944
		#針對每個找到的結果
33178
		#針對每個找到的結果
32945
		foreach($getMeetMultiConditionsStrings["content"] as $found){
33179
		foreach($getMeetMultiConditionsStrings["content"] as $found){
32946
		
33180
 
32947
			#取得符合的關鍵字/屬性名稱
33181
			#取得符合的關鍵字/屬性名稱
32948
			$attrName=$found["meetConditions"]["front"];
33182
			$attrName=$found["meetConditions"]["front"];
32949
			
33183
 
32950
			#取得屬性的數值
33184
			#取得屬性的數值
32951
			$attrValue=$found["content"];
33185
			$attrValue=$found["content"];
32952
		
33186
 
32953
			#移除屬性數值前面的空白
33187
			#移除屬性數值前面的空白
32954
			#函式說明:
33188
			#函式說明:
32955
			#將字串特定關鍵字與其前面的內容剔除
33189
			#將字串特定關鍵字與其前面的內容剔除
32956
			#回傳結果:
33190
			#回傳結果:
32957
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33191
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 32959... Line 33193...
32959
			#$result["warning"],警告訊息鎮列.
33193
			#$result["warning"],警告訊息鎮列.
32960
			#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
33194
			#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
32961
			#$result["function"],當前執行的函數名稱.
33195
			#$result["function"],當前執行的函數名稱.
32962
			#$result["argu"],使用的參數.
33196
			#$result["argu"],使用的參數.
32963
			#$result["oriStr"],要處理的原始字串內容.
33197
			#$result["oriStr"],要處理的原始字串內容.
32964
			#$result["content"],處理好的的字串內容.	
33198
			#$result["content"],處理好的的字串內容.
32965
			#必填參數:
33199
			#必填參數:
32966
			#$conf["stringIn"],字串,要處理的字串.
33200
			#$conf["stringIn"],字串,要處理的字串.
32967
			$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$attrValue;
33201
			$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$attrValue;
32968
			#$conf["keyWord"],字串,特定字串.
33202
			#$conf["keyWord"],字串,特定字串.
32969
			$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
33203
			$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
Line 32976... Line 33210...
32976
			#無.
33210
			#無.
32977
			#備註:
33211
			#備註:
32978
			#無.
33212
			#無.
32979
			$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
33213
			$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
32980
			unset($conf["stringProcess::delStrBeforeKeyWord"]);
33214
			unset($conf["stringProcess::delStrBeforeKeyWord"]);
32981
		
33215
 
32982
			#如果執行失敗
33216
			#如果執行失敗
32983
			if($delStrBeforeKeyWord["status"]==="false"){
33217
			if($delStrBeforeKeyWord["status"]==="false"){
32984
			
33218
 
32985
				#設置執行失敗
33219
				#設置執行失敗
32986
				$result["status"]="false";
33220
				$result["status"]="false";
32987
 
33221
 
32988
				#設置錯誤訊息
33222
				#設置錯誤訊息
32989
				$result["error"]=$delStrBeforeKeyWord;
33223
				$result["error"]=$delStrBeforeKeyWord;
32990
 
33224
 
32991
				#回傳結果
33225
				#回傳結果
32992
				return $result;
33226
				return $result;
32993
			
33227
 
32994
				}#if end
33228
				}#if end
32995
				
33229
 
32996
			#如果不存在開頭的空白
33230
			#如果不存在開頭的空白
32997
			if($delStrBeforeKeyWord["founded"]==="false"){
33231
			if($delStrBeforeKeyWord["founded"]==="false"){
32998
			
33232
 
32999
				#設置執行失敗
33233
				#設置執行失敗
33000
				$result["status"]="false";
33234
				$result["status"]="false";
33001
 
33235
 
33002
				#設置錯誤訊息
33236
				#設置錯誤訊息
33003
				$result["error"]=$delStrBeforeKeyWord;
33237
				$result["error"]=$delStrBeforeKeyWord;
33004
 
33238
 
33005
				#回傳結果
33239
				#回傳結果
33006
				return $result;
33240
				return $result;
33007
			
33241
 
33008
				}#if end
33242
				}#if end
33009
			
33243
 
33010
			#取得移除開頭空格後的屬性數值
33244
			#取得移除開頭空格後的屬性數值
33011
			$attrValue=$delStrBeforeKeyWord["content"];
33245
			$attrValue=$delStrBeforeKeyWord["content"];
33012
			
33246
 
33013
			#如果是 server
33247
			#如果是 server
33014
			if($attrName==="ServerName"){
33248
			if($attrName==="ServerName"){
33015
			
33249
 
33016
				#判斷 ServerName 的結尾是否為 ":".$port,並移除之.
33250
				#判斷 ServerName 的結尾是否為 ":".$port,並移除之.
33017
				#函式說明:
33251
				#函式說明:
33018
				#將字串特定關鍵字與其後面的內容剔除
33252
				#將字串特定關鍵字與其後面的內容剔除
33019
				#回傳結果:
33253
				#回傳結果:
33020
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33254
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33038... Line 33272...
33038
				#無.
33272
				#無.
33039
				#備註:
33273
				#備註:
33040
				#無.
33274
				#無.
33041
				$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33275
				$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33042
				unset($conf["stringProcess::delStrAfterKeyWord"]);
33276
				unset($conf["stringProcess::delStrAfterKeyWord"]);
33043
				
33277
 
33044
				#如果執行失敗
33278
				#如果執行失敗
33045
				if($delStrAfterKeyWord["status"]==="false"){
33279
				if($delStrAfterKeyWord["status"]==="false"){
33046
				
33280
 
33047
					#設置執行失敗
33281
					#設置執行失敗
33048
					$result["status"]="false";
33282
					$result["status"]="false";
33049
 
33283
 
33050
					#設置錯誤訊息
33284
					#設置錯誤訊息
33051
					$result["error"]=$delStrAfterKeyWord;
33285
					$result["error"]=$delStrAfterKeyWord;
33052
 
33286
 
33053
					#回傳結果
33287
					#回傳結果
33054
					return $result;
33288
					return $result;
33055
				
33289
 
33056
					}#if end
33290
					}#if end
33057
					
33291
 
33058
				#如果有符合的關鍵字
33292
				#如果有符合的關鍵字
33059
				if($delStrAfterKeyWord["founded"]==="true"){
33293
				if($delStrAfterKeyWord["founded"]==="true"){
33060
				
33294
 
33061
					#取得處理好的內容
33295
					#取得處理好的內容
33062
					$attrValue=$delStrAfterKeyWord["content"];
33296
					$attrValue=$delStrAfterKeyWord["content"];
33063
				
33297
 
33064
					#更新 port
33298
					#更新 port
33065
					$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
33299
					$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
33066
				
33300
 
33067
					}#if end
33301
					}#if end
33068
			
33302
 
33069
				}#if end
33303
				}#if end
33070
			
33304
 
33071
			#如果是 DocumentRoot 的設定
33305
			#如果是 DocumentRoot 的設定
33072
			if($attrName==="DocumentRoot"){
33306
			if($attrName==="DocumentRoot"){
33073
			
33307
 
33074
				#設置其數值為沒有雙引號的內容
33308
				#設置其數值為沒有雙引號的內容
33075
				eval("\$attrValue=".$attrValue.";");
33309
				eval("\$attrValue=".$attrValue.";");
33076
			
33310
 
33077
				}#if end
33311
				}#if end
33078
			
33312
 
33079
			#設置 vhost 資訊
33313
			#設置 vhost 資訊
33080
			$vhostInfo[$attrName]=$attrValue;
33314
			$vhostInfo[$attrName]=$attrValue;
33081
			
33315
 
33082
			}#foreach end
33316
			}#foreach end
33083
		
33317
 
33084
		#儲存解析出來的 vhost 資訊到要回傳的結果
33318
		#儲存解析出來的 vhost 資訊到要回傳的結果
33085
		$result["content"][]=$vhostInfo;
33319
		$result["content"][]=$vhostInfo;
33086
		
33320
 
33087
		#取得 ServerName、ServerAlias、DocumentRoot - end
33321
		#取得 ServerName、ServerAlias、DocumentRoot - end
33088
		
33322
 
33089
		#函式說明:
33323
		#函式說明:
33090
		#呼叫shell執行系統命令,並取得回傳的內容.
33324
		#呼叫shell執行系統命令,並取得回傳的內容.
33091
		#回傳結果:
33325
		#回傳結果:
33092
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33326
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33093
		#$result["error"],錯誤訊息陣列.
33327
		#$result["error"],錯誤訊息陣列.
Line 33143... Line 33377...
33143
		#備註:
33377
		#備註:
33144
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
33378
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
33145
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
33379
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
33146
		$callShell=external::callShell($conf["external::callShell"]);
33380
		$callShell=external::callShell($conf["external::callShell"]);
33147
		unset($conf["external::callShell"]);
33381
		unset($conf["external::callShell"]);
33148
	
33382
 
33149
		#如果檢查不通過
33383
		#如果檢查不通過
33150
		if($callShell["status"]==="false"){
33384
		if($callShell["status"]==="false"){
33151
		
33385
 
33152
			#設置執行失敗
33386
			#設置執行失敗
33153
			$result["status"]="false";
33387
			$result["status"]="false";
33154
 
33388
 
33155
			#設置錯誤訊息
33389
			#設置錯誤訊息
33156
			$result["error"]=$callShell;
33390
			$result["error"]=$callShell;
33157
 
33391
 
33158
			#回傳結果
33392
			#回傳結果
33159
			return $result;
33393
			return $result;
33160
		
33394
 
33161
			}#if end
33395
			}#if end
33162
	
33396
 
33163
		/*
33397
		/*
33164
		輸出範例
33398
		輸出範例
33165
		VirtualHost configuration:
33399
		VirtualHost configuration:
33166
		169.254.1.1:80         latest.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-latest.conf:1)
33400
		169.254.1.1:80         latest.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-latest.conf:1)
33167
		169.254.1.1:443        is a NameVirtualHost
33401
		169.254.1.1:443        is a NameVirtualHost
Line 33187... Line 33421...
33187
		        port 443 namevhost sock.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-sock.conf:1)
33421
		        port 443 namevhost sock.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-sock.conf:1)
33188
		        port 443 namevhost svn.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-svn.conf:1)
33422
		        port 443 namevhost svn.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-svn.conf:1)
33189
		        port 443 namevhost sock.freedomainandssl.cloudns.asia (/etc/httpd/conf.d/sock.freeDomainAndSSL.conf:1)
33423
		        port 443 namevhost sock.freedomainandssl.cloudns.asia (/etc/httpd/conf.d/sock.freeDomainAndSSL.conf:1)
33190
		        port 443 namevhost yao-lan-lesa-free.qbpwcf.org (/etc/httpd/conf.d/yao-lan-lesa-free.qbpwcf.org.conf:1)
33424
		        port 443 namevhost yao-lan-lesa-free.qbpwcf.org (/etc/httpd/conf.d/yao-lan-lesa-free.qbpwcf.org.conf:1)
33191
		*/
33425
		*/
33192
	
33426
 
33193
		#輸出陣列
33427
		#輸出陣列
33194
		#$callShell["output"];
33428
		#$callShell["output"];
33195
		
33429
 
33196
		#初始化搭配的ip與port
33430
		#初始化搭配的ip與port
33197
		$ipAndPort="";
33431
		$ipAndPort="";
33198
		
33432
 
33199
		#針對每行輸出
33433
		#針對每行輸出
33200
		for($line=0;$line<count($callShell["output"]);$line++){
33434
		for($line=0;$line<count($callShell["output"]);$line++){
33201
		
33435
 
33202
			#若是第一行
33436
			#若是第一行
33203
			if($line===0){
33437
			if($line===0){
33204
			
33438
 
33205
				#若第一行輸出有錯
33439
				#若第一行輸出有錯
33206
				if($callShell["output"][$line]!=="VirtualHost configuration:"){
33440
				if($callShell["output"][$line]!=="VirtualHost configuration:"){
33207
				
33441
 
33208
					#設置執行失敗
33442
					#設置執行失敗
33209
					$result["status"]="false";
33443
					$result["status"]="false";
33210
 
33444
 
33211
					#設置錯誤訊息
33445
					#設置錯誤訊息
33212
					$result["error"]=$callShell["output"];
33446
					$result["error"]=$callShell["output"];
Line 33214... Line 33448...
33214
					#設置錯誤訊息
33448
					#設置錯誤訊息
33215
					$result["error"][]="output of VirtualHost configuration seems not right!";
33449
					$result["error"][]="output of VirtualHost configuration seems not right!";
33216
 
33450
 
33217
					#回傳結果
33451
					#回傳結果
33218
					return $result;
33452
					return $result;
33219
				
33453
 
33220
					}#if end
33454
					}#if end
33221
			
33455
 
33222
				}#if end
33456
				}#if end
33223
		
33457
 
33224
			#反之
33458
			#反之
33225
			else{
33459
			else{
33226
			
33460
 
33227
				#函式說明:
33461
				#函式說明:
33228
				#取得符合特定字首與字尾的字串
33462
				#取得符合特定字首與字尾的字串
33229
				#回傳結果:
33463
				#回傳結果:
33230
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
33464
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
33231
				#$result["function"],當前執行的函數名稱.
33465
				#$result["function"],當前執行的函數名稱.
Line 33246... Line 33480...
33246
				#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
33480
				#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
33247
				#備註:
33481
				#備註:
33248
				#無.
33482
				#無.
33249
				$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
33483
				$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
33250
				unset($conf["search::getMeetConditionsString"]);
33484
				unset($conf["search::getMeetConditionsString"]);
33251
			
33485
 
33252
				#如果執行失敗
33486
				#如果執行失敗
33253
				if($getMeetConditionsString["status"]==="false"){
33487
				if($getMeetConditionsString["status"]==="false"){
33254
				
33488
 
33255
					#設置執行失敗
33489
					#設置執行失敗
33256
					$result["status"]="false";
33490
					$result["status"]="false";
33257
 
33491
 
33258
					#設置錯誤訊息
33492
					#設置錯誤訊息
33259
					$result["error"]=$callShell["output"];
33493
					$result["error"]=$callShell["output"];
33260
 
33494
 
33261
					#回傳結果
33495
					#回傳結果
33262
					return $result;
33496
					return $result;
33263
				
33497
 
33264
					}#if end
33498
					}#if end
33265
					
33499
 
33266
				#如果該行為空白開頭
33500
				#如果該行為空白開頭
33267
				if($getMeetConditionsString["founded"]==="true"){
33501
				if($getMeetConditionsString["founded"]==="true"){
33268
				
33502
 
33269
					#若無搭配的ip跟port
33503
					#若無搭配的ip跟port
33270
					if($ipAndPort===""){
33504
					if($ipAndPort===""){
33271
				
33505
 
33272
						#設置執行失敗
33506
						#設置執行失敗
33273
						$result["status"]="false";
33507
						$result["status"]="false";
33274
 
33508
 
33275
						#設置錯誤訊息
33509
						#設置錯誤訊息
33276
						$result["error"]=$callShell["output"];
33510
						$result["error"]=$callShell["output"];
Line 33278... Line 33512...
33278
						#設置錯誤訊息
33512
						#設置錯誤訊息
33279
						$result["error"][]="output of VirtualHost configuration seems not right!";
33513
						$result["error"][]="output of VirtualHost configuration seems not right!";
33280
 
33514
 
33281
						#回傳結果
33515
						#回傳結果
33282
						return $result;
33516
						return $result;
33283
						
33517
 
33284
						}#if end
33518
						}#if end
33285
						
33519
 
33286
					#執行到這邊代表輸出為以下格式
33520
					#執行到這邊代表輸出為以下格式
33287
					/*
33521
					/*
33288
					        default server mobile.qbpwcf.org (/etc/httpd/conf.d/01-qbpwcf.conf:1)
33522
					        default server mobile.qbpwcf.org (/etc/httpd/conf.d/01-qbpwcf.conf:1)
33289
					        port 443 namevhost mobile.qbpwcf.org (/etc/httpd/conf.d/01-qbpwcf.conf:1)
33523
					        port 443 namevhost mobile.qbpwcf.org (/etc/httpd/conf.d/01-qbpwcf.conf:1)
33290
					                alias www.qbpwcf.org
33524
					                alias www.qbpwcf.org
Line 33307... Line 33541...
33307
					        port 443 namevhost sock.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-sock.conf:1)
33541
					        port 443 namevhost sock.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-sock.conf:1)
33308
					        port 443 namevhost svn.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-svn.conf:1)
33542
					        port 443 namevhost svn.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-svn.conf:1)
33309
					        port 443 namevhost sock.freedomainandssl.cloudns.asia (/etc/httpd/conf.d/sock.freeDomainAndSSL.conf:1)
33543
					        port 443 namevhost sock.freedomainandssl.cloudns.asia (/etc/httpd/conf.d/sock.freeDomainAndSSL.conf:1)
33310
					        port 443 namevhost yao-lan-lesa-free.qbpwcf.org (/etc/httpd/conf.d/yao-lan-lesa-free.qbpwcf.org.conf:1)
33544
					        port 443 namevhost yao-lan-lesa-free.qbpwcf.org (/etc/httpd/conf.d/yao-lan-lesa-free.qbpwcf.org.conf:1)
33311
					*/
33545
					*/
33312
					
33546
 
33313
					#嘗試移除 "(" 前面的內容
33547
					#嘗試移除 "(" 前面的內容
33314
					#函式說明:
33548
					#函式說明:
33315
					#將字串特定關鍵字與其前面的內容剔除
33549
					#將字串特定關鍵字與其前面的內容剔除
33316
					#回傳結果:
33550
					#回傳結果:
33317
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33551
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33319... Line 33553...
33319
					#$result["warning"],警告訊息鎮列.
33553
					#$result["warning"],警告訊息鎮列.
33320
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
33554
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
33321
					#$result["function"],當前執行的函數名稱.
33555
					#$result["function"],當前執行的函數名稱.
33322
					#$result["argu"],使用的參數.
33556
					#$result["argu"],使用的參數.
33323
					#$result["oriStr"],要處理的原始字串內容.
33557
					#$result["oriStr"],要處理的原始字串內容.
33324
					#$result["content"],處理好的的字串內容.	
33558
					#$result["content"],處理好的的字串內容.
33325
					#必填參數:
33559
					#必填參數:
33326
					#$conf["stringIn"],字串,要處理的字串.
33560
					#$conf["stringIn"],字串,要處理的字串.
33327
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$callShell["output"][$line];
33561
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$callShell["output"][$line];
33328
					#$conf["keyWord"],字串,特定字串.
33562
					#$conf["keyWord"],字串,特定字串.
33329
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="(";
33563
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="(";
Line 33336... Line 33570...
33336
					#無.
33570
					#無.
33337
					#備註:
33571
					#備註:
33338
					#無.
33572
					#無.
33339
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
33573
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
33340
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
33574
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
33341
					
33575
 
33342
					#如果執行失敗
33576
					#如果執行失敗
33343
					if($delStrBeforeKeyWord["status"]==="false"){
33577
					if($delStrBeforeKeyWord["status"]==="false"){
33344
					
33578
 
33345
						#設置執行失敗
33579
						#設置執行失敗
33346
						$result["status"]="false";
33580
						$result["status"]="false";
33347
 
33581
 
33348
						#設置錯誤訊息
33582
						#設置錯誤訊息
33349
						$result["error"]=$delStrBeforeKeyWord;
33583
						$result["error"]=$delStrBeforeKeyWord;
33350
 
33584
 
33351
						#回傳結果
33585
						#回傳結果
33352
						return $result;
33586
						return $result;
33353
					
33587
 
33354
						}#if end
33588
						}#if end
33355
						
33589
 
33356
					#如果應該要存在的關鍵字存在
33590
					#如果應該要存在的關鍵字存在
33357
					if($delStrBeforeKeyWord["founded"]==="true"){
33591
					if($delStrBeforeKeyWord["founded"]==="true"){
33358
					
33592
 
33359
						#嘗試移除 ")" 後面的內容
33593
						#嘗試移除 ")" 後面的內容
33360
						#函式說明:
33594
						#函式說明:
33361
						#將字串特定關鍵字與其後面的內容剔除
33595
						#將字串特定關鍵字與其後面的內容剔除
33362
						#回傳結果:
33596
						#回傳結果:
33363
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33597
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33380... Line 33614...
33380
						#無.
33614
						#無.
33381
						#備註:
33615
						#備註:
33382
						#無.
33616
						#無.
33383
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33617
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33384
						unset($conf["stringProcess::delStrAfterKeyWord"]);
33618
						unset($conf["stringProcess::delStrAfterKeyWord"]);
33385
						
33619
 
33386
						#如果執行失敗
33620
						#如果執行失敗
33387
						if($delStrAfterKeyWord["status"]==="false"){
33621
						if($delStrAfterKeyWord["status"]==="false"){
33388
						
33622
 
33389
							#設置執行失敗
33623
							#設置執行失敗
33390
							$result["status"]="false";
33624
							$result["status"]="false";
33391
 
33625
 
33392
							#設置錯誤訊息
33626
							#設置錯誤訊息
33393
							$result["error"]=$delStrAfterKeyWord;
33627
							$result["error"]=$delStrAfterKeyWord;
33394
 
33628
 
33395
							#回傳結果
33629
							#回傳結果
33396
							return $result;
33630
							return $result;
33397
						
33631
 
33398
							}#if end
33632
							}#if end
33399
							
33633
 
33400
						#如果無找到 ")"
33634
						#如果無找到 ")"
33401
						if($delStrAfterKeyWord["founded"]==="false"){
33635
						if($delStrAfterKeyWord["founded"]==="false"){
33402
						
33636
 
33403
							#設置執行失敗
33637
							#設置執行失敗
33404
							$result["status"]="false";
33638
							$result["status"]="false";
33405
 
33639
 
33406
							#設置錯誤訊息
33640
							#設置錯誤訊息
33407
							$result["error"]=$delStrAfterKeyWord;
33641
							$result["error"]=$delStrAfterKeyWord;
33408
 
33642
 
33409
							#回傳結果
33643
							#回傳結果
33410
							return $result;
33644
							return $result;
33411
						
33645
 
33412
							}#if end
33646
							}#if end
33413
						
33647
 
33414
						#嘗試移除":number"
33648
						#嘗試移除":number"
33415
						#函式說明:
33649
						#函式說明:
33416
						#將字串特定關鍵字與其後面的內容剔除
33650
						#將字串特定關鍵字與其後面的內容剔除
33417
						#回傳結果:
33651
						#回傳結果:
33418
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33652
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33435... Line 33669...
33435
						#無.
33669
						#無.
33436
						#備註:
33670
						#備註:
33437
						#無.
33671
						#無.
33438
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33672
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33439
						unset($conf["stringProcess::delStrAfterKeyWord"]);
33673
						unset($conf["stringProcess::delStrAfterKeyWord"]);
33440
						
33674
 
33441
						#如果執行失敗
33675
						#如果執行失敗
33442
						if($delStrAfterKeyWord["status"]==="false"){
33676
						if($delStrAfterKeyWord["status"]==="false"){
33443
						
33677
 
33444
							#設置執行失敗
33678
							#設置執行失敗
33445
							$result["status"]="false";
33679
							$result["status"]="false";
33446
 
33680
 
33447
							#設置錯誤訊息
33681
							#設置錯誤訊息
33448
							$result["error"]=$delStrAfterKeyWord;
33682
							$result["error"]=$delStrAfterKeyWord;
33449
 
33683
 
33450
							#回傳結果
33684
							#回傳結果
33451
							return $result;
33685
							return $result;
33452
						
33686
 
33453
							}#if end
33687
							}#if end
33454
						
33688
 
33455
						#取得 vhost 設定檔案的位置
33689
						#取得 vhost 設定檔案的位置
33456
						$vhostFile=$delStrAfterKeyWord["content"];
33690
						$vhostFile=$delStrAfterKeyWord["content"];
33457
						
33691
 
33458
						#取得設定檔的內容
33692
						#取得設定檔的內容
33459
						#函式說明:
33693
						#函式說明:
33460
						#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
33694
						#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
33461
						#回傳的變數說明:
33695
						#回傳的變數說明:
33462
						#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
33696
						#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 33489... Line 33723...
33489
						#無.
33723
						#無.
33490
						#備註:
33724
						#備註:
33491
						#無.
33725
						#無.
33492
						$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
33726
						$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
33493
						unset($conf["fileAccess::getFileContent"]);
33727
						unset($conf["fileAccess::getFileContent"]);
33494
						
33728
 
33495
						#如果執行失敗
33729
						#如果執行失敗
33496
						if($getFileContent["status"]==="false"){
33730
						if($getFileContent["status"]==="false"){
33497
						
33731
 
33498
							#設置執行失敗
33732
							#設置執行失敗
33499
							$result["status"]="false";
33733
							$result["status"]="false";
33500
 
33734
 
33501
							#設置錯誤訊息
33735
							#設置錯誤訊息
33502
							$result["error"]=$getFileContent;
33736
							$result["error"]=$getFileContent;
33503
 
33737
 
33504
							#回傳結果
33738
							#回傳結果
33505
							return $result;
33739
							return $result;
33506
						
33740
 
33507
							}#if end
33741
							}#if end
33508
						
33742
 
33509
						#符合條件的內容範例
33743
						#符合條件的內容範例
33510
						/*
33744
						/*
33511
						DocumentRoot "/var/www/html/qbpwcf"
33745
						DocumentRoot "/var/www/html/qbpwcf"
33512
						ServerName mobile.qbpwcf.org:443
33746
						ServerName mobile.qbpwcf.org:443
33513
						ServerAlias www.qbpwcf.org
33747
						ServerAlias www.qbpwcf.org
33514
						ServerAlias qbpwcf.org
33748
						ServerAlias qbpwcf.org
33515
						*/
33749
						*/
33516
						
33750
 
33517
						#取得 ServerName、ServerAlias、DocumentRoot - start
33751
						#取得 ServerName、ServerAlias、DocumentRoot - start
33518
				
33752
 
33519
						#函式說明:
33753
						#函式說明:
33520
						#取得符合多個特定字首與字尾之一的字串們
33754
						#取得符合多個特定字首與字尾之一的字串們
33521
						#回傳結果:
33755
						#回傳結果:
33522
						#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
33756
						#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
33523
						#$result["function"],當前執行的函數名稱.
33757
						#$result["function"],當前執行的函數名稱.
Line 33536... Line 33770...
33536
						#無.
33770
						#無.
33537
						#備註:
33771
						#備註:
33538
						#無.
33772
						#無.
33539
						$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
33773
						$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
33540
						unset($conf["search::getMeetMultiConditionsStrings"]);
33774
						unset($conf["search::getMeetMultiConditionsStrings"]);
33541
						
33775
 
33542
						#如果執行失敗
33776
						#如果執行失敗
33543
						if($getMeetMultiConditionsStrings["status"]==="false"){
33777
						if($getMeetMultiConditionsStrings["status"]==="false"){
33544
						
33778
 
33545
							#設置執行失敗
33779
							#設置執行失敗
33546
							$result["status"]="false";
33780
							$result["status"]="false";
33547
 
33781
 
33548
							#設置錯誤訊息
33782
							#設置錯誤訊息
33549
							$result["error"]=$getMeetMultiConditionsStrings;
33783
							$result["error"]=$getMeetMultiConditionsStrings;
33550
 
33784
 
33551
							#回傳結果
33785
							#回傳結果
33552
							return $result;
33786
							return $result;
33553
						
33787
 
33554
							}#if end
33788
							}#if end
33555
						
33789
 
33556
						#如果沒有需要的關鍵字存在
33790
						#如果沒有需要的關鍵字存在
33557
						if($getMeetMultiConditionsStrings["found"]==="false"){
33791
						if($getMeetMultiConditionsStrings["found"]==="false"){
33558
						
33792
 
33559
							#設置執行失敗
33793
							#設置執行失敗
33560
							$result["status"]="false";
33794
							$result["status"]="false";
33561
 
33795
 
33562
							#設置錯誤訊息
33796
							#設置錯誤訊息
33563
							$result["error"]=$getMeetMultiConditionsStrings;
33797
							$result["error"]=$getMeetMultiConditionsStrings;
33564
 
33798
 
33565
							#回傳結果
33799
							#回傳結果
33566
							return $result;
33800
							return $result;
33567
						
33801
 
33568
							}#if end
33802
							}#if end
33569
						
33803
 
33570
						#初始化vhost的資訊
33804
						#初始化vhost的資訊
33571
						$vhostInfo=array("ip"=>$ip,"port"=>$port);
33805
						$vhostInfo=array("ip"=>$ip,"port"=>$port);
33572
						
33806
 
33573
						#針對每個找到的結果
33807
						#針對每個找到的結果
33574
						foreach($getMeetMultiConditionsStrings["content"] as $found){
33808
						foreach($getMeetMultiConditionsStrings["content"] as $found){
33575
						
33809
 
33576
							#取得符合的關鍵字/屬性名稱
33810
							#取得符合的關鍵字/屬性名稱
33577
							$attrName=$found["meetConditions"]["front"];
33811
							$attrName=$found["meetConditions"]["front"];
33578
							
33812
 
33579
							#取得屬性的數值
33813
							#取得屬性的數值
33580
							$attrValue=$found["content"];
33814
							$attrValue=$found["content"];
33581
						
33815
 
33582
							#移除屬性數值前面的空白
33816
							#移除屬性數值前面的空白
33583
							#函式說明:
33817
							#函式說明:
33584
							#將字串特定關鍵字與其前面的內容剔除
33818
							#將字串特定關鍵字與其前面的內容剔除
33585
							#回傳結果:
33819
							#回傳結果:
33586
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33820
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33588... Line 33822...
33588
							#$result["warning"],警告訊息鎮列.
33822
							#$result["warning"],警告訊息鎮列.
33589
							#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
33823
							#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
33590
							#$result["function"],當前執行的函數名稱.
33824
							#$result["function"],當前執行的函數名稱.
33591
							#$result["argu"],使用的參數.
33825
							#$result["argu"],使用的參數.
33592
							#$result["oriStr"],要處理的原始字串內容.
33826
							#$result["oriStr"],要處理的原始字串內容.
33593
							#$result["content"],處理好的的字串內容.	
33827
							#$result["content"],處理好的的字串內容.
33594
							#必填參數:
33828
							#必填參數:
33595
							#$conf["stringIn"],字串,要處理的字串.
33829
							#$conf["stringIn"],字串,要處理的字串.
33596
							$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$attrValue;
33830
							$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$attrValue;
33597
							#$conf["keyWord"],字串,特定字串.
33831
							#$conf["keyWord"],字串,特定字串.
33598
							$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
33832
							$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
Line 33605... Line 33839...
33605
							#無.
33839
							#無.
33606
							#備註:
33840
							#備註:
33607
							#無.
33841
							#無.
33608
							$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
33842
							$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
33609
							unset($conf["stringProcess::delStrBeforeKeyWord"]);
33843
							unset($conf["stringProcess::delStrBeforeKeyWord"]);
33610
						
33844
 
33611
							#如果執行失敗
33845
							#如果執行失敗
33612
							if($delStrBeforeKeyWord["status"]==="false"){
33846
							if($delStrBeforeKeyWord["status"]==="false"){
33613
							
33847
 
33614
								#設置執行失敗
33848
								#設置執行失敗
33615
								$result["status"]="false";
33849
								$result["status"]="false";
33616
 
33850
 
33617
								#設置錯誤訊息
33851
								#設置錯誤訊息
33618
								$result["error"]=$delStrBeforeKeyWord;
33852
								$result["error"]=$delStrBeforeKeyWord;
33619
 
33853
 
33620
								#回傳結果
33854
								#回傳結果
33621
								return $result;
33855
								return $result;
33622
							
33856
 
33623
								}#if end
33857
								}#if end
33624
								
33858
 
33625
							#如果不存在開頭的空白
33859
							#如果不存在開頭的空白
33626
							if($delStrBeforeKeyWord["founded"]==="false"){
33860
							if($delStrBeforeKeyWord["founded"]==="false"){
33627
							
33861
 
33628
								#設置執行失敗
33862
								#設置執行失敗
33629
								$result["status"]="false";
33863
								$result["status"]="false";
33630
 
33864
 
33631
								#設置錯誤訊息
33865
								#設置錯誤訊息
33632
								$result["error"]=$delStrBeforeKeyWord;
33866
								$result["error"]=$delStrBeforeKeyWord;
33633
 
33867
 
33634
								#回傳結果
33868
								#回傳結果
33635
								return $result;
33869
								return $result;
33636
							
33870
 
33637
								}#if end
33871
								}#if end
33638
							
33872
 
33639
							#取得移除開頭空格後的屬性數值
33873
							#取得移除開頭空格後的屬性數值
33640
							$attrValue=$delStrBeforeKeyWord["content"];
33874
							$attrValue=$delStrBeforeKeyWord["content"];
33641
							
33875
 
33642
							#如果是 server
33876
							#如果是 server
33643
							if($attrName==="ServerName"){
33877
							if($attrName==="ServerName"){
33644
							
33878
 
33645
								#判斷 ServerName 的結尾是否為 ":".$port,並移除之.
33879
								#判斷 ServerName 的結尾是否為 ":".$port,並移除之.
33646
								#函式說明:
33880
								#函式說明:
33647
								#將字串特定關鍵字與其後面的內容剔除
33881
								#將字串特定關鍵字與其後面的內容剔除
33648
								#回傳結果:
33882
								#回傳結果:
33649
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33883
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33667... Line 33901...
33667
								#無.
33901
								#無.
33668
								#備註:
33902
								#備註:
33669
								#無.
33903
								#無.
33670
								$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33904
								$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33671
								unset($conf["stringProcess::delStrAfterKeyWord"]);
33905
								unset($conf["stringProcess::delStrAfterKeyWord"]);
33672
								
33906
 
33673
								#如果執行失敗
33907
								#如果執行失敗
33674
								if($delStrAfterKeyWord["status"]==="false"){
33908
								if($delStrAfterKeyWord["status"]==="false"){
33675
								
33909
 
33676
									#設置執行失敗
33910
									#設置執行失敗
33677
									$result["status"]="false";
33911
									$result["status"]="false";
33678
 
33912
 
33679
									#設置錯誤訊息
33913
									#設置錯誤訊息
33680
									$result["error"]=$delStrAfterKeyWord;
33914
									$result["error"]=$delStrAfterKeyWord;
33681
 
33915
 
33682
									#回傳結果
33916
									#回傳結果
33683
									return $result;
33917
									return $result;
33684
								
33918
 
33685
									}#if end
33919
									}#if end
33686
									
33920
 
33687
								#如果有符合的關鍵字
33921
								#如果有符合的關鍵字
33688
								if($delStrAfterKeyWord["founded"]==="true"){
33922
								if($delStrAfterKeyWord["founded"]==="true"){
33689
								
33923
 
33690
									#取得處理好的內容
33924
									#取得處理好的內容
33691
									$attrValue=$delStrAfterKeyWord["content"];
33925
									$attrValue=$delStrAfterKeyWord["content"];
33692
								
33926
 
33693
									#更新 port
33927
									#更新 port
33694
									$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
33928
									$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
33695
									
33929
 
33696
									}#if end
33930
									}#if end
33697
							
33931
 
33698
								}#if end
33932
								}#if end
33699
							
33933
 
33700
							#設置 vhost 資訊
33934
							#設置 vhost 資訊
33701
							$vhostInfo[$attrName]=$attrValue;
33935
							$vhostInfo[$attrName]=$attrValue;
33702
							
33936
 
33703
							}#foreach end
33937
							}#foreach end
33704
						
33938
 
33705
						#如果沒有 document 存在
33939
						#如果沒有 document 存在
33706
						if(!isset($vhostInfo["DocumentRoot"])){
33940
						if(!isset($vhostInfo["DocumentRoot"])){
33707
						
33941
 
33708
							#給予預設的 document root
33942
							#給予預設的 document root
33709
							$vhostInfo["DocumentRoot"]=$defaultDocumentRoot;
33943
							$vhostInfo["DocumentRoot"]=$defaultDocumentRoot;
33710
						
33944
 
33711
							}#if end
33945
							}#if end
33712
						
33946
 
33713
						#儲存解析出來的 vhost 資訊到要回傳的結果
33947
						#儲存解析出來的 vhost 資訊到要回傳的結果
33714
						$result["content"][]=$vhostInfo;
33948
						$result["content"][]=$vhostInfo;
33715
						
33949
 
33716
						#取得 ServerName、ServerAlias、DocumentRoot - end
33950
						#取得 ServerName、ServerAlias、DocumentRoot - end
33717
					
33951
 
33718
						}#if end
33952
						}#if end
33719
						
33953
 
33720
					}#if end
33954
					}#if end
33721
					
33955
 
33722
				#反之為 Listen 的 addr & port info
33956
				#反之為 Listen 的 addr & port info
33723
				else{
33957
				else{
33724
				
33958
 
33725
					/*
33959
					/*
33726
					輸出範例
33960
					輸出範例
33727
					169.254.1.1:80         latest.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-latest.conf:1)
33961
					169.254.1.1:80         latest.qbpwcf.org (/etc/httpd/conf.d/qbpwcf-latest.conf:1)
33728
					169.254.1.1:443        is a NameVirtualHost
33962
					169.254.1.1:443        is a NameVirtualHost
33729
					*/
33963
					*/
33730
					
33964
 
33731
					#函式說明:
33965
					#函式說明:
33732
					#將字串特定關鍵字與其後面的內容剔除
33966
					#將字串特定關鍵字與其後面的內容剔除
33733
					#回傳結果:
33967
					#回傳結果:
33734
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33968
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33735
					#$result["error"],錯誤訊息陣列.
33969
					#$result["error"],錯誤訊息陣列.
Line 33751... Line 33985...
33751
					#無.
33985
					#無.
33752
					#備註:
33986
					#備註:
33753
					#無.
33987
					#無.
33754
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33988
					$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33755
					unset($conf["stringProcess::delStrAfterKeyWord"]);
33989
					unset($conf["stringProcess::delStrAfterKeyWord"]);
33756
				
33990
 
33757
					#如果執行失敗
33991
					#如果執行失敗
33758
					if($delStrAfterKeyWord["status"]==="false"){
33992
					if($delStrAfterKeyWord["status"]==="false"){
33759
					
33993
 
33760
						#設置執行失敗
33994
						#設置執行失敗
33761
						$result["status"]="false";
33995
						$result["status"]="false";
33762
 
33996
 
33763
						#設置錯誤訊息
33997
						#設置錯誤訊息
33764
						$result["error"]=$delStrAfterKeyWord;
33998
						$result["error"]=$delStrAfterKeyWord;
33765
 
33999
 
33766
						#回傳結果
34000
						#回傳結果
33767
						return $result;
34001
						return $result;
33768
					
34002
 
33769
						}#if end
34003
						}#if end
33770
						
34004
 
33771
					#如果應該要存在的關鍵字不存在
34005
					#如果應該要存在的關鍵字不存在
33772
					if($delStrAfterKeyWord["founded"]==="false"){
34006
					if($delStrAfterKeyWord["founded"]==="false"){
33773
					
34007
 
33774
						#設置執行失敗
34008
						#設置執行失敗
33775
						$result["status"]="false";
34009
						$result["status"]="false";
33776
 
34010
 
33777
						#設置錯誤訊息
34011
						#設置錯誤訊息
33778
						$result["error"]=$delStrAfterKeyWord;
34012
						$result["error"]=$delStrAfterKeyWord;
33779
 
34013
 
33780
						#回傳結果
34014
						#回傳結果
33781
						return $result;
34015
						return $result;
33782
					
34016
 
33783
						}#if end
34017
						}#if end
33784
						
34018
 
33785
					#取得IP跟Port
34019
					#取得IP跟Port
33786
					$listenAddrAndPort=$delStrAfterKeyWord["content"];
34020
					$listenAddrAndPort=$delStrAfterKeyWord["content"];
33787
				
34021
 
33788
					#函式說明:
34022
					#函式說明:
33789
					#將固定格式的字串分開,並回傳分開的結果.
34023
					#將固定格式的字串分開,並回傳分開的結果.
33790
					#回傳結果:
34024
					#回傳結果:
33791
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34025
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
33792
					#$result["error"],錯誤訊息陣列
34026
					#$result["error"],錯誤訊息陣列
Line 33808... Line 34042...
33808
					#無.
34042
					#無.
33809
					#備註:
34043
					#備註:
33810
					#無.
34044
					#無.
33811
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
34045
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
33812
					unset($conf["stringProcess::spiltString"]);
34046
					unset($conf["stringProcess::spiltString"]);
33813
					
34047
 
33814
					#如果執行失敗
34048
					#如果執行失敗
33815
					if($spiltString["status"]==="false"){
34049
					if($spiltString["status"]==="false"){
33816
					
34050
 
33817
						#設置執行失敗
34051
						#設置執行失敗
33818
						$result["status"]="false";
34052
						$result["status"]="false";
33819
 
34053
 
33820
						#設置錯誤訊息
34054
						#設置錯誤訊息
33821
						$result["error"]=$spiltString;
34055
						$result["error"]=$spiltString;
33822
 
34056
 
33823
						#回傳結果
34057
						#回傳結果
33824
						return $result;
34058
						return $result;
33825
					
34059
 
33826
						}#if end
34060
						}#if end
33827
						
34061
 
33828
					#如果應該要存在的關鍵字不存在
34062
					#如果應該要存在的關鍵字不存在
33829
					if($spiltString["found"]==="false"){
34063
					if($spiltString["found"]==="false"){
33830
					
34064
 
33831
						#設置執行失敗
34065
						#設置執行失敗
33832
						$result["status"]="false";
34066
						$result["status"]="false";
33833
 
34067
 
33834
						#設置錯誤訊息
34068
						#設置錯誤訊息
33835
						$result["error"]=$spiltString;
34069
						$result["error"]=$spiltString;
33836
 
34070
 
33837
						#回傳結果
34071
						#回傳結果
33838
						return $result;
34072
						return $result;
33839
					
34073
 
33840
						}#if end
34074
						}#if end
33841
						
34075
 
33842
					#如果不是切成兩段
34076
					#如果不是切成兩段
33843
					if($spiltString["dataCounts"]!==2){
34077
					if($spiltString["dataCounts"]!==2){
33844
					
34078
 
33845
						#設置執行失敗
34079
						#設置執行失敗
33846
						$result["status"]="false";
34080
						$result["status"]="false";
33847
 
34081
 
33848
						#設置錯誤訊息
34082
						#設置錯誤訊息
33849
						$result["error"]=$spiltString;
34083
						$result["error"]=$spiltString;
33850
 
34084
 
33851
						#回傳結果
34085
						#回傳結果
33852
						return $result;
34086
						return $result;
33853
					
34087
 
33854
						}#if end
34088
						}#if end
33855
						
34089
 
33856
					#更新 ip and port 變數
34090
					#更新 ip and port 變數
33857
					$ipAndPort=$spiltString["oriStr"];
34091
					$ipAndPort=$spiltString["oriStr"];
33858
					
34092
 
33859
					#更新 ip
34093
					#更新 ip
33860
					$ip=$spiltString["dataArray"][0];
34094
					$ip=$spiltString["dataArray"][0];
33861
					
34095
 
33862
					#更新 port
34096
					#更新 port
33863
					$port=$spiltString["dataArray"][1];
34097
					$port=$spiltString["dataArray"][1];
33864
					
34098
 
33865
					#嘗試移除 "(" 前面的內容
34099
					#嘗試移除 "(" 前面的內容
33866
					#函式說明:
34100
					#函式說明:
33867
					#將字串特定關鍵字與其前面的內容剔除
34101
					#將字串特定關鍵字與其前面的內容剔除
33868
					#回傳結果:
34102
					#回傳結果:
33869
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34103
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33871... Line 34105...
33871
					#$result["warning"],警告訊息鎮列.
34105
					#$result["warning"],警告訊息鎮列.
33872
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
34106
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
33873
					#$result["function"],當前執行的函數名稱.
34107
					#$result["function"],當前執行的函數名稱.
33874
					#$result["argu"],使用的參數.
34108
					#$result["argu"],使用的參數.
33875
					#$result["oriStr"],要處理的原始字串內容.
34109
					#$result["oriStr"],要處理的原始字串內容.
33876
					#$result["content"],處理好的的字串內容.	
34110
					#$result["content"],處理好的的字串內容.
33877
					#必填參數:
34111
					#必填參數:
33878
					#$conf["stringIn"],字串,要處理的字串.
34112
					#$conf["stringIn"],字串,要處理的字串.
33879
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$callShell["output"][$line];
34113
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$callShell["output"][$line];
33880
					#$conf["keyWord"],字串,特定字串.
34114
					#$conf["keyWord"],字串,特定字串.
33881
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="(";
34115
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="(";
Line 33888... Line 34122...
33888
					#無.
34122
					#無.
33889
					#備註:
34123
					#備註:
33890
					#無.
34124
					#無.
33891
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
34125
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
33892
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
34126
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
33893
					
34127
 
33894
					#如果執行失敗
34128
					#如果執行失敗
33895
					if($delStrBeforeKeyWord["status"]==="false"){
34129
					if($delStrBeforeKeyWord["status"]==="false"){
33896
					
34130
 
33897
						#設置執行失敗
34131
						#設置執行失敗
33898
						$result["status"]="false";
34132
						$result["status"]="false";
33899
 
34133
 
33900
						#設置錯誤訊息
34134
						#設置錯誤訊息
33901
						$result["error"]=$delStrBeforeKeyWord;
34135
						$result["error"]=$delStrBeforeKeyWord;
33902
 
34136
 
33903
						#回傳結果
34137
						#回傳結果
33904
						return $result;
34138
						return $result;
33905
					
34139
 
33906
						}#if end
34140
						}#if end
33907
						
34141
 
33908
					#如果應該要存在的關鍵字存在
34142
					#如果應該要存在的關鍵字存在
33909
					if($delStrBeforeKeyWord["founded"]==="true"){
34143
					if($delStrBeforeKeyWord["founded"]==="true"){
33910
					
34144
 
33911
						#嘗試移除 ")" 後面的內容
34145
						#嘗試移除 ")" 後面的內容
33912
						#函式說明:
34146
						#函式說明:
33913
						#將字串特定關鍵字與其後面的內容剔除
34147
						#將字串特定關鍵字與其後面的內容剔除
33914
						#回傳結果:
34148
						#回傳結果:
33915
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34149
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33932... Line 34166...
33932
						#無.
34166
						#無.
33933
						#備註:
34167
						#備註:
33934
						#無.
34168
						#無.
33935
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
34169
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33936
						unset($conf["stringProcess::delStrAfterKeyWord"]);
34170
						unset($conf["stringProcess::delStrAfterKeyWord"]);
33937
						
34171
 
33938
						#如果執行失敗
34172
						#如果執行失敗
33939
						if($delStrAfterKeyWord["status"]==="false"){
34173
						if($delStrAfterKeyWord["status"]==="false"){
33940
						
34174
 
33941
							#設置執行失敗
34175
							#設置執行失敗
33942
							$result["status"]="false";
34176
							$result["status"]="false";
33943
 
34177
 
33944
							#設置錯誤訊息
34178
							#設置錯誤訊息
33945
							$result["error"]=$delStrAfterKeyWord;
34179
							$result["error"]=$delStrAfterKeyWord;
33946
 
34180
 
33947
							#回傳結果
34181
							#回傳結果
33948
							return $result;
34182
							return $result;
33949
						
34183
 
33950
							}#if end
34184
							}#if end
33951
							
34185
 
33952
						#如果無找到 ")"
34186
						#如果無找到 ")"
33953
						if($delStrAfterKeyWord["founded"]==="false"){
34187
						if($delStrAfterKeyWord["founded"]==="false"){
33954
						
34188
 
33955
							#設置執行失敗
34189
							#設置執行失敗
33956
							$result["status"]="false";
34190
							$result["status"]="false";
33957
 
34191
 
33958
							#設置錯誤訊息
34192
							#設置錯誤訊息
33959
							$result["error"]=$delStrAfterKeyWord;
34193
							$result["error"]=$delStrAfterKeyWord;
33960
 
34194
 
33961
							#回傳結果
34195
							#回傳結果
33962
							return $result;
34196
							return $result;
33963
						
34197
 
33964
							}#if end
34198
							}#if end
33965
						
34199
 
33966
						#嘗試移除":number"
34200
						#嘗試移除":number"
33967
						#函式說明:
34201
						#函式說明:
33968
						#將字串特定關鍵字與其後面的內容剔除
34202
						#將字串特定關鍵字與其後面的內容剔除
33969
						#回傳結果:
34203
						#回傳結果:
33970
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34204
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 33987... Line 34221...
33987
						#無.
34221
						#無.
33988
						#備註:
34222
						#備註:
33989
						#無.
34223
						#無.
33990
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
34224
						$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
33991
						unset($conf["stringProcess::delStrAfterKeyWord"]);
34225
						unset($conf["stringProcess::delStrAfterKeyWord"]);
33992
						
34226
 
33993
						#如果執行失敗
34227
						#如果執行失敗
33994
						if($delStrAfterKeyWord["status"]==="false"){
34228
						if($delStrAfterKeyWord["status"]==="false"){
33995
						
34229
 
33996
							#設置執行失敗
34230
							#設置執行失敗
33997
							$result["status"]="false";
34231
							$result["status"]="false";
33998
 
34232
 
33999
							#設置錯誤訊息
34233
							#設置錯誤訊息
34000
							$result["error"]=$delStrAfterKeyWord;
34234
							$result["error"]=$delStrAfterKeyWord;
34001
 
34235
 
34002
							#回傳結果
34236
							#回傳結果
34003
							return $result;
34237
							return $result;
34004
						
34238
 
34005
							}#if end
34239
							}#if end
34006
						
34240
 
34007
						#取得 vhost 設定檔案的位置
34241
						#取得 vhost 設定檔案的位置
34008
						$vhostFile=$delStrAfterKeyWord["content"];
34242
						$vhostFile=$delStrAfterKeyWord["content"];
34009
						
34243
 
34010
						#取得設定檔的內容
34244
						#取得設定檔的內容
34011
						#函式說明:
34245
						#函式說明:
34012
						#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
34246
						#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
34013
						#回傳的變數說明:
34247
						#回傳的變數說明:
34014
						#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
34248
						#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 34041... Line 34275...
34041
						#無.
34275
						#無.
34042
						#備註:
34276
						#備註:
34043
						#無.
34277
						#無.
34044
						$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
34278
						$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
34045
						unset($conf["fileAccess::getFileContent"]);
34279
						unset($conf["fileAccess::getFileContent"]);
34046
						
34280
 
34047
						#如果執行失敗
34281
						#如果執行失敗
34048
						if($getFileContent["status"]==="false"){
34282
						if($getFileContent["status"]==="false"){
34049
						
34283
 
34050
							#設置執行失敗
34284
							#設置執行失敗
34051
							$result["status"]="false";
34285
							$result["status"]="false";
34052
 
34286
 
34053
							#設置錯誤訊息
34287
							#設置錯誤訊息
34054
							$result["error"]=$getFileContent;
34288
							$result["error"]=$getFileContent;
34055
 
34289
 
34056
							#回傳結果
34290
							#回傳結果
34057
							return $result;
34291
							return $result;
34058
						
34292
 
34059
							}#if end
34293
							}#if end
34060
						
34294
 
34061
						#符合條件的內容範例
34295
						#符合條件的內容範例
34062
						/*
34296
						/*
34063
						DocumentRoot "/var/www/html/qbpwcf"
34297
						DocumentRoot "/var/www/html/qbpwcf"
34064
						ServerName mobile.qbpwcf.org:443
34298
						ServerName mobile.qbpwcf.org:443
34065
						ServerAlias www.qbpwcf.org
34299
						ServerAlias www.qbpwcf.org
34066
						ServerAlias qbpwcf.org
34300
						ServerAlias qbpwcf.org
34067
						*/
34301
						*/
34068
						
34302
 
34069
						#取得 ServerName、ServerAlias、DocumentRoot - start
34303
						#取得 ServerName、ServerAlias、DocumentRoot - start
34070
				
34304
 
34071
						#函式說明:
34305
						#函式說明:
34072
						#取得符合多個特定字首與字尾之一的字串們
34306
						#取得符合多個特定字首與字尾之一的字串們
34073
						#回傳結果:
34307
						#回傳結果:
34074
						#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
34308
						#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
34075
						#$result["function"],當前執行的函數名稱.
34309
						#$result["function"],當前執行的函數名稱.
Line 34088... Line 34322...
34088
						#無.
34322
						#無.
34089
						#備註:
34323
						#備註:
34090
						#無.
34324
						#無.
34091
						$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
34325
						$getMeetMultiConditionsStrings=search::getMeetMultiConditionsStrings($conf["search::getMeetMultiConditionsStrings"]);
34092
						unset($conf["search::getMeetMultiConditionsStrings"]);
34326
						unset($conf["search::getMeetMultiConditionsStrings"]);
34093
						
34327
 
34094
						#如果執行失敗
34328
						#如果執行失敗
34095
						if($getMeetMultiConditionsStrings["status"]==="false"){
34329
						if($getMeetMultiConditionsStrings["status"]==="false"){
34096
						
34330
 
34097
							#設置執行失敗
34331
							#設置執行失敗
34098
							$result["status"]="false";
34332
							$result["status"]="false";
34099
 
34333
 
34100
							#設置錯誤訊息
34334
							#設置錯誤訊息
34101
							$result["error"]=$getMeetMultiConditionsStrings;
34335
							$result["error"]=$getMeetMultiConditionsStrings;
34102
 
34336
 
34103
							#回傳結果
34337
							#回傳結果
34104
							return $result;
34338
							return $result;
34105
						
34339
 
34106
							}#if end
34340
							}#if end
34107
						
34341
 
34108
						#如果沒有需要的關鍵字存在
34342
						#如果沒有需要的關鍵字存在
34109
						if($getMeetMultiConditionsStrings["found"]==="false"){
34343
						if($getMeetMultiConditionsStrings["found"]==="false"){
34110
						
34344
 
34111
							#設置執行失敗
34345
							#設置執行失敗
34112
							$result["status"]="false";
34346
							$result["status"]="false";
34113
 
34347
 
34114
							#設置錯誤訊息
34348
							#設置錯誤訊息
34115
							$result["error"]=$getMeetMultiConditionsStrings;
34349
							$result["error"]=$getMeetMultiConditionsStrings;
34116
 
34350
 
34117
							#回傳結果
34351
							#回傳結果
34118
							return $result;
34352
							return $result;
34119
						
34353
 
34120
							}#if end
34354
							}#if end
34121
						
34355
 
34122
						#初始化vhost的資訊
34356
						#初始化vhost的資訊
34123
						$vhostInfo=array("ip"=>$defaultIp,"port"=>$defaultPort,"DocumentRoot"=>$defaultDocumentRoot);
34357
						$vhostInfo=array("ip"=>$defaultIp,"port"=>$defaultPort,"DocumentRoot"=>$defaultDocumentRoot);
34124
						
34358
 
34125
						#針對每個找到的結果
34359
						#針對每個找到的結果
34126
						foreach($getMeetMultiConditionsStrings["content"] as $found){
34360
						foreach($getMeetMultiConditionsStrings["content"] as $found){
34127
						
34361
 
34128
							#取得符合的關鍵字/屬性名稱
34362
							#取得符合的關鍵字/屬性名稱
34129
							$attrName=$found["meetConditions"]["front"];
34363
							$attrName=$found["meetConditions"]["front"];
34130
							
34364
 
34131
							#取得屬性的數值
34365
							#取得屬性的數值
34132
							$attrValue=$found["content"];
34366
							$attrValue=$found["content"];
34133
						
34367
 
34134
							#移除屬性數值前面的空白
34368
							#移除屬性數值前面的空白
34135
							#函式說明:
34369
							#函式說明:
34136
							#將字串特定關鍵字與其前面的內容剔除
34370
							#將字串特定關鍵字與其前面的內容剔除
34137
							#回傳結果:
34371
							#回傳結果:
34138
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34372
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 34140... Line 34374...
34140
							#$result["warning"],警告訊息鎮列.
34374
							#$result["warning"],警告訊息鎮列.
34141
							#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
34375
							#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
34142
							#$result["function"],當前執行的函數名稱.
34376
							#$result["function"],當前執行的函數名稱.
34143
							#$result["argu"],使用的參數.
34377
							#$result["argu"],使用的參數.
34144
							#$result["oriStr"],要處理的原始字串內容.
34378
							#$result["oriStr"],要處理的原始字串內容.
34145
							#$result["content"],處理好的的字串內容.	
34379
							#$result["content"],處理好的的字串內容.
34146
							#必填參數:
34380
							#必填參數:
34147
							#$conf["stringIn"],字串,要處理的字串.
34381
							#$conf["stringIn"],字串,要處理的字串.
34148
							$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$attrValue;
34382
							$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$attrValue;
34149
							#$conf["keyWord"],字串,特定字串.
34383
							#$conf["keyWord"],字串,特定字串.
34150
							$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
34384
							$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
Line 34157... Line 34391...
34157
							#無.
34391
							#無.
34158
							#備註:
34392
							#備註:
34159
							#無.
34393
							#無.
34160
							$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
34394
							$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
34161
							unset($conf["stringProcess::delStrBeforeKeyWord"]);
34395
							unset($conf["stringProcess::delStrBeforeKeyWord"]);
34162
						
34396
 
34163
							#如果執行失敗
34397
							#如果執行失敗
34164
							if($delStrBeforeKeyWord["status"]==="false"){
34398
							if($delStrBeforeKeyWord["status"]==="false"){
34165
							
34399
 
34166
								#設置執行失敗
34400
								#設置執行失敗
34167
								$result["status"]="false";
34401
								$result["status"]="false";
34168
 
34402
 
34169
								#設置錯誤訊息
34403
								#設置錯誤訊息
34170
								$result["error"]=$delStrBeforeKeyWord;
34404
								$result["error"]=$delStrBeforeKeyWord;
34171
 
34405
 
34172
								#回傳結果
34406
								#回傳結果
34173
								return $result;
34407
								return $result;
34174
							
34408
 
34175
								}#if end
34409
								}#if end
34176
								
34410
 
34177
							#如果不存在開頭的空白
34411
							#如果不存在開頭的空白
34178
							if($delStrBeforeKeyWord["founded"]==="false"){
34412
							if($delStrBeforeKeyWord["founded"]==="false"){
34179
							
34413
 
34180
								#設置執行失敗
34414
								#設置執行失敗
34181
								$result["status"]="false";
34415
								$result["status"]="false";
34182
 
34416
 
34183
								#設置錯誤訊息
34417
								#設置錯誤訊息
34184
								$result["error"]=$delStrBeforeKeyWord;
34418
								$result["error"]=$delStrBeforeKeyWord;
34185
 
34419
 
34186
								#回傳結果
34420
								#回傳結果
34187
								return $result;
34421
								return $result;
34188
							
34422
 
34189
								}#if end
34423
								}#if end
34190
							
34424
 
34191
							#取得移除開頭空格後的屬性數值
34425
							#取得移除開頭空格後的屬性數值
34192
							$attrValue=$delStrBeforeKeyWord["content"];
34426
							$attrValue=$delStrBeforeKeyWord["content"];
34193
						
34427
 
34194
							#如果是 ServerName 定義行
34428
							#如果是 ServerName 定義行
34195
							if($attrName="ServerName"){
34429
							if($attrName="ServerName"){
34196
							
34430
 
34197
								#判斷 ServerName 的結尾是否為 ":".$port,並移除之.
34431
								#判斷 ServerName 的結尾是否為 ":".$port,並移除之.
34198
								#函式說明:
34432
								#函式說明:
34199
								#將字串特定關鍵字與其後面的內容剔除
34433
								#將字串特定關鍵字與其後面的內容剔除
34200
								#回傳結果:
34434
								#回傳結果:
34201
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34435
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 34219... Line 34453...
34219
								#無.
34453
								#無.
34220
								#備註:
34454
								#備註:
34221
								#無.
34455
								#無.
34222
								$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
34456
								$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
34223
								unset($conf["stringProcess::delStrAfterKeyWord"]);
34457
								unset($conf["stringProcess::delStrAfterKeyWord"]);
34224
								
34458
 
34225
								#如果執行失敗
34459
								#如果執行失敗
34226
								if($delStrAfterKeyWord["status"]==="false"){
34460
								if($delStrAfterKeyWord["status"]==="false"){
34227
								
34461
 
34228
									#設置執行失敗
34462
									#設置執行失敗
34229
									$result["status"]="false";
34463
									$result["status"]="false";
34230
 
34464
 
34231
									#設置錯誤訊息
34465
									#設置錯誤訊息
34232
									$result["error"]=$delStrAfterKeyWord;
34466
									$result["error"]=$delStrAfterKeyWord;
34233
 
34467
 
34234
									#回傳結果
34468
									#回傳結果
34235
									return $result;
34469
									return $result;
34236
								
34470
 
34237
									}#if end
34471
									}#if end
34238
									
34472
 
34239
								#如果有符合的關鍵字
34473
								#如果有符合的關鍵字
34240
								if($delStrAfterKeyWord["founded"]==="true"){
34474
								if($delStrAfterKeyWord["founded"]==="true"){
34241
								
34475
 
34242
									#取得處理好的內容
34476
									#取得處理好的內容
34243
									$attrValue=$delStrAfterKeyWord["content"];
34477
									$attrValue=$delStrAfterKeyWord["content"];
34244
								
34478
 
34245
									#更新 port
34479
									#更新 port
34246
									$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
34480
									$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
34247
									
34481
 
34248
									}#if end
34482
									}#if end
34249
							
34483
 
34250
								#更新 port
34484
								#更新 port
34251
								$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
34485
								$vhostInfo["port"]=substr($delStrAfterKeyWord["deleted"],1);
34252
															
34486
 
34253
								}#if end
34487
								}#if end
34254
						
34488
 
34255
							#設置 vhost 資訊
34489
							#設置 vhost 資訊
34256
							$vhostInfo[$attrName]=$attrValue;
34490
							$vhostInfo[$attrName]=$attrValue;
34257
						
34491
 
34258
							}#foreach end
34492
							}#foreach end
34259
						
34493
 
34260
						#如果沒有 document 存在
34494
						#如果沒有 document 存在
34261
						if(!isset($vhostInfo["DocumentRoot"])){
34495
						if(!isset($vhostInfo["DocumentRoot"])){
34262
						
34496
 
34263
							#給予預設的 document root
34497
							#給予預設的 document root
34264
							$vhostInfo["DocumentRoot"]=$defaultDocumentRoot;
34498
							$vhostInfo["DocumentRoot"]=$defaultDocumentRoot;
34265
						
34499
 
34266
							}#if end
34500
							}#if end
34267
						
34501
 
34268
						#儲存解析出來的 vhost 資訊到要回傳的結果
34502
						#儲存解析出來的 vhost 資訊到要回傳的結果
34269
						$result["content"][]=$vhostInfo;
34503
						$result["content"][]=$vhostInfo;
34270
						
34504
 
34271
						#取得 ServerName、ServerAlias、DocumentRoot - end
34505
						#取得 ServerName、ServerAlias、DocumentRoot - end
34272
					
34506
 
34273
						}#if end
34507
						}#if end
34274
					
34508
 
34275
					}#else end
34509
					}#else end
34276
				
34510
 
34277
				}#else end
34511
				}#else end
34278
		
34512
 
34279
			}#if end
34513
			}#if end
34280
		
34514
 
34281
		#剔除重複的vhost內容
34515
		#剔除重複的vhost內容
34282
		#函式說明:
34516
		#函式說明:
34283
		#將陣列中重複的元素剔除
34517
		#將陣列中重複的元素剔除
34284
		#回傳的結果:
34518
		#回傳的結果:
34285
		#$result["status"],"true"表執行正常,"false"代表執行不正常.
34519
		#$result["status"],"true"表執行正常,"false"代表執行不正常.
Line 34296... Line 34530...
34296
		#無.
34530
		#無.
34297
		#備註:
34531
		#備註:
34298
		#無.
34532
		#無.
34299
		$unique=arrays::unique($conf["arrays::unique"]);
34533
		$unique=arrays::unique($conf["arrays::unique"]);
34300
		unset($conf["arrays::unique"]);
34534
		unset($conf["arrays::unique"]);
34301
		
34535
 
34302
		#debug
34536
		#debug
34303
		#var_dump(__LINE__,$unique);
34537
		#var_dump(__LINE__,$unique);
34304
		
34538
 
34305
		#如果執行失敗
34539
		#如果執行失敗
34306
		if($unique["status"]==="false"){
34540
		if($unique["status"]==="false"){
34307
		
34541
 
34308
			#設置執行失敗
34542
			#設置執行失敗
34309
			$result["status"]="false";
34543
			$result["status"]="false";
34310
 
34544
 
34311
			#設置錯誤訊息
34545
			#設置錯誤訊息
34312
			$result["error"]=$unique;
34546
			$result["error"]=$unique;
34313
 
34547
 
34314
			#回傳結果
34548
			#回傳結果
34315
			return $result;
34549
			return $result;
34316
		
34550
 
34317
			}#if end
34551
			}#if end
34318
			
34552
 
34319
		#取得不重複的vhost內容
34553
		#取得不重複的vhost內容
34320
		$result["content"]=$unique["content"];
34554
		$result["content"]=$unique["content"];
34321
		
34555
 
34322
		#如果沒有vhost的解析結果
34556
		#如果沒有vhost的解析結果
34323
		if(!isset($result["content"])){
34557
		if(!isset($result["content"])){
34324
		
34558
 
34325
			#設置錯誤訊息
34559
			#設置錯誤訊息
34326
			$result["error"][]="No vhost setting found";
34560
			$result["error"][]="No vhost setting found";
34327
		
34561
 
34328
			#設置執行失敗
34562
			#設置執行失敗
34329
			$result["status"]="false";
34563
			$result["status"]="false";
34330
			
34564
 
34331
			#回傳結果
34565
			#回傳結果
34332
			return $result;
34566
			return $result;
34333
		
34567
 
34334
			}#if end
34568
			}#if end
34335
		
34569
 
34336
		#設置執行正常
34570
		#設置執行正常
34337
		$result["status"]="true";
34571
		$result["status"]="true";
34338
		
34572
 
34339
		#回傳結果
34573
		#回傳結果
34340
		return $result;	
34574
		return $result;
34341
	
34575
 
34342
		}#function httpdGetVhostInfo end
34576
		}#function httpdGetVhostInfo end
34343
 
34577
 
34344
	/*
34578
	/*
34345
	#函式說明:
34579
	#函式說明:
34346
	#產生 rpmspec 檔案內容的程式.
34580
	#產生 rpmspec 檔案內容的程式.
Line 34360... Line 34594...
34360
	#$conf["desc"]="";
34594
	#$conf["desc"]="";
34361
	#可省略參數:
34595
	#可省略參數:
34362
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
34596
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
34363
	#$conf["fileArgu"]=__FILE__;
34597
	#$conf["fileArgu"]=__FILE__;
34364
	#$conf["release"],字串,發行版次。初始值一般都應該是 "1%{?dist}" ,每次新發行同版本軟體的軟體包就遞增一個數字。若上游發行新的版本,就對應修改 Version 標籤,然後把 Release >發行版次重設回 1
34598
	#$conf["release"],字串,發行版次。初始值一般都應該是 "1%{?dist}" ,每次新發行同版本軟體的軟體包就遞增一個數字。若上游發行新的版本,就對應修改 Version 標籤,然後把 Release >發行版次重設回 1
34365
	#$conf["release"]="";	
34599
	#$conf["release"]="";
34366
	#$conf["license"],字串,版權宣告,預設為 "GPL-3.0-or-later" .
34600
	#$conf["license"],字串,版權宣告,預設為 "GPL-3.0-or-later" .
34367
	#$conf["license"]="";
34601
	#$conf["license"]="";
34368
	#$conf["projectUrl"],字串,該package所屬專案的官方網址,預設為"https://%{name}.qbpwcf.org".
34602
	#$conf["projectUrl"],字串,該package所屬專案的官方網址,預設為"https://%{name}.qbpwcf.org".
34369
	#$conf["projectUrl"]="";
34603
	#$conf["projectUrl"]="";
34370
	#$conf["sourceFileUrl"],字串,原始碼檔案的下載位置,預設為"https://%{name}.qbpwcf.org/%{name}-%{version}.tar.zst"
34604
	#$conf["sourceFileUrl"],字串,原始碼檔案的下載位置,預設為"https://%{name}.qbpwcf.org/%{name}-%{version}.tar.zst"
Line 34383... Line 34617...
34383
	#無
34617
	#無
34384
	#備註:
34618
	#備註:
34385
	#建構中...
34619
	#建構中...
34386
	*/
34620
	*/
34387
	public static function createRPMspec(&$conf){
34621
	public static function createRPMspec(&$conf){
34388
	
34622
 
34389
		}#function createRPMspec end
34623
		}#function createRPMspec end
34390
 
34624
 
34391
	/*
34625
	/*
34392
	#函式說明:
34626
	#函式說明:
34393
	#產生 php 程式的字串,將外部變數透過編碼的方式放進去.
34627
	#產生 php 程式的字串,將外部變數透過編碼的方式放進去.
Line 34409... Line 34643...
34409
	#https://www.php.net/manual/en/function.unserialize.php
34643
	#https://www.php.net/manual/en/function.unserialize.php
34410
	#備註:
34644
	#備註:
34411
	#無.
34645
	#無.
34412
	*/
34646
	*/
34413
	public static function createPHPcodeString(&$conf){
34647
	public static function createPHPcodeString(&$conf){
34414
	
34648
 
34415
		#初始化要回傳的結果
34649
		#初始化要回傳的結果
34416
		$result=array();
34650
		$result=array();
34417
 
34651
 
34418
		#取得當前執行的函數名稱
34652
		#取得當前執行的函數名稱
34419
		$result["function"]=__FUNCTION__;
34653
		$result["function"]=__FUNCTION__;
Line 34454... Line 34688...
34454
 
34688
 
34455
			#回傳結果
34689
			#回傳結果
34456
			return $result;
34690
			return $result;
34457
 
34691
 
34458
			}#if end
34692
			}#if end
34459
	
34693
 
34460
		#函式說明:
34694
		#函式說明:
34461
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
34695
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
34462
		#回傳結果:
34696
		#回傳結果:
34463
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34697
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
34464
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
34698
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 34506... Line 34740...
34506
		#array_keys=>http://php.net/manual/en/function.array-keys.php
34740
		#array_keys=>http://php.net/manual/en/function.array-keys.php
34507
		#備註:
34741
		#備註:
34508
		#無.
34742
		#無.
34509
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
34743
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
34510
		unset($conf["variableCheck::checkArguments"]);
34744
		unset($conf["variableCheck::checkArguments"]);
34511
	
34745
 
34512
		#如果執行失敗
34746
		#如果執行失敗
34513
		if($checkArguments["status"]==="false"){
34747
		if($checkArguments["status"]==="false"){
34514
		
34748
 
34515
			#設置執行失敗
34749
			#設置執行失敗
34516
			$result["status"]="false";
34750
			$result["status"]="false";
34517
 
34751
 
34518
			#設置錯誤訊息
34752
			#設置錯誤訊息
34519
			$result["error"]=$checkArguments;
34753
			$result["error"]=$checkArguments;
34520
 
34754
 
34521
			#回傳結果
34755
			#回傳結果
34522
			return $result;
34756
			return $result;
34523
		
34757
 
34524
			}#if end
34758
			}#if end
34525
			
34759
 
34526
		#如果檢查不通過
34760
		#如果檢查不通過
34527
		if($checkArguments["passed"]==="false"){
34761
		if($checkArguments["passed"]==="false"){
34528
		
34762
 
34529
			#設置執行失敗
34763
			#設置執行失敗
34530
			$result["status"]="false";
34764
			$result["status"]="false";
34531
 
34765
 
34532
			#設置錯誤訊息
34766
			#設置錯誤訊息
34533
			$result["error"]=$checkArguments;
34767
			$result["error"]=$checkArguments;
34534
 
34768
 
34535
			#回傳結果
34769
			#回傳結果
34536
			return $result;
34770
			return $result;
34537
		
34771
 
34538
			}#if end
34772
			}#if end
34539
	
34773
 
34540
		#初始化儲存結果的變數
34774
		#初始化儲存結果的變數
34541
		$result["content"]="";
34775
		$result["content"]="";
34542
	
34776
 
34543
		#針對每段程式字串 
34777
		#針對每段程式字串
34544
		foreach($conf["codes"] as $index => $code){
34778
		foreach($conf["codes"] as $index => $code){
34545
		
34779
 
34546
			#串接程式 
34780
			#串接程式
34547
			$result["content"]=$result["content"].$code;
34781
			$result["content"]=$result["content"].$code;
34548
		
34782
 
34549
			#如果有設置  vars
34783
			#如果有設置  vars
34550
			if(isset($conf["vars"])){
34784
			if(isset($conf["vars"])){
34551
			
34785
 
34552
				#如果有設置要接上的php變數
34786
				#如果有設置要接上的php變數
34553
				if(isset($conf["vars"][$index])){
34787
				if(isset($conf["vars"][$index])){
34554
				
34788
 
34555
					#編碼變數
34789
					#編碼變數
34556
					$encodedVarStr=base64_encode(serialize($conf["vars"][$index]));
34790
					$encodedVarStr=base64_encode(serialize($conf["vars"][$index]));
34557
				
34791
 
34558
					#串接變數
34792
					#串接變數
34559
					$result["content"]=$result["content"]."unserialize(base64_decode(\"".$encodedVarStr."\"))";
34793
					$result["content"]=$result["content"]."unserialize(base64_decode(\"".$encodedVarStr."\"))";
34560
				
34794
 
34561
					}#if end
34795
					}#if end
34562
			
34796
 
34563
				}#if end
34797
				}#if end
34564
		
34798
 
34565
			}#foreach end
34799
			}#foreach end
34566
			
34800
 
34567
		#設置執行正常
34801
		#設置執行正常
34568
		$result["status"]="true";
34802
		$result["status"]="true";
34569
		
34803
 
34570
		#回傳結果
34804
		#回傳結果
34571
		return $result;
34805
		return $result;
34572
	
34806
 
34573
		}#function createPHPcodeString end
34807
		}#function createPHPcodeString end
34574
 
34808
 
34575
	}#class cmd end
34809
	}#class cmd end
34576
 
34810
 
34577
?>
-
 
34578
34811
?>
-
 
34812