Subversion Repositories php-qbpwcf

Rev

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

Rev 249 Rev 253
Line 1270... Line 1270...
1270
	#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
1270
	#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
1271
	$conf["dnsRecordFile"]="";
1271
	$conf["dnsRecordFile"]="";
1272
	#可省略參數:
1272
	#可省略參數:
1273
	#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
1273
	#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
1274
	#$conf["writeNow"]="false";
1274
	#$conf["writeNow"]="false";
-
 
1275
	#$conf["debug"],字串,是否要開啟debug模式,預設為"false"不開啟;反之為"true"要開啟,會在/tmp/建立debug檔案zerossl\:\:updateDnsRecordFile.
-
 
1276
	#$conf["debug"]="false";
1275
	#參考資料:
1277
	#參考資料:
1276
	#無.
1278
	#無.
1277
	#備註:
1279
	#備註:
1278
	#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
1280
	#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
1279
	#通常qbpwcf使用者沒有權限存取RR(dns記錄檔案),本套件是透過sshfs掛載來繞過該問題.
1281
	#通常qbpwcf使用者沒有權限存取RR(dns記錄檔案),本套件是透過sshfs掛載來繞過該問題.
Line 1339... Line 1341...
1339
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
1341
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
1340
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1342
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1341
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1343
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1342
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1344
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1343
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1345
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1344
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("writeNow");
1346
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("writeNow","debug");
1345
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1347
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1346
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1348
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
1347
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1349
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1348
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
1350
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false");
1349
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1351
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1350
		#$conf["arrayCountEqualCheck"][]=array();
1352
		#$conf["arrayCountEqualCheck"][]=array();
1351
		#參考資料來源:
1353
		#參考資料來源:
1352
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1354
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1353
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1355
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
Line 1469... Line 1471...
1469
		foreach($lines as $lineNo => $line){
1471
		foreach($lines as $lineNo => $line){
1470
		
1472
		
1471
			#另存一份要處理的RR
1473
			#另存一份要處理的RR
1472
			$unFormatStr=$line;
1474
			$unFormatStr=$line;
1473
		
1475
		
1474
			#/*
1476
			#如果要debug
-
 
1477
			if($conf["debug"]==="true"){
1475
			#debug
1478
			
1476
			#函式說明:
1479
				#函式說明:
1477
			#撰寫log
1480
				#撰寫log
1478
			#回傳結果:
1481
				#回傳結果:
1479
			#$result["status"],狀態,"true"或"false".
1482
				#$result["status"],狀態,"true"或"false".
1480
			#$result["error"],錯誤訊息陣列.
1483
				#$result["error"],錯誤訊息陣列.
1481
			#$result["function"],當前函式的名稱.
1484
				#$result["function"],當前函式的名稱.
1482
			#$result["argu"],使用的參數.
1485
				#$result["argu"],使用的參數.
1483
			#$result["content"],要寫入log的內容字串.
1486
				#$result["content"],要寫入log的內容字串.
1484
			#必填參數:
1487
				#必填參數:
1485
			#$conf["path"],字串,log檔案的路徑與名稱.
1488
				#$conf["path"],字串,log檔案的路徑與名稱.
1486
			$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
1489
				$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
1487
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1490
				#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1488
			$conf["logs::record"]["content"]="processing lineNo:".$lineNo." content:".$line.PHP_EOL;
1491
				$conf["logs::record"]["content"]="processing lineNo:".$lineNo." content:".$line.PHP_EOL;
1489
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1492
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1490
			$conf["logs::record"]["fileArgu"]=__FILE__;
1493
				$conf["logs::record"]["fileArgu"]=__FILE__;
1491
			#可省略參數:
1494
				#可省略參數:
1492
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1495
				#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1493
			#$conf["rewrite"]="false";
1496
				#$conf["rewrite"]="false";
1494
			#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
1497
				#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
1495
			#$conf["returnOnly"]="true";
1498
				#$conf["returnOnly"]="true";
1496
			#參考資料:
1499
				#參考資料:
1497
			#無.
1500
				#無.
1498
			#備註:
1501
				#備註:
1499
			#無.
1502
				#無.
1500
			$record=logs::record($conf["logs::record"]);
1503
				$record=logs::record($conf["logs::record"]);
1501
			unset($conf["logs::record"]);
1504
				unset($conf["logs::record"]);
1502
			#*/
1505
				
-
 
1506
				}#if end
1503
		
1507
			
1504
			#初始化該行的資訊陣列
1508
			#初始化該行的資訊陣列
1505
			$info=array();
1509
			$info=array();
1506
		
1510
		
1507
			#尋找";"開頭的內容,亦即整行都是註解.
1511
			#尋找";"開頭的內容,亦即整行都是註解.
1508
			#函式說明:
1512
			#函式說明:
Line 1651... Line 1655...
1651
					#取得處理後的結果
1655
					#取得處理後的結果
1652
					$unFormatStr=$delHeadStr["content"];
1656
					$unFormatStr=$delHeadStr["content"];
1653
				
1657
				
1654
					}#if end
1658
					}#if end
