]> git.mxchange.org Git - friendica.git/blobdiff - index.php
don't invoke slap if there's no endpoint configured
[friendica.git] / index.php
index 81d089dfb3aa4ed2cfcc6ce8f9f0fc275d31b416..cf20d35a29c907fa7bde0959f1e0f80b2c192099 100644 (file)
--- a/index.php
+++ b/index.php
@@ -17,7 +17,7 @@ if(isset($lang) && strlen($lang))
 
 require_once("dba.php");
 $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
-       unset($db_host, $db_user, $db_pass, $db_data);
+        unset($db_host, $db_user, $db_pass, $db_data);
 
 if(! $install)
        require_once("session.php");
@@ -30,10 +30,17 @@ $a->init_pagehead();
 
 session_start();
 
+// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
 
-if((x($_SESSION,'authenticated')) || (x($_POST['auth-params'])))
+if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
        require("auth.php");
 
+if(! x($_SESSION,'authenticated'))
+       header('X-Account-Management-Status: none');
+
+if(! x($_SESSION,'sysmsg'))
+       $_SESSION['sysmsg'] = '';
+
 if($install)
        $a->module = 'install';
 else
@@ -71,7 +78,9 @@ if($a->module_loaded) {
 
        if((! $a->error) && (function_exists($a->module . '_content'))) {
                $func = $a->module . '_content';
-               $a->page['content'] .= $func($a);
+               if(! x($a->page,'content'))
+                       $a->page['content'] = '';
+               $a->page['content'] .= $func($a);
        }
 
 }
@@ -84,7 +93,7 @@ if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
        
 if(x($_SESSION,'sysmsg')) {
        $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
-               . $a->page['content'];
+               . ((x($a->page,'content')) ? $a->page['content'] : '');
        unset($_SESSION['sysmsg']);
 }
 
@@ -100,6 +109,11 @@ $a->page['content'] .=  '<div id="pause"></div>';
 if($a->module != 'install')
        require_once("nav.php");
 
+// make sure the desired theme exists, though if the default theme doesn't exist we're stuffed.
+
+if((x($_SESSION,'theme')) && (! file_exists('/view/theme/' . $_SESSION['theme'] . '/style.css')))
+       unset($_SESSION['theme']);
+
 $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
        '$stylesheet' => $a->get_baseurl() . '/view/theme/'
                . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
@@ -109,14 +123,18 @@ $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
 $page    = $a->page;
 $profile = $a->profile;
 $lang    = get_config('system','language');
+if($lang === false)
+       $lang = 'en';
 
 header("Content-type: text/html; charset=utf-8");
 
-$template = "view/" . (($lang) ? $lang . "/" : "") 
-       . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) 
-       . ".php";
+$template = 'view/' . $lang . '/' 
+       . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
 
-require_once($template);
+if(file_exists($template))
+       require_once($template);
+else
+       require_once(str_replace($lang . '/', '', $template));
 
 session_write_close();
 exit;