Checks to see if an apache module is enabled.

Paramètres

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 dans ./advagg.install
Make sure http requests to css/js files work correctly.

Fichier

./advagg.install, line 2652

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;
}