Subversion Repositories php-qbpwcf

Rev

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

Rev 288 Rev 291
Line 1395... Line 1395...
1395
 
1395
 
1396
		}#function createCertificate end
1396
		}#function createCertificate end
1397
 
1397
 
1398
	/*
1398
	/*
1399
	#函式說明:
1399
	#函式說明:
-
 
1400
	#解析RR檔案中其中的一行內容,回傳結果.
-
 
1401
	#回傳結果:
-
 
1402
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1403
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1404
	#$result["function"],當前執行的函式名稱.
-
 
1405
	#$result["argu"],所使用的參數.
-
 
1406
	#$result["content"],字串陣列,該行RR(DNS記錄)的資訊,key可能有"type","value","content","query","update",也可能為空陣列.
-
 
1407
	#$result["domain"],字串,RR所屬domain.
-
 
1408
	#$result["defaultTTL"],字串,預設的RR更新時間.
-
 
1409
	#$result["comment"],字串,一行的註解.
-
 
1410
	#必填參數:
-
 
1411
	#$conf["line"],字串,要解析的行內容.
-
 
1412
	$conf["line"]="";
-
 
1413
	#可省略參數:
-
 
1414
	#無.
-
 
1415
	#參考資料:
-
 
1416
	#無.
-
 
1417
	#備註:
-
 
1418
	#無.
-
 
1419
	*/
-
 
