271 * @param string $title The title of the message |
271 * @param string $title The title of the message |
272 * @param string $message A short message to show to the user |
272 * @param string $message A short message to show to the user |
273 * @param string $timeout Timeout, in seconds, to delay the redirect. Defaults to 3. |
273 * @param string $timeout Timeout, in seconds, to delay the redirect. Defaults to 3. |
274 */ |
274 */ |
275 |
275 |
276 function redirect($url, $title = 'Redirecting...', $message = 'Please wait while you are redirected.', $timeout = 3) |
276 function redirect($url, $title = 'etc_redirect_title', $message = 'etc_redirect_body', $timeout = 3) |
277 { |
277 { |
278 global $db, $session, $paths, $template, $plugins; // Common objects |
278 global $db, $session, $paths, $template, $plugins; // Common objects |
|
279 global $lang; |
279 |
280 |
280 if ( $timeout == 0 ) |
281 if ( $timeout == 0 ) |
281 { |
282 { |
282 header('Location: ' . $url); |
283 header('Location: ' . $url); |
283 header('HTTP/1.1 307 Temporary Redirect'); |
284 header('HTTP/1.1 307 Temporary Redirect'); |
284 } |
285 } |
|
286 |
|
287 $title = $lang->get($title); |
|
288 $message = $lang->get($message); |
285 |
289 |
286 $template->add_header('<meta http-equiv="refresh" content="' . $timeout . '; url=' . str_replace('"', '\\"', $url) . '" />'); |
290 $template->add_header('<meta http-equiv="refresh" content="' . $timeout . '; url=' . str_replace('"', '\\"', $url) . '" />'); |
287 $template->add_header('<script type="text/javascript"> |
291 $template->add_header('<script type="text/javascript"> |
288 function __r() { |
292 function __r() { |
289 // FUNCTION AUTOMATICALLY GENERATED |
293 // FUNCTION AUTOMATICALLY GENERATED |
293 </script> |
297 </script> |
294 '); |
298 '); |
295 |
299 |
296 $template->tpl_strings['PAGE_NAME'] = $title; |
300 $template->tpl_strings['PAGE_NAME'] = $title; |
297 $template->header(true); |
301 $template->header(true); |
298 echo '<p>' . $message . '</p><p>If you are not redirected within ' . ( $timeout + 1 ) . ' seconds, <a href="' . str_replace('"', '\\"', $url) . '">please click here</a>.</p>'; |
302 echo '<p>' . $message . '</p>'; |
|
303 $subst = array( |
|
304 'timeout' => ( $timeout + 1 ), |
|
305 'redirect_url' => str_replace('"', '\\"', $url) |
|
306 ); |
|
307 echo '<p>' . $lang->get('etc_redirect_timeout', $subst) . '</p>'; |
299 $template->footer(true); |
308 $template->footer(true); |
300 |
309 |
301 $db->close(); |
310 $db->close(); |
302 exit(0); |
311 exit(0); |
303 |
312 |