Пример #1
0
function error($type, $allowReload = false)
{
    global $CONFIG, $themeReplace, $options, $phrases, $flag;
    # Get extra arguments
    $args = func_get_args();
    # Remove first argument (we have that as $type)
    array_shift($args);
    # Check error exists
    # Force to the "unknown" error message
    if (!isset($phrases[$type])) {
        $args = array($type);
        $type = 'unknown_error';
    }
    if ($args) {
        # Error text must be generated by calling sprintf - we only have
        # the extra args as an array so we have to use call_user_func_array
        $errorText = call_user_func_array('sprintf', array_merge((array) $phrases[$type], $args));
    } else {
        # Error text can be fetched simply from the $phrases array
        $errorText = $phrases[$type];
    }
    # If in frame or ajax, don't redirect back to index
    if (isset($flag) && ($flag == 'frame' || $flag == 'ajax')) {
        die($errorText . ' <a href="index.php">Return to index</a>.');
    }
    # Finally add it to the $themeReplace array to get it in there
    $themeReplace['error'] = '<div id="error">' . $errorText . '</div>';
    # And a link to try again?
    $return = currentURL();
    if (strlen($return) > 0) {
        $themeReplace['error'] .= '<p style="text-align:right">[<a href="' . htmlentities($return) . '">Reload ' . htmlentities(deproxyURL($return)) . '</a>]</p>';
    }
    # Start with an empty array
    $toShow = array();
    # Loop through the available options
    foreach ($CONFIG['options'] as $name => $details) {
        # Check we're allowed to choose
        if (!empty($details['force'])) {
            continue;
        }
        # Generate the HTML 'checked' where appropriate
        $checked = $options[$name] ? ' checked="checked"' : '';
        # Add to the toShow array
        $toShow[] = array('name' => $name, 'title' => $details['title'], 'desc' => $details['desc'], 'escaped_desc' => str_replace("'", "\\'", $details['desc']), 'checked' => $checked);
    }
    sendNoCache();
    $vars2['toShow'] = $toShow;
    echo loadTemplate('main', $vars2);
    # And flush buffer
    ob_end_flush();
    exit;
}
Пример #2
0
 case 'not_modified':
     header("HTTP/1.1 304 Not Modified", true, 304);
     exit;
     # 401 Authentication (HTTP authentication hooks not available in all PHP versions
     # so we have to use our method)
 # 401 Authentication (HTTP authentication hooks not available in all PHP versions
 # so we have to use our method)
 case 'auth_required':
     # Ensure we have some means of authenticating and extract details about the type of authentication
     if (!isset($fetch->headers['www-authenticate'])) {
         break;
     }
     # Realm to display to the user
     $realm = preg_match('#\\brealm="([^"]*)"#i', $fetch->headers['www-authenticate'], $tmp) ? $tmp[1] : '';
     # Prevent caching
     sendNoCache();
     # Prepare template variables (session may be closed at this point so send via form)
     $tmp = array('site' => $URL['scheme_host'], 'realm' => $realm, 'return' => currentURL());
     # Show our form and quit
     echo loadTemplate('authenticate.page', $tmp);
     exit;
     # File request above filesize limit
 # File request above filesize limit
 case 'filesize_limit':
     # If already sent some of the file, we can't display an error
     # so just stop running
     if (!$fetch->parseType) {
         exit;
     }
     # Send to error page with filesize limit expressed in MB
     error('file_too_large', round($CONFIG['max_filesize'] / 1024 / 1024, 3));
Пример #3
0
function error($type, $allowReload = false)
{
    global $phrases, $flag;
    // Get extra arguments
    $args = func_get_args();
    // Remove first argument (we have that as $type)
    array_shift($args);
    // Check error exists
    if (!isset($phrases[$type])) {
        // Force to the "unknown" error message
        $args = array($type);
        $type = 'unknown_error';
    }
    // If in frame or ajax, don't redirect back to index
    if (isset($flag) && ($flag == 'frame' || $flag == 'ajax')) {
        // Extra arguments to take care of?
        if ($args) {
            // Error text must be generated by calling sprintf - we only have
            // the extra args as an array so we have to use call_user_func_array
            $errorText = call_user_func_array('sprintf', array_merge((array) $phrases[$type], $args));
        } else {
            // Error text can be fetched simply from the $phrases array
            $errorText = $phrases[$type];
        }
        die($errorText . ' <a href="index.php">Return to index</a>.');
    }
    // Still here? Not frame so serialize to pass in query string
    $pass = $args ? '&p=' . base64_encode(serialize($args)) : '';
    // Don't cache the error
    sendNoCache();
    // Do we want to allow refresh?
    $return = $allowReload ? '&return=' . rawurlencode(currentURL()) : '';
    // And go to error page
    redirect('index.php?e=' . $type . $return . $pass);
    exit;
}