1420
	public static function parseRRline(&$conf){
-
 
1421
	
-
 
1422
		#初始化要回傳的結果
-
 
1423
		$result=array();
-
 
1424
 
-
 
1425
		#設置當其函數名稱
-
 
1426
		$result["function"]=__FUNCTION__;
-
 
1427
 
-
 
1428
		#如果 $conf 不為陣列
-
 
1429
		if(gettype($conf)!="array"){
-
 
1430
 
-
 
1431
			#設置執行失敗
-
 
1432
			$result["status"]="false";
-
 
1433
 
-
 
1434
			#設置執行錯誤訊息
-
 
1435
			$result["error"][]="\$conf變數須為陣列形態";
-
 
1436
 
-
 
1437
			#如果傳入的參數為 null
-
 
1438
			if($conf==null){
-
 
1439
 
-
 
1440
				#設置執行錯誤訊息
-
 
1441
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
1442
 
-
 
1443
				}#if end
-
 
1444
 
-
 
1445
			#回傳結果
-
 
1446
			return $result;
-
 
1447
 
-
 
1448
			}#if end
-
 
1449
 
-
 
1450
		#取得參數
-
 
1451
		$result["argu"]=$conf;
-
 
1452
 
-
 
1453
		#檢查參數
-
 
1454
		#函式說明:
-
 
1455
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
-
 
1456
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1457
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1458
		#$result["function"],當前執行的函式名稱.
-
 
1459
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
1460
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
1461
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
1462
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
1463
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
1464
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
1465
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
1466
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
1467
		#必填寫的參數:
-
 
1468
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
1469
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
1470
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
1471
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("line");
-
 
1472
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
-
 
1473
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
-
 
1474
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
1475
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
1476
		#可以省略的參數:
-
 
1477
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
1478
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
-
 
1479
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
-
 
1480
		#$conf["skipableVariableCanNotBeEmpty"]=array();
-
 
1481
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
1482
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("writeNow","debug","multiThread");
-
 
1483
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
1484
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
-
 
1485
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
1486
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false","false");
-
 
1487
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
1488
		#$conf["arrayCountEqualCheck"][]=array();
-
 
1489
		#參考資料來源:
-
 
1490
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
1491
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
1492
		unset($conf["variableCheck::checkArguments"]);
-
 
1493
 
-
 
1494
		#如果檢查失敗
-
 
1495
		if($checkArguments["status"]==="false"){
-
 
1496
 
-
 
1497
			#設置錯誤識別
-
 
1498
			$result["status"]="false";
-
 
1499
 
-
 
1500
			#設置錯誤訊息
-
 
1501
			$result["error"]=$checkArguments;
-
 
1502
 
-
 
1503
			#回傳結果
-
 
1504
			return $result;
-
 
1505
 
-
 
1506
			}#if end
-
 
1507
 
-
 
1508
		#如果檢查不通過
-
 
1509
		if($checkArguments["passed"]==="false"){
-
 
1510
 
-
 
1511
			#設置錯誤識別
-
 
1512
			$result["status"]="false";
-
 
1513
 
-
 
1514
			#設置錯誤訊息
-
 
1515
			$result["error"]=$checkArguments;
-
 
1516
 
-
 
1517
			#回傳結果
-
 
1518
			return $result;
-
 
1519
 
-
 
1520
			}#if end
-
 
1521
		
-
 
1522
		#初始化要回傳的content
-
 
1523
		$result["content"]=array();
-
 
1524
		
-
 
1525
		#另存一份要處理的RR
-
 
1526
		$unFormatStr=$conf["line"];
-
 
1527
		
-
 
1528
		#初始化該行的資訊陣列
-
 
1529
		$info=array();
-
 
1530
	
-
 
1531
		#尋找";"開頭的內容,亦即整行都是註解.
-
 
1532
		#函式說明:
-
 
1533
		#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1534
		#回傳結果:
-
 
1535
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1536
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1537
		#$result["function"],當前執行的函式名稱.
-
 
1538
		#$result["argu"],所使用的參數.
-
 
1539
		#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1540
		#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1541
		#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1542
		#必填參數:
-
 
1543
		#$conf["input"],字串,要檢查的字串.
-
 
1544
		$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1545
		#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1546
		$conf["search::findSpecifyStrFormat"]["format"]=";\${else}";
-
 
1547
		#可省略參數:
-
 
1548
		#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1549
		#$conf["varEqual"]=array(null,"found");
-
 
1550
		#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1551
		#$conf["varCon"]=array("no_tail"=>" not");
-
 
1552
		#參考資料:
-
 
1553
		#無.
-
 
1554
		#備註:
-
 
1555
		#無.
-
 
1556
		$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1557
		unset($conf["search::findSpecifyStrFormat"]);
-
 
1558
	
-
 
1559
		#如果執行異常
-
 
1560
		if($findSpecifyStrFormat["status"]==="false"){
-
 
1561
		
-
 
1562
			#設置錯誤識別
-
 
1563
			$result["status"]="false";
-
 
1564
 
-
 
1565
			#設置錯誤訊息
-
 
1566
			$result["error"]=$findSpecifyStrFormat;
-
 
1567
 
-
 
1568
			#回傳結果
-
 
1569
			return $result;
-
 
1570
		
-
 
1571
			}#if end
-
 
1572
			
-
 
1573
		#如果有找到符合格式的內容
-
 
1574
		if($findSpecifyStrFormat["found"]==="true"){
-
 
1575
		
-
 
1576
			#儲存為註解
-
 
1577
			$result["comment"]=$unFormatStr;
-
 
1578
			
-
 
1579
			#設置執行正常
-
 
1580
			$result["status"]="true";
-
 
1581
			
-
 
1582
			#回傳結果
-
 
1583
			return $result;
-
 
1584
		
-
 
1585
			}#if end
-
 
1586
	
-
 
1587
		#函式說明:
-
 
1588
		#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1589
		#回傳結果:
-
 
1590
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1591
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1592
		#$result["function"],當前執行的函式名稱.
-
 
1593
		#$result["argu"],所使用的參數.
-
 
1594
		#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1595
		#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1596
		#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1597
		#必填參數:
-
 
1598
		#$conf["input"],字串,要檢查的字串.
-
 
1599
		$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1600
		#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1601
		$conf["search::findSpecifyStrFormat"]["format"]="\$ORIGIN\${else}";
-
 
1602
		#可省略參數:
-
 
1603
		#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1604
		#$conf["varEqual"]=array(null,"found");
-
 
1605
		#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1606
		#$conf["varCon"]=array("no_tail"=>" not");
-
 
1607
		#參考資料:
-
 
1608
		#無.
-
 
1609
		#備註:
-
 
1610
		#無.
-
 
1611
		$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1612
		unset($conf["search::findSpecifyStrFormat"]);
-
 
1613
	
-
 
1614
		#如果執行異常
-
 
1615
		if($findSpecifyStrFormat["status"]==="false"){
-
 
1616
		
-
 
1617
			#設置錯誤識別
-
 
1618
			$result["status"]="false";
-
 
1619
 
-
 
1620
			#設置錯誤訊息
-
 
1621
			$result["error"]=$findSpecifyStrFormat;
-
 
1622
 
-
 
1623
			#回傳結果
-
 
1624
			return $result;
-
 
1625
		
-
 
1626
			}#if end
-
 
1627
			
-
 
1628
		#如果有找到符合格式的內容
-
 
1629
		if($findSpecifyStrFormat["found"]==="true"){
-
 
1630
		
-
 
1631
			#設置 type 的數值
-
 
1632
			$info["type"]="\$ORIGIN";
-
 
1633
		
-
 
1634
			#取得後面待處理的內容
-
 
1635
			$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
1636
		
-
 
1637
			#函式說明:
-
 
1638
			#將字串開頭的特定關鍵字移除.
-
 
1639
			#回傳結果:
-
 
1640
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1641
			#$result["error"],錯誤訊息陣列.
-
 
1642
			#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
1643
			#$result["function"],當前執行的函數名稱.
-
 
1644
			#$result["argu"],使用的參數.
-
 
1645
			#$result["content"],處理好的的字串內容.
-
 
1646
			#$result["deleted"],被移除的內容.
-
 
1647
			#必填參數:
-
 
1648
			#$conf["stringIn"],字串,要處理的字串.
-
 
1649
			$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
1650
			#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
1651
			$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t");
-
 
1652
			#可省略參數:
-
 
1653
			#無.
-
 
1654
			#參考資料:
-
 
1655
			#無.
-
 
1656
			#備註:
-
 
1657
			#無.
-
 
1658
			$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
1659
			unset($conf["stringProcess::delHeadStr"]);
-
 
1660
				
-
 
1661
			#如果執行異常
-
 
1662
			if($delHeadStr["status"]==="false"){
-
 
1663
			
-
 
1664
				#設置錯誤識別
-
 
1665
				$result["status"]="false";
-
 
1666
 
-
 
1667
				#設置錯誤訊息
-
 
1668
				$result["error"]=$delHeadStr;
-
 
1669
 
-
 
1670
				#回傳結果
-
 
1671
				return $result;
-
 
1672
			
-
 
1673
				}#if end
-
 
1674
				
-
 
1675
			#如果有移除開頭的字串
-
 
1676
			if($delHeadStr["founded"]==="true"){
-
 
1677
			
-
 
1678
				#取得處理後的結果
-
 
1679
				$unFormatStr=$delHeadStr["content"];
-
 
1680
			
-
 
1681
				}#if end
-
 
1682
		
-
 
1683
			#解析 $ORIGN 的數值, 以及後面是否有註解...
-
 
1684
			#函式說明:
-
 
1685
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1686
			#回傳結果:
-
 
1687
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1688
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1689
			#$result["function"],當前執行的函式名稱.
-
 
1690
			#$result["argu"],所使用的參數.
-
 
1691
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1692
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1693
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1694
			#必填參數:
-
 
1695
			#$conf["input"],字串,要檢查的字串.
-
 
1696
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1697
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1698
			$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
1699
			#可省略參數:
-
 
1700
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1701
			#$conf["varEqual"]=array(null,"found");
-
 
1702
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1703
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
1704
			#參考資料:
-
 
1705
			#無.
-
 
1706
			#備註:
-
 
1707
			#無.
-
 
1708
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1709
			unset($conf["search::findSpecifyStrFormat"]);
-
 
1710
		
-
 
1711
			#如果執行異常
-
 
1712
			if($findSpecifyStrFormat["status"]==="false"){
-
 
1713
			
-
 
1714
				#設置錯誤識別
-
 
1715
				$result["status"]="false";
-
 
1716
 
-
 
1717
				#設置錯誤訊息
-
 
1718
				$result["error"]=$findSpecifyStrFormat;
-
 
1719
 
-
 
1720
				#回傳結果
-
 
1721
				return $result;
-
 
1722
			
-
 
1723
				}#if end
-
 
1724
				
-
 
1725
			#如果有數值跟註解
-
 
1726
			if($findSpecifyStrFormat["found"]==="true"){
-
 
1727
			
-
 
1728
				#儲存數值
-
 
1729
				$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
1730
			
-
 
1731
				#儲存zone domain
-
 
1732
				$result["domain"]=trim($info["value"]);
-
 
1733
			
-
 
1734
				#儲存註解
-
 
1735
				$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
1736
			
-
 
1737
				#儲存 RR 的記錄
-
 
1738
				$result["content"]=$info;
-
 
1739
				
-
 
1740
				#設置執行正常
-
 
1741
				$result["status"]="true";
-
 
1742
				
-
 
1743
				#回傳結果
-
 
1744
				return $result;
-
 
1745
				
-
 
1746
				}#if end
-
 
1747
				
-
 
1748
			#執行到這邊代表剩下的內容都是 value
-
 
1749
			$info["value"]=$unFormatStr;
-
 
1750
			
-
 
1751
			#儲存zone domain
-
 
1752
			$result["domain"]=trim($info["value"]);
-
 
1753
		
-
 
1754
			#儲存 RR 的記錄
-
 
1755
			$result["content"]=$info;
-
 
1756
			
-
 
1757
			#設置執行正常
-
 
1758
			$result["status"]="true";
-
 
1759
			
-
 
1760
			#回傳結果
-
 
1761
			return $result;
-
 
1762
		
-
 
1763
			}#if end
-
 
1764
			
-
 
1765
		#檢查是否為 $TTL 開頭
-
 
1766
		#函式說明:
-
 
1767
		#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1768
		#回傳結果:
-
 
1769
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1770
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1771
		#$result["function"],當前執行的函式名稱.
-
 
1772
		#$result["argu"],所使用的參數.
-
 
1773
		#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1774
		#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1775
		#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1776
		#必填參數:
-
 
1777
		#$conf["input"],字串,要檢查的字串.
-
 
1778
		$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1779
		#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1780
		$conf["search::findSpecifyStrFormat"]["format"]="\$TTL\${else}";
-
 
1781
		#可省略參數:
-
 
1782
		#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1783
		#$conf["varEqual"]=array(null,"found");
-
 
1784
		#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1785
		#$conf["varCon"]=array("no_tail"=>" not");
-
 
1786
		#參考資料:
-
 
1787
		#無.
-
 
1788
		#備註:
-
 
1789
		#無.
-
 
1790
		$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1791
		unset($conf["search::findSpecifyStrFormat"]);
-
 
1792
	
-
 
1793
		#如果執行異常
-
 
1794
		if($findSpecifyStrFormat["status"]==="false"){
-
 
1795
		
-
 
1796
			#設置錯誤識別
-
 
1797
			$result["status"]="false";
-
 
1798
 
-
 
1799
			#設置錯誤訊息
-
 
1800
			$result["error"]=$findSpecifyStrFormat;
-
 
1801
 
-
 
1802
			#回傳結果
-
 
1803
			return $result;
-
 
1804
		
-
 
1805
			}#if end
-
 
1806
			
-
 
1807
		#如果有找到符合格式的內容
-
 
1808
		if($findSpecifyStrFormat["found"]==="true"){
-
 
1809
		
-
 
1810
			#設置 type 的數值
-
 
1811
			$info["type"]="\$TTL";
-
 
1812
			
-
 
1813
			#取得後面待處理的內容
-
 
1814
			$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
1815
		
-
 
1816
			#函式說明:
-
 
1817
			#將字串開頭的特定關鍵字移除.
-
 
1818
			#回傳結果:
-
 
1819
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1820
			#$result["error"],錯誤訊息陣列.
-
 
1821
			#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
1822
			#$result["function"],當前執行的函數名稱.
-
 
1823
			#$result["argu"],使用的參數.
-
 
1824
			#$result["content"],處理好的的字串內容.
-
 
1825
			#$result["deleted"],被移除的內容.
-
 
1826
			#必填參數:
-
 
1827
			#$conf["stringIn"],字串,要處理的字串.
-
 
1828
			$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
1829
			#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
1830
			$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t");
-
 
1831
			#可省略參數:
-
 
1832
			#無.
-
 
1833
			#參考資料:
-
 
1834
			#無.
-
 
1835
			#備註:
-
 
1836
			#無.
-
 
1837
			$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
1838
			unset($conf["stringProcess::delHeadStr"]);
-
 
1839
				
-
 
1840
			#如果執行異常
-
 
1841
			if($delHeadStr["status"]==="false"){
-
 
1842
			
-
 
1843
				#設置錯誤識別
-
 
1844
				$result["status"]="false";
-
 
1845
 
-
 
1846
				#設置錯誤訊息
-
 
1847
				$result["error"]=$delHeadStr;
-
 
1848
 
-
 
1849
				#回傳結果
-
 
1850
				return $result;
-
 
1851
			
-
 
1852
				}#if end
-
 
1853
				
-
 
1854
			#如果有移除開頭的字串
-
 
1855
			if($delHeadStr["founded"]==="true"){
-
 
1856
			
-
 
1857
				#取得處理後的結果
-
 
1858
				$unFormatStr=$delHeadStr["content"];
-
 
1859
			
-
 
1860
				}#if end
-
 
1861
			
-
 
1862
			#解析 $TTL 的數值, 以及後面是否有註解...
-
 
1863
			#函式說明:
-
 
1864
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1865
			#回傳結果:
-
 
1866
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1867
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1868
			#$result["function"],當前執行的函式名稱.
-
 
1869
			#$result["argu"],所使用的參數.
-
 
1870
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1871
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1872
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1873
			#必填參數:
-
 
1874
			#$conf["input"],字串,要檢查的字串.
-
 
1875
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1876
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1877
			$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
1878
			#可省略參數:
-
 
1879
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1880
			#$conf["varEqual"]=array(null,"found");
-
 
1881
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1882
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
1883
			#參考資料:
-
 
1884
			#無.
-
 
1885
			#備註:
-
 
1886
			#無.
-
 
1887
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1888
			unset($conf["search::findSpecifyStrFormat"]);
-
 
1889
		
-
 
1890
			#如果執行異常
-
 
1891
			if($findSpecifyStrFormat["status"]==="false"){
-
 
1892
			
-
 
1893
				#設置錯誤識別
-
 
1894
				$result["status"]="false";
-
 
1895
 
-
 
1896
				#設置錯誤訊息
-
 
1897
				$result["error"]=$findSpecifyStrFormat;
-
 
1898
 
-
 
1899
				#回傳結果
-
 
1900
				return $result;
-
 
1901
			
-
 
1902
				}#if end
-
 
1903
				
-
 
1904
			#如果有數值跟註解
-
 
1905
			if($findSpecifyStrFormat["found"]==="true"){
-
 
1906
			
-
 
1907
				#儲存數值
-
 
1908
				$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
1909
			
-
 
1910
				#儲存註解
-
 
1911
				$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
1912
			
-
 
1913
				#儲存預設的 TTL
-
 
1914
				$result["defaultTTL"]=trim($info["value"]);
-
 
1915
			
-
 
1916
				#儲存 RR 的記錄
-
 
1917
				$result["content"]=$info;
-
 
1918
				
-
 
1919
				#設置執行正常
-
 
1920
				$result["status"]="true";
-
 
1921
				
-
 
1922
				#回傳結果
-
 
1923
				return $result;
-
 
1924
				
-
 
1925
				}#if end
-
 
1926
				
-
 
1927
			#執行到這邊代表剩下的內容都是 value
-
 
1928
			$info["value"]=$unFormatStr;
-
 
1929
			
-
 
1930
			#儲存預設的 TTL
-
 
1931
			$result["defaultTTL"]=trim($info["value"]);
-
 
1932
			
-
 
1933
			#儲存 RR 的記錄
-
 
1934
			$result["content"]=$info;
-
 
1935
			
-
 
1936
			#設置執行正常
-
 
1937
			$result["status"]="true";
-
 
1938
			
-
 
1939
			#回傳結果
-
 
1940
			return $result;
-
 
1941
		
-
 
1942
			}#if end
-
 
1943
		
-
 
1944
		#如果 內容為 query updatTime IN type value;comment,或value含有(或",則需要將其符號與後面的內容先暫時拆開
-
 
1945
		
-
 
1946
		#函式說明:
-
 
1947
		#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1948
		#回傳結果:
-
 
1949
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1950
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1951
		#$result["function"],當前執行的函式名稱.
-
 
1952
		#$result["argu"],所使用的參數.
-
 
1953
		#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1954
		#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1955
		#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
1956
		#必填參數:
-
 
1957
		#$conf["input"],字串,要檢查的字串.
-
 
1958
		$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1959
		#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1960
		$conf["search::findSpecifyStrFormat"]["format"]="\${left}(\${right}";
-
 
1961
		#可省略參數:
-
 
1962
		#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1963
		#$conf["varEqual"]=array(null,"found");
-
 
1964
		#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1965
		#$conf["varCon"]=array("no_tail"=>" not");
-
 
1966
		#參考資料:
-
 
1967
		#無.
-
 
1968
		#備註:
-
 
1969
		#無.
-
 
1970
		$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1971
		unset($conf["search::findSpecifyStrFormat"]);
-
 
1972
	
-
 
1973
		#如果執行異常
-
 
1974
		if($findSpecifyStrFormat["status"]==="false"){
-
 
1975
		
-
 
1976
			#設置錯誤識別
-
 
1977
			$result["status"]="false";
-
 
1978
 
-
 
1979
			#設置錯誤訊息
-
 
1980
			$result["error"]=$findSpecifyStrFormat;
-
 
1981
 
-
 
1982
			#回傳結果
-
 
1983
			return $result;
-
 
1984
	
-
 
1985
			}#if end
-
 
1986
			
-
 
1987
		#如果存在"("
-
 
1988
		if($findSpecifyStrFormat["found"]==="true"){
-
 
1989
		
-
 
1990
			#取得無"("的內容
-
 
1991
			$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
1992
			
-
 
1993
			#取得拆下來的含開頭"("內容
-
 
1994
			$unFormatStr2add="(".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
1995
			
-
 
1996
			}#if end
-
 
1997
		
-
 
1998
		#反之
-
 
1999
		else{
-
 
2000
		
-
 
2001
			#函式說明:
-
 
2002
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2003
			#回傳結果:
-
 
2004
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2005
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2006
			#$result["function"],當前執行的函式名稱.
-
 
2007
			#$result["argu"],所使用的參數.
-
 
2008
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2009
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2010
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2011
			#必填參數:
-
 
2012
			#$conf["input"],字串,要檢查的字串.
-
 
2013
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2014
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2015
			$conf["search::findSpecifyStrFormat"]["format"]="\${left}\"\${right}";
-
 
2016
			#可省略參數:
-
 
2017
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2018
			#$conf["varEqual"]=array(null,"found");
-
 
2019
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2020
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
2021
			#參考資料:
-
 
2022
			#無.
-
 
2023
			#備註:
-
 
2024
			#無.
-
 
2025
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2026
			unset($conf["search::findSpecifyStrFormat"]);
-
 
2027
		
-
 
2028
			#如果執行異常
-
 
2029
			if($findSpecifyStrFormat["status"]==="false"){
-
 
2030
			
-
 
2031
				#設置錯誤識別
-
 
2032
				$result["status"]="false";
-
 
2033
 
-
 
2034
				#設置錯誤訊息
-
 
2035
				$result["error"]=$findSpecifyStrFormat;
-
 
2036
 
-
 
2037
				#回傳結果
-
 
2038
				return $result;
-
 
2039
		
-
 
2040
				}#if end
-
 
2041
				
-
 
2042
			#如果存在"
-
 
2043
			if($findSpecifyStrFormat["found"]==="true"){
-
 
2044
			
-
 
2045
				#取得無"的內容
-
 
2046
				$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2047
				
-
 
2048
				#取得拆下來的含開頭"內容
-
 
2049
				$unFormatStr2add="\"".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2050
				
-
 
2051
				}#if end
-
 
2052
				
-
 
2053
			#反之
-
 
2054
			else{
-
 
2055
			
-
 
2056
				#函式說明:
-
 
2057
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2058
				#回傳結果:
-
 
2059
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2060
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2061
				#$result["function"],當前執行的函式名稱.
-
 
2062
				#$result["argu"],所使用的參數.
-
 
2063
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2064
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2065
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2066
				#必填參數:
-
 
2067
				#$conf["input"],字串,要檢查的字串.
-
 
2068
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2069
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2070
				$conf["search::findSpecifyStrFormat"]["format"]="\${left};\${right}";
-
 
2071
				#可省略參數:
-
 
2072
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2073
				#$conf["varEqual"]=array(null,"found");
-
 
2074
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2075
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
2076
				#參考資料:
-
 
2077
				#無.
-
 
2078
				#備註:
-
 
2079
				#無.
-
 
2080
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2081
				unset($conf["search::findSpecifyStrFormat"]);
-
 
2082
			
-
 
2083
				#如果執行異常
-
 
2084
				if($findSpecifyStrFormat["status"]==="false"){
-
 
2085
				
-
 
2086
					#設置錯誤識別
-
 
2087
					$result["status"]="false";
-
 
2088
 
-
 
2089
					#設置錯誤訊息
-
 
2090
					$result["error"]=$findSpecifyStrFormat;
-
 
2091
 
-
 
2092
					#回傳結果
-
 
2093
					return $result;
-
 
2094
			
-
 
2095
					}#if end
-
 
2096
					
-
 
2097
				#如果存在";"
-
 
2098
				if($findSpecifyStrFormat["found"]==="true"){
-
 
2099
				
-
 
2100
					#取得無";"的內容
-
 
2101
					$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2102
					
-
 
2103
					#取得拆下來的含開頭";"內容
-
 
2104
					$unFormatStr2add=";".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2105
					
-
 
2106
					}#if end
-
 
2107
			
-
 
2108
				}#else end
-
 
2109
		
-
 
2110
			}#else end
-
 
2111
		
-
 
2112
		#檢查是否為 @ 開頭
-
 
2113
		#函式說明:
-
 
2114
		#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2115
		#回傳結果:
-
 
2116
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2117
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2118
		#$result["function"],當前執行的函式名稱.
-
 
2119
		#$result["argu"],所使用的參數.
-
 
2120
		#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2121
		#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2122
		#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
2123
		#必填參數:
-
 
2124
		#$conf["input"],字串,要檢查的字串.
-
 
2125
		$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2126
		#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2127
		$conf["search::findSpecifyStrFormat"]["format"]="@\${else}";
-
 
2128
		#可省略參數:
-
 
2129
		#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2130
		#$conf["varEqual"]=array(null,"found");
-
 
2131
		#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2132
		#$conf["varCon"]=array("no_tail"=>" not");
-
 
2133
		#參考資料:
-
 
2134
		#無.
-
 
2135
		#備註:
-
 
2136
		#無.
-
 
2137
		$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2138
		unset($conf["search::findSpecifyStrFormat"]);
-
 
2139
	
-
 
2140
		#如果執行異常
-
 
2141
		if($findSpecifyStrFormat["status"]==="false"){
-
 
2142
		
-
 
2143
			#設置錯誤識別
-
 
2144
			$result["status"]="false";
-
 
2145
 
-
 
2146
			#設置錯誤訊息
-
 
2147
			$result["error"]=$findSpecifyStrFormat;
-
 
2148
 
-
 
2149
			#回傳結果
-
 
2150
			return $result;
-
 
2151
		
-
 
2152
			}#if end
-
 
2153
			
-
 
2154
		#如果有找到符合格式的內容
-
 
2155
		if($findSpecifyStrFormat["found"]==="true"){
-
 
2156
		
-
 
2157
			#設置 query 的數值
-
 
2158
			$info["query"]="@";
-
 
2159
			
-
 
2160
			#取得後面待處理的內容
-
 
2161
			$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
2162
			
-
 
2163
			#函式說明:
-
 
2164
			#將字串開頭的特定關鍵字移除.
-
 
2165
			#回傳結果:
-
 
2166
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2167
			#$result["error"],錯誤訊息陣列.
-
 
2168
			#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2169
			#$result["function"],當前執行的函數名稱.
-
 
2170
			#$result["argu"],使用的參數.
-
 
2171
			#$result["content"],處理好的的字串內容.
-
 
2172
			#$result["deleted"],被移除的內容.
-
 
2173
			#必填參數:
-
 
2174
			#$conf["stringIn"],字串,要處理的字串.
-
 
2175
			$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2176
			#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2177
			$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t");
-
 
2178
			#可省略參數:
-
 
2179
			#無.
-
 
2180
			#參考資料:
-
 
2181
			#無.
-
 
2182
			#備註:
-
 
2183
			#無.
-
 
2184
			$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2185
			unset($conf["stringProcess::delHeadStr"]);
-
 
2186
			
-
 
2187
			#如果執行異常
-
 
2188
			if($delHeadStr["status"]==="false"){
-
 
2189
			
-
 
2190
				#設置錯誤識別
-
 
2191
				$result["status"]="false";
-
 
2192
 
-
 
2193
				#設置錯誤訊息
-
 
2194
				$result["error"]=$delHeadStr;
-
 
2195
 
-
 
2196
				#回傳結果
-
 
2197
				return $result;
-
 
2198
			
-
 
2199
				}#if end
-
 
2200
				
-
 
2201
			#如果有移除開頭的字串
-
 
2202
			if($delHeadStr["founded"]==="true"){
-
 
2203
			
-
 
2204
				#取得處理後的結果 update time..IN..type...value;comment
-
 
2205
				$unFormatStr=$delHeadStr["content"];
-
 
2206
			
-
 
2207
				}#if end
-
 
2208
				
-
 
2209
			#debug
-
 
2210
			#var_dump(__LINE__,$delHeadStr);
-
 
2211
			
-
 
2212
			}#if end
-
 
2213
		
-
 
2214
		#反之
-
 
2215
		else{
-
 
2216
			
-
 
2217
			#執行到這邊,代表 query 為一非 @ 的字串
-
 
2218
			#函式說明:
-
 
2219
			#將指令字串解析成陣列,方便給予 external::callShell 使用
-
 
2220
			#回傳結果:
-
 
2221
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2222
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2223
			#$result["function"],當前執行的函式名稱.
-
 
2224
			#$result["content"],解析好的指令陣列.
-
 
2225
			#$result["cmd"],解析好的指令名稱.
-
 
2226
			#$result["argus"],解析好的參數陣列.
-
 
2227
			#$result["argu"],所使用的參數.
-
 
2228
			#必填參數
-
 
2229
			#$conf["cmdStr"],字串,要解析的指令字串
-
 
2230
			$conf["stringProcess::parseCmdString"]["cmdStr"]=$unFormatStr;
-
 
2231
			#可省略參數:
-
 
2232
			#無.
-
 
2233
			#參考資料:
-
 
2234
			#無.
-
 
2235
			#備註:
-
 
2236
			#無.
-
 
2237
			$parseCmdString=cmd::parseCmdString($conf["stringProcess::parseCmdString"]);
-
 
2238
			unset($conf["stringProcess::parseCmdString"]);
-
 
2239
			
-
 
2240
			#如果執行失敗
-
 
2241
			if($parseCmdString["status"]==="false"){
-
 
2242
			
-
 
2243
				#設置錯誤識別
-
 
2244
				$result["status"]="false";
-
 
2245
 
-
 
2246
				#設置錯誤訊息
-
 
2247
				$result["error"]=$parseCmdString;
-
 
2248
				
-
 
2249
				#debug
-
 
2250
				#$result["errorProcessLine"]=$line;
-
 
2251
 
-
 
2252
				#回傳結果
-
 
2253
				return $result;
-
 
2254
			
-
 
2255
				}#if end
-
 
2256
				
-
 
2257
			#取得 query 的內容
-
 
2258
			$info["query"]=$parseCmdString["content"][0];
-
 
2259
			
-
 
2260
			#剔除 query以及後面的" "跟\t
-
 
2261
			#函式說明:
-
 
2262
			#將字串開頭的特定關鍵字移除.
-
 
2263
			#回傳結果:
-
 
2264
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2265
			#$result["error"],錯誤訊息陣列.
-
 
2266
			#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2267
			#$result["function"],當前執行的函數名稱.
-
 
2268
			#$result["argu"],使用的參數.
-
 
2269
			#$result["content"],處理好的的字串內容.
-
 
2270
			#$result["deleted"],被移除的內容.
-
 
2271
			#必填參數:
-
 
2272
			#$conf["stringIn"],字串,要處理的字串.
-
 
2273
			$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2274
			#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2275
			$conf["stringProcess::delHeadStr"]["headStr"]=array($info["query"]," ","\t");
-
 
2276
			#可省略參數:
-
 
2277
			#無.
-
 
2278
			#參考資料:
-
 
2279
			#無.
-
 
2280
			#備註:
-
 
2281
			#無.
-
 
2282
			$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2283
			unset($conf["stringProcess::delHeadStr"]);
-
 
2284
			
-
 
2285
			#如果執行異常
-
 
2286
			if($delHeadStr["status"]==="false"){
-
 
2287
			
-
 
2288
				#設置錯誤識別
-
 
2289
				$result["status"]="false";
-
 
2290
 
-
 
2291
				#設置錯誤訊息
-
 
2292
				$result["error"]=$delHeadStr;
-
 
2293
 
-
 
2294
				#回傳結果
-
 
2295
				return $result;
-
 
2296
			
-
 
2297
				}#if end
-
 
2298
				
-
 
2299
			#取得update time..IN..type...value;comment
-
 
2300
			$unFormatStr=$delHeadStr["content"];
-
 
2301
		
-
 
2302
			}#else end
-
 
2303
		
-
 
2304
		#無窮迴圈
-
 
2305
		while(true){
-
 
2306
			
-
 
2307
			#解析 updateTime..IN..type...value...comment
-
 
2308
		
-
 
2309
			#判斷是否無 update time
-
 
2310
			
-
 
2311
			#函式說明:
-
 
2312
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2313
			#回傳結果:
-
 
2314
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2315
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2316
			#$result["function"],當前執行的函式名稱.
-
 
2317
			#$result["argu"],所使用的參數.
-
 
2318
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2319
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2320
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
2321
			#必填參數:
-
 
2322
			#$conf["input"],字串,要檢查的字串.
-
 
2323
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2324
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2325
			$conf["search::findSpecifyStrFormat"]["format"]="IN\${else}";
-
 
2326
			#可省略參數:
-
 
2327
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2328
			#$conf["varEqual"]=array(null,"found");
-
 
2329
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2330
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
2331
			#參考資料:
-
 
2332
			#無.
-
 
2333
			#備註:
-
 
2334
			#無.
-
 
2335
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2336
			unset($conf["search::findSpecifyStrFormat"]);
-
 
2337
		
-
 
2338
			#如果執行異常
-
 
2339
			if($findSpecifyStrFormat["status"]==="false"){
-
 
2340
			
-
 
2341
				#設置錯誤識別
-
 
2342
				$result["status"]="false";
-
 
2343
 
-
 
2344
				#設置錯誤訊息
-
 
2345
				$result["error"]=$findSpecifyStrFormat;
-
 
2346
 
-
 
2347
				#回傳結果
-
 
2348
				return $result;
-
 
2349
			
-
 
2350
				}#if end
-
 
2351
				
-
 
2352
			#如果有找到符合格式的內容
-
 
2353
			if($findSpecifyStrFormat["found"]==="true"){
-
 
2354
			
-
 
2355
				#代表沒有 update time 欄位,因此儲存預設的TTL
-
 
2356
				$info["update"]=&$result["defaultTTL"];
-
 
2357
				
-
 
2358
				#取得剩下的 ...type...value;comment
-
 
2359
				$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
2360
				
-
 
2361
				#設置該行沒有指定 update time
-
 
2362
				$noUpdateTime="true";
-
 
2363
				
-
 
2364
				}#if end
-
 
2365
				
-
 
2366
			#反之
-
 
2367
			else{
-
 
2368
			
-
 
2369
				#設置該行有指定 update time
-
 
2370
				$noUpdateTime="false";
-
 
2371
			
-
 
2372
				#如果有指定 update time
-
 
2373
				if($noUpdateTime==="false"){
-
 
2374
				
-
 
2375
					#要來解析 update time
-
 
2376
					#函式說明:
-
 
2377
					#將字串進行解析,變成多個參數.
-
 
2378
					#回傳結果:
-
 
2379
					#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
-
 
2380
					#$result["function"],當前執行的函式內容.
-
 
2381
					#$result["error"],錯誤訊息陣列.
-
 
2382
					#$result["content"],參數陣列.
-
 
2383
					#$result["count"],總共有幾個參數.
-
 
2384
					#必填參數:
-
 
2385
					#$conf["input"],字串,要解析成參數的字串.
-
 
2386
					$conf["stringProcess::parse"]["input"]=$unFormatStr;
-
 
2387
					#可省略參數:
-
 
2388
					#無.
-
 
2389
					#參考資料:
-
 
2390
					#無.
-
 
2391
					#備註:
-
 
2392
					#無.
-
 
2393
					$parse=stringProcess::parse($conf["stringProcess::parse"]);
-
 
2394
					unset($conf["stringProcess::parse"]);
-
 
2395
					
-
 
2396
					#如果執行異常
-
 
2397
					if($parse["status"]==="false"){
-
 
2398
					
-
 
2399
						#設置錯誤識別
-
 
2400
						$result["status"]="false";
-
 
2401
 
-
 
2402
						#設置錯誤訊息
-
 
2403
						$result["error"]=$parse;
-
 
2404
 
-
 
2405
						#回傳結果
-
 
2406
						return $result;
-
 
2407
						
-
 
2408
						}#if end
-
 
2409
						
-
 
2410
					#取得更新時間
-
 
2411
					$info["update"]=$parse["content"][0];
-
 
2412
				
-
 
2413
					#取得 update time 後面的內容
-
 
2414
					#函式說明:
-
 
2415
					#將字串開頭的特定關鍵字移除.
-
 
2416
					#回傳結果:
-
 
2417
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2418
					#$result["error"],錯誤訊息陣列.
-
 
2419
					#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2420
					#$result["function"],當前執行的函數名稱.
-
 
2421
					#$result["argu"],使用的參數.
-
 
2422
					#$result["content"],處理好的的字串內容.
-
 
2423
					#$result["deleted"],被移除的內容.
-
 
2424
					#必填參數:
-
 
2425
					#$conf["stringIn"],字串,要處理的字串.
-
 
2426
					$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2427
					#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2428
					$conf["stringProcess::delHeadStr"]["headStr"]=array($info["update"]);
-
 
2429
					#可省略參數:
-
 
2430
					#無.
-
 
2431
					#參考資料:
-
 
2432
					#無.
-
 
2433
					#備註:
-
 
2434
					#無.
-
 
2435
					$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2436
					unset($conf["stringProcess::delHeadStr"]);
-
 
2437
					
-
 
2438
					#如果執行異常
-
 
2439
					if($delHeadStr["status"]==="false"){
-
 
2440
					
-
 
2441
						#設置錯誤識別
-
 
2442
						$result["status"]="false";
-
 
2443
 
-
 
2444
						#設置錯誤訊息
-
 
2445
						$result["error"]=$delHeadStr;
-
 
2446
 
-
 
2447
						#回傳結果
-
 
2448
						return $result;
-
 
2449
					
-
 
2450
						}#if end
-
 
2451
					
-
 
2452
					#取得...IN...value;comment
-
 
2453
					$unFormatStr=$delHeadStr["content"];
-
 
2454
				
-
 
2455
					}#if end
-
 
2456
				
-
 
2457
				#取得 ...IN... 後面的內容
-
 
2458
				#函式說明:
-
 
2459
				#將字串開頭的特定關鍵字移除.
-
 
2460
				#回傳結果:
-
 
2461
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2462
				#$result["error"],錯誤訊息陣列.
-
 
2463
				#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2464
				#$result["function"],當前執行的函數名稱.
-
 
2465
				#$result["argu"],使用的參數.
-
 
2466
				#$result["content"],處理好的的字串內容.
-
 
2467
				#$result["deleted"],被移除的內容.
-
 
2468
				#必填參數:
-
 
2469
				#$conf["stringIn"],字串,要處理的字串.
-
 
2470
				$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2471
				#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2472
				$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t","IN");
-
 
2473
				#可省略參數:
-
 
2474
				#無.
-
 
2475
				#參考資料:
-
 
2476
				#無.
-
 
2477
				#備註:
-
 
2478
				#無.
-
 
2479
				$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2480
				unset($conf["stringProcess::delHeadStr"]);
-
 
2481
				
-
 
2482
				#如果執行異常
-
 
2483
				if($delHeadStr["status"]==="false"){
-
 
2484
				
-
 
2485
					#設置錯誤識別
-
 
2486
					$result["status"]="false";
-
 
2487
 
-
 
2488
					#設置錯誤訊息
-
 
2489
					$result["error"]=$delHeadStr;
-
 
2490
 
-
 
2491
					#回傳結果
-
 
2492
					return $result;
-
 
2493
				
-
 
2494
					}#if end
-
 
2495
				
-
 
2496
				#取得IN...value;comment
-
 
2497
				$unFormatStr=$delHeadStr["content"];
-
 
2498
				
-
 
2499
				}#else end
-
 
2500
			
-
 
2501
			#解析 type...value;comment
-
 
2502
			#函式說明:
-
 
2503
			#將字串進行解析,變成多個參數.
-
 
2504
			#回傳結果:
-
 
2505
			#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
-
 
2506
			#$result["function"],當前執行的函式內容.
-
 
2507
			#$result["error"],錯誤訊息陣列.
-
 
2508
			#$result["content"],參數陣列.
-
 
2509
			#$result["count"],總共有幾個參數.
-
 
2510
			#必填參數:
-
 
2511
			#$conf["input"],字串,要解析成參數的字串.
-
 
2512
			$conf["stringProcess::parse"]["input"]=$unFormatStr;
-
 
2513
			#可省略參數:
-
 
2514
			#無.
-
 
2515
			#參考資料:
-
 
2516
			#無.
-
 
2517
			#備註:
-
 
2518
			#無.
-
 
2519
			$parse=stringProcess::parse($conf["stringProcess::parse"]);
-
 
2520
			unset($conf["stringProcess::parse"]);
-
 
2521
			
-
 
2522
			#如果執行異常
-
 
2523
			if($parse["status"]==="false"){
-
 
2524
			
-
 
2525
				#設置錯誤識別
-
 
2526
				$result["status"]="false";
-
 
2527
 
-
 
2528
				#設置錯誤訊息
-
 
2529
				$result["error"]=$parse;
-
 
2530
 
-
 
2531
				#回傳結果
-
 
2532
				return $result;
-
 
2533
				
-
 
2534
				}#if end
-
 
2535
			
-
 
2536
			#取得 type
-
 
2537
			$info["type"]=$parse["content"][0];
-
 
2538
			
-
 
2539
			#取得 type...後面的value;comment內容
-
 
2540
			#函式說明:
-
 
2541
			#將字串開頭的特定關鍵字移除.
-
 
2542
			#回傳結果:
-
 
2543
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2544
			#$result["error"],錯誤訊息陣列.
-
 
2545
			#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2546
			#$result["function"],當前執行的函數名稱.
-
 
2547
			#$result["argu"],使用的參數.
-
 
2548
			#$result["content"],處理好的的字串內容.
-
 
2549
			#$result["deleted"],被移除的內容.
-
 
2550
			#必填參數:
-
 
2551
			#$conf["stringIn"],字串,要處理的字串.
-
 
2552
			$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2553
			#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2554
			$conf["stringProcess::delHeadStr"]["headStr"]=array($info["type"]," ","\t");
-
 
2555
			#可省略參數:
-
 
2556
			#無.
-
 
2557
			#參考資料:
-
 
2558
			#無.
-
 
2559
			#備註:
-
 
2560
			#無.
-
 
2561
			$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2562
			unset($conf["stringProcess::delHeadStr"]);
-
 
2563
			
-
 
2564
			#如果執行異常
-
 
2565
			if($delHeadStr["status"]==="false"){
-
 
2566
			
-
 
2567
				#設置錯誤識別
-
 
2568
				$result["status"]="false";
-
 
2569
 
-
 
2570
				#設置錯誤訊息
-
 
2571
				$result["error"]=$delHeadStr;
-
 
2572
 
-
 
2573
				#回傳結果
-
 
2574
				return $result;
-
 
2575
			
-
 
2576
				}#if end
-
 
2577
				
-
 
2578
			#取得 value;comment
-
 
2579
			$unFormatStr=$delHeadStr["content"];
-
 
2580
			
-
 
2581
			#如果有要合併回去的內容
-
 
2582
			if(isset($unFormatStr2add)){
-
 
2583
			
-
 
2584
				#合併回去內容
-
 
2585
				$unFormatStr=$unFormatStr.$unFormatStr2add;
-
 
2586
			
-
 
2587
				#移除用不到的變數
-
 
2588
				unset($unFormatStr2add);
-
 
2589
			
-
 
2590
				}#if end
-
 
2591
			
-
 
2592
			#如果type不為 CNAME 跟 TXT 跟 SOA
-
 
2593
			if( $info["type"]!=="CNAME" && $info["type"]!=="TXT" && $info["type"]!=="SOA" ){
-
 
2594
			
-
 
2595
				#儲存value
-
 
2596
				$info["value"]=$unFormatStr;
-
 
2597
			
-
 
2598
				#判斷是否有 ";" 存在
-
 
2599
				#函式說明:
-
 
2600
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2601
				#回傳結果:
-
 
2602
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2603
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2604
				#$result["function"],當前執行的函式名稱.
-
 
2605
				#$result["argu"],所使用的參數.
-
 
2606
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2607
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2608
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
2609
				#必填參數:
-
 
2610
				#$conf["input"],字串,要檢查的字串.
-
 
2611
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2612
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2613
				$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
2614
				#可省略參數:
-
 
2615
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2616
				#$conf["varEqual"]=array(null,"found");
-
 
2617
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2618
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
2619
				#參考資料:
-
 
2620
				#無.
-
 
2621
				#備註:
-
 
2622
				#無.
-
 
2623
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2624
				unset($conf["search::findSpecifyStrFormat"]);
-
 
2625
			
-
 
2626
				#如果執行異常
-
 
2627
				if($findSpecifyStrFormat["status"]==="false"){
-
 
2628
				
-
 
2629
					#設置錯誤識別
-
 
2630
					$result["status"]="false";
-
 
2631
 
-
 
2632
					#設置錯誤訊息
-
 
2633
					$result["error"]=$findSpecifyStrFormat;
-
 
2634
 
-
 
2635
					#回傳結果
-
 
2636
					return $result;
-
 
2637
				
-
 
2638
					}#if end
-
 
2639
					
-
 
2640
				#如果有 ";"
-
 
2641
				if($findSpecifyStrFormat["found"]==="true"){
-
 
2642
				
-
 
2643
					#儲存value
-
 
2644
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
2645
				
-
 
2646
					#儲存comment
-
 
2647
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
2648
				
-
 
2649
					}#if end
-
 
2650
					
-
 
2651
				#儲存 RR 的記錄
-
 
2652
				$result["content"]=$info;
-
 
2653
				
-
 
2654
				#設置執行正常
-
 
2655
				$result["status"]="true";
-
 
2656
				
-
 
2657
				#回傳結果
-
 
2658
				return $result;
-
 
2659
			
-
 
2660
				}#if end
-
 
2661
		
-
 
2662
			#執行到這邊,代表type為CNAME或TXT或SOA
-
 
2663
			
-
 
2664
			#如果 type 是 SOA
-
 
2665
			if($info["type"]==="SOA"){
-
 
2666
			
-
 
2667
				#如果要debug
-
 
2668
				if($conf["debug"]==="true"){
-
 
2669
				
-
 
2670
					#函式說明:
-
 
2671
					#撰寫log
-
 
2672
					#回傳結果:
-
 
2673
					#$result["status"],狀態,"true"或"false".
-
 
2674
					#$result["error"],錯誤訊息陣列.
-
 
2675
					#$result["function"],當前函式的名稱.
-
 
2676
					#$result["argu"],使用的參數.
-
 
2677
					#$result["content"],要寫入log的內容字串.
-
 
2678
					#必填參數:
-
 
2679
					#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2680
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
2681
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2682
					$conf["logs::record"]["content"]="lineNo:".__LINE__." type:".$info["type"].PHP_EOL;
-
 
2683
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2684
					$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
2685
					#可省略參數:
-
 
2686
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2687
					#$conf["rewrite"]="false";
-
 
2688
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
2689
					#$conf["returnOnly"]="true";
-
 
2690
					#參考資料:
-
 
2691
					#無.
-
 
2692
					#備註:
-
 
2693
					#無.
-
 
2694
					$record=logs::record($conf["logs::record"]);
-
 
2695
					unset($conf["logs::record"]);
-
 
2696
				
-
 
2697
					}#if end
-
 
2698
					
-
 
2699
				#SOA 範例
-
 
2700
				#@	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
-
 
2701
			
-
 
2702
				#再度嘗試分割
-
 
2703
				#如果 內容為 query updatTime IN type value;comment,或value含有(或",則需要將其符號與後面的內容先暫時拆開
-
 
2704
		
-
 
2705
				#函式說明:
-
 
2706
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2707
				#回傳結果:
-
 
2708
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2709
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2710
				#$result["function"],當前執行的函式名稱.
-
 
2711
				#$result["argu"],所使用的參數.
-
 
2712
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2713
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2714
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2715
				#必填參數:
-
 
2716
				#$conf["input"],字串,要檢查的字串.
-
 
2717
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2718
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2719
				$conf["search::findSpecifyStrFormat"]["format"]="\${left}(\${right}";
-
 
2720
				#可省略參數:
-
 
2721
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2722
				#$conf["varEqual"]=array(null,"found");
-
 
2723
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2724
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
2725
				#參考資料:
-
 
2726
				#無.
-
 
2727
				#備註:
-
 
2728
				#無.
-
 
2729
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2730
				unset($conf["search::findSpecifyStrFormat"]);
-
 
2731
			
-
 
2732
				#如果執行異常
-
 
2733
				if($findSpecifyStrFormat["status"]==="false"){
-
 
2734
				
-
 
2735
					#設置錯誤識別
-
 
2736
					$result["status"]="false";
-
 
2737
 
-
 
2738
					#設置錯誤訊息
-
 
2739
					$result["error"]=$findSpecifyStrFormat;
-
 
2740
 
-
 
2741
					#回傳結果
-
 
2742
					return $result;
-
 
2743
			
-
 
2744
					}#if end
-
 
2745
					
-
 
2746
				#如果存在"("
-
 
2747
				if($findSpecifyStrFormat["found"]==="true"){
-
 
2748
				
-
 
2749
					#取得無"("的內容
-
 
2750
					$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2751
					
-
 
2752
					#取得拆下來的含開頭"("內容
-
 
2753
					$unFormatStr2add="(".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2754
					
-
 
2755
					}#if end
-
 
2756
				
-
 
2757
				#反之
-
 
2758
				else{
-
 
2759
				
-
 
2760
					#函式說明:
-
 
2761
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2762
					#回傳結果:
-
 
2763
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2764
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2765
					#$result["function"],當前執行的函式名稱.
-
 
2766
					#$result["argu"],所使用的參數.
-
 
2767
					#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2768
					#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2769
					#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2770
					#必填參數:
-
 
2771
					#$conf["input"],字串,要檢查的字串.
-
 
2772
					$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2773
					#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2774
					$conf["search::findSpecifyStrFormat"]["format"]="\${left}\"\${right}";
-
 
2775
					#可省略參數:
-
 
2776
					#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2777
					#$conf["varEqual"]=array(null,"found");
-
 
2778
					#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2779
					#$conf["varCon"]=array("no_tail"=>" not");
-
 
2780
					#參考資料:
-
 
2781
					#無.
-
 
2782
					#備註:
-
 
2783
					#無.
-
 
2784
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2785
					unset($conf["search::findSpecifyStrFormat"]);
-
 
2786
				
-
 
2787
					#如果執行異常
-
 
2788
					if($findSpecifyStrFormat["status"]==="false"){
-
 
2789
					
-
 
2790
						#設置錯誤識別
-
 
2791
						$result["status"]="false";
-
 
2792
 
-
 
2793
						#設置錯誤訊息
-
 
2794
						$result["error"]=$findSpecifyStrFormat;
-
 
2795
 
-
 
2796
						#回傳結果
-
 
2797
						return $result;
-
 
2798
				
-
 
2799
						}#if end
-
 
2800
						
-
 
2801
					#如果存在"
-
 
2802
					if($findSpecifyStrFormat["found"]==="true"){
-
 
2803
					
-
 
2804
						#取得無"的內容
-
 
2805
						$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2806
						
-
 
2807
						#取得拆下來的含開頭"內容
-
 
2808
						$unFormatStr2add="\"".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2809
						
-
 
2810
						}#if end
-
 
2811
						
-
 
2812
					#反之
-
 
2813
					else{
-
 
2814
					
-
 
2815
						#函式說明:
-
 
2816
						#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2817
						#回傳結果:
-
 
2818
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2819
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2820
						#$result["function"],當前執行的函式名稱.
-
 
2821
						#$result["argu"],所使用的參數.
-
 
2822
						#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2823
						#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2824
						#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2825
						#必填參數:
-
 
2826
						#$conf["input"],字串,要檢查的字串.
-
 
2827
						$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2828
						#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2829
						$conf["search::findSpecifyStrFormat"]["format"]="\${left};\${right}";
-
 
2830
						#可省略參數:
-
 
2831
						#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2832
						#$conf["varEqual"]=array(null,"found");
-
 
2833
						#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2834
						#$conf["varCon"]=array("no_tail"=>" not");
-
 
2835
						#參考資料:
-
 
2836
						#無.
-
 
2837
						#備註:
-
 
2838
						#無.
-
 
2839
						$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2840
						unset($conf["search::findSpecifyStrFormat"]);
-
 
2841
					
-
 
2842
						#如果執行異常
-
 
2843
						if($findSpecifyStrFormat["status"]==="false"){
-
 
2844
						
-
 
2845
							#設置錯誤識別
-
 
2846
							$result["status"]="false";
-
 
2847
 
-
 
2848
							#設置錯誤訊息
-
 
2849
							$result["error"]=$findSpecifyStrFormat;
-
 
2850
 
-
 
2851
							#回傳結果
-
 
2852
							return $result;
-
 
2853
					
-
 
2854
							}#if end
-
 
2855
							
-
 
2856
						#如果存在";"
-
 
2857
						if($findSpecifyStrFormat["found"]==="true"){
-
 
2858
						
-
 
2859
							#取得無";"的內容
-
 
2860
							$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2861
							
-
 
2862
							#取得拆下來的含開頭";"內容
-
 
2863
							$unFormatStr2add=";".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2864
							
-
 
2865
							}#if end
-
 
2866
					
-
 
2867
						}#else end
-
 
2868
				
-
 
2869
					}#else end
-
 
2870
			
-
 
2871
				#取得 serial number
-
 
2872
				#函式說明:
-
 
2873
				#將字串進行解析,變成多個參數.
-
 
2874
				#回傳結果:
-
 
2875
				#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
-
 
2876
				#$result["function"],當前執行的函式內容.
-
 
2877
				#$result["error"],錯誤訊息陣列.
-
 
2878
				#$result["content"],參數陣列.
-
 
2879
				#$result["count"],總共有幾個參數.
-
 
2880
				#必填參數:
-
 
2881
				#$conf["input"],字串,要解析成參數的字串.
-
 
2882
				$conf["stringProcess::parse"]["input"]=$unFormatStr;
-
 
2883
				#可省略參數:
-
 
2884
				#無.
-
 
2885
				#參考資料:
-
 
2886
				#無.
-
 
2887
				#備註:
-
 
2888
				#無.
-
 
2889
				$parse=stringProcess::parse($conf["stringProcess::parse"]);
-
 
2890
				unset($conf["stringProcess::parse"]);
-
 
2891
				
-
 
2892
				#如果執行異常
-
 
2893
				if($parse["status"]==="false"){
-
 
2894
				
-
 
2895
					#設置錯誤識別
-
 
2896
					$result["status"]="false";
-
 
2897
 
-
 
2898
					#設置錯誤訊息
-
 
2899
					$result["error"]=$parse;
-
 
2900
 
-
 
2901
					#回傳結果
-
 
2902
					return $result;
-
 
2903
				
-
 
2904
					}#if end
-
 
2905
				
-
 
2906
				#取得serial number
-
 
2907
				$serialNo=$parse["content"][2];
-
 
2908
			
-
 
2909
				#serialNo+1
-
 
2910
				$serialNo++;
-
 
2911
			
-
 
2912
				#回存
-
 
2913
				$parse["content"][2]=(string)$serialNo;
-
 
2914
				
-
 
2915
				#函式說明:
-
 
2916
				#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
-
 
2917
				#回傳的結果:
-
 
2918
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2919
				#$result["function"],當前執行的function名稱
-
 
2920
				#$result["error"],錯誤訊息陣列.
-
 
2921
				#$result["content"],處理好的字串.
-
 
2922
				#$result["argu"],使用的參數.
-
 
2923
				#必填參數:
-
 
2924
				#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
-
 
2925
				$conf["arrays::arrayToString"]["inputArray"]=$parse["content"];
-
 
2926
				#可省略參數:
-
 
2927
				#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
-
 
2928
				$conf["arrays::arrayToString"]["spiltSymbol"]=" ";
-
 
2929
				#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
-
 
2930
				$conf["arrays::arrayToString"]["skipEnd"]="true";
-
 
2931
				#$conf["spiltSymbolAtStart"],字串,是否要在開頭加上spiltSymbol,預設為"false",代表不要;反之為“true”.
-
 
2932
				#$conf["spiltSymbolAtStart"]="";
-
 
2933
				#參考資料:
-
 
2934
				#無.
-
 
2935
				#備註:
-
 
2936
				#無.
-
 
2937
				$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
-
 
2938
				unset($conf["arrays::arrayToString"]);
-
 
2939
				
-
 
2940
				#如果執行異常
-
 
2941
				if($arrayToString["status"]==="false"){
-
 
2942
				
-
 
2943
					#設置錯誤識別
-
 
2944
					$result["status"]="false";
-
 
2945
 
-
 
2946
					#設置錯誤訊息
-
 
2947
					$result["error"]=$arrayToString;
-
 
2948
 
-
 
2949
					#回傳結果
-
 
2950
					return $result;
-
 
2951
				
-
 
2952
					}#if end
-
 
2953
				
-
 
2954
				#取得更新 serial number 後的 SOA value string
-
 
2955
				$unFormatStr=$arrayToString["content"];
-
 
2956
			
-
 
2957
				#如果有要合併回去的內容
-
 
2958
				if(isset($unFormatStr2add)){
-
 
2959
				
-
 
2960
					#合併回去內容
-
 
2961
					$unFormatStr=$unFormatStr.$unFormatStr2add;
-
 
2962
				
-
 
2963
					#移除用不到的變數
-
 
2964
					unset($unFormatStr2add);
-
 
2965
				
-
 
2966
					}#if end
-
 
2967
			
-
 
2968
				#假設剩下的沒有註解都是 value
-
 
2969
				$info["value"]=$unFormatStr;
-
 
2970
			
-
 
2971
				#函式說明:
-
 
2972
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2973
				#回傳結果:
-
 
2974
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2975
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2976
				#$result["function"],當前執行的函式名稱.
-
 
2977
				#$result["argu"],所使用的參數.
-
 
2978
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2979
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2980
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
2981
				#必填參數:
-
 
2982
				#$conf["input"],字串,要檢查的字串.
-
 
2983
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2984
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2985
				$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
2986
				#可省略參數:
-
 
2987
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2988
				#$conf["varEqual"]=array(null,"found");
-
 
2989
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2990
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
2991
				#參考資料:
-
 
2992
				#無.
-
 
2993
				#備註:
-
 
2994
				#無.
-
 
2995
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2996
				unset($conf["search::findSpecifyStrFormat"]);
-
 
2997
			
-
 
2998
				#如果執行異常
-
 
2999
				if($findSpecifyStrFormat["status"]==="false"){
-
 
3000
				
-
 
3001
					#設置錯誤識別
-
 
3002
					$result["status"]="false";
-
 
3003
 
-
 
3004
					#設置錯誤訊息
-
 
3005
					$result["error"]=$findSpecifyStrFormat;
-
 
3006
 
-
 
3007
					#回傳結果
-
 
3008
					return $result;
-
 
3009
				
-
 
3010
					}#if end
-
 
3011
					
-
 
3012
				#如果有符合格式
-
 
3013
				if($findSpecifyStrFormat["found"]==="true"){
-
 
3014
				
-
 
3015
					#儲存 value
-
 
3016
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3017
				
-
 
3018
					#儲存 comment
-
 
3019
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3020
				
-
 
3021
					}#if end
-
 
3022
				
-
 
3023
				#儲存 RR 的記錄
-
 
3024
				$result["content"]=$info;
-
 
3025
				
-
 
3026
				#設置執行正常
-
 
3027
				$result["status"]="true";
-
 
3028
				
-
 
3029
				#回傳結果
-
 
3030
				return $result;
-
 
3031
			
-
 
3032
				}#if end
-
 
3033
			
-
 
3034
			#執行到這邊代表不是 SOA
-
 
3035
			
-
 
3036
			#尋找是否有(...)...的內容存在
-
 
3037
			#函式說明:
-
 
3038
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3039
			#回傳結果:
-
 
3040
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3041
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3042
			#$result["function"],當前執行的函式名稱.
-
 
3043
			#$result["argu"],所使用的參數.
-
 
3044
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3045
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3046
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3047
			#必填參數:
-
 
3048
			#$conf["input"],字串,要檢查的字串.
-
 
3049
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3050
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3051
			$conf["search::findSpecifyStrFormat"]["format"]="(\${value};\${comment}";
-
 
3052
			#可省略參數:
-
 
3053
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3054
			#$conf["varEqual"]=array(null,"found");
-
 
3055
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3056
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
3057
			#參考資料:
-
 
3058
			#無.
-
 
3059
			#備註:
-
 
3060
			#無.
-
 
3061
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3062
			unset($conf["search::findSpecifyStrFormat"]);
-
 
3063
		
-
 
3064
			#如果執行異常
-
 
3065
			if($findSpecifyStrFormat["status"]==="false"){
-
 
3066
			
-
 
3067
				#設置錯誤識別
-
 
3068
				$result["status"]="false";
-
 
3069
 
-
 
3070
				#設置錯誤訊息
-
 
3071
				$result["error"]=$findSpecifyStrFormat;
-
 
3072
 
-
 
3073
				#回傳結果
-
 
3074
				return $result;
-
 
3075
			
-
 
3076
				}#if end
-
 
3077
				
-
 
3078
			#如果有 有符合 ($value);${comment} 的格式
-
 
3079
			if($findSpecifyStrFormat["found"]==="true"){
-
 
3080
			
-
 
3081
				#儲存value
-
 
3082
				$info["value"]="(".$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3083
			
-
 
3084
				#儲存comment
-
 
3085
				$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3086
			
-
 
3087
				#儲存 RR 的記錄
-
 
3088
				$result["content"]=$info;
-
 
3089
				
-
 
3090
				#設置執行正常
-
 
3091
				$result["status"]="true";
-
 
3092
				
-
 
3093
				#回傳結果
-
 
3094
				return $result;
-
 
3095
			
-
 
3096
				}#if end
-
 
3097
			
-
 
3098
			#執行到這邊代表沒有 (...)... 的內容存在
-
 
3099
			
-
 
3100
			#尋找是否有 (...) 的內容存在
-
 
3101
			#函式說明:
-
 
3102
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3103
			#回傳結果:
-
 
3104
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3105
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3106
			#$result["function"],當前執行的函式名稱.
-
 
3107
			#$result["argu"],所使用的參數.
-
 
3108
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3109
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3110
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3111
			#必填參數:
-
 
3112
			#$conf["input"],字串,要檢查的字串.
-
 
3113
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3114
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3115
			$conf["search::findSpecifyStrFormat"]["format"]="(\${value})";
-
 
3116
			#可省略參數:
-
 
3117
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3118
			#$conf["varEqual"]=array(null,"found");
-
 
3119
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3120
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
3121
			#參考資料:
-
 
3122
			#無.
-
 
3123
			#備註:
-
 
3124
			#無.
-
 
3125
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3126
			unset($conf["search::findSpecifyStrFormat"]);
-
 
3127
		
-
 
3128
			#如果執行異常
-
 
3129
			if($findSpecifyStrFormat["status"]==="false"){
-
 
3130
			
-
 
3131
				#設置錯誤識別
-
 
3132
				$result["status"]="false";
-
 
3133
 
-
 
3134
				#設置錯誤訊息
-
 
3135
				$result["error"]=$findSpecifyStrFormat;
-
 
3136
 
-
 
3137
				#回傳結果
-
 
3138
				return $result;
-
 
3139
			
-
 
3140
				}#if end
-
 
3141
				
-
 
3142
			#如果有 有符合 ($value);${comment} 的格式
-
 
3143
			if($findSpecifyStrFormat["found"]==="true"){
-
 
3144
			
-
 
3145
				#儲存value
-
 
3146
				$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3147
			
-
 
3148
				#儲存 RR 的記錄
-
 
3149
				$result["content"]=$info;
-
 
3150
				
-
 
3151
				#設置執行正常
-
 
3152
				$result["status"]="true";
-
 
3153
				
-
 
3154
				#回傳結果
-
 
3155
				return $result;
-
 
3156
			
-
 
3157
				}#if end
-
 
3158
				
-
 
3159
			#執行到這邊代表沒有 (...) 的內容存在
-
 
3160
			
-
 
3161
			#尋找有無 "...";... 的內容存在
-
 
3162
			#函式說明:
-
 
3163
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3164
			#回傳結果:
-
 
3165
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3166
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3167
			#$result["function"],當前執行的函式名稱.
-
 
3168
			#$result["argu"],所使用的參數.
-
 
3169
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3170
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3171
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3172
			#必填參數:
-
 
3173
			#$conf["input"],字串,要檢查的字串.
-
 
3174
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3175
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3176
			$conf["search::findSpecifyStrFormat"]["format"]="\"\${value};\${comment}";
-
 
3177
			#可省略參數:
-
 
3178
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3179
			#$conf["varEqual"]=array(null,"found");
-
 
3180
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3181
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
3182
			#參考資料:
-
 
3183
			#無.
-
 
3184
			#備註:
-
 
3185
			#無.
-
 
3186
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3187
			unset($conf["search::findSpecifyStrFormat"]);
-
 
3188
		
-
 
3189
			#如果執行異常
-
 
3190
			if($findSpecifyStrFormat["status"]==="false"){
-
 
3191
			
-
 
3192
				#設置錯誤識別
-
 
3193
				$result["status"]="false";
-
 
3194
 
-
 
3195
				#設置錯誤訊息
-
 
3196
				$result["error"]=$findSpecifyStrFormat;
-
 
3197
 
-
 
3198
				#回傳結果
-
 
3199
				return $result;
-
 
3200
			
-
 
3201
				}#if end
-
 
3202
				
-
 
3203
			#如果有 有符合 "$value";${comment} 的格式
-
 
3204
			if($findSpecifyStrFormat["found"]==="true"){
-
 
3205
			
-
 
3206
				#儲存value
-
 
3207
				$info["value"]="\"".$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3208
				
-
 
3209
				#儲存comment
-
 
3210
				$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3211
			
-
 
3212
				#儲存 RR 的記錄
-
 
3213
				$result["content"]=$info;
-
 
3214
				
-
 
3215
				#設置執行正常
-
 
3216
				$result["status"]="true";
-
 
3217
				
-
 
3218
				#回傳結果
-
 
3219
				return $result;
-
 
3220
			
-
 
3221
				}#if end
-
 
3222
				
-
 
3223
			#執行到這邊代表沒有 "$value";${comment} 的格式
-
 
3224
			
-
 
3225
			#尋找有無 "..." 的內容存在
-
 
3226
			#函式說明:
-
 
3227
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3228
			#回傳結果:
-
 
3229
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3230
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3231
			#$result["function"],當前執行的函式名稱.
-
 
3232
			#$result["argu"],所使用的參數.
-
 
3233
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3234
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3235
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3236
			#必填參數:
-
 
3237
			#$conf["input"],字串,要檢查的字串.
-
 
3238
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3239
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3240
			$conf["search::findSpecifyStrFormat"]["format"]="\"\${value}\"";
-
 
3241
			#可省略參數:
-
 
3242
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3243
			#$conf["varEqual"]=array(null,"found");
-
 
3244
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3245
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
3246
			#參考資料:
-
 
3247
			#無.
-
 
3248
			#備註:
-
 
3249
			#無.
-
 
3250
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3251
			unset($conf["search::findSpecifyStrFormat"]);
-
 
3252
		
-
 
3253
			#如果執行異常
-
 
3254
			if($findSpecifyStrFormat["status"]==="false"){
-
 
3255
			
-
 
3256
				#設置錯誤識別
-
 
3257
				$result["status"]="false";
-
 
3258
 
-
 
3259
				#設置錯誤訊息
-
 
3260
				$result["error"]=$findSpecifyStrFormat;
-
 
3261
 
-
 
3262
				#回傳結果
-
 
3263
				return $result;
-
 
3264
			
-
 
3265
				}#if end
-
 
3266
				
-
 
3267
			#如果有 有符合 "$value" 的格式
-
 
3268
			if($findSpecifyStrFormat["found"]==="true"){
-
 
3269
			
-
 
3270
				#儲存value
-
 
3271
				$info["value"]="\"".$findSpecifyStrFormat["parsedVar"]["value"][0]."\"";
-
 
3272
				
-
 
3273
				#儲存 RR 的記錄
-
 
3274
				$result["content"]=$info;
-
 
3275
				
-
 
3276
				#設置執行正常
-
 
3277
				$result["status"]="true";
-
 
3278
				
-
 
3279
				#回傳結果
-
 
3280
				return $result;
-
 
3281
			
-
 
3282
				}#if end
-
 
3283
				
-
 
3284
			#執行到這邊代表沒有 "$value" 格式的內容
-
 
3285
			
-
 
3286
			#檢查是否有 $value;$comment 格式的內容
-
 
3287
			#函式說明:
-
 
3288
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3289
			#回傳結果:
-
 
3290
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3291
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3292
			#$result["function"],當前執行的函式名稱.
-
 
3293
			#$result["argu"],所使用的參數.
-
 
3294
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3295
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3296
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3297
			#必填參數:
-
 
3298
			#$conf["input"],字串,要檢查的字串.
-
 
3299
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3300
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3301
			$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
3302
			#可省略參數:
-
 
3303
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3304
			#$conf["varEqual"]=array(null,"found");
-
 
3305
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3306
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
3307
			#參考資料:
-
 
3308
			#無.
-
 
3309
			#備註:
-
 
3310
			#無.
-
 
3311
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3312
			unset($conf["search::findSpecifyStrFormat"]);
-
 
3313
		
-
 
3314
			#如果執行異常
-
 
3315
			if($findSpecifyStrFormat["status"]==="false"){
-
 
3316
			
-
 
3317
				#設置錯誤識別
-
 
3318
				$result["status"]="false";
-
 
3319
 
-
 
3320
				#設置錯誤訊息
-
 
3321
				$result["error"]=$findSpecifyStrFormat;
-
 
3322
 
-
 
3323
				#回傳結果
-
 
3324
				return $result;
-
 
3325
			
-
 
3326
				}#if end
-
 
3327
				
-
 
3328
			#如果有 有符合 "$value" 的格式
-
 
3329
			if($findSpecifyStrFormat["found"]==="true"){
-
 
3330
			
-
 
3331
				#儲存value
-
 
3332
				$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3333
				
-
 
3334
				#儲存comment
-
 
3335
				$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3336
				
-
 
3337
				#儲存 RR 的記錄
-
 
3338
				$result["content"]=$info;
-
 
3339
				
-
 
3340
				#設置執行正常
-
 
3341
				$result["status"]="true";
-
 
3342
				
-
 
3343
				#回傳結果
-
 
3344
				return $result;
-
 
3345
			
-
 
3346
				}#if end
-
 
3347
		
-
 
3348
			#執行到這邊代表沒有 ${value};${comment} 格式的內容
-
 
3349
			
-
 
3350
			#亦即剩下的內容都是 value
-
 
3351
			
-
 
3352
			#儲存value
-
 
3353
			$info["value"]=$unFormatStr;
-
 
3354
			
-
 
3355
			#儲存 RR 的記錄
-
 
3356
			$result["content"]=$info;
-
 
3357
			
-
 
3358
			#設置執行正常
-
 
3359
			$result["status"]="true";
-
 
3360
			
-
 
3361
			#回傳結果
-
 
3362
			return $result;
-
 
3363
			
-
 
3364
			}#while end
-
 
3365
	
-
 
3366
		}#function parseRRline end
