You are here

function advagg_install_apache_mod_loaded in Advanced CSS/JS Aggregation 7.2

Checks to see if an apache module is enabled.

Parameters

string $mod: Name of an apache module.

Return value

bool TRUE if it exists; FALSE if it does not; NULL if it can not be determined.

1 call to advagg_install_apache_mod_loaded()
advagg_install_chk_urls in ./advagg.install
Make sure http requests to css/js files work correctly.

File

./advagg.install, line 2622
Handles Advanced Aggregation installation and upgrade tasks.

Code

function advagg_install_apache_mod_loaded($mod) {
  $sapi_type = php_sapi_name();
  if (substr($sapi_type, 0, 3) == 'cgi' || $sapi_type == 'fpm-fcgi') {

    // NULL returned, apache_get_modules and phpinfo can not be called.
    return NULL;
  }
  if (is_callable('apache_get_modules')) {
    $mods = apache_get_modules();
    if (in_array($mod, $mods)) {

      // Return TRUE, module exists.
      return TRUE;
    }
  }
  elseif (is_callable('phpinfo') && FALSE === strpos(ini_get('disable_functions'), 'phpinfo')) {

    // Use static so we don't run phpinfo multiple times.
    $phpinfo =& drupal_static(__FUNCTION__);
    if (empty($phpinfo)) {

      // Use phpinfo to get the info if apache_get_modules doesn't exist.
      ob_start();
      phpinfo(8);
      $phpinfo = ob_get_clean();
    }
    if (FALSE !== strpos($phpinfo, $mod)) {

      // Return TRUE, module exists.
      return TRUE;
    }
  }
  else {

    // NULL returned, apache_get_modules and phpinfo can not be called.
    return NULL;
  }
  return FALSE;
}