]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Fix bug #3160512: Make SemantiScuttle work with FastCGI
authorChristian Weiske <cweiske@cweiske.de>
Sat, 23 Jul 2011 12:19:09 +0000 (14:19 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Sat, 23 Jul 2011 12:19:09 +0000 (14:19 +0200)
doc/ChangeLog
src/SemanticScuttle/Environment.php [new file with mode: 0644]
src/SemanticScuttle/constants.php
src/SemanticScuttle/header.php
tests/SemanticScuttle/EnvironmentTest.php [new file with mode: 0644]

index 229db5528c5659ad221ba732a63293962c4ac4fa..fc8c7185f3431185bd00bd2c3a3b652f7556adfa 100644 (file)
@@ -7,6 +7,7 @@ ChangeLog for SemantiScuttle
 -------------------
 - Fix bug #3375635: XML parsing problem in top.inc.php
 - Fix bug #3375428: Forgot to remove some old dojo files
+- Fix bug #3160512: Make SemantiScuttle work with FastCGI
 
 
 0.98.0 - 2011-07-21
diff --git a/src/SemanticScuttle/Environment.php b/src/SemanticScuttle/Environment.php
new file mode 100644 (file)
index 0000000..e5fe3de
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+/**
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package  SemanticScuttle
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @license  AGPL http://www.gnu.org/licenses/agpl.html
+ * @link     http://sourceforge.net/projects/semanticscuttle
+ */
+
+/**
+ * Server environment handling methods
+ *
+ * @category Bookmarking
+ * @package  SemanticScuttle
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @license  AGPL http://www.gnu.org/licenses/agpl.html
+ * @link     http://sourceforge.net/projects/semanticscuttle
+ */
+class SemanticScuttle_Environment
+{
+    /**
+     * Determines the correct $_SERVER['PATH_INFO'] value
+     *
+     * @return string New value
+     */
+    public static function getServerPathInfo()
+    {
+        /* old code that does not work today.
+           if you find that this code helps you, tell us
+           and send us the output of var_export($_SERVER);
+        // Correct bugs with PATH_INFO (maybe for Apache 1 or CGI) -- for 1&1 host...
+        if (isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) {
+            if (strlen($_SERVER["PATH_INFO"])<strlen($_SERVER["ORIG_PATH_INFO"])) {
+                $_SERVER["PATH_INFO"] = $_SERVER["ORIG_PATH_INFO"];
+            }
+            if (strcasecmp($_SERVER["PATH_INFO"], $_SERVER["SCRIPT_NAME"]) == 0) {
+                unset($_SERVER["PATH_INFO"]);
+            }
+            if (strpos($_SERVER["PATH_INFO"], '.php') !== false) {
+                unset($_SERVER["PATH_INFO"]);
+            }
+        }
+        */
+
+        return $_SERVER['PATH_INFO'];
+    }
+}
+?>
\ No newline at end of file
index 11ab0daaa70995fc6e43b76dbbc4ea998e0ce2f3..fcb2d902d292cdbc8e81c4f3ac3441a48650da46 100644 (file)
@@ -69,16 +69,6 @@ define('PAGE_WATCHLIST', "watchlist");
 // installations on the same host server
 define('INSTALLATION_ID', md5($GLOBALS['dbname'].$GLOBALS['tableprefix']));
 
-// Correct bugs with PATH_INFO (maybe for Apache 1 or CGI) -- for 1&1 host...
-if (isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) {
-    if (strlen($_SERVER["PATH_INFO"])<strlen($_SERVER["ORIG_PATH_INFO"])) {
-        $_SERVER["PATH_INFO"] = $_SERVER["ORIG_PATH_INFO"];
-    }
-    if (strcasecmp($_SERVER["PATH_INFO"], $_SERVER["SCRIPT_NAME"]) == 0) {
-        unset($_SERVER["PATH_INFO"]);
-    }
-    if (strpos($_SERVER["PATH_INFO"], '.php') !== false) {
-        unset($_SERVER["PATH_INFO"]);
-    }
-}
+//currently not needed
+//$_SERVER['PATH_INFO'] = SemanticScuttle_Environment::getServerPathInfo();
 ?>
index 92523003060271d5ac33cc6bcf5fbeccad889a27..694df542d467af602d67506cf617ab19cad5778a 100644 (file)
@@ -25,6 +25,7 @@ if ('@data_dir@' == '@' . 'data_dir@') {
     //FIXME: when you have multiple installations, the www_dir will be wrong
     $wwwdir  = '@www_dir@/SemanticScuttle/';
 }
+require_once dirname(__FILE__) . '/Environment.php';
 require_once dirname(__FILE__) . '/Config.php';
 
 $cfg = new SemanticScuttle_Config();
diff --git a/tests/SemanticScuttle/EnvironmentTest.php b/tests/SemanticScuttle/EnvironmentTest.php
new file mode 100644 (file)
index 0000000..a41efa1
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+
+class SemanticScuttle_EnvironmentTest extends PHPUnit_Framework_TestCase
+{
+    public function testServerPathInfoModPhp()
+    {
+        $_SERVER = array(
+            'HTTP_USER_AGENT' => 'Opera/9.80 (X11; Linux x86_64; U; de) Presto/2.9.168 Version/11.50',
+            'HTTP_HOST' => 'bm-cgi.bogo',
+            'HTTP_ACCEPT' => 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
+            'HTTP_ACCEPT_LANGUAGE' => 'de-DE,de;q=0.9,en;q=0.8',
+            'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
+            'HTTP_COOKIE' => 'PHPSESSID=ga446jhs0e09hkt60u9bsmp0n0',
+            'HTTP_CACHE_CONTROL' => 'no-cache',
+            'HTTP_CONNECTION' => 'Keep-Alive',
+            'PATH' => '/usr/local/bin:/usr/bin:/bin',
+  'SERVER_SIGNATURE' => '<address>Apache/2.2.17 (Ubuntu) Server at bm-cgi.bogo Port 80</address>',
+            'SERVER_SOFTWARE' => 'Apache/2.2.17 (Ubuntu)',
+            'SERVER_NAME' => 'bm-cgi.bogo',
+            'SERVER_ADDR' => '127.0.0.1',
+            'SERVER_PORT' => '80',
+            'REMOTE_ADDR' => '127.0.0.1',
+            'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
+            'SERVER_ADMIN' => '[no address given]',
+            'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/profile.php',
+            'REMOTE_PORT' => '45349',
+            'GATEWAY_INTERFACE' => 'CGI/1.1',
+            'SERVER_PROTOCOL' => 'HTTP/1.1',
+            'REQUEST_METHOD' => 'GET',
+            'QUERY_STRING' => '',
+            'REQUEST_URI' => '/profile.php/dummy',
+            'SCRIPT_NAME' => '/profile.php',
+            'PATH_INFO' => '/dummy',
+            'PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/dummy',
+            'PHP_SELF' => '/profile.php/dummy',
+            'REQUEST_TIME' => 1311422546,
+        );
+        $this->assertEquals(
+            '/dummy', SemanticScuttle_Environment::getServerPathInfo()
+        );
+    }
+
+
+    public function testServerPathInfoFastCgi()
+    {
+        $_SERVER = array(
+            'PHP_FCGI_MAX_REQUESTS' => '5000',
+            'PHPRC' => '/etc/php5/cgi/5.3.6/',
+            'PHP_FCGI_CHILDREN' => '3',
+            'PWD' => '/var/www/cgi-bin',
+            'FCGI_ROLE' => 'RESPONDER',
+            'REDIRECT_HANDLER' => 'php-cgi',
+            'REDIRECT_STATUS' => '200',
+            'HTTP_USER_AGENT' => 'Opera/9.80 (X11; Linux x86_64; U; de) Presto/2.9.168 Version/11.50',
+            'HTTP_HOST' => 'bm-cgi.bogo',
+            'HTTP_ACCEPT' => 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
+            'HTTP_ACCEPT_LANGUAGE' => 'de-DE,de;q=0.9,en;q=0.8',
+            'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
+            'HTTP_COOKIE' => 'PHPSESSID=ga446jhs0e09hkt60u9bsmp0n0',
+            'HTTP_CONNECTION' => 'Keep-Alive',
+            'PATH' => '/usr/local/bin:/usr/bin:/bin',
+  'SERVER_SIGNATURE' => '<address>Apache/2.2.17 (Ubuntu) Server at bm-cgi.bogo Port 80</address>',
+            'SERVER_SOFTWARE' => 'Apache/2.2.17 (Ubuntu)',
+            'SERVER_NAME' => 'bm-cgi.bogo',
+            'SERVER_ADDR' => '127.0.0.1',
+            'SERVER_PORT' => '80',
+            'REMOTE_ADDR' => '127.0.0.1',
+            'DOCUMENT_ROOT' => '/etc/apache2/htdocs',
+            'SERVER_ADMIN' => '[no address given]',
+            'SCRIPT_FILENAME' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/profile.php',
+            'REMOTE_PORT' => '45342',
+            'REDIRECT_URL' => '/profile.php/dummy',
+            'GATEWAY_INTERFACE' => 'CGI/1.1',
+            'SERVER_PROTOCOL' => 'HTTP/1.1',
+            'REQUEST_METHOD' => 'GET',
+            'QUERY_STRING' => '',
+            'REQUEST_URI' => '/profile.php/dummy',
+            'SCRIPT_NAME' => '/profile.php',
+            'PATH_INFO' => '/dummy',
+            'PATH_TRANSLATED' => '/etc/apache2/htdocs/dummy',
+            'ORIG_PATH_INFO' => '/profile.php/dummy',
+            'ORIG_SCRIPT_NAME' => '/cgi-bin-php/php-cgi-5.3.6',
+            'ORIG_SCRIPT_FILENAME' => '/var/www/cgi-bin/php-cgi-5.3.6',
+            'ORIG_PATH_TRANSLATED' => '/home/cweiske/Dev/html/hosts/bm-cgi.bogo/profile.php/dummy',
+            'PHP_SELF' => '/profile.php/dummy',
+            'REQUEST_TIME' => 1311422521,
+        );
+        $this->assertEquals(
+            '/dummy', SemanticScuttle_Environment::getServerPathInfo()
+        );
+    }
+
+}
+
+?>
\ No newline at end of file