diff --git a/src/ajax.php b/src/ajax.php
index ecbca85..c6eb572 100644
--- a/src/ajax.php
+++ b/src/ajax.php
@@ -15,7 +15,7 @@ $db = DBConnection::instance();
if(isset($_GET['loadLists']))
{
- if($needAuth && !is_logged()) $sqlWhere = 'WHERE published=1';
+ if (need_auth() && !is_logged()) $sqlWhere = 'WHERE published=1';
else $sqlWhere = '';
$t = array();
$t['total'] = 0;
@@ -297,7 +297,7 @@ elseif(isset($_GET['changeOrder']))
elseif(isset($_POST['login']))
{
$t = array('logged' => 0);
- if(!$needAuth) {
+ if (!need_auth()) {
$t['disabled'] = 1;
jsonExit($t);
}
diff --git a/src/feed.php b/src/feed.php
index ed8ec03..f617530 100644
--- a/src/feed.php
+++ b/src/feed.php
@@ -14,7 +14,7 @@ $lang = Lang::instance();
$listId = (int)_get('list');
$listData = $db->sqa("SELECT * FROM {$db->prefix}lists WHERE id=$listId");
-if($needAuth && (!$listData || !$listData['published'])) {
+if (need_auth() && (!$listData || !$listData['published'])) {
die("Access denied!
List is not published.");
}
if(!$listData) {
diff --git a/src/init.php b/src/init.php
index 29c19f3..59df7bb 100644
--- a/src/init.php
+++ b/src/init.php
@@ -63,8 +63,7 @@ Lang::loadLang(Config::get('lang'));
$_mttinfo = array();
-$needAuth = (Config::get('password') != '') ? 1 : 0;
-if($needAuth && !isset($dontStartSession))
+if (need_auth() && !isset($dontStartSession))
{
if(Config::get('session') == 'files')
{
@@ -81,16 +80,21 @@ if($needAuth && !isset($dontStartSession))
session_start();
}
+function need_auth()
+{
+ return (Config::get('password') != '') ? 1 : 0;
+}
+
function is_logged()
{
- if(!isset($_SESSION['logged']) || !$_SESSION['logged']) return false;
- return true;
+ if ( !need_auth() ) return true;
+ if ( isset($_SESSION['logged']) && $_SESSION['logged'] ) return true;
+ return false;
}
function is_readonly()
{
- $needAuth = (Config::get('password') != '') ? 1 : 0;
- if($needAuth && !is_logged()) return true;
+ if (need_auth() && !is_logged()) return true;
return false;
}
diff --git a/src/settings.php b/src/settings.php
index 766b59f..739bcac 100644
--- a/src/settings.php
+++ b/src/settings.php
@@ -10,7 +10,7 @@ require_once('./init.php');
$lang = Lang::instance();
-if($needAuth && !is_logged())
+if (need_auth() && !is_logged())
{
die("Access denied!
Disable password protection or Log in.");
}
diff --git a/src/setup.php b/src/setup.php
index 39acd99..47156d2 100644
--- a/src/setup.php
+++ b/src/setup.php
@@ -27,7 +27,7 @@ if(!isset($config['db']))
if($config['db'] != '')
{
require_once('./init.php');
- if($needAuth && !is_logged())
+ if (need_auth() && !is_logged())
{
die("Access denied!
Disable password protection or Log in.");
}
diff --git a/src/themes/default/index.php b/src/themes/default/index.php
index 8f32e63..95ada7c 100644
--- a/src/themes/default/index.php
+++ b/src/themes/default/index.php
@@ -29,8 +29,8 @@ $().ready(function(){
lang: makeJS() ?>,
mttUrl: "",
db: mytinytodoStorageAjax,
- needAuth: ,
- isLogged: ,
+ needAuth: ,
+ isLogged: ,
showdate: ,
singletab: ,
duedatepickerformat: "",