Subversion Repositories php-qbpwcf

Rev

Rev 81 | Rev 224 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 liveuser 1
<?php
2
 
3
/*
4
 
5
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
7
 
8
    This file is part of QBPWCF.
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
 
25
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
28
#初始化輸出
29
$output=array();
30
 
31
#取得 lib path
97 liveuser 32
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../../../usr/bin/libexec/folderOfUsrLib.php"),$output,$status);
6 liveuser 33
 
34
#如果執行失敗
35
if($status!==0){
36
 
37
	#debug
38
	var_dump(__LINE__,$output);
39
 
40
	#結束執行,回傳shell 1.
41
	exit(1);
42
 
43
	}#if end
44
 
45
#儲存lib path
46
$folderOfUsrLib=$output[0];
47
 
48
#初始化輸出
49
$output=array();
50
 
51
#以該檔案的實際位置的 lib path 為 include path 首位
97 liveuser 52
exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../../usr/".$folderOfUsrLib."/qbpwcf;pwd;",$output,$status);
6 liveuser 53
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
54
 
55
#匯入套件
56
require_once("allInOne.php");
57
 
58
#設定要讀取的檔案
59
$file="./assets of stringProcess/https_error_504.log.txt";
60
 
61
#函式說明:
62
#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
63
#回傳的變數說明:
64
#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
65
#$result["error"],錯誤訊息提示.
66
#$result["warning"],警告訊息.
67
#$result["function"],當前執行的函數名稱.
68
#$result["fileContent"],爲檔案的內容陣列.
69
#$result["lineCount"],爲檔案內容總共的行數.
70
#$result["fullContent"],為檔案的完整內容.
71
#$result["base64data"],為檔案的base64內容.
72
#$result["mimeType"],為檔案的mime type.
73
#必填參數:
74
#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
75
$conf["filePositionAndName"]=$file;
76
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
77
$conf["fileArgu"]=__FILE__;
78
#可省略參數:
79
#$conf["web"],是要取得網路上的檔案則為"true";反之則為"false".
80
$conf["web"]="false";
81
#參考資料:
82
#file(),取得檔案內容的行數.
83
#file=>http:#php.net/manual/en/function.file.php
84
#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
85
#filesize=>http://php.net/manual/en/function.filesize.php
86
#參考資料:
87
#無.
88
#備註:
89
#無.
90
$getFileContent=fileAccess::getFileContent($conf);
91
unset($conf);
92
 
93
#如果執行失敗
94
if($getFileContent["status"]==="false")
95
{
96
 
97
	#印出錯誤
98
	var_dump($getFileContent);
99
 
100
	#錯誤離開
101
	exit(1);
102
 
103
}#if end
104
 
105
#初始化結果
106
$result["content"]=array();
107
 
108
#針對每個行內容
109
foreach($getFileContent["fileContent"] as $lineNo => $lineContent)
110
{
111
 
112
	#將字串進行解析,取得兩個關鍵字中間的內容.
113
	#回傳結果:
114
	#$result["status"],執行正常與否,"false"代表不正常,"true"代表正常.
115
	#$result["function"],當前執行的函式內容.
116
	#$result["error"],錯誤訊息陣列.
117
	#$result["content"],取得的內容.
118
	#$result["oriStr"],原始的內容.
119
	#$result["found"],是否有找到符合條件的內容.
120
	#必填參數:
121
	#$conf["input"],字串,要處理的字串.
122
	$conf["input"]=$lineContent;
123
	#$conf["startKeyWord"],字串,開頭的關鍵字.
124
	$conf["startKeyWord"]="[";
125
	#$conf["endKeyWord"],字串,結束的關鍵字.
126
	$conf["endKeyWord"]="]";
127
	#可省略參數:
128
	#無.
129
	#參考資料:
130
	#無.
131
	#備註:
132
	#無.
133
	$getContentBetweenKeyWord=stringProcess::getContentBetweenKeyWord($conf);
134
	unset($conf);
135
 
136
	#如果執行失敗
137
	if($getContentBetweenKeyWord["status"]==="false")
138
	{
139
 
140
		#印出錯誤
141
		var_dump($getContentBetweenKeyWord);
142
 
143
		#錯誤離開
144
		exit(1);
145
 
146
	}#if end
147
 
148
	#var_dump($getContentBetweenKeyWord);exit;
149
 
150
	#如果無符合的內容
151
	if($getContentBetweenKeyWord["found"]==="false")
152
	{
153
 
154
		#下一行
155
		continue;
156
 
157
	}#if end
158
 
159
	#取得日期與時間
160
	$dateTime=$getContentBetweenKeyWord["content"];
161
 
162
	#var_dump($getContentBetweenKeyWord);
163
 
164
	#依照日期與時間記錄 對應的內容
165
	$result["content"][$dateTime][]=$lineContent;
166
 
167
}#foreach end
168
 
169
#針對每個 時間點
170
foreach($result["content"] as $dateTime => $lines)
171
{
172
 
173
	#取得同時間的資料有多少筆
174
	$count=count($lines);
175
 
176
	#如果沒有同時間的資料
177
	if($count<2)
178
	{
179
 
180
		#下一輪
181
		continue;
182
 
183
	}#if end
184
 
185
	#印出時間
186
	echo "Date Time:".$dateTime." ".$count." requests in same time".PHP_EOL;
187
 
188
	#針對每行內容
189
	foreach($lines as $line)
190
	{
191
 
192
		#印出記錄
193
		echo $line.PHP_EOL;
194
 
195
	}#foreach end
196
 
197
	#結束這個時間的記錄
198
	echo PHP_EOL;
199
 
200
}#foreach end
201
 
202
?>