From e46f1de22c5ca737d10d22bdad64034ef104f07e Mon Sep 17 00:00:00 2001
From: Chtixof
Date: Sat, 11 Apr 2015 00:42:20 +0200
Subject: [PATCH] README updated and corrections
---
README.md | 18 +++++++++++++++---
sources/index.php | 16 ++++++++++++----
sources/post.php | 2 +-
sources/server.php | 2 +-
4 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index e08dcee..a11e46f 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,10 @@ It is based on [wojtek77/chat](https://github.com/wojtek77/chat), itself based o
## Features
- No need for users to register. Just need the web address.
-- On connection, the page is feeded with the 50 last messages.
-- Optional *get* arguments to specify the user name and the room.
+- On connection, the page is feeded with the 50 last messages of the day
+- Args are in the URL as *get* arguments, so that you can share the URL or make it a favorite
Example : `https://yourdomain.org/minchat/?room=Living&name=John`
-- Mono room (for now)
+- Optionaly multi room
## Installation
### On Yunohost
@@ -17,5 +17,17 @@ Via the admin web console, type in:
Or on ssh : `sudo yunohost app install https://github.com/chtixof/minchat_ynh`
### Otherwise
Download, unzip and just copy the content of the `sources` folder to any folder of your web site.
+## Setup
+On the application folder of your site, edit the file `conf/setup.ini`. The interesting parameter is `auth` that indicates which user is authorized to which room.
+
+In this example `auth = John:Game,Mary:Game,John:Family,Tim:Family,admin:,:Public`,
+- John can access the Game room, the Family room and the Public room
+- Mary can access the Game room and the Public room
+- Tim can access the Family room and the Public room
+- admin can access all rooms
+- other users can only acccess the Public room
+
+If `auth` is not set (default), there is a single unnamed room, opened to all users.
+
## Screen shot
![screenshot](https://raw.githubusercontent.com/chtixof/databank/master/minchat_ynh/minchat_ynh_screenshot01.gif)
\ No newline at end of file
diff --git a/sources/index.php b/sources/index.php
index ee38b6c..a497a3d 100644
--- a/sources/index.php
+++ b/sources/index.php
@@ -49,13 +49,19 @@ if (isset($_REQUEST['room'])) {
$room = stripslashes(htmlspecialchars($_REQUEST['room']));
}
+// no auth = single room = no room specified
+if ($auth[0]==""){$room="";}
+
// check args
if ($name.$room=="") {
// no args
$prompt = "Please fill in the form to continue:";
} else {
if ($name=="") {$prompt = "User name missing.";}
- else if ($room=="") {$prompt="Room missing.";}
+ else if ($room=="") {
+ if ($auth[0]==""){$prompt="";}
+ else {$prompt="Room missing.";}
+ }
else if (in_array($name.":".$room,$auth)) {$prompt="";}
else if (in_array(":".$room,$auth)) {$prompt="";}
else if (in_array($name.":",$auth)) {$prompt="";}
@@ -79,9 +85,11 @@ if ($name.$room=="") {
echo '
';
} else {
deleteOldHistory();
diff --git a/sources/post.php b/sources/post.php
index 3a397c9..f6e2243 100644
--- a/sources/post.php
+++ b/sources/post.php
@@ -25,7 +25,7 @@ $name = isset($_POST['name']) ? $_POST['name'] : '';
$room = isset($_POST['room']) ? $_POST['room'] : '';
$delay = isset($_POST['delay']) ? $_POST['delay'] : '';
-if ($text === '' || $name === '' || $room === '' || $delay === '') return;
+if ($text === '' || $name === '' || $delay === '') return;
$isApc = extension_loaded('apc');
diff --git a/sources/server.php b/sources/server.php
index 1855d58..c8820e4 100644
--- a/sources/server.php
+++ b/sources/server.php
@@ -23,7 +23,7 @@ function vvv($var, & $result = null, $is_view = true)
$id = isset($_POST['id']) ? $_POST['id'] : '';
$room = isset($_POST['room']) ? $_POST['room'] : '';
-if ($id === '' || $room === '') return;
+if ($id === '' ) return;
$isApc = extension_loaded('apc');
$cache = $isApc ? apc_fetch('chat') : @unserialize(file_get_contents('./history/'.$room.'cache2100-01-01'));