Subversion Repositories php-qbpwcf

Rev

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

Rev 239 Rev 249
Line 122... Line 122...
122
		$result=array();
122
		$result=array();
123
 
123
 
124
		#api domain
124
		#api domain
125
		$result["apiDomain"]="api.zerossl.com";
125
		$result["apiDomain"]="api.zerossl.com";
126
 
126
 
127
		#create certificate path
127
		#create certificate api path
128
		$result["csrPath"]="/certificates";
128
		$result["csrPath"]="/certificates";
129
 
129
 
130
		#create certificate url
130
		#create certificate url
131
		$result["csrUrl"]=$result["apiDomain"].$result["csrPath"];
131
		$result["csrUrl"]=$result["apiDomain"].$result["csrPath"];
132
 
132
 
Line 401... Line 401...
401
 
401
 
402
		}#function createPrivateKey end
402
		}#function createPrivateKey end
403
 
403
 
404
	/*
404
	/*
405
	#函式說明:
405
	#函式說明:
406
	#產生certificate sign request.
406
	#產生certificate sign request(CSR).
407
	#回傳結果:
407
	#回傳結果:
408
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
408
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
409
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
409
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
410
	#$result["function"],當前執行的函式名稱.
410
	#$result["function"],當前執行的函式名稱.
411
	#$result["argu"],所使用的參數.
411
	#$result["argu"],所使用的參數.
412
	#$result["curl_verbose_info"],curl執行的詳細資訊.
412
	#$result["curl_verbose_info"],curl執行的詳細資訊.
413
	#必填參數:
413
	#必填參數:
-
 
414
	#$conf["domain"],字串,csr內容的網域名稱.
-
 
415
	#$conf["domain"]="";
-
 
416
	#可省略參數:
-
 
417
	#$conf["country"],字串,csr內容的國家名稱,預設為"TW".
-
 
418
	#$conf["country"]="";
-
 
419
	#$conf["state"],字串,csr內容的State名稱,預設為"Taiwan".
-
 
420
	#$conf["state"]="";
-
 
421
	#$conf["org"],字串,csr內容的組織名稱,預設為"QBPWCF".
-
 
422
	#$conf["org"]="";
-
 
423
	#$conf["unit"],字串,csr內容的組織所屬單位,預設為"RD".
-
 
424
	#$conf["unit"]="";
-
 
425
	#參考資料:
-
 
426
	#無.
-
 
427
	#備註:
-
 
428
	#無.
-
 
429
	*/
-
 
430
	public static function createCSR(&$conf){
-
 
431
	
-
 
432
		#初始化要回傳的結果
-
 
433
		$result=array();
-
 
434
 
-
 
435
		#設置當其函數名稱
-
 
436
		$result["function"]=__FUNCTION__;
-
 
437
 
-
 
438
		#如果 $conf 不為陣列
-
 
439
		if(gettype($conf)!="array"){
-
 
440
 
-
 
441
			#設置執行失敗
-
 
442
			$result["status"]="false";
-
 
443
 
-
 
444
			#設置執行錯誤訊息
-
 
445
			$result["error"][]="\$conf變數須為陣列形態";
-
 
446
 
-
 
447
			#如果傳入的參數為 null
-
 
448
			if($conf==null){
-
 
449
 
-
 
450
				#設置執行錯誤訊息
-
 
451
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
452
 
-
 
453
				}#if end
-
 
454
 
-
 
455
			#回傳結果
-
 
456
			return $result;
-
 
457
 
-
 
458
			}#if end
-
 
459
 
-
 
460
		#取得參數
-
 
461
		$result["argu"]=$conf;
-
 
462
 
-
 
463
		#檢查參數
-
 
464
		#函式說明:
-
 
465
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
-
 
466
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
467
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
468
		#$result["function"],當前執行的函式名稱.
-
 
469
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
470
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
471
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
472
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
473
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
474
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
475
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
476
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
477
		#必填寫的參數:
-
 
478
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
479
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
480
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
481
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("domain");
-
 
482
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
-
 
483
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
-
 
484
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
485
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
486
		#可以省略的參數:
-
 
487
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
488
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
-
 
489
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
-
 
490
		#$conf["skipableVariableCanNotBeEmpty"]=array();
-
 
491
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
492
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("country","state","city","org","unit");
-
 
493
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
494
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string");
-
 
495
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
496
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("TW","Taiwan","Taoyuan City","QBPWCF","RD");
-
 
497
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
498
		#$conf["arrayCountEqualCheck"][]=array();
-
 
499
		#參考資料來源:
-
 
500
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
501
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
502
		unset($conf["variableCheck::checkArguments"]);
-
 
503
 
-
 
504
		#如果檢查失敗
-
 
505
		if($checkArguments["status"]==="false"){
-
 
506
 
-
 
507
			#設置錯誤識別
-
 
508
			$result["status"]="false";
-
 
509
 
-
 
510
			#設置錯誤訊息
-
 
511
			$result["error"]=$checkArguments;
-
 
512
 
-
 
513
			#回傳結果
-
 
514
			return $result;
-
 
515
 
-
 
516
			}#if end
-
 
517
 
-
 
518
		#如果檢查不通過
-
 
519
		if($checkArguments["passed"]==="false"){
-
 
520
 
-
 
521
			#設置錯誤識別
-
 
522
			$result["status"]="false";
-
 
523
 
-
 
524
			#設置錯誤訊息
-
 
525
			$result["error"]=$checkArguments;
-
 
526
 
-
 
527
			#回傳結果
-
 
528
			return $result;
-
 
529
 
-
 
530
			}#if end
-
 
531
		
-
 
532
		#產生uuid名稱
-
 
533
		#函式說明:
-
 
534
		#使用 linux 的 uuid 指令來產生 uuid 字串
-
 
535
		#回傳結果:
-
 
536
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
537
		#$result["error"],錯誤訊息.
-
 
538
		#$result["function"],當前執行的函式名稱.
-
 
539
		#$result["content"],uuid.
-
 
540
		#必填參數:
-
 
541
		#無.
-
 
542
		#可省略參數:
-
 
543
		#無.
-
 
544
		#參考資料:
-
 
545
		#無.
-
 
546
		#備註:
-
 
547
		#無.
-
 
548
		$uuid=cmd::uuid();
-
 
549
		
-
 
550
		#如果執行異常
-
 
551
		if($uuid["status"]==="false"){
-
 
552
 
-
 
553
			#設置錯誤識別
-
 
554
			$result["status"]="false";
-
 
555
 
-
 
556
			#設置錯誤訊息
-
 
557
			$result["error"]=$uuid;
-
 
558
 
-
 
559
			#回傳結果
-
 
560
			return $result;
-
 
561
 
-
 
562
			}#if end
-
 
563
		
-
 
564
		#取得暫存的檔案名稱
-
 
565
		$TFN=$uuid["content"];
-
 
566
		
-
 
567
		#函式說明:
-
 
568
		#於本套件位置底下的tmp資料夾下建立與回傳暫存檔案名稱路徑
-
 
569
		#回傳結果:
-
 
570
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
571
		#$result["error"],錯誤訊息.
-
 
572
		#$result["function"],當前執行的函數名稱.
-
 
573
		#$result["content"],暫存檔案的路徑與名稱.
-
 
574
		#$result["fileName"],暫存檔案的名稱.
-
 
575
		#$result["path"],暫存檔案的路徑.
-
 
576
		#必填參數:
-
 
577
		#無.
-
 
578
		#可省略參數:
-
 
579
		#$conf["content"],陣列,每行檔案的內容,預設為空陣列,不寫入任何資料.
-
 
580
		#$conf["contant"]=array();
-
 
581
		#參考資料:
-
 
582
		#無.
-
 
583
		#備註:
-
 
584
		#無.
-
 
585
		$conf["fileAccess::createTempFile"]=array();
-
 
586
		$createTempFile=fileAccess::createTempFile($conf["fileAccess::createTempFile"]);
-
 
587
		unset($conf["fileAccess::createTempFile"]);
-
 
588
		
-
 
589
		#如果執行異常
-
 
590
		if($createTempFile["status"]==="false"){
-
 
591
 
-
 
592
			#設置錯誤識別
-
 
593
			$result["status"]="false";
-
 
594
 
-
 
595
			#設置錯誤訊息
-
 
596
			$result["error"]=$createTempFile;
-
 
597
 
-
 
598
			#回傳結果
-
 
599
			return $result;
-
 
600
 
-
 
601
			}#if end
-
 
602
		
-
 
603
		#暫存的檔案路徑與名稱
-
 
604
		$TFN=$createTempFile["content"];
-
 
605
		
-
 
606
		#產生 privae key
-
 
607
		#openssl genrsa -out output.key 4096 
-
 
608
		
-
 
609
		#函式說明:
-
 
610
		#呼叫shell執行系統命令,並取得回傳的內容.
-
 
611
		#回傳結果:
-
 
612
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
613
		#$result["error"],錯誤訊息陣列.
-
 
614
		#$result["function"],當前執行的函數名稱.
-
 
615
		#$result["argu"],使用的參數.
-
 
616
		#$result["cmd"],執行的指令內容.
-
 
617
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
618
		#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
-
 
619
		#$result["content"],為執行完後的輸出字串.
-
 
620
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
621
		#$result["running"],是否還在執行.
-
 
622
		#$result["pid"],pid.
-
 
623
		#$result["statusCode"],執行結束後的代碼.
-
 
624
		#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
625
		#$result["noEcaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
626
		#必填參數:
-
 
627
		#$conf["command"],字串,要執行的指令.
-
 
628
		$conf["external::callShell"]["command"]="openssl";
-
 
629
		#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
630
		$conf["external::callShell"]["fileArgu"]=__FILE__;
-
 
631
		#可省略參數:
-
 
632
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
-
 
633
		$conf["external::callShell"]["argu"]=array("genrsa","-out",$TFN,"4096");
-
 
634
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
-
 
635
		#$conf["arguIsAddr"]=array();
-
 
636
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
-
 
637
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
-
 
638
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
-
 
639
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
-
 
640
		#$conf["enablePrintDescription"]="true";
-
 
641
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
-
 
642
		#$conf["printDescription"]="";
-
 
643
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
-
 
644
		#$conf["escapeshellarg"]="false";
-
 
645
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
-
 
646
		#$conf["thereIsShellVar"]=array();
-
 
647
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
-
 
648
		#$conf["username"]="";
-
 
649
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
-
 
650
		#$conf["password"]="";
-
 
651
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
-
 
652
		#$conf["useScript"]="";
-
 
653
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
-
 
654
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
-
 
655
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
-
 
656
		#$conf["inBackGround"]="";
-
 
657
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
-
 
658
		#$conf["getErr"]="false";
-
 
659
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
-
 
660
		$conf["external::callShell"]["doNotRun"]="true";
-
 
661
		#參考資料:
-
 
662
		#exec=>http://php.net/manual/en/function.exec.php
-
 
663
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
-
 
664
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
-
 
665
		#備註:
-
 
666
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
-
 
667
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
-
 
668
		$callShell=external::callShell($conf["external::callShell"]);
-
 
669
		unset($conf["external::callShell"]);
-
 
670
		
-
 
671
		#如果執行異常
-
 
672
		if($callShell["status"]==="false"){
-
 
673
 
-
 
674
			#設置錯誤識別
-
 
675
			$result["status"]="false";
-
 
676
 
-
 
677
			#設置錯誤訊息
-
 
678
			$result["error"]=$callShell;
-
 
679
 
-
 
680
			#回傳結果
-
 
681
			return $result;
-
 
682
 
-
 
683
			}#if end
-
 
684
		
-
 
685
		#debug
-
 
686
		#var_dump(__LINE__,$callShell);exit;
-
 
687
		
-
 
688
		#函式說明:
-
 
689
		#透過proc來多執行序運作.
-
 
690
		#回傳結果:
-
 
691
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
692
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
693
		#$result["function"],當前執行的函式名稱.
-
 
694
		#$result["argu"],使用的參數.
-
 
695
		#$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"代表程序的資訊.
-
 
696
		#必填參數:
-
 
697
		#$conf["cmds"],字串陣列,每個元素代表單一程序要執行的指令與參數.
-
 
698
		$conf["threads::proc"]["cmds"]=array($callShell["cmd"]);
-
 
699
		#可省略參數:
-
 
700
		#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
-
 
701
		$conf["threads::proc"]["wait"]="true";
-
 
702
		#$conf["timeout"],字串陣列,每個元素代表單一程序執行的最大等待秒數,超過後將會強迫停止執行,僅當wait參數為"true"時生效.
-
 
703
		#$conf["timeout"]=array("10");
-
 
704
		#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
-
 
705
		#$conf["workingDir"]=array("path");
-
 
706
		#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
-
 
707
		#$conf["envs"]=array(array("key"=>"value"));
-
 
708
		#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
-
 
709
		#$conf["executeBy"]=array("bash");
-
 
710
		#參考資料:
-
 
711
		#https://www.php.net/manual/en/function.proc-open.php
-
 
712
		#https://www.php.net/manual/en/function.proc-get-status.php
-
 
713
		#https://www.php.net/manual/en/function.proc-terminate.php
-
 
714
		#備註:
-
 
715
		#若需要取得當下的執行狀況,請使用 self::proc_update 來更新.
-
 
716
		$proc=threads::proc($conf["threads::proc"]);
-
 
717
		unset($conf["threads::proc"]);
-
 
718
		
-
 
719
		#如果執行異常
-
 
720
		if($proc["status"]==="false"){
-
 
721
 
-
 
722
			#設置錯誤識別
-
 
723
			$result["status"]="false";
-
 
724
 
-
 
725
			#設置錯誤訊息
-
 
726
			$result["error"]=$proc;
-
 
727
 
-
 
728
			#回傳結果
-
 
729
			return $result;
-
 
730
 
-
 
731
			}#if end
-
 
732
		
-
 
733
		#debug
-
 
734
		#var_dump(__LINE__,$proc);exit;
-
 
735
		
-
 
736
		#如果執行異常
-
 
737
		if($proc["content"][0]["status"]==="false"){
-
 
738
		
-
 
739
			#設置錯誤識別
-
 
740
			$result["status"]="false";
-
 
741
 
-
 
742
			#設置錯誤訊息
-
 
743
			$result["error"]=$proc["content"][0]["error"];
-
 
744
 
-
 
745
			#回傳結果
-
 
746
			return $result;
-
 
747
		
-
 
748
			}#if end
-
 
749
		
-
 
750
		#儲存錯誤訊息
-
 
751
		$errorMsg=$proc["content"][0]["error"];
-
 
752
		
-
 
753
		#如果有錯誤訊息
-
 
754
		if(!empty($errorMsg)){
-
 
755
		
-
 
756
			#設置錯誤識別
-
 
757
			$result["status"]="false";
-
 
758
 
-
 
759
			#設置錯誤訊息
-
 
760
			$result["error"]=$errorMsg;
-
 
761
 
-
 
762
			#回傳結果
-
 
763
			return $result;
-
 
764
		
-
 
765
			}#if end
-
 
766
		
-
 
767
		#範例指令
-
 
768
		#C,國家,例如TW,代表Taiwan
-
 
769
		#ST,州、省,要完整名稱,例如:Taiwan
-
 
770
		#L,城市名稱,例如Taoyuan City.
-
 
771
		#O=,組織或公司名稱,例如QBPWCF.
-
 
772
		#OU,單位名稱,例如RD.
-
 
773
		#CN,網域名稱,例如www.qbpwcf.org
-
 
774
		#openssl req -new -key qbpwcf.org.key -out qbpwcf.org.csr "-subj=/C=TW/ST=Taiwan/L=Taoyuan City/O=QBPWCF/OU=RD/CN=www.qbpwcf.org/"
-
 
775
		
-
 
776
		#初始化subj參數
-
 
777
		$subjStr="-subj=/";
-
 
778
		
-
 
779
		#設置 Country 參數
-
 
780
		$subjStr=$subjStr."C=".$conf["country"]."/";
-
 
781
		
-
 
782
		#設置 State 參數
-
 
783
		$subjStr=$subjStr."ST=".$conf["state"]."/";
-
 
784
		
-
 
785
		#設置 city 參數
-
 
786
		$subjStr=$subjStr."L=".$conf["city"]."/";
-
 
787
		
-
 
788
		#設置 Org 參數
-
 
789
		$subjStr=$subjStr."O=".$conf["org"]."/";
-
 
790
		
-
 
791
		#設置 Unit 參數
-
 
792
		$subjStr=$subjStr."OU=".$conf["unit"]."/";
-
 
793
		
-
 
794
		#設置 domain name 參數
-
 
795
		$subjStr=$subjStr."CN=".$conf["domain"]."/";
-
 
796
		
-
 
797
		#函式說明:
-
 
798
		#呼叫shell執行系統命令,並取得回傳的內容.
-
 
799
		#回傳結果:
-
 
800
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
801
		#$result["error"],錯誤訊息陣列.
-
 
802
		#$result["function"],當前執行的函數名稱.
-
 
803
		#$result["argu"],使用的參數.
-
 
804
		#$result["cmd"],執行的指令內容.
-
 
805
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
806
		#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
-
 
807
		#$result["content"],為執行完後的輸出字串.
-
 
808
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
809
		#$result["running"],是否還在執行.
-
 
810
		#$result["pid"],pid.
-
 
811
		#$result["statusCode"],執行結束後的代碼.
-
 
812
		#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
813
		#$result["noEcaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
814
		#必填參數:
-
 
815
		#$conf["command"],字串,要執行的指令.
-
 
816
		$conf["external::callShell"]["command"]="openssl";
-
 
817
		#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
818
		$conf["external::callShell"]["fileArgu"]=__FILE__;
-
 
819
		#可省略參數:
-
 
820
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
-
 
821
		$conf["external::callShell"]["argu"]=array("req","-new","-key",$TFN,$subjStr);
-
 
822
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
-
 
823
		#$conf["arguIsAddr"]=array();
-
 
824
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
-
 
825
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
-
 
826
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
-
 
827
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
-
 
828
		#$conf["enablePrintDescription"]="true";
-
 
829
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
-
 
830
		#$conf["printDescription"]="";
-
 
831
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
-
 
832
		$conf["external::callShell"]["escapeshellarg"]="true";
-
 
833
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
-
 
834
		#$conf["thereIsShellVar"]=array();
-
 
835
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
-
 
836
		#$conf["username"]="";
-
 
837
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
-
 
838
		#$conf["password"]="";
-
 
839
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
-
 
840
		#$conf["useScript"]="";
-
 
841
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
-
 
842
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
-
 
843
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
-
 
844
		#$conf["inBackGround"]="";
-
 
845
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
-
 
846
		#$conf["getErr"]="false";
-
 
847
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
-
 
848
		$conf["external::callShell"]["doNotRun"]="true";
-
 
849
		#參考資料:
-
 
850
		#exec=>http://php.net/manual/en/function.exec.php
-
 
851
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
-
 
852
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
-
 
853
		#備註:
-
 
854
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
-
 
855
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
-
 
856
		$callShell=external::callShell($conf["external::callShell"]);
-
 
857
		unset($conf["external::callShell"]);
-
 
858
		
-
 
859
		#如果執行異常
-
 
860
		if($callShell["status"]==="false"){
-
 
861
 
-
 
862
			#設置錯誤識別
-
 
863
			$result["status"]="false";
-
 
864
 
-
 
865
			#設置錯誤訊息
-
 
866
			$result["error"]=$callShell;
-
 
867
 
-
 
868
			#回傳結果
-
 
869
			return $result;
-
 
870
 
-
 
871
			}#if end
-
 
872
		
-
 
873
		#debug
-
 
874
		#var_dump(__LINE__,$callShell);exit;
-
 
875
		
-
 
876
		#函式說明:
-
 
877
		#透過proc來多執行序運作.
-
 
878
		#回傳結果:
-
 
879
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
880
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
881
		#$result["function"],當前執行的函式名稱.
-
 
882
		#$result["argu"],使用的參數.
-
 
883
		#$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"代表程序的資訊.
-
 
884
		#必填參數:
-
 
885
		#$conf["cmds"],字串陣列,每個元素代表單一程序要執行的指令與參數.
-
 
886
		$conf["threads::proc"]["cmds"]=array($callShell["cmd"]);
-
 
887
		#可省略參數:
-
 
888
		#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
-
 
889
		$conf["threads::proc"]["wait"]="true";
-
 
890
		#$conf["timeout"],字串陣列,每個元素代表單一程序執行的最大等待秒數,超過後將會強迫停止執行,僅當wait參數為"true"時生效.
-
 
891
		#$conf["timeout"]=array("10");
-
 
892
		#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
-
 
893
		#$conf["workingDir"]=array("path");
-
 
894
		#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
-
 
895
		#$conf["envs"]=array(array("key"=>"value"));
-
 
896
		#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
-
 
897
		#$conf["executeBy"]=array("bash");
-
 
898
		#參考資料:
-
 
899
		#https://www.php.net/manual/en/function.proc-open.php
-
 
900
		#https://www.php.net/manual/en/function.proc-get-status.php
-
 
901
		#https://www.php.net/manual/en/function.proc-terminate.php
-
 
902
		#備註:
-
 
903
		#若需要取得當下的執行狀況,請使用 self::proc_update 來更新.
-
 
904
		$proc=threads::proc($conf["threads::proc"]);
-
 
905
		unset($conf["threads::proc"]);
-
 
906
		
-
 
907
		#如果執行異常
-
 
908
		if($proc["status"]==="false"){
-
 
909
 
-
 
910
			#設置錯誤識別
-
 
911
			$result["status"]="false";
-
 
912
 
-
 
913
			#設置錯誤訊息
-
 
914
			$result["error"]=$proc;
-
 
915
 
-
 
916
			#回傳結果
-
 
917
			return $result;
-
 
918
 
-
 
919
			}#if end
-
 
920
			
-
 
921
		#如果執行異常
-
 
922
		if($proc["content"][0]["status"]==="false"){
-
 
923
		
-
 
924
			#設置錯誤識別
-
 
925
			$result["status"]="false";
-
 
926
 
-
 
927
			#設置錯誤訊息
-
 
928
			$result["error"]=$proc["content"][0]["error"];
-
 
929
 
-
 
930
			#回傳結果
-
 
931
			return $result;
-
 
932
		
-
 
933
			}#if end
-
 
934
		
-
 
935
		#debug
-
 
936
		#var_dump(__LINE__,$proc);exit;
-
 
937
		
-
 
938
		#儲存csr
-
 
939
		$csr=$proc["content"][0]["content"];
-
 
940
		
-
 
941
		#取得 csr 內容
-
 
942
		$result["content"]=$csr;
-
 
943
		
-
 
944
		#移除private key
-
 
945
		#函式說明:
-
 
946
		#移除檔案
-
 
947
		#回傳結果:
-
 
948
		#$result["status"],"true"代表移除成功,"false"代表移除失敗.
-
 
949
		#$result["error"],錯誤訊息陣列.
-
 
950
		#$result["warning"],警告訊息陣列.
-
 
951
		#$result["function"],當前執行的函數名稱.
-
 
952
		#$result["argu"],當前函式使用的參數.
-
 
953
		#必填參數:
-
 
954
		#$conf["fileAddress"],字串,要移除檔案的位置.
-
 
955
		$conf["fileAccess::delFile"]["fileAddress"]=$TFN;
-
 
956
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
-
 
957
		$conf["fileAccess::delFile"]["fileArgu"]=__FILE__;
-
 
958
		#可省略參數:
-
 
959
		#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
-
 
960
		#$conf["commentsArray"]=array("");
-
 
961
		#$conf["allowDelSymlink"],字串,預設為"false",不移除軟連結;"true"代表要移除軟連結.
-
 
962
		#$conf["allowDelSymlink"]="true";
-
 
963
		#$conf["allowDelFolder"],字串,預設為"false",不移除目錄;"true"代表要移除目錄.
-
 
964
		#$conf["allowDelFolder"]="true";
-
 
965
		#參考資料:
-
 
966
		#無.
-
 
967
		#備註:
-
 
968
		#無.
-
 
969
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
-
 
970
		unset($conf["fileAccess::delFile"]);
-
 
971
		
-
 
972
		#如果執行異常
-
 
973
		if($delFile["status"]==="false"){
-
 
974
 
-
 
975
			#設置錯誤識別
-
 
976
			$result["status"]="false";
-
 
977
 
-
 
978
			#設置錯誤訊息
-
 
979
			$result["error"]=$delFile;
-
 
980
 
-
 
981
			#回傳結果
-
 
982
			return $result;
-
 
983
 
-
 
984
			}#if end
-
 
985
		
-
 
986
		#設置執行正常
-
 
987
		$result["status"]="true";
-
 
988
		
-
 
989
		#回傳結果
-
 
990
		return $result;
-
 
991
		
-
 
992
		}#function createCSR end