1655
			
1659
			
-
 
1660
				
-
 
1661
			
1656
				#解析 $ORIGN 的數值, 以及後面是否有註解...
1662
				#解析 $ORIGN 的數值, 以及後面是否有註解...
1657
				#函式說明:
1663
				#函式說明:
1658
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
1664
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
1659
				#回傳結果:
1665
				#回傳結果:
1660
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1666
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 1703... Line 1709...
1703
				
1709
				
1704
					#儲存zone domain
1710
					#儲存zone domain
1705
					$result["domain"]=trim($info["value"]);
1711
					$result["domain"]=trim($info["value"]);
1706
				
1712
				
1707
					#儲存註解
1713
					#儲存註解
1708
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
1714
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
1709
				
1715
				
1710
					#儲存解析好的RR
1716
					#儲存解析好的RR
1711
					$result["content"][]=$info;
1717
					$result["content"][]=$info;
1712
				
1718
				
1713
					#換下一行
1719
					#換下一行
Line 1873... Line 1879...
1873
				
1879
				
1874
					#儲存數值
1880
					#儲存數值
1875
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
1881
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
1876
				
1882
				
1877
					#儲存註解
1883
					#儲存註解
1878
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
1884
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
1879
				
1885
				
1880
					#儲存預設的 TTL
1886
					#儲存預設的 TTL
1881
					$result["defaultTTL"]=trim($info["value"]);
1887
					$result["defaultTTL"]=trim($info["value"]);
1882
				
1888
				
1883
					#儲存解析好的RR
1889
					#儲存解析好的RR
Line 2263... Line 2269...
2263
				}#else end
2269
				}#else end
2264
			
2270
			
2265
			#無窮迴圈
2271
			#無窮迴圈
