Callback to delete files if size == 0 and modified more than 60 seconds ago.
Paramètres
string $has_string: If the .htaccess file contains this string it will be removed and recreated.
string $does_not_have_string: If the .htaccess file does not contains this string it will be removed & recreated.
Return value
string Translated string indicating what was done.
9 calls to advagg_install_update_htaccess()
- advagg_update_7201 dans ./
advagg.install - Remove Last-Modified Header from .htaccess to fix far future 304's.
- advagg_update_7202 dans ./
advagg.install - Remove the 480 week Far-Future code from .htaccess (violates RFC 2616 14.21).
- advagg_update_7203 dans ./
advagg.install - Add forcing of .js files to be application/javascript to follow RFC 4329 7.1.
- advagg_update_7205 dans ./
advagg.install - Fix incorrect usage of ForceType in .htaccess from update 7203.
- advagg_update_7214 dans ./
advagg.install - Update .htaccess to support brotli compression (br).
Fichier
-
./
advagg.install, line 2783
Code
function advagg_install_update_htaccess($has_string = '', $does_not_have_string = '') {
// Make sure the advagg_get_root_files_dir() function is available.
drupal_load('module', 'advagg');
// Get paths to .htaccess file.
list($css_path, $js_path) = advagg_get_root_files_dir();
$files['css'] = $css_path[0] . '/.htaccess';
$files['js'] = $js_path[0] . '/.htaccess';
// Check for old .htaccess files.
$something_done = FALSE;
foreach ($files as $type => $uri) {
if (!file_exists($uri)) {
unset($files[$type]);
continue;
}
$contents = advagg_file_get_contents($uri);
// Remove old .htaccess file if it has this string.
if (!empty($has_string) && strpos($contents, $has_string) !== FALSE) {
drupal_unlink($uri);
$something_done = TRUE;
}
// Remove old .htaccess file if it does not have this string.
if (!empty($does_not_have_string) && strpos($contents, $does_not_have_string) === FALSE) {
drupal_unlink($uri);
$something_done = TRUE;
}
}
// Create the new .htaccess file.
$new_htaccess = FALSE;
if (!empty($files) && $something_done && variable_get('advagg_htaccess_check_generate', ADVAGG_HTACCESS_CHECK_GENERATE)) {
// Make the advagg_htaccess_check_generate() function available.
module_load_include('inc', 'advagg', 'advagg.missing');
foreach ($files as $type => $uri) {
advagg_htaccess_check_generate(array(
$uri => $type,
), $type, TRUE);
$new_htaccess = TRUE;
}
}
// Output info.
if ($something_done) {
if ($new_htaccess) {
return t('Removed the old .htaccess file and put in a new one.');
}
else {
return t('Removed the old .htaccess file.');
}
}
else {
return t('Nothing needed to be done.');
}
}