Beispiel #1
0
 function __destruct()
 {
     // Run shutdown function
     if (function_exists("run_shutdown")) {
         run_shutdown();
     }
 }
Beispiel #2
0
/**
 * Redirect the user to a given URL with a given message
 *
 * @param string The URL to redirect the user to
 * @param string The redirection message to be shown
 */
function redirect($url, $message = "", $title = "")
{
    global $header, $footer, $mybb, $theme, $headerinclude, $templates, $lang, $plugins;
    $redirect_args = array('url' => &$url, 'message' => &$message, 'title' => &$title);
    $plugins->run_hooks("redirect", $redirect_args);
    if ($mybb->input['ajax']) {
        // Send our headers.
        @header("Content-type: text/html; charset={$lang->settings['charset']}");
        echo "<script type=\"text/javascript\">\n";
        if ($message != "") {
            echo 'alert("' . addslashes($message) . '");';
        }
        $url = str_replace("#", "&#", $url);
        $url = htmlspecialchars_decode($url);
        $url = str_replace(array("\n", "\r", ";"), "", $url);
        echo 'window.location = "' . addslashes($url) . '";' . "\n";
        echo "</script>\n";
        exit;
    }
    if (!$message) {
        $message = $lang->redirect;
    }
    $time = TIME_NOW;
    $timenow = my_date($mybb->settings['dateformat'], $time) . " " . my_date($mybb->settings['timeformat'], $time);
    if (!$title) {
        $title = $mybb->settings['bbname'];
    }
    // Show redirects only if both ACP and UCP settings are enabled, or ACP is enabled, and user is a guest.
    if ($mybb->settings['redirects'] == 1 && ($mybb->user['showredirect'] != 0 || !$mybb->user['uid'])) {
        $url = str_replace("&amp;", "&", $url);
        $url = htmlspecialchars_uni($url);
        eval("\$redirectpage = \"" . $templates->get("redirect") . "\";");
        output_page($redirectpage);
    } else {
        $url = htmlspecialchars_decode($url);
        $url = str_replace(array("\n", "\r", ";"), "", $url);
        run_shutdown();
        if (my_substr($url, 0, 7) !== 'http://' && my_substr($url, 0, 8) !== 'https://' && my_substr($url, 0, 1) !== '/') {
            header("Location: {$mybb->settings['bburl']}/{$url}");
        } else {
            header("Location: {$url}");
        }
    }
    exit;
}