2266
			while(true){
2272
			while(true){
2267
				
2273
				
2268
				#/*
2274
				#如果要debug
-
 
2275
				if($conf["debug"]==="true"){
2269
				#debug
2276
				
2270
				#函式說明:
2277
					#函式說明:
2271
				#撰寫log
2278
					#撰寫log
2272
				#回傳結果:
2279
					#回傳結果:
2273
				#$result["status"],狀態,"true"或"false".
2280
					#$result["status"],狀態,"true"或"false".
2274
				#$result["error"],錯誤訊息陣列.
2281
					#$result["error"],錯誤訊息陣列.
2275
				#$result["function"],當前函式的名稱.
2282
					#$result["function"],當前函式的名稱.
2276
				#$result["argu"],使用的參數.
2283
					#$result["argu"],使用的參數.
2277
				#$result["content"],要寫入log的內容字串.
2284
					#$result["content"],要寫入log的內容字串.
2278
				#必填參數:
2285
					#必填參數:
2279
				#$conf["path"],字串,log檔案的路徑與名稱.
2286
					#$conf["path"],字串,log檔案的路徑與名稱.
2280
				$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2287
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2281
				#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2288
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2282
				$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2289
					$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2283
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2290
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2284
				$conf["logs::record"]["fileArgu"]=__FILE__;
2291
					$conf["logs::record"]["fileArgu"]=__FILE__;
2285
				#可省略參數:
2292
					#可省略參數:
2286
				#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2293
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2287
				#$conf["rewrite"]="false";
2294
					#$conf["rewrite"]="false";
2288
				#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2295
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2289
				#$conf["returnOnly"]="true";
2296
					#$conf["returnOnly"]="true";
2290
				#參考資料:
2297
					#參考資料:
2291
				#無.
2298
					#無.
2292
				#備註:
2299
					#備註:
2293
				#無.
2300
					#無.
2294
				$record=logs::record($conf["logs::record"]);
2301
					$record=logs::record($conf["logs::record"]);
2295
				unset($conf["logs::record"]);
2302
					unset($conf["logs::record"]);
2296
				#*/
2303
					
-
 
2304
					}#if end
2297
				
2305
				
2298
				#解析 updateTime..IN..type...value...comment
2306
				#解析 updateTime..IN..type...value...comment
2299
			
2307
			
2300
				#判斷是否無 update time
2308
				#判斷是否無 update time
2301
				
2309
				
Line 2350... Line 2358...
2350
					$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
2358
					$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
2351
					
2359
					
2352
					#設置該行沒有指定 update time
2360
					#設置該行沒有指定 update time
2353
					$noUpdateTime="true";
2361
					$noUpdateTime="true";
2354
					
2362
					
2355
					#/*
2363
					#如果要debug
-
 
2364
					if($conf["debug"]==="true"){
2356
					#debug
2365
					
2357
					#函式說明:
2366
						#函式說明:
2358
					#撰寫log
2367
						#撰寫log
2359
					#回傳結果:
2368
						#回傳結果:
2360
					#$result["status"],狀態,"true"或"false".
2369
						#$result["status"],狀態,"true"或"false".
2361
					#$result["error"],錯誤訊息陣列.
2370
						#$result["error"],錯誤訊息陣列.
2362
					#$result["function"],當前函式的名稱.
2371
						#$result["function"],當前函式的名稱.
2363
					#$result["argu"],使用的參數.
2372
						#$result["argu"],使用的參數.
2364
					#$result["content"],要寫入log的內容字串.
2373
						#$result["content"],要寫入log的內容字串.
2365
					#必填參數:
2374
						#必填參數:
2366
					#$conf["path"],字串,log檔案的路徑與名稱.
2375
						#$conf["path"],字串,log檔案的路徑與名稱.
2367
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2376
						$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2368
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2377
						#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2369
					$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2378
						$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2370
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2379
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2371
					$conf["logs::record"]["fileArgu"]=__FILE__;
2380
						$conf["logs::record"]["fileArgu"]=__FILE__;
2372
					#可省略參數:
2381
						#可省略參數:
2373
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2382
						#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2374
					#$conf["rewrite"]="false";
2383
						#$conf["rewrite"]="false";
2375
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2384
						#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2376
					#$conf["returnOnly"]="true";
2385
						#$conf["returnOnly"]="true";
2377
					#參考資料:
2386
						#參考資料:
2378
					#無.
2387
						#無.
2379
					#備註:
2388
						#備註:
2380
					#無.
2389
						#無.
2381
					$record=logs::record($conf["logs::record"]);
2390
						$record=logs::record($conf["logs::record"]);
2382
					unset($conf["logs::record"]);
2391
						unset($conf["logs::record"]);
2383
					#*/
2392
					
-
 
2393
						}#if end
2384
				
2394
				
2385
					}#if end
2395
					}#if end
2386
					
2396
					
2387
				#反之
2397
				#反之
2388
				else{
2398
				else{
Line 2515... Line 2525...
2515
						}#if end
2525
						}#if end
2516
					
2526
					
2517
					#取得IN...value;comment
2527
					#取得IN...value;comment
2518
					$unFormatStr=$delHeadStr["content"];
2528
					$unFormatStr=$delHeadStr["content"];
2519
					
2529
					
2520
					#/*
2530
					#如果要debug
-
 
2531
					if($conf["debug"]==="true"){
2521
					#debug
2532
					
2522
					#函式說明:
2533
						#函式說明:
2523
					#撰寫log
2534
						#撰寫log
2524
					#回傳結果:
2535
						#回傳結果:
2525
					#$result["status"],狀態,"true"或"false".
2536
						#$result["status"],狀態,"true"或"false".
2526
					#$result["error"],錯誤訊息陣列.
2537
						#$result["error"],錯誤訊息陣列.
2527
					#$result["function"],當前函式的名稱.
2538
						#$result["function"],當前函式的名稱.
2528
					#$result["argu"],使用的參數.
2539
						#$result["argu"],使用的參數.
2529
					#$result["content"],要寫入log的內容字串.
2540
						#$result["content"],要寫入log的內容字串.
2530
					#必填參數:
2541
						#必填參數:
2531
					#$conf["path"],字串,log檔案的路徑與名稱.
2542
						#$conf["path"],字串,log檔案的路徑與名稱.
2532
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2543
						$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2533
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2544
						#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2534
					$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2545
						$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2535
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2546
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2536
					$conf["logs::record"]["fileArgu"]=__FILE__;
2547
						$conf["logs::record"]["fileArgu"]=__FILE__;
2537
					#可省略參數:
2548
						#可省略參數:
2538
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2549
						#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2539
					#$conf["rewrite"]="false";
2550
						#$conf["rewrite"]="false";
2540
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2551
						#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2541
					#$conf["returnOnly"]="true";
2552
						#$conf["returnOnly"]="true";
2542
					#參考資料:
2553
						#參考資料:
2543
					#無.
2554
						#無.
2544
					#備註:
2555
						#備註:
2545
					#無.
2556
						#無.
2546
					$record=logs::record($conf["logs::record"]);
2557
						$record=logs::record($conf["logs::record"]);
2547
					unset($conf["logs::record"]);
2558
						unset($conf["logs::record"]);
2548
					#*/
2559
					
-
 
2560
						}#if end
