]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - index.php
Merge branch '0.9.x' into userflag
[quix0rs-gnu-social.git] / index.php
index 4e6c0937927a5a5abe6184d0dd2adbb51cb4b5c7..3acdba3754a7c095618efe6eacbc96dffd98e9c4 100644 (file)
--- a/index.php
+++ b/index.php
  *
  * You should have received a copy of the GNU Affero General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  * @category StatusNet
  * @package  StatusNet
+ * @author   Brenda Wallace <shiny@cpan.org>
+ * @author   Christopher Vollick <psycotica0@gmail.com>
+ * @author   CiaranG <ciaran@ciarang.com>
+ * @author   Craig Andrews <candrews@integralblue.com>
+ * @author   Evan Prodromou <evan@controlezvous.ca>
+ * @author   Gina Haeussge <osd@foosel.net>
+ * @author   Jeffery To <jeffery.to@gmail.com>
+ * @author   Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author   Robin Millette <millette@controlyourself.ca>
+ * @author   Sarven Capadisli <csarven@controlyourself.ca>
+ * @author   Tom Adams <tom@holizz.com>
+ * 
  * @license  GNU Affero General Public License http://www.gnu.org/licenses/
- * @author Brenda Wallace <shiny@cpan.org> 
- * @author Christopher Vollick <psycotica0@gmail.com> 
- * @author CiaranG <ciaran@ciarang.com>
- * @author Craig Andrews <candrews@integralblue.com> 
- * @author Evan Prodromou <evan@status.net>
- * @author Evan Prodromou <evan@status.net> 
- * @author Evan Prodromou <evan@status.net>
- * @author Evan Prodromou <evan@status.net>
- * @author Gina Haeussge <osd@foosel.net> 
- * @author Jeffery To <jeffery.to@gmail.com>
- * @author Mike Cochrane <mikec@mikenz.geek.nz>
- * @author Robin Millette <millette@controlyourself.ca>
- * @author Sarven Capadisli <csarven@controlyourself.ca> 
- * @author Tom Adams <tom@holizz.com>
  */
 
 define('INSTALLDIR', dirname(__FILE__));
@@ -51,12 +49,23 @@ function getPath($req)
     ) {
         return $req['p'];
     } else if (array_key_exists('PATH_INFO', $_SERVER)) {
-        return $_SERVER['PATH_INFO'];
+        $path = $_SERVER['PATH_INFO'];
+        $script = $_SERVER['SCRIPT_NAME'];
+        if (substr($path, 0, mb_strlen($script)) == $script) {
+            return substr($path, mb_strlen($script));
+        } else {
+            return $path;
+        }
     } else {
         return null;
     }
 }
 
+/**
+ * logs and then displays error messages
+ *
+ * @return void
+ */
 function handleError($error)
 {
     if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) {
@@ -74,7 +83,7 @@ function handleError($error)
             common_log(LOG_ERR, $line);
         }
     }
-    if ($error instanceof DB_DataObject_Error 
+    if ($error instanceof DB_DataObject_Error
         || $error instanceof DB_Error
     ) {
         $msg = sprintf(
@@ -134,7 +143,7 @@ function checkMirror($action_obj, $args)
 
 function isLoginAction($action)
 {
-    static $loginActions =  array('login', 'recoverpassword', 'api', 'doc', 'register');
+    static $loginActions =  array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds');
 
     $login = null;
 
@@ -227,8 +236,8 @@ function main()
     // If the site is private, and they're not on one of the "public"
     // parts of the site, redirect to login
 
-    if (!$user && common_config('site', 'private') 
-        && !isLoginAction($action) 
+    if (!$user && common_config('site', 'private')
+        && !isLoginAction($action)
         && !preg_match('/rss$/', $action)
     ) {
         common_redirect(common_local_url('login'));