Index: fb_settings.inc
===================================================================
--- fb_settings.inc     (revision 2770)
+++ fb_settings.inc     (working copy)
@@ -1,4 +1,12 @@
 <?php
+// $Id$
+
+/**
+ * @file
+ * Initial configuration and session initialisation.
+ *
+ */
+
 // The URL prefix will look something like fb_cb/NID.
 // Or in avanced cases fb_cb/NID/fb_cb_type/TYPE, or even fb_cb/NID/fb_sess/SESSION.
 define('FB_SETTINGS_APP_NID', 'fb_cb');
@@ -6,8 +14,9 @@
 define('FB_SETTINGS_SESSION_KEY', 'fb_sess');

 // NOTE: can't use variable_set() -- database.inc hasn't loaded yet, so db_query() in variable_set() fails
-if (!is_array($conf))
+if (!is_array($conf)) {
   $conf = array();
+}

 // This allows us to test whether this file has been included.
 $conf['fb_settings_check'] = TRUE;
@@ -15,22 +24,26 @@
 // Ensure unique session for facebook app.
 $conf['session_inc'] = dirname(__FILE__) . '/fb_session.inc';

-if ($nid = _fb_settings_parse(FB_SETTINGS_APP_NID))
+if ($nid = _fb_settings_parse(FB_SETTINGS_APP_NID)) {
   // We're providing a canvas page or connect callback.
-
   if (isset($_REQUEST['fb_sig']) && isset($_REQUEST['fb_sig_in_canvas'])) {
-  // It's a facebook callback to an FBML page.
-
-  // Force clean URLs.  Looks better on facebook, and helps us know
-  // what to expect Note that we set our facebook callback to end in
-  // "?q=" so clean URLs will work in a facebook app whether or not
-  // they work locally
-  $conf['clean_url'] = 1;
-
-  // Force the admin theme to be our facebook theme.
-  // TODO: find a way to make this configurable.  I.e. to support iframe apps.
-  $conf['admin_theme'] = 'fb_fbml';
-
+    // It's a facebook callback to an FBML page.
+
+    // Force clean URLs.  Looks better on facebook, and helps us know
+    // what to expect Note that we set our facebook callback to end in
+    // "?q=" so clean URLs will work in a facebook app whether or not
+    // they work locally
+    $conf['clean_url'] = 1;
+
+    // Force the admin theme to be our facebook theme.
+    // TODO: find a way to make this configurable.  I.e. to support iframe apps.
+    $conf['admin_theme'] = 'fb_fbml';
+  }
+  elseif (isset($_REQUEST['fb_sig']) && isset($_REQUEST['fb_sig_in_iframe'])) {
+    // It's a facebook callback to an iFrame page.
+    $conf['clean_url'] = 1;
+    $conf['admin_theme'] = 'fb_fbml';
+  }
 }

 /**
@@ -73,12 +86,12 @@
       $args = explode('/', $path);
       $i = 0;
       while (isset($args[$i]) && isset($args[$i+1])) {
-       if ($args[$i] == $key)
-         // Found the value we're interested in.
-         return $args[$i+1];
-       $i = $i + 2;
+        if ($args[$i] == $key) {
+          // Found the value we're interested in.
+          return $args[$i+1];
+        }
+        $i = $i + 2;
       }
     }
   }
 }
-
