forked from chaosarium/lwt
-
Notifications
You must be signed in to change notification settings - Fork 20
/
table_set_management.php
168 lines (144 loc) · 5.23 KB
/
table_set_management.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
<?php
/**
* Analyse DB tables, and manage Table Sets
*
* Call: table_set_management.php
*
* PHP version 8.1
*
* @category User_Interface
*/
require_once 'inc/session_utility.php';
$message = "";
if (isset($_REQUEST['delpref'])) {
if($_REQUEST['delpref'] !== '-') {
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_archivedtexts', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_archtexttags', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_languages', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_sentences', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_tags', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_tags2', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_temptextitems', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_tempwords', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_textitems2', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_texts', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_texttags', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_words', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_newsfeeds', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_feedlinks', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_wordtags', '');
runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_settings', '');
$message = 'Table Set "' . $_REQUEST['delpref'] . '" deleted';
if ($_REQUEST['delpref'] == substr($tbpref, 0, -1)) {
$tbpref = "";
LWTTableSet("current_table_prefix", $tbpref);
}
}
}
elseif (isset($_REQUEST['newpref'])) {
if (in_array($_REQUEST['newpref'], getprefixes())) {
$message = 'Table Set "' . $_REQUEST['newpref'] . '" already exists';
} else {
$tbpref = $_REQUEST['newpref'];
LWTTableSet("current_table_prefix", $tbpref);
header("Location: index.php");
exit();
}
}
elseif (isset($_REQUEST['prefix'])) {
if($_REQUEST['prefix'] !== '-') {
$tbpref = $_REQUEST['prefix'];
LWTTableSet("current_table_prefix", $tbpref);
header("Location: index.php");
exit();
}
}
pagestart('Select, Create or Delete a Table Set', false);
echo error_message_with_hide($message, false);
if ($fixed_tbpref) {
?>
<table class="tab2" cellspacing="0" cellpadding="5">
<tr>
<td class="td1">
<p>These features are not currently not available.<br /><br />
Reason:<br /><b>$tbpref</b> is set to a fixed value in <i>connect.inc.php</i>.<br />
Please remove the definition<br /><span class="red"><b>$tbpref = '<?php echo substr($tbpref, 0, -1); ?>';</b></span></br />
in <i>connect.inc.php</i> to make these features available.<br />
Then try again.</p>
<p class="right">
<br />
<input type="button" value="<< Back" onclick="history.back();" />
</p>
</td>
</tr>
</table>
<?php
} else {
$prefix = getprefixes();
?>
<table class="tab2" style="width: auto;" cellspacing="0" cellpadding="5">
<tr>
<th class="th1 center">Select</th>
<td class="td1">
<form name="f1" class="inline" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Table Set: <select name="prefix">
<option value="-" selected="selected">[Choose...]</option>
<option value="">Default Table Set</option>
<?php
foreach ($prefix as $value) {
?>
<option value="<?php echo tohtml($value); ?>"><?php echo tohtml($value); ?></option>
<?php
}
?>
</select>
</p>
<p class="right"> <br /><input type="submit" name="op" value="Start LWT with selected Table Set" />
</p>
</form>
</td>
</tr>
<tr>
<th class="th1 center">Create</th>
<td class="td1">
<form name="f2" class="inline" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="return check_table_prefix(document.f2.newpref.value);">
<p>New Table Set: <input type="text" name="newpref" value="" maxlength="20" size="20" />
</p>
<p class="right"> <br /><input type="submit" name="op" value="Create New Table Set & Start LWT" />
</p>
</form>
</td>
</tr>
<tr>
<th class="th1 center">Delete</th>
<td class="td1">
<form name="f3" class="inline" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onsubmit="if (document.f3.delpref.selectedIndex > 0) { return confirm('\n*** DELETING TABLE SET: ' + document.f3.delpref.options[document.f3.delpref.selectedIndex].text + ' ***\n\n*** ALL DATA IN THIS TABLE SET WILL BE LOST! ***\n\n*** ARE YOU SURE ?? ***'); } else { return true; }">
<p>Table Set: <select name="delpref">
<option value="-" selected="selected">[Choose...]</option>
<?php
foreach ($prefix as $value) {
if ($value != '') {
?>
<option value="<?php echo tohtml($value); ?>"><?php echo tohtml($value); ?></option>
<?php
}
}
?>
</select>
<br />
(You cannot delete the Default Table Set.)
</p>
<p class="right"> <br /><span class="red2">YOU MAY LOSE DATA - BE CAREFUL: </span><input type="submit" name="op" value="DELETE Table Set" />
</p>
</form>
</td>
</tr>
<tr>
<td class="td1 right" colspan="2">
<input type="button" value="<< Back" onclick="location.href='index.php';" /></td>
</tr>
</table>
<?php
}
pageend();
?>