-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclearcache.php
More file actions
297 lines (271 loc) · 12 KB
/
Copy pathclearcache.php
File metadata and controls
297 lines (271 loc) · 12 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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<?php
/************************************************************************/
/* Oscailt */
/* Indepenent Media Centre Content Management System */
/* ==================================================================== */
/* Copyright (c)2003-2005 by Independent Media Centre Ireland */
/* http://www.indymedia.ie */
/* Development List: oscailt@lists.indymedia.org */
/* See contributions.txt for the list of contributors */
/* */
/* 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. http://www.gnu.org/copyleft/gpl.html */
/* */
/* 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. */
/************************************************************************/
$OSCAILT_SCRIPT = "clearcache.php";
require_once("oscailt_init.inc");
require_once("objects/statistics.inc");
addToPageTitle("Clear Cache and Cache Checks");
function writeClearForm()
{
global $query_cache;
if ($query_cache->new_cache == true ) $cache_type_in_use = "New Oscailt 3.3 ";
else $cache_type_in_use = "Standard (Oscailt 3.1) Type ";
?>
<table align=center class=admin>
<TR class=admin>
<th class=admin align=center>Clear Cache</th>
</tr>
<tr class=admin>
<td class=admin><blockquote>The buttons below allow you to clear the various data caches used by oscailt.
While this usally shouldn't be necessary, you may wish to clear caches if errors become cached
or cache files get corrupted.
<BR><BR>
There is also an addition option to check the database cache directory exists and if it does
not to create it. For the new database cache directory structure in Oscailt 3.3 onwards, there
are 5 associated subdirectories that will be checked and created also if that cache mode is in use.
</blockquote>
<BR>
</td>
</tr>
<tr class=admin>
<td class=admin align=center> <BR>
<form action="clearcache.php" method=post>
<input type=hidden name="cachetype" value="SQL">
<input type=submit value="Clear SQL Cache >>">
</form>
<form action="clearcache.php" method=post>
<input type=hidden name="cachetype" value="RSS">
<input type=submit value="Clear RSS Cache >>">
</form>
<form action="clearcache.php" method=post>
<input type=hidden name="cachetype" value="OML">
<input type=submit value="Clear OML Cache >>">
</form>
<form action="clearcache.php" method=post>
<input type=hidden name="cachetype" value="Image">
<input type=submit value="Clear Image Cache >>">
</form>
<form action="clearcache.php" method=post>
<input type=hidden name="cachetype" value="Object">
<input type=submit value="Rebuild Object Caches >>">
</form>
<form action="clearcache.php" method=post>
<input type=hidden name="cachetype" value="Type">
<input type=submit value="Rebuild Type Details Caches >>">
</form>
<br>
<br>
<form action="clearcache.php" method=post>
<input type=hidden name="checkdbcache" value="Type">
<input type=submit value="Check SQL Cache Directories Exists and Create If Required >>">
</form>
<p>
Note: <?=$cache_type_in_use?> SQL Cache Structure in use.
</p>
</td>
</tr>
</table>
<?
}
function writeError($error)
{
?><BR><BR><font class=error><B><?=$error?></B></font><BR><BR><?
}
function writeConfirmClearBox()
{
global $system_config;
// No idea what this variable is so commented it out.
//$time_posted_upper_limit = strtotime($_REQUEST['delete'])+$system_config->timezone_offset;
if ($_REQUEST['cachetype'] == "Object") $requestedAction = "and Rebuild Object ";
else $requestedAction = $_REQUEST['cachetype'];
?>
<table align=center border=0>
<form action="clearcache.php" method=post>
<input type=hidden name="cachetype" value="<?=$_REQUEST['cachetype']?>">
<tr>
<td colspan=2 align=center><img src="graphics/caution.gif" align=middle><BR><BR><B>Are you sure you want to clear the <?=$_REQUEST['cachetype']?> Cache</B><BR><BR></td>
</tr>
<?
if ($_REQUEST['cachetype'] == "SQL") {
if (isset($_REQUEST['old_cache']) && $_REQUEST['old_cache'] == 'true') {
?> <input type=hidden name="old_cache" value="true"> <?
} else {
}
?>
<tr>
<td align=right>Editorial Cache 1</td><td align=center><input type=checkbox name="sql_cache_1" checked></td>
</tr>
<tr>
<td align=right>Stories & Comments Cache 2</td><td align=center><input type=checkbox name="sql_cache_2" checked></td>
</tr>
<tr>
<td align=right>Editorial Locks Cache 3</td><td align=center><input type=checkbox name="sql_cache_3" checked></td>
</tr>
<tr>
<td align=right>Objects Cache 4</td><td align=center><input type=checkbox name="sql_cache_4" checked></td>
</tr>
<tr>
<td align=right>Statistics Cache 5</td><td align=center><input type=checkbox name="sql_cache_5" checked></td>
</tr>
<tr> <td colspan=2> </td> </tr>
<?
if (isset($_REQUEST['old_cache']) && $_REQUEST['old_cache'] == 'true') {
?> <input type=hidden name="old_cache" value="true"> <?
} else {
global $query_cache;
if ($query_cache->new_cache == true) {
?>
<tr><td align=right><small>Delete pre Oscailt 3.3 cache directory only</small></td><td align=center><input type=checkbox name='old_cache' unchecked> </td> </tr>
<tr> <td colspan=2> </td> </tr>
<?
}
}
}
?>
<tr>
<td align=right><input type=submit name=cancel value="<< Cancel"></td>
<td><input type=submit name=confirm value="Clear <?=$requestedAction?> Cache >>"> </td>
</tr>
</form>
</table>
<?
}
ob_start();
if($editor_session->isSessionOpen())
{
writeAdminHeader("viewsitelog.php?log_type=action","View Logs");
if($editor_session->editor->allowedReadAccessTo("clearcache"))
{
if(isset($_REQUEST['cachetype']) && $_REQUEST['cachetype']!=null && isset($_REQUEST['confirm']) )
{
//perform delete
if($editor_session->editor->allowedWriteAccessTo("clearcache"))
{
global $query_cache;
$cleared=true;
if($_REQUEST['cachetype']=="SQL") {
$cache_1 = "";
$cache_2 = "";
$cache_3 = "";
$cache_4 = "";
$cache_5 = "";
if (isset($_REQUEST['sql_cache_1'])) $cache_1 = $_REQUEST['sql_cache_1'];
if (isset($_REQUEST['sql_cache_2'])) $cache_2 = $_REQUEST['sql_cache_2'];
if (isset($_REQUEST['sql_cache_3'])) $cache_3 = $_REQUEST['sql_cache_3'];
if (isset($_REQUEST['sql_cache_4'])) $cache_4 = $_REQUEST['sql_cache_4'];
if (isset($_REQUEST['sql_cache_5'])) $cache_5 = $_REQUEST['sql_cache_5'];
if (isset($_REQUEST['old_cache']) && ($_REQUEST['old_cache']=='true' || $_REQUEST['old_cache']=='on')) {
echo("<p align=center><font class=editornotice><BR><B>Deleting pre Oscailt 3.3 ".$_REQUEST['cachetype']." Cache.</B></font></p>");
$saved_state = $query_cache->new_cache;
$query_cache->new_cache=false;
}
if ($cache_1 == 'on' && $cache_2 == 'on' && $cache_3 == 'on' && $cache_4 == 'on' && $cache_5 == 'on')
$query_cache->clearCache("sql", 0);
else
{
if ($cache_1 == 'on' ) $query_cache->clearCache("sql", 1);
if ($cache_2 == 'on' ) $query_cache->clearCache("sql", 2);
if ($cache_3 == 'on' ) $query_cache->clearCache("sql", 3);
if ($cache_4 == 'on' ) $query_cache->clearCache("sql", 4);
if ($cache_5 == 'on' ) $query_cache->clearCache("sql", 5);
}
// Undocumented code to delete the old cache
if (isset($_REQUEST['old_cache']) && ($_REQUEST['old_cache']=='true' || $_REQUEST['old_cache']=='on')) {
$query_cache->new_cache = $saved_state;
}
}
else if($_REQUEST['cachetype']=="RSS") $query_cache->clearCache("rss");
else if($_REQUEST['cachetype']=="OML") $query_cache->clearCache("oml",0);
else if($_REQUEST['cachetype']=="Image")
{
$imagetool = new ImageTool();
$imagetool->clearImageCache();
logAction("", "all-images", "image", "cache clear");
}
elseif($_REQUEST['cachetype']=="Object")
{
include_once("objects/indyobjects/indydataobjects.inc");
global $system_config, $redirectList;
$redirectList->load();
$obj_set = new indyObjectSet($system_config->xmltypedef_dir, $system_config->object_index_storage);
$x = new indyObjectActionRequest();
$obj_set->load(array("*"),array("*"), $x);
$obj_set->rebuildCaches(array("*"));
$obj_set->writeUserMessageBox();
logAction("", "all-objects", "object", "site-recache");
}
elseif($_REQUEST['cachetype']=="Type")
{
include_once("objects/indyobjects/indydataobjects.inc");
global $system_config;
$obj_set = new indyObjectSet($system_config->xmltypedef_dir, $system_config->object_index_storage);
$x = new indyObjectActionRequest();
$obj_set->load(array("*"),array("*"), $x);
$obj_set->supportedTypes->saveTypeDetailsCache();
$obj_set->writeUserMessageBox();
logAction("", "all-types", "type object", "type-recache");
}
else
{
$cleared=false;
echo("<p align=center><font class=editornotice><BR><B>".$_REQUEST['cachetype']." Cache Type Is Unknown!</B></font></p>");
}
if($cleared) echo("<p align=center><font class=editornotice><BR><B>".$_REQUEST['cachetype']." Cache Cleared!</B></font></p>");
}
else $editor_session->writeNoWritePermissionError();
writeClearForm();
}
else if(isset($_REQUEST['cachetype']) && $_REQUEST['cachetype']!=null && isset($_REQUEST['cancel']) )
{
writeClearForm();
}
else if(isset($_REQUEST['cachetype']) && $_REQUEST['cachetype']!=null)
{
writeConfirmClearBox();
}
else if(isset($_REQUEST['checkdbcache']) && $_REQUEST['checkdbcache'] !=null)
{
// Check it exists
if($editor_session->editor->allowedWriteAccessTo("clearcache"))
{
global $query_cache;
$error_array = $query_cache->checkCacheDirs(true, true);
if (count($error_array) == 0 ) {
echo("<p align=center><font class=editornotice><BR> All SQL Cache Directories exist.</font></p>");
} else {
echo("<p align=center><font class=editornotice><BR>");
foreach ($error_array as $each_msg) {
echo $each_msg."<BR>";
}
echo("</font></p>");
}
}
else $editor_session->writeNoWritePermissionError();
writeClearForm();
}
else
{
writeClearForm();
}
}
else $editor_session->writeNoReadPermissionError();
}
else $editor_session->writeNoSessionError();
require_once("adminfooter.inc");
?>