diff -urpN drupal-6.x-dev-access-0.6.2/modules/block/block.admin.inc drupal-6.x-dev-apache_mode-0.2/modules/block/block.admin.inc
--- drupal-6.x-dev-access-0.6.2/modules/block/block.admin.inc	2007-08-20 14:41:38.000000000 +0800
+++ drupal-6.x-dev-apache_mode-0.2/modules/block/block.admin.inc	2007-08-28 18:30:42.000000000 +0800
@@ -180,9 +180,10 @@ function block_admin_configure(&$form_st
     '#title' => t('Page specific visibility settings'),
     '#collapsible' => TRUE,
   );
-  $access = user_access('use PHP for block visibility');
+  $php_access = user_access('use PHP-mode for block visibility');
+  $apache_access = user_access('use Apache-mode for block visibility');
 
-  if ($edit['visibility'] == 2 && !$access) {
+  if (($edit['visibility'] == 2 && !$php_access) || ($edit['visibility'] == 3 && !$apache_access)) {
     $form['page_vis_settings'] = array();
     $form['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
     $form['page_vis_settings']['pages'] = array('#type' => 'value', '#value' => $edit['pages']);
@@ -191,10 +192,14 @@ function block_admin_configure(&$form_st
     $options = array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.'));
     $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
 
-    if ($access) {
+    if ($php_access) {
       $options[] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
       $description .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
     }
+    if ($apache_access) {
+      $options[] = t('Show if the following Apache access restriction returns <code>TRUE</code> (Apache-mode, experts only).');
+      $description .= ' '. t("If the Apache-mode is chosen, start and specific filter ordering by %order, and enter one %allow or %deny rule per line as Drupal paths. Start the pattern with a '^' character to designate a regular expression match. Example ordering is %deny-allow for not display if only %deny rules are match, or else display as default. Example pattern are %user for user login and %user-regex for every user acount detail pages but not for user login.", array('%order' => 'Order', '%allow' => 'Allow from', '%deny' => 'Deny from', '%deny-allow' => 'Order Deny,Allow', '%user' => 'Allow from user', '%user-regex' => 'Allow from ^user\/\d+'));
+    }
     $form['page_vis_settings']['visibility'] = array(
       '#type' => 'radios',
       '#title' => t('Show block on specific pages'),
@@ -233,6 +238,19 @@ function block_admin_configure_submit($f
       db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']);
     }
     module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']);
+    // Phase Apache-mode syntax.
+    if ($form_state['values']['visibility'] == 3) {
+      $type = 'block_' . $form_state['values']['module'] . '_' . $form_state['values']['delta'];
+      access_del($type);
+      $rules = preg_split('/\r\n?|\n/', $form_state['values']['pages']);
+      foreach ($rules as $rule) {
+        if (preg_match('/^(allow|deny)\s+(from)\s+(.+)\s*/Dsi', $rule, $matches)) {
+          $mask = preg_replace(array('/all/Dsi', '/\<front\>/'), array('^.*', preg_quote(variable_get('site_frontpage', 'node'), '/')), $matches[3]);
+          $status = strtolower($matches[1]) == 'allow' ? 1 : 0;
+          access_set($type, $mask, $status);
+        }
+      }
+    }
     drupal_set_message(t('The block configuration has been saved.'));
     cache_clear_all();
     $form_state['redirect'] = 'admin/build/block';
@@ -270,6 +288,20 @@ function block_add_block_form_submit($fo
     db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta);
   }
 
+  // Phase Apache-mode syntax.
+  if ($form_state['values']['visibility'] == 3) {
+    $type = 'block_' . $form_state['values']['module'] . '_' . $delta;
+    access_del($type);
+    $rules = preg_split('/\r\n?|\n/', $form_state['values']['pages']);
+    foreach ($rules as $rule) {
+      if (preg_match('/^(allow|deny)\s+(from)\s+(.+)\s*/Dsi', $rule, $matches)) {
+        $mask = preg_replace(array('/all/Dsi', '/\<front\>/'), array('^.*', preg_quote(variable_get('site_frontpage', 'node'), '/')), $matches[3]);
+        $status = strtolower($matches[1]) == 'allow' ? 1 : 0;
+        access_set($type, $mask, $status);
+      }
+    }
+  }
+
   drupal_set_message(t('The block has been created.'));
   cache_clear_all();
 
diff -urpN drupal-6.x-dev-access-0.6.2/modules/block/block.module drupal-6.x-dev-apache_mode-0.2/modules/block/block.module
--- drupal-6.x-dev-access-0.6.2/modules/block/block.module	2007-08-26 15:46:10.000000000 +0800
+++ drupal-6.x-dev-apache_mode-0.2/modules/block/block.module	2007-08-28 18:48:29.000000000 +0800
@@ -172,7 +172,7 @@ function template_preprocess_block_admin
  * Implementation of hook_perm().
  */
 function block_perm() {
-  return array('administer blocks', 'use PHP for block visibility');
+  return array('administer blocks', 'use PHP-mode for block visibility', 'use Apache-mode for block visibility');
 }
 
 /**
@@ -457,7 +457,7 @@ function block_list($region) {
 
       // Match path if necessary
       if ($block->pages) {
-        if ($block->visibility < 2) {
+        if ($block->visibility == 0 || $block->visibility == 1) {
           $path = drupal_get_path_alias($_GET['q']);
           $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($block->pages, '/')) .')$/';
           // Compare with the internal and path alias (if any).
@@ -470,9 +470,21 @@ function block_list($region) {
           // is displayed only on those pages listed in $block->pages.
           $page_match = !($block->visibility xor $page_match);
         }
-        else {
+        else if ($block->visibility == 2) {
           $page_match = drupal_eval($block->pages);
         }
+        else if ($block->visibility == 3) {
+          $path = drupal_get_path_alias($_GET['q']);
+          $type = 'block_' . $block->module . '_' . $block->delta;
+          $rules = preg_split('/\r\n?|\n/', $block->pages);
+          preg_match('/^(order)\s*(deny,allow|allow,deny|mutual-failure)/Dsi', $rules[0], $matches);
+          $order = (isset($matches[2]) && $matches[2]) ? $matches[2] : NULL;
+          // Compare with the internal and path alias (if any).
+          $page_match = access_get($type, $path, $order);
+          if ($path != $_GET['q']) {
+            $page_match = $page_match || access_get($type, $_GET['q'], $order);
+          }
+        }
       }
       else {
         $page_match = TRUE;