-
 
3367
 
-
 
3368
	/*
-
 
3369
	#函式說明:
1400
	#新增DNS記錄到檔案裡面.
3370
	#新增DNS記錄到檔案裡面.
1401
	#回傳結果:
3371
	#回傳結果:
1402
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3372
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1403
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
3373
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
1404
	#$result["function"],當前執行的函式名稱.
3374
	#$result["function"],當前執行的函式名稱.
Line 1415... Line 3385...
1415
	#可省略參數:
3385
	#可省略參數:
1416
	#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
3386
	#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
1417
	#$conf["writeNow"]="false";
3387
	#$conf["writeNow"]="false";
1418
	#$conf["debug"],字串,是否要開啟debug模式,預設為"false"不開啟;反之為"true"要開啟,會在/tmp/建立debug檔案zerossl\:\:updateDnsRecordFile.
3388
	#$conf["debug"],字串,是否要開啟debug模式,預設為"false"不開啟;反之為"true"要開啟,會在/tmp/建立debug檔案zerossl\:\:updateDnsRecordFile.
1419
	#$conf["debug"]="false";
3389
	#$conf["debug"]="false";
-
 
3390
	#$conf["multiThread"],字串,是否啟動多執行序加快執行速度,預設為"false"代表不要;反之為"true"代表要.
-
 
3391
	#$conf["multiThread"]="false";
1420
	#參考資料:
3392
	#參考資料:
1421
	#無.
3393
	#無.
1422
	#備註:
3394
	#備註:
1423
	#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
3395
	#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
1424
	#通常qbpwcf使用者沒有權限存取RR(dns記錄檔案),本套件是透過sshfs掛載來繞過該問題.
3396
	#本套件是透過sshfs掛載來存取RR(dns記錄檔案),其檔案建議的擁有者權限為 root:qbpwcf,權限代碼為 774.
1425
	#php-pear上的Net_DNS2也可以解析RR.
3397
	#php-pear上的Net_DNS2也可以解析RR.
1426
	*/
3398
	*/