2549
					
2561
					
2550
					}#else end
2562
					}#else end
2551
				
2563
				
2552
				#解析 type...value;comment
2564
				#解析 type...value;comment
2553
				#函式說明:
2565
				#函式說明:
Line 2638... Line 2650...
2638
					#移除用不到的變數
2650
					#移除用不到的變數
2639
					unset($unFormatStr2add);
2651
					unset($unFormatStr2add);
2640
				
2652
				
2641
					}#if end
2653
					}#if end
2642
				
2654
				
2643
				#/*
2655
				#如果要debug
-
 
2656
				if($conf["debug"]==="true"){
2644
				#debug
2657
				
2645
				#函式說明:
2658
					#函式說明:
2646
				#撰寫log
2659
					#撰寫log
2647
				#回傳結果:
2660
					#回傳結果:
2648
				#$result["status"],狀態,"true"或"false".
2661
					#$result["status"],狀態,"true"或"false".
2649
				#$result["error"],錯誤訊息陣列.
2662
					#$result["error"],錯誤訊息陣列.
2650
				#$result["function"],當前函式的名稱.
2663
					#$result["function"],當前函式的名稱.
2651
				#$result["argu"],使用的參數.
2664
					#$result["argu"],使用的參數.
2652
				#$result["content"],要寫入log的內容字串.
2665
					#$result["content"],要寫入log的內容字串.
2653
				#必填參數:
2666
					#必填參數:
2654
				#$conf["path"],字串,log檔案的路徑與名稱.
2667
					#$conf["path"],字串,log檔案的路徑與名稱.
2655
				$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2668
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2656
				#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2669
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2657
				$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2670
					$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
2658
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2671
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2659
				$conf["logs::record"]["fileArgu"]=__FILE__;
2672
					$conf["logs::record"]["fileArgu"]=__FILE__;
2660
				#可省略參數:
2673
					#可省略參數:
2661
				#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2674
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2662
				#$conf["rewrite"]="false";
2675
					#$conf["rewrite"]="false";
2663
				#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2676
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2664
				#$conf["returnOnly"]="true";
2677
					#$conf["returnOnly"]="true";
2665
				#參考資料:
2678
					#參考資料:
2666
				#無.
2679
					#無.
2667
				#備註:
2680
					#備註:
2668
				#無.
2681
					#無.
2669
				$record=logs::record($conf["logs::record"]);
2682
					$record=logs::record($conf["logs::record"]);
2670
				unset($conf["logs::record"]);
2683
					unset($conf["logs::record"]);
2671
				#*/
2684
				
-
 
2685
					}#if end
2672
				
2686
				
2673
				#如果type不為 CNAME 跟 TXT 跟 SOA
2687
				#如果type不為 CNAME 跟 TXT 跟 SOA
