forked from X-Genesis-Qhulut/alpha
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwow_alpha_tables.php
126 lines (97 loc) · 3.1 KB
/
wow_alpha_tables.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
<?php
/*
Author: X'Genesis Qhulut <XGenesis-Qhulut@protonmail.com>
Date: August 2022
See LICENSE for license details.
*/
// TABLES
function tableDetails ($info)
{
bottomSection ($info, function ($info)
{
global $database, $table;
if ($database == LIVE_DBC_DBNAME)
$realDatabase = DBC_DBNAME;
elseif ($database == LIVE_WORLD_DBNAME)
$realDatabase = WORLD_DBNAME;
else
Problem ("Invalid database specified, must be " . LIVE_DBC_DBNAME . " or " . LIVE_WORLD_DBNAME);
$td = function ($s) use (&$row) { tdx ($row [$s]); };
$tdr = function ($s) use (&$row) { tdx ($row [$s], 'tdr'); };
$row = dbQueryOne ("SELECT COUNT(*) AS count FROM `" .
($database == 'alpha_dbc' ? DBC_DBNAME : WORLD_DBNAME) . '`.' . $table);
if (!$row)
{
ShowWarning ("Table $table is not on the database");
return;
} // end of not finding it
boxTitle ($row ['count'] . " rows in this table. Schema below.");
$results = dbQueryParam ("SELECT * FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?",
array ('ss', &$realDatabase, &$table));
echo "<table class='table-rows'>\n";
echo "<thead>\n";
echo "<tr>\n";
th ('Name');
th ('Type');
th ('Null');
th ('Key');
th ('Default');
echo "</tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
foreach ($results as $row)
{
echo "<tr>\n";
$td ('COLUMN_NAME');
$td ('COLUMN_TYPE');
$td ('IS_NULLABLE');
$td ('COLUMN_KEY');
$td ('COLUMN_DEFAULT');
echo "</tr>\n";
}
echo "</tbody>\n";
echo "</table>\n";
});
} // end of tableDetails
function showOneTable ()
{
global $database, $table;
setTitle ("Database table: $table");
pageContent (false, 'Table', $database . '.' . $table, 'tables', 'tableDetails', $database);
} // end of showOneTable
function showTablesHelper ($tableName, $headingName)
{
$results = dbQueryParam ("SELECT TABLE_NAME AS tableName FROM information_schema.TABLES
WHERE TABLE_SCHEMA = ?",
array ('s', &$tableName));
echo "<table class='table-rows'>\n";
echo "<thead>\n";
echo "<tr>\n";
th ('Tables in ' . fixHTML ($headingName));
echo "</tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
foreach ($results as $row)
{
echo "<tr>\n";
$name = $row ['tableName'];
tdh ("<a href='?action=show_table&table=$name&database=$headingName'>$name</a>");
echo "</tr>\n";
}
echo "</table>\n";
} // end of showTablesHelper
function showAllTables ($info)
{
setTitle ("Database tables");
bottomSectionMany ($info, function ($info)
{
showTablesHelper (DBC_DBNAME, LIVE_DBC_DBNAME);
showTablesHelper (WORLD_DBNAME, LIVE_WORLD_DBNAME);
});
} // end of showAllTables
function showTables ()
{
pageContent (false, 'Tables', 'Database tables', 'tables', 'showAllTables', '');
} // end of showTables
?>