diff --git a/app/post.class.php b/app/post.class.php
index 6e3c840..15486fd 100644
--- a/app/post.class.php
+++ b/app/post.class.php
@@ -310,7 +310,7 @@ class Post
"SELECT `id`, `text`, `feeling`, `persons`, `location`, `privacy`, `content_type`, `content`, DATE_FORMAT(`posts`.`datetime`,'%d %b %Y %H:%i') AS `datetime` ".
"FROM `posts` ".
"WHERE ".
- (!User::is_logged_in() ? "`privacy` = 'public' AND " : "").
+ (!User::is_logged_in() ? (User::is_visitor() ? "`privacy` IN ('public', 'friends') AND " : "`privacy` = 'public' AND ") : "").
($until ? "`posts`.`datetime` < DATE_ADD('{$until}', INTERVAL +1 MONTH) AND " : "").
($id ? "`id` = {$id} AND " : "").
($tag ? "`plain_text` LIKE '%{$tag}%' AND " : "").
@@ -331,6 +331,6 @@ class Post
}
public static function handshake($r){
- return ["logged_in" => User::is_logged_in()];
+ return ["logged_in" => User::is_logged_in(), "is_visitor" => User::is_visitor()];
}
}
\ No newline at end of file
diff --git a/app/user.class.php b/app/user.class.php
index c5a96c5..882372a 100644
--- a/app/user.class.php
+++ b/app/user.class.php
@@ -4,6 +4,14 @@ class user
{
const SESSION_NAME = "logged_in";
+ public static function is_visitor(){
+ if(!Config::get_safe("force_login", false)){
+ return true;
+ }
+
+ return !empty($_SESSION[User::SESSION_NAME]) && $_SESSION[User::SESSION_NAME] == 'visitor';
+ }
+
public static function is_logged_in(){
if(!Config::get_safe("force_login", false)){
return true;
@@ -23,9 +31,14 @@ class user
if(Config::get("nick") == $nick && Config::get_safe("pass", "") == $pass){
$_SESSION[User::SESSION_NAME] = md5($nick.$pass);
- return true;
+ return ["logged_in" => true, "is_visitor" => false];
}
-
+
+ if(($visitors = Config::get_safe("visitor", [])) && !empty($visitors) && isset($visitors[$nick]) && $visitors[$nick] === $pass){
+ $_SESSION[User::SESSION_NAME] = 'visitor';
+ return ["logged_in" => false, "is_visitor" => true];
+ }
+
Log::put("login_fails", $nick);
throw new Exception(__("The nick or password is incorrect."));
}
@@ -35,7 +48,7 @@ class user
throw new Exception(__("You can't log out. There is no account."));
}
- if(!self::is_logged_in()){
+ if(!self::is_logged_in() && !self::is_visitor()){
throw new Exception(__("You are not even logged in."));
}
diff --git a/config.ini b/config.ini
index 07bff3e..3d9aaf0 100644
--- a/config.ini
+++ b/config.ini
@@ -23,13 +23,18 @@ highlight = true
;styles[] = static/styles/custom2.css
;scripts = static/styles/scripts.css
+[bbcode]
;bbtags[quote] = "{param}
"
-[login]
+[admin]
force_login = true
nick = demo
pass = demo
+[visitors]
+;visitor[user] = pass
+;visitor[user] = pass
+
[system]
system_name = blog
version = 1.05
diff --git a/index.php b/index.php
index 9ff86dc..e6a0a03 100644
--- a/index.php
+++ b/index.php
@@ -290,7 +290,7 @@ if(!empty($scripts)){