| Line 1177... |
Line 1177... |
| 1177 |
#$conf["web"]="true";
|
1177 |
#$conf["web"]="true";
|
| 1178 |
#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
|
1178 |
#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
|
| 1179 |
#$conf["createIfnotExist"]="false";
|
1179 |
#$conf["createIfnotExist"]="false";
|
| 1180 |
#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
|
1180 |
#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
|
| 1181 |
#$conf["autoDeleteSpaceOnEachLineStart"]="false";
|
1181 |
#$conf["autoDeleteSpaceOnEachLineStart"]="false";
|
| - |
|
1182 |
#$conf["disableReturnBase64"],字串,預設為"false"代表要回傳base64結果,反之為"true".
|
| - |
|
1183 |
#$conf["disableReturnBase64"]="false";
|
| 1182 |
#參考資料:
|
1184 |
#參考資料:
|
| 1183 |
#file(),取得檔案內容的行數.
|
1185 |
#file(),取得檔案內容的行數.
|
| 1184 |
#file=>http:#php.net/manual/en/function.file.php
|
1186 |
#file=>http:#php.net/manual/en/function.file.php
|
| 1185 |
#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
|
1187 |
#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
|
| 1186 |
#filesize=>http://php.net/manual/en/function.filesize.php
|
1188 |
#filesize=>http://php.net/manual/en/function.filesize.php
|
| Line 1257... |
Line 1259... |
| 1257 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
1259 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
| 1258 |
#$conf["canNotBeEmpty"]=array();
|
1260 |
#$conf["canNotBeEmpty"]=array();
|
| 1259 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
1261 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
| 1260 |
#$conf["canBeEmpty"]=array();
|
1262 |
#$conf["canBeEmpty"]=array();
|
| 1261 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
1263 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
| 1262 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("createIfnotExist","web","autoDeleteSpaceOnEachLineStart");
|
1264 |
$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("createIfnotExist","web","autoDeleteSpaceOnEachLineStart","disableReturnBase64");
|
| 1263 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
1265 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
| 1264 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("createIfnotExist","web","autoDeleteSpaceOnEachLineStart");
|
1266 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("createIfnotExist","web","autoDeleteSpaceOnEachLineStart","disableReturnBase64");
|
| 1265 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
1267 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 1266 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
|
1268 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string");
|
| 1267 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
1269 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
| 1268 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false","false");
|
1270 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false","false","false");
|
| 1269 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
1271 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
| 1270 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
1272 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
| 1271 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
1273 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
| 1272 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
1274 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
| 1273 |
#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
|
1275 |
#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
|
| Line 1560... |
Line 1562... |
| 1560 |
$result["mimeType"]=$mimeType;
|
1562 |
$result["mimeType"]=$mimeType;
|
| 1561 |
|
1563 |
|
| 1562 |
#取得檔案的內容為字串
|
1564 |
#取得檔案的內容為字串
|
| 1563 |
$result["fullContent"]=file_get_contents($tmpFile);
|
1565 |
$result["fullContent"]=file_get_contents($tmpFile);
|
| 1564 |
|
1566 |
|
| 1565 |
#取得檔案的base64data
|
1567 |
#如果沒有要停用回傳base64結果
|
| 1566 |
$result["base64dataOnly"]=base64_encode($result["fullContent"]);
|
1568 |
if($conf["disableReturnBase64"]==="false"){
|
| 1567 |
|
1569 |
|
| - |
|
1570 |
#取得檔案的base64data
|
| - |
|
1571 |
$result["base64dataOnly"]=base64_encode($result["fullContent"]);
|
| - |
|
1572 |
|
| 1568 |
#取得檔案用 data:mimeType;base64,base64data 表示的字串
|
1573 |
#取得檔案用 data:mimeType;base64,base64data 表示的字串
|
| 1569 |
$result["base64data"]="data:".$result["mimeType"].";base64,".$result["base64dataOnly"];
|
1574 |
$result["base64data"]="data:".$result["mimeType"].";base64,".$result["base64dataOnly"];
|
| - |
|
1575 |
|
| - |
|
1576 |
}#if end
|
| 1570 |
|
1577 |
|
| 1571 |
#移除暫存檔案
|
1578 |
#移除暫存檔案
|
| 1572 |
unlink($tmpFile);
|
1579 |
unlink($tmpFile);
|
| 1573 |
|
1580 |
|
| 1574 |
#將檔案內容的行數放進 $result 陣列變數裏面
|
1581 |
#將檔案內容的行數放進 $result 陣列變數裏面
|
| Line 12010... |
Line 12017... |
| 12010 |
|
12017 |
|
| 12011 |
}#function getFilePart end
|
12018 |
}#function getFilePart end
|
| 12012 |
|
12019 |
|
| 12013 |
/*
|
12020 |
/*
|
| 12014 |
#函式說明:
|
12021 |
#函式說明:
|
| - |
|
12022 |
#一次讀取一行純文字檔案的內容.
|
| - |
|
12023 |
#回傳結果:
|
| - |
|
12024 |
#$result["status"],"true"代表移除成功,"false"代表移除失敗.
|
| - |
|
12025 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
12026 |
#$result["function"],當前執行的函數名稱.
|
| - |
|
12027 |
#$result["cmd"],執行的指令.
|
| - |
|
12028 |
#$result["content"],取得的檔案內容,若沒有內容則為null,反之為字串.
|
| - |
|
12029 |
#$result["length"],取得的內容長度.
|
| - |
|
12030 |
#$result["EOF"],識別是否已經到檔案結尾,"true"代表是,"false"代表不是.
|
| - |
|
12031 |
#$result["nextLine"],整數,下一行的行號,亦即下次來讀取下一行時,lineStart參數要給予的數值.
|
| - |
|
12032 |
#$result["fileSize"],整數,檔案的大小,用於下次來讀取下一行時,preFileSize參數要給予的數值.
|
| - |
|
12033 |
#必填參數:
|
| - |
|
12034 |
#$conf["file"],字串,檔案的路徑與名稱.
|
| - |
|
12035 |
$conf["file"]="";
|
| - |
|
12036 |
#可省略參數:
|
| - |
|
12037 |
#$conf["lineStart"],整數,要從第幾行開始,起始點為1.
|
| - |
|
12038 |
#$conf["lineStart"]=1;
|
| - |
|
12039 |
#$conf["preFileSize"],整數,上次透過本函式取得的fileSize結果,用於確認檔案是否有被rotate過,預設不設置.
|
| - |
|
12040 |
#$conf["preFileSize"]=;
|
| - |
|
12041 |
#可省略參數:
|
| - |
|
12042 |
#無
|
| - |
|
12043 |
#參考資料:
|
| - |
|
12044 |
#無.
|
| - |
|
12045 |
#備註:
|
| - |
|
12046 |
#無
|
| - |
|
12047 |
*/
|
| - |
|
12048 |
public static function getTextFilePart(&$conf){
|
| - |
|
12049 |
|
| - |
|
12050 |
#初始化要回傳的結果
|
| - |
|
12051 |
$result=array();
|
| - |
|
12052 |
|
| - |
|
12053 |
#取得當前執行的函數名稱
|
| - |
|
12054 |
$result["function"]=__FUNCTION__;
|
| - |
|
12055 |
|
| - |
|
12056 |
#如果沒有參數
|
| - |
|
12057 |
if(func_num_args()===0){
|
| - |
|
12058 |
|
| - |
|
12059 |
#設置執行失敗
|
| - |
|
12060 |
$result["status"]="false";
|
| - |
|
12061 |
|
| - |
|
12062 |
#設置執行錯誤訊息
|
| - |
|
12063 |
$result["error"]="函數".$result["function"]."需要參數";
|
| - |
|
12064 |
|
| - |
|
12065 |
#回傳結果
|
| - |
|
12066 |
return $result;
|
| - |
|
12067 |
|
| - |
|
12068 |
}#if end
|
| - |
|
12069 |
|
| - |
|
12070 |
#取得參數
|
| - |
|
12071 |
$result["argu"]=$conf;
|
| - |
|
12072 |
|
| - |
|
12073 |
#如果 $conf 不為陣列
|
| - |
|
12074 |
if(gettype($conf)!=="array"){
|
| - |
|
12075 |
|
| - |
|
12076 |
#設置執行失敗
|
| - |
|
12077 |
$result["status"]="false";
|
| - |
|
12078 |
|
| - |
|
12079 |
#設置執行錯誤訊息
|
| - |
|
12080 |
$result["error"][]="\$conf變數須為陣列形態";
|
| - |
|
12081 |
|
| - |
|
12082 |
#如果傳入的參數為 null
|
| - |
|
12083 |
if(is_null($conf)){
|
| - |
|
12084 |
|
| - |
|
12085 |
#設置執行錯誤訊息
|
| - |
|
12086 |
$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
|
| - |
|
12087 |
|
| - |
|
12088 |
}#if end
|
| - |
|
12089 |
|
| - |
|
12090 |
#回傳結果
|
| - |
|
12091 |
return $result;
|
| - |
|
12092 |
|
| - |
|
12093 |
}#if end
|
| - |
|
12094 |
|
| - |
|
12095 |
#函式說明:
|
| - |
|
12096 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
|
| - |
|
12097 |
#回傳結果:
|
| - |
|
12098 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
12099 |
#$result["error"],執行不正常結束的錯訊息陣列.
|
| - |
|
12100 |
#$result["simpleError"],簡單表示的錯誤訊息.
|
| - |
|
12101 |
#$result["function"],當前執行的函式名稱.
|
| - |
|
12102 |
#$result["argu"],設置給予的參數.
|
| - |
|
12103 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
| - |
|
12104 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
| - |
|
12105 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
| - |
|
12106 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
| - |
|
12107 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
| - |
|
12108 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
| - |
|
12109 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
| - |
|
12110 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
| - |
|
12111 |
#必填參數:
|
| - |
|
12112 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
| - |
|
12113 |
$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
|
| - |
|
12114 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
| - |
|
12115 |
$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
|
| - |
|
12116 |
#可省略參數:
|
| - |
|
12117 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
| - |
|
12118 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file");
|
| - |
|
12119 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
|
| - |
|
12120 |
$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
|
| - |
|
12121 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
| - |
|
12122 |
#$conf["canBeEmptyString"]="false";
|
| - |
|
12123 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
| - |
|
12124 |
$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("lineStart");
|
| - |
|
12125 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
| - |
|
12126 |
#$conf["canBeEmpty"]=array();
|
| - |
|
12127 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
| - |
|
12128 |
#$conf["skipableVariableCanNotBeEmpty"]=array();
|
| - |
|
12129 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
| - |
|
12130 |
$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("lineStart","preFileSize");
|
| - |
|
12131 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| - |
|
12132 |
$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("integer","integer");
|
| - |
|
12133 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
| - |
|
12134 |
$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(1,null);
|
| - |
|
12135 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
| - |
|
12136 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
| - |
|
12137 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
| - |
|
12138 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
| - |
|
12139 |
#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
|
| - |
|
12140 |
#$conf["disallowAllSkipableVarNotExist"]="";
|
| - |
|
12141 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
| - |
|
12142 |
#$conf["arrayCountEqualCheck"][]=array();
|
| - |
|
12143 |
#參考資料:
|
| - |
|
12144 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
| - |
|
12145 |
#備註:
|
| - |
|
12146 |
#無.
|
| - |
|
12147 |
$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
|
| - |
|
12148 |
unset($conf["variableCheck::checkArguments"]);
|
| - |
|
12149 |
|
| - |
|
12150 |
#如果執行異常
|
| - |
|
12151 |
if($checkArguments["status"]==="false"){
|
| - |
|
12152 |
|
| - |
|
12153 |
#設置執行失敗
|
| - |
|
12154 |
$result["status"]="false";
|
| - |
|
12155 |
|
| - |
|
12156 |
#設置執行錯誤訊息
|
| - |
|
12157 |
$result["error"]=$checkArguments;
|
| - |
|
12158 |
|
| - |
|
12159 |
#回傳結果
|
| - |
|
12160 |
return $result;
|
| - |
|
12161 |
|
| - |
|
12162 |
}#if end
|
| - |
|
12163 |
|
| - |
|
12164 |
#如果參數檢查不通過
|
| - |
|
12165 |
if($checkArguments["passed"]==="false"){
|
| - |
|
12166 |
|
| - |
|
12167 |
#設置執行失敗
|
| - |
|
12168 |
$result["status"]="false";
|
| - |
|
12169 |
|
| - |
|
12170 |
#設置執行錯誤訊息
|
| - |
|
12171 |
$result["error"]=$checkArguments;
|
| - |
|
12172 |
|
| - |
|
12173 |
#回傳結果
|
| - |
|
12174 |
return $result;
|
| - |
|
12175 |
|
| - |
|
12176 |
}#if end
|
| - |
|
12177 |
|
| - |
|
12178 |
#取得檔案資訊,包含檔案的大小
|
| - |
|
12179 |
#函式說明:
|
| - |
|
12180 |
#取得節點的資訊.
|
| - |
|
12181 |
#回傳結果:
|
| - |
|
12182 |
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
|
| - |
|
12183 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
12184 |
#$result["function"],函數名稱.
|
| - |
|
12185 |
#$result["content"],檔案資訊陣列.
|
| - |
|
12186 |
#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
|
| - |
|
12187 |
#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
|
| - |
|
12188 |
#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
|
| - |
|
12189 |
#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
|
| - |
|
12190 |
#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
|
| - |
|
12191 |
#$result["content"]["ownerName"],檔案擁有着資訊.
|
| - |
|
12192 |
#$result["content"]["groupName"],檔案所屬擁有着資訊.
|
| - |
|
12193 |
#$result["content"]["size"],檔案大小.
|
| - |
|
12194 |
#$result["content"]["modifyDate"],檔案變更年月日.
|
| - |
|
12195 |
#$result["content"]["modifyTime"],檔案變更時分秒.
|
| - |
|
12196 |
#$result["content"]["modifyTimeFloat"],檔案變更時間秒的float數值.
|
| - |
|
12197 |
#$result["content"]["timezone"],檔案變更時間的時區與UTC的差距.
|
| - |
|
12198 |
#必填參數:
|
| - |
|
12199 |
#$conf["fileArgu"],字串,當前檔案的位置亦即__FILE__的內容.
|
| - |
|
12200 |
$conf["fileAccess::fileInfo"]["fileArgu"]=__FILE__;
|
| - |
|
12201 |
#$conf["file"],字串,要查看擁有者資訊的檔案.
|
| - |
|
12202 |
$conf["fileAccess::fileInfo"]["file"]=$conf["file"];
|
| - |
|
12203 |
#可省略參數:
|
| - |
|
12204 |
#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
|
| - |
|
12205 |
$conf["fileAccess::fileInfo"]["web"]="false";
|
| - |
|
12206 |
#參考資料:
|
| - |
|
12207 |
#fileowner=>http://php.net/manual/en/function.fileowner.php
|
| - |
|
12208 |
#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
|
| - |
|
12209 |
#備註:
|
| - |
|
12210 |
#無.
|
| - |
|
12211 |
$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
|
| - |
|
12212 |
unset($conf["fileAccess::fileInfo"]);
|
| - |
|
12213 |
|
| - |
|
12214 |
#如果執行異常
|
| - |
|
12215 |
if($fileInfo["status"]==="false"){
|
| - |
|
12216 |
|
| - |
|
12217 |
#設置執行失敗
|
| - |
|
12218 |
$result["status"]="false";
|
| - |
|
12219 |
|
| - |
|
12220 |
#設置執行錯誤訊息
|
| - |
|
12221 |
$result["error"]=$fileInfo;
|
| - |
|
12222 |
|
| - |
|
12223 |
#回傳結果
|
| - |
|
12224 |
return $result;
|
| - |
|
12225 |
|
| - |
|
12226 |
}#if end
|
| - |
|
12227 |
|
| - |
|
12228 |
#如果有設置
|
| - |
|
12229 |
if(isset($conf["preFileSize"])){
|
| - |
|
12230 |
|
| - |
|
12231 |
#如果檔案大小變小
|
| - |
|
12232 |
if( $conf["preFileSize"] < (int)$fileInfo["content"]["size"] ){
|
| - |
|
12233 |
|
| - |
|
12234 |
#代表檔案被 rotate 了
|
| - |
|
12235 |
|
| - |
|
12236 |
#設置從頭開始讀取
|
| - |
|
12237 |
$conf["lineStart"]=1;
|
| - |
|
12238 |
|
| - |
|
12239 |
}#if end
|
| - |
|
12240 |
|
| - |
|
12241 |
}#if end
|
| - |
|
12242 |
|
| - |
|
12243 |
#取得檔案大小
|
| - |
|
12244 |
$result["fileSize"]=$fileInfo["content"]["size"];
|
| - |
|
12245 |
|
| - |
|
12246 |
#函式說明:
|
| - |
|
12247 |
#呼叫shell執行系統命令,並取得回傳的內容.
|
| - |
|
12248 |
#回傳結果:
|
| - |
|
12249 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
| - |
|
12250 |
#$result["error"],錯誤訊息陣列.
|
| - |
|
12251 |
#$result["function"],當前執行的函數名稱.
|
| - |
|
12252 |
#$result["argu"],使用的參數.
|
| - |
|
12253 |
#$result["cmd"],執行的指令內容.
|
| - |
|
12254 |
#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
12255 |
#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
|
| - |
|
12256 |
#$result["content"],為執行完後的輸出字串.
|
| - |
|
12257 |
#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
|
| - |
|
12258 |
#$result["running"],是否還在執行.
|
| - |
|
12259 |
#$result["pid"],pid.
|
| - |
|
12260 |
#$result["statusCode"],執行結束後的代碼.
|
| - |
|
12261 |
#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
|
| - |
|
12262 |
#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
|
| - |
|
12263 |
#必填參數:
|
| - |
|
12264 |
#$conf["command"],字串,要執行的指令.
|
| - |
|
12265 |
$conf["fileAccess::callShell"]["command"]="getContentByLineRange.php";
|
| - |
|
12266 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
| - |
|
12267 |
$conf["fileAccess::callShell"]["fileArgu"]=__FILE__;
|
| - |
|
12268 |
#可省略參數:
|
| - |
|
12269 |
#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
|
| - |
|
12270 |
$conf["fileAccess::callShell"]["argu"]=array($conf["lineStart"],$conf["lineStart"]+1,$conf["file"]);
|
| - |
|
12271 |
#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
|
| - |
|
12272 |
#$conf["arguIsAddr"]=array();
|
| - |
|
12273 |
#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
|
| - |
|
12274 |
#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
|
| - |
|
12275 |
#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
|
| - |
|
12276 |
#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
|
| - |
|
12277 |
#$conf["enablePrintDescription"]="true";
|
| - |
|
12278 |
#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
|
| - |
|
12279 |
#$conf["printDescription"]="";
|
| - |
|
12280 |
#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
|
| - |
|
12281 |
$conf["fileAccess::callShell"]["escapeshellarg"]="true";
|
| - |
|
12282 |
#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
|
| - |
|
12283 |
#$conf["thereIsShellVar"]=array();
|
| - |
|
12284 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
| - |
|
12285 |
#$conf["username"]="";
|
| - |
|
12286 |
#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
| - |
|
12287 |
#$conf["password"]="";
|
| - |
|
12288 |
#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
|
| - |
|
12289 |
#$conf["useScript"]="";
|
| - |
|
12290 |
#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
|
| - |
|
12291 |
#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
|
| - |
|
12292 |
#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
|
| - |
|
12293 |
#$conf["inBackGround"]="";
|
| - |
|
12294 |
#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
|
| - |
|
12295 |
#$conf["getErr"]="false";
|
| - |
|
12296 |
#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
|
| - |
|
12297 |
#$conf["doNotRun"]="false";
|
| - |
|
12298 |
#$conf["cmdContainArgu"],字串,cmd參數是否已經含有參數,預設為"false"代表沒有;反之為"true".
|
| - |
|
12299 |
#$conf["cmdContainArgu"]="false";
|
| - |
|
12300 |
#$conf["remoteIp"],字串,遠端ip或domainName,預設不使用,若存在則會透過ssh指令進行連線,然後執行指令.
|
| - |
|
12301 |
#$conf["remoteIp"]="";
|
| - |
|
12302 |
#$conf["remoteUser"],字串,遠端的使用者賬戶,預設不指定,亦即跟為運行該php程式的使用者.
|
| - |
|
12303 |
#$conf["remoteUser"]="";
|
| - |
|
12304 |
#$conf["sshOptions"],陣列,當具備 "remoteIp" 參數時,該參數每個元素為ssh指令的參數.
|
| - |
|
12305 |
#$conf["sshOptions"]=array();
|
| - |
|
12306 |
#參考資料:
|
| - |
|
12307 |
#exec=>http://php.net/manual/en/function.exec.php
|
| - |
|
12308 |
#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
|
| - |
|
12309 |
#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
|
| - |
|
12310 |
#備註:
|
| - |
|
12311 |
#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
|
| - |
|
12312 |
#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
|
| - |
|
12313 |
$callShell=external::callShell($conf["fileAccess::callShell"]);
|
| - |
|
12314 |
unset($conf["fileAccess::callShell"]);
|
| - |
|
12315 |
|
| - |
|
12316 |
#debug
|
| - |
|
12317 |
#var_dump(__LINE__,$callShell);
|
| - |
|
12318 |
|
| - |
|
12319 |
#預設尚未到檔案結尾
|
| - |
|
12320 |
$result["EOF"]="false";
|
| - |
|
12321 |
|
| - |
|
12322 |
#如果沒有內容
|
| - |
|
12323 |
if(empty($callShell["output"])){
|
| - |
|
12324 |
|
| - |
|
12325 |
#代表檔案被 rotate 了
|
| - |
|
12326 |
|
| - |
|
12327 |
#設置到檔案結尾了
|
| - |
|
12328 |
$result["EOF"]="true";
|
| - |
|
12329 |
|
| - |
|
12330 |
#設置下一行的行號為當前行號
|
| - |
|
12331 |
$result["nextLine"]=$conf["lineStart"];
|
| - |
|
12332 |
|
| - |
|
12333 |
#設置沒有內容
|
| - |
|
12334 |
$result["content"]=null;
|
| - |
|
12335 |
|
| - |
|
12336 |
}#if end
|
| - |
|
12337 |
|
| - |
|
12338 |
#反之
|
| - |
|
12339 |
else{
|
| - |
|
12340 |
|
| - |
|
12341 |
#取得行內容
|
| - |
|
12342 |
$result["content"]=$callShell["output"][0];
|
| - |
|
12343 |
|
| - |
|
12344 |
}#else end
|
| - |
|
12345 |
|
| - |
|
12346 |
#如果沒有下一行的內容
|
| - |
|
12347 |
if(!isset($callShell["output"][1])){
|
| - |
|
12348 |
|
| - |
|
12349 |
#設置已經到檔案結尾了
|
| - |
|
12350 |
$result["EOF"]="true";
|
| - |
|
12351 |
|
| - |
|
12352 |
#設置下一行的行號為當前行號
|
| - |
|
12353 |
$result["nextLine"]=$conf["lineStart"];
|
| - |
|
12354 |
|
| - |
|
12355 |
}#if end
|
| - |
|
12356 |
|
| - |
|
12357 |
#反之
|
| - |
|
12358 |
else{
|
| - |
|
12359 |
|
| - |
|
12360 |
#設置下一行的行號
|
| - |
|
12361 |
$result["nextLine"]=$conf["lineStart"]+1;
|
| - |
|
12362 |
|
| - |
|
12363 |
}#else end
|
| - |
|
12364 |
|
| - |
|
12365 |
#儲存執行的指令內容
|
| - |
|
12366 |
$result["cmd"]=$callShell["cmd"];
|
| - |
|
12367 |
|
| - |
|
12368 |
#取得行內容長度
|
| - |
|
12369 |
$result["length"]=strlen($result["content"]);
|
| - |
|
12370 |
|
| - |
|
12371 |
#設置執行正常
|
| - |
|
12372 |
$result["status"]="true";
|
| - |
|
12373 |
|
| - |
|
12374 |
#回傳結果
|
| - |
|
12375 |
return $result;
|
| - |
|
12376 |
|
| - |
|
12377 |
}#function getTextFilePart end
|
| - |
|
12378 |
|
| - |
|
12379 |
/*
|
| - |
|
12380 |
#函式說明:
|
| 12015 |
#取得節點的資訊.
|
12381 |
#取得節點的資訊.
|
| 12016 |
#回傳結果:
|
12382 |
#回傳結果:
|
| 12017 |
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
|
12383 |
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
|
| 12018 |
#$result["error"],錯誤訊息陣列.
|
12384 |
#$result["error"],錯誤訊息陣列.
|
| 12019 |
#$result["function"],函數名稱.
|
12385 |
#$result["function"],函數名稱.
|
| Line 12023... |
Line 12389... |
| 12023 |
#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
|
12389 |
#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
|
| 12024 |
#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
|
12390 |
#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
|
| 12025 |
#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
|
12391 |
#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
|
| 12026 |
#$result["content"]["ownerName"],檔案擁有着資訊.
|
12392 |
#$result["content"]["ownerName"],檔案擁有着資訊.
|
| 12027 |
#$result["content"]["groupName"],檔案所屬擁有着資訊.
|
12393 |
#$result["content"]["groupName"],檔案所屬擁有着資訊.
|
| 12028 |
#$result["content"]["size"],檔案大小.
|
12394 |
#$result["content"]["size"],字串,檔案大小.
|
| 12029 |
#$result["content"]["modifyDate"],檔案變更年月日.
|
12395 |
#$result["content"]["modifyDate"],檔案變更年月日.
|
| 12030 |
#$result["content"]["modifyTime"],檔案變更時分秒.
|
12396 |
#$result["content"]["modifyTime"],檔案變更時分秒.
|
| 12031 |
#$result["content"]["modifyTimeFloat"],檔案變更時間秒的float數值.
|
12397 |
#$result["content"]["modifyTimeFloat"],檔案變更時間秒的float數值.
|
| 12032 |
#$result["content"]["timezone"],檔案變更時間的時區與UTC的差距.
|
12398 |
#$result["content"]["timezone"],檔案變更時間的時區與UTC的差距.
|
| 12033 |
#必填參數:
|
12399 |
#必填參數:
|
| Line 12876... |
Line 13242... |
| 12876 |
$conf["fileArgu"]=__FILE__;
|
13242 |
$conf["fileArgu"]=__FILE__;
|
| 12877 |
#可省略參數:
|
13243 |
#可省略參數:
|
| 12878 |
#$conf["extract"],字串,要解壓縮到那個路徑,預設為當前位置"./".
|
13244 |
#$conf["extract"],字串,要解壓縮到那個路徑,預設為當前位置"./".
|
| 12879 |
#$conf["extract"]="";
|
13245 |
#$conf["extract"]="";
|
| 12880 |
#備註:
|
13246 |
#備註:
|
| 12881 |
#建議加上特定邊碼的支援例如、單
|
13247 |
#建議加上特定邊碼的支援例如,big5、shilf_jis.
|
| 12882 |
*/
|
13248 |
*/
|
| 12883 |
public static function unzip(&$conf=array()){
|
13249 |
public static function unzip(&$conf=array()){
|
| 12884 |
|
13250 |
|
| 12885 |
#初始化要回傳的結果
|
13251 |
#初始化要回傳的結果
|
| 12886 |
$result=array();
|
13252 |
$result=array();
|