1427
	public static function updateDnsRecordFile(&$conf){
3399
	public static function updateDnsRecordFile(&$conf){
1428
	
3400
	
1429
		#初始化要回傳的結果
3401
		#初始化要回傳的結果
Line 1484... Line 3456...
1484
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
3456
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
1485
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3457
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1486
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
3458
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
1487
		#$conf["skipableVariableCanNotBeEmpty"]=array();
3459
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1488
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3460
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1489
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("writeNow","debug");
3461
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("writeNow","debug","multiThread");
1490
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3462
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1491
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
3463
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
1492
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3464
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1493
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false");
3465
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false","false");
1494
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3466
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1495
		#$conf["arrayCountEqualCheck"][]=array();
3467
		#$conf["arrayCountEqualCheck"][]=array();
1496
		#參考資料來源:
3468
		#參考資料來源:
1497
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3469
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1498
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3470
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
Line 1611... Line 3583...
1611
		*/
3583
		*/
1612
		
3584
		
1613
		#針對每行內容
3585
		#針對每行內容
1614
		foreach($lines as $lineNo => $line){
3586
		foreach($lines as $lineNo => $line){
1615
		
3587
		
-
 
3588
			#如果要啟用多執行序
-
 
3589
			if($conf["multiThread"]==="true"){
-
 
3590
			
-
 
3591
				#初始化要執行的 php 程式
-
 
3592
				$phpCode2run=array();
-
 
3593
				
-
 
3594
				#用 php 執行
-
 
3595
				$phpCode2run[]="php";
-
 
3596
				
-
 
3597
				#用 "-r" 參數
-
 
3598
				$phpCode2run[]="-r";
-
 
3599
				
-
 
3600
				#用 "-r" 參數
-
 
3601
				$phpCode2run[]=<<<'PHP'
-
 
3602
#匯入QBPWCF套件
-
 
3603
include("allInOne.php");
-
 
3604
 
-
 
3605
#函式說明:
-
 
3606
#解析RR檔案中其中的一行內容.
-
 
3607
#回傳結果:
-
 
3608
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3609
#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3610
#$result["function"],當前執行的函式名稱.
-
 
3611
#$result["argu"],所使用的參數.
-
 
3612
#$result["content"],字串陣列,更新後的檔案RR(DNS記錄).
-
 
3613
#$result["domain"],字串,RR所屬domain.
-
 
3614
#$result["defaultTTL"],字串,預設的RR更新時間.
-
 
3615
#$result["comment"],字串陣列,逐行的註解.
-
 
3616
#必填參數:
-
 
3617
#$conf["line"],字串,要解析的行內容.
-
 
3618
$conf["line"]=$line;
-
 
3619
#可省略參數:
-
 
3620
#無.
-
 
3621
#參考資料:
-
 
3622
#無.
-
 
3623
#備註:
-
 
3624
#無.
-
 
3625
$parseRRline=zerossl::parseRRline($conf);
-
 
3626
unset($conf);
-
 
3627
 
-
 
3628
#如果執行異常 
-
 
3629
if($parseRRline["status"]==="false"){
-
 
3630
 
-
 
3631
	#設置錯誤識別
-
 
3632
	$result["status"]="false";
-
 
3633
 
-
 
3634
	#設置錯誤訊息
-
 
3635
	$result["error"]=$parseRRline;
-
 
3636
 
-
 
3637
	#印出 json 結果
-
 
3638
	echo json_encode($result);
-
 
3639
	
-
 
3640
	#結束執行,回傳1.
-
 
3641
	exit(1);
-
 
3642
 
-
 
3643
	}#if end
-
 
3644
	
-
 
3645
#印出json
-
 
3646
echo json_encode($parseRRline);
-
 
3647
 
-
 
3648
PHP;
-
 
3649
				
-
 
3650
				#函式說明:
-
 
3651
				#透過proc來多執行序運作.
-
 
3652
				#回傳結果:
-
 
3653
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3654
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3655
				#$result["function"],當前執行的函式名稱.
-
 
3656
				#$result["argu"],使用的參數.
-
 
3657
				#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值,若為"?"則代表程序尚未結束,若為整數0,則代表順利執行結束,可透過proc_update函式進行資訊的更新與取得;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source;key為"proc_get_status"代表程序的資訊.
-
 
3658
				#必填參數:
-
 
3659
				#$conf["cmds"],字串陣列,每個元素代表單一程序要執行的指令與參數.
-
 
3660
				$conf["threads::proc"]["cmds"]=$phpCode2run;
-
 
3661
				#可省略參數:
-
 
3662
				#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
-
 
3663
				$conf["threads::proc"]["wait"]="false";
-
 
3664
				#$conf["timeout"],字串陣列,每個元素代表單一程序執行的最大等待秒數,超過後將會強迫停止執行,僅當wait參數為"true"時生效.
-
 
3665
				#$conf["timeout"]=array("10");
-
 
3666
				#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
-
 
3667
				$conf["threads::proc"]["workingDir"]=array(pathinfo(__FILE__)["driname"]);
-
 
3668
				#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
-
 
3669
				#$conf["envs"]=array(array("key"=>"value"));
-
 
3670
				#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
-
 
3671
				#$conf["executeBy"]=array("bash");
-
 
3672
				#參考資料:
-
 
3673
				#https://www.php.net/manual/en/function.proc-open.php
-
 
3674
				#https://www.php.net/manual/en/function.proc-get-status.php
-
 
3675
				#https://www.php.net/manual/en/function.proc-terminate.php
-
 
3676
				#備註:
-
 
3677
				#當wait參數為"true"時,會自動解析stdout與stderr,因此不用再透過 self::proc_update 來更新.
-
 
3678
				#當wait參數不為"true"時,若需要取得當下的執行狀況,請使用 self::proc_update 來更新.
-
 
3679
				$proc=threads::proc($conf["threads::proc"]);
-
 
3680
				unset($conf["threads::proc"]);
-
 
3681
			
-
 
3682
				#如果檢查失敗
-
 
3683
				if($proc["status"]==="false"){
-
 
3684
 
-
 
3685
					#設置錯誤識別
-
 
3686
					$result["status"]="false";
-
 
3687
 
-
 
3688
					#設置錯誤訊息
-
 
3689
					$result["error"]=$proc;
-
 
3690
 
-
 
3691
					#回傳結果
-
 
3692
					return $result;
-
 
3693
 
-
 
3694
					}#if end
-
 
3695
					
-
 
3696
				#儲存程序資訊
-
 
3697
				$procs[]=$proc;	
-
 
3698
				
-
 
3699
				#換解析下一行
-
 
3700
				continue;
-
 
3701
			
-
 
3702
				}#if end
-
 
3703
		
1616
			#另存一份要處理的RR
3704
			#另存一份要處理的RR
1617
			$unFormatStr=$line;
3705
			$unFormatStr=$line;
1618
		
3706
		
1619
			#如果要debug
3707
			#如果要debug
1620
			if($conf["debug"]==="true"){
3708
			if($conf["debug"]==="true"){
Line 2891... Line 4979...
2891
						
4979
						
2892
					#解析完畢換下一行
4980
					#解析完畢換下一行
2893
					continue 2;
4981
					continue 2;
2894
				
4982
				
2895
					}#if end
4983
					}#if end
2896
						
4984
			
2897
				#執行到這邊,代表type為CNAME或TXT或SOA
4985
				#執行到這邊,代表type為CNAME或TXT或SOA
2898
				
4986
				
2899
				#如果 type 是 SOA
4987
				#如果 type 是 SOA
2900
				if($info["type"]==="SOA"){
4988
				if($info["type"]==="SOA"){
2901
				
4989
				
Line 3576... Line 5664...
3576
				continue 2;
5664
				continue 2;
3577
				
5665
				
3578
				}#while end
5666
				}#while end
3579
			
5667
			
3580
			}#foreach end
5668
			}#foreach end
-
 
5669
			
-
 
5670
		#如果要啟用多執行序
-
 
5671
		if($conf["multiThread"]==="true"){
-
 
5672
		
-
 
5673
			#debug
-
 
5674
			var_dump($procs);
-
 
5675
		
-
 
5676
			#結束執行,回傳shell 1.
-
 
5677
			exit(1);
-
 
5678
		
-
 
5679
			}#if end
3581
		
5680
		
3582
		#如果要debug
5681
		#如果要debug
3583
		if($conf["debug"]==="true"){
5682
		if($conf["debug"]==="true"){
3584
		
5683
		
3585
			#函式說明:
5684
			#函式說明:
Line 4448... Line 6547...
4448
 
6547
 
4449
				#回傳結果
6548
				#回傳結果
4450
				return $result;
6549
				return $result;
4451
			
6550
			
4452
				}#if end
6551
				}#if end
-
 
6552
				
-
 
6553
			#修正 zone file 的權限
-
 
6554
			#函式說明:
-
 
6555
			#使用 linux 的 chown 指令來修改目標檔案或目錄的擁有者跟群組擁有者資訊.
-
 
6556
			#回傳結果:
-
 
6557
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
6558
			#$result["error"],錯誤訊息.
-
 
6559
			#$result["function"],當前執行的函式名稱.
-
 
6560
			#$result["cmd"],執行的指令.
-
 
6561
			#必填參數:
-
 
6562
			#$conf["owner"],字串,要變哪個使用者擁有.
-
 
6563
			$conf["cmd::chown"]["owner"]="root";
-
 
6564
			#$conf["target"],字串,需要變更擁有者、 群組的目標.
-
 
6565
			$conf["cmd::chown"]["target"]=$conf["dnsRecordFile"];
-
 
6566
			#可省略參數:
-
 
6567
			#$conf["group"],字串,要變成什麼群組擁有,預設跟"owner"一樣.
-
 
6568
			$conf["cmd::chown"]["group"]=webUser;
-
 
6569
			#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
-
 
6570
			#$conf["recursive"]="true";
-
 
6571
			#$conf["excludeSelf"],字串,預設為"false"代表不處理;若為"true"則會排除目標自己(資料夾).
-
 
6572
			#$conf["excludeSelf"]="true";
-
 
6573
			#參考資料:
-
 
6574
			#無.
-
 
6575
			#備註:
-
 
6576
			#無.
-
 
6577
			$chown=cmd::chown($conf["cmd::chown"]);
-
 
6578
			unset($conf["cmd::chown"]);
-
 
6579
		
-
 
6580
			#如果執行異常
-
 
6581
			if($chown["status"]==="false"){
-
 
6582
			
-
 
6583
				#設置錯誤識別
-
 
6584
				$result["status"]="false";
-
 
6585
 
-
 
6586
				#設置錯誤訊息
-
 
6587
				$result["error"]=$chown;
-
 
6588
 
-
 
6589
				#回傳結果
-
 
6590
				return $result;
-
 
6591
			
-
 
6592
				}#if end
-
 
6593
				
-
 
6594
			#函式說明:
-
 
6595
			#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
-
 
6596
			#回傳結果:
-
 
6597
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
6598
			#$result["error"],錯誤訊息.
-
 
6599
			#$result["function"],當前執行的函式名稱.
-
 
6600
			#$result["cmd"],執行的指令.
-
 
6601
			#必填參數:
-
 
6602
			#$conf["mode"],字串,要變成什麼權限.
-
 
6603
			$conf["cmd::chmod"]["mode"]="774";
-
 
6604
			#$conf["target"],字串,需要變更權限的目標.
-
 
6605
			$conf["cmd::chmod"]["target"]=$conf["dnsRecordFile"];
-
 
6606
			#可省略參數:
-
 
6607
			#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
-
 
6608
			#$conf["recursive"]="true";
-
 
6609
			#$conf["excludeSelf"],字串,預設為"false"代表不處理;若為"true"則會排除目標自己(資料夾).
-
 
6610
			#$conf["excludeSelf"]="true";
-
 
6611
			#參考資料:
-
 
6612
			#無.
-
 
6613
			#備註:
-
 
6614
			#無.
-
 
6615
			$chmod=cmd::chmod($conf["cmd::chmod"]);
-
 
6616
			unset($conf["cmd::chmod"]);
-
 
6617
		
-
 
6618
			#如果執行異常
-
 
6619
			if($chmod["status"]==="false"){
-
 
6620
			
-
 
6621
				#設置錯誤識別
-
 
6622
				$result["status"]="false";
-
 
6623
 
-
 
6624
				#設置錯誤訊息
-
 
6625
				$result["error"]=$chmod;
-
 
6626
 
-
 
6627
				#回傳結果
-
 
6628
				return $result;
-
 
6629
			
-
 
6630
				}#if end
4453
		
6631
		
4454
			}#if end
6632
			}#if end
4455
			
6633
			
4456
		#設置執行正常
6634
		#設置執行正常
4457
		$result["status"]="true";
6635
		$result["status"]="true";
Line 4785... Line 6963...
4785
 
6963
 
4786
			}#if end
6964
			}#if end
4787
 
6965
 
4788
		#取得參數
6966
		#取得參數
4789
		$result["argu"]=$conf;
6967
		$result["argu"]=$conf;
-
 
6968
	
-
 
6969
		#DEBUG
-
 
6970
		#var_dump(__LINE__,self::getApiInfo());exit;
4790
 
6971
 
4791
		#檢查參數
6972
		#檢查參數
4792
		#函式說明:
6973
		#函式說明:
4793
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
6974
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4794
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6975
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 5109... Line 7290...
5109
			return $result;
7290
			return $result;
5110
 
7291
 
5111
			}#if end
7292
			}#if end
5112
		
7293
		
5113
		#預設網址
7294
		#預設網址
5114
		$url="https://".$conf["apiDomain"].self::getApiInfo()["csrPath"]."/?access_key=".$conf["key"];
7295
		$url="https://".$conf["apiDomain"].self::getApiInfo()["csrPath"]."?access_key=".$conf["key"];
5115
		
7296
		
5116
		#如果有設置 cerStatus
7297
		#如果有設置 cerStatus
5117
		if(isset($conf["cerStatus"])){
7298
		if(isset($conf["cerStatus"])){
5118
		
7299
		
5119
			#設置 certificate_status 
7300
			#設置 certificate_status 
5120
			$url=$url."?certificate_status=".urlencode($conf["cerStatus"]);
7301
			$url=$url."&certificate_status=".urlencode($conf["cerStatus"]);
5121
		
7302
		
5122
			}#if end
7303
			}#if end
5123
			
7304
			
5124
		#如果有設置 cerType
7305
		#如果有設置 cerType
5125
		if(isset($conf["cerType"])){
7306
		if(isset($conf["cerType"])){
5126
		
7307
		
5127
			#設置 certificate_type
7308
			#設置 certificate_type
5128
			$url=$url."?certificate_type=".$conf["cerType"];
7309
			$url=$url."&certificate_type=".urlencode($conf["cerType"]);
5129
		
7310
		
5130
			}#if end
7311
			}#if end
5131
			
7312
			
5132
		#如果有設置 search
7313
		#如果有設置 search
5133
		if(isset($conf["search"])){
7314
		if(isset($conf["search"])){
5134
		
7315
		
5135
			#設置 search
7316
			#設置 search
5136
			$url=$url."?search=".urlencode($conf["search"]);
7317
			$url=$url."&search=".urlencode($conf["search"]);
5137
		
7318
		
5138
			}#if end
7319
			}#if end
5139
			
7320
			
5140
		#如果有設置 limit
7321
		#如果有設置 limit
5141
		if(isset($conf["limit"])){
7322
		if(isset($conf["limit"])){
5142
		
7323
		
5143
			#設置 search
7324
			#設置 search
5144
			$url=$url."?limit=".$conf["limit"];
7325
			$url=$url."&limit=".urlencode($conf["limit"]);
5145
		
7326
		
5146
			}#if end
7327
			}#if end
5147
			
7328
			
5148
		#如果有設置 page
7329
		#如果有設置 page
5149
		if(isset($conf["page"])){
7330
		if(isset($conf["page"])){
5150
		
7331
		
5151
			#設置 search
7332
			#設置 search
5152
			$url=$url."?page=".$conf["page"];
7333
			$url=$url."&"."page=".urlencode($conf["page"]);
5153
		
7334
		
5154
			}#if end
7335
			}#if end
5155
		
7336
		
5156
		#函式說明:
7337
		#函式說明:
5157
		#運行curl cmd
7338
		#運行curl cmd
Line 5318... Line 7499...
5318
		
7499
		
5319
		#取得該頁的筆數
7500
		#取得該頁的筆數
5320
		$result["count"]=$jsonRes->result_count;
7501
		$result["count"]=$jsonRes->result_count;
5321
		
7502
		
5322
		#取得certificate清單
7503
		#取得certificate清單
5323
		$cers=$jsonRes->results;
7504
		$certs=$jsonRes->results;
5324
		
7505
		
5325
		#針對每個certificate
7506
		#針對每個certificate
5326
		foreach($certs as $index => $cert){
7507
		foreach($certs as $index => $cert){
5327
		
7508
		
5328
			#初始化暫存的陣列
7509
			#初始化暫存的陣列
Line 5364... Line 7545...
5364
			#無.
7545
			#無.
5365
			$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
7546
			$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
5366
			unset($conf["time::caculateTimeAmount"]);
7547
			unset($conf["time::caculateTimeAmount"]);
5367
		
7548
		
5368
			#如果執行異常
7549
			#如果執行異常
5369
			if($caculateTimeAmount["passed"]==="false"){
7550
			if($caculateTimeAmount["status"]==="false"){
5370
 
7551
 
5371
				#設置錯誤識別
7552
				#設置錯誤識別
5372
				$result["status"]="false";
7553
				$result["status"]="false";
5373
 
7554
 
5374
				#設置錯誤訊息
7555
				#設置錯誤訊息
Line 5378... Line 7559...
5378
				return $result;
7559
				return $result;
5379
 
7560
 
5380
				}#if end
7561
				}#if end
5381
				
7562
				
5382
			#儲存還要多少秒要過期
7563
			#儲存還要多少秒要過期
5383
			$tmpA["expiresIn"]=$caculateTimeAmount["unixtime"]-time();
7564
			$tmpA["expiresIn"]=$caculateTimeAmount["content"]-time();
5384
		
7565
		
5385
			#憑證的狀態
7566
			#憑證的狀態
5386
			$tmpA["status"]=$cert->status;
7567
			$tmpA["status"]=$cert->status;
5387
			
7568
			
5388
			#儲存要回傳的 cers 清單,key為cert的id.
7569
			#儲存要回傳的 certs 清單,key為cert的id.
5389
			$result["cers"][$cert->id]=$tmpA;
7570
			$result["certs"][$cert->id]=$tmpA;
5390
		
7571
		
5391
			}#foreach end
7572
			}#foreach end
5392
	
7573
	
5393
		#設置執行正常
7574
		#設置執行正常
5394
		$result["status"]="true";
7575
		$result["status"]="true";
Line 5695... Line 7876...
5695
		$result["content"]=$curlCmd["fullContent"];
7876
		$result["content"]=$curlCmd["fullContent"];
5696
		
7877
		
5697
		#取得 json
7878
		#取得 json
5698
		$json=json_decode($curlCmd["fullContent"]);
7879
		$json=json_decode($curlCmd["fullContent"]);
5699
		
7880
		
-
 
7881
		#儲存成變數以便透過object呼叫
-
 
7882
		$c_crt="certificate.crt";
-
 
7883
		
-
 
7884
		#儲存成變數以便透過object呼叫
-
 
7885
		$ca_crt="ca_bundle.crt";
-
 
7886
		
5700
		#取得certificate.crt的內容
7887
		#取得certificate.crt的內容
5701
		$result["certificate.crt"]=$json->certificate.crt;
7888
		$result["certificate.crt"]=$json->$c_crt;
5702
		
7889
		
5703
		#取得ca_bundle.crt的內容
7890
		#取得ca_bundle.crt的內容
5704
		$result["ca_bundle.crt"]=$json->ca_bundle.crt;
7891
		$result["ca_bundle.crt"]=$json->$ca_crt;
5705
		
7892
		
5706
		#設置執行正常
7893
		#設置執行正常
5707
		$result["status"]="true";
7894
		$result["status"]="true";
5708
		
7895
		
5709
		#回傳結果
7896
		#回傳結果
Line 6328... Line 8515...
6328
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
8515
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
6329
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("sock","debug","apiDomain","key","addOnProcessFunc","funcToRunWhenIdle");
8516
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("sock","debug","apiDomain","key","addOnProcessFunc","funcToRunWhenIdle");
6330
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
8517
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
6331
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","array","array");
8518
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","array","array");
6332
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
8519
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
6333
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($defaultSocket,"false",self::getApiInfo()["apiDomain"],self::getApiInfo()["apiKey"],"false",array("/qbpwcf/zerossl::sslUpdater_cmd"),array("/qbpwcf/zerossl::sslUpdater_idle"));
8520
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($defaultSocket,"false",self::getApiInfo()["apiDomain"],self::getApiInfo()["apiKey"],array("/qbpwcf/zerossl::sslUpdater_cmd"),array("/qbpwcf/zerossl::sslUpdater_idle"));
6334
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
8521
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
6335
		$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("cName","certInfo","rrFile","dnsSerAddr","actionAfterUpdateCert");
8522
		$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("cName","certInfo","rrFile","dnsSerAddr","actionAfterUpdateCert");
6336
		#參考資料來源:
8523
		#參考資料來源:
6337
		#array_keys=>http://php.net/manual/en/function.array-keys.php
8524
		#array_keys=>http://php.net/manual/en/function.array-keys.php
6338
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
8525
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
Line 6395... Line 8582...
6395
 
8582
 
6396
				#回傳結果
8583
				#回傳結果
6397
				return $result;
8584
				return $result;
6398
			
8585
			
6399
				}#if end
8586
				}#if end
6400
				
-
 
6401
			#檢查 certInfo
-
 
6402
			foreach($certInfo[$index] as $cInfo){
-
 
6403
			
8587
			
6404
				#如果沒有設定 certPath
8588
			#檢查 $conf["certInfo"][$index] 是否資訊都有存在
6405
				if(!isset($cInfo["certPath"])){
8589
			#函式說明:
-
 
8590
			#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
6406
				
8591
			#回傳結果:
-
 
8592
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
8593
			#$result["error"],執行不正常結束的錯訊息陣列.
-
 
8594
			#$result["simpleError"],簡單表示的錯誤訊息.
-
 
8595
			#$result["function"],當前執行的函式名稱.
6407
					#初始化為 ${cName}-cerfificate.crt
8596
			#$result["argu"],設置給予的參數.
-
 
8597
			#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
8598
			#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
8599
			#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
8600
			#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
8601
			#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
8602
			#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
8603
			#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
6408
					$cInfo["certPath"]=$conf["cName"][$index]."-certificate.crt";
8604
			#$result["notNeedVar"],字串陣列,多餘的參數名稱.
6409
				
8605
			#必填參數:
-
 
8606
			#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
8607
			$conf["variableCheck::checkArguments"]["varInput"]=&$conf["certInfo"][$index];
-
 
8608
			#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
8609
			$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
6410
					}#if end
8610
			#可省略參數:
-
 
8611
			#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
8612
			#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("certPath","pKey","caPath","certWithCaPath");
6411
					
8613
			#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
-
 
8614
			#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array","array","array");
-
 
8615
			#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
8616
			#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
-
 
8617
			#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
6412
				#如果沒有設定 pKey
8618
			#$conf["canNotBeEmpty"]=array();
-
 
8619
			#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
6413
				if(!isset($cInfo["pKey"])){
8620
			#$conf["canBeEmpty"]=array();
6414
				
-
 
-
 
8621
			#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
-
 
8622
			$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("true","true","true","true");
-
 
8623
			#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
8624
			$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("certPath","pKey","caPath","certWithCaPath");
-
 
8625
			#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
8626
			$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
-
 
8627
			#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
8628
			$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($conf["cName"][$index]."-certificate.crt",$conf["cName"][$index]."-private.key",$conf["cName"][$index]."-ca_bundle.crt",$conf["cName"][$index]."-certWithCaPath.crt");
-
 
8629
			#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
6415
					#初始化為 ${cName}-private.key
8630
			#$conf["disallowAllSkipableVarIsEmpty"]="";
-
 
8631
			#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
6416
					$cInfo["pKey"]=$conf["cName"][$index]."-private.key";
8632
			#$conf["disallowAllSkipableVarIsEmptyArray"]="";
-
 
8633
			#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
-
 
8634
			#$conf["disallowAllSkipableVarNotExist"]="";
-
 
8635
			#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
8636
			#$conf["arrayCountEqualCheck"][]=array();
-
 
8637
			#參考資料:
-
 
8638
			#array_keys=>http://php.net/manual/en/function.array-keys.php
6417
				
8639
			#備註:
6418
					}#if end
8640
			#無.
-
 
8641
			$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
8642
			unset($conf["variableCheck::checkArguments"]);
6419
					
8643
			
6420
				#如果沒有設定 caPath
8644
			#如果檢查失敗
6421
				if(!isset($cInfo["caPath"])){
8645
			if($checkArguments["status"]==="false"){
6422
				
8646
 
-
 
8647
				#設置錯誤識別
6423
					#初始化為 ${cName}-ca_bundle.crt"
8648
				$result["status"]="false";
-
 
8649
 
-
 
8650
				#設置錯誤訊息
6424
					$cInfo["caPath"]=$conf["cName"][$index]."-ca_bundle.crt";
8651
				$result["error"]=$checkArguments;
-
 
8652
 
-
 
8653
				#回傳結果
-
 
8654
				return $result;
6425
				
8655
 
6426
					}#if end
8656
				}#if end
6427
					
8657
 
6428
				#如果沒有設定 certWithCaPath
8658
			#如果檢查不通過
6429
				if(!isset($cInfo["certWithCaPath"])){
8659
			if($checkArguments["passed"]==="false"){
6430
				
8660
 
-
 
8661
				#設置錯誤識別
6431
					#初始化為 ${cName}-certWithCaPath.crt"
8662
				$result["status"]="false";
-
 
8663
 
-
 
8664
				#設置錯誤訊息
6432
					$cInfo["certWithCaPath"]=$conf["cName"][$index]."-certWithCaPath.crt";
8665
				$result["error"]=$checkArguments;
-
 
8666
 
-
 
8667
				#回傳結果
-
 
8668
				return $result;
6433
				
8669
 
6434
					}#if end
8670
				}#if end
6435
					
8671
			
6436
				#儲存 cName
8672
			#儲存 cName
6437
				$cInfo["cName"]=$cName;
8673
			$cInfo["cName"]=$cName;
6438
				
-
 
6439
				#儲存 RR 檔案的路徑與名稱
-
 
6440
				$cInfo["rrFile"]=$conf["rrFile"][$index];
-
 
6441
				
8674
				
6442
				#儲存 cName 對應的 dns server addr
8675
			#儲存 RR 檔案的路徑與名稱
6443
				$cInfo["dnsSerAddr"]=$conf["dnsSerAddr"][$index];
8676
			$cInfo["rrFile"]=$conf["rrFile"][$index];
6444
				
8677
				
6445
				#儲存 cName 的憑證更新後要做的事情.
8678
			#儲存 cName 對應的 dns server addr
6446
				$cInfo["actionAfterUpdateCert"]=$conf["actionAfterUpdateCert"][$index];
8679
			$cInfo["dnsSerAddr"]=$conf["dnsSerAddr"][$index];
6447
				
8680
				
6448
				#儲存 certInfo
8681
			#儲存 cName 的憑證更新後要做的事情.
6449
				$share["certInfo"][]=$cInfo;
8682
			$cInfo["actionAfterUpdateCert"]=$conf["actionAfterUpdateCert"][$index];
6450
			
8683
			
-
 
8684
			#設置 certPath
-
 
8685
			$cInfo["ssl"]["certPath"]=$conf["certInfo"][$index]["certPath"];
-
 
8686
			
-
 
8687
			#設置 pKey
-
 
8688
			$cInfo["ssl"]["pKey"]=$conf["certInfo"][$index]["pKey"];
-
 
8689
			
6451
				}#foreach end
8690
			#設置 caPath
-
 
8691
			$cInfo["ssl"]["caPath"]=$conf["certInfo"][$index]["caPath"];
-
 
8692
			
-
 
8693
			#設置 certWithCaPath
-
 
8694
			$cInfo["ssl"]["certWithCaPath"]=$conf["certInfo"][$index]["certWithCaPath"];
-
 
8695
			
-
 
8696
			#儲存 certInfo
-
 
8697
			$share["certInfo"][]=$cInfo;
6452
			
8698
			
6453
			}#foreach end
8699
			}#foreach end
6454
			
8700
			
6455
		#如果為空
8701
		#如果為空
