Index: gallery_install.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gallery/Attic/gallery_install.inc,v
retrieving revision 1.1.2.14
diff -u -r1.1.2.14 gallery_install.inc
--- gallery_install.inc	2 Jul 2007 09:22:18 -0000	1.1.2.14
+++ gallery_install.inc	10 Jul 2007 08:24:43 -0000
@@ -258,11 +258,13 @@
       '#value' => $gallery_dir,
     );
     
-    $form['install']['gallery_embed_uri_auto_item'] = array(
-      '#title' => t('Embed URI'),
-      '#type' => 'item',
-      '#value' => $embed_uri,
-    );
+    if (!empty($embed_uri)) {
+      $form['install']['gallery_embed_uri_auto_item'] = array(
+        '#title' => t('Embed URI'),
+        '#type' => 'item',
+        '#value' => $embed_uri,
+      );
+    }
     $form['install']['gallery_embed_uri_auto'] = array(
       '#type' => 'value',
       '#value' => $embed_uri,
@@ -302,7 +304,7 @@
       '#maxlength' => 128,
       '#description' => t('The filesystem path of your Gallery2 directory. This can be either an
         absolute path (e.g. /home/mysite/htdocs/gallery2) or relative to the root directory of your
-        Drupal installation (e.g. ../gallery2).'),
+        Drupal installation (e.g. ./gallery2 or ./../gallery2).'),
       '#disabled' => $form_values['gallery_valid'],
     );
   
@@ -335,6 +337,12 @@
       );
     }
   }
+  else {
+    $form['install']['gallery_outside'] = array(
+      '#type' => 'value',
+      '#value' => $form_values['gallery_outside'],
+    );
+  }
 }
 
 /**
@@ -632,6 +640,7 @@
         variable_set('gallery_dir', $form_values['gallery_dir_man']);
         variable_set('gallery_embed_uri', $form_values['gallery_embed_uri_man']);
       }
+      variable_set('gallery_outside', $form_values['gallery_outside']);
       variable_del('gallery_wizard_data');
       
       // This is the last step: gallery_valid will be TRUE even
@@ -679,9 +688,10 @@
       variable_del('gallery_uri');
       variable_del('gallery_dir');
       variable_del('gallery_embed_uri');
+      variable_del('gallery_outside');
+      variable_del('gallery_wizard_data');
       variable_del('gallery_valid');
       variable_del('gallery_rewrite_disable');
-      variable_del('gallery_wizard_data');
       menu_rebuild();
       variable_set('gallery_config_reset', TRUE);
       drupal_goto('admin/settings/gallery/install');
@@ -726,7 +736,7 @@
     $form_values['gallery_dir_man'] = $detect_values['g2_embed_path'];
     $form_values['gallery_embed_uri_man'] = $detect_values['embed_uri'];
   }
-
+  $form_values['gallery_outside'] = $detect_values['gallery_outside'];
   $form_values['gallery_valid'] = $gallery_valid;
 
   $install_status['locations']['status'] = $gallery_valid;
@@ -740,11 +750,11 @@
   // Set up the result status array. The rest gets filled in later.
   $result = array(
     'g2_uri' => array(
-          'title' => t('URI of Gallery2'),
+          'title' => t('Gallery2 URL or URI'),
           'severity' => GALLERY_SEVERITY_ERROR,
     ),
     'g2_embed_path' => array(
-          'title' => t('Location of Gallery2'),
+          'title' => t('Gallery2 filesystem path'),
           'severity' => GALLERY_SEVERITY_ERROR,
     ),
     'init' => array(
@@ -754,6 +764,7 @@
   );
   
   $vars = array();
+  $vars['gallery_outside'] = FALSE;
   $vars['gallery_valid'] = TRUE;
 
   // Strip the end /gallery if present and replace with index.php?q=gallery to avoid any 
@@ -794,7 +805,7 @@
         G2EmbedDiscoveryUtilities::getG2EmbedPathByG2UriEmbedUriAndLocation($g2_uri, $embed_uri, $drupal_path);
       if ($success) {
         // G2 Embed Path is found OK
-        $vars['g2_embed_path'] = rtrim($embed_php_path, 'embed.php'); 
+        $vars['g2_embed_path'] = rtrim($embed_php_path, 'embed.php');
       }
       else {                     
         $result['g2_uri']['info'] = $error_string;
@@ -851,10 +862,20 @@
       $vars['gallery_valid'] = FALSE;
     }
     else {
+      // Is Gallery2 installed inside the Drupal root directory?
+      $docroot = str_replace('/', '\\' , $_SERVER['DOCUMENT_ROOT']);
+      $base_path = str_replace('/', '\\' , base_path());
+      if ((stripos($vars['g2_embed_path'], $base_path) === FALSE && stripos($vars['g2_embed_path'], $docroot) !== FALSE)
+           || stripos($vars['g2_embed_path'], '../') !== FALSE) {
+        $vars['gallery_outside'] = TRUE;
+      }
+      // Update version info
       gallery_version();       
       GalleryEmbed::done();
     }
   }
+  
+  gallery_debug($vars, t('Location variables'));
 
   // Only return items where status has been set
   foreach ($result as $key => $value) {