2674
				if( $info["type"]!=="CNAME" && $info["type"]!=="TXT" && $info["type"]!=="SOA" ){
2688
				if( $info["type"]!=="CNAME" && $info["type"]!=="TXT" && $info["type"]!=="SOA" ){
2675
				
2689
				
2676
					#儲存value
2690
					#儲存value
Line 2740... Line 2754...
2740
				#執行到這邊,代表type為CNAME或TXT或SOA
2754
				#執行到這邊,代表type為CNAME或TXT或SOA
2741
				
2755
				
2742
				#如果 type 是 SOA
2756
				#如果 type 是 SOA
2743
				if($info["type"]==="SOA"){
2757
				if($info["type"]==="SOA"){
2744
				
2758
				
2745
					#/*
2759
					#如果要debug
-
 
2760
					if($conf["debug"]==="true"){
2746
					#debug
2761
					
2747
					#函式說明:
2762
						#函式說明:
2748
					#撰寫log
2763
						#撰寫log
2749
					#回傳結果:
2764
						#回傳結果:
2750
					#$result["status"],狀態,"true"或"false".
2765
						#$result["status"],狀態,"true"或"false".
2751
					#$result["error"],錯誤訊息陣列.
2766
						#$result["error"],錯誤訊息陣列.
2752
					#$result["function"],當前函式的名稱.
2767
						#$result["function"],當前函式的名稱.
2753
					#$result["argu"],使用的參數.
2768
						#$result["argu"],使用的參數.
2754
					#$result["content"],要寫入log的內容字串.
2769
						#$result["content"],要寫入log的內容字串.
2755
					#必填參數:
2770
						#必填參數:
2756
					#$conf["path"],字串,log檔案的路徑與名稱.
2771
						#$conf["path"],字串,log檔案的路徑與名稱.
2757
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2772
						$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
2758
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2773
						#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2759
					$conf["logs::record"]["content"]="lineNo:".__LINE__." type:".$info["type"].PHP_EOL;
2774
						$conf["logs::record"]["content"]="lineNo:".__LINE__." type:".$info["type"].PHP_EOL;
2760
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2775
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2761
					$conf["logs::record"]["fileArgu"]=__FILE__;
2776
						$conf["logs::record"]["fileArgu"]=__FILE__;
2762
					#可省略參數:
2777
						#可省略參數:
2763
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2778
						#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2764
					#$conf["rewrite"]="false";
2779
						#$conf["rewrite"]="false";
2765
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2780
						#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
2766
					#$conf["returnOnly"]="true";
2781
						#$conf["returnOnly"]="true";
2767
					#參考資料:
2782
						#參考資料:
2768
					#無.
2783
						#無.
2769
					#備註:
2784
						#備註:
2770
					#無.
2785
						#無.
2771
					$record=logs::record($conf["logs::record"]);
2786
						$record=logs::record($conf["logs::record"]);
2772
					unset($conf["logs::record"]);
2787
						unset($conf["logs::record"]);
2773
					#*/
2788
					
-
 
2789
						}#if end
2774
				
2790
						
2775
					#SOA 範例
2791
					#SOA 範例
2776
					#@	1200	IN	SOA	dns.qbpwcf.org. liveuser.qbpwcf.org. 2026012205 10800 1800 1728000 1200 ;domain name server, admin mail, serial, refresh time, expire, Negative Caching, https://bind9.readthedocs.io/en/latest/chapter3.html#term-SOA-minimum
2792
					#@	1200	IN	SOA	dns.qbpwcf.org. liveuser.qbpwcf.org. 2026012205 10800 1800 1728000 1200 ;domain name server, admin mail, serial, refresh time, expire, Negative Caching, https://bind9.readthedocs.io/en/latest/chapter3.html#term-SOA-minimum
2777
				
2793
				
2778
					#再度嘗試分割
2794
					#再度嘗試分割
2779
					#如果 內容為 query updatTime IN type value;comment,或value含有(或",則需要將其符號與後面的內容先暫時拆開
2795
					#如果 內容為 query updatTime IN type value;comment,或value含有(或",則需要將其符號與後面的內容先暫時拆開
Line 3418... Line 3434...
3418
				
3434
				
3419
				}#while end
3435
				}#while end
3420
			
3436
			
3421
			}#foreach end
3437
			}#foreach end
3422
		
3438
		
3423
		#/*
3439
		#如果要debug
-
 
