Subversion Repositories php-qbpwcf

Rev

Rev 391 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 391 Rev 406
Line 431... Line 431...
431
			$result["fileInfo"]["createdFilePath"]=$validatePath["path"];
431
			$result["fileInfo"]["createdFilePath"]=$validatePath["path"];
432
			$result["fileInfo"]["createdFileName"]=$validatePath["fileName"];
432
			$result["fileInfo"]["createdFileName"]=$validatePath["fileName"];
433
 
433
 
434
			}#else end
434
			}#else end
435
 
435
 
-
 
436
		#debug
-
 
437
		#var_dump(__LINE__,$conf["fileName"]);
-
 
438
 
436
		#設定要寫入或複寫的檔案
439
		#設定要寫入或複寫的檔案
437
		$fileopenResult=fopen($conf["fileName"],$conf["writeMethod"]);
440
		$fileopenResult=fopen($conf["fileName"],$conf["writeMethod"]);
438
 
441
 
439
		#如果 $fileopenResult 等於 FALSE
442
		#如果 $fileopenResult 等於 FALSE
440
		if($fileopenResult==FALSE){
443
		if($fileopenResult===FALSE){
441
 
444
 
442
			#設置錯誤識別
445
			#設置錯誤識別
443
			$result["status"]="false";
446
			$result["status"]="false";
444
 
447
 
445
			#代表打開檔案失敗
448
			#代表打開檔案失敗
Line 10993... Line 10996...
10993
 
10996
 
10994
		#設置預設的暫存目錄
10997
		#設置預設的暫存目錄
10995
		$defaultTmpDir=$output[0];
10998
		$defaultTmpDir=$output[0];
10996
 
10999
 
10997
		#取得暫存檔案的路徑與名稱
11000
		#取得暫存檔案的路徑與名稱
-
 
11001
		#雖然有指定存放的目錄,但系統還是會先嘗試在系統暫存目錄建立,不過最後還會在指定的目錄產生暫存檔案.
10998
		$result["content"]=tempnam($defaultTmpDir,"qbpwcf_tmpfile_");
11002
		$result["content"]=tempnam($defaultTmpDir,"qbpwcf_tmpfile_");
10999
 
11003
 
11000
		#如果產生的暫存檔案位置異常
11004
		#如果產生的暫存檔案位置異常
11001
		#參考資料:
11005
		#參考資料:
11002
		#https://www.php.net/manual/en/function.tempnam.php
11006
		#https://www.php.net/manual/en/function.tempnam.php
Line 11011... Line 11015...
11011
			#回傳結果
11015
			#回傳結果
11012
			return $result;
11016
			return $result;
11013
 
11017
 
11014
			}#if end
11018
			}#if end
11015
 
11019
 
11016
		#函式說明:
11020
		#函式說明:
11017
		#將字串特定關鍵字與其前面的內容剔除
11021
		#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
11018
		#回傳結果:
11022
		#回傳結果:
11019
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11023
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11020
		#$result["error"],錯誤訊息陣列.
11024
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
11021
		#$result["warning"],警告訊息鎮列.
-
 
11022
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
11023
		#$result["function"],當前執行的函數名稱.
11025
		#$result["function"],當前執行的函式名稱.
11024
		#$result["argu"],使用的參數.
11026
		#$result["argu"],所使用的參數.
11025
		#$result["oriStr"],要處理的原始字串內容.
11027
		#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
11026
		#$result["content"],處理好的的字串內容.
11028
		#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
11029
		#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
11027
		#必填參數:
11030
		#必填參數:
11028
		#$conf["stringIn"],字串,要處理的字串.
11031
		#$conf["input"],字串,要檢查的字串.
11029
		$conf["stringPorcess::delStrBeforeKeyWord"]["stringIn"]=$result["content"];
11032
		$conf["search::findSpecifyStrFormat"]["input"]=$result["content"];
11030
		#$conf["keyWord"],字串,特定字串.
11033
		#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
11031
		$conf["stringPorcess::delStrBeforeKeyWord"]["keyWord"]=$defaultTmpDir."/";
11034
		$conf["search::findSpecifyStrFormat"]["format"]="\${path}/tmp/qbpwcf_tmpfile_\${randomStr}";
11032
		#可省略參數:
11035
		#可省略參數:
11033
		#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
11036
		#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
11034
		$conf["stringPorcess::delStrBeforeKeyWord"]["recursive"]="true";
11037
		#$conf["varEqual"]=array(null,"found");
11035
		#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
11038
		#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
11036
		#$conf["lastResult"]=$delStrBeforeKeyWord;
11039
		#$conf["varCon"]=array("no_tail"=>" not");
11037
		#參考資料:
11040
		#參考資料:
11038
		#無.
11041
		#無.
11039
		#備註:
11042
		#備註:
11040
		#無.
11043
		#無.
11041
		$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringPorcess::delStrBeforeKeyWord"]);
11044
		$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
11042
		unset($conf["stringPorcess::delStrBeforeKeyWord"]);
11045
		unset($conf["search::findSpecifyStrFormat"]);
11043
 
-
 
11044
		#如果執行失敗
-
 
11045
		if($delStrBeforeKeyWord["status"]==="false"){
-
 
11046
 
11046
 
-
 
11047
		#如果執行異常
-
 
11048
		if($findSpecifyStrFormat["status"]==="false"){
-
 
11049
		
11047
			#設置執行失敗
11050
			#設置執行失敗
11048
			$result["status"]="false";
11051
			$result["status"]="false";
11049
 
11052
 
11050
			#設置執行錯誤訊息
11053
			#設置執行錯誤訊息
11051
			$result["error"]=$delStrBeforeKeyWord;
11054
			$result["error"]=$findSpecifyStrFormat;
11052
 
11055
 
11053
			#回傳結果
11056
			#回傳結果
11054
			return $result;
11057
			return $result;
11055
 
11058
		
11056
			}#if end
11059
			}#if end
11057
 
11060
			
11058
		#如果應該要存在的路徑關鍵字不在
11061
		#如果執行異常
11059
		if($delStrBeforeKeyWord["founded"]==="false"){
11062
		if($findSpecifyStrFormat["found"]==="false"){
11060
 
11063
		
11061
			#設置執行失敗
11064
			#設置執行失敗
11062
			$result["status"]="false";
11065
			$result["status"]="false";
11063
 
11066
 
11064
			#設置執行錯誤訊息
11067
			#設置執行錯誤訊息
11065
			$result["error"]=$delStrBeforeKeyWord;
11068
			$result["error"]=$findSpecifyStrFormat;
11066
 
11069
 
11067
			#回傳結果
11070
			#回傳結果
11068
			return $result;
11071
			return $result;
11069
 
11072
		
11070
			}#if end
11073
			}#if end
11071
 
11074
 
11072
		#取得檔案名稱
11075
		#取得檔案名稱
11073
		$result["fileName"]=$delStrBeforeKeyWord["content"];
11076
		$result["fileName"]="qbpwcf_tmpfile_".$findSpecifyStrFormat["parsedVar"]["randomStr"][0];
11074
 
11077
 
11075
		#函式說明:
11078
		#函式說明:
11076
		#將字串特定關鍵字與其後面的內容剔除
11079
		#將字串特定關鍵字與其後面的內容剔除
11077
		#回傳結果:
11080
		#回傳結果:
11078
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11081
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.