From 95595ae6f821fd616a60031b166b035482736c10 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Tue, 2 Nov 2004 12:47:10 +0000 Subject: #12384: Test if clean URLs work before allowing them to be turned on. --- modules/system/system.module | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'modules/system/system.module') diff --git a/modules/system/system.module b/modules/system/system.module index 332cea9f8..556cdb2e2 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -68,6 +68,12 @@ function system_menu($may_cache) { 'access' => TRUE, 'type' => MENU_CALLBACK); + // Clean URL tester + $items[] = array('path' => 'system/test', + 'callback' => 'system_test', + 'access' => TRUE, + 'type' => MENU_CALLBACK); + $access = user_access('administer site configuration'); // Themes: @@ -109,6 +115,12 @@ function system_menu($may_cache) { return $items; } +/** + * Menu callback: dummy clean URL tester. + */ +function system_test() { +} + /** * Implementation of hook_user(). * @@ -185,7 +197,11 @@ function system_view_general() { $group .= form_textarea(t('Footer message'), 'site_footer', variable_get('site_footer', ''), 70, 5, t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.')); $group .= form_textfield(t('Anonymous user'), 'anonymous', variable_get('anonymous', 'Anonymous'), 70, 70, t('The name used to indicate anonymous users.')); $group .= form_textfield(t('Default front page'), 'site_frontpage', variable_get('site_frontpage', 'node'), 70, 70, t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".')); - $group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable clean URLs. If enabled, you\'ll need ModRewrite support. See also the .htaccess file in Drupal\'s top-level directory.')); + + // check if clean URLs are supported (HTTP 200 = Ok) + $request = drupal_http_request($GLOBALS['base_url'] . '/system/test'); + $supported = $request->code == 200; + $group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled')), t('This option makes Drupal emit clean URLs (i.e. without ?q= in the URL). You\'ll need ModRewrite support for this to work. See the .htaccess file in Drupal\'s top-level directory for more information.'), false, $supported ? NULL : array('disabled' => 'disabled')); $output = form_group(t('General settings'), $group); -- cgit v1.2.3