Subversion Repositories php-qbpwcf

Rev

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

Rev 173 Rev 190
Line 920... Line 920...
920
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
920
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
921
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("alt","style","class","mimeType","compressType","delImg");
921
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("alt","style","class","mimeType","compressType","delImg");
922
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
922
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
923
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string","string","string","string");
923
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string","string","string","string");
924
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
924
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
925
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,"image/*","base64","false");
925
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,null,null,"base64","false");
926
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
926
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
927
		#$conf["arrayCountEqualCheck"][]=array();
927
		#$conf["arrayCountEqualCheck"][]=array();
928
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
928
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
929
		unset($conf["variableCheck::checkArguments"]);
929
		unset($conf["variableCheck::checkArguments"]);
930
		
930
		
Line 953... Line 953...
953
			
953
			
954
			#回傳結果
954
			#回傳結果
955
			return $result;
955
			return $result;
956
			
956
			
957
			}#if end
957
			}#if end
958
				
958
		
-
 
959
		#函式說明:
-
 
960
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
-
 
961
		#回傳的變數說明:
-
 
962
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
-
 
963
		#$result["error"],錯誤訊息提示.
-
 
964
		#$result["warning"],警告訊息.
-
 
965
		#$result["function"],當前執行的函數名稱.
-
 
966
		#$result["fileContent"],爲檔案的內容陣列.
-
 
967
		#$result["lineCount"],爲檔案內容總共的行數.
-
 
968
		#$result["fullContent"],為檔案的完整內容.
-
 
969
		#$result["base64data"],為檔案的base64內容.
-
 
970
		#$result["mimeType"],為檔案的mime type.
-
 
971
		#必填參數:
-
 
972
		#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
-
 
973
		$conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["imgPosition"];
-
 
974
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
975
		$conf["fileAccess::getFileContent"]["fileArgu"]=__FILE__;
959
		#讀取圖片檔案
976
		#可省略參數:
-
 
977
		#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
-
 
978
		#$conf["web"]="true";
-
 
979
		#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
-
 
980
		#$conf["createIfnotExist"]="false";
-
 
981
		#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
-
 
982
		#$conf["autoDeleteSpaceOnEachLineStart"]="false";
-
 
983
		#參考資料:
-
 
984
		#file(),取得檔案內容的行數.
-
 
985
		#file=>http:#php.net/manual/en/function.file.php
-
 
986
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
-
 
987
		#filesize=>http://php.net/manual/en/function.filesize.php
-
 
988
		#參考資料:
-
 
989
		#無.
-
 
990
		#備註:
-
 
991
		#無.
960
		$imgBin=file_get_contents($conf["imgPosition"],"rb");
992
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
-
 
993
		unset($conf["fileAccess::getFileContent"]);
-
 
994
		
-
 
995
		#如果執行異常
-
 
996
		if($getFileContent["status"]=="false"){
961
					
997
			
962
		#壓縮圖片檔案
998
			#設置執行失敗
-
 
999
			$result["status"]="false";
-
 
1000
			
-
 
1001
			#設置錯誤訊息
963
		$base64ImgBin=base64_encode($imgBin);
1002
			$result["error"]=$getFileContent;
-
 
1003
			
-
 
1004
			#回傳結果
-
 
1005
			return $result;
-
 
1006
			
-
 
1007
			}#if end
964
		
1008
		
965
		#如果 $conf["alt"] 有設定
1009
		#如果 $conf["alt"] 有設定
966
		if(isset($conf["alt"])){
1010
		if(isset($conf["alt"])){
967
			
1011
			
968
			#設置 alt 屬性
1012
			#設置 alt 屬性
Line 1050... Line 1094...
1050
				}#foreach end
1094
				}#foreach end
1051
			
1095
			
1052
			#函式說明: 
1096
			#函式說明: 
1053
			#建立給與html標籤使用的style屬性字串.
1097
			#建立給與html標籤使用的style屬性字串.
1054
			#回傳結果:
1098
			#回傳結果:
1055
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.		
1099
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1056
			#$result["function"],當前執行的函數
1100
			#$result["function"],當前執行的函數
1057
			#$result["error"],錯誤訊息陣列
1101
			#$result["error"],錯誤訊息陣列
1058
			#$result["content"],css設定內容
1102
			#$result["content"],css設定內容
1059
			#必填參數:
1103
			#必填參數:
1060
			$conf["css::styleStr"]["styleName"]=$styleN;#為屬性名稱,須為陣列值
1104
			$conf["css::styleStr"]["styleName"]=$styleN;#為屬性名稱,須為陣列值
Line 1079... Line 1123...
1079
			#取得樣式字串
1123
			#取得樣式字串
1080
			$style=$styleStr["content"];
1124
			$style=$styleStr["content"];
1081
			
1125
			
1082
			}#if end
1126
			}#if end
1083
		
1127
		
-
 
1128
		#如果未設置 mime type
-
 
1129
		if(!isset($conf["mimeType"])){
-
 
1130
		
-
 
1131
			#設置自動取得的mime tpye
-
 
1132
			$conf["mimeType"]=$getFileContent["mimeType"];
-
 
1133
		
-
 
1134
			}#if end
-
 
1135
		
1084
		#設置 img 的 src 數值
1136
		#設置 img 的 src 數值
1085
		$result["content"]["imgWithoutImgTag"]="data:".$conf["mimeType"].";".$conf["compressType"].",".$base64ImgBin;
1137
		$result["content"]["imgWithoutImgTag"]="data:".$conf["mimeType"].";".$conf["compressType"].",".$getFileContent["base64data"];
1086
 
1138
 
1087
		#放置圖片的語法
1139
		#放置圖片的語法
1088
		$result["content"]["img"]="<img ".$style." ".$conf["alt"]." ".$conf["class"]." src=\"".$result["content"]["imgWithoutImgTag"]."\" >";
1140
		$result["content"]["img"]="<img ".$style." ".$conf["alt"]." ".$conf["class"]." src=\"".$result["content"]["imgWithoutImgTag"]."\" >";
1089
		
1141
		
1090
		#執行到這邊代表執行正常
1142
		#執行到這邊代表執行正常