Index: includes/purl_path.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/includes/Attic/purl_path.inc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 purl_path.inc
--- includes/purl_path.inc	5 Jan 2010 02:48:37 -0000	1.1.2.5
+++ includes/purl_path.inc	18 Mar 2010 01:52:28 -0000
@@ -81,8 +81,7 @@
     // that contains our prefix. Then $alt will not be the same as the $path 
     // and we won't do any rewriting.
     $alt = $this->remove($path, $element);
-
-    if ($alt == $path && !_purl_skip($element, $options)) {
+    if ($alt == $path && !_purl_skip($element, $options, $path)) {
       $items = explode('/', $path);
       array_unshift($items, $element->value);
       $path = implode('/', $items);
Index: purl.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/Attic/purl.admin.inc,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 purl.admin.inc
--- purl.admin.inc	18 Dec 2009 16:11:32 -0000	1.1.2.10
+++ purl.admin.inc	18 Mar 2010 02:19:25 -0000
@@ -60,6 +60,7 @@
 function purl_settings_form() {
   $form = array();
   $options = _purl_options();
+  $rewrite_rules = db_fetch_array(db_query("SELECT mode, urls FROM {purl_rules}"));
 
   foreach (purl_providers() as $id => $provider) {
     // Check to see whether provider has limited the available valueing methods
@@ -92,11 +93,58 @@
     }
   }
 
+  $form['purl_rewrite_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Rewrite settings'),
+    '#collapsible' => TRUE,
+  );
+  $access = user_access('use PHP for rewrite evaluation');
+
+  if ($rewrite_rules['mode'] == 2 && !$access) {
+    $form['purl_rewrite_settings'] = array();
+    $form['purl_rewrite_settings']['mode'] = array('#type' => 'value', '#value' => 2);
+    $form['page_rewrite_settings']['urls'] = array('#type' => 'value', '#value' => $rewrite_rules['urls']);
+  }
+  else {
+    $options = array(t('Exclude these URLs'), t('Include these URLs'));
+    $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) {
+      $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 ?>'));
+    }
+    $form['purl_rewrite_settings']['mode'] = array(
+      '#type' => 'radios',
+      '#title' => t('Rewrite specific urls'),
+      '#options' => $options,
+      '#default_value' => $rewrite_rules['mode'],
+    );
+    $form['purl_rewrite_settings']['urls'] = array(
+      '#type' => 'textarea',
+      '#title' => t('Pages'),
+      '#default_value' => $rewrite_rules['urls'],
+      '#description' => $description,
+    );
+  }
+
   $form = system_settings_form($form);
   $form['#theme'] = 'purl_settings_form';
+  $form['#submit'][] = 'purl_settings_rules_submit';
   return $form;
 }
 
+function purl_settings_rules_submit($form, &$form_state) {
+  if (!form_get_errors()) {
+    db_query("UPDATE {purl_rules} SET mode = %d, urls = '%s'", $form_state['values']['mode'], trim($form_state['values']['urls']));
+    if (!db_affected_rows()) {
+      db_query("INSERT INTO {purl_rules} (mode, urls) VALUES (%d, '%s')", $form_state['values']['mode'], trim($form_state['values']['urls']));
+    }
+    drupal_set_message(t('The PURL configuration has been saved.'));
+    cache_clear_all();
+    return;
+  }
+}
+
 /**
  * Validate a key element and move its value to the correct key if validated.
  */
Index: purl.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/purl/purl.module,v
retrieving revision 1.1.2.36
diff -u -r1.1.2.36 purl.module
--- purl.module	17 Feb 2010 12:02:57 -0000	1.1.2.36
+++ purl.module	18 Mar 2010 02:38:06 -0000
@@ -853,9 +853,44 @@
  *   purl_path_element object
  * @param $o
  *   url options array.
+ * @param $p
+ *   the path
  * @return true if processing should be skipped, false otherwise.
  */
-function _purl_skip($e, $o) {
+function _purl_skip($e, $o, $p = NULL) {
+  static $rules;
+
+  // we need backward compatibility, $p is a new parameter
+  if(!empty($p)) {
+    if(!isset($rules)) {
+      $rules = db_fetch_array(db_query("SELECT mode, urls FROM {purl_rules}"));
+    }
+
+    // Match path if necessary
+    $page_match = TRUE;
+    if ($rules['urls']) {
+      if ($rules['mode'] < 2) {
+        // maybe the given path is a system path
+        $alt = drupal_get_path_alias($p);
+        // Compare with the internal and path alias (if any).
+        $page_match = drupal_match_path($alt, $rules['urls']);
+        if ($alt != $p) {
+          $page_match = $page_match || drupal_match_path($p, $rules['urls']);
+        }
+        // When $block->visibility has a value of 0, the block is displayed on
+        // all pages except those listed in $block->pages. When set to 1, it
+        // is displayed only on those pages listed in $block->pages.
+        $page_match = !($rules['mode'] xor $page_match);
+      }
+      else {
+        $page_match = drupal_eval($rules['urls']);
+      }
+    }
+
+    // the drupal block visibility works the other way around
+    if($page_match == FALSE) { return TRUE; }
+  }
+
   if (!empty($o['purl']['disabled'])) {
     return true;
   }