-
 
993
 
-
 
994
	/*
-
 
995
	#函式說明:
-
 
996
	#提供certificate sign request(CSR)透過zerossl產生cergificate.
-
 
997
	#回傳結果:
-
 
998
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
999
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1000
	#$result["function"],當前執行的函式名稱.
-
 
1001
	#$result["argu"],所使用的參數.
-
 
1002
	#$result["curl_verbose_info"],curl執行的詳細資訊.
-
 
1003
	#$result["id"],用於zerossl api驗證domain的id.
-
 
1004
	#$result["content"],字串,得到的json字串回應.
-
 
1005
	#$result["cnameKey"],用於dns CNAME驗證鍵名.
-
 
1006
	#$result["cnameVal"],用於dms CNAME驗證鍵值.
-
 
1007
	#必填參數:
414
	#$conf["certificate_domains"],字串,要簽署的doamin名稱.
1008
	#$conf["certificate_domains"],字串,要簽署的doamin名稱.
415
	$conf["certificate_domains"]="";
1009
	$conf["certificate_domains"]="";
416
	#$conf["certificate_csr"],字串,簽署的資訊.
1010
	#$conf["certificate_csr"],字串,簽署的資訊.
417
	$conf["certificate_csr"]="";
1011
	$conf["certificate_csr"]="";
418
	#$conf["fileArgu"],字串,變數__FILE__的內容.
1012
	#$conf["fileArgu"],字串,變數__FILE__的內容.
Line 427... Line 1021...
427
	#參考資料:
1021
	#參考資料:
428
	#無.
1022
	#無.
429
	#備註:
1023
	#備註:
430
	#無.
1024
	#無.
431
	*/
1025
	*/
