diff --git a/sources/conf/setup.ini b/sources/conf/setup.ini
new file mode 100644
index 0000000..a27ae8a
--- /dev/null
+++ b/sources/conf/setup.ini
@@ -0,0 +1,14 @@
+; how often get data from serwer
+interval = 2500 ; milliseconds
+
+; extra time for cache to secure transmission delay
+cache = 60000 ; milliseconds
+
+; authorized user:room (comma separated)
+; caution: names must be valid for file names !
+; :room with no user name is a room opened to any user name
+; user: with no room name is a user allowed to every room
+; default = single unnamed room and free user names
+; Example:
+;auth = John:Game,Mary:Game,John:Family,Tim:Family,admin:,:Public
+
diff --git a/sources/index.php b/sources/index.php
index 49749de..ee38b6c 100644
--- a/sources/index.php
+++ b/sources/index.php
@@ -1,5 +1,4 @@
' . print_r($v, true) . '';
@@ -20,79 +19,80 @@ function vvv($var, & $result = null, $is_view = true)
if ($is_view) v($result);
}
-
-
-function loginForm() {
- echo'
-
-
-
- ';
-}
-
-function getSetup($key = null) {
- $arr = parse_ini_file('setup.ini');
- return isset($key) ? $arr[$key] : $arr;
+function getarr($arr,$key,$default) {
+ return isset($arr[$key]) ? $arr[$key] : $default;
}
function deleteOldHistory() {
- $expireHistory = getSetup('expire_history');
- $expireDate = date('Y-m-d', strtotime("-$expireHistory day"));
+ $expireDate = date('Y-m-d', strtotime("-1 day"));
foreach (glob('./history/*') as $f) {
- if (basename($f) < $expireDate) {
+ if (substr(basename($f),-10) < $expireDate) {
unlink($f);
}
}
}
//-------------------------
+// init setup.ini parms
+ $ini = parse_ini_file('conf/setup.ini');
+ $interval= getarr($ini,'interval',2500);
+ $delay= $interval+getarr($ini,'cache',60000);
+ $auth= explode(',',getarr($ini,'auth',''));
-session_start();
-
-if (isset($_GET['logout'])) {
- session_destroy();
- header("Location: ./"); //Redirect the user
-}
-
+// read args
+$name="";
if (isset($_REQUEST['name'])) {
- if ($_REQUEST['name'] != "") {
- $_SESSION['name'] = stripslashes(htmlspecialchars($_REQUEST['name']));
- } else {
- echo 'Please type in a name';
- }
+ $name = stripslashes(htmlspecialchars($_REQUEST['name']));
}
+$room="";
if (isset($_REQUEST['room'])) {
- $room = $_REQUEST['room'];
-} else {
- $room = "";
+ $room = stripslashes(htmlspecialchars($_REQUEST['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 (in_array($name.":".$room,$auth)) {$prompt="";}
+ else if (in_array(":".$room,$auth)) {$prompt="";}
+ else if (in_array($name.":",$auth)) {$prompt="";}
+ else {$prompt="User not authorized to this room.";}
+}
+
?>
-
+
- Chat - Customer Module
+ Minchat - room
';
+ echo $err;
+ echo $prompt;
+ echo '
';
} else {
+ deleteOldHistory();
+// Enter the room
?>