Remove ^M in htaccess see BT#12478

pull/2487/head
jmontoyaa 9 years ago
parent 5209079a89
commit 1e5ab673c1
  1. 22
      plugin/maintenancemode/plugin.php

@ -128,9 +128,12 @@ RewriteRule \.*$ '.$append.'/maintenance.html [R=302,L]
$block = $default; $block = $default;
} }
$form->setDefaults( $form->setDefaults([
['text' => $block, 'maintenance' => $content, 'ip' => $ip, 'active' => $isActive] 'text' => $block,
); 'maintenance' => $content,
'ip' => $ip,
'active' => $isActive,
]);
if ($form->validate()) { if ($form->validate()) {
$values = $form->getSubmitValues(); $values = $form->getSubmitValues();
@ -144,8 +147,8 @@ RewriteRule \.*$ '.$append.'/maintenance.html [R=302,L]
$newFileContent .= $endLine; $newFileContent .= $endLine;
$newFileContent .= PHP_EOL; $newFileContent .= PHP_EOL;
$newFileContent .= $contentNoBlock; $newFileContent .= $contentNoBlock;
// Remove ^m chars
$newFileContent = str_replace('\\r', '', $newFileContent); $newFileContent = str_ireplace("\x0D", '', $newFileContent);
file_put_contents($file, $newFileContent); file_put_contents($file, $newFileContent);
$handle = curl_init(api_get_path(WEB_PATH)); $handle = curl_init(api_get_path(WEB_PATH));
@ -162,7 +165,7 @@ RewriteRule \.*$ '.$append.'/maintenance.html [R=302,L]
'warning' 'warning'
) )
); );
$originalContent = str_replace('\\r', '', $originalContent); $originalContent = str_replace("\x0D", '', $originalContent);
file_put_contents($file, $originalContent); file_put_contents($file, $originalContent);
} else { } else {
$result = file_put_contents($maintenanceHtml, $content); $result = file_put_contents($maintenanceHtml, $content);
@ -177,12 +180,13 @@ RewriteRule \.*$ '.$append.'/maintenance.html [R=302,L]
} }
if ($active == false) { if ($active == false) {
Display::addFlash(Display::return_message($plugin->get_lang('MaintenanceModeIsOff'))); $message = $plugin->get_lang('MaintenanceModeIsOff');
$contentNoBlock = str_replace('\\r', '', $contentNoBlock); $contentNoBlock = str_replace("\x0D", '', $contentNoBlock);
file_put_contents($file, $contentNoBlock); file_put_contents($file, $contentNoBlock);
} else { } else {
Display::addFlash(Display::return_message($plugin->get_lang('MaintenanceModeIsOn'))); $message = $plugin->get_lang('MaintenanceModeIsOn');
} }
Display::addFlash(Display::return_message($message));
} }
$plugin_info['settings_form'] = $form; $plugin_info['settings_form'] = $form;
} }

Loading…
Cancel
Save