Verzeichnisstruktur phpBB-3.0.0
- Veröffentlicht
- 12.12.2007
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
cron.php
001 <?php
002 /**
003 *
004 * @package phpBB3
005 * @version $Id$
006 * @copyright (c) 2005 phpBB Group
007 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008 *
009 */
010
011 /**
012 */
013 define('IN_PHPBB', true);
014 define('IN_CRON', true);
015 $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
016 $phpEx = substr(strrchr(__FILE__, '.'), 1);
017 include($phpbb_root_path . 'common.' . $phpEx);
018
019 // Do not update users last page entry
020 $user->session_begin(false);
021 $auth->acl($user->data);
022
023 $cron_type = request_var('cron_type', '');
024 $use_shutdown_function = (@function_exists('register_shutdown_function')) ? true : false;
025
026 // Output transparent gif
027 header('Cache-Control: no-cache');
028 header('Content-type: image/gif');
029 header('Content-length: 43');
030
031 echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
032
033 // test without flush ;)
034 // flush();
035
036 //
037 if (!isset($config['cron_lock']))
038 {
039 set_config('cron_lock', '0', true);
040 }
041
042 // make sure cron doesn't run multiple times in parallel
043 if ($config['cron_lock'])
044 {
045 // if the other process is running more than an hour already we have to assume it
046 // aborted without cleaning the lock
047 $time = explode(' ', $config['cron_lock']);
048 $time = $time[0];
049
050 if ($time + 3600 >= time())
051 {
052 exit;
053 }
054 }
055
056 define('CRON_ID', time() . ' ' . unique_id());
057
058 $sql = 'UPDATE ' . CONFIG_TABLE . "
059 SET config_value = '" . $db->sql_escape(CRON_ID) . "'
060 WHERE config_name = 'cron_lock' AND config_value = '" . $db->sql_escape($config['cron_lock']) . "'";
061 $db->sql_query($sql);
062
063 // another cron process altered the table between script start and UPDATE query so exit
064 if ($db->sql_affectedrows() != 1)
065 {
066 exit;
067 }
068
069 /**
070 * Run cron-like action
071 * Real cron-based layer will be introduced in 3.2
072 */
073 switch ($cron_type)
074 {
075 case 'queue':
076
077 if (time() - $config['queue_interval'] <= $config['last_queue_run'] || !file_exists($phpbb_root_path . 'cache/queue.' . $phpEx))
078 {
079 break;
080 }
081
082 // A user reported using the mail() function while using shutdown does not work. We do not want to risk that.
083 if ($use_shutdown_function && !$config['smtp_delivery'])
084 {
085 $use_shutdown_function = false;
086 }
087
088 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
089 $queue = new queue();
090
091 if ($use_shutdown_function)
092 {
093 register_shutdown_function(array(&$queue, 'process'));
094 }
095 else
096 {
097 $queue->process();
098 }
099
100 break;
101
102 case 'tidy_cache':
103
104 if (time() - $config['cache_gc'] <= $config['cache_last_gc'] || !method_exists($cache, 'tidy'))
105 {
106 break;
107 }
108
109 if ($use_shutdown_function)
110 {
111 register_shutdown_function(array(&$cache, 'tidy'));
112 }
113 else
114 {
115 $cache->tidy();
116 }
117
118 break;
119
120 case 'tidy_search':
121
122 // Select the search method
123 $search_type = basename($config['search_type']);
124
125 if (time() - $config['search_gc'] <= $config['search_last_gc'] || !file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
126 {
127 break;
128 }
129
130 include_once("{$phpbb_root_path}includes/search/$search_type.$phpEx");
131
132 // We do some additional checks in the module to ensure it can actually be utilised
133 $error = false;
134 $search = new $search_type($error);
135
136 if ($error)
137 {
138 break;
139 }
140
141 if ($use_shutdown_function)
142 {
143 register_shutdown_function(array(&$search, 'tidy'));
144 }
145 else
146 {
147 $search->tidy();
148 }
149
150 break;
151
152 case 'tidy_warnings':
153
154 if (time() - $config['warnings_gc'] <= $config['warnings_last_gc'])
155 {
156 break;
157 }
158
159 include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
160
161 if ($use_shutdown_function)
162 {
163 register_shutdown_function('tidy_warnings');
164 }
165 else
166 {
167 tidy_warnings();
168 }
169
170 break;
171
172 case 'tidy_database':
173
174 if (time() - $config['database_gc'] <= $config['database_last_gc'])
175 {
176 break;
177 }
178
179 include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
180
181 if ($use_shutdown_function)
182 {
183 register_shutdown_function('tidy_database');
184 }
185 else
186 {
187 tidy_database();
188 }
189
190 break;
191
192 case 'tidy_sessions':
193
194 if (time() - $config['session_gc'] <= $config['session_last_gc'])
195 {
196 break;
197 }
198
199 if ($use_shutdown_function)
200 {
201 register_shutdown_function(array(&$user, 'session_gc'));
202 }
203 else
204 {
205 $user->session_gc();
206 }
207
208 break;
209
210 case 'prune_forum':
211
212 $forum_id = request_var('f', 0);
213
214 $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
215 FROM ' . FORUMS_TABLE . "
216 WHERE forum_id = $forum_id";
217 $result = $db->sql_query($sql);
218 $row = $db->sql_fetchrow($result);
219 $db->sql_freeresult($result);
220
221 if (!$row)
222 {
223 break;
224 }
225
226 // Do the forum Prune thang
227 if ($row['prune_next'] < time() && $row['enable_prune'])
228 {
229 include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
230
231 if ($row['prune_days'])
232 {
233 if ($use_shutdown_function)
234 {
235 register_shutdown_function('auto_prune', $row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
236 }
237 else
238 {
239 auto_prune($row['forum_id'], 'posted', $row['forum_flags'], $row['prune_days'], $row['prune_freq']);
240 }
241 }
242
243 if ($row['prune_viewed'])
244 {
245 if ($use_shutdown_function)
246 {
247 register_shutdown_function('auto_prune', $row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
248 }
249 else
250 {
251 auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
252 }
253 }
254 }
255
256 break;
257 }
258
259 // Unloading cache and closing db after having done the dirty work.
260 if ($use_shutdown_function)
261 {
262 register_shutdown_function('unlock_cron');
263 register_shutdown_function('garbage_collection');
264 }
265 else
266 {
267 unlock_cron();
268 garbage_collection();
269 }
270
271 exit;
272
273
274 /**
275 * Unlock cron script
276 */
277 function unlock_cron()
278 {
279 global $db;
280
281 $sql = 'UPDATE ' . CONFIG_TABLE . "
282 SET config_value = '0'
283 WHERE config_name = 'cron_lock' AND config_value = '" . $db->sql_escape(CRON_ID) . "'";
284 $db->sql_query($sql);
285 }
286
287 ?>