-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
204 lines (168 loc) · 6.09 KB
/
index.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
include 'config.php';
if (!isset($_GET['view'])) {
$ftp_connection = ftp_connect($host,$port);
ftp_login($ftp_connection, $user, $password);
if ($passiveftp == 1) {
ftp_pasv($ftp_connection, true);
}
$logpath = $path;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Log Viewer</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/sticky.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">Log Viewer</a>
</div>
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>Log Viewer</h1>
<div class="alert alert-info"><h4>Status</h4>
<?php
echo "<b>Folder:</b> ".$path."<br>";
if (ftp_chdir($ftp_connection, "".$path."")) {
echo "Successfully accessed log folder.";
} else {
echo "Couldn't access log folder";
}
$contents = ftp_nlist($ftp_connection, ".");
?>
</div>
</div>
<p>
<?php
$arrlength=count($contents);
echo '<table class="table table-condensed">
<thead>
<tr>
<th>File</th>
<th>Last Modified</th>
</tr>
</thead>
<tbody>';
for($x=0;$x<$arrlength;$x++)
{
$newname = str_replace("./","",$contents[$x]);
$lastchanged = ftp_mdtm($ftp_connection, $contents[$x]);
echo '
<tr>
<td><a href="?view='.$newname.'">'.$newname.'</a></td>
<td>'.date('F d Y H:i:s.',$lastchanged).'</td>
</tr>
';
}
echo ' </tbody>
</table>';
ftp_close($ftp_connection);
}
if (isset($_GET['view'])) {
if (strstr($_GET['view'],"../")) {
die("<h1>Forbidden URL: ".$_GET['view'].". <a href='index.php'>Go Back</a></h1>");
}
if (preg_match('%\b(.txt|.log)\b%i', $_GET['view']) == 0) {
die("<h1>Can't view that.<a href='index.php'>Go Back</a></h1>");
}
$file = file_get_contents('ftp://'.$user.':'.$password.'@'.$host.'/'.$path.'/'.$_GET['view'].'');
echo '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Log Viewer</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/sticky.css" rel="stylesheet">
<!-- Just for debugging purposes. Don\'t actually copy this line! -->
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">'.$community.' Log Viewer</a>
</div>
</div>
</div>
<!-- Begin page content -->
<div class="container">
<div class="page-header">
<h1>'.$_GET['view'].'</h1>
<div class="alert alert-info"><h4>Here is your file.</h3>
Filename: <b>'.$_GET['view'].'</b>
<form>
<input type="button" class="btn btn-success" value="Select All" onClick="javascript:this.form.ta.focus();this.form.ta.select();"><br />
<br>
<textarea class="form-control" id="ta" rows="20" cols="200" readonly>
'.$file.'
</textarea>
</form>
';
}
?>
</p>
</div>
</div>
<div id="footer">
<div class="container">
<p class="text-muted"> Version 0.0.2 | No folder support | Created by <a href='http://trurascalz.tk'>Trurascalz</a> Topic: <a href='http://forums.ulyssesmod.net/index.php/topic,7155.0.html'>ULX log viewer</a></p>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="dist/js/bootstrap.min.js"></script>
</body>
</html>