You are here

function advagg_missing_fast404 in Advanced CSS/JS Aggregation 7.2

Same name and namespace in other branches
  1. 6 advagg.module \advagg_missing_fast404()
  2. 7 advagg.module \advagg_missing_fast404()

Send out a fast 404 and exit.

Parameters

string $msg: (optional) Small message reporting why the file didn't get created.

1 call to advagg_missing_fast404()
advagg_missing_aggregate in ./advagg.missing.inc
Menu Callback; generates a missing CSS/JS file.

File

./advagg.missing.inc, line 1475
Advanced CSS/JS aggregation module.

Code

function advagg_missing_fast404($msg = '') {
  drupal_page_is_cacheable(FALSE);

  // Strip new lines & separators and limit header message to 512 characters.
  $msg = substr(preg_replace("/[^\\w\\. ]+/", "", $msg), 0, 512);

  // Add in headers if possible.
  if (!headers_sent()) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
    header('X-AdvAgg: Failed validation. ' . $msg);
  }

  // Output fast 404 message and exit.
  print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
  print '<html xmlns="http://www.w3.org/1999/xhtml">';
  print '<head><title>404 Not Found</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head>';
  print '<body><h1>Not Found</h1>';
  print '<p>The requested URL was not found on this server.</p>';
  print '<p><a href="' . $GLOBALS['base_path'] . '">Home</a></p>';
  print '<!-- advagg_missing_fast404 -->';
  print '</body></html>';
  exit;
}