432
	public static function csr(&$conf){
1026
	public static function createCertificate(&$conf){
433
 
1027
 
434
		#break point
1028
		#break point
435
		#var_dump(self::getApiInfo());exit;
1029
		#var_dump(self::getApiInfo());exit;
436
 
1030
 
437
		#初始化要回傳的結果
1031
		#初始化要回傳的結果
Line 505... Line 1099...
505
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1099
		#array_keys=>http://php.net/manual/en/function.array-keys.php
506
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1100
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
507
		unset($conf["variableCheck::checkArguments"]);
1101
		unset($conf["variableCheck::checkArguments"]);
508
 
1102
 
509
		#如果檢查失敗
1103
		#如果檢查失敗
510
		if($checkArguments["status"]=="false"){
1104
		if($checkArguments["status"]==="false"){
511
 
1105
 
512
			#設置錯誤識別
1106
			#設置錯誤識別
513
			$result["status"]="false";
1107
			$result["status"]="false";
514
 
1108
 
515
			#設置錯誤訊息
1109
			#設置錯誤訊息
Line 519... Line 1113...
519
			return $result;
1113
			return $result;
520
 
1114
 
521
			}#if end
1115
			}#if end
522
 
1116
 
523
		#如果檢查不通過
1117
		#如果檢查不通過
524
		if($checkArguments["passed"]=="false"){
1118
		if($checkArguments["passed"]==="false"){
525
 
1119
 
526
			#設置錯誤識別
1120
			#設置錯誤識別
527
			$result["status"]="false";
1121
			$result["status"]="false";
528
 
1122
 
529
			#設置錯誤訊息
1123
			#設置錯誤訊息
Line 613... Line 1207...
613
 
1207
 
614
		#設置curl的詳細資訊
1208
		#設置curl的詳細資訊
615
		$result["curl_verbose_info"]=$curlCmd;
1209
		$result["curl_verbose_info"]=$curlCmd;
616
 
1210
 
617
		/* 範例 json content
1211
		/* 範例 json content
618
		"{"id":"f1448a54da0925356faec06154989452","type":"1","common_name":"test.qbpwcf.org","additional_domains":"","created":"2024-11-27 12:05:52","expires":"2025-02-25 00:00:00","status":"draft","validation_type":null,"validation_emails":null,"replacement_for":"","validation":{"email_validation":{"test.qbpwcf.org":["admin@test.qbpwcf.org","administrator@test.qbpwcf.org","hostmaster@test.qbpwcf.org","postmaster@test.qbpwcf.org","webmaster@test.qbpwcf.org","admin@qbpwcf.org","administrator@qbpwcf.org","hostmaster@qbpwcf.org","postmaster@qbpwcf.org","webmaster@qbpwcf.org"]},"other_methods":{"test.qbpwcf.org":{"file_validation_url_http":"http:\/\/test.qbpwcf.org\/.well-known\/pki-validation\/5CED79AF9CCCB7C8633875D1A7C919FA.txt","file_validation_url_https":"https:\/\/test.qbpwcf.org\/.well-known\/pki-validation\/5CED79AF9CCCB7C8633875D1A7C919FA.txt","file_validation_content":["2C2CAB7C8B941192CB6BD9345DA3806BBC9F13A3DF3109C1E1A8B9B1ECC5B5FC","comodoca.com","42f21840bf8a7a6"],"cname_validation_p1":"_5CED79AF9CCCB7C8633875D1A7C919FA.test.qbpwcf.org","cname_validation_p2":"2C2CAB7C8B941192CB6BD9345DA3806B.BC9F13A3DF3109C1E1A8B9B1ECC5B5FC.42f21840bf8a7a6.comodoca.com"}}}}"
1212
		{"id":"de9bfbbc78ad2b04323ac0670efefe58","type":"1","common_name":"qbpwcf.org","additional_domains":"","created":"2026-01-19 11:47:13","expires":"2026-04-19 23:59:59","status":"draft","validation_type":null,"validation_emails":null,"replacement_for":"","fingerprint_sha1":null,"brand_validation":null,"validation":{"email_validation":{"qbpwcf.org":["admin@qbpwcf.org","administrator@qbpwcf.org","hostmaster@qbpwcf.org","postmaster@qbpwcf.org","webmaster@qbpwcf.org"]},"other_methods":{"qbpwcf.org":{"file_validation_url_http":"http:\/\/qbpwcf.org\/.well-known\/pki-validation\/3FE7CA1D6DA057FB40FDD333B4C105F9.txt","file_validation_url_https":"https:\/\/qbpwcf.org\/.well-known\/pki-validation\/3FE7CA1D6DA057FB40FDD333B4C105F9.txt","file_validation_content":["7B29341B7148276F5025CE90FC1138037871040E5B7FBDB8E7EEF7CC8DAA4A56","comodoca.com","2e85598b7f1b864"],"cname_validation_p1":"_3FE7CA1D6DA057FB40FDD333B4C105F9.qbpwcf.org","cname_validation_p2":"7B29341B7148276F5025CE90FC113803.7871040E5B7FBDB8E7EEF7CC8DAA4A56.2e85598b7f1b864.comodoca.com"}}},"signature_algorithm_properties":null}
619
		*/
1213
		*/
620
 
1214
 
-
 
1215
		#驗證結果是否為 json
-
 
1216
		$json_validate=json_validate($curlCmd["fullContent"]);
-
 
1217
 
-
 
1218
		#如果回應不是 json
-
 
1219
		if(!$json_validate){
-
 
1220
		
-
 
1221
			#設置錯誤識別
-
 
1222
			$result["status"]="false";
-
 
1223
 
-
 
1224
			#設置錯誤訊息
-
 
1225
			$result["error"]=$curlCmd;
-
 
1226
 
621
		#設置結果
1227
			#回傳結果
-
 
1228
			return $result;
-
 
1229
		
-
 
1230
			}#if end
-
 
1231
 
-
 
1232
		#設置json string結果
622
		$result["content"]=$curlCmd["content"];
1233
		$result["content"]=$curlCmd["fullContent"];
-
 
1234
 
-
 
1235
		#解析json
-
 
1236
		$jsonRes=json_decode($result["content"]);
-
 
1237
 
-
 
1238
		#取得用於 dns CNAME 驗證的名稱
-
 
1239
		$result["cnameKey"]=$jsonRes->validation->other_methods->$conf["certificate_domains"]->cname_validation_p1;
-
 
1240
 
-
 
1241
		#取得用於 dns CNAME 驗證的數值
-
 
1242
		$result["cnameVal"]=$jsonRes->validation->other_methods->$conf["certificate_domains"]->cname_validation_p2;
-
 
1243
 
-
 
1244
		#取得用於認證domain時識別用的id
-
 
1245
		$result["id"]=$jsonRes->id;
623
 
1246
 
624
		#設置執行正常
1247
		#設置執行正常
625
		$result["status"]="true";
1248
		$result["status"]="true";
626
 
1249
 
627
		#回傳結果
1250
		#回傳結果
628
		return $result;
1251
		return $result;
629
 
1252
 
-
 
1253
		}#function createCertificate end
-
 
1254
 
-
 
1255
	/*
-
 
1256
	#函式說明:
-
 
1257
	#新增DNS記錄到檔案裡面.
-
 
1258
	#回傳結果:
-
 
1259
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1260
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1261
	#$result["function"],當前執行的函式名稱.
-
 
1262
	#$result["argu"],所使用的參數.
-
 
1263
	#$result["content"],字串陣列,更新後的檔案RR(DNS記錄).
-
 
1264
	#$result["content"]["domain"],字串,RR所屬domain.
-
 
1265
	#$result["content"]["defaultTTL"],字串,預設的RR更新時間.
-
 
1266
	#$result["comment"],字串陣列,逐行的註解.
-
 
1267
	#必填參數:
-
 
1268
	#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
-
 
1269
	$conf["add"]=array();
-
 
1270
	#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
-
 
1271
	$conf["dnsRecordFile"]="";
-
 
1272
	#可省略參數:
-
 
1273
	#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
-
 
1274
	#$conf["writeNow"]="false";
-
 
1275
	#參考資料:
-
 
1276
	#無.
-
 
1277
	#備註:
-
 
1278
	#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
-
 
1279
	#通常qbpwcf使用者沒有權限存取RR(dns記錄檔案),本套件是透過sshfs掛載來繞過該問題.
-
 
1280
	#php-pear上的Net_DNS2也可以解析RR.
-
 
1281
	*/
-
 
1282
	public static function updateDnsRecordFile(&$conf){
-
 
1283
	
-
 
1284
		#初始化要回傳的結果
-
 
1285
		$result=array();
-
 
1286
 
-
 
1287
		#設置當其函數名稱
-
 
1288
		$result["function"]=__FUNCTION__;
-
 
1289
 
-
 
1290
		#如果 $conf 不為陣列
-
 
1291
		if(gettype($conf)!="array"){
-
 
1292
 
-
 
1293
			#設置執行失敗
-
 
1294
			$result["status"]="false";
-
 
1295
 
-
 
1296
			#設置執行錯誤訊息
-
 
1297
			$result["error"][]="\$conf變數須為陣列形態";
-
 
1298
 
-
 
1299
			#如果傳入的參數為 null
-
 
1300
			if($conf==null){
-
 
1301
 
-
 
1302
				#設置執行錯誤訊息
-
 
1303
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
1304
 
-
 
1305
				}#if end
-
 
1306
 
-
 
1307
			#回傳結果
-
 
1308
			return $result;
-
 
1309
 
-
 
1310
			}#if end
-
 
1311
 
-
 
1312
		#取得參數
-
 
1313
		$result["argu"]=$conf;
-
 
1314
 
-
 
1315
		#檢查參數
-
 
1316
		#函式說明:
-
 
1317
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
-
 
1318
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1319
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1320
		#$result["function"],當前執行的函式名稱.
-
 
1321
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
1322
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
1323
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
1324
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
1325
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
1326
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
1327
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
1328
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
1329
		#必填寫的參數:
-
 
1330
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
1331
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
1332
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
1333
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("add","dnsRecordFile");
-
 
1334
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
-
 
1335
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
-
 
1336
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
1337
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
1338
		#可以省略的參數:
-
 
1339
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
1340
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
-
 
1341
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
-
 
1342
		#$conf["skipableVariableCanNotBeEmpty"]=array();
-
 
1343
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
1344
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("writeNow");
-
 
1345
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
1346
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
-
 
1347
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
1348
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
-
 
1349
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
1350
		#$conf["arrayCountEqualCheck"][]=array();
-
 
1351
		#參考資料來源:
-
 
1352
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
1353
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
1354
		unset($conf["variableCheck::checkArguments"]);
-
 
1355
 
-
 
1356
		#如果檢查失敗
-
 
1357
		if($checkArguments["status"]==="false"){
-
 
1358
 
-
 
1359
			#設置錯誤識別
-
 
1360
			$result["status"]="false";
-
 
1361
 
-
 
1362
			#設置錯誤訊息
-
 
1363
			$result["error"]=$checkArguments;
-
 
1364
 
-
 
1365
			#回傳結果
-
 
1366
			return $result;
-
 
1367
 
-
 
1368
			}#if end
-
 
1369
 
-
 
1370
		#如果檢查不通過
-
 
1371
		if($checkArguments["passed"]==="false"){
-
 
1372
 
-
 
1373
			#設置錯誤識別
-
 
1374
			$result["status"]="false";
-
 
1375
 
-
 
1376
			#設置錯誤訊息
-
 
1377
			$result["error"]=$checkArguments;
-
 
1378
 
-
 
1379
			#回傳結果
-
 
1380
			return $result;
-
 
1381
 
-
 
1382
			}#if end
-
 
1383
		
-
 
1384
		#初始化要回傳的content
-
 
1385
		$result["content"]=array();
-
 
1386
		
-
 
1387
		#初始化儲存逐行的註解.
-
 
1388
		$result["comment"]=array();
-
 
1389
		
-
 
1390
		#預設的zone file domain為空
-
 
1391
		$result["domain"]="";
-
 
1392
		
-
 
1393
		#預設的 update 時間
-
 
1394
		$result["defaultTTL"]=3600;
-
 
1395
		
-
 
1396
		#取得 dns 記錄檔案的內容
-
 
1397
		#函式說明:
-
 
1398
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
-
 
1399
		#回傳的變數說明:
-
 
1400
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
-
 
1401
		#$result["error"],錯誤訊息提示.
-
 
1402
		#$result["warning"],警告訊息.
-
 
1403
		#$result["function"],當前執行的函數名稱.
-
 
1404
		#$result["fileContent"],爲檔案的內容陣列.
-
 
1405
		#$result["lineCount"],爲檔案內容總共的行數.
-
 
1406
		#$result["fullContent"],為檔案的完整內容.
-
 
1407
		#$result["base64dataOnly"],檔案的base64data.
-
 
1408
		#$result["base64data"],為在網頁上給予src參數的數值.
-
 
1409
		#$result["mimeType"],為檔案的mime type.
-
 
1410
		#必填參數:
-
 
1411
		#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
-
 
1412
		$conf["fileAccesss::getFileContent"]["filePositionAndName"]=$conf["dnsRecordFile"];
-
 
1413
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
1414
		$conf["fileAccesss::getFileContent"]["fileArgu"]=__FILE__;
-
 
1415
		#可省略參數:
-
 
1416
		#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
-
 
1417
		$conf["fileAccesss::getFileContent"]["web"]="false";
-
 
1418
		#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
-
 
1419
		#$conf["createIfnotExist"]="false";
-
 
1420
		#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
-
 
1421
		#$conf["autoDeleteSpaceOnEachLineStart"]="false";
-
 
1422
		#參考資料:
-
 
1423
		#file(),取得檔案內容的行數.
-
 
1424
		#file=>http:#php.net/manual/en/function.file.php
-
 
1425
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
-
 
1426
		#filesize=>http://php.net/manual/en/function.filesize.php
-
 
1427
		#參考資料:
-
 
1428
		#無.
-
 
1429
		#備註:
-
 
1430
		#無.
-
 
1431
		$getFileContent=fileAccess::getFileContent($conf["fileAccesss::getFileContent"]);
-
 
1432
		unset($conf["fileAccesss::getFileContent"]);
-
 
1433
	
-
 
1434
		#如果檢查失敗
-
 
1435
		if($getFileContent["status"]==="false"){
-
 
1436
 
-
 
1437
			#設置錯誤識別
-
 
1438
			$result["status"]="false";
-
 
1439
 
-
 
1440
			#設置錯誤訊息
-
 
1441
			$result["error"]=$getFileContent;
-
 
1442
 
-
 
1443
			#回傳結果
-
 
1444
			return $result;
-
 
1445
 
-
 
1446
			}#if end
-
 
1447
			
-
 
1448
		#取得每行內容
-
 
1449
		$lines=$getFileContent["fileContent"];
-
 
1450
	
-
 
1451
		/*
-
 
1452
		範例每行內容:
-
 
1453
		$ORIGIN server.domain.	;base domain-name,in this Resource Records (RR) file,"@" equal to base domain-name.
-
 
1454
		$TTL 86400	;default TTL for zone
-
 
1455
		@	1200	IN	SOA	dns.server.domain. admin.server.domain. 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
-
 
1456
		@	3600	IN	TXT	"v=spf1 a mx ~all"
-
 
1457
		@	86400	IN	MX	1 mail.server.domain.
-
 
1458
		@	86400	IN	A	1.1.1.1
-
 
1459
		mail.server.domain.	IN	1.1.1.1
-
 
1460
		10-42-0-1	IN	A	10.42.0.1
-
 
1461
		101-free        IN      A	101.101.101.101
-
 
1462
		127-0-0-1	IN	A	127.0.0.1
-
 
1463
		_dmarc	IN	TXT	"v=DMARC1;p=reject;sp=reject;pct=100;adkim=r;aspf=r;fo=1;ri=86400;rua=mailto:admin@server.domain"
-
 
1464
		default._domainkey	IN	TXT	( "v=DKIM1; k=rsa;" "p=MIGfMA0GCSqG/SIb3DQEBAQQAB" )  ; ----- DKIM key default for qbpwcf.org
-
 
1465
		...
-
 
1466
		*/
-
 
1467
		
-
 
1468
		#針對每行內容
-
 
1469
		foreach($lines as $lineNo => $line){
-
 
1470
		
-
 
1471
			#另存一份要處理的RR
-
 
1472
			$unFormatStr=$line;
-
 
1473
		
-
 
1474
			#/*
-
 
1475
			#debug
-
 
1476
			#函式說明:
-
 
1477
			#撰寫log
-
 
1478
			#回傳結果:
-
 
1479
			#$result["status"],狀態,"true"或"false".
-
 
1480
			#$result["error"],錯誤訊息陣列.
-
 
1481
			#$result["function"],當前函式的名稱.
-
 
1482
			#$result["argu"],使用的參數.
-
 
1483
			#$result["content"],要寫入log的內容字串.
-
 
1484
			#必填參數:
-
 
1485
			#$conf["path"],字串,log檔案的路徑與名稱.
-
 
1486
			$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
1487
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
1488
			$conf["logs::record"]["content"]="processing lineNo:".$lineNo." content:".$line.PHP_EOL;
-
 
1489
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
1490
			$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
1491
			#可省略參數:
-
 
1492
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
1493
			#$conf["rewrite"]="false";
-
 
1494
			#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
1495
			#$conf["returnOnly"]="true";
-
 
1496
			#參考資料:
-
 
1497
			#無.
-
 
1498
			#備註:
-
 
1499
			#無.
-
 
1500
			$record=logs::record($conf["logs::record"]);
-
 
1501
			unset($conf["logs::record"]);
-
 
1502
			#*/
-
 
1503
		
-
 
1504
			#初始化該行的資訊陣列
-
 
1505
			$info=array();
-
 
1506
		
-
 
1507
			#尋找";"開頭的內容,亦即整行都是註解.
-
 
1508
			#函式說明:
-
 
1509
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1510
			#回傳結果:
-
 
1511
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1512
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1513
			#$result["function"],當前執行的函式名稱.
-
 
1514
			#$result["argu"],所使用的參數.
-
 
1515
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1516
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1517
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1518
			#必填參數:
-
 
1519
			#$conf["input"],字串,要檢查的字串.
-
 
1520
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1521
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1522
			$conf["search::findSpecifyStrFormat"]["format"]=";\${else}";
-
 
1523
			#可省略參數:
-
 
1524
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1525
			#$conf["varEqual"]=array(null,"found");
-
 
1526
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1527
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
1528
			#參考資料:
-
 
1529
			#無.
-
 
1530
			#備註:
-
 
1531
			#無.
-
 
1532
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1533
			unset($conf["search::findSpecifyStrFormat"]);
-
 
1534
		
-
 
1535
			#如果執行異常
-
 
1536
			if($findSpecifyStrFormat["status"]==="false"){
-
 
1537
			
-
 
1538
				#設置錯誤識別
-
 
1539
				$result["status"]="false";
-
 
1540
 
-
 
1541
				#設置錯誤訊息
-
 
1542
				$result["error"]=$findSpecifyStrFormat;
-
 
1543
 
-
 
1544
				#回傳結果
-
 
1545
				return $result;
-
 
1546
			
-
 
1547
				}#if end
-
 
1548
				
-
 
1549
			#如果有找到符合格式的內容
-
 
1550
			if($findSpecifyStrFormat["found"]==="true"){
-
 
1551
			
-
 
1552
				#儲存為註解
-
 
1553
				$result["comment"][]=$unFormatStr;
-
 
1554
			
-
 
1555
				#換下一行
-
 
1556
				continue;
-
 
1557
			
-
 
1558
				}#if end
-
 
1559
		
-
 
1560
			#函式說明:
-
 
1561
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1562
			#回傳結果:
-
 
1563
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1564
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1565
			#$result["function"],當前執行的函式名稱.
-
 
1566
			#$result["argu"],所使用的參數.
-
 
1567
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1568
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1569
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1570
			#必填參數:
-
 
1571
			#$conf["input"],字串,要檢查的字串.
-
 
1572
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1573
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1574
			$conf["search::findSpecifyStrFormat"]["format"]="\$ORIGIN\${else}";
-
 
1575
			#可省略參數:
-
 
1576
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1577
			#$conf["varEqual"]=array(null,"found");
-
 
1578
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1579
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
1580
			#參考資料:
-
 
1581
			#無.
-
 
1582
			#備註:
-
 
1583
			#無.
-
 
1584
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1585
			unset($conf["search::findSpecifyStrFormat"]);
-
 
1586
		
-
 
1587
			#如果執行異常
-
 
1588
			if($findSpecifyStrFormat["status"]==="false"){
-
 
1589
			
-
 
1590
				#設置錯誤識別
-
 
1591
				$result["status"]="false";
-
 
1592
 
-
 
1593
				#設置錯誤訊息
-
 
1594
				$result["error"]=$findSpecifyStrFormat;
-
 
1595
 
-
 
1596
				#回傳結果
-
 
1597
				return $result;
-
 
1598
			
-
 
1599
				}#if end
-
 
1600
				
-
 
1601
			#如果有找到符合格式的內容
-
 
1602
			if($findSpecifyStrFormat["found"]==="true"){
-
 
1603
			
-
 
1604
				#設置 type 的數值
-
 
1605
				$info["type"]="\$ORIGIN";
-
 
1606
			
-
 
1607
				#取得後面待處理的內容
-
 
1608
				$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
1609
			
-
 
1610
				#函式說明:
-
 
1611
				#將字串開頭的特定關鍵字移除.
-
 
1612
				#回傳結果:
-
 
1613
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1614
				#$result["error"],錯誤訊息陣列.
-
 
1615
				#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
1616
				#$result["function"],當前執行的函數名稱.
-
 
1617
				#$result["argu"],使用的參數.
-
 
1618
				#$result["content"],處理好的的字串內容.
-
 
1619
				#$result["deleted"],被移除的內容.
-
 
1620
				#必填參數:
-
 
1621
				#$conf["stringIn"],字串,要處理的字串.
-
 
1622
				$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
1623
				#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
1624
				$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t");
-
 
1625
				#可省略參數:
-
 
1626
				#無.
-
 
1627
				#參考資料:
-
 
1628
				#無.
-
 
1629
				#備註:
-
 
1630
				#無.
-
 
1631
				$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
1632
				unset($conf["stringProcess::delHeadStr"]);
-
 
1633
					
-
 
1634
				#如果執行異常
-
 
1635
				if($delHeadStr["status"]==="false"){
-
 
1636
				
-
 
1637
					#設置錯誤識別
-
 
1638
					$result["status"]="false";
-
 
1639
 
-
 
1640
					#設置錯誤訊息
-
 
1641
					$result["error"]=$delHeadStr;
-
 
1642
 
-
 
1643
					#回傳結果
-
 
1644
					return $result;
-
 
1645
				
-
 
1646
					}#if end
-
 
1647
					
-
 
1648
				#如果有移除開頭的字串
-
 
1649
				if($delHeadStr["founded"]==="true"){
-
 
1650
				
-
 
1651
					#取得處理後的結果
-
 
1652
					$unFormatStr=$delHeadStr["content"];
-
 
1653
				
-
 
1654
					}#if end
-
 
1655
			
-
 
1656
				#解析 $ORIGN 的數值, 以及後面是否有註解...
-
 
1657
				#函式說明:
-
 
1658
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1659
				#回傳結果:
-
 
1660
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1661
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1662
				#$result["function"],當前執行的函式名稱.
-
 
1663
				#$result["argu"],所使用的參數.
-
 
1664
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1665
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1666
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1667
				#必填參數:
-
 
1668
				#$conf["input"],字串,要檢查的字串.
-
 
1669
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1670
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1671
				$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
1672
				#可省略參數:
-
 
1673
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1674
				#$conf["varEqual"]=array(null,"found");
-
 
1675
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1676
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
1677
				#參考資料:
-
 
1678
				#無.
-
 
1679
				#備註:
-
 
1680
				#無.
-
 
1681
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1682
				unset($conf["search::findSpecifyStrFormat"]);
-
 
1683
			
-
 
1684
				#如果執行異常
-
 
1685
				if($findSpecifyStrFormat["status"]==="false"){
-
 
1686
				
-
 
1687
					#設置錯誤識別
-
 
1688
					$result["status"]="false";
-
 
1689
 
-
 
1690
					#設置錯誤訊息
-
 
1691
					$result["error"]=$findSpecifyStrFormat;
-
 
1692
 
-
 
1693
					#回傳結果
-
 
1694
					return $result;
-
 
1695
				
-
 
1696
					}#if end
-
 
1697
					
-
 
1698
				#如果有數值跟註解
-
 
1699
				if($findSpecifyStrFormat["found"]==="true"){
-
 
1700
				
-
 
1701
					#儲存數值
-
 
1702
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
1703
				
-
 
1704
					#儲存zone domain
-
 
1705
					$result["domain"]=trim($info["value"]);
-
 
1706
				
-
 
1707
					#儲存註解
-
 
1708
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
1709
				
-
 
1710
					#儲存解析好的RR
-
 
1711
					$result["content"][]=$info;
-
 
1712
				
-
 
1713
					#換下一行
-
 
1714
					continue;
-
 
1715
					
-
 
1716
					}#if end
-
 
1717
					
-
 
1718
				#執行到這邊代表剩下的內容都是 value
-
 
1719
				$info["value"]=$unFormatStr;
-
 
1720
				
-
 
1721
				#儲存zone domain
-
 
1722
				$result["domain"]=trim($info["value"]);
-
 
1723
			
-
 
1724
				#儲存解析好的RR
-
 
1725
				$result["content"][]=$info;
-
 
1726
			
-
 
1727
				#換下一行
-
 
1728
				continue;
-
 
1729
			
-
 
1730
				}#if end
-
 
1731
				
-
 
1732
			#檢查是否為 $TTL 開頭
-
 
1733
			#函式說明:
-
 
1734
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1735
			#回傳結果:
-
 
1736
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1737
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1738
			#$result["function"],當前執行的函式名稱.
-
 
1739
			#$result["argu"],所使用的參數.
-
 
1740
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1741
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1742
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1743
			#必填參數:
-
 
1744
			#$conf["input"],字串,要檢查的字串.
-
 
1745
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1746
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1747
			$conf["search::findSpecifyStrFormat"]["format"]="\$TTL\${else}";
-
 
1748
			#可省略參數:
-
 
1749
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1750
			#$conf["varEqual"]=array(null,"found");
-
 
1751
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1752
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
1753
			#參考資料:
-
 
1754
			#無.
-
 
1755
			#備註:
-
 
1756
			#無.
-
 
1757
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1758
			unset($conf["search::findSpecifyStrFormat"]);
-
 
1759
		
-
 
1760
			#如果執行異常
-
 
1761
			if($findSpecifyStrFormat["status"]==="false"){
-
 
1762
			
-
 
1763
				#設置錯誤識別
-
 
1764
				$result["status"]="false";
-
 
1765
 
-
 
1766
				#設置錯誤訊息
-
 
1767
				$result["error"]=$findSpecifyStrFormat;
-
 
1768
 
-
 
1769
				#回傳結果
-
 
1770
				return $result;
-
 
1771
			
-
 
1772
				}#if end
-
 
1773
				
-
 
1774
			#如果有找到符合格式的內容
-
 
1775
			if($findSpecifyStrFormat["found"]==="true"){
-
 
1776
			
-
 
1777
				#設置 type 的數值
-
 
1778
				$info["type"]="\$TTL";
-
 
1779
				
-
 
1780
				#取得後面待處理的內容
-
 
1781
				$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
1782
			
-
 
1783
				#函式說明:
-
 
1784
				#將字串開頭的特定關鍵字移除.
-
 
1785
				#回傳結果:
-
 
1786
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1787
				#$result["error"],錯誤訊息陣列.
-
 
1788
				#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
1789
				#$result["function"],當前執行的函數名稱.
-
 
1790
				#$result["argu"],使用的參數.
-
 
1791
				#$result["content"],處理好的的字串內容.
-
 
1792
				#$result["deleted"],被移除的內容.
-
 
1793
				#必填參數:
-
 
1794
				#$conf["stringIn"],字串,要處理的字串.
-
 
1795
				$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
1796
				#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
1797
				$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t");
-
 
1798
				#可省略參數:
-
 
1799
				#無.
-
 
1800
				#參考資料:
-
 
1801
				#無.
-
 
1802
				#備註:
-
 
1803
				#無.
-
 
1804
				$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
1805
				unset($conf["stringProcess::delHeadStr"]);
-
 
1806
					
-
 
1807
				#如果執行異常
-
 
1808
				if($delHeadStr["status"]==="false"){
-
 
1809
				
-
 
1810
					#設置錯誤識別
-
 
1811
					$result["status"]="false";
-
 
1812
 
-
 
1813
					#設置錯誤訊息
-
 
1814
					$result["error"]=$delHeadStr;
-
 
1815
 
-
 
1816
					#回傳結果
-
 
1817
					return $result;
-
 
1818
				
-
 
1819
					}#if end
-
 
1820
					
-
 
1821
				#如果有移除開頭的字串
-
 
1822
				if($delHeadStr["founded"]==="true"){
-
 
1823
				
-
 
1824
					#取得處理後的結果
-
 
1825
					$unFormatStr=$delHeadStr["content"];
-
 
1826
				
-
 
1827
					}#if end
-
 
1828
				
-
 
1829
				#解析 $TTL 的數值, 以及後面是否有註解...
-
 
1830
				#函式說明:
-
 
1831
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1832
				#回傳結果:
-
 
1833
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1834
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1835
				#$result["function"],當前執行的函式名稱.
-
 
1836
				#$result["argu"],所使用的參數.
-
 
1837
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1838
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1839
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
1840
				#必填參數:
-
 
1841
				#$conf["input"],字串,要檢查的字串.
-
 
1842
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1843
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1844
				$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
1845
				#可省略參數:
-
 
1846
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1847
				#$conf["varEqual"]=array(null,"found");
-
 
1848
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1849
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
1850
				#參考資料:
-
 
1851
				#無.
-
 
1852
				#備註:
-
 
1853
				#無.
-
 
1854
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1855
				unset($conf["search::findSpecifyStrFormat"]);
-
 
1856
			
-
 
1857
				#如果執行異常
-
 
1858
				if($findSpecifyStrFormat["status"]==="false"){
-
 
1859
				
-
 
1860
					#設置錯誤識別
-
 
1861
					$result["status"]="false";
-
 
1862
 
-
 
1863
					#設置錯誤訊息
-
 
1864
					$result["error"]=$findSpecifyStrFormat;
-
 
1865
 
-
 
1866
					#回傳結果
-
 
1867
					return $result;
-
 
1868
				
-
 
1869
					}#if end
-
 
1870
					
-
 
1871
				#如果有數值跟註解
-
 
1872
				if($findSpecifyStrFormat["found"]==="true"){
-
 
1873
				
-
 
1874
					#儲存數值
-
 
1875
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
1876
				
-
 
1877
					#儲存註解
-
 
1878
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
1879
				
-
 
1880
					#儲存預設的 TTL
-
 
1881
					$result["defaultTTL"]=trim($info["value"]);
-
 
1882
				
-
 
1883
					#儲存解析好的RR
-
 
1884
					$result["content"][]=$info;
-
 
1885
				
-
 
1886
					#換下一行
-
 
1887
					continue;
-
 
1888
					
-
 
1889
					}#if end
-
 
1890
					
-
 
1891
				#執行到這邊代表剩下的內容都是 value
-
 
1892
				$info["value"]=$unFormatStr;
-
 
1893
				
-
 
1894
				#儲存預設的 TTL
-
 
1895
				$result["defaultTTL"]=trim($info["value"]);
-
 
1896
				
-
 
1897
				#儲存解析好的RR
-
 
1898
				$result["content"][]=$info;
-
 
1899
				
-
 
1900
				#換下一行
-
 
1901
				continue;
-
 
1902
			
-
 
1903
				}#if end
-
 
1904
			
-
 
1905
			#如果 內容為 query updatTime IN type value;comment,或value含有(或",則需要將其符號與後面的內容先暫時拆開
-
 
1906
			
-
 
1907
			#函式說明:
-
 
1908
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1909
			#回傳結果:
-
 
1910
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1911
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1912
			#$result["function"],當前執行的函式名稱.
-
 
1913
			#$result["argu"],所使用的參數.
-
 
1914
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1915
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1916
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
1917
			#必填參數:
-
 
1918
			#$conf["input"],字串,要檢查的字串.
-
 
1919
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1920
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1921
			$conf["search::findSpecifyStrFormat"]["format"]="\${left}(\${right}";
-
 
1922
			#可省略參數:
-
 
1923
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1924
			#$conf["varEqual"]=array(null,"found");
-
 
1925
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1926
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
1927
			#參考資料:
-
 
1928
			#無.
-
 
1929
			#備註:
-
 
1930
			#無.
-
 
1931
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1932
			unset($conf["search::findSpecifyStrFormat"]);
-
 
1933
		
-
 
1934
			#如果執行異常
-
 
1935
			if($findSpecifyStrFormat["status"]==="false"){
-
 
1936
			
-
 
1937
				#設置錯誤識別
-
 
1938
				$result["status"]="false";
-
 
1939
 
-
 
1940
				#設置錯誤訊息
-
 
1941
				$result["error"]=$findSpecifyStrFormat;
-
 
1942
 
-
 
1943
				#回傳結果
-
 
1944
				return $result;
-
 
1945
		
-
 
1946
				}#if end
-
 
1947
				
-
 
1948
			#如果存在"("
-
 
1949
			if($findSpecifyStrFormat["found"]==="true"){
-
 
1950
			
-
 
1951
				#取得無"("的內容
-
 
1952
				$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
1953
				
-
 
1954
				#取得拆下來的含開頭"("內容
-
 
1955
				$unFormatStr2add="(".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
1956
				
-
 
1957
				}#if end
-
 
1958
			
-
 
1959
			#反之
-
 
1960
			else{
-
 
1961
			
-
 
1962
				#函式說明:
-
 
1963
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
1964
				#回傳結果:
-
 
1965
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1966
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1967
				#$result["function"],當前執行的函式名稱.
-
 
1968
				#$result["argu"],所使用的參數.
-
 
1969
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
1970
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
1971
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
1972
				#必填參數:
-
 
1973
				#$conf["input"],字串,要檢查的字串.
-
 
1974
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
1975
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
1976
				$conf["search::findSpecifyStrFormat"]["format"]="\${left}\"\${right}";
-
 
1977
				#可省略參數:
-
 
1978
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
1979
				#$conf["varEqual"]=array(null,"found");
-
 
1980
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
1981
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
1982
				#參考資料:
-
 
1983
				#無.
-
 
1984
				#備註:
-
 
1985
				#無.
-
 
1986
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
1987
				unset($conf["search::findSpecifyStrFormat"]);
-
 
1988
			
-
 
1989
				#如果執行異常
-
 
1990
				if($findSpecifyStrFormat["status"]==="false"){
-
 
1991
				
-
 
1992
					#設置錯誤識別
-
 
1993
					$result["status"]="false";
-
 
1994
 
-
 
1995
					#設置錯誤訊息
-
 
1996
					$result["error"]=$findSpecifyStrFormat;
-
 
1997
 
-
 
1998
					#回傳結果
-
 
1999
					return $result;
-
 
2000
			
-
 
2001
					}#if end
-
 
2002
					
-
 
2003
				#如果存在"
-
 
2004
				if($findSpecifyStrFormat["found"]==="true"){
-
 
2005
				
-
 
2006
					#取得無"的內容
-
 
2007
					$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2008
					
-
 
2009
					#取得拆下來的含開頭"內容
-
 
2010
					$unFormatStr2add="\"".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2011
					
-
 
2012
					}#if end
-
 
2013
					
-
 
2014
				#反之
-
 
2015
				else{
-
 
2016
				
-
 
2017
					#函式說明:
-
 
2018
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2019
					#回傳結果:
-
 
2020
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2021
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2022
					#$result["function"],當前執行的函式名稱.
-
 
2023
					#$result["argu"],所使用的參數.
-
 
2024
					#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2025
					#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2026
					#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2027
					#必填參數:
-
 
2028
					#$conf["input"],字串,要檢查的字串.
-
 
2029
					$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2030
					#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2031
					$conf["search::findSpecifyStrFormat"]["format"]="\${left};\${right}";
-
 
2032
					#可省略參數:
-
 
2033
					#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2034
					#$conf["varEqual"]=array(null,"found");
-
 
2035
					#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2036
					#$conf["varCon"]=array("no_tail"=>" not");
-
 
2037
					#參考資料:
-
 
2038
					#無.
-
 
2039
					#備註:
-
 
2040
					#無.
-
 
2041
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2042
					unset($conf["search::findSpecifyStrFormat"]);
-
 
2043
				
-
 
2044
					#如果執行異常
-
 
2045
					if($findSpecifyStrFormat["status"]==="false"){
-
 
2046
					
-
 
2047
						#設置錯誤識別
-
 
2048
						$result["status"]="false";
-
 
2049
 
-
 
2050
						#設置錯誤訊息
-
 
2051
						$result["error"]=$findSpecifyStrFormat;
-
 
2052
 
-
 
2053
						#回傳結果
-
 
2054
						return $result;
-
 
2055
				
-
 
2056
						}#if end
-
 
2057
						
-
 
2058
					#如果存在";"
-
 
2059
					if($findSpecifyStrFormat["found"]==="true"){
-
 
2060
					
-
 
2061
						#取得無";"的內容
-
 
2062
						$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2063
						
-
 
2064
						#取得拆下來的含開頭";"內容
-
 
2065
						$unFormatStr2add=";".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2066
						
-
 
2067
						}#if end
-
 
2068
				
-
 
2069
					}#else end
-
 
2070
			
-
 
2071
				}#else end
-
 
2072
			
-
 
2073
			#檢查是否為 @ 開頭
-
 
2074
			#函式說明:
-
 
2075
			#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2076
			#回傳結果:
-
 
2077
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2078
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2079
			#$result["function"],當前執行的函式名稱.
-
 
2080
			#$result["argu"],所使用的參數.
-
 
2081
			#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2082
			#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2083
			#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
2084
			#必填參數:
-
 
2085
			#$conf["input"],字串,要檢查的字串.
-
 
2086
			$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2087
			#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2088
			$conf["search::findSpecifyStrFormat"]["format"]="@\${else}";
-
 
2089
			#可省略參數:
-
 
2090
			#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2091
			#$conf["varEqual"]=array(null,"found");
-
 
2092
			#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2093
			#$conf["varCon"]=array("no_tail"=>" not");
-
 
2094
			#參考資料:
-
 
2095
			#無.
-
 
2096
			#備註:
-
 
2097
			#無.
-
 
2098
			$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2099
			unset($conf["search::findSpecifyStrFormat"]);
-
 
2100
		
-
 
2101
			#如果執行異常
-
 
2102
			if($findSpecifyStrFormat["status"]==="false"){
-
 
2103
			
-
 
2104
				#設置錯誤識別
-
 
2105
				$result["status"]="false";
-
 
2106
 
-
 
2107
				#設置錯誤訊息
-
 
2108
				$result["error"]=$findSpecifyStrFormat;
-
 
2109
 
-
 
2110
				#回傳結果
-
 
2111
				return $result;
-
 
2112
			
-
 
2113
				}#if end
-
 
2114
				
-
 
2115
			#如果有找到符合格式的內容
-
 
2116
			if($findSpecifyStrFormat["found"]==="true"){
-
 
2117
			
-
 
2118
				#設置 query 的數值
-
 
2119
				$info["query"]="@";
-
 
2120
				
-
 
2121
				#取得後面待處理的內容
-
 
2122
				$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
2123
				
-
 
2124
				#函式說明:
-
 
2125
				#將字串開頭的特定關鍵字移除.
-
 
2126
				#回傳結果:
-
 
2127
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2128
				#$result["error"],錯誤訊息陣列.
-
 
2129
				#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2130
				#$result["function"],當前執行的函數名稱.
-
 
2131
				#$result["argu"],使用的參數.
-
 
2132
				#$result["content"],處理好的的字串內容.
-
 
2133
				#$result["deleted"],被移除的內容.
-
 
2134
				#必填參數:
-
 
2135
				#$conf["stringIn"],字串,要處理的字串.
-
 
2136
				$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2137
				#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2138
				$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t");
-
 
2139
				#可省略參數:
-
 
2140
				#無.
-
 
2141
				#參考資料:
-
 
2142
				#無.
-
 
2143
				#備註:
-
 
2144
				#無.
-
 
2145
				$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2146
				unset($conf["stringProcess::delHeadStr"]);
-
 
2147
				
-
 
2148
				#如果執行異常
-
 
2149
				if($delHeadStr["status"]==="false"){
-
 
2150
				
-
 
2151
					#設置錯誤識別
-
 
2152
					$result["status"]="false";
-
 
2153
 
-
 
2154
					#設置錯誤訊息
-
 
2155
					$result["error"]=$delHeadStr;
-
 
2156
 
-
 
2157
					#回傳結果
-
 
2158
					return $result;
-
 
2159
				
-
 
2160
					}#if end
-
 
2161
					
-
 
2162
				#如果有移除開頭的字串
-
 
2163
				if($delHeadStr["founded"]==="true"){
-
 
2164
				
-
 
2165
					#取得處理後的結果 update time..IN..type...value;comment
-
 
2166
					$unFormatStr=$delHeadStr["content"];
-
 
2167
				
-
 
2168
					}#if end
-
 
2169
					
-
 
2170
				#debug
-
 
2171
				#var_dump(__LINE__,$delHeadStr);
-
 
2172
				
-
 
2173
				}#if end
-
 
2174
			
-
 
2175
			#反之
-
 
2176
			else{
-
 
2177
				
-
 
2178
				#執行到這邊,代表 query 為一非 @ 的字串
-
 
2179
				#函式說明:
-
 
2180
				#將指令字串解析成陣列,方便給予 external::callShell 使用
-
 
2181
				#回傳結果:
-
 
2182
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2183
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2184
				#$result["function"],當前執行的函式名稱.
-
 
2185
				#$result["content"],解析好的指令陣列.
-
 
2186
				#$result["cmd"],解析好的指令名稱.
-
 
2187
				#$result["argus"],解析好的參數陣列.
-
 
2188
				#$result["argu"],所使用的參數.
-
 
2189
				#必填參數
-
 
2190
				#$conf["cmdStr"],字串,要解析的指令字串
-
 
2191
				$conf["stringProcess::parseCmdString"]["cmdStr"]=$unFormatStr;
-
 
2192
				#可省略參數:
-
 
2193
				#無.
-
 
2194
				#參考資料:
-
 
2195
				#無.
-
 
2196
				#備註:
-
 
2197
				#無.
-
 
2198
				$parseCmdString=cmd::parseCmdString($conf["stringProcess::parseCmdString"]);
-
 
2199
				unset($conf["stringProcess::parseCmdString"]);
-
 
2200
				
-
 
2201
				#如果執行失敗
-
 
2202
				if($parseCmdString["status"]==="false"){
-
 
2203
				
-
 
2204
					#設置錯誤識別
-
 
2205
					$result["status"]="false";
-
 
2206
 
-
 
2207
					#設置錯誤訊息
-
 
2208
					$result["error"]=$parseCmdString;
-
 
2209
					
-
 
2210
					#debug
-
 
2211
					#$result["errorProcessLine"]=$line;
-
 
2212
 
-
 
2213
					#回傳結果
-
 
2214
					return $result;
-
 
2215
				
-
 
2216
					}#if end
-
 
2217
					
-
 
2218
				#取得 query 的內容
-
 
2219
				$info["query"]=$parseCmdString["content"][0];
-
 
2220
				
-
 
2221
				#剔除 query以及後面的" "跟\t
-
 
2222
				#函式說明:
-
 
2223
				#將字串開頭的特定關鍵字移除.
-
 
2224
				#回傳結果:
-
 
2225
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2226
				#$result["error"],錯誤訊息陣列.
-
 
2227
				#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2228
				#$result["function"],當前執行的函數名稱.
-
 
2229
				#$result["argu"],使用的參數.
-
 
2230
				#$result["content"],處理好的的字串內容.
-
 
2231
				#$result["deleted"],被移除的內容.
-
 
2232
				#必填參數:
-
 
2233
				#$conf["stringIn"],字串,要處理的字串.
-
 
2234
				$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2235
				#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2236
				$conf["stringProcess::delHeadStr"]["headStr"]=array($info["query"]," ","\t");
-
 
2237
				#可省略參數:
-
 
2238
				#無.
-
 
2239
				#參考資料:
-
 
2240
				#無.
-
 
2241
				#備註:
-
 
2242
				#無.
-
 
2243
				$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2244
				unset($conf["stringProcess::delHeadStr"]);
-
 
2245
				
-
 
2246
				#如果執行異常
-
 
2247
				if($delHeadStr["status"]==="false"){
-
 
2248
				
-
 
2249
					#設置錯誤識別
-
 
2250
					$result["status"]="false";
-
 
2251
 
-
 
2252
					#設置錯誤訊息
-
 
2253
					$result["error"]=$delHeadStr;
-
 
2254
 
-
 
2255
					#回傳結果
-
 
2256
					return $result;
-
 
2257
				
-
 
2258
					}#if end
-
 
2259
					
-
 
2260
				#取得update time..IN..type...value;comment
-
 
2261
				$unFormatStr=$delHeadStr["content"];
-
 
2262
			
-
 
2263
				}#else end
-
 
2264
			
-
 
2265
			#無窮迴圈
-
 
2266
			while(true){
-
 
2267
				
-
 
2268
				#/*
-
 
2269
				#debug
-
 
2270
				#函式說明:
-
 
2271
				#撰寫log
-
 
2272
				#回傳結果:
-
 
2273
				#$result["status"],狀態,"true"或"false".
-
 
2274
				#$result["error"],錯誤訊息陣列.
-
 
2275
				#$result["function"],當前函式的名稱.
-
 
2276
				#$result["argu"],使用的參數.
-
 
2277
				#$result["content"],要寫入log的內容字串.
-
 
2278
				#必填參數:
-
 
2279
				#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2280
				$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
2281
				#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2282
				$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
-
 
2283
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2284
				$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
2285
				#可省略參數:
-
 
2286
				#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2287
				#$conf["rewrite"]="false";
-
 
2288
				#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
2289
				#$conf["returnOnly"]="true";
-
 
2290
				#參考資料:
-
 
2291
				#無.
-
 
2292
				#備註:
-
 
2293
				#無.
-
 
2294
				$record=logs::record($conf["logs::record"]);
-
 
2295
				unset($conf["logs::record"]);
-
 
2296
				#*/
-
 
2297
				
-
 
2298
				#解析 updateTime..IN..type...value...comment
-
 
2299
			
-
 
2300
				#判斷是否無 update time
-
 
2301
				
-
 
2302
				#函式說明:
-
 
2303
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2304
				#回傳結果:
-
 
2305
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2306
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2307
				#$result["function"],當前執行的函式名稱.
-
 
2308
				#$result["argu"],所使用的參數.
-
 
2309
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2310
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2311
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
2312
				#必填參數:
-
 
2313
				#$conf["input"],字串,要檢查的字串.
-
 
2314
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2315
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2316
				$conf["search::findSpecifyStrFormat"]["format"]="IN\${else}";
-
 
2317
				#可省略參數:
-
 
2318
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2319
				#$conf["varEqual"]=array(null,"found");
-
 
2320
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2321
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
2322
				#參考資料:
-
 
2323
				#無.
-
 
2324
				#備註:
-
 
2325
				#無.
-
 
2326
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2327
				unset($conf["search::findSpecifyStrFormat"]);
-
 
2328
			
-
 
2329
				#如果執行異常
-
 
2330
				if($findSpecifyStrFormat["status"]==="false"){
-
 
2331
				
-
 
2332
					#設置錯誤識別
-
 
2333
					$result["status"]="false";
-
 
2334
 
-
 
2335
					#設置錯誤訊息
-
 
2336
					$result["error"]=$findSpecifyStrFormat;
-
 
2337
 
-
 
2338
					#回傳結果
-
 
2339
					return $result;
-
 
2340
				
-
 
2341
					}#if end
-
 
2342
					
-
 
2343
				#如果有找到符合格式的內容
-
 
2344
				if($findSpecifyStrFormat["found"]==="true"){
-
 
2345
				
-
 
2346
					#代表沒有 update time 欄位,因此儲存預設的TTL
-
 
2347
					$info["update"]=&$result["defaultTTL"];
-
 
2348
					
-
 
2349
					#取得剩下的 ...type...value;comment
-
 
2350
					$unFormatStr=$findSpecifyStrFormat["parsedVar"]["else"][0];
-
 
2351
					
-
 
2352
					#設置該行沒有指定 update time
-
 
2353
					$noUpdateTime="true";
-
 
2354
					
-
 
2355
					#/*
-
 
2356
					#debug
-
 
2357
					#函式說明:
-
 
2358
					#撰寫log
-
 
2359
					#回傳結果:
-
 
2360
					#$result["status"],狀態,"true"或"false".
-
 
2361
					#$result["error"],錯誤訊息陣列.
-
 
2362
					#$result["function"],當前函式的名稱.
-
 
2363
					#$result["argu"],使用的參數.
-
 
2364
					#$result["content"],要寫入log的內容字串.
-
 
2365
					#必填參數:
-
 
2366
					#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2367
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
2368
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2369
					$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
-
 
2370
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2371
					$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
2372
					#可省略參數:
-
 
2373
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2374
					#$conf["rewrite"]="false";
-
 
2375
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
2376
					#$conf["returnOnly"]="true";
-
 
2377
					#參考資料:
-
 
2378
					#無.
-
 
2379
					#備註:
-
 
2380
					#無.
-
 
2381
					$record=logs::record($conf["logs::record"]);
-
 
2382
					unset($conf["logs::record"]);
-
 
2383
					#*/
-
 
2384
				
-
 
2385
					}#if end
-
 
2386
					
-
 
2387
				#反之
-
 
2388
				else{
-
 
2389
				
-
 
2390
					#設置該行有指定 update time
-
 
2391
					$noUpdateTime="false";
-
 
2392
				
-
 
2393
					#如果有指定 update time
-
 
2394
					if($noUpdateTime==="false"){
-
 
2395
					
-
 
2396
						#要來解析 update time
-
 
2397
						#函式說明:
-
 
2398
						#將字串進行解析,變成多個參數.
-
 
2399
						#回傳結果:
-
 
2400
						#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
-
 
2401
						#$result["function"],當前執行的函式內容.
-
 
2402
						#$result["error"],錯誤訊息陣列.
-
 
2403
						#$result["content"],參數陣列.
-
 
2404
						#$result["count"],總共有幾個參數.
-
 
2405
						#必填參數:
-
 
2406
						#$conf["input"],字串,要解析成參數的字串.
-
 
2407
						$conf["stringProcess::parse"]["input"]=$unFormatStr;
-
 
2408
						#可省略參數:
-
 
2409
						#無.
-
 
2410
						#參考資料:
-
 
2411
						#無.
-
 
2412
						#備註:
-
 
2413
						#無.
-
 
2414
						$parse=stringProcess::parse($conf["stringProcess::parse"]);
-
 
2415
						unset($conf["stringProcess::parse"]);
-
 
2416
						
-
 
2417
						#如果執行異常
-
 
2418
						if($parse["status"]==="false"){
-
 
2419
						
-
 
2420
							#設置錯誤識別
-
 
2421
							$result["status"]="false";
-
 
2422
 
-
 
2423
							#設置錯誤訊息
-
 
2424
							$result["error"]=$parse;
-
 
2425
 
-
 
2426
							#回傳結果
-
 
2427
							return $result;
-
 
2428
							
-
 
2429
							}#if end
-
 
2430
							
-
 
2431
						#取得更新時間
-
 
2432
						$info["update"]=$parse["content"][0];
-
 
2433
					
-
 
2434
						#取得 update time 後面的內容
-
 
2435
						#函式說明:
-
 
2436
						#將字串開頭的特定關鍵字移除.
-
 
2437
						#回傳結果:
-
 
2438
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2439
						#$result["error"],錯誤訊息陣列.
-
 
2440
						#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2441
						#$result["function"],當前執行的函數名稱.
-
 
2442
						#$result["argu"],使用的參數.
-
 
2443
						#$result["content"],處理好的的字串內容.
-
 
2444
						#$result["deleted"],被移除的內容.
-
 
2445
						#必填參數:
-
 
2446
						#$conf["stringIn"],字串,要處理的字串.
-
 
2447
						$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2448
						#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2449
						$conf["stringProcess::delHeadStr"]["headStr"]=array($info["update"]);
-
 
2450
						#可省略參數:
-
 
2451
						#無.
-
 
2452
						#參考資料:
-
 
2453
						#無.
-
 
2454
						#備註:
-
 
2455
						#無.
-
 
2456
						$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2457
						unset($conf["stringProcess::delHeadStr"]);
-
 
2458
						
-
 
2459
						#如果執行異常
-
 
2460
						if($delHeadStr["status"]==="false"){
-
 
2461
						
-
 
2462
							#設置錯誤識別
-
 
2463
							$result["status"]="false";
-
 
2464
 
-
 
2465
							#設置錯誤訊息
-
 
2466
							$result["error"]=$delHeadStr;
-
 
2467
 
-
 
2468
							#回傳結果
-
 
2469
							return $result;
-
 
2470
						
-
 
2471
							}#if end
-
 
2472
						
-
 
2473
						#取得...IN...value;comment
-
 
2474
						$unFormatStr=$delHeadStr["content"];
-
 
2475
					
-
 
2476
						}#if end
-
 
2477
					
-
 
2478
					#取得 ...IN... 後面的內容
-
 
2479
					#函式說明:
-
 
2480
					#將字串開頭的特定關鍵字移除.
-
 
2481
					#回傳結果:
-
 
2482
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2483
					#$result["error"],錯誤訊息陣列.
-
 
2484
					#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2485
					#$result["function"],當前執行的函數名稱.
-
 
2486
					#$result["argu"],使用的參數.
-
 
2487
					#$result["content"],處理好的的字串內容.
-
 
2488
					#$result["deleted"],被移除的內容.
-
 
2489
					#必填參數:
-
 
2490
					#$conf["stringIn"],字串,要處理的字串.
-
 
2491
					$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2492
					#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2493
					$conf["stringProcess::delHeadStr"]["headStr"]=array(" ","\t","IN");
-
 
2494
					#可省略參數:
-
 
2495
					#無.
-
 
2496
					#參考資料:
-
 
2497
					#無.
-
 
2498
					#備註:
-
 
2499
					#無.
-
 
2500
					$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2501
					unset($conf["stringProcess::delHeadStr"]);
-
 
2502
					
-
 
2503
					#如果執行異常
-
 
2504
					if($delHeadStr["status"]==="false"){
-
 
2505
					
-
 
2506
						#設置錯誤識別
-
 
2507
						$result["status"]="false";
-
 
2508
 
-
 
2509
						#設置錯誤訊息
-
 
2510
						$result["error"]=$delHeadStr;
-
 
2511
 
-
 
2512
						#回傳結果
-
 
2513
						return $result;
-
 
2514
					
-
 
2515
						}#if end
-
 
2516
					
-
 
2517
					#取得IN...value;comment
-
 
2518
					$unFormatStr=$delHeadStr["content"];
-
 
2519
					
-
 
2520
					#/*
-
 
2521
					#debug
-
 
2522
					#函式說明:
-
 
2523
					#撰寫log
-
 
2524
					#回傳結果:
-
 
2525
					#$result["status"],狀態,"true"或"false".
-
 
2526
					#$result["error"],錯誤訊息陣列.
-
 
2527
					#$result["function"],當前函式的名稱.
-
 
2528
					#$result["argu"],使用的參數.
-
 
2529
					#$result["content"],要寫入log的內容字串.
-
 
2530
					#必填參數:
-
 
2531
					#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2532
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
2533
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2534
					$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
-
 
2535
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2536
					$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
2537
					#可省略參數:
-
 
2538
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2539
					#$conf["rewrite"]="false";
-
 
2540
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
2541
					#$conf["returnOnly"]="true";
-
 
2542
					#參考資料:
-
 
2543
					#無.
-
 
2544
					#備註:
-
 
2545
					#無.
-
 
2546
					$record=logs::record($conf["logs::record"]);
-
 
2547
					unset($conf["logs::record"]);
-
 
2548
					#*/
-
 
2549
					
-
 
2550
					}#else end
-
 
2551
				
-
 
2552
				#解析 type...value;comment
-
 
2553
				#函式說明:
-
 
2554
				#將字串進行解析,變成多個參數.
-
 
2555
				#回傳結果:
-
 
2556
				#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
-
 
2557
				#$result["function"],當前執行的函式內容.
-
 
2558
				#$result["error"],錯誤訊息陣列.
-
 
2559
				#$result["content"],參數陣列.
-
 
2560
				#$result["count"],總共有幾個參數.
-
 
2561
				#必填參數:
-
 
2562
				#$conf["input"],字串,要解析成參數的字串.
-
 
2563
				$conf["stringProcess::parse"]["input"]=$unFormatStr;
-
 
2564
				#可省略參數:
-
 
2565
				#無.
-
 
2566
				#參考資料:
-
 
2567
				#無.
-
 
2568
				#備註:
-
 
2569
				#無.
-
 
2570
				$parse=stringProcess::parse($conf["stringProcess::parse"]);
-
 
2571
				unset($conf["stringProcess::parse"]);
-
 
2572
				
-
 
2573
				#如果執行異常
-
 
2574
				if($parse["status"]==="false"){
-
 
2575
				
-
 
2576
					#設置錯誤識別
-
 
2577
					$result["status"]="false";
-
 
2578
 
-
 
2579
					#設置錯誤訊息
-
 
2580
					$result["error"]=$parse;
-
 
2581
 
-
 
2582
					#回傳結果
-
 
2583
					return $result;
-
 
2584
					
-
 
2585
					}#if end
-
 
2586
				
-
 
2587
				#取得 type
-
 
2588
				$info["type"]=$parse["content"][0];
-
 
2589
				
-
 
2590
				#取得 type...後面的value;comment內容
-
 
2591
				#函式說明:
-
 
2592
				#將字串開頭的特定關鍵字移除.
-
 
2593
				#回傳結果:
-
 
2594
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2595
				#$result["error"],錯誤訊息陣列.
-
 
2596
				#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
2597
				#$result["function"],當前執行的函數名稱.
-
 
2598
				#$result["argu"],使用的參數.
-
 
2599
				#$result["content"],處理好的的字串內容.
-
 
2600
				#$result["deleted"],被移除的內容.
-
 
2601
				#必填參數:
-
 
2602
				#$conf["stringIn"],字串,要處理的字串.
-
 
2603
				$conf["stringProcess::delHeadStr"]["stringIn"]=$unFormatStr;
-
 
2604
				#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
2605
				$conf["stringProcess::delHeadStr"]["headStr"]=array($info["type"]," ","\t");
-
 
2606
				#可省略參數:
-
 
2607
				#無.
-
 
2608
				#參考資料:
-
 
2609
				#無.
-
 
2610
				#備註:
-
 
2611
				#無.
-
 
2612
				$delHeadStr=stringProcess::delHeadStr($conf["stringProcess::delHeadStr"]);
-
 
2613
				unset($conf["stringProcess::delHeadStr"]);
-
 
2614
				
-
 
2615
				#如果執行異常
-
 
2616
				if($delHeadStr["status"]==="false"){
-
 
2617
				
-
 
2618
					#設置錯誤識別
-
 
2619
					$result["status"]="false";
-
 
2620
 
-
 
2621
					#設置錯誤訊息
-
 
2622
					$result["error"]=$delHeadStr;
-
 
2623
 
-
 
2624
					#回傳結果
-
 
2625
					return $result;
-
 
2626
				
-
 
2627
					}#if end
-
 
2628
					
-
 
2629
				#取得 value;comment
-
 
2630
				$unFormatStr=$delHeadStr["content"];
-
 
2631
				
-
 
2632
				#如果有要合併回去的內容
-
 
2633
				if(isset($unFormatStr2add)){
-
 
2634
				
-
 
2635
					#合併回去內容
-
 
2636
					$unFormatStr=$unFormatStr.$unFormatStr2add;
-
 
2637
				
-
 
2638
					#移除用不到的變數
-
 
2639
					unset($unFormatStr2add);
-
 
2640
				
-
 
2641
					}#if end
-
 
2642
				
-
 
2643
				#/*
-
 
2644
				#debug
-
 
2645
				#函式說明:
-
 
2646
				#撰寫log
-
 
2647
				#回傳結果:
-
 
2648
				#$result["status"],狀態,"true"或"false".
-
 
2649
				#$result["error"],錯誤訊息陣列.
-
 
2650
				#$result["function"],當前函式的名稱.
-
 
2651
				#$result["argu"],使用的參數.
-
 
2652
				#$result["content"],要寫入log的內容字串.
-
 
2653
				#必填參數:
-
 
2654
				#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2655
				$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
2656
				#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2657
				$conf["logs::record"]["content"]="lineNo:".__LINE__." \$unFormatStr:".$unFormatStr.PHP_EOL;
-
 
2658
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2659
				$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
2660
				#可省略參數:
-
 
2661
				#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2662
				#$conf["rewrite"]="false";
-
 
2663
				#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
2664
				#$conf["returnOnly"]="true";
-
 
2665
				#參考資料:
-
 
2666
				#無.
-
 
2667
				#備註:
-
 
2668
				#無.
-
 
2669
				$record=logs::record($conf["logs::record"]);
-
 
2670
				unset($conf["logs::record"]);
-
 
2671
				#*/
-
 
2672
				
-
 
2673
				#如果type不為 CNAME 跟 TXT 跟 SOA
-
 
2674
				if( $info["type"]!=="CNAME" && $info["type"]!=="TXT" && $info["type"]!=="SOA" ){
-
 
2675
				
-
 
2676
					#儲存value
-
 
2677
					$info["value"]=$unFormatStr;
-
 
2678
				
-
 
2679
					#判斷是否有 ";" 存在
-
 
2680
					#函式說明:
-
 
2681
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2682
					#回傳結果:
-
 
2683
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2684
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2685
					#$result["function"],當前執行的函式名稱.
-
 
2686
					#$result["argu"],所使用的參數.
-
 
2687
					#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2688
					#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2689
					#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
2690
					#必填參數:
-
 
2691
					#$conf["input"],字串,要檢查的字串.
-
 
2692
					$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2693
					#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2694
					$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
2695
					#可省略參數:
-
 
2696
					#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2697
					#$conf["varEqual"]=array(null,"found");
-
 
2698
					#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2699
					#$conf["varCon"]=array("no_tail"=>" not");
-
 
2700
					#參考資料:
-
 
2701
					#無.
-
 
2702
					#備註:
-
 
2703
					#無.
-
 
2704
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2705
					unset($conf["search::findSpecifyStrFormat"]);
-
 
2706
				
-
 
2707
					#如果執行異常
-
 
2708
					if($findSpecifyStrFormat["status"]==="false"){
-
 
2709
					
-
 
2710
						#設置錯誤識別
-
 
2711
						$result["status"]="false";
-
 
2712
 
-
 
2713
						#設置錯誤訊息
-
 
2714
						$result["error"]=$findSpecifyStrFormat;
-
 
2715
 
-
 
2716
						#回傳結果
-
 
2717
						return $result;
-
 
2718
					
-
 
2719
						}#if end
-
 
2720
						
-
 
2721
					#如果有 ";"
-
 
2722
					if($findSpecifyStrFormat["found"]==="true"){
-
 
2723
					
-
 
2724
						#儲存value
-
 
2725
						$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
2726
					
-
 
2727
						#儲存comment
-
 
2728
						$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
2729
					
-
 
2730
						}#if end
-
 
2731
						
-
 
2732
					#儲存該筆RR
-
 
2733
					$result["content"][]=$info;
-
 
2734
						
-
 
2735
					#解析完畢換下一行
-
 
2736
					continue 2;
-
 
2737
				
-
 
2738
					}#if end
-
 
2739
						
-
 
2740
				#執行到這邊,代表type為CNAME或TXT或SOA
-
 
2741
				
-
 
2742
				#如果 type 是 SOA
-
 
2743
				if($info["type"]==="SOA"){
-
 
2744
				
-
 
2745
					#/*
-
 
2746
					#debug
-
 
2747
					#函式說明:
-
 
2748
					#撰寫log
-
 
2749
					#回傳結果:
-
 
2750
					#$result["status"],狀態,"true"或"false".
-
 
2751
					#$result["error"],錯誤訊息陣列.
-
 
2752
					#$result["function"],當前函式的名稱.
-
 
2753
					#$result["argu"],使用的參數.
-
 
2754
					#$result["content"],要寫入log的內容字串.
-
 
2755
					#必填參數:
-
 
2756
					#$conf["path"],字串,log檔案的路徑與名稱.
-
 
2757
					$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
2758
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
2759
					$conf["logs::record"]["content"]="lineNo:".__LINE__." type:".$info["type"].PHP_EOL;
-
 
2760
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
2761
					$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
2762
					#可省略參數:
-
 
2763
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
2764
					#$conf["rewrite"]="false";
-
 
2765
					#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
2766
					#$conf["returnOnly"]="true";
-
 
2767
					#參考資料:
-
 
2768
					#無.
-
 
2769
					#備註:
-
 
2770
					#無.
-
 
2771
					$record=logs::record($conf["logs::record"]);
-
 
2772
					unset($conf["logs::record"]);
-
 
2773
					#*/
-
 
2774
				
-
 
2775
					#SOA 範例
-
 
2776
					#@	1200	IN	SOA	dns.qbpwcf.org. liveuser.qbpwcf.org. 2026012205 10800 1800 1728000 1200 ;domain name server, admin mail, serial, refresh time, expire, Negative Caching, https://bind9.readthedocs.io/en/latest/chapter3.html#term-SOA-minimum
-
 
2777
				
-
 
2778
					#再度嘗試分割
-
 
2779
					#如果 內容為 query updatTime IN type value;comment,或value含有(或",則需要將其符號與後面的內容先暫時拆開
-
 
2780
			
-
 
2781
					#函式說明:
-
 
2782
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2783
					#回傳結果:
-
 
2784
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2785
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2786
					#$result["function"],當前執行的函式名稱.
-
 
2787
					#$result["argu"],所使用的參數.
-
 
2788
					#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2789
					#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2790
					#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2791
					#必填參數:
-
 
2792
					#$conf["input"],字串,要檢查的字串.
-
 
2793
					$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2794
					#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2795
					$conf["search::findSpecifyStrFormat"]["format"]="\${left}(\${right}";
-
 
2796
					#可省略參數:
-
 
2797
					#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2798
					#$conf["varEqual"]=array(null,"found");
-
 
2799
					#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2800
					#$conf["varCon"]=array("no_tail"=>" not");
-
 
2801
					#參考資料:
-
 
2802
					#無.
-
 
2803
					#備註:
-
 
2804
					#無.
-
 
2805
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2806
					unset($conf["search::findSpecifyStrFormat"]);
-
 
2807
				
-
 
2808
					#如果執行異常
-
 
2809
					if($findSpecifyStrFormat["status"]==="false"){
-
 
2810
					
-
 
2811
						#設置錯誤識別
-
 
2812
						$result["status"]="false";
-
 
2813
 
-
 
2814
						#設置錯誤訊息
-
 
2815
						$result["error"]=$findSpecifyStrFormat;
-
 
2816
 
-
 
2817
						#回傳結果
-
 
2818
						return $result;
-
 
2819
				
-
 
2820
						}#if end
-
 
2821
						
-
 
2822
					#如果存在"("
-
 
2823
					if($findSpecifyStrFormat["found"]==="true"){
-
 
2824
					
-
 
2825
						#取得無"("的內容
-
 
2826
						$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2827
						
-
 
2828
						#取得拆下來的含開頭"("內容
-
 
2829
						$unFormatStr2add="(".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2830
						
-
 
2831
						}#if end
-
 
2832
					
-
 
2833
					#反之
-
 
2834
					else{
-
 
2835
					
-
 
2836
						#函式說明:
-
 
2837
						#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2838
						#回傳結果:
-
 
2839
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2840
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2841
						#$result["function"],當前執行的函式名稱.
-
 
2842
						#$result["argu"],所使用的參數.
-
 
2843
						#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2844
						#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2845
						#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2846
						#必填參數:
-
 
2847
						#$conf["input"],字串,要檢查的字串.
-
 
2848
						$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2849
						#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2850
						$conf["search::findSpecifyStrFormat"]["format"]="\${left}\"\${right}";
-
 
2851
						#可省略參數:
-
 
2852
						#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2853
						#$conf["varEqual"]=array(null,"found");
-
 
2854
						#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2855
						#$conf["varCon"]=array("no_tail"=>" not");
-
 
2856
						#參考資料:
-
 
2857
						#無.
-
 
2858
						#備註:
-
 
2859
						#無.
-
 
2860
						$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2861
						unset($conf["search::findSpecifyStrFormat"]);
-
 
2862
					
-
 
2863
						#如果執行異常
-
 
2864
						if($findSpecifyStrFormat["status"]==="false"){
-
 
2865
						
-
 
2866
							#設置錯誤識別
-
 
2867
							$result["status"]="false";
-
 
2868
 
-
 
2869
							#設置錯誤訊息
-
 
2870
							$result["error"]=$findSpecifyStrFormat;
-
 
2871
 
-
 
2872
							#回傳結果
-
 
2873
							return $result;
-
 
2874
					
-
 
2875
							}#if end
-
 
2876
							
-
 
2877
						#如果存在"
-
 
2878
						if($findSpecifyStrFormat["found"]==="true"){
-
 
2879
						
-
 
2880
							#取得無"的內容
-
 
2881
							$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2882
							
-
 
2883
							#取得拆下來的含開頭"內容
-
 
2884
							$unFormatStr2add="\"".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2885
							
-
 
2886
							}#if end
-
 
2887
							
-
 
2888
						#反之
-
 
2889
						else{
-
 
2890
						
-
 
2891
							#函式說明:
-
 
2892
							#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
2893
							#回傳結果:
-
 
2894
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2895
							#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
2896
							#$result["function"],當前執行的函式名稱.
-
 
2897
							#$result["argu"],所使用的參數.
-
 
2898
							#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
2899
							#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
2900
							#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
2901
							#必填參數:
-
 
2902
							#$conf["input"],字串,要檢查的字串.
-
 
2903
							$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
2904
							#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
2905
							$conf["search::findSpecifyStrFormat"]["format"]="\${left};\${right}";
-
 
2906
							#可省略參數:
-
 
2907
							#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
2908
							#$conf["varEqual"]=array(null,"found");
-
 
2909
							#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
2910
							#$conf["varCon"]=array("no_tail"=>" not");
-
 
2911
							#參考資料:
-
 
2912
							#無.
-
 
2913
							#備註:
-
 
2914
							#無.
-
 
2915
							$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
2916
							unset($conf["search::findSpecifyStrFormat"]);
-
 
2917
						
-
 
2918
							#如果執行異常
-
 
2919
							if($findSpecifyStrFormat["status"]==="false"){
-
 
2920
							
-
 
2921
								#設置錯誤識別
-
 
2922
								$result["status"]="false";
-
 
2923
 
-
 
2924
								#設置錯誤訊息
-
 
2925
								$result["error"]=$findSpecifyStrFormat;
-
 
2926
 
-
 
2927
								#回傳結果
-
 
2928
								return $result;
-
 
2929
						
-
 
2930
								}#if end
-
 
2931
								
-
 
2932
							#如果存在";"
-
 
2933
							if($findSpecifyStrFormat["found"]==="true"){
-
 
2934
							
-
 
2935
								#取得無";"的內容
-
 
2936
								$unFormatStr=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
2937
								
-
 
2938
								#取得拆下來的含開頭";"內容
-
 
2939
								$unFormatStr2add=";".$findSpecifyStrFormat["parsedVar"]["right"][0];
-
 
2940
								
-
 
2941
								}#if end
-
 
2942
						
-
 
2943
							}#else end
-
 
2944
					
-
 
2945
						}#else end
-
 
2946
				
-
 
2947
					#取得 serial number
-
 
2948
					#函式說明:
-
 
2949
					#將字串進行解析,變成多個參數.
-
 
2950
					#回傳結果:
-
 
2951
					#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
-
 
2952
					#$result["function"],當前執行的函式內容.
-
 
2953
					#$result["error"],錯誤訊息陣列.
-
 
2954
					#$result["content"],參數陣列.
-
 
2955
					#$result["count"],總共有幾個參數.
-
 
2956
					#必填參數:
-
 
2957
					#$conf["input"],字串,要解析成參數的字串.
-
 
2958
					$conf["stringProcess::parse"]["input"]=$unFormatStr;
-
 
2959
					#可省略參數:
-
 
2960
					#無.
-
 
2961
					#參考資料:
-
 
2962
					#無.
-
 
2963
					#備註:
-
 
2964
					#無.
-
 
2965
					$parse=stringProcess::parse($conf["stringProcess::parse"]);
-
 
2966
					unset($conf["stringProcess::parse"]);
-
 
2967
					
-
 
2968
					#如果執行異常
-
 
2969
					if($parse["status"]==="false"){
-
 
2970
					
-
 
2971
						#設置錯誤識別
-
 
2972
						$result["status"]="false";
-
 
2973
 
-
 
2974
						#設置錯誤訊息
-
 
2975
						$result["error"]=$parse;
-
 
2976
 
-
 
2977
						#回傳結果
-
 
2978
						return $result;
-
 
2979
					
-
 
2980
						}#if end
-
 
2981
					
-
 
2982
					#取得serial number
-
 
2983
					$serialNo=$parse["content"][2];
-
 
2984
				
-
 
2985
					#serialNo+1
-
 
2986
					$serialNo++;
-
 
2987
				
-
 
2988
					#回存
-
 
2989
					$parse["content"][2]=(string)$serialNo;
-
 
2990
					
-
 
2991
					#函式說明:
-
 
2992
					#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
-
 
2993
					#回傳的結果:
-
 
2994
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
2995
					#$result["function"],當前執行的function名稱
-
 
2996
					#$result["error"],錯誤訊息陣列.
-
 
2997
					#$result["content"],處理好的字串.
-
 
2998
					#$result["argu"],使用的參數.
-
 
2999
					#必填參數:
-
 
3000
					#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
-
 
3001
					$conf["arrays::arrayToString"]["inputArray"]=$parse["content"];
-
 
3002
					#可省略參數:
-
 
3003
					#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
-
 
3004
					$conf["arrays::arrayToString"]["spiltSymbol"]=" ";
-
 
3005
					#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
-
 
3006
					$conf["arrays::arrayToString"]["skipEnd"]="true";
-
 
3007
					#$conf["spiltSymbolAtStart"],字串,是否要在開頭加上spiltSymbol,預設為"false",代表不要;反之為“true”.
-
 
3008
					#$conf["spiltSymbolAtStart"]="";
-
 
3009
					#參考資料:
-
 
3010
					#無.
-
 
3011
					#備註:
-
 
3012
					#無.
-
 
3013
					$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
-
 
3014
					unset($conf["arrays::arrayToString"]);
-
 
3015
					
-
 
3016
					#如果執行異常
-
 
3017
					if($arrayToString["status"]==="false"){
-
 
3018
					
-
 
3019
						#設置錯誤識別
-
 
3020
						$result["status"]="false";
-
 
3021
 
-
 
3022
						#設置錯誤訊息
-
 
3023
						$result["error"]=$arrayToString;
-
 
3024
 
-
 
3025
						#回傳結果
-
 
3026
						return $result;
-
 
3027
					
-
 
3028
						}#if end
-
 
3029
					
-
 
3030
					#取得更新 serial number 後的 SOA value string
-
 
3031
					$unFormatStr=$arrayToString["content"];
-
 
3032
				
-
 
3033
					#如果有要合併回去的內容
-
 
3034
					if(isset($unFormatStr2add)){
-
 
3035
					
-
 
3036
						#合併回去內容
-
 
3037
						$unFormatStr=$unFormatStr.$unFormatStr2add;
-
 
3038
					
-
 
3039
						#移除用不到的變數
-
 
3040
						unset($unFormatStr2add);
-
 
3041
					
-
 
3042
						}#if end
-
 
3043
				
-
 
3044
					#假設剩下的沒有註解都是 value
-
 
3045
					$info["value"]=$unFormatStr;
-
 
3046
				
-
 
3047
					#函式說明:
-
 
3048
					#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3049
					#回傳結果:
-
 
3050
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3051
					#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3052
					#$result["function"],當前執行的函式名稱.
-
 
3053
					#$result["argu"],所使用的參數.
-
 
3054
					#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3055
					#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3056
					#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3057
					#必填參數:
-
 
3058
					#$conf["input"],字串,要檢查的字串.
-
 
3059
					$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3060
					#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3061
					$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
3062
					#可省略參數:
-
 
3063
					#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3064
					#$conf["varEqual"]=array(null,"found");
-
 
3065
					#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3066
					#$conf["varCon"]=array("no_tail"=>" not");
-
 
3067
					#參考資料:
-
 
3068
					#無.
-
 
3069
					#備註:
-
 
3070
					#無.
-
 
3071
					$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3072
					unset($conf["search::findSpecifyStrFormat"]);
-
 
3073
				
-
 
3074
					#如果執行異常
-
 
3075
					if($findSpecifyStrFormat["status"]==="false"){
-
 
3076
					
-
 
3077
						#設置錯誤識別
-
 
3078
						$result["status"]="false";
-
 
3079
 
-
 
3080
						#設置錯誤訊息
-
 
3081
						$result["error"]=$findSpecifyStrFormat;
-
 
3082
 
-
 
3083
						#回傳結果
-
 
3084
						return $result;
-
 
3085
					
-
 
3086
						}#if end
-
 
3087
						
-
 
3088
					#如果有符合格式
-
 
3089
					if($findSpecifyStrFormat["found"]==="true"){
-
 
3090
					
-
 
3091
						#儲存 value
-
 
3092
						$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3093
					
-
 
3094
						#儲存 comment
-
 
3095
						$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3096
					
-
 
3097
						}#if end
-
 
3098
					
-
 
3099
					#儲存該筆RR
-
 
3100
					$result["content"][]=$info;
-
 
3101
					
-
 
3102
					#換下解析下筆RR
-
 
3103
					continue 2;
-
 
3104
				
-
 
3105
					}#if end
-
 
3106
				
-
 
3107
				#執行到這邊代表不是 SOA
-
 
3108
				
-
 
3109
				#尋找是否有(...)...的內容存在
-
 
3110
				#函式說明:
-
 
3111
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3112
				#回傳結果:
-
 
3113
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3114
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3115
				#$result["function"],當前執行的函式名稱.
-
 
3116
				#$result["argu"],所使用的參數.
-
 
3117
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3118
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3119
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3120
				#必填參數:
-
 
3121
				#$conf["input"],字串,要檢查的字串.
-
 
3122
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3123
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3124
				$conf["search::findSpecifyStrFormat"]["format"]="(\${value};\${comment}";
-
 
3125
				#可省略參數:
-
 
3126
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3127
				#$conf["varEqual"]=array(null,"found");
-
 
3128
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3129
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
3130
				#參考資料:
-
 
3131
				#無.
-
 
3132
				#備註:
-
 
3133
				#無.
-
 
3134
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3135
				unset($conf["search::findSpecifyStrFormat"]);
-
 
3136
			
-
 
3137
				#如果執行異常
-
 
3138
				if($findSpecifyStrFormat["status"]==="false"){
-
 
3139
				
-
 
3140
					#設置錯誤識別
-
 
3141
					$result["status"]="false";
-
 
3142
 
-
 
3143
					#設置錯誤訊息
-
 
3144
					$result["error"]=$findSpecifyStrFormat;
-
 
3145
 
-
 
3146
					#回傳結果
-
 
3147
					return $result;
-
 
3148
				
-
 
3149
					}#if end
-
 
3150
					
-
 
3151
				#如果有 有符合 ($value);${comment} 的格式
-
 
3152
				if($findSpecifyStrFormat["found"]==="true"){
-
 
3153
				
-
 
3154
					#儲存value
-
 
3155
					$info["value"]="(".$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3156
				
-
 
3157
					#儲存comment
-
 
3158
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3159
				
-
 
3160
					#儲存 RR 的記錄
-
 
3161
					$result["content"][]=$info;
-
 
3162
					
-
 
3163
					#跳到下一筆要解析的RR
-
 
3164
					continue 2;
-
 
3165
				
-
 
3166
					}#if end
-
 
3167
				
-
 
3168
				#執行到這邊代表沒有 (...)... 的內容存在
-
 
3169
				
-
 
3170
				#尋找是否有 (...) 的內容存在
-
 
3171
				#函式說明:
-
 
3172
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3173
				#回傳結果:
-
 
3174
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3175
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3176
				#$result["function"],當前執行的函式名稱.
-
 
3177
				#$result["argu"],所使用的參數.
-
 
3178
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3179
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3180
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3181
				#必填參數:
-
 
3182
				#$conf["input"],字串,要檢查的字串.
-
 
3183
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3184
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3185
				$conf["search::findSpecifyStrFormat"]["format"]="(\${value})";
-
 
3186
				#可省略參數:
-
 
3187
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3188
				#$conf["varEqual"]=array(null,"found");
-
 
3189
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3190
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
3191
				#參考資料:
-
 
3192
				#無.
-
 
3193
				#備註:
-
 
3194
				#無.
-
 
3195
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3196
				unset($conf["search::findSpecifyStrFormat"]);
-
 
3197
			
-
 
3198
				#如果執行異常
-
 
3199
				if($findSpecifyStrFormat["status"]==="false"){
-
 
3200
				
-
 
3201
					#設置錯誤識別
-
 
3202
					$result["status"]="false";
-
 
3203
 
-
 
3204
					#設置錯誤訊息
-
 
3205
					$result["error"]=$findSpecifyStrFormat;
-
 
3206
 
-
 
3207
					#回傳結果
-
 
3208
					return $result;
-
 
3209
				
-
 
3210
					}#if end
-
 
3211
					
-
 
3212
				#如果有 有符合 ($value);${comment} 的格式
-
 
3213
				if($findSpecifyStrFormat["found"]==="true"){
-
 
3214
				
-
 
3215
					#儲存value
-
 
3216
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3217
				
-
 
3218
					#儲存 RR 的記錄
-
 
3219
					$result["content"][]=$info;
-
 
3220
					
-
 
3221
					#跳到下一筆要解析的RR
-
 
3222
					continue 2;
-
 
3223
				
-
 
3224
					}#if end
-
 
3225
					
-
 
3226
				#執行到這邊代表沒有 (...) 的內容存在
-
 
3227
				
-
 
3228
				#尋找有無 "...";... 的內容存在
-
 
3229
				#函式說明:
-
 
3230
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3231
				#回傳結果:
-
 
3232
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3233
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3234
				#$result["function"],當前執行的函式名稱.
-
 
3235
				#$result["argu"],所使用的參數.
-
 
3236
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3237
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3238
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3239
				#必填參數:
-
 
3240
				#$conf["input"],字串,要檢查的字串.
-
 
3241
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3242
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3243
				$conf["search::findSpecifyStrFormat"]["format"]="\"\${value};\${comment}";
-
 
3244
				#可省略參數:
-
 
3245
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3246
				#$conf["varEqual"]=array(null,"found");
-
 
3247
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3248
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
3249
				#參考資料:
-
 
3250
				#無.
-
 
3251
				#備註:
-
 
3252
				#無.
-
 
3253
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3254
				unset($conf["search::findSpecifyStrFormat"]);
-
 
3255
			
-
 
3256
				#如果執行異常
-
 
3257
				if($findSpecifyStrFormat["status"]==="false"){
-
 
3258
				
-
 
3259
					#設置錯誤識別
-
 
3260
					$result["status"]="false";
-
 
3261
 
-
 
3262
					#設置錯誤訊息
-
 
3263
					$result["error"]=$findSpecifyStrFormat;
-
 
3264
 
-
 
3265
					#回傳結果
-
 
3266
					return $result;
-
 
3267
				
-
 
3268
					}#if end
-
 
3269
					
-
 
3270
				#如果有 有符合 "$value";${comment} 的格式
-
 
3271
				if($findSpecifyStrFormat["found"]==="true"){
-
 
3272
				
-
 
3273
					#儲存value
-
 
3274
					$info["value"]="\"".$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3275
					
-
 
3276
					#儲存comment
-
 
3277
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3278
				
-
 
3279
					#儲存 RR 的記錄
-
 
3280
					$result["content"][]=$info;
-
 
3281
					
-
 
3282
					#跳到下一筆要解析的RR
-
 
3283
					continue 2;
-
 
3284
				
-
 
3285
					}#if end
-
 
3286
					
-
 
3287
				#執行到這邊代表沒有 "$value";${comment} 的格式
-
 
3288
				
-
 
3289
				#尋找有無 "..." 的內容存在
-
 
3290
				#函式說明:
-
 
3291
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3292
				#回傳結果:
-
 
3293
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3294
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3295
				#$result["function"],當前執行的函式名稱.
-
 
3296
				#$result["argu"],所使用的參數.
-
 
3297
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3298
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3299
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3300
				#必填參數:
-
 
3301
				#$conf["input"],字串,要檢查的字串.
-
 
3302
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3303
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3304
				$conf["search::findSpecifyStrFormat"]["format"]="\"\${value}\"";
-
 
3305
				#可省略參數:
-
 
3306
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3307
				#$conf["varEqual"]=array(null,"found");
-
 
3308
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3309
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
3310
				#參考資料:
-
 
3311
				#無.
-
 
3312
				#備註:
-
 
3313
				#無.
-
 
3314
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3315
				unset($conf["search::findSpecifyStrFormat"]);
-
 
3316
			
-
 
3317
				#如果執行異常
-
 
3318
				if($findSpecifyStrFormat["status"]==="false"){
-
 
3319
				
-
 
3320
					#設置錯誤識別
-
 
3321
					$result["status"]="false";
-
 
3322
 
-
 
3323
					#設置錯誤訊息
-
 
3324
					$result["error"]=$findSpecifyStrFormat;
-
 
3325
 
-
 
3326
					#回傳結果
-
 
3327
					return $result;
-
 
3328
				
-
 
3329
					}#if end
-
 
3330
					
-
 
3331
				#如果有 有符合 "$value" 的格式
-
 
3332
				if($findSpecifyStrFormat["found"]==="true"){
-
 
3333
				
-
 
3334
					#儲存value
-
 
3335
					$info["value"]="\"".$findSpecifyStrFormat["parsedVar"]["value"][0]."\"";
-
 
3336
					
-
 
3337
					#儲存 RR 的記錄
-
 
3338
					$result["content"][]=$info;
-
 
3339
					
-
 
3340
					#跳到下一筆要解析的RR
-
 
3341
					continue 2;
-
 
3342
				
-
 
3343
					}#if end
-
 
3344
					
-
 
3345
				#執行到這邊代表沒有 "$value" 格式的內容
-
 
3346
				
-
 
3347
				#檢查是否有 $value;$comment 格式的內容
-
 
3348
				#函式說明:
-
 
3349
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3350
				#回傳結果:
-
 
3351
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3352
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3353
				#$result["function"],當前執行的函式名稱.
-
 
3354
				#$result["argu"],所使用的參數.
-
 
3355
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3356
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3357
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容.
-
 
3358
				#必填參數:
-
 
3359
				#$conf["input"],字串,要檢查的字串.
-
 
3360
				$conf["search::findSpecifyStrFormat"]["input"]=$unFormatStr;
-
 
3361
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3362
				$conf["search::findSpecifyStrFormat"]["format"]="\${value};\${comment}";
-
 
3363
				#可省略參數:
-
 
3364
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3365
				#$conf["varEqual"]=array(null,"found");
-
 
3366
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3367
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
3368
				#參考資料:
-
 
3369
				#無.
-
 
3370
				#備註:
-
 
3371
				#無.
-
 
3372
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3373
				unset($conf["search::findSpecifyStrFormat"]);
-
 
3374
			
-
 
3375
				#如果執行異常
-
 
3376
				if($findSpecifyStrFormat["status"]==="false"){
-
 
3377
				
-
 
3378
					#設置錯誤識別
-
 
3379
					$result["status"]="false";
-
 
3380
 
-
 
3381
					#設置錯誤訊息
-
 
3382
					$result["error"]=$findSpecifyStrFormat;
-
 
3383
 
-
 
3384
					#回傳結果
-
 
3385
					return $result;
-
 
3386
				
-
 
3387
					}#if end
-
 
3388
					
-
 
3389
				#如果有 有符合 "$value" 的格式
-
 
3390
				if($findSpecifyStrFormat["found"]==="true"){
-
 
3391
				
-
 
3392
					#儲存value
-
 
3393
					$info["value"]=$findSpecifyStrFormat["parsedVar"]["value"][0];
-
 
3394
					
-
 
3395
					#儲存comment
-
 
3396
					$info["comment"]=$findSpecifyStrFormat["parsedVar"]["comment"][0];
-
 
3397
					
-
 
3398
					#儲存 RR 的記錄
-
 
3399
					$result["content"][]=$info;
-
 
3400
					
-
 
3401
					#跳到下一筆要解析的RR
-
 
3402
					continue 2;
-
 
3403
				
-
 
3404
					}#if end
-
 
3405
			
-
 
3406
				#執行到這邊代表沒有 ${value};${comment} 格式的內容
-
 
3407
				
-
 
3408
				#亦即剩下的內容都是 value
-
 
3409
				
-
 
3410
				#儲存value
-
 
3411
				$info["value"]=$unFormatStr;
-
 
3412
				
-
 
3413
				#儲存 RR 的記錄
-
 
3414
				$result["content"][]=$info;
-
 
3415
				
-
 
3416
				#跳到下一筆要解析的RR
-
 
3417
				continue 2;
-
 
3418
				
-
 
3419
				}#while end
-
 
3420
			
-
 
3421
			}#foreach end
-
 
3422
		
-
 
3423
		#/*
-
 
3424
		#debug
-
 
3425
		#函式說明:
-
 
3426
		#撰寫log
-
 
3427
		#回傳結果:
-
 
3428
		#$result["status"],狀態,"true"或"false".
-
 
3429
		#$result["error"],錯誤訊息陣列.
-
 
3430
		#$result["function"],當前函式的名稱.
-
 
3431
		#$result["argu"],使用的參數.
-
 
3432
		#$result["content"],要寫入log的內容字串.
-
 
3433
		#必填參數:
-
 
3434
		#$conf["path"],字串,log檔案的路徑與名稱.
-
 
3435
		$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
3436
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
3437
		$conf["logs::record"]["content"]="lineNo:".__LINE__." parse RR fin.".PHP_EOL;
-
 
3438
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
3439
		$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
3440
		#可省略參數:
-
 
3441
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
3442
		#$conf["rewrite"]="false";
-
 
3443
		#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
3444
		#$conf["returnOnly"]="true";
-
 
3445
		#參考資料:
-
 
3446
		#無.
-
 
3447
		#備註:
-
 
3448
		#無.
-
 
3449
		$record=logs::record($conf["logs::record"]);
-
 
3450
		unset($conf["logs::record"]);
-
 
3451
		#*/
-
 
3452
		
-
 
3453
		#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
-
 
3454
		
-
 
3455
		#針對每個要新增的RR記錄
-
 
3456
		foreach($conf["add"] as $newRR){
-
 
3457
			
-
 
3458
			#針對 zone file 中既有的每個RR記錄
-
 
3459
			foreach($result["content"] as $index => $oldRR){
-
 
3460
			
-
 
3461
				#如果既有的跟新的RR都為 $ORIGIN
-
 
3462
				if($oldRR["type"]==="\$ORIGIN" && $newRR["type"]==="\$ORIGIN"){
-
 
3463
				
-
 
3464
					#取代既有的 RR
-
 
3465
					$result["content"][$index]=$newRR;
-
 
3466
					
-
 
3467
					#換看下一筆newRR
-
 
3468
					continue 2;
-
 
3469
					
-
 
3470
					}#if end
-
 
3471
					
-
 
3472
				#如果既有的跟新的RR都為 $TTL
-
 
3473
				if($oldRR["type"]==="\$TTL" && $newRR["type"]==="\$TTL"){
-
 
3474
				
-
 
3475
					#取代既有的 RR
-
 
3476
					$result["content"][$index]=$newRR;
-
 
3477
					
-
 
3478
					#換看下一筆newRR
-
 
3479
					continue 2;
-
 
3480
					
-
 
3481
					}#if end
-
 
3482
			
-
 
3483
				#如果跟既有的 query、type、value 有相同
-
 
3484
				if($newRR["query"]===$oldRR["query"] && $newRR["type"]===$oldRR["type"] && $newRR["value"]===$oldRR["value"] ){
-
 
3485
				
-
 
3486
					#如果新 RR 有 update time
-
 
3487
					if(isset($newRR["update"])){
-
 
3488
					
-
 
3489
						#如果新舊 update time 不相同
-
 
3490
						if( $newRR["update"] !== $oldRR["update"] ){
-
 
3491
						
-
 
3492
							#取代既有的 RR
-
 
3493
							$result["content"][$index]=$newRR;
-
 
3494
							
-
 
3495
							#換看下一筆newRR
-
 
3496
							continue 2;
-
 
3497
							
-
 
3498
							}#if end
-
 
3499
					
-
 
3500
						}#if end
-
 
3501
						
-
 
3502
					#反之既有的 update time 若跟 global TTL 不一樣
-
 
3503
					else if( $oldRR["update"] !== $result["defaultTTL"] ){
-
 
3504
					
-
 
3505
						#更新為 global TTL
-
 
3506
						$result["content"][$index]["update"]=$result["defaultTTL"];
-
 
3507
						
-
 
3508
						}#if end
-
 
3509
						
-
 
3510
					#如果新 RR 有 comment
-
 
3511
					if( isset($newRR["comment"]) ){
-
 
3512
					
-
 
3513
						#更新既有 RR 的 comment
-
 
3514
						$result["content"][$index]["comment"]=$newRR["comment"];
-
 
3515
					
-
 
3516
						#換看下一筆newRR
-
 
3517
						continue 2;
-
 
3518
					
-
 
3519
						}#if end
-
 
3520
						
-
 
3521
					#反之,如果有既有 comment
-
 
3522
					else if(isset($result["content"][$index]["comment"])){
-
 
3523
					
-
 
3524
						#移除既有 comment
-
 
3525
						unset($result["content"][$index]["comment"]);
-
 
3526
						
-
 
3527
						#換看下一筆newRR
-
 
3528
						continue 2;
-
 
3529
					
-
 
3530
						}#else end
-
 
3531
				
-
 
3532
					}#if end
-
 
3533
			
-
 
3534
				}#foreach end
-
 
3535
				
-
 
3536
			#儲存確定要新增的RR
-
 
3537
			$result["content"][]=$newRR;
-
 
3538
		
-
 
3539
			}#foreach end
-
 
3540
		
-
 
3541
		#/*
-
 
3542
		#debug
-
 
3543
		#函式說明:
-
 
3544
		#撰寫log
-
 
3545
		#回傳結果:
-
 
3546
		#$result["status"],狀態,"true"或"false".
-
 
3547
		#$result["error"],錯誤訊息陣列.
-
 
3548
		#$result["function"],當前函式的名稱.
-
 
3549
		#$result["argu"],使用的參數.
-
 
3550
		#$result["content"],要寫入log的內容字串.
-
 
3551
		#必填參數:
-
 
3552
		#$conf["path"],字串,log檔案的路徑與名稱.
-
 
3553
		$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
3554
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
3555
		$conf["logs::record"]["content"]="lineNo:".__LINE__." total RR record count:".count($result["content"])." list:".PHP_EOL;
-
 
3556
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
3557
		$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
3558
		#可省略參數:
-
 
3559
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
3560
		#$conf["rewrite"]="false";
-
 
3561
		#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
3562
		#$conf["returnOnly"]="true";
-
 
3563
		#參考資料:
-
 
3564
		#無.
-
 
3565
		#備註:
-
 
3566
		#無.
-
 
3567
		$record=logs::record($conf["logs::record"]);
-
 
3568
		unset($conf["logs::record"]);
-
 
3569
		#*/
-
 
3570
		
-
 
3571
		#/*
-
 
3572
		#debug
-
 
3573
		#函式說明:
-
 
3574
		#撰寫log
-
 
3575
		#回傳結果:
-
 
3576
		#$result["status"],狀態,"true"或"false".
-
 
3577
		#$result["error"],錯誤訊息陣列.
-
 
3578
		#$result["function"],當前函式的名稱.
-
 
3579
		#$result["argu"],使用的參數.
-
 
3580
		#$result["content"],要寫入log的內容字串.
-
 
3581
		#必填參數:
-
 
3582
		#$conf["path"],字串,log檔案的路徑與名稱.
-
 
3583
		$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
3584
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
3585
		$conf["logs::record"]["content"]=$result["content"];
-
 
3586
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
3587
		$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
3588
		#可省略參數:
-
 
3589
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
3590
		#$conf["rewrite"]="false";
-
 
3591
		#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
3592
		#$conf["returnOnly"]="true";
-
 
3593
		#參考資料:
-
 
3594
		#無.
-
 
3595
		#備註:
-
 
3596
		#無.
-
 
3597
		$record=logs::record($conf["logs::record"]);
-
 
3598
		unset($conf["logs::record"]);
-
 
3599
		#*/
-
 
3600
		
-
 
3601
		#初始化要寫入的內容
-
 
3602
		$strs2write=array();
-
 
3603
		
-
 
3604
		#針對每個RR記錄
-
 
3605
		foreach($result["content"] as $RR){
-
 
3606
		
-
 
3607
			#初始化暫存要寫入的行內容
-
 
3608
			$str2write="";
-
 
3609
		
-
 
3610
			#如果是
-
 
3611
			if( $RR["type"]==="\$ORIGIN" || $RR["type"]==="\$TTL" ){
-
 
3612
			
-
 
3613
				#組合變數名稱與數值
-
 
3614
				$str2write=$str2write.$RR["type"]."\t".$RR["value"];
-
 
3615
				
-
 
3616
				}#if end
-
 
3617
			
-
 
3618
			#反之
-
 
3619
			else{
-
 
3620
			
-
 
3621
				#加上查詢的字句
-
 
3622
				$str2write=$str2write.$RR["query"];
-
 
3623
			
-
 
3624
				#如果該筆RR有指定update time該ZONE具備 global TTL.
-
 
3625
				if(isset($RR["update"])){
-
 
3626
				
-
 
3627
					#如果 該ZONE具備 global TTL.
-
 
3628
					if(isset($result["defaultTTL"])){
-
 
3629
					
-
 
3630
						#如果該筆 RR 的 update time 不等於 global TTL
-
 
3631
						if($RR["update"]!==$result["defaultTTL"]){
-
 
3632
						
-
 
3633
							#加上TTL的字句
-
 
3634
							$str2write=$str2write."\t".$RR["update"];
-
 
3635
						
-
 
3636
							}#if end
-
 
3637
					
-
 
3638
						}#if end
-
 
3639
				
-
 
3640
					#反之
-
 
3641
					else{
-
 
3642
					
-
 
3643
						#加上TTL的字句
-
 
3644
						$str2write=$str2write."\t".$RR["update"];
-
 
3645
					
-
 
3646
						}#else end
-
 
3647
				
-
 
3648
					}#if end
-
 
3649
				
-
 
3650
				#反之
-
 
3651
				else{
-
 
3652
				
-
 
3653
					#加上global TTL的字句
-
 
3654
					$str2write=$str2write."\t".$result["defaultTTL"];
-
 
3655
				
-
 
3656
					}#else end
-
 
3657
					
-
 
3658
				#加上IN跟TYPE跟value
-
 
3659
				$str2write=$str2write."\tIN\t".$RR["type"]."\t".$RR["value"];
-
 
3660
				
-
 
3661
				}#else end
-
 
3662
				
-
 
3663
			#如果有註解
-
 
3664
			if(isset($RR["comment"])){
-
 
3665
			
-
 
3666
				#加上comment
-
 
3667
				$str2write=$str2write.";".$RR["comment"];
-
 
3668
			
-
 
3669
				}#if end
-
 
3670
			
-
 
3671
			#/*
-
 
3672
			#debug
-
 
3673
			#函式說明:
-
 
3674
			#撰寫log
-
 
3675
			#回傳結果:
-
 
3676
			#$result["status"],狀態,"true"或"false".
-
 
3677
			#$result["error"],錯誤訊息陣列.
-
 
3678
			#$result["function"],當前函式的名稱.
-
 
3679
			#$result["argu"],使用的參數.
-
 
3680
			#$result["content"],要寫入log的內容字串.
-
 
3681
			#必填參數:
-
 
3682
			#$conf["path"],字串,log檔案的路徑與名稱.
-
 
3683
			$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
3684
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
3685
			$conf["logs::record"]["content"]="lineNo:".__LINE__." build RR record:".$str2write.PHP_EOL;
-
 
3686
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
3687
			$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
3688
			#可省略參數:
-
 
3689
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
3690
			#$conf["rewrite"]="false";
-
 
3691
			#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
3692
			#$conf["returnOnly"]="true";
-
 
3693
			#參考資料:
-
 
3694
			#無.
-
 
3695
			#備註:
-
 
3696
			#無.
-
 
3697
			$record=logs::record($conf["logs::record"]);
-
 
3698
			unset($conf["logs::record"]);
-
 
3699
			#*/
-
 
3700
			
-
 
3701
			#加上要寫入的元素
-
 
3702
			$strs2write[]=$str2write;
-
 
3703
		
-
 
3704
			}#foreach end
-
 
3705
			
-
 
3706
		#如果有逐行註解
-
 
3707
		if(count($result["comment"])>0){
-
 
3708
		
-
 
3709
			#加到結尾
-
 
3710
			#函式說明:
-
 
3711
			#將多個一維陣列串聯起來,key從0開始排序.
-
 
3712
			#回傳的結果:
-
 
3713
			#$result["status"],"true"表執行正常,"false"代表執行不正常.
-
 
3714
			#$result["error"],錯誤訊息陣列.
-
 
3715
			#$result["function"],當前執行的函數.
-
 
3716
			#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
3717
			#$result["content"],合併好的一維陣列.
-
 
3718
			#必填參數
-
 
3719
			#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
-
 
3720
			$conf["arrays::mergeArray"]["inputArray"]=array($strs2write,$result["comment"]);
-
 
3721
			#可省略參數:
-
 
3722
			#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
-
 
3723
			#$conf["allowRepeat"]="true";
-
 
3724
			#$conf["looseDiff"],字串,預設為"false",代表要嚴謹判斷為有相異,例如陣列中元素的key順序不同(整數)就代表有相異;反之為"true",例如陣列中元素的key順序不同(非整數),但value有相同,則視為無相異.
-
 
3725
			#$conf["looseDiff"]="false";
-
 
3726
			#參考資料:
-
 
3727
			#無.
-
 
3728
			#備註:
-
 
3729
			#無.
-
 
3730
			$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
-
 
3731
			unset($conf["arrays::mergeArray"]);
-
 
3732
		
-
 
3733
			#如果執行異常
-
 
3734
			if($mergeArray["status"]==="false"){
-
 
3735
			
-
 
3736
				#設置錯誤識別
-
 
3737
				$result["status"]="false";
-
 
3738
 
-
 
3739
				#設置錯誤訊息
-
 
3740
				$result["error"]=$mergeArray;
-
 
3741
 
-
 
3742
				#回傳結果
-
 
3743
				return $result;
-
 
3744
			
-
 
3745
				}#if end
-
 
3746
				
-
 
3747
			#取得合併好的陣列
-
 
3748
			$strs2write=$mergeArray["content"];
-
 
3749
		
-
 
3750
			}#if end
-
 
3751
		
-
 
3752
		#debug
-
 
3753
		#函式說明:
-
 
3754
		#撰寫log
-
 
3755
		#回傳結果:
-
 
3756
		#$result["status"],狀態,"true"或"false".
-
 
3757
		#$result["error"],錯誤訊息陣列.
-
 
3758
		#$result["function"],當前函式的名稱.
-
 
3759
		#$result["argu"],使用的參數.
-
 
3760
		#$result["content"],要寫入log的內容字串.
-
 
3761
		#必填參數:
-
 
3762
		#$conf["path"],字串,log檔案的路徑與名稱.
-
 
3763
		$conf["logs::record"]["path"]="/tmp/zerossl::".__FUNCTION__;
-
 
3764
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
3765
		$conf["logs::record"]["content"]="lineNo:".__LINE__." total line to write:".count($strs2write).PHP_EOL;
-
 
3766
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
3767
		$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
3768
		#可省略參數:
-
 
3769
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
3770
		#$conf["rewrite"]="false";
-
 
3771
		#$conf["returnOnly"],預設為"false",會寫入到log檔案.若為"true"則不會寫入log.
-
 
3772
		#$conf["returnOnly"]="true";
-
 
3773
		#參考資料:
-
 
3774
		#無.
-
 
3775
		#備註:
-
 
3776
		#無.
-
 
3777
		$record=logs::record($conf["logs::record"]);
-
 
3778
		unset($conf["logs::record"]);
-
 
3779
		
-
 
3780
		#儲存新zone file每行的內容
-
 
3781
		$result["newZoneFileContent"]=$strs2write;
-
 
3782
		
-
 
3783
		#如果要寫入ZONE檔案
-
 
3784
		if($conf["writeNow"]==="true"){
-
 
3785
		
-
 
3786
			#覆寫 ZONE file
-
 
3787
			#函式說明:
-
 
3788
			#更新檔案的內容.
-
 
3789
			#回傳結果:
-
 
3790
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3791
			#$result["error"],錯誤訊息.
-
 
3792
			#$result["function"],當前執行的函數名稱.
-
 
3793
			#$result["content"],更新的資訊.
-
 
3794
			#$result["content"][$lineIndex]["ori"],原始 $lineIndex+1 行的內容,若為null則代表不存在.
-
 
3795
			#$result["content"][$lineIndex]["new"],新 $lineIndex+1 行的內容,若為null則代表不存在.
-
 
3796
			#必填參數:
-
 
3797
			#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
3798
			$conf["fileAccess::updateFile"]["fileArgu"]=__FILE__;
-
 
3799
			#$conf["file"],字串,要更新的檔案位置與名稱.
-
 
3800
			$conf["fileAccess::updateFile"]["file"]=$conf["dnsRecordFile"];
-
 
3801
			#可省略參數:
-
 
3802
			#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
-
 
3803
			$conf["fileAccess::updateFile"]["overWriteWith"]=$strs2write;
-
 
3804
			#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
-
 
3805
			#$conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
-
 
3806
			#$conf["replaceLike"],字串,預設為"false",代表要完全符合關鍵字才能進行整行替換;反之為"true".
-
 
3807
			#$conf["replaceLike"]="false";
-
 
3808
			#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
-
 
3809
			#$conf["addToTailWhenNoMatch"]="false";
-
 
3810
			#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
-
 
3811
			#$conf["addToTailBeforeThat"]="?\>";
-
 
3812
			#$conf["replaceSpecifyLine"],字串陣列,將指定的行取代成指定的內容,元素的key為原始檔案的行索引,若key為$i+1,則代表第$i行;元素的數值就為該行的新內容.
-
 
3813
			#$conf["replaceSpecifyLine"]=array();
-
 
3814
			#$conf["outputPath"],字串,檔案要輸出到哪個位置,預設不指定,直接取代原始檔案的內容.
-
 
3815
			#$conf["outputPath"]="";
-
 
3816
			#參考資料:
-
 
3817
			#無.
-
 
3818
			#備註:
-
 
3819
			#無.
-
 
3820
			$updateFile=fileAccess::updateFile($conf["fileAccess::updateFile"]);
-
 
3821
			unset($conf["fileAccess::updateFile"]);
-
 
3822
		
-
 
3823
			#如果執行異常
-
 
3824
			if($updateFile["status"]==="false"){
-
 
3825
			
-
 
3826
				#設置錯誤識別
-
 
3827
				$result["status"]="false";
-
 
3828
 
-
 
3829
				#設置錯誤訊息
-
 
3830
				$result["error"]=$updateFile;
-
 
3831
 
-
 
3832
				#回傳結果
-
 
3833
				return $result;
-
 
3834
			
-
 
3835
				}#if end
-
 
3836
		
-
 
3837
			}#if end
-
 
3838
			
-
 
3839
		#設置執行正常
-
 
3840
		$result["status"]="true";
-
 
3841
	
-
 
3842
		#回傳結果
-
 
3843
		return $result;
-
 
3844
	
-
 
3845
		}#function updateDnsRecordFile end
-
 
3846
 
-
 
3847
	/*
-
 
3848
	#函式說明:
-
 
3849
	#驗證已經透過zerossl::createCertificate要求的domain,並取得ssl憑證.
-
 
3850
	#回傳結果:
-
 
3851
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3852
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3853
	#$result["function"],當前執行的函式名稱.
-
 
3854
	#$result["argu"],所使用的參數.
-
 
3855
	#$result["curl_verbose_info"],curl執行的詳細資訊.
-
 
3856
	#$result["content"],字串,得到的json字串回應.
-
 
3857
	#必填參數:
-
 
3858
	#$conf["id"],字串,zerossl::createCertificate回傳的id.
-
 
3859
	$conf["id"]="";
-
 
3860
	#可省略參數:
-
 
3861
	#$conf["apiDomain"],字串,提供服務的domain,預設為 self::getApiInfo()["doamin"].
-
 
3862
	#$conf["apiDomain"]=self::getApiInfo()["doamin"];
-
 
3863
	#$conf["key"],字串,api key,預設為 self::getApiInfo()["apiKey"].
-
 
3864
	#$conf["key"]=self::getApiInfo()["apiKey"];
-
 
3865
	#參考資料:
-
 
3866
	#無.
-
 
3867
	#備註:
-
 
3868
	#無.
-
 
3869
	*/
-
 
3870
	public static function verifyDomain(&$conf){
-
 
3871
	
-
 
3872
		#初始化要回傳的結果
-
 
3873
		$result=array();
-
 
3874
 
-
 
3875
		#設置當其函數名稱
-
 
3876
		$result["function"]=__FUNCTION__;
-
 
3877
 
-
 
3878
		#如果 $conf 不為陣列
-
 
3879
		if(gettype($conf)!="array"){
-
 
3880
 
-
 
3881
			#設置執行失敗
-
 
3882
			$result["status"]="false";
-
 
3883
 
-
 
3884
			#設置執行錯誤訊息
-
 
3885
			$result["error"][]="\$conf變數須為陣列形態";
-
 
3886
 
-
 
3887
			#如果傳入的參數為 null
-
 
3888
			if($conf==null){
-
 
3889
 
-
 
3890
				#設置執行錯誤訊息
-
 
3891
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
3892
 
-
 
3893
				}#if end
-
 
3894
 
-
 
3895
			#回傳結果
-
 
3896
			return $result;
-
 
3897
 
-
 
3898
			}#if end
-
 
3899
 
-
 
3900
		#取得參數
-
 
3901
		$result["argu"]=$conf;
-
 
3902
 
-
 
3903
		#檢查參數
-
 
3904
		#函式說明:
-
 
3905
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
-
 
3906
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3907
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3908
		#$result["function"],當前執行的函式名稱.
-
 
3909
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
3910
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
3911
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
3912
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
3913
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
3914
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
3915
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
3916
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
3917
		#必填寫的參數:
-
 
3918
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
3919
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
3920
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
3921
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("id");
-
 
3922
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
-
 
3923
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
-
 
3924
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
3925
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
3926
		#可以省略的參數:
-
 
3927
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
3928
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
-
 
3929
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
-
 
3930
		#$conf["skipableVariableCanNotBeEmpty"]=array();
-
 
3931
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
3932
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("apiDomain","key");
-
 
3933
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
3934
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
-
 
3935
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
3936
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(self::getApiInfo()["apiDomain"],self::getApiInfo()["csrPath"],self::getApiInfo()["apiKey"]);
-
 
3937
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
3938
		#$conf["arrayCountEqualCheck"][]=array();
-
 
3939
		#參考資料來源:
-
 
3940
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
3941
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
3942
		unset($conf["variableCheck::checkArguments"]);
-
 
3943
 
-
 
3944
		#如果檢查失敗
-
 
3945
		if($checkArguments["status"]==="false"){
-
 
3946
 
-
 
3947
			#設置錯誤識別
-
 
3948
			$result["status"]="false";
-
 
3949
 
-
 
3950
			#設置錯誤訊息
-
 
3951
			$result["error"]=$checkArguments;
-
 
3952
 
-
 
3953
			#回傳結果
-
 
3954
			return $result;
-
 
3955
 
-
 
3956
			}#if end
-
 
3957
 
-
 
3958
		#如果檢查不通過
-
 
3959
		if($checkArguments["passed"]==="false"){
-
 
3960
 
-
 
3961
			#設置錯誤識別
-
 
3962
			$result["status"]="false";
-
 
3963
 
-
 
3964
			#設置錯誤訊息
-
 
3965
			$result["error"]=$checkArguments;
-
 
3966
 
-
 
3967
			#回傳結果
-
 
3968
			return $result;
-
 
3969
 
-
 
3970
			}#if end
-
 
3971
			
-
 
3972
		#要傳送的 key -> value
-
 
3973
		$postArray=array();
-
 
3974
 
-
 
3975
		#設置要簽署的domain
-
 
3976
		$postArray["validation_method"]="CNAME_CSR_HASH";
-
 
3977
		
-
 
3978
		#設置要傳送的 json
-
 
3979
		$postJson=json_encode($postArray);
-
 
3980
 
-
 
3981
		#函式說明:
-
 
3982
		#運行curl cmd
-
 
3983
		#回傳結果:
-
 
3984
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3985
		#$result["error"],錯誤訊息陣列.
-
 
3986
		#$result["function"],當前執行的函式名稱.
-
 
3987
		#$result["founded"],識別網址找不找得到.
630
		}#function csr end
3988
		#$result["content"],取得的回應內容陣列;若$conf["bgInProc"]為"true",則每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source;key為"proc_get_status"代表程序的資訊.
-
 
3989
		#$result["fullContent"],取得回應的完整字串內容.
-
 
3990
		#$result["cookie"],cookie檔案的位置與名稱.
-
 
3991
		#$result["cmd"],執行的command.
-
 
3992
		#$result["argu],使用的參數.
-
 
3993
		#必填參數:
-
 
3994
		#$conf["url"],字串,目標url.
-
 
3995
		$conf["catchWebContent::curlCmd"]["url"]="https://".$conf["apiDomain"]."/".$conf["id"]."/challenges";
-
 
3996
		#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
3997
		$conf["catchWebContent::curlCmd"]["fileArgu"]=__FILE__;
-
 
3998
		#可省略參數:
-
 
3999
		#$conf["header"],字串陣列,要傳送的header.
-
 
4000
		$conf["catchWebContent::curlCmd"]["header"]=array("content-type: application/json");
-
 
4001
		#$conf["allowAnySSLcertificate"],字串,是否允許不可信任的SSL憑證,預設為"true".
-
 
4002
		#$conf["allowAnySSLcertificate"]="";
-
 
4003
		#$conf["postVar"],字串陣列,每個要傳送的post變數名稱(陣列的key值)與數值.
-
 
4004
		#$conf["postVar"]=array();
-
 
4005
		#$conf["rawPost"]="字串",要傳送的raw post內容.
-
 
4006
		$conf["catchWebContent::curlCmd"]["rawPost"]=$postJson;
-
 
4007
		#$conf["urlEncode"],字串,post的內容是否要url_encode,"true"代表要,預設為"false"代表不要.
-
 
4008
		#$conf["catchWebContent::curlCmd"]["urlEncode"]="true";
-
 
4009
		#$conf["agent"],字串,user agent的名稱.
-
 
4010
		#$conf["agent"]="";
-
 
4011
		#$conf["cookie"],字串,cookie位置與檔案位置.
-
 
4012
		#$conf["cookie"]="";
-
 
4013
		#$conf["forceNewCookie"],字串,是否要重置cookie,"true"代表要,"false"代表不要,預設為"false".
-
 
4014
		#$conf["forceNewCookie"]="";
-
 
4015
		#$conf["inBg"],字串,"true"代表要在背景中執行;反之則為"false".
-
 
4016
		#$conf["inBg"]="true";
-
 
4017
		#$conf["bgInPorc"],字串,若跟inBg一樣為"true",則會透過proc放在背景執行且回傳proc資訊,以便監控執行狀況.預設為"false",不使用proc.
-
 
4018
		#$conf["bgInProc"]="false";
-
 
4019
		#參考資料:
-
 
4020
		#無.
-
 
4021
		#備註:
-
 
4022
		#無.
-
 
4023
		$curlCmd=catchWebContent::curlCmd($conf["catchWebContent::curlCmd"]);
-
 
4024
		unset($conf["catchWebContent::curlCmd"]);
-
 
4025
 
-
 
4026
		#如果異常
-
 
4027
		if($curlCmd["status"]==="false"){
-
 
4028
 
-
 
4029
			#設置錯誤識別
-
 
4030
			$result["status"]="false";
-
 
4031
 
-
 
4032
			#設置錯誤訊息
-
 
4033
			$result["error"]=$curlCmd;
-
 
4034
 
-
 
4035
			#回傳結果
-
 
4036
			return $result;
-
 
4037
 
-
 
4038
			}#if end
-
 
4039
 
-
 
4040
		#設置curl的詳細資訊
-
 
4041
		$result["curl_verbose_info"]=$curlCmd;
-
 
4042
 
-
 
4043
		/* 範例 response json content
-
 
4044
		
-
 
4045
		*/
-
 
4046
 
-
 
4047
		#驗證結果是否為 json
-
 
4048
		$json_validate=json_validate($curlCmd["fullContent"]);
-
 
4049
 
-
 
4050
		#如果回應不是 json
-
 
4051
		if(!$json_validate){
-
 
4052
		
-
 
4053
			#設置錯誤識別
-
 
4054
			$result["status"]="false";
-
 
4055
 
-
 
4056
			#設置錯誤訊息
-
 
4057
			$result["error"]=$curlCmd;
-
 
4058
 
-
 
4059
			#回傳結果
-
 
4060
			return $result;
-
 
4061
		
-
 
4062
			}#if end
-
 
4063
 
-
 
4064
		#設置json string結果
-
 
4065
		$result["content"]=$curlCmd["fullContent"];
-
 
4066
 
-
 
4067
		#解析json
-
 
4068
		$jsonRes=json_decode($result["content"]);
-
 
4069
		
-
 
4070
		#設置執行正常
-
 
4071
		$result["status"]="true";
-
 
4072
	
-
 
4073
		#回傳結果
-
 
4074
		return $result;
-
 
4075
	
-
 
4076
		}#function verifyDomain end
631
 
4077
 
632
	}#class zerossl end
4078
	}#class zerossl end