forked from andreshg112/phpMyBackupPro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_info.php
executable file
·169 lines (142 loc) · 6.98 KB
/
db_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
167
168
169
<?php
/*
+--------------------------------------------------------------------------+
| phpMyBackupPro |
+--------------------------------------------------------------------------+
| Copyright (c) 2004-2015 by Dirk Randhahn |
| http://www.phpMyBackupPro.net |
| version information can be found in definitions.php. |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program; if not, write to the Free Software |
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.|
+--------------------------------------------------------------------------+
*/
require_once "login.php";
// used variables
if (!isset($_GET['table'])) {
$_GET['table'] = false;
}
// connect to mySQL
$con = PMBP_mysql_connect();
// get start time to calculate duration
if (function_exists("microtime")) {
$microtime = explode(" ", microtime());
$starttime = ($microtime[0] + $microtime[1]);
} else {
$starttime = time();
}
// tables info popUp
if ($_GET['table']) {
// select the db
mysqli_select_db($con, $_GET['table']);
$stati = mysqli_query($con, "show table status");
while ($status = mysqli_fetch_array($stati)) {
$table_names[] = $status['Name'];
$table_rows[] = $status['Rows'];
$size = PMBP_size_type($status['Data_length'] + $status['Index_length']);
$table_size[] = $size['value'] . " " . $size['type'];
}
// get number of fields
if (is_array($table_names)) {
foreach ($table_names as $table) {
mysqli_query($con, "show columns from `" . $table . "`");
$table_fields[] = mysqli_affected_rows($con);
}
}
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html" . ARABIC_HTML . ">
<head>
<title>phpMyBackupPro - " . F_DB_INFO . "</title>
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">
<link rel=\"stylesheet\" href=\"./" . PMBP_STYLESHEET_DIR . $CONF['stylesheet'] . ".css\" type=\"text/css\">\n";
readfile(PMBP_JAVASCRIPTS);
echo "</head>
<body class=\"white\">
<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">\n
<tr><th colspan=\"4\" class=\"active\">\n";
echo PMBP_image_tag("logo.png", "phpMyBackupPro PMBP_WEBSITE", PMBP_WEBSITE);
echo " " . PMBP_VERSION . "</th></tr>\n";
echo "<tr>\n<td colspan=\"4\"><br><div class=\"bold_left\">" . DB_TAB_TITLE . $_GET['table'] . ":</div><br></td>\n</tr>\n";
echo "<tr>\n<th class=\"active\">" . DB_TAB_NAME . "</th>\n<th class=\"active\">" . DB_TAB_COLS . "</th>\n<th class=\"active\">" . DB_NUM_ROWS . "</th>\n<th class=\"active\">" . DB_SIZE . "</th>\n</tr>\n";
for ($i = 0; $i < count($table_names); $i++) {
echo "<tr " . PMBP_change_color("#FFFFFF", "#000000") . ">\n<th class=\"active\">" . $table_names[$i] . "</th>\n<td class=\"list\">" . $table_fields[$i] . "</td>";
echo "\n<td class=\"list\">" . $table_rows[$i] . "</td>\n<td class=\"list\">" . $table_size[$i] . "</td>\n</tr>\n";
}
// show execution duration
if (function_exists("microtime")) {
$microtime = explode(" ", microtime());
$endtime = ($microtime[0] + $microtime[1]);
} else {
$endtime = time();
}
echo "<tr>\n<td colspan=\"4\">\n<br><div class=\"bold_left\">" . F_DURATION . ": " . number_format($endtime - $starttime, 3) . " " . F_SECONDS . "</div>\n</td>\n</tr>\n";
echo "</table>\n</body>\n</html>";
exit;
}
PMBP_print_header(preg_replace("#.*/#", "", $_SERVER['SCRIPT_NAME']));
// if first use or no db-connection possible
if (!$con) {
echo PMBP_addOutput(I_SQL_ERROR, "red");
}
//else
{
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\" width=\"100%\">\n";
// list all databases
$all_dbs = PMBP_get_db_list();
if (count($all_dbs)) {
natsort($all_dbs);
echo "<tr>\n<th class=\"active\">" . DB_NAME . "</th>\n<th class=\"active\">" . DB_NUM_TABLES . "</th>\n<th class=\"active\">" . DB_NUM_ROWS . "</th>\n<th class=\"active\">" . DB_SIZE . "</th>\n</tr>\n";
// print html table
foreach ($all_dbs as $db_name) {
// select the db
mysqli_select_db($con, $db_name);
$num_tables = $num_rows = $data_size = 0;
// get number of rows and size of tables
$stati = mysqli_query($con, "show table status");
while ($status = @mysqli_fetch_array($stati)) {
$data_size += ($status['Data_length'] + $status['Index_length']);
$num_rows += $status['Rows'];
}
$size = PMBP_size_type($data_size);
// get number of tables
$num_tables = mysqli_affected_rows($con);
// first field for the db name
echo "<tr " . PMBP_change_color("#FFFFFF", "#000000") . ">";
echo "\n<th class=\"active\">\n" . $db_name;
if ($num_tables > 0) {
echo "<span class=\"standard\">" . PMBP_pop_up("db_info.php?table=" . $db_name, " [" . DB_TABLES . "]", "view") . "</span>";
} elseif ($num_tables < 0) {
$num_tables = PMBP_addOutput(C_WRONG_DB, "red");
}
echo "\n</th>\n";
echo "<td class=\"list\">" . $num_tables . "</td>\n";
echo "<td class=\"list\">" . $num_rows . "</td>\n";
echo "<td class=\"list\">" . $size['value'] . " " . $size['type'] . "</td>\n";
}
// show execution duration
if (function_exists("microtime")) {
$microtime = explode(" ", microtime());
$endtime = ($microtime[0] + $microtime[1]);
} else {
$endtime = time();
}
echo "<tr>\n<td colspan=\"4\">\n<br><div class=\"bold_left\">" . F_DURATION . ": " . number_format($endtime - $starttime, 3) . " " . F_SECONDS . "</div>\n" . DB_DIFF . "\n</td>\n</tr>\n";
} else {
// if there are no databases
echo "<tr>\n<td><div class=\"bold\">" . DB_NO_DB . ".</div>\n</td>\n</tr>\n";
}
echo "</table>\n";
}
PMBP_print_footer();