3440
		if($conf["debug"]==="true"){
3424
		#debug
3441
		
3425
		#函式說明:
3442
			#函式說明:
3426
		#撰寫log
3443
			#撰寫log
3427
		#回傳結果:
3444
			#回傳結果:
3428
		#$result["status"],狀態,"true"或"false".
3445
			#$result["status"],狀態,"true"或"false".
3429
		#$result["error"],錯誤訊息陣列.
3446
			#$result["error"],錯誤訊息陣列.
3430
		#$result["function"],當前函式的名稱.
3447
			#$result["function"],當前函式的名稱.
3431
		#$result["argu"],使用的參數.
3448
			#$result["argu"],使用的參數.
3432
		#$result["content"],要寫入log的內容字串.
3449
			#$result["content"],要寫入log的內容字串.
3433
		#必填參數:
3450
			#必填參數:
3434
		#$conf["path"],字串,log檔案的路徑與名稱.
3451
			#$conf["path"],字串,log檔案的路徑與名稱.
3435
		$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
3452
			$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
3436
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
3453
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
3437
		$conf["logs::record"]["content"]="lineNo:".__LINE__." parse RR fin.".PHP_EOL;
3454
			$conf["logs::record"]["content"]="lineNo:".__LINE__." parse RR fin.".PHP_EOL;
3438
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3455
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3439
		$conf["logs::record"]["fileArgu"]=__FILE__;
3456
			$conf["logs::record"]["fileArgu"]=__FILE__;
3440
		#可省略參數:
3457
			#可省略參數:
3441
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
3458
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
3442
		#$conf["rewrite"]="false";
3459
			#$conf["rewrite"]="false";
3443
		#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
3460
			#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
3444
		#$conf["returnOnly"]="true";
3461
			#$conf["returnOnly"]="true";
3445
		#參考資料:
3462
			#參考資料:
3446
		#無.
3463
			#無.
3447
		#備註:
3464
			#備註:
3448
		#無.
3465
			#無.
3449
		$record=logs::record($conf["logs::record"]);
3466
			$record=logs::record($conf["logs::record"]);
3450
		unset($conf["logs::record"]);
3467
			unset($conf["logs::record"]);
3451
		#*/
3468
		
-
 
3469
			}#if end
3452
		
3470
		
3453
		#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
3471
		#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
3454
		
3472
		
3455
		#針對每個要新增的RR記錄
3473
		#針對每個要新增的RR記錄
3456
		foreach($conf["add"] as $newRR){
3474
		foreach($conf["add"] as $newRR){
Line 3478... Line 3496...
3478
					#換看下一筆newRR
3496
					#換看下一筆newRR
3479
					continue 2;
3497
					continue 2;
3480
					
3498
					
3481
					}#if end
3499
					}#if end
3482
			
3500
			
3483
				#如果跟既有的 query、type、value 有相同
3501
				#如果新舊資料都有query資訊
3484
				if($newRR["query"]===$oldRR["query"] && $newRR["type"]===$oldRR["type"] && $newRR["value"]===$oldRR["value"] ){
3502
				if( isset($newRR["query"]) && isset($oldRR["query"]) ){
3485
				
3503
				
3486
					#如果新 RR 有 update time
3504
					#如果跟既有的 query、type、value 有相同
3487
					if(isset($newRR["update"])){
3505
					if($newRR["query"]===$oldRR["query"] && $newRR["type"]===$oldRR["type"] && $newRR["value"]===$oldRR["value"] ){
3488
					
3506
					
3489
						#如果新舊 update time 不相同
3507
						#如果新 RR 有 update time
3490
						if( $newRR["update"] !== $oldRR["update"] ){
3508
						if(isset($newRR["update"])){
3491
						
3509
						
3492
							#取代既有的 RR
3510
							#如果新舊 update time 不相同
3493
							$result["content"][$index]=$newRR;
3511
							if( $newRR["update"] !== $oldRR["update"] ){
3494
							
3512
							
-
 
3513
								#取代既有的 RR
-
 
3514
								$result["content"][$index]=$newRR;
-
 
3515
								
3495
							#換看下一筆newRR
3516
								#換看下一筆newRR
3496
							continue 2;
3517
								continue 2;
-
 
3518
								
-
 
3519
								}#if end
-
 
3520
						
-
 
3521
							}#if end
-
 
3522
							
-
 
3523
						#反之既有的 update time 若跟 global TTL 不一樣
-
 
3524
						else if( $oldRR["update"] !== $result["defaultTTL"] ){
-
 
3525
						
-
 
3526
							#更新為 global TTL
-
 
3527
							$result["content"][$index]["update"]=$result["defaultTTL"];
3497
							
3528
							
3498
							}#if end
3529
							}#if end
3499
					
3530
							
3500
						}#if end
3531
						#如果新 RR 有 comment
-
 
3532
						if( isset($newRR["comment"]) ){
3501
						
3533
						
3502
					#反之既有的 update time 若跟 global TTL 不一樣
-
 
3503
					else if( $oldRR["update"] !== $result["defaultTTL"] ){
-
 
3504
					
-
 
3505
						#更新為 global TTL
3534
							#更新既有 RR 的 comment
3506
						$result["content"][$index]["update"]=$result["defaultTTL"];
3535
							$result["content"][$index]["comment"]=$newRR["comment"];
3507
						
3536
						
-
 
3537
							#換看下一筆newRR
3508
						}#if end
3538
							continue 2;
3509
						
3539
						
3510
					#如果新 RR 有 comment
3540
							}#if end
3511
					if( isset($newRR["comment"]) ){
-
 
3512
					
3541
							
3513
						#更新既有 RR 的 comment
3542
						#反之,如果有既有 comment
3514
						$result["content"][$index]["comment"]=$newRR["comment"];
3543
						else if(isset($result["content"][$index]["comment"])){
3515
					
-
 
3516
						#換看下一筆newRR
-
 
3517
						continue 2;
-
 
3518
					
-
 
3519
						}#if end
-
 
3520
						
3544
						
3521
					#反之,如果有既有 comment
3545
							#移除既有 comment
3522
					else if(isset($result["content"][$index]["comment"])){
3546
							unset($result["content"][$index]["comment"]);
3523
					
3547
							
3524
						#移除既有 comment
3548
							#換看下一筆newRR
3525
						unset($result["content"][$index]["comment"]);
3549
							continue 2;
3526
						
3550
						
3527
						#換看下一筆newRR
-
 
3528
						continue 2;
3551
							}#else end
3529
					
3552
					
3530
						}#else end
3553
						}#if end
3531
				
3554
				
3532
					}#if end
3555
					}#if end
