-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinput_debug.php
108 lines (82 loc) · 2.91 KB
/
input_debug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
//data : 2015-7-1
//author: zhe13
//email : [email protected]
//name : input all server's data of yesterday into zhegedb
//
//补时间存储数据用
date_default_timezone_set("PRC");
require "connect.php";
//general variable
$port=array(8888,8788,8688,8588,8488,8887);
$date=date("Y/m/d",strtotime("-1 day"));
echo $date."<br/>";
ini_set('memory_limit','-1');
ini_set('max_execution_time','0');
ini_set('max_input_time','0');
set_time_limit(0);
foreach ($port as $p){
switch($p){
case 8888:
$f = "http://121.201.8.151:8888/gm/getActiveLog?path=/server1/".$date.".log";
break;
case 8788:
$f = "http://121.201.8.151:8788/gm/getActiveLog?path=/server2/".$date.".log";
break;
case 8688:
$f = "http://121.201.8.151:8688/gm/getActiveLog?path=/server3/".$date.".log";
break;
case 8588:
$f = "http://121.201.8.151:8588/gm/getActiveLog?path=/server4/".$date.".log";
break;
case 8488:
$f = "http://121.201.8.151:8488/gm/getActiveLog?path=/server5/".$date.".log";
break;
case 8887:
$f = "http://123.57.69.133:8887/gm/getActiveLog?path=/server1/".$date.".log";
break;
default:
echo "The server is not supported now!!!";
}
echo "$f<br/>";
//echo "<br/>$p";
// readLog($f,$p);
}
//$file = "http://121.201.8.151:8788/gm/getActiveLog?path=/server2/".$date.".log";
//read files
function readLog($file,$port){
global $date;
$data = file($file);
//create everyday's table
$sql = "CREATE TABLE IF NOT EXISTS `".$date."-".$port."action` (\n"
. " `id` int(8) unsigned NOT NULL auto_increment,\n"
. " `time` varchar(20) NOT NULL,\n"
. " `name` varchar(20) NOT NULL,\n"
. " `action` varchar(20) NOT NULL, \n"
. " `string` text COLLATE utf8_unicode_ci NOT NULL,\n"
. " PRIMARY KEY (`id`)\n"
. ") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;";
$result = mysql_query($sql) or die(mysql_error());
echo("is writing...");
//insert data
$num = count($data)-1;
for($x = 0;$x<$num;$x++)
{
$line = $data[$x];
list($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l)= explode(' ',$line);
$k=str_replace("'","",$k);
$g=str_replace("'","",$g);//fix name bug
$insert = "insert into `".$date."-".$port."action`(time,name,action,string)values('$b','$k','$f','$g')";
$insertR = mysql_query($insert) or die(mysql_error());
}
echo("...done!</br>");
//separate the strings&echo
$line = $data[count($data)-1];
$text=iconv("UTF-8","GBK",$line);//convert to GBK
list($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l)= explode(' ',$text);
echo "Time: $a,$b;Name: $k;Action: $f;String: $g<br/>";
echo "$port server/'s total number is $num<br/><br/>";
}
//closeDB
//mysql_close($conn);
?>