From 01e9f212c0c1da9b5dd879c82344d5817210a773 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 21 Dec 2008 12:31:49 +0000 Subject: [PATCH] Warranty form management added, server_request() enhanced, states management added --- web/Obj/brisk.phh | 107 ++++++++++++++++++++++++++++++++++++++++++-- web/room.js | 110 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 213 insertions(+), 4 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 622132c..7728e1a 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -75,9 +75,9 @@ require_once("$DOCUMENT_ROOT/Etc/".BRISK_CONF); $G_false = FALSE; $G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 ); -$G_brisk_version = "2.1.2 - trusty"; +$G_brisk_version = "2.1.3 - trusty"; -$root_wellarr = Array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': Autenticazione, tavoli riservati e ban efficaci.', +$root_wellarr = Array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': Garanzia dal sito e stato degli utenti (guarda l\'help).', 'Se vuoi iscriverti alla Mailing List, cliccala!' ); $table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non può risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.'); @@ -105,10 +105,14 @@ Dopo che è iniziata una partita per uscirne dovete chiedere agli altri gi
Comandi della chat
/nick <nuovo_nickname> - cambio di nickname
/tav <frase di invito> - invito per gli altri giocatori al tavolo dove si è seduti +
/st <stato> - cambia l\'icona associata al tuo user; stato può valere: \\"normale\\", \\"fuori\\", \\"pausa\\", \\"cibo\\", \\"cane\\", \\"lavoro\\" oppure \\"sigaretta\\" +
/garante - se si è autenticati permette di garantire per un utente fidato '; +// + $G_room_about= '
@@ -126,6 +130,13 @@ function xcape($s) return (str_replace($from, $to, htmlentities($s,ENT_COMPAT,"UTF-8"))); } +function xcapelt($s) +{ + $from = array ( '\\', '|' ); + $to = array ( '\\\\', '\\|' ); + + return (str_replace($from, $to, $s)); +} class Card { var $value; /* 0 - 39 card value */ @@ -591,6 +602,17 @@ class Table { // User flags define(USER_FLAG_AUTH, 0x02); +// user status +define(USER_FLAG_S_NORM, 0x000); // done +define(USER_FLAG_S_PAU, 0x100); // done +define(USER_FLAG_S_OUT, 0x200); // done +define(USER_FLAG_S_DOG, 0x300); // done +define(USER_FLAG_S_EAT, 0x400); // done +define(USER_FLAG_S_WRK, 0x500); // done +define(USER_FLAG_S_SMK, 0x600); // done + +define(USER_FLAG_S_ALL, 0xf00); // done + class User { var $name; // name of the user var $sess; // session of the user @@ -1455,7 +1477,14 @@ class Room { $to_all = show_notify($msg, 0, "chiudi", 400, 120); } while (0); } // /alarm chat command - + else if (strncmp($msg, "/garante", 8) == 0) { + if ($user->flags & USER_FLAG_AUTH) { + $to_user = sprintf('authbox(300,200);'); + } + else { + $to_user = sprintf('chatt_sub("%s", [2, "%s"],"Per autenticare qualcuno devi a tua volta essere autenticato.");', $dt, NICKSERV); + } + } else if (strncmp($msg, "/nick ", 6) == 0) { log_main("chatt_send BEGIN"); @@ -1509,6 +1538,46 @@ class Room { } while (0); } // nick chat command + else if (strncmp($msg, "/st ", 4) == 0) { + log_main("chatt_send BEGIN"); + + do { + $st_str = substr($msg, 4); + + if (strcasecmp($st_str, "normale") == 0) { + $st = USER_FLAG_S_NORM; + } + else if (strcasecmp($st_str, "pausa") == 0) { + $st = USER_FLAG_S_PAU; + } + else if (strcasecmp($st_str, "fuori") == 0) { + $st = USER_FLAG_S_OUT; + } + else if (strcasecmp($st_str, "cane") == 0) { + $st = USER_FLAG_S_DOG; + } + else if (strcasecmp($st_str, "cibo") == 0) { + $st = USER_FLAG_S_EAT; + } + else if (strcasecmp($st_str, "lavoro") == 0) { + $st = USER_FLAG_S_WRK; + } + else if (strcasecmp($st_str, "sigaretta") == 0) { + $st = USER_FLAG_S_SMK; + } + else { + $to_user = sprintf('chatt_sub("%s", [2,"%s"],"Questo stato non esiste.");', $dt, NICKSERV); + break; + } + + log_main("chatt_send start set"); + if (($user->flags & USER_FLAG_S_ALL) != $st) { + $update_room = TRUE; + $user->flags = ($user->flags & ~USER_FLAG_S_ALL) | $st; + } + } while (0); + } // nick chat command + else { // normal chat line if ($curtime < ($user->chat_ban + $user->chat_dlt)) { $only_you = TRUE; @@ -2951,5 +3020,37 @@ function sharedmem_sz($tok) return ($shm_sz); } +class Warrant { + function lock_data() + { + GLOBAL $sess; + + if (($tok = @ftok(FTOK_PATH."/warrant", "B")) == -1) { + echo "FTOK FAILED"; + exit; + } + // echo "FTOK ".$tok."
"; + if (($res = sem_get($tok)) == FALSE) { + echo "SEM_GET FAILED"; + exit; + } + if (sem_acquire($res)) { + log_lock("LOCK room"); + return ($res); + } + else + return (FALSE); + } + + function unlock_data($res) + { + GLOBAL $sess; + + log_lock("UNLOCK room"); + + return (sem_release($res)); + } + +} ?> diff --git a/web/room.js b/web/room.js index 000ce38..868c4d6 100644 --- a/web/room.js +++ b/web/room.js @@ -3,10 +3,55 @@ */ +function state_add(flags) +{ + var content = ""; + var st, name = ""; + var tit = ""; + + if ((flags & 0xf00) != 0) { + st = flags & 0xf00; + switch (st) { + case 0x100: + name = "st_pau.png"; + tit = "in pausa"; + break; + case 0x200: + name = "st_out.png"; + tit = "fuori"; + break; + case 0x300: + name = "st_dog.png"; + tit = "cane a spasso"; + break; + case 0x400: + name = "st_eat.png"; + tit = "a mangiare"; + break; + case 0x500: + name = "st_wrk.png"; + tit = "a lavoro"; + break; + case 0x600: + name = "st_smoke.png"; + tit = "si sta fumando una sigaretta (e facendosi venire il cancro)"; + break; + default: + break; + } + if (name != "") { + content += ''; + } + } + + return content; +} + function j_stand_cont(data) { var i; var content; + var st, name = ""; content = ''; for (i = 0 ; i < data.length ; i++) { @@ -27,6 +72,7 @@ function j_stand_cont(data) if (data[i][0] & 0x01) content += ''; + content += state_add(data[i][0]); content += ''; if ((i % 4) == 3) @@ -67,6 +113,7 @@ function j_tab_cont(table_idx, data) if (data[i][0] & 0x01) content += ''; + content += state_add(data[i][0]); content += '
'; } @@ -103,7 +150,7 @@ function j_login_manager(form) else { // console.log("richiesta token"); /* richiede token */ - token = server_request('getchallenge|'+encodeURIComponent(form.elements['nameid'].value)); + token = server_request('mesg', 'getchallenge', 'cli_name', encodeURIComponent(form.elements['nameid'].value)); tokens = token.split('|'); // console.log('XX token: '+token); @@ -148,3 +195,64 @@ function login_init() menu_init(); login_formtext_hilite(); } + +function warrant_formtext_hilite() +{ + formtext_hilite($("nameid")); + formtext_hilite($("emailid")); + formsub_hilite($("subid")); + formsub_hilite($("cloid")); +} + + +function j_check_email(email) +{ + if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) + return (true); + return (false); +} + +function j_authbox(form) +{ + var no; + + if (form.elements['realsub'].value == "chiudi") { + $('authbox').style.visibility = "hidden"; + return (false); + } + + if (form.elements['name'].value == '' || j_check_email(form.elements['email'].value) == false) + no = new notify(gst, "
I campi user e/o e-mail non sono validi;
correggeteli per favore.", 1, "chiudi", 280, 100); + else { + // submit the request + token = server_request('mesg', 'warranty', + 'cli_name', encodeURIComponent(form.elements['name'].value), + 'cli_email', encodeURIComponent(form.elements['email'].value) ); + if (token == "1") { + $('authbox').style.visibility = "hidden"; + form.elements['name'].value = ""; + form.elements['email'].value = ""; + return (false); + } + } + + return (false); +} + +function authbox(w, h) +{ + var box; + + box = $('authbox'); + + box.style.zIndex = 200; + box.style.width = w+"px"; + box.style.marginLeft = -parseInt(w/2)+"px"; + box.style.height = h+"px"; + box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop; + + warrant_formtext_hilite(); + + box.style.visibility = "visible"; + $("nameid").focus(); +} -- 2.17.1