fix image text
[pear] / HTML / FlexyFramework / Page.php
index 86457ad..e8add0e 100644 (file)
@@ -129,7 +129,13 @@ class HTML_FlexyFramework_Page  {
     var $errors = array(); // key(element name)=>error message
 
 
-
+    /**
+    * is the page being run from the command line?
+    *  
+    * @var bool
+    * @access public
+    */
+    var $cli = false;
     /**
     * Arguments from cli if static $cli_opts is used.
     *
@@ -148,6 +154,8 @@ class HTML_FlexyFramework_Page  {
 
 
 
+    var $timer;
+
     /**
     * The default page handler
     * by default relays to get(), or post() methods depending on the request.
@@ -242,7 +250,7 @@ class HTML_FlexyFramework_Page  {
 
     function output()
     {
-        print_r('break template');exit;
+      
         if (!empty($this->cli)) {
             return;
         }
@@ -290,7 +298,7 @@ class HTML_FlexyFramework_Page  {
         }
         $template_engine->elements = $this->elements;
         $template_engine->outputObject($this,$this->elements);
-
+        return '';
     }
 
 
@@ -397,6 +405,12 @@ class HTML_FlexyFramework_Page  {
     {
         static $ses_status = false;
         static $ini = false;
+        
+        if (!empty($_SERVER['PHP_AUTH_USER']) ||  php_sapi_name() == "cli") {
+            // do not do sessions if we are using http auth.
+            return;
+        }
+        
         // session status is only php5.4 and up..
         if (!defined('PHP_SESSION_ACTIVE')) {
             define('PHP_SESSION_ACTIVE' , 1);
@@ -424,8 +438,31 @@ class HTML_FlexyFramework_Page  {
                 $ini = true;
                 // sometimes raises a notice - ps_files_cleanup_dir.
                 @session_start();
+                $this->dedupeSessionCookies();
                 return;
         }
     }
+    
+    function dedupeSessionCookies()
+    {
+         if (headers_sent()) {
+            return;
+        }
+        $cookies = array();
+        
+        foreach (headers_list() as $header) {
+            // Identify cookie headers
+            if (strpos($header, 'Set-Cookie:') === 0) {
+                $cookies[] = $header;
+            }
+        }
+        header_remove('Set-Cookie');
+
+        // Restore one copy of each cookie
+        foreach(array_unique($cookies) as $cookie) {
+            header($cookie, false);
+        }
+    }
+    
 
 }