forked from andreask7/lwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_set_management.php
189 lines (160 loc) · 6.5 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
/**************************************************************
"Learning with Texts" (LWT) is free and unencumbered software
released into the PUBLIC DOMAIN.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a
compiled binary, for any purpose, commercial or non-commercial,
and by any means.
In jurisdictions that recognize copyright laws, the author or
authors of this software dedicate any and all copyright
interest in the software to the public domain. We make this
dedication for the benefit of the public at large and to the
detriment of our heirs and successors. We intend this
dedication to be an overt act of relinquishment in perpetuity
of all present and future rights to this software under
copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
For more information, please refer to [http://unlicense.org/].
***************************************************************/
/**************************************************************
Call: table_set_management.php
Analyse DB tables, and manage Table Sets
***************************************************************/
require_once( 'settings.inc.php' );
require_once( 'connect.inc.php' );
require_once( 'dbutils.inc.php' );
require_once( 'utilities.inc.php' );
$message = "";
if (isset($_REQUEST['delpref'])) {
if($_REQUEST['delpref'] !== '-') {
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_archivedtexts','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_archtexttags','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_languages','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_sentences','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_tags','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_tags2','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_temptextitems','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_tempwords','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_textitems2','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_texts','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_texttags','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_words','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_newsfeeds','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_feedlinks','');
$dummy = runsql('DROP TABLE ' . $_REQUEST['delpref'] . '_wordtags', '');
$dummy = 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,0);
if ($fixed_tbpref) {
?>
<table class="tab1" 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="tab1" 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();
?>