Rev 6 | Rev 224 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*QBPWCF, Quick Build PHP website Component base on Fedora Linux.Copyright (C) 2015~2024 Min-Jhin,ChenThis file is part of QBPWCF.QBPWCF is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.QBPWCF is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with QBPWCF. If not, see <http://www.gnu.org/licenses/>.*/#使用命名空間qbpwcfnamespace qbpwcf;#初始化輸出$output=array();#取得 lib pathexec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);#如果執行失敗if($status!==0){#debugvar_dump(__LINE__,$output);#結束執行,回傳shell 1.exit(1);}#if end#儲存lib path$folderOfUsrLib=$output[0];#初始化輸出$output=array();#以該檔案的實際位置的 lib path 為 include path 首位exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);set_include_path($output[0].PATH_SEPARATOR.get_include_path());#匯入套件require_once("allInOne.php");#設定要讀取的檔案$file="./assets of stringProcess/https_error_504.log.txt";#函式說明:#依據行號分隔抓取檔案的內容,結果會回傳一個陣列#回傳的變數說明:#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.#$result["error"],錯誤訊息提示.#$result["warning"],警告訊息.#$result["function"],當前執行的函數名稱.#$result["fileContent"],爲檔案的內容陣列.#$result["lineCount"],爲檔案內容總共的行數.#$result["fullContent"],為檔案的完整內容.#$result["base64data"],為檔案的base64內容.#$result["mimeType"],為檔案的mime type.#必填參數:#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.$conf["filePositionAndName"]=$file;#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑$conf["fileArgu"]=__FILE__;#可省略參數:#$conf["web"],是要取得網路上的檔案則為"true";反之則為"false".$conf["web"]="false";#參考資料:#file(),取得檔案內容的行數.#file=>http:#php.net/manual/en/function.file.php#rtrim(),剔除透過file()取得每行內容結尾的換行符號.#filesize=>http://php.net/manual/en/function.filesize.php#參考資料:#無.#備註:#無.$getFileContent=fileAccess::getFileContent($conf);unset($conf);#如果執行失敗if($getFileContent["status"]==="false"){#印出錯誤var_dump($getFileContent);#錯誤離開exit(1);}#if end#初始化結果$result["content"]=array();#針對每個行內容foreach($getFileContent["fileContent"] as $lineNo => $lineContent){#將字串進行解析,取得兩個關鍵字中間的內容.#回傳結果:#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.#$result["function"],當前執行的函式內容.#$result["error"],錯誤訊息陣列.#$result["content"],取得的內容.#$result["oriStr"],原始的內容.#$result["found"],是否有找到符合條件的內容.#必填參數:#$conf["input"],字串,要處理的字串.$conf["input"]=$lineContent;#$conf["startKeyWord"],字串,開頭的關鍵字.$conf["startKeyWord"]="[";#$conf["endKeyWord"],字串,結束的關鍵字.$conf["endKeyWord"]="]";#可省略參數:#無.#參考資料:#無.#備註:#無.$getContentBetweenKeyWord=stringProcess::getContentBetweenKeyWord($conf);unset($conf);#如果執行失敗if($getContentBetweenKeyWord["status"]==="false"){#印出錯誤var_dump($getContentBetweenKeyWord);#錯誤離開exit(1);}#if end#var_dump($getContentBetweenKeyWord);exit;#如果無符合的內容if($getContentBetweenKeyWord["found"]==="false"){#下一行continue;}#if end#取得日期與時間$dateTime=$getContentBetweenKeyWord["content"];#var_dump($getContentBetweenKeyWord);#依照日期與時間記錄 對應的內容$result["content"][$dateTime][]=$lineContent;}#foreach end#針對每個 時間點foreach($result["content"] as $dateTime => $lines){#取得同時間的資料有多少筆$count=count($lines);#如果沒有同時間的資料if($count<2){#下一輪continue;}#if end#印出時間echo "Date Time:".$dateTime." ".$count." requests in same time".PHP_EOL;#針對每行內容foreach($lines as $line){#印出記錄echo $line.PHP_EOL;}#foreach end#結束這個時間的記錄echo PHP_EOL;}#foreach end?>