This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
/
server_info.php
166 lines (134 loc) · 4.98 KB
/
server_info.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
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
$action = $_GET['action'] ?? '';
switch ($action) {
case 'export':
$info = tep_get_system_information();
break;
case 'submit':
$target_host = 'usage.oscommerce.com';
$target_path = '/submit.php';
$encoded = base64_encode(serialize(tep_get_system_information()));
$response = false;
if (function_exists('curl_init')) {
$data = ['info' => $encoded];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://' . $target_host . $target_path);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = trim(curl_exec($ch));
curl_close($ch);
} else {
if ($fp = @fsockopen($target_host, 80, $errno, $errstr, 30)) {
$data = 'info=' . $encoded;
fputs($fp, "POST " . $target_path . " HTTP/1.1\r\n");
fputs($fp, "Host: " . $target_host . "\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data."\r\n\r\n");
$response = '';
while (!feof($fp)) {
$response .= fgets($fp, 4096);
}
fclose($fp);
$response = trim(substr($response, strrpos($response, "\r\n\r\n")));
}
}
if ($response != 'OK') {
$messageStack->add_session(ERROR_INFO_SUBMIT, 'error');
} else {
$messageStack->add_session(SUCCESS_INFO_SUBMIT, 'success');
}
tep_redirect(tep_href_link('server_info.php'));
break;
case 'save':
$info = tep_get_system_information();
$info_file = 'server_info-' . date('YmdHis') . '.txt';
header('Content-type: text/plain');
header('Content-disposition: attachment; filename=' . $info_file);
echo tep_format_system_info_array($info);
exit;
break;
default:
$info = tep_get_system_information();
break;
}
require('includes/template_top.php');
?>
<h1 class="display-4 mb-2"><?php echo HEADING_TITLE; ?></h1>
<?php
if ($action == 'export') {
?>
<div class="alert alert-info">
<?php echo TEXT_EXPORT_INTRO; ?>
</div>
<?php
echo tep_draw_textarea_field('server configuration', 'soft', '100', '15', tep_format_system_info_array($info));
echo tep_draw_bootstrap_button(BUTTON_SAVE_TO_DISK, 'fas fa-save', tep_href_link('server_info.php', 'action=save'), 'primary', null, 'btn-success btn-block btn-lg my-2');
echo tep_draw_bootstrap_button(BUTTON_SEND_TO_OSCOMMERCE, 'fas fa-file-upload', tep_href_link('server_info.php', 'action=submit'), 'primary', null, 'btn-light');
} else {
$server = parse_url(HTTP_SERVER);
?>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th><?php echo TABLE_HEADING_KEY; ?></th>
<th><?php echo TABLE_HEADING_VALUE; ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo TITLE_SERVER_HOST; ?></td>
<td><?php echo $server['host'] . ' (' . gethostbyname($server['host']) . ')'; ?></td>
</tr>
<tr>
<td><?php echo TITLE_DATABASE_HOST; ?></td>
<td><?php echo DB_SERVER . ' (' . gethostbyname(DB_SERVER) . ')'; ?></td>
</tr>
<tr>
<td><?php echo TITLE_SERVER_OS; ?></td>
<td><?php echo $info['system']['os'] . ' ' . $info['system']['kernel']; ?></td>
</tr>
<tr>
<td><?php echo TITLE_DATABASE; ?></td>
<td><?php echo 'MySQL ' . $info['mysql']['version']; ?></td>
</tr>
<tr>
<td><?php echo TITLE_SERVER_DATE; ?></td>
<td><?php echo $info['system']['date']; ?></td>
</tr>
<tr>
<td><?php echo TITLE_DATABASE_DATE; ?></td>
<td><?php echo $info['mysql']['date']; ?></td>
</tr>
<tr>
<td><?php echo TITLE_SERVER_UP_TIME; ?></td>
<td><?php echo $info['system']['uptime']; ?></td>
</tr>
<tr>
<td><?php echo TITLE_HTTP_SERVER; ?></td>
<td><?php echo $info['system']['http_server']; ?></td>
</tr>
<tr>
<td><?php echo TITLE_PHP_VERSION; ?></td>
<td><?php echo $info['php']['version'] . ' (' . TITLE_ZEND_VERSION . ' ' . $info['php']['zend'] . ')'; ?></td>
</tr>
</tbody>
</table>
</div>
<?php
echo tep_draw_bootstrap_button(IMAGE_EXPORT, 'fas fa-save', tep_href_link('server_info.php', 'action=export'), null, null, 'btn-danger');
}
require('includes/template_bottom.php');
require('includes/application_bottom.php');
?>