Repository navigation
Expand file tree
/
Copy pathserver_data.php
More file actions
117 lines (111 loc) · 3.85 KB
/
Copy pathserver_data.php
File metadata and controls
117 lines (111 loc) · 3.85 KB
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
<?php
/**
* \file
* \brief Useful software data.
*
* Call: server_data.php
*
* @package Lwt
* @author HugoFara <hugo.farajallah@protonmail.com>
* @license Unlicense <http://unlicense.org/>
* @link https://hugofara.github.io/lwt/docs/html/index_8php.html
* @since 2.7.0
*/
require_once 'inc/session_utility.php';
/**
* Return a lot of different server state variables.
*
* @return array{"db_prefix": string, "db_size": float, "server_soft": string[], "apache": string, "php": string, "mysql": string}
* Table prefix, database size, server software, apache version, PHP version, MySQL
* version
*
* @global string $tbpref Database table prefix
* @global string $dbname Database name
*
* @psalm-return array{
* "db_prefix": string, "db_size": float, "server_soft": non-empty-list<string>,
* "apache": string, "php": false|string, "mysql": string
* }
*/
function get_server_data_table(): array
{
global $tbpref, $dbname;
$dbaccess_format = convert_string_to_sqlsyntax($dbname);
$data_table = array();
$data_table["db_name"] = $dbname;
$data_table["db_prefix"] = $tbpref;
$data_table["db_size"] = (float)get_first_value(
"SELECT ROUND(SUM(data_length+index_length)/1024/1024, 1) AS value
FROM information_schema.TABLES
WHERE table_schema = $dbaccess_format
AND table_name IN (
'{$tbpref}archivedtexts', '{$tbpref}archtexttags', '{$tbpref}feedlinks', '{$tbpref}languages',
'{$tbpref}newsfeeds', '{$tbpref}sentences', '{$tbpref}settings', '{$tbpref}tags', '{$tbpref}tags2',
'{$tbpref}textitems2', '{$tbpref}texts', '{$tbpref}texttags', '{$tbpref}words', '{$tbpref}wordtags'
)"
);
if (!isset($data_table["db_size"])) {
$data_table["db_size"] = 0.0;
}
$data_table["server_soft"] = explode(' ', $_SERVER['SERVER_SOFTWARE']);
$data_table["apache"] = "Apache/?";
if (substr($data_table["server_soft"][0], 0, 7) == "Apache/") {
$data_table["apache"] = $data_table["server_soft"][0];
}
$data_table["php"] = phpversion();
$data_table["mysql"] = (string)get_first_value("SELECT VERSION() as value");
return $data_table;
}
$data = get_server_data_table();
pagestart("Server Data", true);
?>
<table>
<thead>
<tr>
<th>Data</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>LWT version</td>
<td><?php echo get_version_number(); ?></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/Database" name</td>
<td><i><?php echo $data["db_name"]; ?></i></td>
</tr>
<tr>
<td>Database prefix (surrounded by "")</td>
<td>"<?php echo $data["db_prefix"]; ?>"</td>
</tr>
<tr>
<td>Database Location</td>
<td><i><?php echo $data["server_soft"][0]; ?></i></td>
</tr>
<tr>
<td>Database Size</td>
<td><?php echo $data["db_size"]; ?> MB</td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/Web_server" Server</a></td>
<td><i><?php echo $_SERVER['HTTP_HOST']; ?></i></td>
</tr>
<tr>
<td>Server Software</td>
<td>
<a href="https://en.wikipedia.org/wiki/Apache_HTTP_Server">
<?php echo $data["apache"]; ?>
</a>
</td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/PHP" Version</td>
<td><?php echo $data["php"];; ?></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/MySQL" Version</td>
<td><?php echo $data["mysql"];; ?></td>
</tr>
</tbody>
</table>