3533
			
3556
					
3534
				}#foreach end
3557
				}#foreach end
3535
				
3558
				
3536
			#儲存確定要新增的RR
3559
			#儲存確定要新增的RR
3537
			$result["content"][]=$newRR;
3560
			$result["content"][]=$newRR;
3538
		
3561
		
Line 3645... Line 3668...
3645
					
3668
					
3646
						}#else end
3669
						}#else end
3647
				
3670
				
3648
					}#if end
3671
					}#if end
3649
				
3672
				
3650
				#反之
3673
				#反之且該ZONE不具備 global TTL.
3651
				else{
3674
				else if(!isset($result["defaultTTL"])){
3652
				
3675
				
3653
					#加上global TTL的字句
3676
					#加上global TTL的字句
3654
					$str2write=$str2write."\t".$result["defaultTTL"];
3677
					$str2write=$str2write."\t".$result["defaultTTL"];
3655
				
3678
				
3656
					}#else end
3679
					}#if end
3657
					
3680
					
3658
				#加上IN跟TYPE跟value
3681
				#加上IN跟TYPE跟value
3659
				$str2write=$str2write."\tIN\t".$RR["type"]."\t".$RR["value"];
3682
				$str2write=$str2write."\tIN\t".$RR["type"]."\t".$RR["value"];
3660
				
3683
				
3661
				}#else end
3684
				}#else end
Line 3666... Line 3689...
3666
				#加上comment
3689
				#加上comment
3667
				$str2write=$str2write.";".$RR["comment"];
3690
				$str2write=$str2write.";".$RR["comment"];
3668
			
3691
			
3669
				}#if end
3692
				}#if end
3670
			
3693
			
3671
			#/*
3694
			#如果要 debug
-
 