6456
		if(empty($share["certInfo"])){
8702
		if(empty($share["certInfo"])){
Line 6479... Line 8725...
6479
		#$result["serverCache"]["serverSide"],server side 的 cache.
8725
		#$result["serverCache"]["serverSide"],server side 的 cache.
6480
		#$result["serverCache"]["serverSide"]["procs"], server side 的 procs cache,儲存執行的子程序資訊.
8726
		#$result["serverCache"]["serverSide"]["procs"], server side 的 procs cache,儲存執行的子程序資訊.
6481
		#$result["serverCache"]["clientSide"],client site 的 cache.
8727
		#$result["serverCache"]["clientSide"],client site 的 cache.
6482
		#必填參數:
8728
		#必填參數:
6483
		#$conf["sock"],字串,socket檔案要放在哪邊,名稱為何.
8729
		#$conf["sock"],字串,socket檔案要放在哪邊,名稱為何.
6484
		$conf["sock::unixDomainSockServer"]["sock"]=$unixSocket;
8730
		$conf["sock::unixDomainSockServer"]["sock"]=$conf["sock"];
6485
		#$conf["fileArgu"],字串,變數__FILE__的內容.
8731
		#$conf["fileArgu"],字串,變數__FILE__的內容.
6486
		$conf["sock::unixDomainSockServer"]["fileArgu"]=__FILE__;
8732
		$conf["sock::unixDomainSockServer"]["fileArgu"]=__FILE__;
6487
		#可省略參數:
8733
		#可省略參數:
6488
		#$conf["changeOwner"],字串,要將socket檔案的擁有着權限進行修改."user.group"代表擁有者帳號為user,群組為group.
8734
		#$conf["changeOwner"],字串,要將socket檔案的擁有着權限進行修改."user.group"代表擁有者帳號為user,群組為group.
6489
		$conf["sock::unixDomainSockServer"]["changeOwner"]=webUser.".".webUser;
8735
		$conf["sock::unixDomainSockServer"]["changeOwner"]=webUser.".".webUser;
6490
		#$conf["changePermission"],字串,要將socket檔案的權限設為多少.ex: "0666"(所有帳戶都有存取的權限) 或 "0660"(僅有擁有者與群組帳戶有存取的權限) 或 "0600"(只有擁有者有權限執行).
8736
		#$conf["changePermission"],字串,要將socket檔案的權限設為多少.ex: "0666"(所有帳戶都有存取的權限) 或 "0660"(僅有擁有者與群組帳戶有存取的權限) 或 "0600"(只有擁有者有權限執行).
6491
		$conf["sock::unixDomainSockServer"]["changePermission"]="0770";
8737
		$conf["sock::unixDomainSockServer"]["changePermission"]="0770";
6492
		#$conf["sessionTimeout"],字串,當連線結束後於下一次連線間隔多久就算session timeout,server端會將記錄移除,client端需要重新拿取id,預設為300秒.
8738
		#$conf["sessionTimeout"],字串,當連線結束後於下一次連線間隔多久就算session timeout,server端會將記錄移除,client端需要重新拿取id,預設為300秒.
6493
		#$conf["sessionTimeout"]="300";
8739
		#$conf["sessionTimeout"]="300";
6494
		#$conf["addOnProcessFunc"],字串陣列,增加用於處理 json request 的函式名稱,給予的參數為array("request"=>收到的json訊息,"sock"=>用戶的socket,"clientCache"=>給予所有用戶的cache),若收到的不是json而是"quit"則代表用戶要結束連線;若收到的是$shutdownStr則代表要結束本函式.回傳的內容必須為陣列,例如 $res["continue"]="true"代表要繼續執行下一個addOnProcessFunc;"false"代表代表到此為止. $res["content"]="replaced content";代表要將收到的訊息取代成"replaced content". 最少要有回傳 $res["status"]數值"true"代表執行正常;"false"代表執行不正常.
8740
		#$conf["addOnProcessFunc"],字串陣列,增加用於處理 json request 的函式名稱,給予的參數為array("request"=>收到的json訊息,"sock"=>用戶的socket,"clientCache"=>給予所有用戶的cache),若收到的不是json而是"quit"則代表用戶要結束連線;若收到的是$shutdownStr則代表要結束本函式.回傳的內容必須為陣列,例如 $res["continue"]="true"代表要繼續執行下一個addOnProcessFunc;"false"代表代表到此為止. $res["content"]="replaced content";代表要將收到的訊息取代成"replaced content". 最少要有回傳 $res["status"]數值"true"代表執行正常;"false"代表執行不正常.
6495
		$conf["sock::unixDomainSockServer"]["addOnProcessFunc"]=array("/qbpwcf/zerossl::sslUpdater_cmd");
8741
		$conf["sock::unixDomainSockServer"]["addOnProcessFunc"]=array("\qbpwcf\zerossl::sslUpdater_cmd");
6496
		#$conf["funcToRunWhenIdle"],字串陣列,當沒有事件產生時,要執行的函式名稱,給予參數為array("client"=>所有用戶,"clientCache"=>$result["serverCache"]["clientSide"]["addOnProcessFunc"][$funcToRunWhenIdle],"serverCache"=>$result["serverCache"]["serverSide"]["funcToRunWhenIdle"][$funcToRunWhenIdle]).
8742
		#$conf["funcToRunWhenIdle"],字串陣列,當沒有事件產生時,要執行的函式名稱,給予參數為array("client"=>所有用戶,"clientCache"=>$result["serverCache"]["clientSide"]["addOnProcessFunc"][$funcToRunWhenIdle],"serverCache"=>$result["serverCache"]["serverSide"]["funcToRunWhenIdle"][$funcToRunWhenIdle]).
6497
		$conf["sock::unixDomainSockServer"]["funcToRunWhenIdle"]=array("/qbpwcf/zerossl::sslUpdater_idle");
8743
		$conf["sock::unixDomainSockServer"]["funcToRunWhenIdle"]=array("\qbpwcf\zerossl::sslUpdater_idle");
6498
		#$conf["paramsForFuncToRunWhenIdle"],2維陣列,每個元素代表指定給予funcToRunWhenIdle參數中的指定元素的參數.
8744
		#$conf["paramsForFuncToRunWhenIdle"],2維陣列,每個元素代表指定給予funcToRunWhenIdle參數中的指定元素的參數.
6499
		#$conf["paramsForFuncToRunWhenIdle"]=array();
8745
		#$conf["paramsForFuncToRunWhenIdle"]=array();
6500
		#$conf["infoToFunction"],陣列,需要增加給addOnProcessFunc跟funcToRunWhenIdle函式的資訊,在函式中其參數的info鍵值.
8746
		#$conf["infoToFunction"],陣列,需要增加給addOnProcessFunc跟funcToRunWhenIdle函式的資訊,在函式中其參數的info鍵值.
6501
		$conf["sock::unixDomainSockServer"]["infoToFunction"]=array("debug"=>$conf["debug"],"share"=>$share);
8747
		$conf["sock::unixDomainSockServer"]["infoToFunction"]=array("debug"=>$conf["debug"],"share"=>$share);
6502
		#$conf["shutdownStrAddr"],字串,儲存收到用戶傳什麼樣的字串會結束本函式的檔案位置與名稱,預設為 $conf["sock"].".shutdown".
8748
		#$conf["shutdownStrAddr"],字串,儲存收到用戶傳什麼樣的字串會結束本函式的檔案位置與名稱,預設為 $conf["sock"].".shutdown".
Line 6587... Line 8833...
6587
	#可省略參數:
8833
	#可省略參數:
6588
	#無.
8834
	#無.
6589
	#參考資料:
8835
	#參考資料:
6590
	#無.
8836
	#無.
6591
	#備註:
8837
	#備註:
6592
	#建構中...
8838
	#無.
6593
	*/
8839
	*/
6594
	public static function sslUpdater_idle(&$conf){
8840
	public static function sslUpdater_idle(&$conf){
6595
		
8841
		
6596
		#初始化要回傳的結果
8842
		#初始化要回傳的結果
6597
		$result=array();
8843
		$result=array();
Line 6640... Line 8886...
6640
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
8886
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
6641
		#必填寫的參數:
8887
		#必填寫的參數:
6642
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
8888
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
6643
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
8889
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
6644
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
8890
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
6645
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("client","clientCache","serverCache","info");
8891
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("client","serverCache","info");
6646
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
8892
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
6647
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array","array","array");
8893
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","array","array");
6648
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
8894
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
6649
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
8895
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
6650
		#可以省略的參數:
8896
		#可以省略的參數:
6651
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
8897
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
6652
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
8898
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
Line 6695... Line 8941...
6695
		
8941
		
6696
		#預設不開啟 debug flag
8942
		#預設不開啟 debug flag
6697
		$debug=false;
8943
		$debug=false;
6698
		
8944
		
6699
		#如果有設置 debug 為 "true"
8945
		#如果有設置 debug 為 "true"
6700
		if($info["share"]["debug"]==="true"){
8946
		if($conf["info"]["share"]["debug"]==="true"){
6701
		
8947
		
6702
			#設置 debug flag
8948
			#設置 debug flag
6703
			$debug=true;
8949
			$debug=true;
6704
		
8950
		
6705
			}#if end
8951
			}#if end
6706
		
8952
		
6707
		#另存 server cache 的參考
8953
		#另存 server cache 的參考
6708
		$serverCache=&$conf["serverCache"];
8954
		$serverCache=&$conf["serverCache"];
6709
		
8955
		
6710
		#針對每個 domain name
8956
		#針對每個 domain name
6711
		foreach($info["share"]["certInfo"] as $cInfo){
8957
		foreach($conf["info"]["share"]["certInfo"] as $certInfoIndex=>$cInfo){
6712
		
8958
		
6713
			#取得domain name
8959
			#取得domain name
6714
			$cName=$cInfo["cName"];
8960
			$cName=$cInfo["cName"];
6715
		
8961
		
6716
			#如果尚無對應domain name的記錄
8962
			#如果尚無對應domain name的記錄
6717
			if(!isset($serverCache[$cName])){
8963
			if(!isset($serverCache[$cName])){
6718
			
8964
			
6719
				#設置最新一次檢測的unixtime
8965
				#設置最新一次檢測的unixtime
6720
				$serverCache[$cName]["lastCheckUnixTime"]=time();
8966
				$serverCache[$cName]["lastCheckUnixTime"]=time();
6721
			
8967
				
6722
				}#if end
8968
				}#if end
6723
				
8969
				
6724
			#反之距離上次檢查不滿一天
8970
			#反之距離上次檢查不滿一天
6725
			else if(time()-$serverCache[$cName]["lastCheckUnixTime"]<86400){
8971
			else{
6726
			
8972
			
6727
				#跳過該 domain name 的檢查
8973
				#計算距離上次檢查多少秒
6728
				continue;
8974
				$checkedAfter=time()-$serverCache[$cName]["lastCheckUnixTime"];
6729
			
8975
			
-
 
8976
				#若距離上次檢查不滿一天
-
 
8977
				if($checkedAfter<86400){
-
 
8978
			
-
 
8979
					#if enable debug
-
 
8980
					if($debug){
-
 
8981
					
-
 
8982
						#debug msg
-
 
8983
						echo "Domain name(".$cName.") on zerossl require to check in ".(86400-$checkedAfter)." second(s).".PHP_EOL;
-
 
8984
					
-
 
8985
						}#if end
-
 
8986
			
-
 
8987
					#跳過該 domain name 的檢查
-
 
8988
					continue;
-
 
8989
			
6730
				}#if end
8990
					}#if end
-
 
8991
				
-
 
8992
				}#else end
6731
		
8993
		
6732
			#if enable debug
8994
			#if enable debug
6733
			if($debug){
8995
			if($debug){
6734
			
8996
			
6735
				#debug msg
8997
				#debug msg
6736
				echo "Checking domain name(".$cInfo["apiDomain"].") on zerossl...".PHP_EOL;
8998
				echo "Checking domain name(".$cName.") on zerossl...".PHP_EOL;
6737
			
8999
			
6738
				}#if end
9000
				}#if end
6739
		
9001
		
-
 
9002
			#certPath
-
 
9003
			#$cInfo["ssl"]["certPath"];
-
 
9004
			
-
 
9005
			#pKey
-
 
9006
			#$cInfo["ssl"]["pKey"];
-
 
9007
			
-
 
9008
			#caPath
-
 
9009
			#$cInfo["ssl"]["caPath"]=;
-
 
9010
			
-
 
9011
			#certWithCaPath
-
 
9012
			#$cInfo["ssl"]["certWithCaPath"];
-
 
9013
		
6740
			#嘗試取得 domain name 對應的可用憑證
9014
			#嘗試取得 domain name 對應的可用憑證
6741
			#函式說明:
9015
			#函式說明:
6742
			#取得在zerossl上的CSR清單
9016
			#取得在zerossl上的CSR清單
6743
			#回傳結果:
9017
			#回傳結果:
6744
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9018
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 6757... Line 9031...
6757
			#$result["certs"][$cerId]["status"],該certificate憑證的狀態,可能的數值有:"draft"代表尚未驗證;"pending_validation"代表zerossl尚在產生憑證;"issued"代表已經可以下載來使用;"revoked"代表已經廢除;"cancelled"代表已經取消且未驗證;"expired"代表已經過期.
9031
			#$result["certs"][$cerId]["status"],該certificate憑證的狀態,可能的數值有:"draft"代表尚未驗證;"pending_validation"代表zerossl尚在產生憑證;"issued"代表已經可以下載來使用;"revoked"代表已經廢除;"cancelled"代表已經取消且未驗證;"expired"代表已經過期.
6758
			#必填參數:
9032
			#必填參數:
6759
			#無
9033
			#無
6760
			#可省略參數:
9034
			#可省略參數:
6761
			#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
9035
			#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
6762
			$conf["zerossl::getCertList"]["apiDomain"]=$cInfo["apiDomain"];
9036
			$conf["zerossl::getCertList"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
6763
			#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
9037
			#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
6764
			$conf["zerossl::getCertList"]["key"]=$cInfo["key"];
9038
			$conf["zerossl::getCertList"]["key"]=$conf["info"]["share"]["key"];
6765
			#$conf["cerStatus"],字串,需要取得的certificate狀態,預設為全部,若要多個狀態,可用","區隔,可以用的狀態有"draft"代表尚未驗證;"pending_validation"代表zerossl尚在產生憑證;"issued"代表已經可以下載來使用;"revoked"代表已經廢除;"cancelled"代表已經取消且未驗證;"expired"代表已經過期.
9039
			#$conf["cerStatus"],字串,需要取得的certificate狀態,預設為全部,若要多個狀態,可用","區隔,可以用的狀態有"draft"代表尚未驗證;"pending_validation"代表zerossl尚在產生憑證;"issued"代表已經可以下載來使用;"revoked"代表已經廢除;"cancelled"代表已經取消且未驗證;"expired"代表已經過期.
6766
			$conf["zerossl::getCertList"]["cerStatus"]="issued";
9040
			$conf["zerossl::getCertList"]["cerStatus"]="issued";
6767
			#$conf["cerType"],字串,需要取得的certificate類型,預設為不篩選,可以用的類型有"single90Days"代表單一domain90天效期的;"wildcard90Days"代表所有子網域90效期的;”multiDomain90Days“多個domain90天效期的;"single1Year"單一domain一年效期的;"wildcard1Year"所有子網域一年效期的;"multiDomain1Year"多個網域一年效期的;"acme90Days"透過acme取得的90天效期.
9041
			#$conf["cerType"],字串,需要取得的certificate類型,預設為不篩選,可以用的類型有"single90Days"代表單一domain90天效期的;"wildcard90Days"代表所有子網域90效期的;”multiDomain90Days“多個domain90天效期的;"single1Year"單一domain一年效期的;"wildcard1Year"所有子網域一年效期的;"multiDomain1Year"多個網域一年效期的;"acme90Days"透過acme取得的90天效期.
6768
			$conf["zerossl::getCertList"]["cerType"]="single90Days";
9042
			$conf["zerossl::getCertList"]["cerType"]="single90Days";
6769
			#$conf["search"],字串,透過certificate包含的domain來搜尋.
9043
			#$conf["search"],字串,透過certificate包含的domain來搜尋.
Line 6796... Line 9070...
6796
 
9070
 
6797
				#回傳結果
9071
				#回傳結果
6798
				return $result;
9072
				return $result;
6799
			
9073
			
6800
				}#if end
9074
				}#if end
6801
				
9075
			
6802
			#如果沒有憑證
9076
			#如果沒有憑證
6803
			if($getCertList["count"]==="0"){
9077
			if($getCertList["count"]===0){
6804
			
9078
			
6805
				#if enable debug
9079
				#if enable debug
6806
				if($debug){
9080
				if($debug){
6807
				
9081
				
6808
					#debug msg
9082
					#debug msg
6809
					echo "There is not valid ssl for domain name(".$cInfo["apiDomain"].") on zerossl.".PHP_EOL;
9083
					echo "There is not valid ssl for domain name(".$cName.") on zerossl.".PHP_EOL;
6810
				
9084
				
6811
					}#if end
9085
					}#if end
6812
			
9086
			
6813
				#if enable debug
9087
				#if enable debug
6814
				if($debug){
9088
				if($debug){
6815
				
9089
				
6816
					#debug msg
9090
					#debug msg
6817
					echo "Checking ssl private key for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
9091
					echo "Checking ssl private key for domain name(".$cName.")...".PHP_EOL;
6818
				
9092
				
6819
					}#if end
9093
					}#if end
6820
			
9094
			
6821
				#確認有無對應 cName 的 private key
9095
				#確認有無對應 cName 的 private key
6822
				#函式說明:
9096
				#函式說明:
Line 6831... Line 9105...
6831
				#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
9105
				#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
6832
				#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
9106
				#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
6833
				#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
9107
				#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
6834
				#必填參數:
9108
				#必填參數:
6835
				#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
9109
				#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
6836
				$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($cInfo["pKey"]);
9110
				$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["info"]["share"]["ssl"]["pKey"]);
6837
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9111
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6838
				$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=__FILE__;
9112
				$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=__FILE__;
6839
				#可省略參數:
9113
				#可省略參數:
6840
				#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
9114
				#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
6841
				#$conf["disableWebSearch"]="false";
9115
				#$conf["disableWebSearch"]="false";
Line 6871... Line 9145...
6871
				
9145
				
6872
					#if enable debug
9146
					#if enable debug
6873
					if($debug){
9147
					if($debug){
6874
					
9148
					
6875
						#debug msg
9149
						#debug msg
6876
						echo "there is no ssl private key for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
9150
						echo "there is no ssl private key for domain name(".$cName.")...".PHP_EOL;
6877
					
9151
					
6878
						}#if end
9152
						}#if end
6879
						
9153
						
6880
					#if enable debug
9154
					#if enable debug
6881
					if($debug){
9155
					if($debug){
6882
					
9156
					
6883
						#debug msg
9157
						#debug msg
6884
						echo "creating ssl private key for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
9158
						echo "creating ssl private key for domain name(".$cName.")...".PHP_EOL;
6885
					
9159
					
6886
						}#if end
9160
						}#if end
6887
				
9161
				
6888
					#建立 private key
9162
					#建立 private key
6889
					#函式說明:
9163
					#函式說明:
Line 6903... Line 9177...
6903
					#$conf["length"]=4096';
9177
					#$conf["length"]=4096';
6904
					#參考資料:
9178
					#參考資料:
6905
					#無.
9179
					#無.
6906
					#備註:
9180
					#備註:
6907
					#key generated by openssl with RSA.
9181
					#key generated by openssl with RSA.
6908
					$createPrivateKey=openssl::createPrivateKey($conf["openssl::createPrivateKey"]);
9182
					$createPrivateKey=zerossl::createPrivateKey($conf["openssl::createPrivateKey"]);
6909
					unset($conf["openssl::createPrivateKey"]);
9183
					unset($conf["openssl::createPrivateKey"]);
6910
				
9184
				
6911
					#如果運行異常
9185
					#如果運行異常
6912
					if($createPrivateKey["status"]==="false"){
9186
					if($createPrivateKey["status"]==="false"){
6913
					
9187
					
Line 6940... Line 9214...
6940
					#必填參數:
9214
					#必填參數:
6941
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9215
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6942
					$conf["zerossl::writeTextIntoFile"]["fileArgu"]=__FILE__;
9216
					$conf["zerossl::writeTextIntoFile"]["fileArgu"]=__FILE__;
6943
					#可省略參數:
9217
					#可省略參數:
6944
					#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
9218
					#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
6945
					$conf["zerossl::writeTextIntoFile"]["fileName"]=$cInfo["pKey"];
9219
					$conf["zerossl::writeTextIntoFile"]["fileName"]=$conf["info"]["share"]["ssl"]["pKey"];
6946
					#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
9220
					#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
6947
					$conf["zerossl::writeTextIntoFile"]["inputString"]=$pKeyStr;
9221
					$conf["zerossl::writeTextIntoFile"]["inputString"]=$pKeyStr;
6948
					#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
9222
					#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
6949
					#$conf["writeMethod"]="a";
9223
					#$conf["writeMethod"]="a";
6950
					#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
9224
					#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
Line 6957... Line 9231...
6957
					$conf["zerossl::writeTextIntoFile"]["web"]="false";
9231
					$conf["zerossl::writeTextIntoFile"]["web"]="false";
6958
					#參考資料:
9232
					#參考資料:
6959
					#無.
9233
					#無.
6960
					#備註:
9234
					#備註:
6961
					#無.
9235
					#無.
6962
					$writeTextIntoFile=zerossl::writeTextIntoFile($conf["zerossl::writeTextIntoFile"]);
9236
					$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["zerossl::writeTextIntoFile"]);
6963
					unset($conf["zerossl::writeTextIntoFile"]);
9237
					unset($conf["zerossl::writeTextIntoFile"]);
6964
				
9238
				
6965
					#如果運行異常
9239
					#如果運行異常
6966
					if($writeTextIntoFile["status"]==="false"){
9240
					if($writeTextIntoFile["status"]==="false"){
6967
					
9241
					
Line 6980... Line 9254...
6980
				
9254
				
6981
				#if enable debug
9255
				#if enable debug
6982
				if($debug){
9256
				if($debug){
6983
				
9257
				
6984
					#debug msg
9258
					#debug msg
6985
					echo "Creating domain name(".$cInfo["apiDomain"].") csr for zerossl...".PHP_EOL;
9259
					echo "Creating domain name(".$conf["info"]["share"]["apiDomain"].") csr for zerossl...".PHP_EOL;
6986
				
9260
				
6987
					}#if end
9261
					}#if end
6988
				
9262
				
6989
				#建立準備給zerossl的csr
9263
				#建立準備給zerossl的csr
6990
				#函式說明:
9264
				#函式說明:
Line 7037... Line 9311...
7037
				
9311
				
7038
				#if enable debug
9312
				#if enable debug
7039
				if($debug){
9313
				if($debug){
7040
				
9314
				
7041
					#debug msg
9315
					#debug msg
7042
					echo "Creating certificate for domain name(".$cInfo["apiDomain"].") on zerossl...".PHP_EOL;
9316
					echo "Creating certificate for domain name(".$cName.") on zerossl...".PHP_EOL;
7043
				
9317
				
7044
					}#if end
9318
					}#if end
7045
				
9319
				
7046
				#函式說明:
9320
				#函式說明:
7047
				#提供certificate sign request(CSR)透過zerossl產生certificate.
9321
				#提供certificate sign request(CSR)透過zerossl產生certificate.
Line 7062... Line 9336...
7062
				$conf["zerossl::createCertificate"]["certificate_csr"]=$csrLocal;
9336
				$conf["zerossl::createCertificate"]["certificate_csr"]=$csrLocal;
7063
				#$conf["fileArgu"],字串,變數__FILE__的內容.
9337
				#$conf["fileArgu"],字串,變數__FILE__的內容.
7064
				$conf["zerossl::createCertificate"]["fileArgu"]=__FILE__;
9338
				$conf["zerossl::createCertificate"]["fileArgu"]=__FILE__;
7065
				#可省略參數:
9339
				#可省略參數:
7066
				#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
9340
				#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
7067
				$conf["zerossl::createCertificate"]["apiDomain"]=$cInfo["domain"];
9341
				$conf["zerossl::createCertificate"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
7068
				#$conf["path"],字串,提供服務的path,預設為 self::getApiInfo()["csrPath"].
9342
				#$conf["path"],字串,提供服務的path,預設為 self::getApiInfo()["csrPath"].
7069
				#$conf["path"]=self::getApiInfo()["csrPath"];
9343
				#$conf["path"]=self::getApiInfo()["csrPath"];
7070
				#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
9344
				#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
7071
				$conf["zerossl::createCertificate"]["key"]=$cInfo["key"];
9345
				$conf["zerossl::createCertificate"]["key"]=$conf["info"]["share"]["key"];
7072
				#參考資料:
9346
				#參考資料:
7073
				#無.
9347
				#無.
7074
				#備註:
9348
				#備註:
7075
				#無.
9349
				#無.
7076
				$createCertificate=zerossl::createCertificate($conf["zerossl::createCertificate"]);
9350
				$createCertificate=zerossl::createCertificate($conf["zerossl::createCertificate"]);
Line 7116... Line 9390...
7116
				
9390
				
7117
				#if enable debug
9391
				#if enable debug
7118
				if($debug){
9392
				if($debug){
7119
				
9393
				
7120
					#debug msg
9394
					#debug msg
7121
					echo "Adding DNS record to validate certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
9395
					echo "Adding DNS record to validate certificate for domain name(".$cName.")".PHP_EOL;
7122
				
9396
				
7123
					}#if end
9397
					}#if end
7124
				
9398
				
7125
				#函式說明:
9399
				#函式說明:
7126
				#新增DNS記錄到檔案裡面.
9400
				#新增DNS記錄到檔案裡面.
Line 7133... Line 9407...
7133
				#$result["domain"],字串,RR所屬domain.
9407
				#$result["domain"],字串,RR所屬domain.
7134
				#$result["defaultTTL"],字串,預設的RR更新時間.
9408
				#$result["defaultTTL"],字串,預設的RR更新時間.
7135
				#$result["comment"],字串陣列,逐行的註解.
9409
				#$result["comment"],字串陣列,逐行的註解.
7136
				#必填參數:
9410
				#必填參數:
7137
				#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
9411
				#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
7138
				$conf["zerossl::updateDnsRecordFile"]["add"]=array($rr2ad);
9412
				$conf["zerossl::updateDnsRecordFile"]["add"]=array($rr2add);
7139
				#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
9413
				#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
7140
				$conf["zerossl::updateDnsRecordFile"]["dnsRecordFile"]=$cInfo["rrFile"];
9414
				$conf["zerossl::updateDnsRecordFile"]["dnsRecordFile"]=$cInfo["rrFile"];
7141
				#可省略參數:
9415
				#可省略參數:
7142
				#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
9416
				#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
7143
				$conf["zerossl::updateDnsRecordFile"]["writeNow"]="true";
9417
				$conf["zerossl::updateDnsRecordFile"]["writeNow"]="true";
Line 7168... Line 9442...
7168
				
9442
				
7169
				#if enable debug
9443
				#if enable debug
7170
				if($debug){
9444
				if($debug){
7171
				
9445
				
7172
					#debug msg
9446
					#debug msg
7173
					echo "Restart DNS service to validate certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
9447
					echo "Restart DNS service to validate certificate for domain name(".$cName.")".PHP_EOL;
7174
				
9448
				
7175
					}#if end
9449
					}#if end
7176
				
9450
				
7177
				#重新啟動dns伺服器
9451
				#重新啟動dns伺服器
7178
				#函式說明:
9452
				#函式說明:
Line 7192... Line 9466...
7192
				#$result["statusCode"],執行結束後的代碼.
9466
				#$result["statusCode"],執行結束後的代碼.
7193
				#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
9467
				#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
7194
				#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
9468
				#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
7195
				#必填參數:
9469
				#必填參數:
7196
				#$conf["command"],字串,要執行的指令.
9470
				#$conf["command"],字串,要執行的指令.
7197
				$conf["external::callShell"]["command"]="systemd";
9471
				$conf["external::callShell"]["command"]="systemctl";
7198
				#$conf["fileArgu"],字串,變數__FILE__的內容.
9472
				#$conf["fileArgu"],字串,變數__FILE__的內容.
7199
				$conf["external::callShell"]["fileArgu"]=__FILE__;
9473
				$conf["external::callShell"]["fileArgu"]=__FILE__;
7200
				#可省略參數:
9474
				#可省略參數:
7201
				#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
9475
				#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
7202
				$conf["external::callShell"]["argu"]=array("restart","named");
9476
				$conf["external::callShell"]["argu"]=array("restart","named");
Line 7257... Line 9531...
7257
				
9531
				
7258
				#if enable debug
9532
				#if enable debug
7259
				if($debug){
9533
				if($debug){
7260
				
9534
				
7261
					#debug msg
9535
					#debug msg
7262
					echo "Request zerossl to validate certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
9536
					echo "Request zerossl to validate certificate for domain name(".$cName.")".PHP_EOL;
7263
				
9537
				
7264
					}#if end
9538
					}#if end
7265
				
9539
				
7266
				#函式說明:
9540
				#函式說明:
7267
				#請求驗證已經透過zerossl::createCertificate要求的domain.
9541
				#請求驗證已經透過zerossl::createCertificate要求的domain.
Line 7275... Line 9549...
7275
				#必填參數:
9549
				#必填參數:
7276
				#$conf["id"],字串,zerossl::createCertificate回傳的id.
9550
				#$conf["id"],字串,zerossl::createCertificate回傳的id.
7277
				$conf["zerossl::verifyDomain"]["id"]=$csrId;
9551
				$conf["zerossl::verifyDomain"]["id"]=$csrId;
7278
				#可省略參數:
9552
				#可省略參數:
7279
				#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
9553
				#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
7280
				$conf["zerossl::verifyDomain"]["apiDomain"]=$cInfo["domain"];
9554
				$conf["zerossl::verifyDomain"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
7281
				#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
9555
				#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
7282
				$conf["zerossl::verifyDomain"]["key"]=$cInfo["key"];
9556
				$conf["zerossl::verifyDomain"]["key"]=$conf["info"]["share"]["key"];
7283
				#參考資料:
9557
				#參考資料:
7284
				#https://zerossl.com/documentation/api/verify-domains/
9558
				#https://zerossl.com/documentation/api/verify-domains/
7285
				#備註:
9559
				#備註:
7286
				#無.
9560
				#無.
7287
				$verifyDomain=zerossl::verifyDomain($conf["zerossl::verifyDomain"]);
9561
				$verifyDomain=zerossl::verifyDomain($conf["zerossl::verifyDomain"]);
Line 7298... Line 9572...
7298
 
9572
 
7299
					#回傳結果
9573
					#回傳結果
7300
					return $result;
9574
					return $result;
7301
				
9575
				
7302
					}#if end
9576
					}#if end
-
 
9577
					
-
 
9578
				#如果沒有回內容
-
 
9579
				if(!isset($verifyDomain["content"][0])){
-
 
9580
				
-
 
9581
					#設置錯誤識別
-
 
9582
					$result["status"]="false";
-
 
9583
 
-
 
9584
					#設置錯誤訊息
-
 
9585
					$result["error"]=$verifyDomain;
-
 
9586
 
-
 
9587
					#回傳結果
-
 
9588
					return $result;
-
 
9589
				
-
 
9590
					}#if end
-
 
9591
				
-
 
9592
				#如果回應不是 json
-
 
9593
				if(!(json_validate($verifyDomain["content"][0]))){
-
 
9594
				
-
 
9595
					#設置錯誤識別
-
 
9596
					$result["status"]="false";
-
 
9597
 
-
 
9598
					#設置錯誤訊息
-
 
9599
					$result["error"]=$verifyDomain;
-
 
9600
 
-
 
9601
					#回傳結果
-
 
9602
					return $result;
-
 
9603
				
-
 
9604
					}#if end
-
 
9605
				
-
 
9606
				/*
-
 
9607
				範例json:
-
 
9608
				{"id":"51cff04454e6a6860abfecc8072db602","type":"1","common_name":"silverblue-guest.qbpwcf.org","additional_domains":"","created":"2026-03-06 13:45:39","expires":"2026-06-04 23:59:59","status":"pending_validation","validation_type":"CNAME_CSR_HASH","validation_emails":"","replacement_for":"","fingerprint_sha1":null,"brand_validation":null,"validation":{"email_validation":{"silverblue-guest.qbpwcf.org":["admin@silverblue-guest.qbpwcf.org","administrator@silverblue-guest.qbpwcf.org","hostmaster@silverblue-guest.qbpwcf.org","postmaster@silverblue-guest.qbpwcf.org","webmaster@silverblue-guest.qbpwcf.org","admin@qbpwcf.org","administrator@qbpwcf.org","hostmaster@qbpwcf.org","postmaster@qbpwcf.org","webmaster@qbpwcf.org"]},"other_methods":{"silverblue-guest.qbpwcf.org":{"file_validation_url_http":"http:\/\/silverblue-guest.qbpwcf.org\/.well-known\/pki-validation\/383346FA54F492EC8B2A6C421A052827.txt","file_validation_url_https":"https:\/\/silverblue-guest.qbpwcf.org\/.well-known\/pki-validation\/383346FA54F492EC8B2A6C421A052827.txt","file_validation_content":["58B9EB7890F754D041698170B22D22205D710ED09B419A809E5C92C38195DD36","comodoca.com","627e45f007045f0"],"cname_validation_p1":"_383346FA54F492EC8B2A6C421A052827.silverblue-guest.qbpwcf.org","cname_validation_p2":"58B9EB7890F754D041698170B22D2220.5D710ED09B419A809E5C92C38195DD36.627e45f007045f0.comodoca.com"}}},"signature_algorithm_properties":null}
-
 
9609
				*/
-
 
9610
				
-
 
9611
				#解析json回應
-
 
9612
				$verifyDomainRes=json_decode($verifyDomain["content"][0]);
-
 
9613
 
-
 
9614
				#如果是 zerossl 驗證失敗
-
 
9615
				if($verifyDomainRes->status==="false"){
-
 
9616
				
-
 
9617
					#如果是 CNAME 記錄找不到...
-
 
9618
				
-
 
9619
					#設置錯誤識別
-
 
9620
					$result["status"]="false";
-
 
9621
 
-
 
9622
					#設置錯誤訊息
-
 
9623
					$result["error"]=$verifyDomain;
-
 
9624
 
-
 
9625
					#回傳結果
-
 
9626
					return $result;
-
 
9627
				
-
 
9628
					}#if end
-
 
9629
 
-
 
9630
				#如果是 zerossl 尚在驗證中
-
 
9631
				if($verifyDomainRes->status==="pending_validation"){
-
 
9632
				
-
 
9633
					#if enable debug
-
 
9634
					if($debug){
-
 
9635
					
-
 
9636
						#debug msg
-
 
9637
						echo "Waiting zerossl to validate certificate for domain name(".$cName.")...".PHP_EOL;
-
 
9638
					
-
 
9639
						}#if end
-
 
9640
				
-
 
9641
					#無窮迴圈
-
 
9642
					while(true){
-
 
9643
				
-
 
9644
						#查詢驗證狀況
-
 
9645
						#函式說明:
-
 
9646
						#取得CSR在zerossl上的狀態
-
 
9647
						#回傳結果:
-
 
9648
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
9649
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
9650
						#$result["function"],當前執行的函式名稱.
-
 
9651
						#$result["argu"],所使用的參數.
-
 
9652
						#$result["curl_verbose_info"],curl執行的詳細資訊.
-
 
9653
						#$result["content"],結果json字串.
-
 
9654
						#$result["cerStatus"],csr在zerossl上的狀態,"draft"代表尚未驗證;"pending_validation"代表zerossl尚在產生憑證;"issued"代表已經可以下載來使用;"revoked"代表已經廢除;"cancelled"代表已經取消且未驗證;"expired"代表已經過期.
-
 
9655
						#必填參數:
-
 
9656
						#$conf["id"],字串,zerossl::createCertificate回傳的id.
-
 
9657
						$conf["zerossl::getCertSta"]["id"]=$csrId;
-
 
9658
						#可省略參數:
-
 
9659
						#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
-
 
9660
						$conf["zerossl::getCertSta"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
-
 
9661
						#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
-
 
9662
						$conf["zerossl::getCertSta"]["key"]=$conf["info"]["share"]["key"];
-
 
9663
						#參考資料:
-
 
9664
						#https://zerossl.com/documentation/api/get-certificate/
-
 
9665
						#備註:
-
 
9666
						#無.
-
 
9667
						$getCertSta=zerossl::getCertSta($conf["zerossl::getCertSta"]);
-
 
9668
						unset($conf["zerossl::getCertSta"]);
-
 
9669
						
-
 
9670
						#如果執行異常
-
 
9671
						if($getCertSta["status"]==="false"){
-
 
9672
						
-
 
9673
							#設置錯誤識別
-
 
9674
							$result["status"]="false";
-
 
9675
 
-
 
9676
							#設置錯誤訊息
-
 
9677
							$result["error"]=$getCertSta;
-
 
9678
 
-
 
9679
							#回傳結果
-
 
9680
							return $result;
-
 
9681
						
-
 
9682
							}#if end
-
 
9683
							
-
 
9684
						#如果沒有回應內容
-
 
9685
						if(!isset($getCertSta["content"][0])){
-
 
9686
						
-
 
9687
							#設置錯誤識別
-
 
9688
							$result["status"]="false";
-
 
9689
 
-
 
9690
							#設置錯誤訊息
-
 
9691
							$result["error"]=$getCertSta;
-
 
9692
 
-
 
9693
							#回傳結果
-
 
9694
							return $result;
-
 
9695
						
-
 
9696
							}#if end
-
 
9697
							
-
 
9698
						#如果回應不是 json
-
 
9699
						if(!(json_validate($getCertSta["content"][0]))){
-
 
9700
						
-
 
9701
							#設置錯誤識別
-
 
9702
							$result["status"]="false";
-
 
9703
 
-
 
9704
							#設置錯誤訊息
-
 
9705
							$result["error"]=$getCertSta;
-
 
9706
 
-
 
9707
							#回傳結果
-
 
9708
							return $result;
-
 
9709
						
-
 
9710
							}#if end
-
 
9711
							
-
 
9712
						#解析json回應
-
 
9713
						$getCertStaRes=json_decode($getCertSta["content"][0]);
-
 
9714
						
-
 
9715
						#如果憑證已經驗證通過了
-
 
9716
						if($getCertStaRes->status==="issued"){
-
 
9717
						
-
 
9718
							#if enable debug
-
 
9719
							if($debug){
-
 
9720
							
-
 
9721
								#debug msg
-
 
9722
								echo "Zerossl validated certificate for domain name(".$cName.").".PHP_EOL;
-
 
9723
							
-
 
9724
								}#if end
-
 
9725
						
-
 
9726
							#結束等待
-
 
9727
							break;
-
 
9728
						
-
 
9729
							}#if end
-
 
9730
							
-
 
9731
						#如果 zerossl 尚在處理中
-
 
9732
						else if($getCertStaRes->status==="pending_validation"){
-
 
9733
						
-
 
9734
							#if enable debug
-
 
9735
							if($debug){
-
 
9736
							
-
 
9737
								#debug msg
-
 
9738
								echo "Waiting zerossl to validate certificate for domain name(".$cName.")...".PHP_EOL;
-
 
9739
							
-
 
9740
								}#if end
-
 
9741
								
-
 
9742
							#休息1分鐘
-
 
9743
							sleep(60);
-
 
9744
						
-
 
9745
							}#if end
-
 
9746
						
-
 
9747
						#反之
-
 
9748
						else{
-
 
9749
						
-
 
9750
							#例外狀況
-
 
9751
							
-
 
9752
							#設置錯誤識別
-
 
9753
							$result["status"]="false";
-
 
9754
 
-
 
9755
							#設置錯誤訊息
-
 
9756
							$result["error"]=$getCertSta;
-
 
9757
 
-
 
9758
							#回傳結果
-
 
9759
							return $result;
-
 
9760
						
-
 
9761
							}#else end
-
 
9762
 
-
 
9763
						}#while end
7303
				
9764
				
-
 
9765
					}#if end
-
 
9766
 
7304
				#if enable debug
9767
				#if enable debug
7305
				if($debug){
9768
				if($debug){
7306
				
9769
				
7307
					#debug msg
9770
					#debug msg
7308
					echo "Downloading certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
9771
					echo "Downloading certificate for domain name(".$cName.")".PHP_EOL;
7309
				
9772
				
7310
					}#if end
9773
					}#if end
7311
				
9774
				
7312
				#函式說明:
9775
				#函式說明:
7313
				#下載certificate.
9776
				#下載certificate.
Line 7322... Line 9785...
7322
				#$result["ca_bundle.crt"],字串,ca_bundle.crt的內容.
9785
				#$result["ca_bundle.crt"],字串,ca_bundle.crt的內容.
7323
				#必填參數:
9786
				#必填參數:
7324
				#無.
9787
				#無.
7325
				#可省略參數:
9788
				#可省略參數:
7326
				#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
9789
				#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
7327
				$conf["zerossl::getCert"]["apiDomain"]=$cInfo["domain"];
9790
				$conf["zerossl::getCert"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
7328
				#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
9791
				#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
7329
				$conf["zerossl::getCert"]["key"]=$cInfo["key"];
9792
				$conf["zerossl::getCert"]["key"]=$conf["info"]["share"]["key"];
7330
				#$conf["id"],字串,zerossl::createCertificate回傳的id,透過id來下載單一憑證.
9793
				#$conf["id"],字串,zerossl::createCertificate回傳的id,透過id來下載單一憑證.
7331
				$conf["zerossl::getCert"]["id"]=$csrId;
9794
				$conf["zerossl::getCert"]["id"]=$csrId;
7332
				#$conf["cname"],字串,主要的domain,透過common name來取得符合的憑證.
9795
				#$conf["cname"],字串,主要的domain,透過common name來取得符合的憑證.
7333
				#$conf["zerossl::getCert"]["cname"]="";
9796
				#$conf["zerossl::getCert"]["cname"]="";
7334
				#參考資料:
9797
				#參考資料:
Line 7354... Line 9817...
7354
				
9817
				
7355
				#if enable debug
9818
				#if enable debug
7356
				if($debug){
9819
				if($debug){
7357
				
9820
				
7358
					#debug msg
9821
					#debug msg
7359
					echo "Creating certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
9822
					echo "Creating certificate for domain name(".$cName.")".PHP_EOL;
7360
				
9823
				
7361
					}#if end
9824
					}#if end
7362
				
9825
				
7363
				#建立 certificate.crt 檔案
9826
				#建立 certificate.crt 檔案
7364
				#$cInfo["certPath"];
9827
				#$cInfo["certPath"];
Line 7383... Line 9846...
7383
				#$result["argu"],使用的參數.
9846
				#$result["argu"],使用的參數.
7384
				#必填參數:
9847
				#必填參數:
7385
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9848
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
7386
				$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
9849
				$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
7387
				#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
9850
				#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
7388
				$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["certPath"],$cInfo["caPath"],$cInfo["certWithCaPath"]);
9851
				$conf["zerossl::writeMultiFile"]["fileName"]=array($conf["info"]["share"]["certPath"],$conf["info"]["share"]["caPath"],$conf["info"]["share"]["certWithCaPath"]);
7389
				#可省略參數:
9852
				#可省略參數:
7390
				#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
9853
				#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
7391
				$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"],$getCert["ca_bundle.crt"],$getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]);
9854
				$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"],$getCert["ca_bundle.crt"],$getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]);
7392
				#參考資料:
9855
				#參考資料:
7393
				#無.
9856
				#無.
Line 7418... Line 9881...
7418
					
9881
					
7419
					#if enable debug
9882
					#if enable debug
7420
					if($debug){
9883
					if($debug){
7421
					
9884
					
7422
						#debug msg
9885
						#debug msg
7423
						echo "There are many cmds to run to apply certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
9886
						echo "There are many cmds to run to apply certificate for domain name(".$cName.")".PHP_EOL;
7424
					
9887
					
7425
						}#if end
9888
						}#if end
7426
					
9889
					
7427
					#if enable debug
9890
					#if enable debug
7428
					if($debug){
9891
					if($debug){
7429
					
9892
					
7430
						#debug msg
9893
						#debug msg
7431
						echo "Running cmd to apply certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
9894
						echo "Running cmd to apply certificate for domain name(".$cName.")".PHP_EOL;
7432
					
9895
					
7433
						}#if end
9896
						}#if end
7434
					
9897
					
7435
					#針對每的指令
9898
					#針對每的指令
7436
					foreach($action as $ac){
9899
					foreach($action as $ac){
Line 7567... Line 10030...
7567
				
10030
				
7568
					#if enable debug
10031
					#if enable debug
7569
					if($debug){
10032
					if($debug){
7570
					
10033
					
7571
						#debug msg
10034
						#debug msg
7572
						echo "There is only one cmd to run to apply certificate for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
10035
						echo "There is only one cmd to run to apply certificate for domain name(".$cName.")".PHP_EOL;
7573
					
10036
					
7574
						}#if end
10037
						}#if end
7575
				
10038
				
7576
					#if enable debug
10039
					#if enable debug
7577
					if($debug){
10040
					if($debug){
Line 7705... Line 10168...
7705
			
10168
			
7706
				#if enable debug
10169
				#if enable debug
7707
				if($debug){
10170
				if($debug){
7708
				
10171
				
7709
					#debug msg
10172
					#debug msg
7710
					echo "There is already valid ssl for domain name(".$cInfo["apiDomain"].") on zerossl".PHP_EOL;
10173
					echo "There is already valid ssl for domain name(".$cName.") on zerossl".PHP_EOL;
7711
				
10174
				
7712
					}#if end
10175
					}#if end
7713
			
10176
			
-
 
10177
				#debug
-
 
10178
				#var_dump(__LINE__,$getCertList);
-
 
10179
			
7714
				#有 issued 的憑證
10180
				#有 issued 的憑證
7715
				
10181
				
-
 
10182
				#if enable debug
-
 
10183
				if($debug){
-
 
10184
				
-
 
10185
					#debug msg
-
 
10186
					echo "Downloading ssl for domain name(".$cName.") on zerossl".PHP_EOL;
-
 
10187
				
-
 
10188
					}#if end
-
 
10189
				
7716
				#取得 certificate id at zerossl
10190
				#取得 certificate id at zerossl
7717
				#函式說明:
10191
				#函式說明:
7718
				#將陣列轉換成存有key與value的陣列
10192
				#將陣列轉換成存有key與value的陣列
7719
				#回傳的結果:
10193
				#回傳的結果:
7720
				#$result["status"],執行式否正常的識別,"true"代表執行正常,"false"代表執行不正常.
10194
				#$result["status"],執行式否正常的識別,"true"代表執行正常,"false"代表執行不正常.
Line 7746... Line 10220...
7746
					#回傳結果
10220
					#回傳結果
7747
					return $result;
10221
					return $result;
7748
				
10222
				
7749
					}#if end
10223
					}#if end
7750
				
10224
				
-
 
10225
				#debug
-
 
10226
				#var_dump($getKeyAndValue);exit;
-
 
10227
				
7751
				#儲存 certificate id at zerossl
10228
				#儲存 certificate id at zerossl
7752
				$csrId=$getKeyAndValue["key"][0];
10229
				$csrId=$getKeyAndValue[1]["key"];
7753
				
10230
				
7754
				#檢查憑證是否已經快過期
10231
				#檢查憑證是否已經快過期
7755
				$expiresIn=$getCertList["certs"][$csrId]["expiresIn"];
10232
				$expiresIn=$getCertList["certs"][$csrId]["expiresIn"];
7756
				
10233
				
7757
				#如果距離當下不到2個星期就要過期
10234
				#如果距離當下不到2個星期就要過期
7758
				if($expiresIn<=86400*14){
10235
				if($expiresIn<=86400*14){
7759
				
10236
					
7760
					#if enable debug
10237
					#if enable debug
7761
					if($debug){
10238
					if($debug){
7762
					
10239
					
7763
						#debug msg
10240
						#debug msg
7764
						echo "Valid ssl for domain name(".$cInfo["apiDomain"].") on zerossl will expired soon(in at least 14 days)".PHP_EOL;
10241
						echo "Valid ssl for domain name(".$cName.") on zerossl will expired soon(in at least 14 days)".PHP_EOL;
7765
					
10242
					
7766
						}#if end
10243
						}#if end
7767
				
10244
				
-
 
10245
					#debug
-
 
10246
					#var_dump($expiresIn);exit;
-
 
10247
				
7768
					#另存舊的憑證id,最後要revoke之.
10248
					#另存舊的憑證id,最後要revoke之.
7769
					$oldCsrId=$csrId;
10249
					$oldCsrId=$csrId;
7770
				
10250
				
7771
					#if enable debug
10251
					#if enable debug
7772
					if($debug){
10252
					if($debug){
7773
					
10253
					
7774
						#debug msg
10254
						#debug msg
7775
						echo "Start requst new ssl process for domain name(".$cInfo["apiDomain"].").".PHP_EOL;
10255
						echo "Start requst new ssl process for domain name(".$cName.").".PHP_EOL;
7776
					
10256
					
7777
						}#if end
10257
						}#if end
7778
						
10258
						
7779
					#if enable debug
10259
					#if enable debug
7780
					if($debug){
10260
					if($debug){
7781
					
10261
					
7782
						#debug msg
10262
						#debug msg
7783
						echo "Finding ssl private key for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
10263
						echo "Finding ssl private key for domain name(".$cName.")...".PHP_EOL;
7784
					
10264
					
7785
						}#if end
10265
						}#if end
7786
				
10266
				
7787
					#確認有無對應 cName 的 private key
10267
					#確認有無對應 cName 的 private key
7788
					#函式說明:
10268
					#函式說明:
Line 7797... Line 10277...
7797
					#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
10277
					#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
7798
					#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
10278
					#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
7799
					#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
10279
					#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
7800
					#必填參數:
10280
					#必填參數:
7801
					#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
10281
					#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
7802
					$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($cInfo["pKey"]);
10282
					$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($cInfo["ssl"]["pKey"]);
7803
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
10283
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
7804
					$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=__FILE__;
10284
					$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=__FILE__;
7805
					#可省略參數:
10285
					#可省略參數:
7806
					#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
10286
					#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
7807
					#$conf["disableWebSearch"]="false";
10287
					#$conf["disableWebSearch"]="false";
Line 7837... Line 10317...
7837
					
10317
					
7838
						#if enable debug
10318
						#if enable debug
7839
						if($debug){
10319
						if($debug){
7840
						
10320
						
7841
							#debug msg
10321
							#debug msg
7842
							echo "Thers is no ssl private key for domain name(".$cInfo["apiDomain"].").".PHP_EOL;
10322
							echo "Thers is no ssl private key for domain name(".$cName.").".PHP_EOL;
7843
						
10323
						
7844
							}#if end
10324
							}#if end
7845
							
10325
							
7846
						#if enable debug
10326
						#if enable debug
7847
						if($debug){
10327
						if($debug){
7848
						
10328
						
7849
							#debug msg
10329
							#debug msg
7850
							echo "Creating ssl private key for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
10330
							echo "Creating ssl private key for domain name(".$cName.")...".PHP_EOL;
7851
						
10331
						
7852
							}#if end
10332
							}#if end
7853
					
10333
					
7854
						#建立 private key
10334
						#建立 private key
7855
						#函式說明:
10335
						#函式說明:
Line 7869... Line 10349...
7869
						#$conf["length"]=4096';
10349
						#$conf["length"]=4096';
7870
						#參考資料:
10350
						#參考資料:
7871
						#無.
10351
						#無.
7872
						#備註:
10352
						#備註:
7873
						#key generated by openssl with RSA.
10353
						#key generated by openssl with RSA.
7874
						$createPrivateKey=openssl::createPrivateKey($conf["openssl::createPrivateKey"]);
10354
						$createPrivateKey=zerossl::createPrivateKey($conf["openssl::createPrivateKey"]);
7875
						unset($conf["openssl::createPrivateKey"]);
10355
						unset($conf["openssl::createPrivateKey"]);
7876
					
10356
					
7877
						#如果運行異常
10357
						#如果運行異常
7878
						if($createPrivateKey["status"]==="false"){
10358
						if($createPrivateKey["status"]==="false"){
7879
						
10359
						
Line 7893... Line 10373...
7893
					
10373
					
7894
						#if enable debug
10374
						#if enable debug
7895
						if($debug){
10375
						if($debug){
7896
						
10376
						
7897
							#debug msg
10377
							#debug msg
7898
							echo "Writing ssl private key for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
10378
							echo "Writing ssl private key for domain name(".$cName.")...".PHP_EOL;
7899
						
10379
						
7900
							}#if end
10380
							}#if end
7901
					
10381
					
7902
						#建立private key檔案
10382
						#建立private key檔案
7903
						#函式說明:
10383
						#函式說明:
Line 7914... Line 10394...
7914
						#必填參數:
10394
						#必填參數:
7915
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
10395
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
7916
						$conf["zerossl::writeTextIntoFile"]["fileArgu"]=__FILE__;
10396
						$conf["zerossl::writeTextIntoFile"]["fileArgu"]=__FILE__;
7917
						#可省略參數:
10397
						#可省略參數:
7918
						#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
10398
						#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
7919
						$conf["zerossl::writeTextIntoFile"]["fileName"]=$cInfo["pKey"];
10399
						$conf["zerossl::writeTextIntoFile"]["fileName"]=$cInfo["ssl"]["pKey"];
7920
						#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
10400
						#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
7921
						$conf["zerossl::writeTextIntoFile"]["inputString"]=$pKeyStr;
10401
						$conf["zerossl::writeTextIntoFile"]["inputString"]=$pKeyStr;
7922
						#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
10402
						#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
7923
						#$conf["writeMethod"]="a";
10403
						#$conf["writeMethod"]="a";
7924
						#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
10404
						#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
Line 7954... Line 10434...
7954
					
10434
					
7955
					#if enable debug
10435
					#if enable debug
7956
					if($debug){
10436
					if($debug){
7957
					
10437
					
7958
						#debug msg
10438
						#debug msg
7959
						echo "Creating CSR for domain name(".$cInfo["apiDomain"].") to zerossl.".PHP_EOL;
10439
						echo "Creating CSR for domain name(".$cName.") to zerossl.".PHP_EOL;
7960
					
10440
					
7961
						}#if end
10441
						}#if end
7962
					
10442
					
7963
					#建立準備給zerossl的csr
10443
					#建立準備給zerossl的csr
7964
					#函式說明:
10444
					#函式說明:
Line 8011... Line 10491...
8011
					
10491
					
8012
					#if enable debug
10492
					#if enable debug
8013
					if($debug){
10493
					if($debug){
8014
					
10494
					
8015
						#debug msg
10495
						#debug msg
8016
						echo "Providing CSR for domain name(".$cInfo["apiDomain"].") to zerossl".PHP_EOL;
10496
						echo "Providing CSR for domain name(".$cName.") to zerossl".PHP_EOL;
8017
					
10497
					
8018
						}#if end
10498
						}#if end
8019
					
10499
					
8020
					#函式說明:
10500
					#函式說明:
8021
					#提供certificate sign request(CSR)透過zerossl產生certificate.
10501
					#提供certificate sign request(CSR)透過zerossl產生certificate.
Line 8036... Line 10516...
8036
					$conf["zerossl::createCertificate"]["certificate_csr"]=$csrLocal;
10516
					$conf["zerossl::createCertificate"]["certificate_csr"]=$csrLocal;
8037
					#$conf["fileArgu"],字串,變數__FILE__的內容.
10517
					#$conf["fileArgu"],字串,變數__FILE__的內容.
8038
					$conf["zerossl::createCertificate"]["fileArgu"]=__FILE__;
10518
					$conf["zerossl::createCertificate"]["fileArgu"]=__FILE__;
8039
					#可省略參數:
10519
					#可省略參數:
8040
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
10520
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
8041
					$conf["zerossl::createCertificate"]["apiDomain"]=$cInfo["domain"];
10521
					$conf["zerossl::createCertificate"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
8042
					#$conf["path"],字串,提供服務的path,預設為 self::getApiInfo()["csrPath"].
10522
					#$conf["path"],字串,提供服務的path,預設為 self::getApiInfo()["csrPath"].
8043
					#$conf["path"]=self::getApiInfo()["csrPath"];
10523
					#$conf["path"]=self::getApiInfo()["csrPath"];
8044
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
10524
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
8045
					$conf["zerossl::createCertificate"]["key"]=$cInfo["key"];
10525
					$conf["zerossl::createCertificate"]["key"]=$conf["info"]["share"]["key"];
8046
					#參考資料:
10526
					#參考資料:
8047
					#無.
10527
					#無.
8048
					#備註:
10528
					#備註:
8049
					#無.
10529
					#無.
8050
					$createCertificate=zerossl::createCertificate($conf["zerossl::createCertificate"]);
10530
					$createCertificate=zerossl::createCertificate($conf["zerossl::createCertificate"]);
Line 8090... Line 10570...
8090
					
10570
					
8091
					#if enable debug
10571
					#if enable debug
8092
					if($debug){
10572
					if($debug){
8093
					
10573
					
8094
						#debug msg
10574
						#debug msg
8095
						echo "Adding DNS record to valid domain name(".$cInfo["apiDomain"].").".PHP_EOL;
10575
						echo "Adding DNS record to valid domain name(".$conf["info"]["share"]["apiDomain"].").".PHP_EOL;
8096
					
10576
					
8097
						}#if end
10577
						}#if end
8098
					
10578
					
8099
					#函式說明:
10579
					#函式說明:
8100
					#新增DNS記錄到檔案裡面.
10580
					#新增DNS記錄到檔案裡面.
Line 8142... Line 10622...
8142
					
10622
					
8143
					#if enable debug
10623
					#if enable debug
8144
					if($debug){
10624
					if($debug){
8145
					
10625
					
8146
						#debug msg
10626
						#debug msg
8147
						echo "Restarting DNS service to valid domain name(".$cInfo["apiDomain"].").".PHP_EOL;
10627
						echo "Restarting DNS service to valid domain name(".$conf["info"]["share"]["apiDomain"].").".PHP_EOL;
8148
					
10628
					
8149
						}#if end
10629
						}#if end
8150
					
10630
					
8151
					#重新啟動dns伺服器
10631
					#重新啟動dns伺服器
8152
					#函式說明:
10632
					#函式說明:
Line 8166... Line 10646...
8166
					#$result["statusCode"],執行結束後的代碼.
10646
					#$result["statusCode"],執行結束後的代碼.
8167
					#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
10647
					#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
8168
					#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
10648
					#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
8169
					#必填參數:
10649
					#必填參數:
8170
					#$conf["command"],字串,要執行的指令.
10650
					#$conf["command"],字串,要執行的指令.
8171
					$conf["external::callShell"]["command"]="systemd";
10651
					$conf["external::callShell"]["command"]="systemctl";
8172
					#$conf["fileArgu"],字串,變數__FILE__的內容.
10652
					#$conf["fileArgu"],字串,變數__FILE__的內容.
8173
					$conf["external::callShell"]["fileArgu"]=__FILE__;
10653
					$conf["external::callShell"]["fileArgu"]=__FILE__;
8174
					#可省略參數:
10654
					#可省略參數:
8175
					#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
10655
					#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
8176
					$conf["external::callShell"]["argu"]=array("restart","named");
10656
					$conf["external::callShell"]["argu"]=array("restart","named");
Line 8231... Line 10711...
8231
					
10711
					
8232
					#if enable debug
10712
					#if enable debug
8233
					if($debug){
10713
					if($debug){
8234
					
10714
					
8235
						#debug msg
10715
						#debug msg
8236
						echo "Request zerossl to valid domain name(".$cInfo["apiDomain"].").".PHP_EOL;
10716
						echo "Request zerossl to valid domain name(".$conf["info"]["share"]["apiDomain"].").".PHP_EOL;
8237
					
10717
					
8238
						}#if end
10718
						}#if end
8239
					
10719
					
8240
					#函式說明:
10720
					#函式說明:
8241
					#請求驗證已經透過zerossl::createCertificate要求的domain.
10721
					#請求驗證已經透過zerossl::createCertificate要求的domain.
Line 8249... Line 10729...
8249
					#必填參數:
10729
					#必填參數:
8250
					#$conf["id"],字串,zerossl::createCertificate回傳的id.
10730
					#$conf["id"],字串,zerossl::createCertificate回傳的id.
8251
					$conf["zerossl::verifyDomain"]["id"]=$csrId;
10731
					$conf["zerossl::verifyDomain"]["id"]=$csrId;
8252
					#可省略參數:
10732
					#可省略參數:
8253
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
10733
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
8254
					$conf["zerossl::verifyDomain"]["apiDomain"]=$cInfo["domain"];
10734
					$conf["zerossl::verifyDomain"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
8255
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
10735
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
8256
					$conf["zerossl::verifyDomain"]["key"]=$cInfo["key"];
10736
					$conf["zerossl::verifyDomain"]["key"]=$conf["info"]["share"]["key"];
8257
					#參考資料:
10737
					#參考資料:
8258
					#https://zerossl.com/documentation/api/verify-domains/
10738
					#https://zerossl.com/documentation/api/verify-domains/
8259
					#備註:
10739
					#備註:
8260
					#無.
10740
					#無.
8261
					$verifyDomain=zerossl::verifyDomain($conf["zerossl::verifyDomain"]);
10741
					$verifyDomain=zerossl::verifyDomain($conf["zerossl::verifyDomain"]);
Line 8277... Line 10757...
8277
					
10757
					
8278
					#if enable debug
10758
					#if enable debug
8279
					if($debug){
10759
					if($debug){
8280
					
10760
					
8281
						#debug msg
10761
						#debug msg
8282
						echo "Downling ssl for domain name(".$cInfo["apiDomain"].") on zerossl.".PHP_EOL;
10762
						echo "Downling ssl for domain name(".$cName.") on zerossl.".PHP_EOL;
8283
					
10763
					
8284
						}#if end
10764
						}#if end
8285
					
10765
					
8286
					#函式說明:
10766
					#函式說明:
8287
					#下載certificate.
10767
					#下載certificate.
Line 8296... Line 10776...
8296
					#$result["ca_bundle.crt"],字串,ca_bundle.crt的內容.
10776
					#$result["ca_bundle.crt"],字串,ca_bundle.crt的內容.
8297
					#必填參數:
10777
					#必填參數:
8298
					#無.
10778
					#無.
8299
					#可省略參數:
10779
					#可省略參數:
8300
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
10780
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
8301
					$conf["zerossl::getCert"]["apiDomain"]=$cInfo["domain"];
10781
					$conf["zerossl::getCert"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
8302
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
10782
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
8303
					$conf["zerossl::getCert"]["key"]=$cInfo["key"];
10783
					$conf["zerossl::getCert"]["key"]=$conf["info"]["share"]["key"];
8304
					#$conf["id"],字串,zerossl::createCertificate回傳的id,透過id來下載單一憑證.
10784
					#$conf["id"],字串,zerossl::createCertificate回傳的id,透過id來下載單一憑證.
8305
					$conf["zerossl::getCert"]["id"]=$csrId;
10785
					$conf["zerossl::getCert"]["id"]=$csrId;
8306
					#$conf["cname"],字串,主要的domain,透過common name來取得符合的憑證.
10786
					#$conf["cname"],字串,主要的domain,透過common name來取得符合的憑證.
8307
					#$conf["zerossl::getCert"]["cname"]="";
10787
					#$conf["zerossl::getCert"]["cname"]="";
8308
					#參考資料:
10788
					#參考資料:
Line 8328... Line 10808...
8328
					
10808
					
8329
					#if enable debug
10809
					#if enable debug
8330
					if($debug){
10810
					if($debug){
8331
					
10811
					
8332
						#debug msg
10812
						#debug msg
8333
						echo "Creating ssl for domain name(".$cInfo["apiDomain"].").".PHP_EOL;
10813
						echo "Creating ssl for domain name(".$cName.").".PHP_EOL;
8334
					
10814
					
8335
						}#if end
10815
						}#if end
8336
					
10816
					
8337
					#建立 certificate.crt 檔案
10817
					#建立 certificate.crt 檔案
8338
					#$cInfo["certPath"];
10818
					#$cInfo["certPath"];
Line 8357... Line 10837...
8357
					#$result["argu"],使用的參數.
10837
					#$result["argu"],使用的參數.
8358
					#必填參數:
10838
					#必填參數:
8359
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
10839
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
8360
					$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
10840
					$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
8361
					#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
10841
					#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
8362
					$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["certPath"],$cInfo["caPath"],$cInfo["certWithCaPath"]);
10842
					$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["ssl"]["certPath"],$cInfo["ssl"]["caPath"],$cInfo["ssl"]["certWithCaPath"]);
8363
					#可省略參數:
10843
					#可省略參數:
8364
					#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
10844
					#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
8365
					$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"],$getCert["ca_bundle.crt"],$getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]);
10845
					$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"],$getCert["ca_bundle.crt"],$getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]);
8366
					#參考資料:
10846
					#參考資料:
8367
					#無.
10847
					#無.
Line 8392... Line 10872...
8392
						
10872
						
8393
						#if enable debug
10873
						#if enable debug
8394
						if($debug){
10874
						if($debug){
8395
						
10875
						
8396
							#debug msg
10876
							#debug msg
8397
							echo "There many cmd to run to valid domain name(".$cInfo["apiDomain"].").".PHP_EOL;
10877
							echo "There many cmd to run to valid domain name(".$conf["info"]["share"]["apiDomain"].").".PHP_EOL;
8398
						
10878
						
8399
							}#if end
10879
							}#if end
8400
						
10880
						
8401
						#針對每的指令
10881
						#針對每的指令
8402
						foreach($action as $ac){
10882
						foreach($action as $ac){
Line 8533... Line 11013...
8533
					
11013
					
8534
						#if enable debug
11014
						#if enable debug
8535
						if($debug){
11015
						if($debug){
8536
						
11016
						
8537
							#debug msg
11017
							#debug msg
8538
							echo "There is only one cmd to run to valid domain name(".$cInfo["apiDomain"].").".PHP_EOL;
11018
							echo "There is only one cmd to run to valid domain name(".$conf["info"]["share"]["apiDomain"].").".PHP_EOL;
8539
						
11019
						
8540
							}#if end
11020
							}#if end
8541
							
11021
							
8542
						#if enable debug
11022
						#if enable debug
8543
						if($debug){
11023
						if($debug){
Line 8690... Line 11170...
8690
					#必填參數:
11170
					#必填參數:
8691
					#$conf["id"],字串,zerossl::createCertificate回傳的id.
11171
					#$conf["id"],字串,zerossl::createCertificate回傳的id.
8692
					$conf["zerosssl::revokeCert"]["id"]=$oldCsrId;
11172
					$conf["zerosssl::revokeCert"]["id"]=$oldCsrId;
8693
					#可省略參數:
11173
					#可省略參數:
8694
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
11174
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
8695
					$conf["zerosssl::revokeCert"]["apiDomain"]=$cInfo["domain"];
11175
					$conf["zerosssl::revokeCert"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
8696
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
11176
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
8697
					$conf["zerosssl::revokeCert"]["key"]=$cInfo["key"];
11177
					$conf["zerosssl::revokeCert"]["key"]=$conf["info"]["share"]["key"];
8698
					#$conf["reason"],字串,廢除該certificate的原因,可以設置的原因有"keyCompromise",ssl private key 泄漏了;"affiliationChanged",憑證的使用對象變更了;"Superseded",已經有可以替換的憑證了;"cessationOfOperation",domain name已經換擁有着.
11178
					#$conf["reason"],字串,廢除該certificate的原因,可以設置的原因有"keyCompromise",ssl private key 泄漏了;"affiliationChanged",憑證的使用對象變更了;"Superseded",已經有可以替換的憑證了;"cessationOfOperation",domain name已經換擁有着.
8699
					$conf["zerosssl::revokeCert"]["reason"]="Superseded";
11179
					$conf["zerosssl::revokeCert"]["reason"]="Superseded";
8700
					#參考資料:
11180
					#參考資料:
8701
					#https://zerossl.com/documentation/api/revoke-certificate/
11181
					#https://zerossl.com/documentation/api/revoke-certificate/
8702
					#備註:
11182
					#備註:
Line 8714... Line 11194...
8714
						$result["error"]=$revokeCert;
11194
						$result["error"]=$revokeCert;
8715
 
11195
 
8716
						#回傳結果
11196
						#回傳結果
8717
						return $result;
11197
						return $result;
8718
				
11198
				
-
 
11199
						}#if end
-
 
11200
						
8719
					}#if end
11201
					}#if end
8720
					
11202
					
8721
				#反之,尚不需要提前申請新的憑證
11203
				#反之,尚不需要提前申請新的憑證
8722
				else{
11204
				else{
8723
				
11205
				
-
 
11206
					#debug
-
 
11207
					#var_dump(__LINE__,"尚不需要提前申請新的憑證");exit;
-
 
11208
				
8724
					#if enable debug
11209
					#if enable debug
8725
					if($debug){
11210
					if($debug){
8726
					
11211
					
8727
						#debug msg
11212
						#debug msg
8728
						echo "ssl for domain name(".$cInfo["apiDomain"].") is valid ".PHP_EOL;
11213
						echo "ssl for domain name(".$cName.") is valid ".PHP_EOL;
8729
					
11214
					
8730
						}#if end
11215
						}#if end
8731
				
11216
				
8732
					#if enable debug
11217
					#if enable debug
8733
					if($debug){
11218
					if($debug){
8734
					
11219
					
8735
						#debug msg
11220
						#debug msg
8736
						echo "Downling ssl for domain name(".$cInfo["apiDomain"].") on zerossl...".PHP_EOL;
11221
						echo "Downling ssl for domain name(".$cName.") on zerossl...".PHP_EOL;
8737
					
11222
					
8738
						}#if end
11223
						}#if end
8739
				
11224
				
8740
					#下載憑證
11225
					#下載憑證
8741
					#函式說明:
11226
					#函式說明:
Line 8751... Line 11236...
8751
					#$result["ca_bundle.crt"],字串,ca_bundle.crt的內容.
11236
					#$result["ca_bundle.crt"],字串,ca_bundle.crt的內容.
8752
					#必填參數:
11237
					#必填參數:
8753
					#無.
11238
					#無.
8754
					#可省略參數:
11239
					#可省略參數:
8755
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
11240
					#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
8756
					$conf["zerossl::getCert"]["apiDomain"]=$cInfo["domain"];
11241
					$conf["zerossl::getCert"]["apiDomain"]=$conf["info"]["share"]["apiDomain"];
8757
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
11242
					#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
8758
					$conf["zerossl::getCert"]["key"]=$cInfo["key"];
11243
					$conf["zerossl::getCert"]["key"]=$conf["info"]["share"]["key"];
8759
					#$conf["id"],字串,zerossl::createCertificate回傳的id,透過id來下載單一憑證.
11244
					#$conf["id"],字串,zerossl::createCertificate回傳的id,透過id來下載單一憑證.
8760
					$conf["zerossl::getCert"]["id"]=$csrId;
11245
					$conf["zerossl::getCert"]["id"]=$csrId;
8761
					#$conf["cname"],字串,主要的domain,透過common name來取得符合的憑證.
11246
					#$conf["cname"],字串,主要的domain,透過common name來取得符合的憑證.
8762
					#$conf["zerossl::getCert"]["cname"]="";
11247
					#$conf["zerossl::getCert"]["cname"]="";
8763
					#參考資料:
11248
					#參考資料:
Line 8783... Line 11268...
8783
					
11268
					
8784
					#if enable debug
11269
					#if enable debug
8785
					if($debug){
11270
					if($debug){
8786
					
11271
					
8787
						#debug msg
11272
						#debug msg
8788
						echo "Getting host ssl for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11273
						echo "Getting host ssl for domain name(".$cName.")...".PHP_EOL;
8789
					
11274
					
8790
						}#if end
11275
						}#if end
8791
					
11276
					
8792
					#zerossl上的certificate.crt內容
11277
					#zerossl上的certificate.crt內容
8793
					#$getCert["certificate.crt"];
11278
					#$getCert["certificate.crt"];
Line 8809... Line 11294...
8809
					
11294
					
8810
					#if enable debug
11295
					#if enable debug
8811
					if($debug){
11296
					if($debug){
8812
					
11297
					
8813
						#debug msg
11298
						#debug msg
8814
						echo "Getting host ssl(certificate.crt) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11299
						echo "Getting host ssl(certificate.crt) for domain name(".$cName.")...".PHP_EOL;
8815
					
11300
					
8816
						}#if end
11301
						}#if end
8817
				
11302
				
8818
					#取得既有的 certificate.crt 檔案內容
11303
					#取得既有的 certificate.crt 檔案內容
8819
					#函式說明:
11304
					#函式說明:
Line 8829... Line 11314...
8829
					#$result["base64dataOnly"],檔案的base64data.
11314
					#$result["base64dataOnly"],檔案的base64data.
8830
					#$result["base64data"],為在網頁上給予src參數的數值.
11315
					#$result["base64data"],為在網頁上給予src參數的數值.
8831
					#$result["mimeType"],為檔案的mime type.
11316
					#$result["mimeType"],為檔案的mime type.
8832
					#必填參數:
11317
					#必填參數:
8833
					#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
11318
					#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
8834
					$conf["fileAccesss::getFileContent"]["filePositionAndName"]=$cInfo["certPath"];
11319
					$conf["fileAccesss::getFileContent"]["filePositionAndName"]=$cInfo["ssl"]["certPath"];
8835
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11320
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
8836
					$conf["fileAccesss::getFileContent"]["fileArgu"]=__FILE__;
11321
					$conf["fileAccesss::getFileContent"]["fileArgu"]=__FILE__;
8837
					#可省略參數:
11322
					#可省略參數:
8838
					#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
11323
					#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
8839
					#$conf["web"]="true";
11324
					#$conf["web"]="true";
8840
					#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
11325
					#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
8841
					#$conf["createIfnotExist"]="false";
11326
					$conf["fileAccesss::getFileContent"]["createIfnotExist"]="true";
8842
					#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
11327
					#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
8843
					#$conf["autoDeleteSpaceOnEachLineStart"]="false";
11328
					#$conf["autoDeleteSpaceOnEachLineStart"]="false";
8844
					#參考資料:
11329
					#參考資料:
8845
					#file(),取得檔案內容的行數.
11330
					#file(),取得檔案內容的行數.
8846
					#file=>http:#php.net/manual/en/function.file.php
11331
					#file=>http:#php.net/manual/en/function.file.php
Line 8848... Line 11333...
8848
					#filesize=>http://php.net/manual/en/function.filesize.php
11333
					#filesize=>http://php.net/manual/en/function.filesize.php
8849
					#參考資料:
11334
					#參考資料:
8850
					#無.
11335
					#無.
8851
					#備註:
11336
					#備註:
8852
					#無.
11337
					#無.
8853
					$getFileContent=fileAccesss::getFileContent($conf["fileAccesss::getFileContent"]);
11338
					$getFileContent=fileAccess::getFileContent($conf["fileAccesss::getFileContent"]);
8854
					unset($conf["fileAccesss::getFileContent"]);
11339
					unset($conf["fileAccesss::getFileContent"]);
8855
				
11340
				
8856
					#如果執行異常
11341
					#如果執行異常
8857
					if($getFileContent["status"]==="false"){
11342
					if($getFileContent["status"]==="false"){
8858
					
11343
					
Line 8869... Line 11354...
8869
				
11354
				
8870
					#if enable debug
11355
					#if enable debug
8871
					if($debug){
11356
					if($debug){
8872
					
11357
					
8873
						#debug msg
11358
						#debug msg
8874
						echo "Checking host ssl(certificate.crt) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11359
						echo "Checking host ssl(certificate.crt) for domain name(".$cName.")...".PHP_EOL;
8875
					
11360
					
8876
						}#if end
11361
						}#if end
8877
				
11362
				
-
 
11363
					#預設 certificate.crt 不用更新
-
 
11364
					$certificate_need_update="false";
-
 
11365
				
8878
					#如果既有憑證跟剛下載的憑證不一樣
11366
					#如果既有憑證跟剛下載的憑證不一樣
8879
					if($getFileContent["fullContent"]!==$getCert["certificate.crt"]){
11367
					if($getFileContent["fullContent"]!==$getCert["certificate.crt"]){
8880
					
11368
					
8881
						#識別要改成下載好的憑證
11369
						#識別要改成下載好的憑證
8882
						$certificate_need_update="true";
11370
						$certificate_need_update="true";
8883
						
11371
						
8884
						#if enable debug
11372
						#if enable debug
8885
						if($debug){
11373
						if($debug){
8886
						
11374
						
8887
							#debug msg
11375
							#debug msg
8888
							echo "SSL(certificate.crt) for domain name(".$cInfo["apiDomain"].") differs between host and zerossl".PHP_EOL;
11376
							echo "SSL(certificate.crt) for domain name(".$cName.") differs between host and zerossl".PHP_EOL;
8889
						
11377
						
8890
							}#if end
11378
							}#if end
8891
					
11379
					
8892
						}#if end
11380
						}#if end
8893
					
11381
					
8894
					#if enable debug
11382
					#if enable debug
8895
					if($debug){
11383
					if($debug){
8896
					
11384
					
8897
						#debug msg
11385
						#debug msg
8898
						echo "Getting host ssl(ca_bundle.crt) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11386
						echo "Getting host ssl(ca_bundle.crt) for domain name(".$cName.")...".PHP_EOL;
8899
					
11387
					
8900
						}#if end
11388
						}#if end
8901
					
11389
					
8902
					#取得既有的 ca_bundle.crt 檔案內容
11390
					#取得既有的 ca_bundle.crt 檔案內容
8903
					#函式說明:
11391
					#函式說明:
Line 8913... Line 11401...
8913
					#$result["base64dataOnly"],檔案的base64data.
11401
					#$result["base64dataOnly"],檔案的base64data.
8914
					#$result["base64data"],為在網頁上給予src參數的數值.
11402
					#$result["base64data"],為在網頁上給予src參數的數值.
8915
					#$result["mimeType"],為檔案的mime type.
11403
					#$result["mimeType"],為檔案的mime type.
8916
					#必填參數:
11404
					#必填參數:
8917
					#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
11405
					#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
8918
					$conf["fileAccesss::getFileContent"]["filePositionAndName"]=$cInfo["caPath"];
11406
					$conf["fileAccesss::getFileContent"]["filePositionAndName"]=$cInfo["ssl"]["caPath"];
8919
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11407
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
8920
					$conf["fileAccesss::getFileContent"]["fileArgu"]=__FILE__;
11408
					$conf["fileAccesss::getFileContent"]["fileArgu"]=__FILE__;
8921
					#可省略參數:
11409
					#可省略參數:
8922
					#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
11410
					#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
8923
					#$conf["web"]="true";
11411
					#$conf["web"]="true";
8924
					#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
11412
					#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
8925
					#$conf["createIfnotExist"]="false";
11413
					$conf["fileAccesss::getFileContent"]["createIfnotExist"]="true";
8926
					#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
11414
					#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
8927
					#$conf["autoDeleteSpaceOnEachLineStart"]="false";
11415
					#$conf["autoDeleteSpaceOnEachLineStart"]="false";
8928
					#參考資料:
11416
					#參考資料:
8929
					#file(),取得檔案內容的行數.
11417
					#file(),取得檔案內容的行數.
8930
					#file=>http:#php.net/manual/en/function.file.php
11418
					#file=>http:#php.net/manual/en/function.file.php
Line 8932... Line 11420...
8932
					#filesize=>http://php.net/manual/en/function.filesize.php
11420
					#filesize=>http://php.net/manual/en/function.filesize.php
8933
					#參考資料:
11421
					#參考資料:
8934
					#無.
11422
					#無.
8935
					#備註:
11423
					#備註:
8936
					#無.
11424
					#無.
8937
					$getFileContent=fileAccesss::getFileContent($conf["fileAccesss::getFileContent"]);
11425
					$getFileContent=fileAccess::getFileContent($conf["fileAccesss::getFileContent"]);
8938
					unset($conf["fileAccesss::getFileContent"]);
11426
					unset($conf["fileAccesss::getFileContent"]);
8939
				
11427
				
8940
					#如果執行異常
11428
					#如果執行異常
8941
					if($getFileContent["status"]==="false"){
11429
					if($getFileContent["status"]==="false"){
8942
					
11430
					
Line 8953... Line 11441...
8953
				
11441
				
8954
					#if enable debug
11442
					#if enable debug
8955
					if($debug){
11443
					if($debug){
8956
					
11444
					
8957
						#debug msg
11445
						#debug msg
8958
						echo "Checking host ssl(ca_bundle.crt) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11446
						echo "Checking host ssl(ca_bundle.crt) for domain name(".$cName.")...".PHP_EOL;
8959
					
11447
					
8960
						}#if end
11448
						}#if end
8961
				
11449
				
-
 
11450
					#預設 ca_bundle.crt 不用更新
-
 
11451
					$ca_bundle_need_update="false";
-
 
11452
				
8962
					#如果既有憑證跟剛下載的憑證不一樣
11453
					#如果既有憑證跟剛下載的憑證不一樣
8963
					if($getFileContent["fullContent"]!==$getCert["ca_bundle.crt"]){
11454
					if($getFileContent["fullContent"]!==$getCert["ca_bundle.crt"]){
8964
					
11455
					
8965
						#識別要改成下載好的憑證
11456
						#識別要改成下載好的憑證
8966
						$ca_bundle_need_update="true";
11457
						$ca_bundle_need_update="true";
8967
						
11458
						
8968
						#if enable debug
11459
						#if enable debug
8969
						if($debug){
11460
						if($debug){
8970
						
11461
						
8971
							#debug msg
11462
							#debug msg
8972
							echo "SSL(ca_bundle.crt) for domain name(".$cInfo["apiDomain"].") differs between host and zerossl".PHP_EOL;
11463
							echo "SSL(ca_bundle.crt) for domain name(".$cName.") differs between host and zerossl".PHP_EOL;
8973
						
11464
						
8974
							}#if end
11465
							}#if end
8975
					
11466
					
8976
						}#if end
11467
						}#if end
8977
					
11468
					
8978
					#if enable debug
11469
					#if enable debug
8979
					if($debug){
11470
					if($debug){
8980
					
11471
					
8981
						#debug msg
11472
						#debug msg
8982
						echo "Getting host ssl(cert and ca_bundle) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11473
						echo "Getting host ssl(cert and ca_bundle) for domain name(".$cName.")...".PHP_EOL;
8983
					
11474
					
8984
						}#if end
11475
						}#if end
8985
					
11476
					
8986
					#取得既有的 certWithCa 檔案內容
11477
					#取得既有的 certWithCa 檔案內容
8987
					#函式說明:
11478
					#函式說明:
Line 8997... Line 11488...
8997
					#$result["base64dataOnly"],檔案的base64data.
11488
					#$result["base64dataOnly"],檔案的base64data.
8998
					#$result["base64data"],為在網頁上給予src參數的數值.
11489
					#$result["base64data"],為在網頁上給予src參數的數值.
8999
					#$result["mimeType"],為檔案的mime type.
11490
					#$result["mimeType"],為檔案的mime type.
9000
					#必填參數:
11491
					#必填參數:
9001
					#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
11492
					#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
9002
					$conf["fileAccesss::getFileContent"]["filePositionAndName"]=$cInfo["certWithCaPath"];
11493
					$conf["fileAccesss::getFileContent"]["filePositionAndName"]=$cInfo["ssl"]["certWithCaPath"];
9003
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11494
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9004
					$conf["fileAccesss::getFileContent"]["fileArgu"]=__FILE__;
11495
					$conf["fileAccesss::getFileContent"]["fileArgu"]=__FILE__;
9005
					#可省略參數:
11496
					#可省略參數:
9006
					#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
11497
					#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
9007
					#$conf["web"]="true";
11498
					#$conf["web"]="true";
9008
					#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
11499
					#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
9009
					#$conf["createIfnotExist"]="false";
11500
					$conf["fileAccesss::getFileContent"]["createIfnotExist"]="true";
9010
					#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
11501
					#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
9011
					#$conf["autoDeleteSpaceOnEachLineStart"]="false";
11502
					#$conf["autoDeleteSpaceOnEachLineStart"]="false";
9012
					#參考資料:
11503
					#參考資料:
9013
					#file(),取得檔案內容的行數.
11504
					#file(),取得檔案內容的行數.
9014
					#file=>http:#php.net/manual/en/function.file.php
11505
					#file=>http:#php.net/manual/en/function.file.php
Line 9016... Line 11507...
9016
					#filesize=>http://php.net/manual/en/function.filesize.php
11507
					#filesize=>http://php.net/manual/en/function.filesize.php
9017
					#參考資料:
11508
					#參考資料:
9018
					#無.
11509
					#無.
9019
					#備註:
11510
					#備註:
9020
					#無.
11511
					#無.
9021
					$getFileContent=fileAccesss::getFileContent($conf["fileAccesss::getFileContent"]);
11512
					$getFileContent=fileAccess::getFileContent($conf["fileAccesss::getFileContent"]);
9022
					unset($conf["fileAccesss::getFileContent"]);
11513
					unset($conf["fileAccesss::getFileContent"]);
9023
				
11514
				
9024
					#如果執行異常
11515
					#如果執行異常
9025
					if($getFileContent["status"]==="false"){
11516
					if($getFileContent["status"]==="false"){
9026
					
11517
					
Line 9037... Line 11528...
9037
				
11528
				
9038
					#if enable debug
11529
					#if enable debug
9039
					if($debug){
11530
					if($debug){
9040
					
11531
					
9041
						#debug msg
11532
						#debug msg
9042
						echo "Checking host ssl(cert and ca_bundle) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11533
						echo "Checking host ssl(cert and ca_bundle) for domain name(".$cName.")...".PHP_EOL;
9043
					
11534
					
9044
						}#if end
11535
						}#if end
9045
				
11536
				
-
 
11537
					#預設 cert_and_ca_bundle.crt 不用更新
-
 
11538
					$cert_and_ca_bundle_need_update="false";
-
 
11539
				
9046
					#如果既有憑證跟剛下載的憑證不一樣
11540
					#如果既有憑證跟剛下載的憑證不一樣
9047
					if($getFileContent["fullContent"]!==$getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]){
11541
					if($getFileContent["fullContent"]!==$getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]){
9048
					
11542
					
9049
						#識別要改成下載好的憑證
11543
						#識別要改成下載好的憑證
9050
						$cert_and_ca_bundle_need_update="true";
11544
						$cert_and_ca_bundle_need_update="true";
9051
						
11545
						
9052
						#if enable debug
11546
						#if enable debug
9053
						if($debug){
11547
						if($debug){
9054
						
11548
						
9055
							#debug msg
11549
							#debug msg
9056
							echo "SSL(cert and ca_bundle) for domain name(".$cInfo["apiDomain"].") differs between host and zerossl".PHP_EOL;
11550
							echo "SSL(cert and ca_bundle) for domain name(".$cName.") differs between host and zerossl".PHP_EOL;
9057
						
11551
						
9058
							}#if end
11552
							}#if end
9059
					
11553
					
9060
						}#if end
11554
						}#if end
9061
					
11555
					
Line 9067... Line 11561...
9067
					
11561
					
9068
						#if enable debug
11562
						#if enable debug
9069
						if($debug){
11563
						if($debug){
9070
					
11564
					
9071
							#debug msg
11565
							#debug msg
9072
							echo "Updating host ssl(certificate.crt) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11566
							echo "Updating host ssl(certificate.crt) for domain name(".$cName.")...".PHP_EOL;
9073
						
11567
						
9074
							}#if end
11568
							}#if end
9075
					
11569
					
9076
						#更新之
11570
						#更新之
9077
						#函式說明:
11571
						#函式說明:
Line 9087... Line 11581...
9087
						#$result["argu"],使用的參數.
11581
						#$result["argu"],使用的參數.
9088
						#必填參數:
11582
						#必填參數:
9089
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11583
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9090
						$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
11584
						$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
9091
						#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
11585
						#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
9092
						$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["certPath"]);
11586
						$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["ssl"]["certPath"]);
9093
						#可省略參數:
11587
						#可省略參數:
9094
						#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
11588
						#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
9095
						$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"]);
11589
						$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"]);
9096
						#參考資料:
11590
						#參考資料:
9097
						#無.
11591
						#無.
9098
						#備註:
11592
						#備註:
9099
						#無.
11593
						#無.
9100
						$writeMultiFile=zerossl::writeMultiFile($conf["zerossl::writeMultiFile"]);
11594
						$writeMultiFile=fileAccess::writeMultiFile($conf["zerossl::writeMultiFile"]);
9101
						unset($conf["zerossl::writeMultiFile"]);
11595
						unset($conf["zerossl::writeMultiFile"]);
9102
						
11596
						
9103
						#如果執行異常
11597
						#如果執行異常
9104
						if($writeMultiFile["status"]==="false"){
11598
						if($writeMultiFile["status"]==="false"){
9105
						
11599
						
Line 9121... Line 11615...
9121
					
11615
					
9122
						#if enable debug
11616
						#if enable debug
9123
						if($debug){
11617
						if($debug){
9124
					
11618
					
9125
							#debug msg
11619
							#debug msg
9126
							echo "Updating host ssl(ca_bundle.crt) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11620
							echo "Updating host ssl(ca_bundle.crt) for domain name(".$cName.")...".PHP_EOL;
9127
						
11621
						
9128
							}#if end
11622
							}#if end
9129
					
11623
					
9130
						#更新之
11624
						#更新之
9131
						#函式說明:
11625
						#函式說明:
Line 9141... Line 11635...
9141
						#$result["argu"],使用的參數.
11635
						#$result["argu"],使用的參數.
9142
						#必填參數:
11636
						#必填參數:
9143
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11637
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9144
						$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
11638
						$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
9145
						#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
11639
						#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
9146
						$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["caPath"]);
11640
						$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["ssl"]["caPath"]);
9147
						#可省略參數:
11641
						#可省略參數:
9148
						#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
11642
						#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
9149
						$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["ca_bundle.crt"]);
11643
						$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["ca_bundle.crt"]);
9150
						#參考資料:
11644
						#參考資料:
9151
						#無.
11645
						#無.
9152
						#備註:
11646
						#備註:
9153
						#無.
11647
						#無.
9154
						$writeMultiFile=zerossl::writeMultiFile($conf["zerossl::writeMultiFile"]);
11648
						$writeMultiFile=fileAccess::writeMultiFile($conf["zerossl::writeMultiFile"]);
9155
						unset($conf["zerossl::writeMultiFile"]);
11649
						unset($conf["zerossl::writeMultiFile"]);
9156
						
11650
						
9157
						#如果執行異常
11651
						#如果執行異常
9158
						if($writeMultiFile["status"]==="false"){
11652
						if($writeMultiFile["status"]==="false"){
9159
						
11653
						
Line 9175... Line 11669...
9175
					
11669
					
9176
						#if enable debug
11670
						#if enable debug
9177
						if($debug){
11671
						if($debug){
9178
					
11672
					
9179
							#debug msg
11673
							#debug msg
9180
							echo "Updating host ssl(cert and ca_bundle) for domain name(".$cInfo["apiDomain"].")...".PHP_EOL;
11674
							echo "Updating host ssl(cert and ca_bundle) for domain name(".$cName.")...".PHP_EOL;
9181
						
11675
						
9182
							}#if end
11676
							}#if end
9183
					
11677
					
9184
						#更新之
11678
						#更新之
9185
						#函式說明:
11679
						#函式說明:
Line 9195... Line 11689...
9195
						#$result["argu"],使用的參數.
11689
						#$result["argu"],使用的參數.
9196
						#必填參數:
11690
						#必填參數:
9197
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11691
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9198
						$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
11692
						$conf["zerossl::writeMultiFile"]["fileArgu"]=__FILE__;
9199
						#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
11693
						#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
9200
						$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["certWithCaPath"]);
11694
						$conf["zerossl::writeMultiFile"]["fileName"]=array($cInfo["ssl"]["certWithCaPath"]);
9201
						#可省略參數:
11695
						#可省略參數:
9202
						#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
11696
						#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
9203
						$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]);
11697
						$conf["zerossl::writeMultiFile"]["inputString"]=array($getCert["certificate.crt"].PHP_EOL.$getCert["ca_bundle.crt"]);
9204
						#參考資料:
11698
						#參考資料:
9205
						#無.
11699
						#無.
9206
						#備註:
11700
						#備註:
9207
						#無.
11701
						#無.
9208
						$writeMultiFile=zerossl::writeMultiFile($conf["zerossl::writeMultiFile"]);
11702
						$writeMultiFile=fileAccess::writeMultiFile($conf["zerossl::writeMultiFile"]);
9209
						unset($conf["zerossl::writeMultiFile"]);
11703
						unset($conf["zerossl::writeMultiFile"]);
9210
						
11704
						
9211
						#如果執行異常
11705
						#如果執行異常
9212
						if($writeMultiFile["status"]==="false"){
11706
						if($writeMultiFile["status"]==="false"){
9213
						
11707
						
Line 9229... Line 11723...
9229
					
11723
					
9230
						#if enable debug
11724
						#if enable debug
9231
						if($debug){
11725
						if($debug){
9232
					
11726
					
9233
							#debug msg
11727
							#debug msg
9234
							echo "Action required to apply ssl for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
11728
							echo "Action required to apply ssl for domain name(".$cName.")".PHP_EOL;
9235
						
11729
						
9236
							}#if end
11730
							}#if end
9237
					
11731
					
9238
						#儲存 actionAfterUpdateCert
11732
						#儲存 actionAfterUpdateCert
9239
						$action=$cInfo["actionAfterUpdateCert"];
11733
						$action=$cInfo["actionAfterUpdateCert"];
Line 9243... Line 11737...
9243
							
11737
							
9244
							#if enable debug
11738
							#if enable debug
9245
							if($debug){
11739
							if($debug){
9246
						
11740
						
9247
								#debug msg
11741
								#debug msg
9248
								echo "There are many cmds to run to apply ssl for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
11742
								echo "There are many cmds to run to apply ssl for domain name(".$cName.")".PHP_EOL;
9249
							
11743
							
9250
								}#if end
11744
								}#if end
9251
							
11745
							
9252
							#針對每的指令
11746
							#針對每的指令
9253
							foreach($action as $ac){
11747
							foreach($action as $ac){
Line 9377... Line 11871...
9377
							
11871
							
9378
								}#foreach end
11872
								}#foreach end
9379
							
11873
							
9380
							}#if end
11874
							}#if end
9381
						
11875
						
9382
							#反之
11876
						#反之
9383
							else{
11877
						else{
9384
							
11878
						
9385
								#if enable debug
11879
							#if enable debug
9386
								if($debug){
11880
							if($debug){
-
 
11881
						
-
 
11882
								#debug msg
-
 
11883
								echo "There is only one cmd to run to apply ssl for domain name(".$cName.")".PHP_EOL;
9387
							
11884
							
9388
									#debug msg
-
 
9389
									echo "There is only one cmd to run to apply ssl for domain name(".$cInfo["apiDomain"].")".PHP_EOL;
-
 
9390
								
-
 
9391
									}#if end
11885
								}#if end
9392
							
11886
							
9393
								#函式說明:
11887
							#函式說明:
9394
								#解析指令與參數,回傳指令與參數給 callShell 函式使用.
11888
							#解析指令與參數,回傳指令與參數給 callShell 函式使用.
9395
								#回傳結果:
11889
							#回傳結果:
9396
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11890
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9397
								#$result["error"],錯誤訊息陣列.
11891
							#$result["error"],錯誤訊息陣列.
9398
								#$result["function"],當前執行的函數名稱.
11892
							#$result["function"],當前執行的函數名稱.
9399
								#$result["argu"],使用的參數.
11893
							#$result["argu"],使用的參數.
9400
								#$result["cmd"],執行的指令名稱.
11894
							#$result["cmd"],執行的指令名稱.
9401
								#$result["params"],執行指令伴隨的參數.
11895
							#$result["params"],執行指令伴隨的參數.
9402
								#必填參數:
11896
							#必填參數:
9403
								#$conf["cmdArray"],字串陣列,要執行的指令字串.
11897
							#$conf["cmdArray"],字串陣列,要執行的指令字串.
9404
								$conf["external::callShellHelper"]["cmdArray"]=$action;
11898
							$conf["external::callShellHelper"]["cmdArray"]=$action;
9405
								#可省略參數:
11899
							#可省略參數:
9406
								#無.
11900
							#無.
9407
								#參考資料:
11901
							#參考資料:
9408
								#array_shift=>https://www.php.net/manual/en/function.array-shift.php
11902
							#array_shift=>https://www.php.net/manual/en/function.array-shift.php
9409
								#備註:
11903
							#備註:
9410
								#無.
11904
							#無.
9411
								$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
11905
							$callShellHelper=external::callShellHelper($conf["external::callShellHelper"]);
9412
								unset($conf["external::callShellHelper"]);
11906
							unset($conf["external::callShellHelper"]);
-
 
11907
						
-
 
11908
							#如果執行異常
-
 
11909
							if($callShellHelper["status"]==="false"){
9413
							
11910
							
9414
								#如果執行異常
-
 
9415
								if($callShellHelper["status"]==="false"){
-
 
9416
								
-
 
9417
									#設置錯誤識別
11911
								#設置錯誤識別
9418
									$result["status"]="false";
11912
								$result["status"]="false";
9419
 
11913
 
9420
									#設置錯誤訊息
11914
								#設置錯誤訊息
9421
									$result["error"]=$callShellHelper;
11915
								$result["error"]=$callShellHelper;
9422
 
11916
 
9423
									#回傳結果
11917
								#回傳結果
9424
									return $result;
11918
								return $result;
9425
								
11919
							
9426
									}#if end
11920
								}#if end
9427
									
11921
									
9428
								#函式說明:
11922
							#函式說明:
9429
								#呼叫shell執行系統命令,並取得回傳的內容.
11923
							#呼叫shell執行系統命令,並取得回傳的內容.
9430
								#回傳結果:
11924
							#回傳結果:
9431
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11925
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9432
								#$result["error"],錯誤訊息陣列.
11926
							#$result["error"],錯誤訊息陣列.
9433
								#$result["function"],當前執行的函數名稱.
11927
							#$result["function"],當前執行的函數名稱.
9434
								#$result["argu"],使用的參數.
11928
							#$result["argu"],使用的參數.
9435
								#$result["cmd"],執行的指令內容.
11929
							#$result["cmd"],執行的指令內容.
9436
								#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
11930
							#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
9437
								#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
11931
							#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
9438
								#$result["content"],為執行完後的輸出字串.
11932
							#$result["content"],為執行完後的輸出字串.
9439
								#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
11933
							#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
9440
								#$result["running"],是否還在執行.
11934
							#$result["running"],是否還在執行.
9441
								#$result["pid"],pid.
11935
							#$result["pid"],pid.
9442
								#$result["statusCode"],執行結束後的代碼.
11936
							#$result["statusCode"],執行結束後的代碼.
9443
								#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
11937
							#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
9444
								#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
11938
							#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
9445
								#必填參數:
11939
							#必填參數:
9446
								#$conf["command"],字串,要執行的指令.
11940
							#$conf["command"],字串,要執行的指令.
9447
								$conf["external::callShell"]["command"]=$callShellHelper["cmd"];
11941
							$conf["external::callShell"]["command"]=$callShellHelper["cmd"];
9448
								#$conf["fileArgu"],字串,變數__FILE__的內容.
11942
							#$conf["fileArgu"],字串,變數__FILE__的內容.
9449
								$conf["external::callShell"]["fileArgu"]=__FILE__;
11943
							$conf["external::callShell"]["fileArgu"]=__FILE__;
9450
								#可省略參數:
11944
							#可省略參數:
9451
								#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
11945
							#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
9452
								$conf["external::callShell"]["argu"]=$callShellHelper["params"];
11946
							$conf["external::callShell"]["argu"]=$callShellHelper["params"];
9453
								#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
11947
							#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
9454
								#$conf["arguIsAddr"]=array();
11948
							#$conf["arguIsAddr"]=array();
9455
								#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
11949
							#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
9456
								#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
11950
							#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
9457
								#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
11951
							#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
9458
								#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
11952
							#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
9459
								#$conf["enablePrintDescription"]="true";
11953
							#$conf["enablePrintDescription"]="true";
9460
								#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
11954
							#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
9461
								#$conf["printDescription"]="";
11955
							#$conf["printDescription"]="";
9462
								#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
11956
							#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
9463
								$conf["external::callShell"]["escapeshellarg"]="true";
11957
							$conf["external::callShell"]["escapeshellarg"]="true";
9464
								#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
11958
							#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
9465
								#$conf["thereIsShellVar"]=array();
11959
							#$conf["thereIsShellVar"]=array();
9466
								#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
11960
							#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
9467
								#$conf["username"]="";
11961
							#$conf["username"]="";
9468
								#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
11962
							#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
9469
								#$conf["password"]="";
11963
							#$conf["password"]="";
9470
								#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
11964
							#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
9471
								#$conf["useScript"]="";
11965
							#$conf["useScript"]="";
9472
								#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
11966
							#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
9473
								#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
11967
							#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
9474
								#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
11968
							#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
9475
								#$conf["inBackGround"]="";
11969
							#$conf["inBackGround"]="";
9476
								#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
11970
							#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
9477
								#$conf["getErr"]="false";
11971
							#$conf["getErr"]="false";
9478
								#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
11972
							#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
9479
								#$conf["doNotRun"]="false";
11973
							#$conf["doNotRun"]="false";
9480
								#$conf["remoteIp"],字串,遠端ip或domainName,預設不使用,若存在則會透過ssh指令進行連線,然後執行指令.
11974
							#$conf["remoteIp"],字串,遠端ip或domainName,預設不使用,若存在則會透過ssh指令進行連線,然後執行指令.
9481
								#$conf["remoteIp"]="";
11975
							#$conf["remoteIp"]="";
9482
								#$conf["remoteUser"],字串,遠端的使用者賬戶,預設不指定,亦即跟為運行該php程式的使用者.
11976
							#$conf["remoteUser"],字串,遠端的使用者賬戶,預設不指定,亦即跟為運行該php程式的使用者.
9483
								#$conf["remoteUser"]="";
11977
							#$conf["remoteUser"]="";
9484
								#參考資料:
11978
							#參考資料:
9485
								#exec=>http://php.net/manual/en/function.exec.php
11979
							#exec=>http://php.net/manual/en/function.exec.php
9486
								#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
11980
							#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
9487
								#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
11981
							#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
9488
								#備註:
11982
							#備註:
9489
								#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
11983
							#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
9490
								#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
11984
							#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
9491
								$callShell=external::callShell($conf["external::callShell"]);
11985
							$callShell=external::callShell($conf["external::callShell"]);
9492
								unset($conf["external::callShell"]);
11986
							unset($conf["external::callShell"]);
-
 
11987
						
-
 
11988
							#如果執行異常
-
 
11989
							if($callShellHelper["status"]==="false"){
9493
							
11990
							
9494
								#如果執行異常
-
 
9495
								if($callShellHelper["status"]==="false"){
-
 
9496
								
-
 
9497
									#設置錯誤識別
11991
								#設置錯誤識別
9498
									$result["status"]="false";
11992
								$result["status"]="false";
9499
 
11993
 
9500
									#設置錯誤訊息
11994
								#設置錯誤訊息
9501
									$result["error"]=$callShell;
11995
								$result["error"]=$callShell;
9502
 
11996
 
9503
									#回傳結果
11997
								#回傳結果
9504
									return $result;
11998
								return $result;
9505
								
-
 
9506
									}#if end
-
 
9507
							
11999
							
9508
								}#else end
12000
								}#if end
9509
								
12001
						
9510
							}#if end
12002
							}#else end
9511
					
12003
						
9512
						}#if end
12004
						}#if end
9513
				
12005
					
9514
					}#else end
12006
					}#else end
9515
				
12007
				
9516
				}#else end
12008
				}#else end
9517
		
12009
				
9518
			}#foreach end
12010
			}#foreach end
9519
		
12011
		
9520
		}#function sslUpdater_idle end
12012
		}#function sslUpdater_idle end
9521
 
12013
 
9522
	}#class zerossl end
12014
	}#class zerossl end