| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
$user = "admin"; |
|---|
| 22 |
$pw = "eAccelerator"; |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_USER']) || |
|---|
| 27 |
$_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pw) { |
|---|
| 28 |
header('WWW-Authenticate: Basic realm="eAccelerator control panel"'); |
|---|
| 29 |
header('HTTP/1.0 401 Unauthorized'); |
|---|
| 30 |
exit; |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
?> |
|---|
| 35 |
|
|---|
| 36 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|---|
| 37 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
|---|
| 38 |
<head> |
|---|
| 39 |
<title>eAccelerator control panel</title> |
|---|
| 40 |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> |
|---|
| 41 |
<meta http-equiv="Content-Style-Type" content="text/css" /> |
|---|
| 42 |
<meta http-equiv="Content-Language" content="en" /> |
|---|
| 43 |
|
|---|
| 44 |
<style type="text/css" media="all"> |
|---|
| 45 |
body {background-color: #ffffff; color: #000000;} |
|---|
| 46 |
body, td, th, h1, h2 {font-family: sans-serif;} |
|---|
| 47 |
pre {margin: 0px; font-family: monospace;} |
|---|
| 48 |
a:link {color: #000099; text-decoration: none; background-color: #ffffff;} |
|---|
| 49 |
a:hover {text-decoration: underline;} |
|---|
| 50 |
table {border-collapse: collapse; width: 800px;} |
|---|
| 51 |
.center {text-align: center;} |
|---|
| 52 |
.center table { margin-left: auto; margin-right: auto; text-align: left;} |
|---|
| 53 |
.center th { text-align: center !important; } |
|---|
| 54 |
td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;} |
|---|
| 55 |
td.source { background-color: #ffffff; font-size: small;} |
|---|
| 56 |
h1 {font-size: 150%;} |
|---|
| 57 |
h2 {font-size: 125%;} |
|---|
| 58 |
.p {text-align: left;} |
|---|
| 59 |
.e {background-color: #ccccff; font-weight: bold; color: #000000;} |
|---|
| 60 |
.h,th {background-color: #9999cc; font-weight: bold; color: #000000;} |
|---|
| 61 |
.v,td {background-color: #cccccc; color: #000000;} |
|---|
| 62 |
.vr{background-color: #cccccc; text-align: right; color: #000000;} |
|---|
| 63 |
img {float: right; border: 0px;} |
|---|
| 64 |
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;} |
|---|
| 65 |
input {width: 150px} |
|---|
| 66 |
h1 {width: 800px; border: 1px solid #000000; margin-left: auto; margin-right: auto; background-color: #9999cc;} |
|---|
| 67 |
</style> |
|---|
| 68 |
</head> |
|---|
| 69 |
<body class="center"> |
|---|
| 70 |
<h1>eAccelerator disassembler</h1> |
|---|
| 71 |
<?php |
|---|
| 72 |
if (!isset($_GET['file']) || !is_file($_GET['file'])) { |
|---|
| 73 |
die('File argument not given!'); |
|---|
| 74 |
} |
|---|
| 75 |
$file = $_GET['file']; |
|---|
| 76 |
|
|---|
| 77 |
$asm = eaccelerator_dasm_file($file); |
|---|
| 78 |
if ($asm == null) { |
|---|
| 79 |
die('File not found!'); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
$source = explode("\n", htmlentities(file_get_contents($_GET['file']), ENT_QUOTES, 'UTF-8')); |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
if (!isset($_GET['show'])) { |
|---|
| 87 |
$show = ''; |
|---|
| 88 |
|
|---|
| 89 |
$show = $_GET['show']; |
|---|
| 90 |
|
|---|
| 91 |
$show) { |
|---|
| 92 |
'main': |
|---|
| 93 |
print_op_array($asm['op_array']); |
|---|
| 94 |
|
|---|
| 95 |
'functions': |
|---|
| 96 |
is_array($asm['functions'][$_GET['name']])) { |
|---|
| 97 |
print_function($_GET['name'], $asm['functions'][$_GET['name']]); |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
'classes': |
|---|
| 101 |
is_array($asm['classes'][$_GET['name']])) { |
|---|
| 102 |
print_class($_GET['name'], $asm['classes'][$_GET['name']]); |
|---|
| 103 |
|
|---|
| 104 |
$_GET['method']) && is_array($asm['classes'][$_GET['name']][$_GET['method']])) { |
|---|
| 105 |
print_method($_GET['method'], $asm['classes'][$_GET['name']][$_GET['method']]); |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
print_layout(); |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
function convert_string($string, $length) { |
|---|
| 114 |
strlen($string) > $length) { |
|---|
| 115 |
$string = substr($string, 0, $length -4).' ...'; |
|---|
| 116 |
|
|---|
| 117 |
htmlspecialchars($string); |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
function print_op_array($op_array) { ?> |
|---|
| 123 |
<table> |
|---|
| 124 |
<tr> |
|---|
| 125 |
<th>N</th> |
|---|
| 126 |
<th>Line</th> |
|---|
| 127 |
<th>Opcode</th> |
|---|
| 128 |
<th>Extented value</th> |
|---|
| 129 |
<th>Op1</th> |
|---|
| 130 |
<th>Op2</th> |
|---|
| 131 |
<th>Result</th> |
|---|
| 132 |
</tr> |
|---|
| 133 |
<?php |
|---|
| 134 |
$count = count($op_array); |
|---|
| 135 |
$line = 0; |
|---|
| 136 |
global $source; |
|---|
| 137 |
for ($i = 0; $i < $count; ++$i) { |
|---|
| 138 |
|
|---|
| 139 |
code until that line above the opcode */ |
|---|
| 140 |
if ($line < $op_array[$i]['lineno']) |
|---|
| 141 |
{ |
|---|
| 142 |
$print = $op_array[$i]['lineno']; |
|---|
| 143 |
} |
|---|
| 144 |
$code = ''; |
|---|
| 145 |
while($line < $print) { |
|---|
| 146 |
$code .= sprintf("%03d: %s\n", ($line + 1), $source[$line]); |
|---|
| 147 |
++$line; |
|---|
| 148 |
} |
|---|
| 149 |
if ($code != '') { |
|---|
| 150 |
echo "<tr>\n"; |
|---|
| 151 |
|
|---|
| 152 |
echo '<td class="source" colspan="7"><pre>' . $code . "</pre></td>\n"; |
|---|
| 153 |
"</tr>\n"; |
|---|
| 154 |
|
|---|
| 155 |
?> |
|---|
| 156 |
<tr> |
|---|
| 157 |
<td class="e"><?php echo $i; ?></td> |
|---|
| 158 |
<td><nobr><?php echo $op_array[$i]['lineno']; ?></nobr></td> |
|---|
| 159 |
<td><nobr><?php echo $op_array[$i]['opcode']; ?></nobr></td> |
|---|
| 160 |
<td><nobr><?php echo $op_array[$i]['extended_value']; ?></nobr></td> |
|---|
| 161 |
<td><nobr><?php echo convert_string($op_array[$i]['op1'], 50); ?></nobr></td> |
|---|
| 162 |
<td><nobr><?php echo convert_string($op_array[$i]['op2'], 50); ?></nobr></td> |
|---|
| 163 |
<td><nobr><?php echo convert_string($op_array[$i]['result'], 50); ?></nobr></td> |
|---|
| 164 |
</tr> |
|---|
| 165 |
<?php |
|---|
| 166 |
} |
|---|
| 167 |
$count = count($source); |
|---|
| 168 |
if ($line < $count) { |
|---|
| 169 |
$code = ''; |
|---|
| 170 |
while($line < $count) { |
|---|
| 171 |
$code .= sprintf("%03d: %s\n", ($line + 1), $source[$line]); |
|---|
| 172 |
++$line; |
|---|
| 173 |
} |
|---|
| 174 |
if ($code != '') { |
|---|
| 175 |
echo "<tr>\n"; |
|---|
| 176 |
|
|---|
| 177 |
echo '<td class="source" colspan="7"><pre>' . $code . "</pre></td>\n"; |
|---|
| 178 |
"</tr>\n"; |
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
?> |
|---|
| 183 |
</table> |
|---|
| 184 |
<?php |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
function print_function($name, $op_array) { |
|---|
| 190 |
"<h2>Function: $name</h2>"; |
|---|
| 191 |
print_op_array($op_array); |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
function print_method($name, $op_array) { |
|---|
| 197 |
"<h2>Method: $name</h2>"; |
|---|
| 198 |
print_op_array($op_array); |
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
function print_layout() { |
|---|
| 204 |
$asm, $file; |
|---|
| 205 |
"<h2>Script layout</h2>\n"; |
|---|
| 206 |
"<div style=\"text-align: left; width: 800px\">\n"; |
|---|
| 207 |
"<ul>\n"; |
|---|
| 208 |
$asm['op_array'])) { |
|---|
| 209 |
"<li><a href=\"?file=$file&show=main\">Global file op_array</a></li>"; |
|---|
| 210 |
|
|---|
| 211 |
$asm['functions']) && count($asm['functions']) > 0) { |
|---|
| 212 |
"<li>Functions<ul>\n"; |
|---|
| 213 |
$asm['functions'] as $name => $data) { |
|---|
| 214 |
"<li><a href=\"?file=$file&show=functions&name=$name\">$name</a></li>"; |
|---|
| 215 |
|
|---|
| 216 |
"</ul></li>\n"; |
|---|
| 217 |
|
|---|
| 218 |
$asm['classes']) && count($asm['classes']) > 0) { |
|---|
| 219 |
"<li>Classes<ul>\n"; |
|---|
| 220 |
$asm['classes'] as $name => $data) { |
|---|
| 221 |
"<li><a href=\"?file=$file&show=classes&name=$name\">$name</a></li>"; |
|---|
| 222 |
|
|---|
| 223 |
"</ul></li>\n"; |
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
"</ul>\n"; |
|---|
| 227 |
"</div>\n"; |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
function print_class($name, $class) { |
|---|
| 233 |
$file; |
|---|
| 234 |
"<h2>Class $name</h2>"; |
|---|
| 235 |
"<div style=\"text-align: left; width: 800px\"><ul>\n"; |
|---|
| 236 |
$class as $method => $data) { |
|---|
| 237 |
"<li><a href=\"?file=$file&show=classes&name=$name&method=$method\">$method</a></li>\n"; |
|---|
| 238 |
|
|---|
| 239 |
"</ul></div>"; |
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
?> |
|---|
| 243 |
</body> |
|---|
| 244 |
</html> |
|---|
| 245 |
|
|---|
| 246 |
<?php |
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
?> |
|---|
| 258 |
|
|---|