3695
			if($conf["debug"]==="true"){
3672
			#debug
3696
			
3673
			#函式說明:
3697
				#函式說明:
3674
			#撰寫log
3698
				#撰寫log
3675
			#回傳結果:
3699
				#回傳結果:
3676
			#$result["status"],狀態,"true"或"false".
3700
				#$result["status"],狀態,"true"或"false".
3677
			#$result["error"],錯誤訊息陣列.
3701
				#$result["error"],錯誤訊息陣列.
3678
			#$result["function"],當前函式的名稱.
3702
				#$result["function"],當前函式的名稱.
3679
			#$result["argu"],使用的參數.
3703
				#$result["argu"],使用的參數.
3680
			#$result["content"],要寫入log的內容字串.
3704
				#$result["content"],要寫入log的內容字串.
3681
			#必填參數:
3705
				#必填參數:
3682
			#$conf["path"],字串,log檔案的路徑與名稱.
3706
				#$conf["path"],字串,log檔案的路徑與名稱.
3683
			$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
3707
				$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
3684
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
3708
				#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
3685
			$conf["logs::record"]["content"]="lineNo:".__LINE__." build RR record:".$str2write.PHP_EOL;
3709
				$conf["logs::record"]["content"]="lineNo:".__LINE__." build RR record:".$str2write.PHP_EOL;
3686
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3710
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3687
			$conf["logs::record"]["fileArgu"]=__FILE__;
3711
				$conf["logs::record"]["fileArgu"]=__FILE__;
3688
			#可省略參數:
3712
				#可省略參數:
3689
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
3713
				#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
3690
			#$conf["rewrite"]="false";
3714
				#$conf["rewrite"]="false";
3691
			#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
3715
				#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
3692
			#$conf["returnOnly"]="true";
3716
				#$conf["returnOnly"]="true";
3693
			#參考資料:
3717
				#參考資料:
3694
			#無.
3718
				#無.
3695
			#備註:
3719
				#備註:
3696
			#無.
3720
				#無.
3697
			$record=logs::record($conf["logs::record"]);
3721
				$record=logs::record($conf["logs::record"]);
3698
			unset($conf["logs::record"]);
3722
				unset($conf["logs::record"]);
3699
			#*/
3723
			
-
 
3724
				}#if end
3700
			
3725
			
3701
			#加上要寫入的元素
3726
			#加上要寫入的元素
3702
			$strs2write[]=$str2write;
3727
			$strs2write[]=$str2write;
3703
		
3728
		
3704
			}#foreach end
3729
			}#foreach end
Line 3747... Line 3772...
3747
			#取得合併好的陣列
3772
			#取得合併好的陣列
3748
			$strs2write=$mergeArray["content"];
3773
			$strs2write=$mergeArray["content"];
3749
		
3774
		
3750
			}#if end
3775
			}#if end
3751
		
3776
		
3752
		#debug
3777
		#如果要 debug
-
 
3778
		if($conf["debug"]==="true"){
-
 
3779
		
3753
		#函式說明:
3780
			#函式說明:
3754
		#撰寫log
3781
			#撰寫log
3755
		#回傳結果:
3782
			#回傳結果:
3756
		#$result["status"],狀態,"true"或"false".
3783
			#$result["status"],狀態,"true"或"false".
3757
		#$result["error"],錯誤訊息陣列.
3784
			#$result["error"],錯誤訊息陣列.
3758
		#$result["function"],當前函式的名稱.
3785
			#$result["function"],當前函式的名稱.
3759
		#$result["argu"],使用的參數.
3786
			#$result["argu"],使用的參數.
3760
		#$result["content"],要寫入log的內容字串.
3787
			#$result["content"],要寫入log的內容字串.
3761
		#必填參數:
3788
			#必填參數:
3762
		#$conf["path"],字串,log檔案的路徑與名稱.
3789
			#$conf["path"],字串,log檔案的路徑與名稱.
3763
		$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
3790
			$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
3764
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
3791
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
3765
		$conf["logs::record"]["content"]="lineNo:".__LINE__." total line to write:".count($strs2write).PHP_EOL;
3792
			$conf["logs::record"]["content"]="lineNo:".__LINE__." total line to write:".count($strs2write).PHP_EOL;
3766
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3793
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3767
		$conf["logs::record"]["fileArgu"]=__FILE__;
3794
			$conf["logs::record"]["fileArgu"]=__FILE__;
3768
		#可省略參數:
3795
			#可省略參數:
3769
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
3796
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
3770
		#$conf["rewrite"]="false";
3797
			#$conf["rewrite"]="false";
3771
		#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
3798
			#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
3772
		#$conf["returnOnly"]="true";
3799
			#$conf["returnOnly"]="true";
3773
		#參考資料:
3800
			#參考資料:
3774
		#無.
3801
			#無.
3775
		#備註:
3802
			#備註:
3776
		#無.
3803
			#無.
3777
		$record=logs::record($conf["logs::record"]);
3804
			$record=logs::record($conf["logs::record"]);
3778
		unset($conf["logs::record"]);
3805
			unset($conf["logs::record"]);
-
 
3806
			
-
 
3807
			}#if end
3779
		
3808
		
3780
		#儲存新zone file每行的內容
3809
		#儲存新zone file每行的內容
3781
		$result["newZoneFileContent"]=$strs2write;
3810
		$result["newZoneFileContent"]=$strs2write;
3782
		
3811
		
3783
		#如果要寫入ZONE檔案
3812
		#如果要寫入ZONE檔案