+0.14.0 ("spawn" branch) - xx/06/2008
+ White space between logo and tables under IE 6 & 7 bug fixed.
+ Creation of tmpfs subdirs if not exists fixed.
+ Input encoding detection management fixed.
+ Help content error fixed.
+ All *printf funcs verified (args and formats) and fixed when needed.
+ All "align" attributes removed from "table" tags.
+ Content-type from 'application/xml; charset="utf-8"'
+ to 'text/plain; charset="utf-8"' as index_rd.php output.
+
+ Topbanner management moved to .conf file.
+ Unsessioned requests mode added to index_wr.php.
+ User statistics.
+ Refactored menu to supprt full tree.
+ Meeting links added to menu.
+ Roadmap and support entry added to menu.
+
+0.13.4 ("spawn" branch) - 17/05/2008
+ Serialization now includes postaction bug fixed.
+ "Roadmap" and "whysupport" main menu items added.
+ Ticker keep users list opened when wagon implode bug fixed.
+ Keeped cards still on table when table restart bug fixed.
+
+0.13.3 ("spawn" branch) - 4/05/2008
+ Tav button added.
+ Raccomandations for firefox users.
+ Chat scroll enhancement.
+ Troll defence.
+
+0.13.2 ("spawn" branch) - 21/04/2008
+ Black list added.
+ Cache-Control 'no-store flag' added.
+ Scroll for standup area and top position of proxhr class adjusted.
+ Behavior of ticker changed.
+
+0.13.1 ("spawn" branch) - 20/04/2008
+ Copyrights updated.
+ addEvent and removeEvent functions added.
+ Ticker added.
+ G_is_local var to prevent remote site access when
+ you are in unconnected devel environment (on the train :).
+ Set to 25% the width of each td for the tables table.
+ chatt_send function refactored.
+ Functions show_room, table_content, standup_content moved into Room class.
+
+0.13.0 ("spawn" branch) - 19/04/2008
+ Add ftokk_path var to allow temporary move of the ftok dir.
+
+0.12.0 ("spawn" branch) - 30/03/2008
+ Sitdown disable when shutdowning.
+ Topbanner added.
+ "alert" command added.
+
+0.11.0 ("spawn" branch) - 30/03/2008
+ Pro-site configuration file added.
+ White-list for proxy access added.
+
+0.10.8 ("spawn" branch) - 27/03/2008
+ Forumolimpia supporter images added.
+
+0.10.7 ("spawn" branch) - 27/03/2008
+ Proxyscan to check (and deny) proxy connections.
+ Chat ban: first implementation.
+
+0.10.6 ("spawn" branch) - 23/03/2008
+ "nobohide" class for img added.
+ Big img for supporters and sponsors added.
+
+0.10.5 ("spawn" branch) - 23/03/2008
+ Factorized user reset (and comm array clean added).
+
+0.10.4 ("spawn" branch) - 23/03/2008
+ Flush of command when the table start.
+ comm array to 18 elements.
+
+0.10.3 ("spawn" branch) - 20/03/2008
+ Disabled comm flush optimization.
+ Critical log type added.
+
+0.9.3 ("spawn" branch) - 19/03/2008
+ Quasi atomical installation procedure.
+ cards_hidetake(win) dumb function removed.
+ New shared mem management added.
+
+0.9.2 ("spawn" branch) - 16/03/2008
+ BRISK_SINGLE_SESS and BRISK_SINGLE_DEBUG added.
+
+0.9.1 ("spawn" branch) - 16/03/2008
+ Char "@" before all ftok functions.
+ Briskin5::load_data checked.
+
+0.0.9 ("spawn" branch) - 13/03/2008
+ Show_room function with new step arg.
+ Table recovery and external garbage_manager call recovery.
+
+0.0.8 ("spawn" branch) - 07/03/2008
+ Correct touch index for ftok from 1-100 to 0-99
+ Unlock_data to garbage_manager added.
+ UnescapeHTML func added.
+
+0.0.7 ("spawn" branch) - 16/02/2008
+ Log path from /tmp to LEGAL_PATH.
+
+0.0.6 ("spawn" branch) - 16/02/2008
+ BRISKIN5_PLAYERS_N sedify.
+ Install ftok file for tables.
+ Preload.js now must manage trees and not flat img dir.
+ Reduced SHM dim and send a parameter to js to have status consistency.
+
+0.0.5 ("spawn" branch) - 12/02/2008
+ Log refactoring.
+ Deep refactoring of garbage_manager func.
+
+0.0.4 ("spawn" branch) - 07/02/2008
+ Garbage_manager updated.
+
+0.0.3 ("spawn" branch) - 03/02/2008
+ Clean of table's data.
+
+0.0.2 ("spawn" branch) - 26/01/2008
+ Cookiepath added in commons.js.
+ Table_idx via cookie, removed from index_rd.php call.
+ Location to briskin5.
+ Recovery from table supported.
+ First support to return to index.php.
+ Normalized log.
+ room_join_wakeup func added.
+ room_wakeup renamed with table_wakeup.
+ ftok in briskin5 constructor.
+ Dstroy_data and chatt_send funcs added.
+
+0.0.1 ("spawn" branch) - 19/01/2008
+ Obj and briskin5 dirs added.
+ Renamed class Brisco to Room.
+ Split standard constructors to be able to have multiple constructors.
+ Spawning action when the table is completed added.
+
+0.8.3 - 30/12/2007
+ Temporary advise added.
+ Webstart layout enhancement.
+
+0.8.2 - 09/10/2007
+ Start menu added..
+
0.8.1 - 30/9/2007
Auction points bug was fixed.
IE rendering bug was fixed.
# Defaults
#
n_players=3
-brisk_debug="TRUE"
-ftok_path="/var/lib/brisk"
+brisk_debug="0xffff"
web_path="$HOME/brisk"
+legal_path="$HOME/brisk-priv"
+ftok_path="$HOME/brisk-priv/ftok"
+proxy_path="$HOME/brisk-priv/proxy"
web_only="FALSE"
+brisk_conf="brisk.conf.pho"
-if [ -f $HOME/.brisk_install ]; then
- . $HOME/.brisk_install
+if [ -f $HOME/.spawn_install ]; then
+ . $HOME/.spawn_install
fi
if [ "x$cookie_path" = "x" ]; then
cookie_path=$web_path
echo " -l dir where save logs - def. \"$legal_path\""
echo " -y dir where place proxy files - def. \"$proxy_path\""
echo " -c cookie path - def. \"$cookie_path\""
+ echo " -C config filename - def. \"$brisk_conf\""
echo
}
return 0
}
+function searchetc() {
+ local dstart dname pp
+ dstart="$1"
+ dname="$2"
+
+ pp="$dstart"
+ while [ "$pp" != "/" ]; do
+ if [ -d "$pp/$dname" ]; then
+ echo "$pp/$dname"
+ return 0
+ fi
+ pp="`dirname "$pp"`"
+ done
+
+ return 1
+}
+
#
# MAIN
#
-k*) ftok_path="`get_param "-k" "$1" "$2"`"; sh=$?;;
-y*) proxy_path="`get_param "-y" "$1" "$2"`"; sh=$?;;
-c*) cookie_path="`get_param "-c" "$1" "$2"`"; sh=$?;;
+ -C*) brisk_conf="`get_param "-C" "$1" "$2"`"; sh=$?;;
-l*) legal_path="`get_param "-l" "$1" "$2"`"; sh=$?;;
-W) web_only="TRUE";;
-h) usage $0; exit 0;;
echo "web_only=\"$web_only\""
) > "$outconf"
fi
+#
+# Pre-check
+#
+# check for etc path existence
+dsta="`dirname "$web_path"`"
+etc_path="`searchetc "$dsta" Etc`"
+if [ $? -ne 0 ]; then
+ echo "Etc directory not found"
+ exit 1
+fi
+
#
# Installation
#
+ftokk_path="${ftok_path}k"
+
if [ $n_players -ne 3 -a $n_players -ne 5 ]; then
echo "n_players ($n_players) out of range (3|5)"
exit 1
fi
if [ "$web_only" = "FALSE" ]; then
- if [ ! -d $ftok_path ]; then
+ if [ ! -d "$ftok_path" -a ! -d "$ftokk_path" ]; then
echo "ftok_path (\"$ftok_path\") not exists"
exit 2
fi
- touch $ftok_path/spy.txt >/dev/null 2>&1
+ if [ -d "$ftok_path" -a -d "$ftokk_path" ]; then
+ echo "ftok_path (\"$ftok_path\") and ftokk_path (\"$ftokk_path\") exist, cannot continue"
+ exit 4
+ fi
+ if [ -d "$ftok_path" ]; then
+ mv "$ftok_path" "$ftokk_path"
+ fi
+ touch $ftokk_path/spy.txt >/dev/null 2>&1
if [ $? -ne 0 ]; then
- echo "ftok_path (\"$ftok_path\") write not allow."
+ echo "ftokk_path (\"$ftokk_path\") write not allowed."
exit 3
fi
- rm $ftok_path/spy.txt
+ rm $ftokk_path/spy.txt
# create the fs subtree to enable ftok-ing
- touch ${ftok_path}/main
- chmod 666 ${ftok_path}/main
+ touch ${ftokk_path}/main
+ chmod 666 ${ftokk_path}/main
+ for i in `seq 0 99`; do
+ touch ${ftokk_path}/table$i
+ chmod 666 ${ftokk_path}/table$i
+ done
fi
-install -d $web_path
-install -m 644 web/*.{php,phh,css,js,mp3,swf} ${web_path}
+install -d ${web_path}__
+for i in `find web -type d | grep -v /CVS | sed 's/^....//g'`; do
+ install -d ${web_path}__/$i
+done
+
+for i in `find web -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' | grep -v /CVS | sed 's/^....//g'`; do
+ install -m 644 web/$i ${web_path}__/$i
+done
+
cd web
-find . -name '.htaccess' -exec install -m 644 {} ${web_path}/{} \;
-cd -
+find . -name '.htaccess' -exec install -m 644 {} ${web_path}__/{} \;
+cd - >/dev/null 2>&1
if [ $n_players -eq 5 ]; then
send_time=250
fi
# .js substitutions
-sed -i "s/PLAYERS_N *= *[0-9]\+/PLAYERS_N = $n_players/g" `find ${web_path} -type f -name '*.js' -exec grep -l 'PLAYERS_N *= *[0-9]\+' {} \;`
+sed -i "s/PLAYERS_N *= *[0-9]\+/PLAYERS_N = $n_players/g" `find ${web_path}__ -type f -name '*.js' -exec grep -l 'PLAYERS_N *= *[0-9]\+' {} \;`
+
+sed -i "s/^var G_send_time *= *[0-9]\+/var G_send_time = $send_time/g" `find ${web_path}__ -type f -name '*.js' -exec grep -l '^var G_send_time *= *[0-9]\+' {} \;`
+
+# .ph[pho] substitutions
+sed -i "s/define *( *PLAYERS_N, *[0-9]\+ *)/define(PLAYERS_N, $n_players)/g" `find ${web_path}__ -type f -name '*.ph*' -exec grep -l 'define *( *PLAYERS_N, *[0-9]\+ *)' {} \;`
+
+sed -i "s/define *( *BRISKIN5_PLAYERS_N, *[0-9]\+ *)/define(BRISKIN5_PLAYERS_N, $n_players)/g" `find ${web_path}__ -type f -name '*.ph*' -exec grep -l 'define *( *BRISKIN5_PLAYERS_N, *[0-9]\+ *)' {} \;`
+
+sed -i "s@define *( *FTOK_PATH,[^)]*)@define(FTOK_PATH, \"$ftok_path\")@g" `find ${web_path}__ -type f -name '*.ph*' -exec grep -l 'define *( *FTOK_PATH,[^)]*)' {} \;`
+
+sed -i "s@define *( *BRISK_DEBUG,[^)]*)@define(BRISK_DEBUG, $brisk_debug)@g" ${web_path}__/Obj/brisk.phh
-sed -i "s/^var G_send_time *= *[0-9]\+/var G_send_time = $send_time/g" `find ${web_path} -type f -name '*.js' -exec grep -l '^var G_send_time *= *[0-9]\+' {} \;`
+sed -i "s@define *( *LEGAL_PATH,[^)]*)@define(LEGAL_PATH, \"$legal_path\")@g" ${web_path}__/Obj/brisk.phh
-# .ph[ph] substitutions
-sed -i "s/define *( *PLAYERS_N, *[0-9]\+ *)/define(PLAYERS_N, $n_players)/g" `find ${web_path} -type f -name '*.ph*' -exec grep -l 'define *( *PLAYERS_N, *[0-9]\+ *)' {} \;`
+sed -i "s@define *( *PROXY_PATH,[^)]*)@define(PROXY_PATH, \"$proxy_path\")@g" ${web_path}__/Obj/brisk.phh
-sed -i "s@define *( *FTOK_PATH,[^)]*)@define(FTOK_PATH, \"$ftok_path\")@g" `find ${web_path} -type f -name '*.ph*' -exec grep -l 'define *( *FTOK_PATH,[^)]*)' {} \;`
+sed -i "s@define *( *BRISK_CONF,[^)]*)@define(BRISK_CONF, \"$brisk_conf\")@g" ${web_path}__/Obj/brisk.phh
-sed -i "s@define *( *BRISK_DEBUG,[^)]*)@define(BRISK_DEBUG, $brisk_debug)@g" ${web_path}/brisk.phh
+sed -i "s@var \+xhr_rd_cookiepath \+= \+\"[^\"]*\";@var xhr_rd_cookiepath = \"$cookie_path\";@g" ${web_path}__/xhr.js
+sed -i "s@var \+cookiepath \+= \+\"[^\"]*\";@var cookiepath = \"$cookie_path\";@g" ${web_path}__/commons.js
-sed -i "s@define *( *LEGAL_PATH,[^)]*)@define(LEGAL_PATH, \"$legal_path\")@g" ${web_path}/brisk.phh
+if [ -d ${web_path} ]; then
+ mv ${web_path} ${web_path}.old
+fi
-sed -i "s@define *( *PROXY_PATH,[^)]*)@define(PROXY_PATH, \"$proxy_path\")@g" ${web_path}/brisk.phh
+if [ -d ../brisk-img ]; then
+ cd ../brisk-img
+ ./INSTALL.sh -w ${web_path}__
+ cd - >/dev/null 2>&1
+fi
-sed -i "s@var \+xhr_rd_cookiepath \+= \+\"[^\"]*\";@var xhr_rd_cookiepath = \"$cookie_path\";@g" ${web_path}/xhr.js
+# config file installation or diff
+if [ -f "$etc_path/$brisk_conf" ]; then
+ echo "Config file $etc_path/$brisk_conf exists."
+ echo "=== Dump the diff. ==="
+ diff -u "$etc_path/$brisk_conf" "${web_path}__""/Obj/brisk.conf-templ.pho"
+ echo "=== End dump. ==="
+else
+ echo "Config file $etc_path/$brisk_conf not exists."
+ echo "Install a template."
+ cp "${web_path}__""/Obj/brisk.conf-templ.pho" "$etc_path/$brisk_conf"
+fi
+mv ${web_path}__ ${web_path}
+if [ -d ${web_path}.old ]; then
+ rm -rf ${web_path}.old
+fi
+if [ "$web_only" = "FALSE" ]; then
+ mv "$ftokk_path" "$ftok_path"
+fi
exit 0
--- /dev/null
+Test base di funzionamento
+==========================
+v - partita avviata
+v - partita conclusa
+v - partita avviata con un quarto in piedi
+v - partita conclusa con un quarto in piedi
+
+Test del timeout della _rd
+==========================
+v - partita avviata con un giocatore freeze
+v - partita avviata con un giocatore freeze e un quarto in piedi
+v - partita avviata con tutti i giocatori freeze e un quarto in piedi
+
+Test dei resync di pagina per rientro
+=====================================
+v - partita avviata, browser killato e rientro in index.php
+v - al tavolo, browser killato e rientro in briskin5/index.php
+
+Test verifica degli stati sui browser (var mostrate in basso)
+=============================================================
+v - dal login
+v - ritorno in room dopo un kill
+v - ritorno al tavolo dopo un kill
+
+Test di chiusura della finestra del browser
+===========================================
+v - al tavolo, chiusura finestra
+v - partita avviata, chiusura finestra
+
+Varie
+=====
+v - gestione dei ban temporanei
+
+Bugfix
+======
+v - partita conclusa, garbage_manager lanciato da giocatore in room
+ index_rd_nop.php = "<?php sleep(1); exit; ?>"
+ in brisk.phh si accorcia il timeout per _rd da 20 a 3 sec
+ si prepara l'uscita da un tavolo
+ parall.
+ . cp index_rd.php index_rd_ok.php ; cp index_rd_nop.php index_rd.php ; sleep 10 ; kill -STOP <pid dei firefox> ; sleep 5 ; cp index_rd_ok.php index_rd.php
+ . si aspettano 5 sec e poi si esce dal tavolo
+ si accede da un altro browser a brisk (forzando così il garbage manager)
+ kill -CONT <pid dei firefox>
TODO
====
+
URGENT - tables spawn
+ DONE - link with photos
+ DONE - top banner in Etc file
+ DONE - spawn of a table
+ DONE - data to cookies (removed table_idx from xhr calls also)
+ DONE - set subst to shutdowner/shutdowned
+ DONE - return to index.php
+ DONE - game's token
+ DONE - recover of corrupted table data
+ DONE - closure of a table
+ DONE - flush of the table
+ DONE - security checks for right scope access
+ DONE - garbage collector management
+ DONE - recursive garbage - howto ?
+ DONE - stat & subst in browser
+ DONE - laccwr setting and exit if all players are unactive for some time
+ DONE - the list of test case
+ DONE - shm dimension
+ DONE - remove unused parts
+ DONE - move images
+ DONE - optimizations
+ DONE - cambiare titolo al tavolo
+ DONE - shutdowning lock tables
+ DONE - topbanner
+ DONE - public announcements
+ DONE - 10 sec to exit from table
+
+ FAR - inheritances
+
+ TRAIN - DONE - add again in reload
+ DONE - wag_set refact
+ DONE - filtra char speciali per title
+ DONE - chatt_send refact
+ DONE - elenco dei giocatori
+ DONE - documentazione online
+ DONE - timeout management
+ LATER - border color a muzzo
+
+ NORM - testament
+ NORM - public announcements
+ NORM - 10 sec to exit from table
+ NORM - moving label for tables click
+
+----------------- join -----------------
+ NORM - map
- NORM - pubblic announcements
NORM - restart preload img
- NORM - chat vecchie in reload
NORM - tools dir with a main and some pages where check briscola tools.
- NORM - bottoni => immagini
NORM - watchdog
- MIN - cambiare titolo al tavolo
+ NORM - chat vecchie in reload (forse)
MIDDLE TODO
===========
--- /dev/null
+#!/bin/bash
+IFS='
+'
+for f in `find | grep '\.ph[ph]$'`; do
+ echo "-- file: $f ---------------------------------------"
+ st="out"
+
+ for l in `egrep '^ *class |^} // end class|^ *function +' $f`; do
+ if [ $st = "out" ]; then
+ echo "$l" | grep -q '^ *class \+'
+ if [ $? -eq 0 ]; then
+ st="in"
+ class="`echo "$l" | sed 's/^ *class \+//g; s/ *{ *//g'`"
+ continue
+ fi
+ elif [ $st = "in" ]; then
+ echo "$l" | grep -q '^} // end class'
+ if [ $? -eq 0 ]; then
+ st="out"
+ continue
+ fi
+ fi
+
+ fun="`echo "$l" | sed 's/ *function *//g'`"
+ funame="`echo "$fun" | sed 's/ *(.*//g'`"
+ if [ $st = "out" ]; then
+ echo "ss $f - $fun sssssssssssssssssss"
+ elif [ $st = "in" ]; then
+ echo "xx $f - $class :: $fun xxxxxxxxxxxxxxxxxxxxxx"
+ if [ "$class" = "$funame" ]; then
+ # constructor case
+ egrep "new *$class" `find | grep '\.ph[ph]$'`
+ else
+ egrep -- "$class::$funame\(|->$funame\(" `find | grep '\.ph[ph]$'`
+ fi
+ echo
+ fi
+ done
+ echo --------------------------------------------------------
+done
+
+
+#grep -r '^ *function \+'
+#grep -r '^ *class' `find -name '*.ph*'`
+#grep -ir '} // end class'
\ No newline at end of file
OUTFILE=web/preload_img.js
-IMGPATH=../brisk-img/img
+IMGPATH=../brisk-img
# (
# echo '<?php'
# echo '?>'
# ) > $OUTFILE
+function imglist () {
+ ls -S `find $1 -type f -name '*.jpg' -o -name '*.png' -o -name '*.gif' | grep -v '/src_' | sort`
+}
+
rm -f $OUTFILE
(
echo "var g_preload_img_arr = new Array( "
first=1
spa=" "
-for i in `ls -S $IMGPATH/*.{jpg,png,gif} | grep -v '/src_'`; do
+ltri="`echo "$IMGPATH" | wc -c`"
+for i in `imglist $IMGPATH`; do
if [ $first -ne 1 ]; then
echo -n ", "
- if [ $ct -eq 4 ]; then
+ if [ $((ct % 2)) -eq 0 ]; then
echo
echo -n "$spa"
- ct=0
fi
else
echo -n "$spa"
fi
- outna="img/`basename $i`"
+ outna="`echo "$i" | cut -c $((ltri + 1))-`"
echo -n "\"$outna\""
ct=$((ct + 1))
first=0
done
-
+echo "CT: $ct" >&2
echo ");"
) >> $OUTFILE
sum=0
spa=" "
tot=0
-for i in `ls -S $IMGPATH`; do
+for i in `imglist $IMGPATH`; do
sz="`stat -c '%s' $IMGPATH/$i`"
tot=$((tot + sz))
done
-for i in `ls -S $IMGPATH`; do
+for i in `imglist $IMGPATH`; do
if [ $first -ne 1 ]; then
echo -n ", "
- if [ $ct -eq 8 ]; then
+ if [ $((ct % 8)) -eq 0 ]; then
echo
echo -n "$spa"
- ct=0
fi
else
echo -n "$spa"
first=0
done
+echo "CT2: $ct" >&2
+
echo ");"
) >> $OUTFILE
<FilesMatch "\.(js|css)$">
-header append Cache-Control "public, last-modified, must-revalidate"
+header append Cache-Control "public, no-store, last-modified, must-revalidate"
</FilesMatch>
<FilesMatch "\.php$">
header append Pragma "no-cache"
header append Expires "-1"
+php_value mbstring.http_input "auto"
+php_value mbstring.internal_encoding "UTF-8"
+php_flag mbstring.encoding_translation On
+php_value mbstring.func_overload "7"
</FilesMatch>
ExpiresActive On
ExpiresByType image/jpg "access plus 4 days"
--- /dev/null
+<?php
+$G_shutdown = FALSE;
+$G_room_roadmap = '<div style=\"text-align: left;\"><ul>
+<li>testing della versione beta di brisk2</li>
+<li>rilascio di brisk2</li>
+<li>inizio di brisk3 - supporto a database</li>
+<li>possibilità di autenticarsi</li>
+</ul></div>';
+$G_proxy_white_list = array();
+$G_alarm_passwd = "yourpasswd";
+$G_is_local = FALSE;
+$G_black_list = array();
+
+$G_with_topbanner = FALSE;
+$G_topbanner = '<div class="topbanner" id="topbanner" onMouseOver="show_bigpict(this, \'over\', -100, 80);" onMouseOut="show_bigpict(this, \'out\', 0, 0);">
+<a target="_blank" href="http://www.briscolachiamatamilano.it/maggiotorneo.htm">
+Torneo di briscola<br> chiamata - Milano<br> 17/05/2008</a>
+</div>
+<img class="nobohide" id="topbanner_big" src="img/bcm_tor080517.gif">';
+
+?>
--- /dev/null
+<?php
+/*
+ * brisk - brisk.phh
+ *
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+define(BRISK_CONF, "brisk.conf.pho");
+define(FTOK_PATH, "/var/lib/brisk");
+define(LEGAL_PATH, "/tmp/legal_brisk");
+define(PROXY_PATH, "/var/lib/brisk_proxy");
+define(TABLES_N, 32);
+define(PLAYERS_N, 3);
+define(MAX_POINTS, 5);
+define(MAX_PLAYERS, (20 + (PLAYERS_N * TABLES_N)));
+define(SHM_DIMS_MIN, (50000 + 10000 * TABLES_N + 15000 * MAX_PLAYERS));
+define(SHM_DIMS_MAX, SHM_DIMS_MIN + 1048576);
+define(SHM_DIMS_DLT, 65536);
+
+define(COMM_N, 18);
+define(COMM_GEN_N, 50);
+
+define(CHAT_N, 3);
+define(CHAT_ILL_TIME, 6);
+
+define(SESS_LEN, 13);
+define(STREAM_TIMEOUT, 20);
+define(EXPIRE_TIME_RD, 180);
+define(EXPIRE_TIME_SMAMMA, 360);
+define(EXPIRE_TIME_WAG, 10);
+define(WAKEUP_TIME, 12);
+// BAN_TIME da allineare anche in commons.js
+define(BAN_TIME, 900);
+define(GARBAGE_TIMEOUT, 10);
+define(NICKSERV, "<i>BriskServ</i>");
+
+define(DBG_ONL2, 0x0001);
+define(DBG_ONLY, 0x0002);
+define(DBG_MAIN, 0x0004);
+define(DBG_READ, 0x0008);
+define(DBG_REA2, 0x0010);
+define(DBG_SEND, 0x0020);
+define(DBG_LOCK, 0x0040);
+define(DBG_WRIT, 0x0080);
+define(DBG_LOAD, 0x0100);
+define(DBG_AUTH, 0x0200);
+define(DBG_CRIT, 0x0400);
+
+define(BRISK_DEBUG, 0);
+
+define(BRISK_SINGLE_DEBUG,0);
+define(BRISK_SINGLE_SESS, "");
+// define(DEBUGGING, "local");
+
+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 = "spawn-0.14.2";
+
+$root_wellarr = Array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: Più risalto a Start - Beta8.',
+ 'Se vuoi iscriverti alla <a target="_blank" href="http://www.milug.org/cgi-bin/mailman/listinfo/ml-briscola">Mailing List</a>, 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.');
+
+
+$G_room_help= '
+<div style=\\"text-align: left; padding: 8px;\\">
+<b>Descrizione</b><br>
+Questa è un\'implementazione della briscola in cinque, così come è spiegata su
+<a target=\\"_blank\\" href=\\"http://it.wikipedia.org/wiki/Briscola#Gioco_a_5\\">Wikipedia</a>; in breve è la variante con l\'asta prima sulla carta e poi sui punti.<br><br>
+<b>Configurazione del browser.</b><br>
+Occorre abilitare i cookies.<br>
+<br>
+<b>Uso del sito</b><br>
+Potete sedervi a un tavolo o rimanere in piedi.<br>
+Se al vostro tavolo si raggiungono i 5 giocatori inizia automaticamente la partita.<br>
+<br>
+<b>Partita</b><br>
+All\'inizio vengono distribuite le carte e parte l\'asta; per partecipare all\'asta, quando sarà il vostro turno, potrete scegliere se andare avanti o passare cliccando sulle icone corrispondenti. Se si arriva ai punti, scrivete nella textbox il vostro rilancio e cliccate PUNTI.<br><br>
+Chi vince l\'asta dovrà decidere il seme della carta scelta e inizierà la mano.<br>
+Per giocare le carte dovrete trascinarle nel quadrato al centro del vostro schermo.<br><br>
+Il vostro turno è sempre segnalato da una cornice verde lampeggiante intorno al quadrato al centro del vostro schermo.<br><br>
+Durante la partita, se vorrete ricaricare la pagina, usate l\'apposito bottone \\"reload\\" in basso a destra.<br>
+Dopo che è iniziata una partita per uscirne dovete chiedere agli altri giocatori di sbloccarla cliccando sul lucchetto. Se non si segue questa prassi, una volta usciti, non vi potrete sedere a nessun tavolo per '.floor(BAN_TIME/60).' minuti.
+<dl>
+<dt><b>Comandi della chat</b>
+<dd><b>/nick <i><nuovo_nickname></i></b> - cambio di nickname
+<dd><b>/tav <i><frase di invito></i></b> - invito per gli altri giocatori al tavolo dove si è seduti
+</dl>
+</div>
+';
+
+$G_room_about= '<br>
+<div id=\\"header\\" class=\\"header\\">
+ <img class=\\"nobo\\" src=\\"img/brisk_logo64.png\\">
+ briscola chiamata in salsa ajax
+</div>
+<br><b>version '.$G_brisk_version.'</b><br><br>
+Copyright 2006-2008 <a href=\\"mailto:brisk@alternativeoutput.it\\">Matteo Nastasi</a> (aka mop)<br><br>';
+
+
+function xcape($s)
+{
+ $from = array ( '\\', '@', '|' );
+ $to = array ( '\\\\', '@', '¦' );
+
+ return (str_replace($from, $to, htmlentities($s,ENT_COMPAT,"UTF-8")));
+}
+
+
+class Card {
+ var $value; /* 0 - 39 card value */
+ var $stat; /* 'bunch', 'hand', 'table', 'take' */
+ var $owner; /* (table position 0-4) */
+ // var $pos; /* Pos in hand. */
+ var $x; /* When played the X position on the table of the owner. */
+ var $y; /* When played the Y position on the table of the owner. */
+
+ function Card($value, $stat, $owner)
+ {
+ $this->value = $value;
+ $this->stat = $stat; // Card stat
+ $this->owner = $owner;
+ }
+
+ function assign($stat,$owner)
+ {
+ $this->stat = $stat; // Card stat
+ $this->owner = $owner;
+ }
+
+ function setpos($pos)
+ {
+ $this->pos = $pos;
+ }
+
+ function play($x,$y)
+ {
+ $this->stat = 'table'; // Card stat
+ $this->x = $x;
+ $this->y = $y;
+ }
+
+ function take($newown)
+ {
+ $this->stat = 'take'; // Card stat
+ $this->owner = $newown;
+ }
+} // end class Card
+
+class Table {
+ var $player;
+ var $player_n;
+ var $card;
+ var $mazzo;
+ var $gstart;
+ var $turn;
+
+ var $wag_own;
+ var $wag_com;
+ var $wag_tout;
+
+ var $asta_pla;
+ var $asta_pla_n;
+ var $asta_card;
+ var $asta_pnt;
+
+ var $mult;
+ var $points; // points array
+ var $points_n; // number of row of points
+ var $total;
+
+ var $asta_win;
+ var $briscola;
+ var $friend;
+
+ var $old_reason;
+ var $old_asta_pnt;
+ var $old_pnt;
+ var $old_win;
+ var $old_friend;
+
+ var $table_token;
+ var $table_start;
+
+ var $wakeup_time;
+
+ function Table()
+ {
+ }
+
+ function &create()
+ {
+ GLOBAL $G_false;
+
+ if (($thiz =& new Table()) == FALSE)
+ return ($G_false);
+
+ $thiz->player = array();
+ $thiz->player_n = 0;
+ $thiz->card = FALSE;
+ $thiz->asta_pla = array(); // TRUE: in auction, FALSE: out of the auction
+ $thiz->asta_pla_n= -1;
+ $thiz->asta_card = -1;
+ $thiz->asta_pnt = -1;
+ $thiz->mult = 1;
+ $thiz->points = array( );
+ $thiz->points_n = 0;
+ $thiz->total = array( 0, 0, 0, 0, 0);
+ $thiz->asta_win = -1;
+ $thiz->briscola = -1;
+ $thiz->friend = -1;
+ $thiz->turn = 0;
+
+ $thiz->wag_own = NULL;
+ $thiz->wag_com = "";
+ $thiz->wag_tout = 0;
+
+ $thiz->old_reason = "";
+ $thiz->old_asta_pnt = -1;
+ $thiz->old_pnt = -1;
+ $thiz->old_win = -1;
+ $thiz->old_friend = -1;
+
+ $thiz->table_token = "";
+ $thiz->table_start = 0;
+
+ $thiz->wakeup_time = 0;
+
+ return ($thiz);
+ }
+
+ function &clone(&$from)
+ {
+ GLOBAL $G_false;
+
+ if (($thiz =& new Table()) == FALSE)
+ return ($G_false);
+
+ $thiz->player = array();
+ for ($i = 0 ; $i < $from->player_n ; $i++)
+ $thiz->player[$i] = $from->player[$i];
+ $thiz->player_n = $from->player_n;
+ $thiz->card = $from->card;
+ $thiz->mazzo = $from->mazzo; // REVIEW
+ $thiz->gstart = $from->gstart;
+ $thiz->turn = $from->turn;
+
+ $thiz->wag_own = $from->wag_own;
+ $thiz->wag_com = $from->wag_com;
+ $thiz->wag_tout = $from->wag_taut;
+
+ $thiz->asta_pla = $from->asta_pla;
+ $thiz->asta_pla_n = $from->asta_pla_n;
+ $thiz->asta_card = $from->asta_card;
+ $thiz->asta_pnt = $from->asta_pnt;
+
+ $thiz->mult = $from->mult;
+ $thiz->points = $from->points;
+ $thiz->points_n = $from->points_n;
+ $thiz->total = $from->total;
+
+ $thiz->asta_win = $from->asta_win;
+ $thiz->briscola = $from->briscola;
+ $thiz->friend = $from->friend;
+
+ $thiz->old_reason = $from->old_reason;
+ $thiz->old_asta_pnt = $from->old_asta_pnt;
+ $thiz->old_pnt = $from->old_pnt;
+ $thiz->old_win = $from->old_win;
+ $thiz->old_friend = $from->old_friend;
+
+ $thiz->table_token = $from->table_token;
+ $thiz->table_start = $from->table_start;
+
+ $thiz->wakeup_time = $from->wakeup_time;
+
+ return ($thiz);
+ }
+
+ function &spawn(&$from)
+ {
+ GLOBAL $G_false;
+
+ if (($thiz =& new Table()) == FALSE)
+ return ($G_false);
+
+ $thiz->player_n = $from->player_n;
+ $thiz->card = &$thiz->bunch_create();
+ $thiz->mazzo = $from->mazzo;
+ $thiz->gstart = $from->gstart;
+ $thiz->turn = $from->turn;
+
+ $thiz->wag_own = $from->wag_own;
+ $thiz->wag_com = $from->wag_com;
+ $thiz->wag_tout = $from->wag_taut;
+
+ $thiz->asta_pla = $from->asta_pla;
+ $thiz->asta_pla_n = $from->asta_pla_n;
+ $thiz->asta_card = $from->asta_card;
+ $thiz->asta_pnt = $from->asta_pnt;
+
+ $thiz->mult = $from->mult;
+ $thiz->points = $from->points;
+ $thiz->points_n = $from->points_n;
+ $thiz->total = $from->total;
+
+ $thiz->asta_win = $from->asta_win;
+ $thiz->briscola = $from->briscola;
+ $thiz->friend = $from->friend;
+
+ $thiz->old_reason = $from->old_reason;
+ $thiz->old_asta_pnt = $from->old_asta_pnt;
+ $thiz->old_pnt = $from->old_pnt;
+ $thiz->old_win = $from->old_win;
+ $thiz->old_friend = $from->old_friend;
+
+ // players are rearranged in an dedicated array
+ $thiz->player = array();
+ for ($i = 0 ; $i < $from->player_n ; $i++)
+ $thiz->player[$i] = $i;
+
+ $thiz->table_token = $from->table_token;
+ $thiz->table_start = $from->table_start;
+
+ $thiz->wakeup_time = $from->wakeup_time;
+
+ return ($thiz);
+ }
+
+ function &bunch_create()
+ {
+ $ret = array();
+
+ for ($i = 0 ; $i < 40 ; $i++) {
+ $ret[$i] =& new Card($i, 'bunch', 'no_owner');
+ }
+
+ $oret = &$ret;
+ return ($oret);
+ }
+
+ function wag_set(&$user, $mesg)
+ {
+ log_main("WAG_SET");
+
+ $this->wag_own = &$user;
+ $this->wag_com = $mesg;
+ $this->wag_tout = 0;
+ }
+
+ function wag_reset($timeout)
+ {
+ log_main("WAG_RESET");
+
+ unset($this->wag_own);
+ $this->wag_own = NULL;
+ $this->wag_com = "";
+ $this->wag_tout = $timeout;
+ }
+
+ function bunch_make()
+ {
+ $ct = array(0,0,0,0,0);
+
+ mt_srand(make_seed());
+
+ for ($i = 39 ; $i >= 0 ; $i--)
+ $rest[$i] = $i;
+
+ for ($i = 39 ; $i >= 0 ; $i--) {
+ $rn = rand(0, $i);
+
+ if ($rn == 0)
+ log_main("RND ZERO");
+
+ $id = $rest[$rn];
+
+ $owner = $i % 5;
+ $this->card[$id]->assign('hand', $owner);
+
+ $rest[$rn] = $rest[$i];
+ // $pubbpos[$rn2] = $pubbpos[$i];
+ }
+ }
+
+ function init(&$userarr)
+ {
+ $this->mazzo = rand(0,PLAYERS_N-1);
+ $this->points_n = 0;
+ $this->mult = 1;
+ $this->old_win =-1;
+ $this->old_reason = "";
+ for ($i = 0 ; $i < PLAYERS_N ; $i++) {
+ $this->total[$i] = 0;
+ $user_cur = &$userarr[$this->player[$i]];
+ $user_cur->exitislock = TRUE;
+ }
+
+ log_main("table::init: ci siamo");
+ }
+
+ function game_init(&$userarr)
+ {
+ log_rd2("GSTART 4");
+
+ $this->gstart = ($this->mazzo+1) % PLAYERS_N;
+ $this->bunch_make();
+
+
+ $this->asta_pla_n = PLAYERS_N;
+ $this->asta_card = -1;
+ $this->asta_pnt = 60;
+ $this->asta_win = -1;
+ $this->briscola = -1;
+ $this->friend = -1;
+ $this->turn = 0;
+
+ for ($i = 0 ; $i < PLAYERS_N ; $i++) {
+ $this->asta_pla[$i] = TRUE;
+ $user_cur = &$userarr[$this->player[$i]];
+ $user_cur->subst = 'asta';
+ $user_cur->asta_card = -2;
+ $user_cur->asta_pnt = -1;
+ $user_cur->handpt = $this->hand_points($i);
+ // SEE function calculate_points(&$table)
+ }
+ }
+
+ function game_next()
+ {
+ $this->mazzo = ($this->mazzo + 1) % PLAYERS_N;
+ }
+
+ function getPlayer($idx)
+ {
+ return ($this->player[$idx]);
+ }
+
+ function setPlayer($idx, $player)
+ {
+ $this->player[$idx] = $player;
+ }
+
+ function user_add($idx)
+ {
+ $this->player[$this->player_n] = $idx;
+ $this->player_n++;
+
+ return ($this->player_n - 1);
+ }
+
+ function user_rem(&$room, &$user)
+ {
+ $tabpos = $user->table_pos;
+
+ /* verifico la consistenza dei dati */
+ if ($room->user[$this->player[$tabpos]] == $user) {
+
+ /* aggiorna l'array dei giocatori al tavolo. */
+ for ($i = $tabpos ; $i < $this->player_n-1 ; $i++) {
+ $this->player[$i] = $this->player[$i+1];
+ $user_cur = &$room->user[$this->player[$i]];
+ $user_cur->table_pos = $i;
+ }
+ $this->player_n--;
+ }
+ else {
+ log_main("INCONSISTENCY ON TABLE.");
+ }
+ }
+
+ function hand_points($idx)
+ {
+ GLOBAL $G_all_points;
+
+ $tot = 0;
+
+ for ($i = 0 ; $i < 40 ; $i++) {
+ if ($this->card[$i]->owner != $idx)
+ continue;
+
+ $ctt = $this->card[$i]->value % 10;
+ $tot += $G_all_points[$ctt];
+ }
+
+ return ($tot);
+ }
+
+ function exitlock_show(&$userarr, $table_pos)
+ {
+ $ct = $this->exitlock_calc(&$userarr, $table_pos);
+
+ $ret = sprintf('exitlock_show(%d, %s);', $ct,
+ ($userarr[$this->player[$table_pos]]->exitislock ? 'true' : 'false'));
+ return ($ret);
+ }
+
+ function exitlock_calc(&$userarr, $table_pos)
+ {
+ $ct = 0;
+
+ for ($i = 0 , $ct = 0 ; $i < PLAYERS_N ; $i++) {
+ if ($userarr[$this->player[$i]]->exitislock == FALSE)
+ $ct++;
+ }
+
+ return ($ct);
+ }
+} // end class Table
+
+class User {
+ var $name; // name of the user
+ var $sess; // session of the user
+ var $ip; // ip of the user
+ var $lacc; // last access (for the cleanup)
+ var $laccwr; // last access (for the cleanup)
+ var $bantime; // timeout to temporary ban
+ var $stat; // status (outdoor, room, table, game, ...)
+ var $subst; // substatus for each status
+ var $step; // step of the current status
+ var $trans_step; // step to enable transition between pages (disable == -1)
+ var $comm; // commands array
+ var $asta_card; //
+ var $asta_pnt; //
+ var $handpt; // Total card points at the beginning of the current hand.
+ var $exitislock; // Player can exit from the table ?
+ var $table; // id of the current table (if in table state)
+ var $table_pos; // idx on the table
+ var $table_token;// token that identify a game on a table
+ var $the_end; // Flag to change the end of the session
+
+ var $chat_lst; // Last chat line
+ var $chattime; // Array of chat times
+ var $chat_cur; // Current chat line number
+ var $chat_ban; // Time for ban chat
+ var $chat_dlt; // Delta t for ban
+ function User() {
+ }
+
+ function &create($name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
+ GLOBAL $G_false;
+
+ if (($thiz =& new User()) == FALSE)
+ return ($G_false);
+
+ $thiz->name = $name;
+ $thiz->sess = $sess;
+ $thiz->ip = $ip;
+ $thiz->lacc = time();
+ $thiz->laccwr = time();
+ $thiz->bantime = 0;
+ $thiz->stat = $stat;
+ $thiz->subst = $subst;
+ $thiz->step = 1;
+ $thiz->trans_step = -1;
+ $thiz->comm = array();
+ $thiz->asta_card = -2;
+ $thiz->asta_pnt = -1;
+ $thiz->handpt = -1;
+ $thiz->exitislock = TRUE;
+
+ $thiz->chattime = array_fill(0, CHAT_N, 0);
+ $thiz->chat_cur = 0;
+ $thiz->chat_lst = "";
+ $thiz->chat_ban = 0;
+ $thiz->chat_dlt = 0;
+
+ $thiz->table = $table;
+ $thiz->table_pos = -1;
+ $thiz->table_token = "";
+
+ return ($thiz);
+ }
+
+ function &clone(&$from)
+ {
+ GLOBAL $G_false;
+
+ if (($thiz =& new User()) == FALSE)
+ return ($G_false);
+
+ $thiz->name = $from->name;
+ $thiz->sess = $from->sess;
+ $thiz->ip = $from->ip;
+ $thiz->lacc = $from->lacc;
+ $thiz->laccwr = $from->laccwr;
+ $thiz->bantime = $from->bantime;
+ $thiz->stat = $from->stat;
+ $thiz->subst = $from->subst;
+ $thiz->step = $from->step;
+ $thiz->trans_step = $from->trans_step;
+ $thiz->comm = array();
+
+ $i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N));
+ for ($i = $i_start ; $i < $from->step ; $i++) {
+ $ii = $i % COMM_N;
+ $thiz->comm[$ii] = $from->comm[$ii];
+ }
+ $thiz->asta_card = $from->asta_card;
+ $thiz->asta_pnt = $from->asta_pnt;
+ $thiz->handpt = $from->handpt;
+ $thiz->exitislock = $from->exitislock;
+
+ $thiz->chattime = array();
+ for ($i = 0 ; $i < CHAT_N ; $i++)
+ $thiz->chattime[$i] = $from->chattime[$i];
+ $thiz->chat_cur = $from->chat_cur;
+ $thiz->chat_lst = $from->chat_lst;
+ $thiz->chat_ban = $from->chat_ban;
+ $thiz->chat_dlt = $from->chat_dlt;
+
+ $thiz->table = $from->table;
+ $thiz->table_pos = $from->table_pos;
+ $thiz->table_token = $from->table_token;
+ $thiz->the_end = $from->the_end;
+
+ return ($thiz);
+ }
+
+ function &spawn(&$from, $table, $table_pos)
+ {
+ GLOBAL $G_false;
+
+ if (($thiz =& new User()) == FALSE)
+ return ($G_false);
+
+ $thiz->name = $from->name;
+ $thiz->sess = $from->sess;
+ $thiz->ip = $from->ip;
+ $thiz->lacc = $from->lacc;
+ $thiz->laccwr = $from->laccwr;
+ $thiz->bantime = $from->bantime;
+ $thiz->stat = $from->stat;
+ $thiz->subst = $from->subst;
+ $thiz->step = $from->step;
+ $thiz->trans_step = $from->trans_step;
+ $thiz->comm = array();
+
+ /*
+ $i_start = (1 > ($from->step - COMM_N) ? 1 : ($from->step - COMM_N));
+ for ($i = $i_start ; $i < $from->step ; $i++) {
+ log_wr("TRY PUSH:".$i);
+ $ii = $i % COMM_N;
+ $thiz->comm[$ii] = $from->comm[$ii];
+ }
+ */
+ $thiz->asta_card = $from->asta_card;
+ $thiz->asta_pnt = $from->asta_pnt;
+ $thiz->handpt = $from->handpt;
+ $thiz->exitislock = $from->exitislock;
+ $thiz->the_end = $from->the_end;
+
+ $thiz->chattime = array_fill(0, CHAT_N, 0);
+ $thiz->chat_cur = 0;
+ $thiz->chat_lst = "";
+ $thiz->chat_ban = 0;
+ $thiz->chat_dlt = 0;
+
+ $thiz->table = $table;
+ $thiz->table_pos = $table_pos;
+ $thiz->table_token = $from->table_token;
+
+ return ($thiz);
+ }
+
+ function stat_set($stat) {
+ log_main("sess: [".$this->sess. "] NEW STAT: [".$stat."]");
+ $this->stat = "$stat";
+
+ /*
+ if (validate_sess($this->sess)) {
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
+ $fp = fopen(PROXY_PATH."/".$this->sess.".stat", 'w');
+ fwrite($fp, sprintf("%s\n",$this->stat));
+ fclose($fp);
+ }
+ */
+ }
+
+ function step_set($step) {
+ $this->step = $step;
+
+ do {
+ if (validate_sess($this->sess) == FALSE)
+ break;
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
+ if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE)
+ break;
+ fwrite($fp, pack("l",$this->step), 4);
+ fclose($fp);
+
+ return (TRUE);
+ } while (0);
+
+ return (FALSE);
+ }
+
+ function step_inc($delta = 1) {
+ $this->step += $delta;
+
+ if (validate_sess($this->sess)) {
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
+ $fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w');
+ fwrite($fp, pack("l",$this->step), 4);
+ fclose($fp);
+
+ return (TRUE);
+ }
+
+ return (FALSE);
+ }
+
+ function reset() {
+ $curtime = time();
+ log_legal($curtime, $this->sess, $this->name, "STAT:LOGOUT", '');
+
+ $tmp_sess = $this->sess;
+ $this->sess = "";
+ step_unproxy($tmp_sess);
+ $this->name = ""; // OK here
+ while (array_pop($this->comm) != NULL);
+ $this->step = 0;
+ $this->chattime = array_fill(0, CHAT_N, 0);
+ $this->chat_cur = 0;
+ $this->chat_lst = "";
+ $this->chat_ban = 0;
+ $this->chat_dlt = 0;
+ $this->the_end = FALSE;
+ }
+} // end class User
+
+
+function step_get($sess) {
+ $fp = FALSE;
+ do {
+ if (validate_sess($sess) == FALSE)
+ break;
+
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
+ if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE)
+ break;
+ if (($s = fread($fp, 4)) == FALSE)
+ break;
+ if (strlen($s) != 4)
+ break;
+ $arr = unpack('l', $s);
+ fclose($fp);
+
+ // log_rd2("A0: ".$arr[0]." A1: ".$arr[1]);
+ return ($arr[1]);
+ } while (0);
+
+ if ($fp != FALSE)
+ fclose($fp);
+
+ log_rd2("STEP_GET: return false ");
+
+ return (FALSE);
+}
+
+function step_unproxy($sess) {
+ log_rd2("UNPROXY: ".PROXY_PATH."/".$sess.".step");
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
+ @unlink(PROXY_PATH."/".$sess.".step");
+}
+
+
+class Room {
+ var $user;
+ var $table;
+ var $comm; // commands for many people
+ var $step; // current step of the comm array
+ var $garbage_timeout;
+ var $shm_sz;
+
+ function Room () {
+ $this->user = array();
+ $this->table = array();
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $this->user[$i] =& User::create("", "");
+ }
+
+ for ($i = 0 ; $i < TABLES_N ; $i++)
+ $this->table[$i] =& Table::create();
+ $this->garbage_timeout = 0;
+ }
+
+ function garbage_manager($force)
+ {
+ $ismod = FALSE;
+
+ log_rd2("garbage_manager START");
+
+ /* Garbage collector degli utenti in timeout */
+ $curtime = time();
+ if ($force || $this->garbage_timeout < $curtime) {
+
+ // Before all align times with table timeout
+ for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ $table_cur =& $this->table[$table_idx];
+ // if the table is complete and exists its shared mem we get the info about users lacc
+
+ if ($table_cur->player_n == PLAYERS_N) {
+ log_main("PLAYERS == N TABLE ".$table_idx);
+
+ if (($sem = Briskin5::lock_data($table_idx)) != FALSE) {
+ log_main("bin5 lock data success");
+
+ $no_recovery = FALSE;
+ if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+ if ($table_cur->table_token != $bri->table_token) {
+ log_main("ERROR: not matching table_token. Room: ".$table_cur->table_token." Table: ".$bri->table_token);
+ log_main("ERROR: not matching table_start. Room: ".$table_cur->table_start." Table: ".$bri->table_start);
+ $no_recovery = TRUE;
+ $bri = FALSE;
+ }
+ }
+
+ if ($bri != FALSE) {
+ //
+ // SPAWN: JOIN
+ //
+ log_main("garbage_manager: bri loaded successfully.");
+ $bri->garbage_manager(TRUE);
+
+ $bri_table = &$bri->table[0];
+
+ // is the end of the table
+ if ($bri->the_end == TRUE) {
+ /*
+ * DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN
+ */
+ log_main("garbage_manager: INSIDE THE END.");
+
+ $plist = "$table_cur->table_token|$user_cur->table|$table_cur->player_n";
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
+ }
+
+ for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
+ // stat must be "table" by definition
+ $user_cur =& $this->user[$table_cur->player[$i]];
+ $bri_user =& $bri->user[$i];
+
+ $user_cur->subst = $bri_user->subst;
+ $user_cur->step = $bri_user->step;
+ $user_cur->lacc = $bri_user->lacc;
+ $user_cur->laccwr = $bri_user->lacc;
+ $user_cur->bantime = $bri_user->bantime;
+ }
+
+ log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME", $plist);
+
+ $this->room_join_wakeup(&$user_cur, FALSE, 0);
+ $table_cur->table_token = "";
+ $table_cur->wakeup_time = $curtime + WAKEUP_TIME;
+ Briskin5::destroy_data($table_idx);
+ }
+ else {
+ log_main("gm:: save_data");
+
+ for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
+ $this->user[$table_cur->player[$i]]->lacc = $bri->user[$i]->lacc;
+ }
+
+ Briskin5::save_data(&$bri);
+ }
+ } // else if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+ else if ($no_recovery == FALSE) {
+ log_crit("ERROR: table ".$table_idx." unrecoverable join");
+
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $user_cur = &$this->user[$table_cur->player[$i]];
+ $user_cur->subst = "shutdowner";
+ $user_cur->step_inc();
+
+ $ret = sprintf('stat = "%s"; subst = "%s";', $user_cur->stat, $user_cur->subst);
+ $ret .= "gst.st = ".($user_cur->step+1)."; ";
+ $ret .= show_notify("<br>I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.<br><br>Torni in piedi.<br><br>", 2000, "Chiudi.", 400, 110);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+
+ $plist = "$table_cur->table_token|$user_cur->table|$table_cur->player_n";
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
+ }
+ log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME(RECOVERY)", $plist);
+
+ $this->room_join_wakeup(&$user_cur, TRUE, -2);
+ $table_cur->table_token = "";
+ }
+
+ Briskin5::unlock_data($sem);
+ } // bri::lock_data
+ } // if ($table_cur->player_n == PLAYERS_N) {
+ } // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+
+ log_rd2("out new loop.");
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = &$this->user[$i];
+
+ log_rd2("User: ".$user_cur->name." stat: ".$user_cur->stat." subst: ".$user_cur->subst);
+
+ if ($user_cur->sess == "")
+ continue;
+
+ if ($user_cur->lacc + EXPIRE_TIME_RD < $curtime) {
+ // Auto logout dell'utente
+ log_rd2("AUTO LOGOUT.".($user_cur->lacc + EXPIRE_TIME_RD)." curtime ".$curtime);
+
+ if ($user_cur->stat == 'table' || $user_cur->stat == 'room') {
+ log_auth($user_cur->sess, "Autologout session.");
+
+ $user_cur->reset();
+
+ log_rd2("AUTO LOGOUT.");
+ if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
+ $this->room_wakeup(&$user_cur);
+ else if ($user_cur->subst == 'standup')
+ $this->room_outstandup(&$user_cur);
+ else
+ log_rd2("LOGOUT FROM WHAT ???");
+ }
+ }
+
+ if ($user_cur->laccwr + EXPIRE_TIME_SMAMMA < $curtime) { // lo rimettiamo in piedi
+ if ($user_cur->stat == 'room' && $user_cur->subst == 'sitdown') {
+ $this->room_wakeup(&$user_cur);
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+ $user_cur->comm[$user_cur->step % COMM_N] .= show_notify("<br>Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti. <br><br>Quindi ritorni tra i <b>Giocatori in piedi</b>.", 0, "torna ai tavoli", 400, 100);
+ $user_cur->step_inc();
+ }
+ }
+ }
+ log_rd2("GARBAGE UPDATED!");
+
+ $this->garbage_timeout = time() + GARBAGE_TIMEOUT;
+ $ismod = TRUE;
+ }
+
+ return ($ismod);
+ }
+
+ function show_room($user_step, &$user)
+ {
+ log_main("show_room: username: ".$user->name);
+
+
+ $ret = sprintf('gst.st = %d; ', $user_step);
+ if ($user->subst == 'standup')
+ $ret .= "tra.show(); ";
+ else
+ $ret .= "tra.hide(); ";
+
+ $ret .= sprintf('stat = "%s";', $user->stat);
+
+ $ret .= root_wellcome($user);
+ $ret .= sprintf('subst = "%s";', $user->subst);
+ $ret .= sprintf('$("myname").innerHTML = "<b>%s</b>";', xcape($user->name));
+ for ($i = 0 ; $i < TABLES_N ; $i++) {
+ $ret .= $this->table_content($user, $i);
+ $act_content = table_act_content(($user->subst == 'standup'),
+ $this->table[$i]->player_n, $i, $user->table);
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $i, $act_content);
+ if ($this->table[$i]->wag_own != NULL)
+ $ret .= sprintf('tra.add(%d, "%s: %s"); ', $i, $this->table[$i]->wag_own->name, $this->table[$i]->wag_com);
+ else
+ $ret .= sprintf('tra.rem(%d); ', $i);
+ }
+ $ret .= $this->standup_content($user);
+
+ return ($ret);
+ }
+
+
+ function room_wakeup(&$user)
+ {
+ $table_idx = $user->table;
+ $table = &$this->table[$table_idx];
+
+ log_main("WAKEUP: begin function table:".$table_idx." stat: ".$user->stat." subst: ".$user->subst);
+
+ $curtime = time();
+
+ $from_table = ($user->stat == "table");
+ if ($from_table) {
+ log_main("WAKEUP: from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n);
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user_cur = &$this->user[$table->player[$i]];
+ log_main("PREIMPOST: INLOOP name: ".$user_cur->name);
+
+ if ($user_cur != $user) {
+ $user_cur->stat_set("room");
+ $user_cur->subst = "sitdown";
+ $user_cur->laccwr = $curtime;
+ }
+ else if ($user->sess != "") {
+ $user_cur->stat_set("room");
+ $user_cur->subst = "standup";
+ $user_cur->laccwr = $curtime;
+ $user_cur->table = -1;
+ }
+ }
+ }
+ else {
+ $user->stat_set("room");
+ $user->subst = "standup";
+ $user->laccwr = $curtime;
+ }
+
+ $remove_wagon = false;
+ if($table->wag_own == $user) {
+ $remove_wagon = true;
+ $table->wag_reset($curtime);
+
+ }
+
+
+ /* aggiorna l'array dei giocatori al tavolo. */
+ $table->user_rem(&$this, &$user);
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == '' || $user_cur->stat != 'room')
+ continue;
+
+ log_main("VALORI: name: ".$user_cur->name."from_table: ".$from_table." tab: ".$user_cur->table." taix: ".$table_idx." ucur: ".$user_cur." us: ".$user);
+
+ $ret = "gst.st = ".($user_cur->step+1)."; ".($remove_wagon ? sprintf("tra.rem(%d);",$table_idx) : "");
+ if ($from_table && ($user_cur->table == $table_idx || $user_cur == $user)) {
+ $ret .= 'gst.st_loc++; the_end=true; window.onunload = null; document.location.assign("index.php");|';
+ // $ret .= 'gst.st_loc++; document.location.assign("index.php");|';
+ log_main("DOCUMENT.index.php: from table");
+ }
+ else if ($user_cur->stat == "room") {
+ log_main("DOCUMENT.index.php: from table");
+
+ $ret .= $this->table_content($user_cur, $table_idx);
+ $ret .= $this->standup_content($user_cur);
+
+ $act_content = table_act_content(FALSE, 0, $table_idx, $user->table);
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
+
+
+ if ($user_cur == $user) {
+ // set the new status
+ $ret .= 'subst = "standup"; tra.show(); ';
+ // clean the action buttons in other tables
+ for ($e = 0 ; $e < TABLES_N ; $e++) {
+ if ($this->table[$e]->player_n < PLAYERS_N)
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, table_act_content(TRUE, 0, $e, $user->table));
+ }
+ }
+ else {
+ $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table);
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
+ }
+ }
+ log_wr("ROOM_WAKEUP: ".$ret);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ }
+
+ function room_join_wakeup(&$user, $update_lacc = FALSE, $trans_delta)
+ {
+ $table_idx = $user->table;
+ $table = &$this->table[$table_idx];
+
+ log_main("JOIN_WAKEUP: begin function table:".$table_idx." stat: ".$user->stat." subst: ".$user->subst);
+
+ $curtime = time();
+ $user_wup = array();
+ $user_wup_n = 0;
+ $user_tab = array();
+ $user_tab_n = 0;
+ log_main("JOIN WAKEUP: from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n);
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user_cur = &$this->user[$table->player[$i]];
+ log_main("PREIMPOST INLOOP name: ".$user_cur->name);
+ if ($user_cur->sess != "") {
+ if ($update_lacc == TRUE) {
+ $user_cur->laccwr = $curtime;
+ }
+ log_main("cur: ".$user_cur->name." subst: ".$user_cur->subst);
+ if ($user_cur->subst == "shutdowned") {
+ $user_cur->stat_set("room");
+ $user_cur->subst = "sitdown";
+ }
+ else if ($user_cur->subst == "shutdowner") {
+ $user_cur->stat_set("room");
+ $user_cur->subst = "standup";
+ $user_cur->table = -1;
+ $user_wup[$user_wup_n++] = &$user_cur;
+
+ $remove_wagon = false;
+ if($table->wag_own == $user_cur) {
+ $remove_wagon = true;
+ $table->wag_reset($curtime);
+ }
+ }
+ $user_tab[$user_tab_n++] = &$user_cur;
+ }
+ }
+
+ for ($wup_idx = 0 ; $wup_idx < $user_wup_n ; $wup_idx++)
+ $table->user_rem(&$this, &$user_wup[$wup_idx]);
+
+ /* aggiorna l'array dei giocatori al tavolo. */
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ log_main("START LOOP");
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == '' || $user_cur->stat != 'room') {
+ log_main("name: ".$user_cur->name."skip subst: ".$user_cur->subst);
+ continue;
+ }
+
+ log_main("___");
+ log_main("VALORI name: ".$user_cur->name." tab: ".$user_cur->table." taix: ".$table_idx." ucur: ".$user_cur." us: ".$user);
+
+ $ret = "gst.st = ".($user_cur->step+1)."; ".($remove_wagon ? sprintf("tra.rem(%d);",$table_idx) : "");
+ if ($user_cur->stat == "room") {
+ log_main("DOCUMENT.index.php from table");
+
+ $ret .= $this->table_content($user_cur, $table_idx);
+ $ret .= $this->standup_content($user_cur);
+
+ $act_content = table_act_content(FALSE, 0, $table_idx, $user_cur->table);
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
+
+ for ($tab_idx = 0 ; $tab_idx < $user_tab_n ; $tab_idx++)
+ if ($user_cur == $user_tab[$tab_idx])
+ break;
+
+ // for users that wakeup the room will be reconstructed by index_rd.php
+ if ($tab_idx < $user_tab_n) {
+ log_main("PRE show_room username: ".$user_cur->name." STEP: ".$user_cur->step);
+
+// ARRAY_POP DISABLED
+// if ($trans_delta == 0)
+// while (array_pop($user_cur->comm) != NULL);
+
+ $user_cur->trans_step = $user_cur->step + 1 + $trans_delta;
+ $user_cur->comm[$user_cur->step % COMM_N] = "";
+ $user_cur->step_inc();
+ $user_cur->comm[$user_cur->step % COMM_N] = $this->show_room(($user_cur->step + 1), &$user_cur);
+ $user_cur->step_inc();
+ log_main("POST show_room username: ".$user_cur->name." STEP: ".$user_cur->step);
+
+ continue;
+ }
+ log_main("JOIN_WAKEUP wup_idx ".$wup_idx." wup_n ".$user_wup_n);
+
+ log_main("JOIN_WAKEUP more");
+ $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table);
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
+ log_main("JOIN_WAKEUP end more");
+ }
+ log_wr("ROOM_JOIN_WAKEUP: ".$ret);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ }
+
+ function room_outstandup(&$user)
+ {
+ $this->room_sitdown(&$user, -1);
+ }
+
+ function table_update(&$user)
+ {
+ log_main("table_update: pre - USER: ".$user->name);
+
+ $table_idx = $user->table;
+
+ if ($table_idx > -1)
+ $table = &$this->table[$table_idx];
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $ret = "";
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == '' || $user_cur->stat != 'room')
+ continue;
+
+ $ret = "gst.st = ".($user_cur->step+1)."; ";
+ if ($table_idx > -1)
+ $ret .= $this->table_content($user_cur, $table_idx);
+
+ if ($user_cur == $user) {
+ $ret .= sprintf('$("myname").innerHTML = "<b>%s</b>: ";', xcape($user->name));
+ }
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+
+ log_main("table_update: post");
+ }
+
+ function room_sitdown(&$user, $table_idx)
+ {
+ log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name));
+
+ $train_app = "";
+
+ if ($table_idx > -1 && $table_idx < TABLES_N) {
+ $table = &$this->table[$table_idx];
+
+ // wagon shutdown
+ if ($table->wag_own != NULL && $table->player_n == PLAYERS_N) {
+ for ($i = 0 ; $i < TABLES_N ; $i++) {
+ $user_cur =& $this->user[$table->player[$i]];
+ if ($user_cur == $table->wag_own) {
+ $train_app = sprintf("tra.rem(%d); ", $table_idx);
+ $table->wag_reset(time());
+ break;
+ }
+ }
+ }
+ }
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $ret = "";
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == '' || $user_cur->stat != 'room')
+ continue;
+
+ $ret = "gst.st = ".($user_cur->step+1)."; ".$train_app;
+ if ($table_idx > -1)
+ $ret .= $this->table_content($user_cur, $table_idx);
+ $ret .= $this->standup_content($user_cur);
+
+ if ($user_cur == $user) {
+ $ret .= 'subst = "sitdown"; tra.hide(); ';
+ // clean the action buttons in other tables
+ for ($e = 0 ; $e < TABLES_N ; $e++) {
+ $act_content = table_act_content(FALSE, 0, $e, $user_cur->table);
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, $act_content);
+ }
+ }
+ else if ($table_idx > -1) {
+ if ($table->player_n == PLAYERS_N) {
+ $act_content = table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table);
+ $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
+ }
+ }
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ }
+
+ function chatt_send(&$user, $mesg)
+ {
+ GLOBAL $G_alarm_passwd;
+ $only_you = FALSE;
+
+ // common settings
+ $msg = substr($mesg, 6, 128);
+ $curtime = time();
+ $dt = date("H:i ", $curtime);
+
+ //
+ // Compute actions
+ //
+
+ $to_user = FALSE;
+ $to_all = FALSE;
+ $to_room = FALSE;
+ $to_tabl = FALSE;
+ $update_room = FALSE;
+
+ if (strcmp($msg, "/tav") == 0 ||
+ strncmp($msg, "/tav ", 5) == 0) {
+ do {
+ if ($user->stat != 'room' || $user->subst != 'sitdown') {
+ $msg = "<br>Per attivare il messaggio di segnalazione del tavolo occorre essere seduti.<br><br>";
+ $to_user = show_notify($msg, 0, "chiudi", 400, 100);
+
+ break;
+ }
+
+ $table = &$this->table[$user->table];
+
+ if ($table->wag_own != NULL) {
+ $msg = "<br>Il messaggio di segnalazione del tavolo è già attivato.<br><br>";
+ $to_user = show_notify($msg, 0, "chiudi", 400, 100);
+
+ break;
+ }
+
+ $dtime = $curtime - $table->wag_tout;
+ if ($dtime < EXPIRE_TIME_WAG) {
+ $msg = sprintf("<br>Il messaggio di segnalazione del tavolo<br>è disattivato ancora per %d second%s.<br><br>",
+ EXPIRE_TIME_WAG - $dtime, (EXPIRE_TIME_WAG - $dtime == 1 ? "o" : "i"));
+ $to_user = show_notify($msg, 0, "chiudi", 400, 100);
+
+ break;
+ }
+
+ $msg = substr($msg, 5);
+
+ $table->wag_set($user, $msg);
+ $to_user = sprintf('tra.add(%d, "%s");', $user->table, xcape(sprintf("%s: %s", $user->name, $msg)));
+ $to_room = $to_user;
+
+ } while (0);
+ } // /tav chat command
+
+ else if (strncmp($msg, "/alarm ", 7) == 0) {
+ $alarm_check = "/alarm ".$G_alarm_passwd." ";
+ do {
+ if (strncmp($msg, $alarm_check, strlen($alarm_check)) != 0) {
+ $msg = "<br>La password digitata non è corretta.<br><br>";
+ $to_user = show_notify($msg, 0, "chiudi", 400, 100);
+
+ break;
+ }
+
+ $to_user = sprintf('chatt_sub("%s","Alarm <b>%s</b> inviato a tutti.");',
+ $dt.NICKSERV, xcape(substr($msg, strlen($alarm_check))));
+
+ $msg = sprintf("<br><b>%s<br><br>%s</b><br><br>",
+ $dt.NICKSERV, xcape(substr($msg, strlen($alarm_check))));
+ $to_all = show_notify($msg, 0, "chiudi", 400, 120);
+ } while (0);
+ } // /alarm chat command
+
+ else if (strncmp($msg, "/nick ", 6) == 0) {
+ log_main("chatt_send BEGIN");
+
+ do {
+ if (($name_new = validate_name(substr($msg, 6))) == FALSE) {
+ $to_user = sprintf('chatt_sub("%s","Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.");', $dt.NICKSERV);
+ break;
+ }
+
+ $msg = "COMMAND ".$msg;
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = &$this->user[$i];
+
+ if ($user_cur->sess == '')
+ continue;
+ if ($user_cur->name == $name_new)
+ break;
+ }
+ if ($i < MAX_PLAYERS) {
+ $to_user = sprintf('chatt_sub("%s","Nickname <b>%s</b> già in uso.");', $dt.NICKSERV, xcape($name_new));
+ break;
+ }
+
+ $user->name = $name_new; // OK - nick changed
+
+ log_main("chatt_send start set");
+
+ $update_room = TRUE;
+ } while (0);
+ } // nick chat command
+
+ else { // normal chat line
+ if ($curtime < ($user->chat_ban + $user->chat_dlt)) {
+ $only_you = TRUE;
+ $user->chat_dlt = $user->chat_dlt * 2;
+ if ($user->chat_dlt > 120)
+ $user->chat_dlt = 120;
+ }
+ else if ($user->chat_lst == $msg)
+ $only_you = TRUE;
+ else if ($curtime - $user->chattime[($user->chat_cur + 1) % CHAT_N] < CHAT_ILL_TIME) {
+ $user->chat_ban = $curtime;
+ $user->chat_dlt = 5;
+ $only_you = TRUE;
+ }
+ else {
+ $user->chat_ban = 0;
+ $user->chat_dlt = 0;
+ }
+
+ if ($only_you) {
+ $to_user = sprintf('chatt_sub("%s","%s");', $dt.xcape($user->name), xcape("== chat ban =="));
+ }
+ else {
+ $to_user = sprintf('chatt_sub("%s","%s");', $dt.xcape($user->name), xcape($msg));
+ // temporary silentiation for troll (will became array check)
+ if (strcasecmp($user->name,'JackRokka') != 0 && $user->sess != '47ea653f602e8')
+ $to_room = $to_user;
+ }
+
+ log_legal($curtime, $user->sess, $user->name,
+ ($user->stat == 'room' ? 'room' : 'table '.$user->table),$msg);
+
+ $user->chat_lst = "$msg";
+ $user->chattime[$user->chat_cur % CHAT_N] = $curtime;
+ $user->chat_cur++;
+ }
+
+ if ($to_all) {
+ $to_room = $to_all;
+ $to_tabl = $to_all;
+ }
+
+ //
+ // Output to clients
+ //
+
+ if ($to_user != FALSE) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= $to_user;
+ $user->step_inc();
+ }
+
+ if ($to_room != FALSE) {
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = &$this->user[$i];
+ // if ($user_cur->sess == '' || $user_cur->stat != 'room')
+ if ($user_cur->sess == '' || $user_cur->stat == 'table' || $user_cur == $user)
+ continue;
+
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+ $user_cur->comm[$user_cur->step % COMM_N] .= $to_room;
+ $user_cur->step_inc();
+ }
+ }
+
+ if ($to_tabl) {
+ // Before all align times with table timeout
+ for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ $table_cur =& $this->table[$table_idx];
+ // if the table is complete and exists its shared mem we get the info about users lacc
+
+ if ($table_cur->player_n == PLAYERS_N) {
+ log_main("PLAYERS == N TABLE ".$table_idx);
+
+ if (($sem = Briskin5::lock_data($table_idx)) != FALSE) {
+ log_main("bin5 lock data success");
+
+ $no_recovery = FALSE;
+ if (($bri = &Briskin5::load_data($table_idx)) != FALSE) {
+ if ($table_cur->table_token != $bri->table_token) {
+ log_main("ERROR: not matching table_token. Room: ".$table_cur->table_token." Table: ".$bri->table_token);
+ $bri = FALSE;
+ }
+ }
+
+ if ($bri != FALSE) {
+ $bri_table = &$bri->table[0];
+ for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
+ // stat must be "table" by definition
+ $bri_user =& $bri->user[$i];
+
+ log_main("writa: ".$user_mesg);
+ $bri_user->comm[$bri_user->step % COMM_N] = "gst.st = ".($bri_user->step+1)."; ";
+ $bri_user->comm[$bri_user->step % COMM_N] .= $to_tabl;
+ $bri_user->step_inc();
+ }
+ Briskin5::save_data(&$bri);
+ }
+ Briskin5::unlock_data($sem);
+ } // bri::lock_data
+ } // if ($table_cur->player_n == PLAYERS_N) {
+ } // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ } // if ($to_tabl == true ...
+
+ if ($update_room) {
+ if ($user->stat == 'room' && $user->subst == 'standup') {
+ $this->standup_update(&$user);
+ }
+ else if ($user->stat == 'room' && $user->subst == 'sitdown') {
+ log_main("chatt_send pre table update");
+ $this->table_update(&$user);
+ log_main("chatt_send post table update");
+ }
+ } // if ($update_room ...
+
+ return;
+ } // function chatt_send( ...
+
+ function &get_user($sess, &$idx)
+ {
+ GLOBAL $PHP_SELF, $G_false;
+
+ if (validate_sess($sess)) {
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ if (strcmp($sess, $this->user[$i]->sess) == 0) {
+ // find it
+ $idx = $i;
+ $ret = &$this->user[$i];
+ return ($ret);
+ }
+ }
+ log_main(sprintf("get_user: Wrong sess from page [%s]",$PHP_SELF));
+ // for ($i = 0 ; $i < MAX_PLAYERS ; $i++)
+ // log_main(sprintf("get_user: Wrong sess compared with [%s]",$this->user[$i]->sess));
+ }
+ else {
+ log_main(sprintf("get_user: Wrong strlen [%s]",$sess));
+ }
+
+ return ($G_false);
+ }
+
+ /*
+ * function &add_user(&$room, &$sess, &$idx, $name, $ip)
+ *
+ * RETURN VALUE:
+ * if ($idx != -1 && ret == FALSE) => duplicated nick
+ * if ($idx == -2 && ret == FALSE) => invalid name
+ * if ($idx == -1 && ret == FALSE) => no space left
+ * if (ret == TRUE) => SUCCESS
+ */
+ function &add_user(&$sess, &$idx, $name, $ip)
+ {
+ GLOBAL $G_false;
+
+ $idx = -1;
+ $idfree = -1;
+
+ if (($name_new = validate_name($name)) == FALSE) {
+ $idx = -2;
+ return ($G_false);
+ }
+
+ log_auth("XXX", sprintf("ARRIVA: [%s]", $sess));
+ if (validate_sess($sess) == FALSE)
+ $sess = "";
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ /* free user ? */
+ if (strcmp($sess, $this->user[$i]->sess) == 0) {
+ if ($idx == -1)
+ $idx = $i;
+ }
+ if ($idfree == -1 && strcmp("", $this->user[$i]->sess) == 0) {
+ $idfree = $i;
+ }
+ if (strcmp($this->user[$i]->name, $name_new) == 0) {
+ $idx = $i;
+ break;
+ }
+ }
+ if ($idx == -1)
+ $idx = $idfree;
+
+ log_auth("XXX", sprintf("TROVATO A QUESTO PUNTO [%d] sess [%s] name [%s]", $idx, $sess, $name_new));
+
+ if ($idx != -1 && $i == MAX_PLAYERS) {
+ /* SUCCESS */
+ $curtime = time();
+ if ($sess == "") {
+ $this->user[$idx]->sess = uniqid("");
+ $sess = $this->user[$idx]->sess;
+
+ }
+ else {
+ $this->user[$idx]->sess = $sess;
+ }
+ $this->user[$idx]->name = $name_new; // OK - add new user
+ $this->user[$idx]->stat_set("room");
+ $this->user[$idx]->step_set(0);
+ while (array_pop($this->user[$idx]->comm) != NULL);
+ $this->user[$idx]->subst = "standup";
+ $this->user[$idx]->lacc = $curtime;
+ $this->user[$idx]->laccwr = $curtime;
+ $this->user[$idx]->bantime = 0;
+ $this->user[$idx]->ip = $ip;
+ log_main(sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s]", $idx, $sess, $name_new));
+
+ return ($this->user[$idx]);
+ }
+
+ return ($G_false);
+ }
+
+ function standup_update(&$user)
+ {
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == '')
+ continue;
+
+ log_main("STANDUP START: ".$user_cur->stat);
+
+ if ($user_cur->stat == 'room') {
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ".$this->standup_content($user_cur);
+ if ($user_cur == $user)
+ $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "<b>%s</b>: ";', xcape($user->name));
+
+ log_main("FROM STANDUP: NAME: ".$user_cur->name." SENDED: ".$user_cur->comm[$user_cur->step % COMM_N]);
+
+ $user_cur->step_inc();
+ }
+ }
+ }
+
+ // Static functions
+ function &init_data()
+ {
+ $room =& new Room();
+
+ return $room;
+ }
+
+
+ function &load_data()
+ {
+ GLOBAL $G_false, $sess;
+ $doexit = FALSE;
+ do {
+ if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) {
+ log_main("ftok failed");
+ $doexit = TRUE;
+ break;
+ }
+
+ if (($shm_sz = sharedmem_sz($tok)) == -1) {
+ log_main("shmop_open failed");
+ }
+
+ if ($shm_sz == -1)
+ $shm_sz = SHM_DIMS_MIN;
+
+ if ($shm = shm_attach($tok, $shm_sz)) {
+ $room = @shm_get_var($shm, $tok);
+
+ log_only("bri == ".($room == FALSE ? "FALSE" : "TRUE")." bri === ".($room === FALSE ? "FALSE" : "TRUE")." bri isset ".(isset($room) ? "TRUE" : "FALSE"));
+ if (isset($room))
+ log_only("bri count ".count($room));
+
+ if ($room == FALSE) {
+ log_only("INIT MAIN DATA");
+
+ $room =& Room::init_data();
+ if (@shm_put_var($shm, $tok, $room) == FALSE) {
+ log_only("PUT_VAR FALLITA ".strlen(serialize($room)));
+ log_only(serialize($room));
+ }
+ }
+ $room->shm_sz = $shm_sz;
+
+ shm_detach($shm);
+ }
+ $ret = &$room;
+ return ($ret);
+ } while (0);
+
+ if ($doexit)
+ exit();
+
+ return ($G_false);
+ }
+
+
+ function save_data(&$room)
+ {
+ GLOBAL $sess;
+
+ $ret = FALSE;
+ $shm = FALSE;
+
+ // var_dump($room);
+
+ if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1)
+ return (FALSE);
+
+ while ($room->shm_sz < SHM_DIMS_MAX) {
+ if (($shm = shm_attach($tok, $room->shm_sz)) == FALSE)
+ break;
+
+ // log_only("PUT_VAR DI ".strlen(serialize($room)));
+ if (shm_put_var($shm, $tok, $room) != FALSE) {
+ shm_detach($shm);
+ return (TRUE);
+ }
+ if (shm_remove($shm) === FALSE) {
+ log_only("REMOVE FALLITA");
+ break;
+ }
+ shm_detach($shm);
+ $room->shm_sz += SHM_DIMS_DLT;
+ }
+
+ if ($shm)
+ shm_detach($shm);
+
+ return ($ret);
+ }
+
+ function lock_data()
+ {
+ GLOBAL $sess;
+
+ // echo "LOCK: ".FTOK_PATH."/main";
+ // exit;
+ if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) {
+ echo "FTOK FAILED";
+ exit;
+ }
+ // echo "FTOK ".$tok."<br>";
+ 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));
+ }
+
+ function standup_content($user)
+ {
+ $ret = "";
+ $content = "";
+
+ if ($user->stat != 'room')
+ return;
+
+ for ($e = 0 , $ct = 0 ; $ct < 4 && $e < MAX_PLAYERS ; $e++) {
+ if ($this->user[$e]->sess == "" || $this->user[$e]->stat != "room" || $this->user[$e]->name == "")
+ continue;
+ $ct++;
+ }
+
+ $content .= sprintf('<table cols=\\"%d\\" class=\\"table_standup\\">', $ct);
+
+ for ($e = 0 , $ct = 0 ; $e < MAX_PLAYERS ; $e++) {
+ if ($this->user[$e]->sess == "" || $this->user[$e]->stat != "room" || $this->user[$e]->name == "")
+ continue;
+
+
+ if ($this->user[$e]->subst == "standup") {
+ if (($ct % 4) == 0) {
+ $content .= '<tr>';
+ }
+ if ($this->user[$e] == $user)
+ { $hilion = "<b>"; $hilioff = "</b>"; }
+ else
+ { $hilion = ""; $hilioff = ""; }
+
+ $content .= sprintf('<td class=\\"room_standup\\">%s%s%s</td>',$hilion, xcape($this->user[$e]->name), $hilioff);
+ if (($ct % 4) == 3) {
+ $content .= '</tr>';
+ }
+ $ct++;
+ }
+ }
+ $content .= '</table>';
+
+ $content2 = '<input class=\\"button\\" name=\\"logout\\" value=\\"Esco.\\" onclick=\\"window.onunload = null; act_logout();\\" type=\\"button\\">';
+ $ret .= sprintf('$("standup").innerHTML = "%s"; $("esco").innerHTML = "%s";',
+ $content, $content2);
+
+ return ($ret);
+ }
+
+ function table_content($user, $table_idx)
+ {
+ $content = "";
+ $ret = "";
+ // TODO
+ //
+ // Si possono usare i dati nella classe table
+ //
+
+ $sess = $user->sess;
+ $table = &$this->table[$table_idx];
+
+ if ($user->stat != 'room')
+ return;
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user_cur = &$this->user[$table->player[$i]];
+
+ if ($user_cur == $user)
+ { $hilion = "<b>"; $hilioff = "</b>"; }
+ else
+ { $hilion = ""; $hilioff = ""; }
+
+ log_main($user_cur->name. sprintf(" IN TABLE [%d]", $table_idx));
+
+ $content .= sprintf("%s%s%s<br>",$hilion, xcape($user_cur->name), $hilioff);
+ }
+ /*
+ for ( ; $i < PLAYERS_N ; $i++)
+ $content .= "<br>";
+ */
+
+ $ret .= sprintf('$("table%d").innerHTML = "%s";', $table_idx, $content);
+
+ return ($ret);
+ }
+
+
+} // end class Room
+
+function make_seed()
+{
+ list($usec, $sec) = explode(' ', microtime());
+ return (float) $sec + ((float) $usec * 100000);
+}
+
+
+function log_only2($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_ONL2) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_ONL2) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("ONL2: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_crit($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_CRIT) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_CRIT) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("CRIT: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_only($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_ONLY) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_ONLY) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("ONLY: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_main($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_MAIN) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_MAIN) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("MAIN: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_rd($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_READ) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_READ) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("READ: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_rd2($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_REA2) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_REA2) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("REA2: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_send($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_SEND) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_SEND) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("SEND: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_lock($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_LOCK) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_LOCK) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("LOCK: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_wr($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_WRIT) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_WRIT) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("WRIT: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_load($log) {
+ GLOBAL $sess;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_LOAD) == 0)
+ return;
+
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_LOAD) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("LOAD: [%s] [%s]\n", $ssess, $log));
+ fclose($fp);
+ }
+}
+
+function log_auth($sess, $log) {
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_AUTH) == 0)
+ return;
+
+ if (( (BRISK_DEBUG | ($sess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_AUTH) == 0)
+ return;
+
+ if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("AUTH: [%s] [%d] [%s]\n", $sess, time(), $log));
+ fclose($fp);
+ }
+}
+
+
+function log_legal($curtime, $sess, $name, $where, $mesg)
+{
+ GLOBAL $_SERVER;
+
+ if (($fp = @fopen(LEGAL_PATH."/legal.log", 'a')) != FALSE) {
+ /* Unix time | session | nickname | IP | where was | mesg */
+ fwrite($fp, sprintf("%ld|%s|%s|%s|%s|%s|\n", $curtime, $sess, $name, $_SERVER['REMOTE_ADDR'], $where , $mesg));
+ fclose($fp);
+ }
+}
+
+
+
+
+function lock_banlist()
+{
+ if (($tok = @ftok(FTOK_PATH."/main", "L")) == -1) {
+ echo "FTOK FAILED";
+ exit;
+ }
+ if (($res = sem_get($tok)) == FALSE) {
+ echo "SEM_GET FAILED";
+ exit;
+ }
+ if (sem_acquire($res))
+ return ($res);
+ else
+ return (FALSE);
+}
+
+function unlock_banlist($res)
+{
+ return (sem_release($res));
+}
+
+function table_act_content($isstanding, $sitted, $table, $cur_table)
+{
+ $ret = "";
+
+ if ($isstanding) {
+ if ($sitted < PLAYERS_N) {
+ $ret = sprintf('<input type=\\"button\\" class=\\"button\\" name=\\"xhenter%d\\" value=\\"Mi siedo.\\" onclick=\\"act_sitdown(%d);\\">', $table, $table);
+ }
+ }
+ else {
+ if ($table == $cur_table)
+ $ret = sprintf('<input type=\\"button\\" class=\\"button\\" name=\\"xwakeup\\" value=\\"Mi alzo.\\" onclick=\\"act_wakeup();\\">');
+ else
+ $ret = "";
+ }
+ return ($ret);
+}
+
+
+function show_notify($text, $tout, $butt, $w, $h)
+{
+ log_main("SHOW_NOTIFY: ".$text);
+ return sprintf('var noti = new notify(gst,"%s",%d,"%s",%d,%d);', $text, $tout, $butt, $w, $h);
+}
+
+function briscola_show($room, $table, $user)
+{
+ $ptnadd = "";
+ $ret = "";
+
+ if ($table->asta_card == 9)
+ $ptnadd = sprintf("<br>con %d punti", $table->asta_pnt);
+
+ /* text of caller cell */
+ if ($user->table_pos == $table->asta_win)
+ $ret .= sprintf('$("callerinfo").innerHTML = "Chiami%s:";', $ptnadd);
+ else
+ $ret .= sprintf('$("callerinfo").innerHTML = "Chiama %s%s:";',
+ xcape($room->user[$table->player[$table->asta_win]]->name), $ptnadd);
+
+ $ret .= sprintf('$("caller").style.backgroundImage = \'url("img/brisk_caller_sand%d.png")\';',
+ $table->asta_win);
+ $ret .= sprintf('$("callerimg").src = "img/%02d.png";', $table->briscola);
+ $ret .= sprintf('$("caller").style.visibility = "visible";');
+ $ret .= sprintf('$("chooseed").style.visibility = "hidden";');
+ $ret .= sprintf('$("astalascio").style.visibility = "";');
+ $ret .= sprintf('$("asta").style.visibility = "hidden";');
+ $ret .= sprintf('show_astat(-2,-2,-2,-2,-2);');
+
+ return ($ret);
+}
+
+
+function game_result($asta_pnt, $pnt)
+{
+ if ($asta_pnt == 61) {
+ if ($pnt > 60)
+ return (1);
+ else if ($pnt == 60)
+ return (0);
+ else
+ return (-1);
+ }
+ else {
+ if ($pnt >= $asta_pnt)
+ return (1);
+ else
+ return (-1);
+ }
+}
+
+function multoval($mult)
+{
+ if ($mult == 2)
+ return ("doppio");
+ else if ($mult == 4)
+ return ("quadruplo");
+ else
+ return (sprintf("%d-plo", $mult));
+}
+
+function show_table_info(&$room, &$table, $table_pos)
+{
+ $ret = "";
+ $user = &$room->user[$table->player[$table_pos]];
+
+ $pnt_min = $table->points_n - MAX_POINTS < 0 ? 0 : $table->points_n - MAX_POINTS;
+ $noty = sprintf('<table class=\"points\"><tr><th></th>');
+
+ // Names.
+ for ($i = 0 ; $i < PLAYERS_N ; $i++)
+ $noty .= sprintf('<th class=\"td_points\">%s</th>', xcape($room->user[$table->player[$i]]->name));
+ $noty .= sprintf("</tr>");
+
+ // Points.
+ log_main("show_table_info: pnt_min: ".$pnt_min." Points_n: ".$table->points_n);
+
+ for ($i = $pnt_min ; $i < $table->points_n ; $i++) {
+ $noty .= sprintf('<tr><th class=\"td_points\">%d</th>', $i+1);
+ for ($e = 0 ; $e < PLAYERS_N ; $e++)
+ $noty .= sprintf('<td class=\"td_points\">%d</td>', $table->points[$i % MAX_POINTS][$e]);
+ $noty .= "</tr>";
+ }
+
+ // Total points.
+ $noty .= '<tr><th class=\"td_points\">Tot.</th>';
+ for ($e = 0 ; $e < PLAYERS_N ; $e++)
+ $noty .= sprintf('<td class=\"td_points\">%d</td>', $table->total[$e]);
+ $noty .= "</tr></table>";
+
+ if ($table->old_reason != "") {
+ $noty .= sprintf("<hr><b>%s</b><br>", xcape($table->old_reason));
+ }
+
+ if ($table->old_win != -1) {
+ $win = $table->player[$table->old_win];
+ $fri = $table->player[$table->old_friend];
+
+ $wol = game_result($table->old_asta_pnt, $table->old_pnt);
+
+ if ($win != $fri) {
+ $noty .= sprintf("<hr>Nell'ultima mano ha chiamato <b>%s</b>, il socio era <b>%s</b>,<br>",
+ xcape($room->user[$win]->name),
+ xcape($room->user[$fri]->name));
+ if ($table->old_pnt == 120) {
+ $noty .= sprintf("hanno fatto <b>cappotto</b> EBBRAVI!.<hr>");
+ }
+ else {
+ $noty .= sprintf("dovevano fare <b>%s</b> punti e ne hanno fatti <b>%d</b>: hanno <b>%s</b>.<hr>",
+ ($table->old_asta_pnt > 61 ? "almeno ".$table->old_asta_pnt :
+ 'più di 60'), $table->old_pnt,
+ ($wol == 1 ? "vinto" : ($wol == 0 ? "pareggiato" : "perso")));
+ }
+ }
+ else {
+ $noty .= sprintf("<hr>Nell'ultima mano <b>%s</b> si è chiamato in mano,<br>",
+ xcape($room->user[$win]->name));
+ if ($table->old_pnt == 120) {
+ $noty .= sprintf("ha fatto <b>cappotto</b> EBBRAVO!.<hr>");
+ }
+ else {
+ $noty .= sprintf("doveva fare <b>%s</b> punti e ne ha fatti <b>%d</b>: ha <b>%s</b>.<hr>",
+ ($table->old_asta_pnt > 61 ? "almeno ".$table->old_asta_pnt :
+ 'più di 60'), $table->old_pnt,
+ ($wol == 1 ? "vinto" : ($wol == 0 ? "pareggiato" : "perso")));
+ }
+ }
+ }
+ if ($table->mazzo == $table_pos)
+ $noty .= "Fai <b>tu</b> il mazzo,";
+ else {
+ $unam = xcape($room->user[$table->player[$table->mazzo]]->name);
+ $noty .= "Il mazzo a <b>$unam</b>,";
+ }
+
+ if ($user->subst == 'asta') {
+ if ($table->asta_win == -1) // auction case
+ $curplayer = $table->gstart % PLAYERS_N;
+ else
+ $curplayer = $table->asta_win;
+ }
+ else if ($user->subst == 'game') {
+ $curplayer = ($table->gstart + $table->turn) % PLAYERS_N;
+ }
+
+
+ if ($curplayer == $table_pos) {
+ $noty .= " tocca a <b>te</b> giocare.";
+ }
+ else {
+ $unam = xcape($room->user[$table->player[$curplayer]]->name);
+ $noty .= " tocca a <b>$unam</b> giocare.";
+ }
+
+ if ($table->mult > 1) {
+ $noty .= sprintf(" La partita vale <b>%s</b>.", multoval($table->mult));
+ }
+ $noty .= "<hr><br>";
+ $ret .= show_notify($noty, 3000, "torna alla partita", 500, 400);
+ /* NOTE: show_notify($noty, 3000, "torna alla partita", 500,
+ * 130 + ($table->points_n > 0 ? 50 : 0) +
+ * (120 * ($table->points_n / MAX_POINTS)));
+ * will be used when we refact notify js function following
+ * photoo class logic
+ */
+
+ return ($ret);
+}
+
+function root_wellcome($user)
+{
+ GLOBAL $root_wellarr;
+ $ret = "";
+
+ $curtime = time();
+ $dt = date("H:i ", $curtime);
+
+ for ($i = 0 ; $i < count($root_wellarr) ; $i++)
+ $ret .= sprintf('chatt_sub("%s","%s");', $dt.NICKSERV, str_replace('"', '\"', $root_wellarr[$i]));
+
+ return ($ret);
+}
+
+function table_wellcome($user)
+{
+ GLOBAL $table_wellarr;
+ $ret = "";
+
+ for ($i = 0 ; $i < count($table_wellarr) ; $i++)
+ $ret .= sprintf('chatt_sub("ChanServ: ","%s");', str_replace('"', '\"', $table_wellarr[$i]));
+
+ return ($ret);
+}
+
+
+
+/* show table
+is_transition (is from room to table ?)
+is_again (is another game)
+
+Examples of $is_transition, $is_again:
+ from reload of the page: FALSE, FALSE
+ from sitdown in room: TRUE, FALSE
+ from table: asta cmd e tutti passano: TRUE, TRUE
+ from table: fine partita: TRUE, TRUE
+ */
+function show_table(&$room, &$user, $sendstep, $is_transition, $is_again)
+{
+ $table_idx = $user->table;
+ $table = &$room->table[$table_idx];
+ $table_pos = $user->table_pos;
+
+ $ret = "table_init();";
+ $ret .= $table->exitlock_show(&$room->user, $table_pos);
+ if (!$is_again) {
+ /* GENERAL STATUS */
+ $ret .= sprintf( 'gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;',
+ $sendstep, $user->stat, $user->subst, $table_pos);
+
+ log_rd(sprintf( 'SHOW_TABLE: gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;',
+ $sendstep, $user->stat, $user->subst, $table_pos));
+
+ /* BACKGROUND */
+ $ret .= "background_set();";
+
+ /* USERS INFO */
+ $ret .= sprintf('$("myname").innerHTML = "<b>%s</b>";', xcape($user->name));
+ $ret .= sprintf('set_names(" %s", " %s", " %s", " %s", " %s"); ',
+ xcape($room->user[$table->player[($table_pos)%PLAYERS_N]]->name),
+ xcape($room->user[$table->player[($table_pos+1)%PLAYERS_N]]->name),
+ xcape($room->user[$table->player[($table_pos+2)%PLAYERS_N]]->name),
+ (PLAYERS_N == 3 ? "" : xcape($room->user[$table->player[($table_pos+3)%PLAYERS_N]]->name)),
+ (PLAYERS_N == 3 ? "" : xcape($room->user[$table->player[($table_pos+4)%PLAYERS_N]]->name)));
+ }
+ /* NOTIFY FOR THE CARD MAKER */
+ if ($is_transition) { // && $user->subst == "asta" superfluo
+ $ret .= show_table_info(&$room, &$table, $table_pos);
+ }
+ if (!$is_again)
+ $ret .= table_wellcome($user);
+
+ if ($is_transition && !$is_again) { // appena seduti al tavolo, play della mucca
+ $ret .= playsound("cow.mp3");
+ }
+
+
+ /* CARDS */
+ if ($is_transition) { // && $user->subst == "asta" superfluo
+ $ret .= "|";
+
+ for ($i = 0 ; $i < 8 ; $i++) {
+ for ($e = 0 ; $e < PLAYERS_N ; $e++) {
+ $ct = 0;
+ for ($o = 0 ; $o < 40 && $ct < $i+1 ; $o++) {
+ if ($table->card[$o]->owner == (($e + $table->gstart) % PLAYERS_N)) {
+ $ct++;
+ if ($ct == $i+1)
+ break;
+ }
+ }
+ log_rd("O ".$o." VAL ".$table->card[$o]->value." Owner: ".$table->card[$o]->owner);
+
+ $ret .= sprintf( ' card_send(%d,%d,%d,%8.2f,%d);|', ($table->gstart + $e) % PLAYERS_N,
+ $i, ((($e + PLAYERS_N - $table_pos + $table->gstart) % PLAYERS_N) == 0 ?
+ $table->card[$o]->value : -1),
+ ($i == 7 && $e == (PLAYERS_N - 1) ? 1 : 0.5),$i+1);
+ }
+ }
+ }
+ else {
+ $taked = array(0,0,0,0,0);
+ $inhand = array(0,0,0,0,0);
+ $ontabl = array(-1,-1,-1,-1,-1);
+ $cards = array();
+
+ for ($i = 0 ; $i < 40 ; $i++) {
+ if ($table->card[$i]->stat == 'hand') {
+ if ($table->card[$i]->owner == $table_pos) {
+ $cards[$inhand[$table->card[$i]->owner]] = $table->card[$i]->value;
+ }
+ $inhand[$table->card[$i]->owner]++;
+ }
+ else if ($table->card[$i]->stat == 'take') {
+ log_main("Card taked: ".$table->card[$i]->value."OWN: ".$table->card[$i]->owner);
+ $taked[$table->card[$i]->owner]++;
+ }
+ else if ($table->card[$i]->stat == 'table') {
+ $ontabl[$table->card[$i]->owner] = $i;
+ }
+ }
+ $logg = "\n";
+ for ($i = 0 ; $i < PLAYERS_N ; $i++) {
+ $logg .= sprintf("INHAND: %d IN TABLE %d TAKED %d\n", $inhand[$i], $ontabl[$i], $taked[$i]);
+ }
+ log_main("Stat table: ".$logg);
+
+ /* Set ours cards. */
+ $oursarg = "";
+ for ($i = 0 ; $i < $inhand[$table_pos] ; $i++)
+ $oursarg .= ($i == 0 ? "" : ", ").$cards[$i];
+ for ($i = $inhand[$table_pos] ; $i < 8 ; $i++)
+ $oursarg .= ($i == 0 ? "" : ", ")."-1";
+ $ret .= sprintf('card_setours(%s);', $oursarg);
+
+ /* Dispose all cards */
+ for ($i = 0 ; $i < PLAYERS_N ; $i++) {
+ /* Qui sotto al posto di + 1 c'era + ->gstart ... credo in modo errato */
+ $ret .= sprintf('cards_dispose(%d,%d,%d);', $i,
+ $inhand[$i], $taked[$i]);
+
+ if ($ontabl[$i] != -1) {
+ $ret .= sprintf('card_place(%d,%d,%d,%d,%d);',$i, $inhand[$i],
+ $table->card[$ontabl[$i]]->value,
+ $table->card[$ontabl[$i]]->x, $table->card[$ontabl[$i]]->y);
+ }
+ }
+ }
+
+ /* Show auction */
+ if ($user->subst == 'asta') {
+
+ /* show users auction status */
+ $showst = "";
+ for ($i = 0 ; $i < PLAYERS_N ; $i++) {
+ $user_cur = &$room->user[$table->player[$i]];
+ $showst .= sprintf("%s%d", ($i == 0 ? "" : ", "),
+ ($user_cur->asta_card < 9 ? $user_cur->asta_card : $user_cur->asta_pnt));
+ }
+ if (PLAYERS_N == 3)
+ $showst .= ",-2,-2";
+ $ret .= sprintf('show_astat(%s);', $showst);
+
+ if ($table->asta_win != -1 && $table->asta_win == $table_pos) {
+ /* show card chooser */
+ $ret .= sprintf('choose_seed(%s); $("astalascio").style.visibility = ""; $("asta").style.visibility = "hidden";',
+ $table->asta_card);
+ }
+ else {
+ /* show auction */
+ if ($table_pos == ($table->gstart % PLAYERS_N) &&
+ $table->asta_win == -1)
+ $ret .= sprintf('dispose_asta(%d,%d, %s);',
+ $table->asta_card + 1, $table->asta_pnt+1, ($user->handpt <= 2 ? "true" : "false"));
+ else
+ $ret .= sprintf('dispose_asta(%d,%d, %s);',
+ $table->asta_card + 1, -($table->asta_pnt+1), ($user->handpt <= 2 ? "true" : "false"));
+ }
+
+ /* Remark */
+ if ($table->asta_win == -1) { // auction case
+ if ($table_pos == ($table->gstart % PLAYERS_N))
+ $ret .= "remark_on();";
+ else
+ $ret .= "remark_off();";
+ }
+ else { // chooseed case
+ if ($table_pos == $table->asta_win)
+ $ret .= "remark_on();";
+ else
+ $ret .= "remark_off();";
+ }
+ }
+ else if ($user->subst == 'game') {
+ /* HIGHLIGHT */
+ if (($table->gstart + $table->turn) % PLAYERS_N == $table_pos)
+ $ret .= "is_my_time = true; remark_on();";
+ else
+ $ret .= "remark_off();";
+
+ /* WHO CALL AND WATH */
+ $ret .= briscola_show($room, $table, $user);
+
+ }
+ return ($ret);
+} // end function show_table(...
+
+function calculate_winner(&$table)
+{
+ $briontab = FALSE;
+ $ontab = array();
+ $ontid = array();
+ $cur_win = -1;
+ $cur_val = 100;
+ $cur_seed = $table->briscola - ($table->briscola % 10);
+
+ for ($i = 0 ; $i < 40 ; $i++) {
+ if ($table->card[$i]->stat != "table")
+ continue;
+
+ log_wr(sprintf("Card On table: [%d]", $i));
+
+ $v = $table->card[$i]->value;
+ $ontab[$table->card[$i]->owner] = $v;
+ $ontid[$table->card[$i]->owner] = $i;
+ /* se briscola setto il flag */
+ if (($v - ($v % 10)) == $cur_seed)
+ $briontab = TRUE;
+ }
+
+ if ($briontab == FALSE) {
+ $cur_win = $table->gstart;
+ $cur_val = $ontab[$cur_win];
+ $cur_seed = $cur_val - ($cur_val % 10);
+ }
+
+ for ($i = 0 ; $i < PLAYERS_N ; $i++) {
+ if (($ontab[$i] - ($ontab[$i] % 10)) == $cur_seed) {
+ if ($ontab[$i] < $cur_val) {
+ $cur_val = $ontab[$i];
+ $cur_win = $i;
+ }
+ }
+ }
+
+ for ($i = 0 ; $i < PLAYERS_N ; $i++) {
+ $table->card[$ontid[$i]]->owner = $cur_win;
+ $table->card[$ontid[$i]]->stat = "take"; // Card stat
+ }
+ return ($cur_win);
+}
+
+function calculate_points(&$table)
+{
+ GLOBAL $G_all_points;
+
+ $pro = 0;
+
+ if ($table->asta_pnt == 60)
+ $table->asta_pnt = 61;
+
+ $table->old_reason = "";
+ $table->old_win = $table->asta_win;
+ $table->old_friend = $table->friend;
+ $table->old_asta_pnt = $table->asta_pnt;
+
+ for ($i = 0 ; $i < 40 ; $i++) {
+ $ctt = $table->card[$i]->value % 10;
+ $own = $table->card[$i]->owner;
+ if ($own == $table->asta_win || $own == $table->friend)
+ $pro += $G_all_points[$ctt];
+ }
+
+ log_wr(sprintf("PRO: [%d]", $pro));
+
+
+ if ($table->asta_pnt == 61 && $pro == 60) { // PATTA !
+ $table->points[$table->points_n % MAX_POINTS] = array();
+ for ($i = 0 ; $i < PLAYERS_N ; $i++)
+ $table->points[$table->points_n % MAX_POINTS][$i] = 0;
+ $table->points_n++;
+ $table->old_pnt = $pro;
+ $table->mult *= 2;
+
+ return;
+ }
+
+ if ($pro >= $table->asta_pnt)
+ $sig = 1;
+ else
+ $sig = -1;
+
+ $table->points[$table->points_n % MAX_POINTS] = array();
+ for ($i = 0 ; $i < 5 ; $i++) {
+ if ($i == $table->asta_win)
+ $pt = ($i == $table->friend ? 4 : 2);
+ else if ($i == $table->friend)
+ $pt = 1;
+ else
+ $pt = -1;
+
+ log_wr(sprintf("PRO: pt[%d][%d] = %d", $table->points_n % MAX_POINTS, $i, $pt));
+
+ $pt = $pt * $sig * $table->mult * ($pro == 120 ? 2 : 1);
+
+ log_wr(sprintf("PRO:[%d][%d][%d]", $sig, $table->mult, ($pro == 120 ? 2 : 1)));
+
+ $table->points[$table->points_n % MAX_POINTS][$i] = $pt;
+ $table->total[$i] += $pt;
+ }
+ $table->points_n++;
+ $table->old_pnt = $pro;
+ $table->mult = 1;
+}
+
+function validate_sess($sess)
+{
+ if (strlen($sess) == SESS_LEN)
+ return (TRUE);
+ else
+ return (FALSE);
+}
+
+function validate_name($name)
+{
+ $name_new = str_replace(' ', '_', substr(trim($name),0,12));
+
+ for ($i = 0 ; $i < strlen($name_new) ; $i++) {
+ $c = $name_new[$i];
+ if (($c >= "a" && $c <= "z") || ($c >= "A" && $c <= "Z") || ($c >= "0" && $c <= "9"))
+ return ($name_new);
+ }
+
+ return (FALSE);
+}
+
+function playsound($filename)
+{
+ return (sprintf('playsound("flasou", "%s");', $filename));
+}
+
+function secstoword($secs)
+{
+ $mins = floor($secs / 60);
+ $secs = $secs % 60;
+ if ($mins > 0)
+ $ret = sprintf("%d minut%s%s", $mins, ($mins > 1 ? "i" : "o"), ($secs > 0 ? " e " : ""));
+
+ if ($secs > 0)
+ $ret .= sprintf("%d second%s", $secs, ($secs > 1 ? "i" : "o"));
+
+ return ($ret);
+}
+
+function sharedmem_sz($tok)
+{
+ if (($shm_id = @shmop_open($tok, 'a', 0, 0)) == FALSE) {
+ log_main("shmop_open failed");
+ return (-1);
+ }
+ $shm_sz = shmop_size($shm_id);
+ shmop_close($shm_id);
+
+ log_main("shm_sz: ".$shm_sz." SHM_DIMS: ".SHM_DIMS);
+ return ($shm_sz);
+}
+
+
+?>
--- /dev/null
+<?php
+/**
+ * Proxy Detector v0.1
+ * copyrights by: Daantje Eeltink (me@daantje.nl)
+ * http://www.daantje.nl
+ *
+ * first build: Mon Sep 18 21:43:48 CEST 2006
+ * last build: Tue Sep 19 10:37:12 CEST 2006
+ *
+ * Description:
+ * This class can detect if a visitor uses a proxy server by scanning the
+ * headers returned by the user client. When the user uses a proxy server,
+ * most of the proxy servers alter the header. The header is returned to
+ * PHP in the array $_SERVER.
+ *
+ * License:
+ * GPL v2 licence. (http://www.gnu.org/copyleft/gpl.txt)
+ *
+ * Support:
+ * If you like this class and find it usefull, please donate one or two
+ * coins to my PayPal account me@daantje.nl
+ *
+ * Todo:
+ * Add open proxy black list scan.
+ */
+
+class proxy_detector {
+
+ /**
+ * CONSTRUCTOR
+ * Set defaults...
+ */
+ function proxy_detector(){
+ $this->config = array();
+ $this->lastLog = "";
+
+ //set default headers
+ $this->scan_headers = array(
+ 'HTTP_VIA',
+ 'HTTP_X_FORWARDED_FOR',
+ 'HTTP_FORWARDED_FOR',
+ 'HTTP_X_FORWARDED',
+ 'HTTP_FORWARDED',
+ 'HTTP_CLIENT_IP',
+ 'HTTP_FORWARDED_FOR_IP',
+ 'VIA',
+ 'X_FORWARDED_FOR',
+ 'FORWARDED_FOR',
+ 'X_FORWARDED',
+ 'FORWARDED',
+ 'CLIENT_IP',
+ 'FORWARDED_FOR_IP',
+ 'HTTP_PROXY_CONNECTION'
+ );
+ }
+
+ function exists_in_rbl($remote) {
+ $rbls = array('http.dnsbl.sorbs.net', 'misc.dnsbl.sorbs.net');
+ // $remote = $_SERVER['REMOTE_ADDR'];
+ // $remote = '213.134.170.206';
+ // $remote = '64.34.166.71';
+
+ if (preg_match("/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/",
+ $remote, $matches)) {
+ foreach ($rbls as $rbl) {
+ $rblhost = $matches[4] . "." . $matches[3] . "." .
+ $matches[2] . "." . $matches[1] . "." . $rbl;
+
+ $resolved = gethostbyname($rblhost);
+ // echo "RBL ".$rblhost."<br>";
+ if ($resolved != $rblhost) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+ }
+
+ /**
+ * VOID setHeader( STRING $trigger )
+ * Set new header trigger...
+ */
+ function setHeader($trigger){
+ $this->scan_headers[] = $trigger;
+ }
+
+
+ /**
+ * ARRAY $triggers = getHeaders( VOID )
+ * Get all triggers in one array
+ */
+ function getHeaders(){
+ return $this->scan_headers;
+ }
+
+
+ /**
+ * VOID setConfig( STRING $key, STRING $value)
+ * Set config line...
+ */
+ function setConfig($key,$value){
+ $this->config[$key] = $value;
+ }
+
+
+ /**
+ * MIXED $config = getConfig( [STRING $key] )
+ * Get all config in one array, or only one config value as a string.
+ */
+ function getConfig($key=''){
+ if($key)
+ return $this->config[$key];
+ else
+ return $this->config;
+ }
+
+
+ /**
+ * STRING $log = getLog( VOID )
+ * Get last logged information. Only works AFTER calling detect()!
+ */
+ function getLog(){
+ return $this->lastLog;
+ }
+
+
+ /**
+ * BOOL $proxy = detect( VOID )
+ * Start detection and return TRUE if a proxy server is detected...
+ */
+ function detect(){
+ GLOBAL $G_proxy_white_list;
+ $log = "";
+
+ foreach($G_proxy_white_list as $authproxy) {
+ if ($_SERVER['REMOTE_ADDR'] == $authproxy)
+ return (FALSE);
+ }
+
+ if ($this->exists_in_rbl($_SERVER['REMOTE_ADDR']) == TRUE)
+ return (TRUE);
+
+// //scan all headers
+// foreach($this->scan_headers as $i){
+// //proxy detected? lets log...
+// if($_SERVER[$i])
+// $log.= "trigger $i: ".$_SERVER[$i]."\n";
+// }
+
+ //let's do something...
+ if($log){
+ $log = $this->lastLog = date("Y-m-d H:i:s")."\nDetected proxy server: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])." ({$_SERVER['REMOTE_ADDR']})\n".$log;
+
+ //mail message
+ if($this->getConfig('MAIL_ALERT_TO'))
+ mail($this->getConfig('MAIL_ALERT_TO'),"Proxy detected at {$_SERVER['REQUEST_URI']}",$log);
+
+ //write to file
+ $f = $this->getConfig('LOG_FILE');
+ if($f){
+ if(is_writable($f)){
+ $fp = fopen($f,'a');
+ fwrite($fp,"$log\n");
+ fclose($fp);
+ }else{
+ die("<strong>Fatal Error:</strong> Couldn't write to file: '<strong>$f</strong>'<br>Please check if the path exists and is writable for the webserver or php...");
+ }
+ }
+
+ //done
+ return TRUE;
+ }
+
+ //nope, no proxy was logged...
+ return FALSE;
+ }
+}
+
+//init class
+function is_proxy()
+{
+ $proxy = new proxy_detector();
+
+ //start detect
+ if($proxy->detect()) {
+ //returned TRUE, lets die...
+ echo "<br><br><div style=\"text-align:center;\"><h1>Accesso attaverso proxy non consentito.</h1><br><br>";
+ echo "Se state utilizzando un proxy privato e volete che sia autorizzato mandate il suo indirizzo IP (".$_SERVER['REMOTE_ADDR'].") e il suo proprietario all'indirizzo di posta elettronica <a href=\"mailto:brisk@alternativeoutput.it\">brisk@alternativeoutput.it</a><br><br></div>";
+
+ //parse logged info
+ echo nl2br($proxy->getLog());
+
+ //some credits...
+ // echo "<hr><strong>proxy detector v0.1</strong> - ©2006 <a href=\"http://www.daantje.nl\" target=\"_blank\">daantje.nl</a>";
+
+ //and do nothing anymore! (but not in my example)
+ return (TRUE);
+ }
+ else
+ return (FALSE);
+}
+
+?>
\ No newline at end of file
/*
* brisk - brisk.css
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
body {
- background-image: url('img/bg_capodanno.jpg');
+ background-image: url('img/bg_spawn2.jpg');
+ background-color: #fafafa;
background-repeat: no-repeat;
background-position: top center;
margin:0px;
margin: auto;
}
+img.nobohide {
+ position: absolute;
+ border-width: 0px;
+ visibility: hidden;
+ z-index: 12;
+}
+
.notify {
border-style: solid;
border-width: 1px;
+++ /dev/null
-<?php
-/*
- * brisk - brisk.phh
- *
- * Copyright (C) 2006-2007 matteo.nastasi@milug.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details. You should have received a
- * copy of the GNU General Public License along with this program; if
- * not, write to the Free Software Foundation, Inc, 59 Temple Place -
- * Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-define(FTOK_PATH, "/var/lib/brisk");
-define(LEGAL_PATH, "/tmp/legal_brisk");
-define(PROXY_PATH, "/var/lib/brisk_proxy");
-define(TABLES_N, 12);
-define(PLAYERS_N, 3);
-define(MAX_POINTS, 5);
-define(MAX_PLAYERS, (20 + (PLAYERS_N * TABLES_N)));
-define(SHM_DIMS, (50000 * MAX_PLAYERS));
-// define(COMM_N, 6);
-define(COMM_N, 12);
-define(COMM_GEN_N, 50);
-define(SESS_LEN, 13);
-define(STREAM_TIMEOUT, 20);
-define(EXPIRE_TIME_RD, 180);
-define(EXPIRE_TIME_SMAMMA, 360);
-// BAN_TIME da allineare anche in commons.js
-define(BAN_TIME, 900);
-define(GARBAGE_TIMEOUT, 10);
-define(NICKSERV, "<i>SERVER</i>");
-define(BRISK_DEBUG, FALSE);
-// define(DEBUGGING, "local");
-
-$G_false = FALSE;
-
-$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "0.8.2";
-
-$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuovo layout che permette più tavoli, più tavoli.',
- 'Se vuoi iscriverti alla <a target="_blank" href="http://www.milug.org/cgi-bin/mailman/listinfo/ml-briscola">Mailing List</a>, 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.');
-
-
-$G_room_help= '
-<div style=\\"text-align: left; padding: 8px;\\">
-<b>Descrizione</b><br>
-Questa è un\'implementazione della briscola in cinque, così come è spiegata su
-<a target=\\"_blank\\" href=\\"http://it.wikipedia.org/wiki/Briscola#Gioco_a_5\\">Wikipedia</a>; in breve è la variante con l\'asta prima sulla carta e poi sui punti.<br><br>
-<b>Configurazione del browser.</b><br>
-Occorre abilitare i cookies.<br>
-<br>
-<b>Uso del sito</b><br>
-Potete sedervi a un tavolo o rimanere in piedi.<br>
-Se al vostro tavolo si raggiungono i 5 giocatori inizia automaticamente la partita.<br>
-<br>
-<b>Partita</b><br>
-All\'inizio vengono distribuite le carte e parte l\'asta; per partecipare all\'asta, quando sarà il vostro turno, potrete scegliere se andare avanti o passare cliccando sulle icone corrispondenti. Se si arriva ai punti, scrivete nella textbox il vostro rilancio e cliccate PUNTI.<br><br>
-Chi vince l\'asta dovrà decidere il seme della carta scelta e inizierà la mano.<br>
-Per giocare le carte dovrete trascinarle nel quadrato al centro del vostro schermo.<br><br>
-Il vostro turno è sempre segnalato da una cornice verde lampeggiante intorno al quadrato al centro del vostro schermo.<br><br>
-Durante la partita, se vorrete ricaricare la pagina, usate l\'apposito bottone \\"reload\\" in basso a destra.<br>
-Dopo che è iniziata una partita per uscirne dovete chiedere agli altri giocatori di sbloccarla cliccando sul lucchetto. Se non si segue questa prassi, una volta usciti, non vi potrete sedere a nessun tavolo per '.floor(BAN_TIME/60).' minuti.
-<dl>
-<dt><b>Comandi della chat</b>
-<dd><b>/nick <i><nuovo_nickname></i></b> - cambio di nickname
-<dd>.. to be continue ..
-</dl>
-</div>
-';
-
-$G_room_about= '<br>
-<div id=\\"header\\" class=\\"header\\">
- <img class=\\"nobo\\" src=\\"img/brisk_logo64.png\\">
- briscola chiamata in salsa ajax
-</div>
-<br><b>version '.$G_brisk_version.'</b><br><br>
-Copyright 2006-2007 <a href=\\"mailto:brisk@alternativeoutput.it\\">Matteo Nastasi</a> (aka mop)<br><br>';
-
-
-function xcape($s)
-{
- $from = array ( '\\', '@', '|' );
- $to = array ( '\\\\', '@', '¦' );
-
- return (str_replace($from, $to, htmlentities($s,ENT_COMPAT,"UTF-8")));
-}
-
-
-class Card {
- var $value; /* 0 - 39 card value */
- var $stat; /* 'bunch', 'hand', 'table', 'take' */
- var $owner; /* (table position 0-4) */
- // var $pos; /* Pos in hand. */
- var $x; /* When played the X position on the table of the owner. */
- var $y; /* When played the Y position on the table of the owner. */
-
- function Card($value, $stat, $owner)
- {
- $this->value = $value;
- $this->stat = $stat; // Card stat
- $this->owner = $owner;
- }
-
- function assign($stat,$owner)
- {
- $this->stat = $stat; // Card stat
- $this->owner = $owner;
- }
-
- function setpos($pos)
- {
- $this->pos = $pos;
- }
-
- function play($x,$y)
- {
- $this->stat = 'table'; // Card stat
- $this->x = $x;
- $this->y = $y;
- }
-
- function take($newown)
- {
- $this->stat = 'take'; // Card stat
- $this->owner = $newown;
- }
-}
-
-class Table {
- var $player;
- var $player_n;
- var $card;
- var $mazzo;
- var $gstart;
- var $turn;
-
- var $asta_pla;
- var $asta_pla_n;
- var $asta_card;
- var $asta_pnt;
-
- var $mult;
- var $points; // points array
- var $points_n; // number of row of points
- var $total;
-
- var $asta_win;
- var $briscola;
- var $friend;
-
- var $old_reason;
- var $old_asta_pnt;
- var $old_pnt;
- var $old_win;
- var $old_friend;
-
- function Table()
- {
- $this->player = array();
- $this->player_n = 0;
- $this->card = &$this->bunch_create();
- $this->asta_pla = array(); // TRUE: in auction, FALSE: out of the auction
- $this->asta_pla_n= -1;
- $this->asta_card = -1;
- $this->asta_pnt = -1;
- $this->mult = 1;
- $this->points = array( );
- $this->points_n = 0;
- $this->total = array( 0, 0, 0, 0, 0);
- $this->asta_win = -1;
- $this->briscola = -1;
- $this->friend = -1;
- $this->turn = 0;
- $this->old_reason = "";
- $this->old_asta_pnt = -1;
- $this->old_pnt = -1;
- $this->old_win = -1;
- $this->old_friend= -1;
-
- }
-
- function &bunch_create()
- {
- $ret = array();
-
- for ($i = 0 ; $i < 40 ; $i++) {
- $ret[$i] =& new Card($i, 'bunch', 'no_owner');
- }
-
- $oret = &$ret;
- return ($oret);
- }
-
- function bunch_make()
- {
- $ct = array(0,0,0,0,0);
-
- mt_srand(make_seed());
-
- for ($i = 39 ; $i >= 0 ; $i--)
- $rest[$i] = $i;
-
- for ($i = 39 ; $i >= 0 ; $i--) {
- $rn = rand(0, $i);
-
- if ($rn == 0)
- log_main("RND ZERO", "");
-
- $id = $rest[$rn];
-
- $owner = $i % 5;
- $this->card[$id]->assign('hand', $owner);
-
- $rest[$rn] = $rest[$i];
- // $pubbpos[$rn2] = $pubbpos[$i];
- }
- }
-
- function init(&$userarr)
- {
- $this->mazzo = rand(0,PLAYERS_N-1);
- $this->points_n = 0;
- $this->mult = 1;
- $this->old_win =-1;
- $this->old_reason = "";
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $this->total[$i] = 0;
- $user_cur = &$userarr[$this->player[$i]];
- $user_cur->exitislock = TRUE;
- }
-
- log_main("table::init","ci siamo");
- }
-
- function game_init(&$userarr)
- {
- log_rd2("XXX", "GSTART 4");
-
- $this->gstart = ($this->mazzo+1) % PLAYERS_N;
- $this->bunch_make();
-
-
- $this->asta_pla_n = PLAYERS_N;
- $this->asta_card = -1;
- $this->asta_pnt = 60;
- $this->asta_win = -1;
- $this->briscola = -1;
- $this->friend = -1;
- $this->turn = 0;
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $this->asta_pla[$i] = TRUE;
- $user_cur = &$userarr[$this->player[$i]];
- $user_cur->subst = 'asta';
- $user_cur->asta_card = -2;
- $user_cur->asta_pnt = -1;
- $user_cur->handpt = $this->hand_points($i);
- // SEE function calculate_points(&$table)
- }
- }
-
- function game_next()
- {
- $this->mazzo = ($this->mazzo + 1) % PLAYERS_N;
- }
-
- function getPlayer($idx)
- {
- return ($this->player[$idx]);
- }
-
- function setPlayer($idx, $player)
- {
- $this->player[$idx] = $player;
- }
-
- function user_add($idx)
- {
- $this->player[$this->player_n] = $idx;
- $this->player_n++;
-
- return ($this->player_n - 1);
- }
-
- function user_rem(&$bri, &$user)
- {
- $tabpos = $user->table_pos;
-
- /* verifico la consistenza dei dati */
- if ($bri->user[$this->player[$tabpos]] == $user) {
-
- /* aggiorna l'array dei giocatori al tavolo. */
- for ($i = $tabpos ; $i < $this->player_n-1 ; $i++) {
- $this->player[$i] = $this->player[$i+1];
- $user_cur = &$bri->user[$this->player[$i]];
- $user_cur->table_pos = $i;
- }
- $this->player_n--;
- }
- else {
- log_main($user->sess, "INCONSISTENCY ON TABLE.");
- }
- }
-
- function hand_points($idx)
- {
- GLOBAL $G_all_points;
-
- $tot = 0;
-
- for ($i = 0 ; $i < 40 ; $i++) {
- if ($this->card[$i]->owner != $idx)
- continue;
-
- $ctt = $this->card[$i]->value % 10;
- $tot += $G_all_points[$ctt];
- }
-
- return ($tot);
- }
-
- function exitlock_show(&$userarr, $table_pos)
- {
- $ct = $this->exitlock_calc(&$userarr, $table_pos);
-
- $ret = sprintf('exitlock_show(%d, %s);', $ct,
- ($userarr[$this->player[$table_pos]]->exitislock ? 'true' : 'false'));
- return ($ret);
- }
-
- function exitlock_calc(&$userarr, $table_pos)
- {
- $ct = 0;
-
- for ($i = 0 , $ct = 0 ; $i < PLAYERS_N ; $i++) {
- if ($userarr[$this->player[$i]]->exitislock == FALSE)
- $ct++;
- }
-
- return ($ct);
- }
-} // End class Table
-
-class User {
- var $name; // name of the user
- var $sess; // session of the user
- var $ip; // ip of the user
- var $lacc; // last access (for the cleanup)
- var $laccwr; // last access (for the cleanup)
- var $bantime; // timeout to temporary ban
- var $stat; // status (outdoor, room, table, game, ...)
- var $subst; // substatus for each status
- var $step; // step of the current status
- var $trans_step; // step to enable transition between pages (disable == -1)
- var $comm; // commands array
- var $asta_card; //
- var $asta_pnt; //
- var $handpt; // Total card points at the beginning of the current hand.
- var $exitislock; // Player can exit from the table ?
- var $table; // id of the current table (if in table state)
- var $table_pos; // idx on the table
- var $the_end; // Flag to change the end of the session
-
- function User($name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
- $this->name = $name;
- $this->sess = $sess;
- $this->ip = $ip;
- $this->lacc = time();
- $this->laccwr = time();
- $this->bantime = 0;
- $this->stat = $stat;
- $this->subst = $subst;
- $this->step = 1;
- $this->trans_step = -1;
- $this->comm = array();
- $this->asta_card = -2;
- $this->asta_pnt = -1;
- $this->handpt = -1;
- $this->exitislock = TRUE;
-
- $this->table = $table;
- }
-
- function stat_set($stat) {
- $this->stat = "$stat";
-
- /*
- if (validate_sess($this->sess)) {
- $fp = fopen(PROXY_PATH."/".$this->sess.".stat", 'w');
- fwrite($fp, sprintf("%s\n",$this->stat));
- fclose($fp);
- }
- */
- }
-
- function step_set($step) {
- $this->step = $step;
-
- do {
- if (validate_sess($this->sess) == FALSE)
- break;
- if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE)
- break;
- fwrite($fp, pack("l",$this->step), 4);
- fclose($fp);
-
- return (TRUE);
- } while (0);
-
- return (FALSE);
- }
-
- function step_inc() {
- $this->step++;
-
- if (validate_sess($this->sess)) {
- $fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w');
- fwrite($fp, pack("l",$this->step), 4);
- fclose($fp);
-
- return (TRUE);
- }
-
- return (FALSE);
- }
-}
-
-function step_get($sess) {
- $fp = FALSE;
- $ct = 0;
- do {
- if (validate_sess($sess) == FALSE)
- break;
- $ct = 1;
- if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE)
- break;
- $ct = 2;
- if (($s = fread($fp, 4)) == FALSE)
- break;
- $ct = 3;
- if (strlen($s) != 4)
- break;
- $ct = 4;
- $arr = unpack('l', $s);
- fclose($fp);
-
- // log_rd2($sess, "A0: ".$arr[0]." A1: ".$arr[1]);
- return ($arr[1]);
- } while (0);
-
- if ($fp != FALSE)
- fclose($fp);
-
- log_rd2($sess, "STEP_GET: return false ".$ct);
- return (FALSE);
-}
-
-function step_unproxy($sess) {
- log_rd2($sess, "UNPROXY: ".PROXY_PATH."/".$sess.".step");
- @unlink(PROXY_PATH."/".$sess.".step");
-}
-
-
-class brisco {
- var $user;
- var $table;
- var $comm; // commands for many people
- var $step; // current step of the comm array
- var $garbage_timeout;
-
- function brisco () {
- $this->user = array();
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $this->user[$i] =& new User("", "");
- }
- for ($i = 0 ; $i < TABLES_N ; $i++)
- $this->table[$i] =& new Table();
- $this->garbage_timeout = 0;
- }
-
- function garbage_manager($force)
- {
-
- /* Garbage collector degli utenti in timeout */
- $curtime = time();
- if ($force || $this->garbage_timeout < $curtime) {
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $user_cur = &$this->user[$i];
- if ($user_cur->sess == "")
- continue;
-
- if ($user_cur->lacc + EXPIRE_TIME_RD < $curtime) { // Auto logout dell'utente
- log_rd2($user_cur->sess, "AUTO LOGOUT.");
-
- if ($user_cur->stat == 'table' || $user_cur->stat == 'room') {
- log_auth($user_cur->sess, "Autologout session.");
-
- $tmp_sess = $user_cur->sess;
- $user_cur->sess = "";
- step_unproxy($tmp_sess);
- $user_cur->name = "";
- $user_cur->the_end = FALSE;
-
- log_rd2($user_cur->sess, "AUTO LOGOUT.");
- if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
- $this->room_wakeup(&$user_cur);
- else if ($user_cur->subst == 'standup')
- $this->room_outstandup(&$user_cur);
- else
- log_rd2($sess, "LOGOUT FROM WHAT ???");
- }
- }
-
- if ($user_cur->laccwr + EXPIRE_TIME_SMAMMA < $curtime) { // lo rimettiamo in piedi
- if ($user_cur->stat == 'room' && $user_cur->subst == 'sitdown') {
- $this->room_wakeup(&$user_cur);
- $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
- $user_cur->comm[$user_cur->step % COMM_N] .= show_notify("<br>Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti. <br><br>Quindi ritorni tra i <b>Giocatori in piedi</b>.", 0, "torna ai tavoli", 400, 100);
- $user_cur->step_inc();
- }
- }
- }
- log_rd2($user_cur->sess, "GARBAGE UPDATED!");
-
- $this->garbage_timeout = time() + GARBAGE_TIMEOUT;
- }
-
- // BAN_IP_CLEAN
-
- }
-
-
- function room_wakeup(&$user)
- {
- $table_idx = $user->table;
- $table = &$this->table[$table_idx];
-
- log_main("WAKEUP", "begin function table:".$table_idx." stat: ".$user->stat." subst: ".$user->subst);
-
- $curtime = time();
-
- $from_table = ($user->stat == "table");
- if ($from_table) {
- log_main("WAKEUP", "from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n);
-
- for ($i = 0 ; $i < $table->player_n ; $i++) {
- $user_cur = &$this->user[$table->player[$i]];
- log_main("PREIMPOST", "INLOOP name: ".$user_cur->name);
-
- if ($user_cur != $user) {
- $user_cur->stat_set("room");
- $user_cur->subst = "sitdown";
- $user_cur->laccwr = $curtime;
- }
- else if ($user->sess != "") {
- $user_cur->stat_set("room");
- $user_cur->subst = "standup";
- $user_cur->laccwr = $curtime;
- $user_cur->table = -1;
- }
- }
- }
- else {
- $user->stat_set("room");
- $user->subst = "standup";
- $user->laccwr = $curtime;
- }
- /* aggiorna l'array dei giocatori al tavolo. */
- $table->user_rem(&$this, &$user);
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $user_cur = &$this->user[$i];
- if ($user_cur->sess == '' || $user_cur->stat != 'room')
- continue;
-
- log_main("VALORI", "name: ".$user_cur->name."from_table: ".$from_table." tab: ".$user_cur->table." taix: ".$table_idx." ucur: ".$user_cur." us: ".$user);
-
- $ret = "gst.st = ".($user_cur->step+1)."; ";
- if ($from_table && ($user_cur->table == $table_idx || $user_cur == $user)) {
- $ret .= 'gst.st_loc++; the_end=true; window.onunload = null; document.location.assign("index.php");|';
- // $ret .= 'gst.st_loc++; document.location.assign("index.php");|';
- log_main("DOCUMENT.index.php", "from table");
- }
- else if ($user_cur->stat == "room") {
- log_main("DOCUMENT.index.php", "from table");
-
- $ret .= table_content($this, $user_cur, $table_idx);
- $ret .= standup_content($this, $user_cur);
-
- $act_content = table_act_content(FALSE, 0, $table_idx, $user->table);
- $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
-
-
- if ($user_cur == $user) {
- // set the new status
- $ret .= 'subst = "standup"; ';
- // clean the action buttons in other tables
- for ($e = 0 ; $e < TABLES_N ; $e++) {
- if ($this->table[$e]->player_n < PLAYERS_N)
- $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, table_act_content(TRUE, 0, $e, $user->table));
- }
- }
- else {
- $act_content = table_act_content(($user_cur->subst == 'standup'), $table->player_n, $table_idx, $user_cur->table);
- $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
- }
- }
- log_wr($user_cur->sess, "ROOM_WAKEUP: ".$ret);
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
- }
-
-
-
-
- function room_outstandup(&$user)
- {
- $this->room_sitdown(&$user, -1);
- }
-
- function table_update(&$user)
- {
- log_main("table_update", "pre - USER: ".$user->name);
-
- $table_idx = $user->table;
-
- if ($table_idx > -1)
- $table = &$this->table[$table_idx];
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $ret = "";
- $user_cur = &$this->user[$i];
- if ($user_cur->sess == '' || $user_cur->stat != 'room')
- continue;
-
- $ret = "gst.st = ".($user_cur->step+1)."; ";
- if ($table_idx > -1)
- $ret .= table_content($this, $user_cur, $table_idx);
-
- if ($user_cur == $user) {
- $ret .= sprintf('$("myname").innerHTML = "<b>%s</b>: ";', xcape($user->name));
- }
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
-
- log_main("table_update", "post");
- }
-
- function room_sitdown(&$user, $table_idx)
- {
- log_main("room_sitdown", ($user == FALSE ? "USER: FALSE" : "USER: ".$user->name));
-
- if ($table_idx > -1)
- $table = &$this->table[$table_idx];
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $ret = "";
- $user_cur = &$this->user[$i];
- if ($user_cur->sess == '' || $user_cur->stat != 'room')
- continue;
-
- $ret = "gst.st = ".($user_cur->step+1)."; ";
- if ($table_idx > -1)
- $ret .= table_content($this, $user_cur, $table_idx);
- $ret .= standup_content($this, $user_cur);
-
- if ($user_cur == $user) {
- $ret .= 'subst = "sitdown"; ';
- // clean the action buttons in other tables
- for ($e = 0 ; $e < TABLES_N ; $e++) {
- $act_content = table_act_content(FALSE, 0, $e, $user_cur->table);
- $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $e, $act_content);
- }
- }
- else if ($table_idx > -1) {
- if ($table->player_n == PLAYERS_N) {
- $act_content = table_act_content(($user_cur->subst == 'standup'), PLAYERS_N, $table_idx, $user_cur->table);
- $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $table_idx, $act_content);
- }
- }
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
- }
-
- function chatt_send(&$user, $mesg)
- {
- if ($user->stat == 'table') {
- $table = &$this->table[$user->table];
- }
-
- $user_mesg = substr($mesg,6);
-
- $timecur = time();
-
- $dt = date("H:i ", $timecur);
- if (strncmp($user_mesg, "/nick ", 6) == 0) {
- log_main($user->sess, "chatt_send BEGIN");
-
- if (($name_new = validate_name(substr($user_mesg, 6))) == FALSE) {
- $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","Il nickname deve contenere almeno una lettera o una cifra.");', $dt.NICKSERV, xcape($name_new));
- $user->step_inc();
-
- return;
- }
- $user_mesg = "COMMAND ".$user_mesg;
- // Search dup name
- // change
- // update local graph
- // update remote graphs
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $user_cur = &$this->user[$i];
- // if ($user_cur->sess == '' || $user_cur->stat != 'room')
- if ($user_cur->sess == '')
- continue;
- if ($user_cur->name == $name_new) {
- $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","Nickname <b>%s</b> già in uso.");', $dt.NICKSERV, xcape($name_new));
- $user->step_inc();
- break;
- }
- }
- if ($i == MAX_PLAYERS) {
- $user->name = $name_new;
-
- log_main($user->sess, "chatt_send start set");
-
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- log_main($user->sess, "chatt_send set loop");
-
- $user_cur = &$this->user[$i];
- if ($user_cur->sess == '')
- continue;
- if ($user_cur->stat == 'room') {
- if ($user->stat == 'room' && $user->subst == 'standup') {
- $this->standup_update(&$user);
- }
- else if ($user->stat == 'room' && $user->subst == 'sitdown' ||
- $user->stat == 'table') {
- log_main($user->sess, "chatt_send pre table update");
-
- $this->table_update(&$user);
-
- log_main($user->sess, "chatt_send post table update");
- }
- }
- else if ($user_cur->stat == 'table' && $user_cur->table == $user->table) {
- $table = &$this->table[$user->table];
-
- $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
- $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('set_names(" %s", " %s", " %s", " %s", " %s"); ',
- xcape($this->user[$table->player[($user_cur->table_pos)%PLAYERS_N]]->name),
- xcape($this->user[$table->player[($user_cur->table_pos+1)%PLAYERS_N]]->name),
- xcape($this->user[$table->player[($user_cur->table_pos+2)%PLAYERS_N]]->name),
- (PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+3)%PLAYERS_N]]->name)),
- (PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+4)%PLAYERS_N]]->name)));
- if ($user_cur == $user)
- $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "<b>%s</b>";',
- xcape($user->name,ENT_COMPAT,"UTF-8"));
- $user_cur->step_inc();
- }
- }
- }
- }
- else {
- for ($i = 0 ; $i < ($user->stat == 'room' ? MAX_PLAYERS : PLAYERS_N) ; $i++) {
- if ($user->stat == 'room') {
- $user_cur = &$this->user[$i];
- if ($user_cur->sess == '' || $user_cur->stat != 'room')
- continue;
- }
- else {
- $user_cur = &$this->user[$table->player[$i]];
- }
-
- $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
- $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('chatt_sub("%s","%s");',
- $dt.xcape($user->name), xcape($user_mesg));
- $user_cur->step_inc();
- }
- log_legal($timecur, $user->sess, $user->name,
- ($user->stat == 'room' ? 'room' : 'table '.$user->table),$user_mesg);
- }
- }
-
- function &get_user($sess, &$idx)
- {
- GLOBAL $PHP_SELF, $G_false;
-
- if (validate_sess($sess)) {
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- if (strcmp($sess, $this->user[$i]->sess) == 0) {
- // find it
- $idx = $i;
- $ret = &$this->user[$i];
- return ($ret);
- }
- }
- log_main($sess, sprintf("get_user: Wrong sess from page [%s]",$PHP_SELF));
- // for ($i = 0 ; $i < MAX_PLAYERS ; $i++)
- // log_main($sess, sprintf("get_user: Wrong sess compared with [%s]",$this->user[$i]->sess));
- }
- else {
- log_main($sess, sprintf("get_user: Wrong strlen [%s]",$sess));
- }
-
- return ($G_false);
- }
-
- /*
- * function &add_user(&$bri, &$sess, &$idx, $name, $ip)
- *
- * RETURN VALUE:
- * if ($idx != -1 && ret == FALSE) => duplicated nick
- * if ($idx == -2 && ret == FALSE) => invalid name
- * if ($idx == -1 && ret == FALSE) => no space left
- * if (ret == TRUE) => SUCCESS
- */
- function &add_user(&$sess, &$idx, $name, $ip)
- {
- GLOBAL $G_false;
-
- $idx = -1;
- $idfree = -1;
-
- if (($name_new = validate_name($name)) == FALSE) {
- $idx = -2;
- return ($G_false);
- }
-
- log_auth("XXX", sprintf("ARRIVA: [%s]", $sess));
- if (validate_sess($sess) == FALSE)
- $sess = "";
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- /* free user ? */
- if (strcmp($sess, $this->user[$i]->sess) == 0) {
- if ($idx == -1)
- $idx = $i;
- }
- if ($idfree == -1 && strcmp("", $this->user[$i]->sess) == 0) {
- $idfree = $i;
- }
- if (strcmp($this->user[$i]->name, $name_new) == 0) {
- $idx = $i;
- break;
- }
- }
- if ($idx == -1)
- $idx = $idfree;
-
- log_auth("XXX", sprintf("TROVATO A QUESTO PUNTO [%d] sess [%s] name [%s]", $idx, $sess, $name_new));
-
- if ($idx != -1 && $i == MAX_PLAYERS) {
- /* SUCCESS */
- $curtime = time();
- if ($sess == "") {
- $this->user[$idx]->sess = uniqid("");
- $sess = $this->user[$idx]->sess;
-
- }
- else {
- $this->user[$idx]->sess = $sess;
- }
- $this->user[$idx]->name = $name_new;
- $this->user[$idx]->stat_set("room");
- // MOP $this->user[$idx]->step_set(0);
- $this->user[$idx]->subst = "standup";
- $this->user[$idx]->lacc = $curtime;
- $this->user[$idx]->laccwr = $curtime;
- $this->user[$idx]->bantime = 0;
- $this->user[$idx]->ip = $ip;
- log_main("XXX", sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s]", $idx, $sess, $name_new));
-
- return ($this->user[$idx]);
- }
-
- return ($G_false);
- }
-
- function standup_update(&$user)
- {
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $user_cur = &$this->user[$i];
- if ($user_cur->sess == '')
- continue;
-
- log_main("STANDUP START", $user_cur->stat);
-
- if ($user_cur->stat == 'room') {
- $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ".standup_content($this, $user_cur);
- if ($user_cur == $user)
- $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "<b>%s</b>: ";', xcape($user->name));
-
- log_main("FROM STANDUP", "NAME: ".$user_cur->name." SENDED: ".$user_cur->comm[$user_cur->step % COMM_N]);
-
- $user_cur->step_inc();
- }
- }
- }
-
-
-} // end class brisco
-
-function make_seed()
-{
- list($usec, $sec) = explode(' ', microtime());
- return (float) $sec + ((float) $usec * 100000);
-}
-
-function log_only2($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
-
- if (($fp = @fopen("/tmp/brisk_only2.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_only($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
-
- if (($fp = @fopen("/tmp/brisk_only.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_main($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_main.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_rd($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_rd.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_rd2($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_rd2.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_send($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_send.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_auth($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_auth.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%d] [%s] [%s]\n", time(), $sess, $log));
- fclose($fp);
- }
-}
-
-function log_lock($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_lock.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%d] [%s] [%s]\n", time(), $sess, $log));
- fclose($fp);
- }
-}
-
-function log_wr($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_wr.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_load($sess, $log) {
- if (BRISK_DEBUG != TRUE)
- return;
-
- if (($fp = @fopen("/tmp/brisk_load.log", 'a')) != FALSE) {
- fwrite($fp, sprintf("SESS: [%s] [%s]\n", $sess, $log));
- fclose($fp);
- }
-}
-
-function log_legal($timecur, $sess, $name, $where, $mesg)
-{
- GLOBAL $_SERVER;
-
- if (($fp = @fopen(LEGAL_PATH, 'a')) != FALSE) {
- /* Unix time | session | nickname | IP | where was | mesg */
- fwrite($fp, sprintf("%ld|%s|%s|%s|%s|%s|\n", $timecur, $sess, $name, $_SERVER['REMOTE_ADDR'], $where , $mesg));
- fclose($fp);
- }
-}
-
-
-
-function init_data()
-{
- $brisco =& new brisco();
-
- return $brisco;
-}
-
-function lock_data()
-{
- GLOBAL $sess;
-
- // echo "LOCK: ".FTOK_PATH."/main";
- // exit;
- if (($tok = ftok(FTOK_PATH."/main", "B")) == -1) {
- echo "FTOK FAILED";
- exit;
- }
- // echo "FTOK ".$tok."<br>";
- if (($res = sem_get($tok)) == FALSE) {
- echo "SEM_GET FAILED";
- exit;
- }
- if (sem_acquire($res)) {
- log_only($sess, "LOCK");
- return ($res);
- }
- else
- return (FALSE);
-}
-
-function unlock_data($res)
-{
- GLOBAL $sess;
-
- log_only($sess, "UNLOCK");
- return (sem_release($res));
-}
-
-
-function lock_banlist()
-{
- if (($tok = ftok(FTOK_PATH."/main", "L")) == -1) {
- echo "FTOK FAILED";
- exit;
- }
- if (($res = sem_get($tok)) == FALSE) {
- echo "SEM_GET FAILED";
- exit;
- }
- if (sem_acquire($res))
- return ($res);
- else
- return (FALSE);
-}
-
-function unlock_banlist($res)
-{
- return (sem_release($res));
-}
-
-
-function &load_data()
-{
- GLOBAL $G_false, $sess;
-
- if (($tok = ftok(FTOK_PATH."/main", "B")) == -1) {
- echo "FTOK FAILED";
- exit;
- }
-
- if ($shm = shm_attach($tok, SHM_DIMS)) {
- $bri = @shm_get_var($shm, $tok);
-
- log_only($sess, "bri == ".($bri == FALSE ? "FALSE" : "TRUE")." bri === ".($bri === FALSE ? "FALSE" : "TRUE")." bri isset ".(isset($bri) ? "TRUE" : "FALSE"));
- if (isset($bri))
- log_only($sess, "bri count ".count($bri));
-
- if ($bri == FALSE) {
- log_only($sess, "INIT MAIN DATA");
-
- $bri = init_data();
- if (shm_put_var($shm, $tok, $bri) == FALSE) {
- log_only($sess, "PUT_VAR FALLITA ".strlen(serialize($bri)));
- log_only($sess, serialize($bri));
- }
- }
-
- shm_detach($shm);
-
- $ret = &$bri;
- return ($ret);
- }
-
- return ($G_false);
-}
-
-
-function save_data(&$bri)
-{
- GLOBAL $sess;
-
- $ret = FALSE;
- $shm = FALSE;
- $isacq = FALSE;
-
- // var_dump($bri);
-
- if (($tok = ftok(FTOK_PATH."/main", "B")) == -1)
- return (FALSE);
-
- do {
- $isacq = TRUE;
-
- if (($shm = shm_attach($tok, SHM_DIMS)) == FALSE)
- break;
-
- // log_only($sess, "PUT_VAR DI ".strlen(serialize($bri)));
- if (shm_put_var($shm, $tok, $bri) == FALSE) {
- log_only($sess, "PUT_VAR FALLITA ".strlen(serialize($bri)));
- log_only($sess, serialize($bri));
- break;
- }
- // log_main("XXX", "QUI CI ARRIVA [".$bri->user[0]->name."]");
- $ret = TRUE;
- } while (0);
-
- if ($shm)
- shm_detach($shm);
-
- return ($ret);
-}
-
-function table_act_content($isstanding, $sitted, $table, $cur_table)
-{
- $ret = "";
-
- if ($isstanding) {
- if ($sitted < PLAYERS_N) {
- $ret = sprintf('<input type=\\"button\\" class=\\"button\\" name=\\"xhenter%d\\" value=\\"Mi siedo.\\" onclick=\\"act_sitdown(%d);\\">', $table, $table);
- }
- }
- else {
- if ($table == $cur_table)
- $ret = sprintf('<input type=\\"button\\" class=\\"button\\" name=\\"xwakeup\\" value=\\"Mi alzo.\\" onclick=\\"act_wakeup();\\">');
- else
- $ret = "";
- }
- return ($ret);
-}
-
-function table_content($bri, $user, $table_idx)
-{
- $content = "";
- $ret = "";
- // TODO
- //
- // Si possono usare i dati nella classe table
- //
-
- $sess = $user->sess;
- $table = &$bri->table[$table_idx];
-
- if ($user->stat != 'room')
- return;
-
- for ($i = 0 ; $i < $table->player_n ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
-
- if ($user_cur == $user)
- { $hilion = "<b>"; $hilioff = "</b>"; }
- else
- { $hilion = ""; $hilioff = ""; }
-
- log_main($user_cur->name, sprintf("IN TABLE [%d]", $table_idx));
-
- $content .= sprintf("%s%s%s<br>",$hilion, xcape($user_cur->name), $hilioff);
- }
- /*
- for ( ; $i < PLAYERS_N ; $i++)
- $content .= "<br>";
- */
-
- $ret .= sprintf('$("table%d").innerHTML = "%s";', $table_idx, $content);
-
- return ($ret);
-}
-
-function standup_content(&$bri, $user)
-{
- $ret = "";
- $content = "";
-
- if ($user->stat != 'room')
- return;
-
- for ($e = 0 , $ct = 0 ; $ct < 4 && $e < MAX_PLAYERS ; $e++) {
- if ($bri->user[$e]->sess == "" || $bri->user[$e]->stat != "room" || $bri->user[$e]->name == "")
- continue;
- $ct++;
- }
-
- $content .= sprintf('<table cols=\\"%d\\" class=\\"table_standup\\">', $ct);
-
- for ($e = 0 , $ct = 0 ; $e < MAX_PLAYERS ; $e++) {
- if ($bri->user[$e]->sess == "" || $bri->user[$e]->stat != "room" || $bri->user[$e]->name == "")
- continue;
-
-
- if ($bri->user[$e]->subst == "standup") {
- if (($ct % 4) == 0) {
- $content .= '<tr>';
- }
- if ($bri->user[$e] == $user)
- { $hilion = "<b>"; $hilioff = "</b>"; }
- else
- { $hilion = ""; $hilioff = ""; }
-
- $content .= sprintf('<td class=\\"room_standup\\">%s%s%s</td>',$hilion, xcape($bri->user[$e]->name), $hilioff);
- if (($ct % 4) == 3) {
- $content .= '</tr>';
- }
- $ct++;
- }
- }
- $content .= '</table>';
-
- $content2 = '<input class=\\"button\\" name=\\"logout\\" value=\\"Esco.\\" onclick=\\"window.onunload = null; act_logout();\\" type=\\"button\\">';
- $ret .= sprintf('$("standup").innerHTML = "%s"; $("esco").innerHTML = "%s";',
- $content, $content2);
-
- return ($ret);
-}
-
-
-function show_notify($text, $tout, $butt, $w, $h)
-{
- log_main("SHOW_NOTIFY", $text);
- return sprintf('var noti = new notify(gst,"%s",%d,"%s",%d,%d);', $text, $tout, $butt, $w, $h);
-}
-
-function briscola_show($bri, $table, $user)
-{
- $ptnadd = "";
- $ret = "";
-
- if ($table->asta_card == 9)
- $ptnadd = sprintf("<br>con %d punti", $table->asta_pnt);
-
- /* text of caller cell */
- if ($user->table_pos == $table->asta_win)
- $ret .= sprintf('$("callerinfo").innerHTML = "Chiami%s:";', $ptnadd);
- else
- $ret .= sprintf('$("callerinfo").innerHTML = "Chiama %s%s:";',
- xcape($bri->user[$table->player[$table->asta_win]]->name), $ptnadd);
-
- $ret .= sprintf('$("caller").style.backgroundImage = \'url("img/brisk_caller_sand%d.png")\';',
- $table->asta_win);
- $ret .= sprintf('$("callerimg").src = "img/%02d.png";', $table->briscola);
- $ret .= sprintf('$("caller").style.visibility = "visible";');
- $ret .= sprintf('$("chooseed").style.visibility = "hidden";');
- $ret .= sprintf('$("astalascio").style.visibility = "";');
- $ret .= sprintf('$("asta").style.visibility = "hidden";');
- $ret .= sprintf('show_astat(-2,-2,-2,-2,-2);');
-
- return ($ret);
-}
-
-
-function game_result($asta_pnt, $pnt)
-{
- if ($asta_pnt == 61) {
- if ($pnt > 60)
- return (1);
- else if ($pnt == 60)
- return (0);
- else
- return (-1);
- }
- else {
- if ($pnt >= $asta_pnt)
- return (1);
- else
- return (-1);
- }
-}
-
-function multoval($mult)
-{
- if ($mult == 2)
- return ("doppio");
- else if ($mult == 4)
- return ("quadruplo");
- else
- return (sprintf("%d-plo", $mult));
-}
-
-function show_table_info(&$bri, &$table, $table_pos)
-{
- $ret = "";
- $user = &$bri->user[$table->player[$table_pos]];
-
- $pnt_min = $table->points_n - MAX_POINTS < 0 ? 0 : $table->points_n - MAX_POINTS;
- $noty = sprintf('<table class=\"points\"><tr><th></th>');
-
- // Names.
- for ($i = 0 ; $i < PLAYERS_N ; $i++)
- $noty .= sprintf('<th class=\"td_points\">%s</th>', xcape($bri->user[$table->player[$i]]->name));
- $noty .= sprintf("</tr>");
-
- // Points.
- log_main("show_table_info", "pnt_min: ".$pnt_min." Points_n: ".$table->points_n);
-
- for ($i = $pnt_min ; $i < $table->points_n ; $i++) {
- $noty .= sprintf('<tr><th class=\"td_points\">%d</th>', $i+1);
- for ($e = 0 ; $e < PLAYERS_N ; $e++)
- $noty .= sprintf('<td class=\"td_points\">%d</td>', $table->points[$i % MAX_POINTS][$e]);
- $noty .= "</tr>";
- }
-
- // Total points.
- $noty .= '<tr><th class=\"td_points\">Tot.</th>';
- for ($e = 0 ; $e < PLAYERS_N ; $e++)
- $noty .= sprintf('<td class=\"td_points\">%d</td>', $table->total[$e]);
- $noty .= "</tr></table>";
-
- if ($table->old_reason != "") {
- $noty .= sprintf("<hr><b>%s</b><br>", xcape($table->old_reason));
- }
-
- if ($table->old_win != -1) {
- $win = $table->player[$table->old_win];
- $fri = $table->player[$table->old_friend];
-
- $wol = game_result($table->old_asta_pnt, $table->old_pnt);
-
- if ($win != $fri) {
- $noty .= sprintf("<hr>Nell'ultima mano ha chiamato <b>%s</b>, il socio era <b>%s</b>,<br>",
- xcape($bri->user[$win]->name),
- xcape($bri->user[$fri]->name));
- if ($table->old_pnt == 120) {
- $noty .= sprintf("hanno fatto <b>cappotto</b> EBBRAVI!.<hr>");
- }
- else {
- $noty .= sprintf("dovevano fare <b>%s</b> punti e ne hanno fatti <b>%d</b>: hanno <b>%s</b>.<hr>",
- ($table->old_asta_pnt > 61 ? "almeno ".$table->old_asta_pnt :
- 'più di 60'), $table->old_pnt,
- ($wol == 1 ? "vinto" : ($wol == 0 ? "pareggiato" : "perso")));
- }
- }
- else {
- $noty .= sprintf("<hr>Nell'ultima mano <b>%s</b> si è chiamato in mano,<br>",
- xcape($bri->user[$win]->name));
- if ($table->old_pnt == 120) {
- $noty .= sprintf("ha fatto <b>cappotto</b> EBBRAVO!.<hr>");
- }
- else {
- $noty .= sprintf("doveva fare <b>%s</b> punti e ne ha fatti <b>%d</b>: ha <b>%s</b>.<hr>",
- ($table->old_asta_pnt > 61 ? "almeno ".$table->old_asta_pnt :
- 'più di 60'), $table->old_pnt,
- ($wol == 1 ? "vinto" : ($wol == 0 ? "pareggiato" : "perso")));
- }
- }
- }
- if ($table->mazzo == $table_pos)
- $noty .= "Fai <b>tu</b> il mazzo,";
- else {
- $unam = xcape($bri->user[$table->player[$table->mazzo]]->name);
- $noty .= "Il mazzo a <b>$unam</b>,";
- }
-
- if ($user->subst == 'asta') {
- if ($table->asta_win == -1) // auction case
- $curplayer = $table->gstart % PLAYERS_N;
- else
- $curplayer = $table->asta_win;
- }
- else if ($user->subst == 'game') {
- $curplayer = ($table->gstart + $table->turn) % PLAYERS_N;
- }
-
-
- if ($curplayer == $table_pos) {
- $noty .= " tocca a <b>te</b> giocare.";
- }
- else {
- $unam = xcape($bri->user[$table->player[$curplayer]]->name);
- $noty .= " tocca a <b>$unam</b> giocare.";
- }
-
- if ($table->mult > 1) {
- $noty .= sprintf(" La partita vale <b>%s</b>.", multoval($table->mult));
- }
- $noty .= "<hr><br>";
-
- $ret .= show_notify($noty, 3000, "torna alla partita", 500, 400);
-
- return ($ret);
-}
-
-function root_wellcome($user)
-{
- GLOBAL $root_wellarr;
- $ret = "";
-
- for ($i = 0 ; $i < count($root_wellarr) ; $i++)
- $ret .= sprintf('chatt_sub("ChanServ: ","%s");', str_replace('"', '\"', $root_wellarr[$i]));
-
- return ($ret);
-}
-
-function table_wellcome($user)
-{
- GLOBAL $table_wellarr;
- $ret = "";
-
- for ($i = 0 ; $i < count($table_wellarr) ; $i++)
- $ret .= sprintf('chatt_sub("ChanServ: ","%s");', str_replace('"', '\"', $table_wellarr[$i]));
-
- return ($ret);
-}
-
-function show_room(&$bri, &$user)
-{
- $ret = sprintf('gst.st = %d;', $user->step);
- $ret .= sprintf('stat = "%s";', $user->stat);
-
- $ret .= root_wellcome($user);
- $ret .= sprintf('subst = "%s";', $user->subst);
- $ret .= sprintf('$("myname").innerHTML = "<b>%s</b>";', xcape($user->name,ENT_COMPAT,"UTF-8"));
- for ($i = 0 ; $i < TABLES_N ; $i++) {
- $ret .= table_content($bri, $user, $i);
- $act_content = table_act_content(($user->subst == 'standup'),
- $bri->table[$i]->player_n, $i, $user->table);
- $ret .= sprintf('$("table_act%d").innerHTML = "%s";', $i, $act_content);
- }
- $ret .= standup_content($bri, $user);
-
- return ($ret);
-}
-
-
-
-/* show table
-is_transition (is from room to table ?)
-is_again (is another game)
-
-Examples of $is_transition, $is_again:
- from reload of the page: FALSE, FALSE
- from sitdown in room: TRUE, FALSE
- from table: asta cmd e tutti passano: TRUE, TRUE
- from table: fine partita: TRUE, TRUE
- */
-function show_table(&$bri, &$user, $sendstep, $is_transition, $is_again)
-{
- $table_idx = $user->table;
- $table = &$bri->table[$table_idx];
- $table_pos = $user->table_pos;
-
- $ret = "table_init();";
- $ret .= $table->exitlock_show(&$bri->user, $table_pos);
- if (!$is_again) {
- /* GENERAL STATUS */
- $ret .= sprintf( 'gst.st = %d; stat = "%s"; subst = "%s"; table_pos = %d;',
- $sendstep, $user->stat, $user->subst, $table_pos);
- /* BACKGROUND */
- $ret .= "background_set();";
-
- /* USERS INFO */
- $ret .= sprintf('$("myname").innerHTML = "<b>%s</b>";', xcape($user->name,ENT_COMPAT,"UTF-8"));
- $ret .= sprintf('set_names(" %s", " %s", " %s", " %s", " %s"); ',
- xcape($bri->user[$table->player[($table_pos)%PLAYERS_N]]->name),
- xcape($bri->user[$table->player[($table_pos+1)%PLAYERS_N]]->name),
- xcape($bri->user[$table->player[($table_pos+2)%PLAYERS_N]]->name),
- (PLAYERS_N == 3 ? "" : xcape($bri->user[$table->player[($table_pos+3)%PLAYERS_N]]->name)),
- (PLAYERS_N == 3 ? "" : xcape($bri->user[$table->player[($table_pos+4)%PLAYERS_N]]->name)));
- }
- /* NOTIFY FOR THE CARD MAKER */
- if ($is_transition) { // && $user->subst == "asta" superfluo
- $ret .= show_table_info(&$bri, &$table, $table_pos);
- }
- if (!$is_again)
- $ret .= table_wellcome($user);
-
- if ($is_transition && !$is_again) { // appena seduti al tavolo, play della mucca
- $ret .= playsound("cow.mp3");
- }
-
-
- /* CARDS */
- if ($is_transition) { // && $user->subst == "asta" superfluo
- $ret .= "|";
-
- for ($i = 0 ; $i < 8 ; $i++) {
- for ($e = 0 ; $e < PLAYERS_N ; $e++) {
- $ct = 0;
- for ($o = 0 ; $o < 40 && $ct < $i+1 ; $o++) {
- if ($table->card[$o]->owner == (($e + $table->gstart) % PLAYERS_N)) {
- $ct++;
- if ($ct == $i+1)
- break;
- }
- }
- log_rd($user->sess, "O ".$o." VAL ".$table->card[$o]->value." Owner: ".$table->card[$o]->owner);
-
- $ret .= sprintf( ' card_send(%d,%d,%d,%8.2f,%d);|', ($table->gstart + $e) % PLAYERS_N,
- $i, ((($e + PLAYERS_N - $table_pos + $table->gstart) % PLAYERS_N) == 0 ?
- $table->card[$o]->value : -1),
- ($i == 7 && $e == (PLAYERS_N - 1) ? 1 : 0.5),$i+1);
- }
- }
- }
- else {
- $taked = array(0,0,0,0,0);
- $inhand = array(0,0,0,0,0);
- $ontabl = array(-1,-1,-1,-1,-1);
- $cards = array();
-
- for ($i = 0 ; $i < 40 ; $i++) {
- if ($table->card[$i]->stat == 'hand') {
- if ($table->card[$i]->owner == $table_pos) {
- $cards[$inhand[$table->card[$i]->owner]] = $table->card[$i]->value;
- }
- $inhand[$table->card[$i]->owner]++;
- }
- else if ($table->card[$i]->stat == 'take') {
- log_main("Card taked:", $table->card[$i]->value."OWN: ".$table->card[$i]->owner);
- $taked[$table->card[$i]->owner]++;
- }
- else if ($table->card[$i]->stat == 'table') {
- $ontabl[$table->card[$i]->owner] = $i;
- }
- }
- $logg = "\n";
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $logg .= sprintf("INHAND: %d IN TABLE %d TAKED %d\n", $inhand[$i], $ontabl[$i], $taked[$i]);
- }
- log_main("Stat table:", $logg);
-
- /* Set ours cards. */
- $oursarg = "";
- for ($i = 0 ; $i < $inhand[$table_pos] ; $i++)
- $oursarg .= ($i == 0 ? "" : ", ").$cards[$i];
- for ($i = $inhand[$table_pos] ; $i < 8 ; $i++)
- $oursarg .= ($i == 0 ? "" : ", ")."-1";
- $ret .= sprintf('card_setours(%s);', $oursarg);
-
- /* Dispose all cards */
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- /* Qui sotto al posto di + 1 c'era + ->gstart ... credo in modo errato */
- $ret .= sprintf('cards_dispose(%d,%d,%d);', $i,
- $inhand[$i], $taked[$i]);
-
- if ($ontabl[$i] != -1) {
- $ret .= sprintf('card_place(%d,%d,%d,%d,%d);',$i, $inhand[$i],
- $table->card[$ontabl[$i]]->value,
- $table->card[$ontabl[$i]]->x, $table->card[$ontabl[$i]]->y);
- }
- }
- }
-
- /* Show auction */
- if ($user->subst == 'asta') {
-
- /* show users auction status */
- $showst = "";
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- $showst .= sprintf("%s%d", ($i == 0 ? "" : ", "),
- ($user_cur->asta_card < 9 ? $user_cur->asta_card : $user_cur->asta_pnt));
- }
- if (PLAYERS_N == 3)
- $showst .= ",-2,-2";
- $ret .= sprintf('show_astat(%s);', $showst);
-
- if ($table->asta_win != -1 && $table->asta_win == $table_pos) {
- /* show card chooser */
- $ret .= sprintf('choose_seed(%s); $("astalascio").style.visibility = ""; $("asta").style.visibility = "hidden";',
- $table->asta_card);
- }
- else {
- /* show auction */
- if ($table_pos == ($table->gstart % PLAYERS_N) &&
- $table->asta_win == -1)
- $ret .= sprintf('dispose_asta(%d,%d, %s);',
- $table->asta_card + 1, $table->asta_pnt+1, ($user->handpt <= 2 ? "true" : "false"));
- else
- $ret .= sprintf('dispose_asta(%d,%d, %s);',
- $table->asta_card + 1, -($table->asta_pnt+1), ($user->handpt <= 2 ? "true" : "false"));
- }
-
- /* Remark */
- if ($table->asta_win == -1) { // auction case
- if ($table_pos == ($table->gstart % PLAYERS_N))
- $ret .= "remark_on();";
- else
- $ret .= "remark_off();";
- }
- else { // chooseed case
- if ($table_pos == $table->asta_win)
- $ret .= "remark_on();";
- else
- $ret .= "remark_off();";
- }
- }
- else if ($user->subst == 'game') {
- /* HIGHLIGHT */
- if (($table->gstart + $table->turn) % PLAYERS_N == $table_pos)
- $ret .= "is_my_time = true; remark_on();";
- else
- $ret .= "remark_off();";
-
- /* WHO CALL AND WATH */
- $ret .= briscola_show($bri, $table, $user);
-
- }
- return ($ret);
- }
-
-function calculate_winner(&$table)
-{
- $briontab = FALSE;
- $ontab = array();
- $ontid = array();
- $cur_win = -1;
- $cur_val = 100;
- $cur_seed = $table->briscola - ($table->briscola % 10);
-
- for ($i = 0 ; $i < 40 ; $i++) {
- if ($table->card[$i]->stat != "table")
- continue;
-
- log_wr($sess, sprintf("Card On table: [%d]", $i));
-
- $v = $table->card[$i]->value;
- $ontab[$table->card[$i]->owner] = $v;
- $ontid[$table->card[$i]->owner] = $i;
- /* se briscola setto il flag */
- if (($v - ($v % 10)) == $cur_seed)
- $briontab = TRUE;
- }
-
- if ($briontab == FALSE) {
- $cur_win = $table->gstart;
- $cur_val = $ontab[$cur_win];
- $cur_seed = $cur_val - ($cur_val % 10);
- }
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- if (($ontab[$i] - ($ontab[$i] % 10)) == $cur_seed) {
- if ($ontab[$i] < $cur_val) {
- $cur_val = $ontab[$i];
- $cur_win = $i;
- }
- }
- }
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $table->card[$ontid[$i]]->owner = $cur_win;
- $table->card[$ontid[$i]]->stat = "take"; // Card stat
- }
- return ($cur_win);
-}
-
-function calculate_points(&$table)
-{
- GLOBAL $G_all_points;
-
- $pro = 0;
-
- if ($table->asta_pnt == 60)
- $table->asta_pnt = 61;
-
- $table->old_reason = "";
- $table->old_win = $table->asta_win;
- $table->old_friend = $table->friend;
- $table->old_asta_pnt = $table->asta_pnt;
-
- for ($i = 0 ; $i < 40 ; $i++) {
- $ctt = $table->card[$i]->value % 10;
- $own = $table->card[$i]->owner;
- if ($own == $table->asta_win || $own == $table->friend)
- $pro += $G_all_points[$ctt];
- }
-
- log_wr("XXX", sprintf("PRO: [%d]", $pro));
-
-
- if ($table->asta_pnt == 61 && $pro == 60) { // PATTA !
- $table->points[$table->points_n % MAX_POINTS] = array();
- for ($i = 0 ; $i < PLAYERS_N ; $i++)
- $table->points[$table->points_n % MAX_POINTS][$i] = 0;
- $table->points_n++;
- $table->old_pnt = $pro;
- $table->mult *= 2;
-
- return;
- }
-
- if ($pro >= $table->asta_pnt)
- $sig = 1;
- else
- $sig = -1;
-
- $table->points[$table->points_n % MAX_POINTS] = array();
- for ($i = 0 ; $i < 5 ; $i++) {
- if ($i == $table->asta_win)
- $pt = ($i == $table->friend ? 4 : 2);
- else if ($i == $table->friend)
- $pt = 1;
- else
- $pt = -1;
-
- log_wr("XXX", sprintf("PRO: pt[%d][%d] = %d", $table->points_n % MAX_POINTS, $i, $pt));
-
- $pt = $pt * $sig * $table->mult * ($pro == 120 ? 2 : 1);
-
- log_wr("XXX", sprintf("PRO:[%d][%d][%d]", $sig, $table->mult, ($pro == 120 ? 2 : 1)));
-
- $table->points[$table->points_n % MAX_POINTS][$i] = $pt;
- $table->total[$i] += $pt;
- }
- $table->points_n++;
- $table->old_pnt = $pro;
- $table->mult = 1;
-}
-
-function validate_sess($sess)
-{
- if (strlen($sess) == SESS_LEN)
- return (TRUE);
- else
- return (FALSE);
-}
-
-function validate_name($name)
-{
- $name_new = str_replace(' ', '_', substr(trim($name),0,12));
-
- for ($i = 0 ; $i < strlen($name_new) ; $i++) {
- $c = $name_new[$i];
- if (($c >= "a" && $c <= "z") || ($c >= "A" && $c <= "Z") || ($c >= "0" && $c <= "9"))
- return ($name_new);
- }
-
- return (FALSE);
-}
-
-function playsound($filename)
-{
- return (sprintf('playsound("flasou", "%s");', $filename));
-}
-
-function secstoword($secs)
-{
- $mins = floor($secs / 60);
- $secs = $secs % 60;
- if ($mins > 0)
- $ret = sprintf("%d minut%s%s", $mins, ($mins > 1 ? "i" : "o"), ($secs > 0 ? " e " : ""));
-
- if ($secs > 0)
- $ret .= sprintf("%d second%s", $secs, ($secs > 1 ? "i" : "o"));
-
- return ($ret);
-}
-
-?>
--- /dev/null
+<FilesMatch "\.(js|css)$">
+header append Cache-Control "public, no-store, last-modified, must-revalidate"
+</FilesMatch>
+<FilesMatch "\.php$">
+header append Pragma "no-cache"
+header append Expires "-1"
+php_value mbstring.http_input "auto"
+php_value mbstring.internal_encoding "UTF-8"
+php_flag mbstring.encoding_translation On
+php_value mbstring.func_overload "7"
+</FilesMatch>
+ExpiresActive On
+ExpiresByType image/jpg "access plus 4 days"
+ExpiresByType image/png "access plus 4 days"
+ExpiresByType image/mp3 "access plus 4 days"
+
--- /dev/null
+<?php
+define(BRISKIN5_PLAYERS_N, 3);
+define(BRISKIN5_MAX_PLAYERS, BRISKIN5_PLAYERS_N);
+// define(BRISKIN5_SHM_MIN, (50000 * BRISKIN5_MAX_PLAYERS));
+define(BRISKIN5_SHM_MIN, 32768);
+define(BRISKIN5_SHM_MAX, (BRISKIN5_SHM_MIN + 1048576));
+define(BRISKIN5_SHM_DLT, 32768);
+
+class Briskin5 {
+ var $user;
+ var $table;
+ var $table_idx;
+ var $table_token;
+
+ var $comm; // commands for many people
+ var $step; // current step of the comm array
+ var $garbage_timeout;
+
+ var $the_end;
+
+ var $tok;
+ var $shm_sz;
+
+ function Briskin5 (&$room, $table_idx, $table_token) {
+ $this->user = array();
+ $this->table = array();
+
+ $this->the_end = FALSE;
+ $this->shm_sz = BRISKIN5_SHM_MIN;
+ if (($this->tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) {
+ echo "FTOK FAILED";
+ exit;
+ }
+
+ $user =& $room->user;
+ $table =& $room->table[$table_idx];
+
+ log_wr("Briskin5 constructor");
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user[$table->player[$i]]->table_token = $table_token;
+ $this->user[$i] =& User::spawn(&$user[$table->player[$i]], 0, $i);
+ }
+ $this->table[0] =& Table::spawn(&$table);
+ $this->table_idx = $table_idx;
+ $this->table_token = $table_token;
+ $this->garbage_timeout = 0;
+
+ log_wr("Briskin5 constructor end");
+ }
+
+
+ function &get_user($sess, &$idx)
+ {
+ GLOBAL $PHP_SELF, $G_false;
+
+ if (validate_sess($sess)) {
+ for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) {
+ if (strcmp($sess, $this->user[$i]->sess) == 0) {
+ // find it
+ $idx = $i;
+ $ret = &$this->user[$i];
+ return ($ret);
+ }
+ }
+ log_main(sprintf("get_user: Wrong sess from page [%s]",$PHP_SELF));
+ // for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++)
+ // log_main(sprintf("get_user: Wrong sess compared with [%s]",$this->user[$i]->sess));
+ }
+ else {
+ log_main(sprintf("get_user: Wrong strlen [%s]",$sess));
+ }
+
+ return ($G_false);
+ }
+
+
+ function garbage_manager($force)
+ {
+
+ /* Garbage collector degli utenti in timeout */
+ $ismod = FALSE;
+ $curtime = time();
+ if ($force || $this->garbage_timeout < $curtime) {
+
+ for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) {
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == "" ||
+ ($user_cur->stat == 'table' && ($user_cur->subst == 'shutdowned' || $user_cur->subst == 'shutdowner')))
+ continue;
+
+ if ($user_cur->lacc + EXPIRE_TIME_RD < $curtime) { // Auto logout dell'utente
+ log_rd2($user_cur->sess." bin5 AUTO LOGOUT.");
+
+ if ($user_cur->stat == 'table') {
+ log_auth($user_cur->sess," bin5 Autologout session.");
+
+ /* SI DELEGA AL garbage_manager principale LA RIMOZIONE DELL'UTENTE
+
+ $tmp_sess = $user_cur->sess;
+ $user_cur->sess = "";
+ step_unproxy($tmp_sess);
+ $user_cur->name = "";
+ $user_cur->the_end = FALSE;
+
+ */
+
+ $this->table_wakeup(&$user_cur);
+ }
+ }
+ }
+ log_rd2($user_cur->sess." GARBAGE UPDATED!");
+
+ $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT;
+ $ismod = TRUE;
+ }
+
+ return ($ismod);
+ }
+
+
+
+
+ //
+ // static functions
+ //
+ function &load_data($table_idx, $table_token = "")
+ {
+ GLOBAL $G_false, $sess;
+ $doexit = FALSE;
+ $shm = FALSE;
+
+ log_wr("TABLE_IDX ".FTOK_PATH."/table".$table_idx);
+
+ do {
+ if (($tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) {
+ log_main("ftok failed");
+ $doexit = TRUE;
+ break;
+ }
+
+ if (($shm_sz = sharedmem_sz($tok)) == -1) {
+ log_main("shmop_open failed");
+ break;
+ }
+
+ if (($shm = shm_attach($tok, $shm_sz)) == FALSE)
+ break;
+
+ if (($bri = @shm_get_var($shm, $tok)) == FALSE)
+ break;
+
+ if ($table_token != "" && $bri->table_token != $table_token) {
+ log_wr("bri->table_token: ".$bri->table_token."table_token: ".$table_token);
+
+ break;
+ }
+ $bri->tok = $tok;
+
+ shm_detach($shm);
+
+ $ret = &$bri;
+ return ($ret);
+ } while (FALSE);
+
+ if ($shm != FALSE)
+ shm_detach($shm);
+
+ log_wr("briskin5 load_data failed");
+ if ($doexit)
+ exit();
+
+ return ($G_false);
+ }
+
+
+
+ function save_data(&$bri)
+ {
+ GLOBAL $sess;
+
+ $ret = FALSE;
+ $shm = FALSE;
+
+ log_main("SAVE BRISKIN5 DATA");
+
+ if (!isset($bri->tok))
+ return (FALSE);
+
+ while ($bri->shm_sz < BRISKIN5_SHM_MAX) {
+ if (($shm = shm_attach($bri->tok, $bri->shm_sz)) == FALSE)
+ break;
+
+ if (@shm_put_var($shm, $bri->tok, $bri) != FALSE) {
+ shm_detach($shm);
+ return (TRUE);
+ }
+ if (shm_remove($shm) === FALSE) {
+ log_only("REMOVE FALLITA");
+ break;
+ }
+ shm_detach($shm);
+ $bri->shm_sz += BRISKIN5_SHM_DLT;
+ }
+
+ log_crit("save data failed!");
+
+ if ($shm)
+ shm_detach($shm);
+
+ return ($ret);
+ }
+
+
+
+ function destroy_data($table_idx)
+ {
+ GLOBAL $sess;
+
+ $ret = FALSE;
+ $shm = FALSE;
+ log_main("DESTROY BRISKIN5 DATA");
+
+ do {
+ log_main("DESTROY2 BRISKIN5 DATA");
+
+ if (($tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1)
+ break;
+
+ if (($shm = @shmop_open($tok, 'a', 0, 0)) == FALSE)
+ break;
+
+ if (shmop_delete($shm) == 0) {
+ log_only("REMOVE FALLITA ");
+ break;
+ }
+
+ $shm = FALSE;
+ log_main("DESTROY2 BRISKIN5 DATA SUCCESS");
+
+ // log_main("QUI CI ARRIVA [".$bri->user[0]->name."]");
+ $ret = TRUE;
+ } while (0);
+
+ if ($shm)
+ shm_detach($shm);
+
+ return ($ret);
+ }
+
+ function lock_data($table_idx)
+ {
+ GLOBAL $sess;
+
+ log_wr("LOCK_DATA ".FTOK_PATH."/table".$table_idx);
+ // echo "LOCK: ".FTOK_PATH."/main";
+ // exit;
+ // WARNING monitor this step
+ if (($tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) {
+ echo "FTOK FAILED";
+ exit;
+ }
+ // WARNING monitor this step
+ if (($res = @sem_get($tok)) == FALSE) {
+ echo "SEM_GET FAILED";
+ exit;
+ }
+ if (sem_acquire($res)) {
+ log_lock("LOCK table ".$table_idx."[res: ".$res."]");
+ return ($res);
+ }
+ else {
+ log_lock("LOCK table ".$table_idx.":FAILED");
+ return (FALSE);
+ }
+ }
+
+ function unlock_data($res)
+ {
+ GLOBAL $sess;
+
+ log_lock("UNLOCK table [res: ".$res."]");
+
+ return (sem_release($res));
+ }
+
+
+ function chatt_send(&$user, $mesg)
+ {
+ if ($user->stat == 'table') {
+ $table = &$this->table[$user->table];
+ }
+
+ $user_mesg = substr($mesg,6);
+
+ $curtime = time();
+
+ $dt = date("H:i ", $curtime);
+ if (strncmp($user_mesg, "/nick ", 6) == 0) {
+ log_main($user->sess." chatt_send BEGIN");
+
+ if (($name_new = validate_name(substr($user_mesg, 6))) == FALSE) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.");', $dt.NICKSERV);
+ $user->step_inc();
+
+ return;
+ }
+ $user_mesg = "COMMAND ".$user_mesg;
+ // Search dup name
+ // change
+ // update local graph
+ // update remote graphs
+ for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) {
+ $user_cur = &$this->user[$i];
+ // if ($user_cur->sess == '' || $user_cur->stat != 'room')
+ if ($user_cur->sess == '')
+ continue;
+ if ($user_cur->name == $name_new) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","Nickname <b>%s</b> già in uso.");', $dt.NICKSERV, xcape($name_new));
+ $user->step_inc();
+ break;
+ }
+ }
+ if ($i == BRISKIN5_MAX_PLAYERS) {
+ $user->name = $name_new;
+
+ log_main($user->sess." chatt_send start set");
+
+
+ for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) {
+ log_main($user->sess." chatt_send set loop");
+
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == '')
+ continue;
+ if ($user_cur->stat == 'room') {
+ if ($user->stat == 'room' && $user->subst == 'standup') {
+ $this->standup_update(&$user);
+ }
+ else if ($user->stat == 'room' && $user->subst == 'sitdown' ||
+ $user->stat == 'table') {
+ log_main($user->sess." chatt_send pre table update");
+
+ $this->table_update(&$user);
+
+ log_main($user->sess." chatt_send post table update");
+ }
+ }
+ else if ($user_cur->stat == 'table' && $user_cur->table == $user->table) {
+ $table = &$this->table[$user->table];
+
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+ $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('set_names(" %s", " %s", " %s", " %s", " %s"); ',
+ xcape($this->user[$table->player[($user_cur->table_pos) % BRISKIN5_PLAYERS_N]]->name),
+ xcape($this->user[$table->player[($user_cur->table_pos+1) % BRISKIN5_PLAYERS_N]]->name),
+ xcape($this->user[$table->player[($user_cur->table_pos+2) % BRISKIN5_PLAYERS_N]]->name),
+ (BRISKIN5_PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+3) % BRISKIN5_PLAYERS_N]]->name)),
+ (BRISKIN5_PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+4) % BRISKIN5_PLAYERS_N]]->name)));
+ if ($user_cur == $user)
+ $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "<b>%s</b>";',
+ xcape($user->name,ENT_COMPAT,"UTF-8"));
+ $user_cur->step_inc();
+ }
+ }
+ }
+ }
+ else {
+ for ($i = 0 ; $i < ($user->stat == 'room' ? BRISKIN5_MAX_PLAYERS : BRISKIN5_PLAYERS_N) ; $i++) {
+ if ($user->stat == 'room') {
+ $user_cur = &$this->user[$i];
+ if ($user_cur->sess == '' || $user_cur->stat != 'room')
+ continue;
+ }
+ else {
+ $user_cur = &$this->user[$table->player[$i]];
+ }
+
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+ $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('chatt_sub("%s","%s");',
+ $dt.xcape($user->name), xcape($user_mesg));
+ $user_cur->step_inc();
+ }
+ log_legal($curtime, $user->sess, $user->name,
+ ($user->stat == 'room' ? 'room' : 'table '.$user->table),$user_mesg);
+ }
+ }
+
+ function table_wakeup(&$user)
+ {
+ $table = &$this->table[0];
+
+ log_main("BRISKIN5_WAKEUP begin function table stat: ".$user->stat." subst: ".$user->subst);
+
+ $curtime = time();
+
+ log_main("BRISKIN5_WAKEUP from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n);
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user_cur = &$this->user[$i];
+ log_main("PREIMPOST INLOOP name: ".$user_cur->name);
+
+ if ($user_cur == $user)
+ $user_cur->subst = "shutdowner";
+ else
+ $user_cur->subst = "shutdowned";
+ $user_cur->laccwr = $curtime;
+
+ $ret = "gst.st = ".($user_cur->step+1)."; ";
+ $ret .= 'gst.st_loc++; the_end=true; window.onunload = null; document.location.assign("../index.php");|';
+
+ log_wr($user_cur->sess." BRISKIN5_WAKEUP: ".$ret);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+
+ $this->the_end = TRUE;
+ }
+
+ /*
+ * If all players are freezed the room garbage_manager clean up table and users.
+ */
+ function is_abandoned()
+ {
+ $is_ab = TRUE;
+ $curtime = time();
+
+ $table = &$this->table[0];
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user_cur = &$this->user[$i];
+
+ if ($user_cur->lacc + (EXPIRE_TIME_RD * 2) >= $curtime) {
+ $is_ab = FALSE;
+ break;
+ }
+ }
+
+ return ($is_ab);
+ }
+} // end class Briskin5
+
+function locshm_exists($tok)
+{
+ // return (TRUE);
+
+ if (($id = @shmop_open($tok,"a", 0, 0)) == FALSE) {
+ log_main($tok." SHM NOT exists");
+
+ return (FALSE);
+ }
+ else {
+ shmop_close($id);
+ log_main($tok." SHM exists");
+
+ return (TRUE);
+ }
+
+}
+
+
+?>
--- /dev/null
+/*
+ * brisk - briskin5.css
+ *
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ *
+ */
+
+body {
+ background-image: url(null);
+ background-color: #fafafa;
+ text-align: center;
+/* inherit from brisk.css
+ background-repeat: no-repeat;
+ background-position: top center;
+ margin:0px;
+
+ font-size: 12px;
+ padding: 0px;
+
+ align: center;
+*/
+}
+
+.chattshort {
+ height: 70px;
+ overflow: auto;
+ border: 1px solid grey;
+ vertical-align: text-bottom;
+ text-align: left;
+ /* font-size: 10pt;*/
+}
+
+table.chattshort_table {
+ width: 98%;
+ margin: auto;
+}
+
+.txtt {
+ /* font-size: 10pt;*/
+}
+
+img.tableinfo {
+ position: absolute;
+ left: 619;
+ top: 550;
+ border-width: 0px;
+ visibility: visible;
+}
+
+img.tablereload {
+ position: absolute;
+ left: 667;
+ top: 550;
+ border-width: 0px;
+ visibility: visible;
+}
+
+img.tableout {
+ position: absolute;
+ left: 730;
+ top: 550;
+ border-width: 0px;
+ visibility: visible;
+}
+
+img.card {
+ position: absolute;
+ border-style: solid;
+ border-width: 1px;
+ border-color: grey;
+ visibility: hidden;
+}
+
+
+img.astacard {
+ position: absolute;
+ /* visibility: visible; */
+ border-width: 0px;
+}
+
+img.cover {
+ position: absolute;
+ border-style: solid;
+ border-width: 1px;
+ border-color: lightgrey;
+ visibility: hidden;
+}
+
+.chooseed {
+ /* background-color: yellow; */
+ visibility: hidden;
+ position:absolute;
+ width: 200px;
+ height: 200px;
+ top: 250px;
+ left: 300px;
+}
+
+.asta {
+ /* background-color: yellow; */
+ visibility: hidden;
+ position: absolute;
+ width: 200px;
+ height: 200px;
+ top: 250px;
+ left: 300px;
+}
+
+img.seed0 {
+ position: absolute;
+ left: 0px;
+ top: 55px;
+}
+
+img.seed1 {
+ position: absolute;
+ left: 43px;
+ top: 55px;
+}
+
+img.seed2 {
+ position: absolute;
+ left: 93px;
+ top: 55px;
+}
+
+img.seed3 {
+ position: absolute;
+ left: 143px;
+ top: 55px;
+}
+
+.area {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ position: relative;
+ text-align: center;
+ width: 800px;
+ height: 600px;
+}
+
+.subarea {
+ top: 0px;
+ text-align: center;
+}
+
+.points {
+ /* position: relative; */
+
+ margin-top: 8px;
+ margin-left:auto;
+ margin-right:auto;
+ border-style: solid;
+ border-width: 0px;
+ border-color: black;
+ border-collapse: collapse;
+}
+
+.td_points {
+ border-style: solid;
+ border-width: 1px;
+ border-color: black;
+ border-collapse: collapse;
+ display: table-cell;
+ text-align: right;
+ padding: 2px;
+}
+
+div.table_commands {
+ display: inline;
+ position: absolute;
+ right: 2px;
+ bottom: 15px;
+}
+
+.remark0 {
+ position: absolute;
+ width: 199px;
+ height: 200px;
+ left: 299;
+ top: 249;
+ border-style: solid;
+ border-width: 0px;
+ border-color: green;
+ z-index: 0;
+}
+
+.remark1 {
+ position: absolute;
+ width: 199px !important;
+ width: 207px;
+ height: 200px !important;
+ height: 208px;
+ left: 296;
+ top: 246;
+ border-style: solid;
+ border-width: 4px;
+ border-color: green;
+ z-index: 0;
+}
+
+.remark2 {
+ position: absolute;
+ width: 199px !important;
+ width: 203px;
+ height: 200px !important;
+ height: 204px;
+ left: 298;
+ top: 248;
+ border-style: solid;
+ border-width: 2px;
+ border-color: green;
+ z-index: 0;
+}
+
+.punti {
+ position: absolute;
+ width: 68;
+ height: 50;
+ margin-top: 4px;
+ /*
+ border-style: solid;
+ border-width: 1px;
+ border-color: blu;
+ */
+ align: center;
+ text-align: center;
+}
+
+.puntifield {
+ /* position: absolute; */
+ align: center;
+ text-align: center;
+}
+
+.pubinfo {
+ /* background-color: red; */
+ color: grey;
+ visibility: visible;
+ position: absolute;
+ top: 475px;
+ left: 200px;
+ width: 400px;
+ height: 125px;
+}
+
+.public {
+ /* background-color: red; */
+ visibility: hidden;
+ position: absolute;
+ display: table;
+ top: 450px;
+ left: 300px;
+ width: 200px;
+ height: 100px;
+ overflow: hidden;
+ z-index: 8;
+}
+
+.pubacard {
+ border-width: 0px;
+ position: relative;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+
+
+.pubinfo_we {
+ color: grey;
+ visibility: visible;
+ position: absolute;
+ top: 250px;
+ left: 175px;
+ width: 125px;
+ height: 200px;
+}
+
+.public_we {
+ /* background-color: red; */
+ visibility: hidden;
+ position: absolute;
+ top: 250px;
+ left: 175px;
+ display: table;
+ width: 125px;
+ height: 200px;
+ overflow: hidden;
+}
+
+.pubinfo_nw {
+ /* background-color: red; */
+ color: grey;
+ visibility: visible;
+ position: absolute;
+ top: 125px;
+ left: 200px;
+ width: 200px;
+ height: 125px;
+}
+
+.public_nw {
+ /* background-color: red; */
+ visibility: hidden;
+ position: absolute;
+ top: 125px;
+ left: 200px;
+ display: table;
+ width: 200px;
+ height: 125px;
+ overflow: hidden;
+}
+
+.public_ne {
+ /* background-color: red; */
+ visibility: hidden;
+ position: absolute;
+ top: 125px;
+ left: 400px;
+ display: table;
+ width: 200px;
+ height: 125px;
+ overflow: hidden;
+}
+
+.pubinfo_ne {
+ /* background-color: red; */
+ color: grey;
+ visibility: visible;
+ position: absolute;
+ top: 125px;
+ left: 400px;
+ width: 200px;
+ height: 125px;
+}
+
+
+
+.public_ea {
+ /* background-color: red; */
+ visibility: hidden;
+ position: absolute;
+ top: 250px;
+ left: 500px;
+ display: table;
+ width: 125px;
+ height: 200px;
+ overflow: hidden;
+}
+
+.pubinfo_ea {
+ /* background-color: red; */
+ color: grey;
+ visibility: visible;
+ position: absolute;
+ top: 250px;
+ left: 500px;
+ width: 125px;
+ height: 200px;
+}
+
+.vert_midfloat {
+ position: relative;
+#position: absolute;
+ _top: 50%;
+ left: 0px;
+ width: 100%;
+ display: table-cell;
+ vertical-align: middle;
+}
+
+.vert_innfloat {
+#position: relative;
+#top: -50%;
+ text-align: center;
+}
+
+.vert_innfloat_so {
+ /* border-style: solid;
+ border-width: 1px;
+ border-color: black;
+
+ background-color: white; */
+#position: relative;
+#top: -50%;
+ text-align: center;
+}
+
+.pubacard_ea {
+ border-width: 0px;
+ position: relative;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.pubacard_ne {
+ border-width: 0px;
+ position: relative;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.pubacard_nw {
+ border-width: 0px;
+ position: relative;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.pubacard_we {
+ border-width: 0px;
+ position: relative;
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+
+/* CALLER */
+.caller {
+ background-repeat: no-repeat;
+ visibility: hidden;
+ position: absolute;
+ left: 0px;
+ top: 475px;
+ width: 200px;
+ height: 125px;
+}
+
+.callerinfo {
+ /* background-color: red; */
+ /* visibility: visible; */
+ position: absolute;
+ /* font-size: 10pt;*/
+ left: 5px;
+ top: 55px;
+ width: 115px;
+ height: 65px;
+}
+
+img.callerimg {
+ position: absolute;
+ left: 133px;
+ top: 10px;
+}
+
+
--- /dev/null
+/*
+ * brisk - briskin5.js
+ *
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ *
+ */
+
+function background_set()
+{
+ $("bg").style.backgroundImage = 'url("img/brisk_table_sand'+table_pos+'.jpg")';
+}
--- /dev/null
+<?php
+/*
+ * brisk - table.php
+ *
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ *
+ */
+
+require_once("../Obj/brisk.phh");
+require_once("../Obj/proxyscan.phh");
+
+// Use of proxies isn't allowed.
+if (is_proxy()) {
+ exit;
+}
+
+header('Content-type: text/html; charset="utf-8"',true);
+?>
+<html>
+<head>
+<title>Brisk - Tavolo <?php echo "$table_idx";?></title>
+<link rel="shortcut icon" href="../img/brisk_ico.png">
+<script type="text/javascript" src="../dnd.js"></script>
+<script type="text/javascript" src="../dom-drag.js"></script>
+<script type="text/javascript" src="../commons.js"></script>
+<script type="text/javascript" src="../xhr.js"></script>
+<script type="text/javascript" src="../preload_img.js"></script>
+<script type="text/javascript" src="briskin5.js"></script>
+<script type="text/javascript" src="../AC_OETags.js"></script>
+<link rel="stylesheet" type="text/css" href="../brisk.css">
+<link rel="stylesheet" type="text/css" href="briskin5.css">
+</head>
+<body>
+<SCRIPT type="text/javascript">
+ var sess;
+ var stat = "table";
+ var subst = "none";
+ var table_pos = "";
+ var myfrom = "table_php";
+ var g_withflash = false;
+
+var asta_ptr;
+var area_ptr;
+
+var gst = new globst();
+gst.st = <?php
+
+log_load("bin5/index.php");
+
+if (isset($laststate) == false) {
+ $laststate = -1;
+}
+echo $laststate;
+?>;
+var g_is_spawn=1;
+var g_table_idx=<?php echo "$table_idx";?>;
+
+var g_imgct= 0;
+var g_imgtot = g_preload_img_arr.length;
+var g_exitlock = 0;
+
+window.onload = function() {
+ g_withflash = DetectFlashVer(6,0,0);
+ remark_off();
+ // table_init();
+ xhr_rd = createXMLHttpRequest();
+ sess = "<?php echo "$sess"; ?>";
+
+ window.onunload = onunload_cb;
+
+ setTimeout(xhr_rd_poll, 0, sess);
+ // setTimeout(preload_images, 0, g_preload_img_arr, g_imgct);
+}
+</SCRIPT>
+<div id="bg" class="area">
+
+<div id="remark" class="remark0"></div>
+<img id="card0" src="img/00.png" class="card">
+<img id="card1" src="img/01.png" class="card">
+<img id="card2" src="img/02.png" class="card">
+<img id="card3" src="img/03.png" class="card">
+<img id="card4" src="img/04.png" class="card">
+<img id="card5" src="img/05.png" class="card">
+<img id="card6" src="img/06.png" class="card">
+<img id="card7" src="img/07.png" class="card">
+<img id="takes" src="img/cover.png" class="cover">
+<img id="card_ne0" src="img/cover.png" class="cover">
+<img id="card_ne1" src="img/cover.png" class="cover">
+<img id="card_ne2" src="img/cover.png" class="cover">
+<img id="card_ne3" src="img/cover.png" class="cover">
+<img id="card_ne4" src="img/cover.png" class="cover">
+<img id="card_ne5" src="img/cover.png" class="cover">
+<img id="card_ne6" src="img/cover.png" class="cover">
+<img id="card_ne7" src="img/cover.png" class="cover">
+<img id="takes_ne" src="img/cover.png" class="cover">
+<img id="card_nw0" src="img/cover.png" class="cover">
+<img id="card_nw1" src="img/cover.png" class="cover">
+<img id="card_nw2" src="img/cover.png" class="cover">
+<img id="card_nw3" src="img/cover.png" class="cover">
+<img id="card_nw4" src="img/cover.png" class="cover">
+<img id="card_nw5" src="img/cover.png" class="cover">
+<img id="card_nw6" src="img/cover.png" class="cover">
+<img id="card_nw7" src="img/cover.png" class="cover">
+<img id="takes_nw" src="img/cover.png" class="cover">
+<img id="card_ea0" src="img/cover_ea.png" class="cover">
+<img id="card_ea1" src="img/cover_ea.png" class="cover">
+<img id="card_ea2" src="img/cover_ea.png" class="cover">
+<img id="card_ea3" src="img/cover_ea.png" class="cover">
+<img id="card_ea4" src="img/cover_ea.png" class="cover">
+<img id="card_ea5" src="img/cover_ea.png" class="cover">
+<img id="card_ea6" src="img/cover_ea.png" class="cover">
+<img id="card_ea7" src="img/cover_ea.png" class="cover">
+<img id="takes_ea" src="img/cover_ea.png" class="cover">
+<img id="card_we0" src="img/cover_we.png" class="cover">
+<img id="card_we1" src="img/cover_we.png" class="cover">
+<img id="card_we2" src="img/cover_we.png" class="cover">
+<img id="card_we3" src="img/cover_we.png" class="cover">
+<img id="card_we4" src="img/cover_we.png" class="cover">
+<img id="card_we5" src="img/cover_we.png" class="cover">
+<img id="card_we6" src="img/cover_we.png" class="cover">
+<img id="card_we7" src="img/cover_we.png" class="cover">
+<img id="takes_we" src="img/cover_we.png" class="cover">
+<div id="asta" class="asta">
+ <img id="asta0" src="img/asta0.png" class="astacard">
+ <img id="asta1" src="img/asta1.png" class="astacard">
+ <img id="asta2" src="img/asta2.png" class="astacard">
+ <img id="asta3" src="img/asta3.png" class="astacard">
+ <img id="asta4" src="img/asta4.png" class="astacard">
+ <img id="asta5" src="img/asta5.png" class="astacard">
+ <img id="asta6" src="img/asta6.png" class="astacard">
+ <img id="asta7" src="img/asta7.png" class="astacard">
+ <img id="asta8" src="img/asta8.png" class="astacard">
+ <img id="asta9" src="img/asta9.png" class="astacard">
+ <div id="astaptdiv" class="punti">
+ <input class="puntifield" id="astapt" name="astapt" type="text" maxsize="3" size="3" value="61">
+ </div>
+ <img id="astaptsub" src="img/astaptsub_ro.png" class="astacard">
+ <img id="astapasso" src="img/astapasso_ro.png" class="astacard">
+ <img id="astalascio" src="img/astalascio_ro.png" class="astacard">
+</div>
+<div id="name" class="pubinfo"></div>
+<div id="public" class="public">
+ <div class="vert_midfloat">
+ <div id="pubasta" class="vert_innfloat_so">
+ <img id="pubacard" src="img/astapasso_ro.png" class="pubacard">
+ <div id="pubapnt"></div>
+ </div>
+ </div>
+</div>
+<div id="name_ea" class="pubinfo_ea"></div>
+<div id="public_ea" class="public_ea">
+ <div class="vert_midfloat">
+ <div id="pubasta_ea" class="vert_innfloat">
+ <img id="pubacard_ea" src="img/astapasso_ro.png" class="pubacard_ea">
+ <div id="pubapnt_ea"></div>
+ </div>
+ </div>
+</div>
+<div id="name_ne" class="pubinfo_ne"></div>
+<div id="public_ne" class="public_ne">
+ <div class="vert_midfloat">
+ <div id="pubasta_ne" class="vert_innfloat">
+ <img id="pubacard_ne" src="img/astapasso_ro.png" class="pubacard_ne">
+ <div id="pubapnt_ne"></div>
+ </div>
+ </div>
+</div>
+<div id="name_nw" class="pubinfo_nw"></div>
+<div id="public_nw" class="public_nw">
+ <div class="vert_midfloat">
+ <div id="pubasta_nw" class="vert_innfloat">
+ <img id="pubacard_nw" src="img/astapasso_ro.png" class="pubacard_nw">
+ <div id="pubapnt_nw"></div>
+ </div>
+ </div>
+</div>
+<div id="name_we" class="pubinfo_we"></div>
+<div id="public_we" class="public_we">
+ <div class="vert_midfloat">
+ <div id="pubasta_we" class="vert_innfloat">
+ <img id="pubacard_we" src="img/astapasso_ro.png" class="pubacard_we">
+ <div id="pubapnt_we"></div>
+ </div>
+ </div>
+</div>
+<div id="chooseed" class="chooseed">
+Hai vinto l'asta.<br> Scegli il seme:
+<img id="seed0" src="img/00.png" class="seed0">
+<img id="seed1" src="img/10.png" class="seed1">
+<img id="seed2" src="img/20.png" class="seed2">
+<img id="seed3" src="img/30.png" class="seed3">
+</div>
+<div id="caller" class="caller">
+<div id="callerinfo" class="callerinfo">Info</div>
+<img id="callerimg" src="img/noimg.png" class="callerimg">
+</div>
+<div class="table_commands">
+<input type="button" class="button" name="xinfo" value="Info." onclick="act_tableinfo();">
+<input type="button" class="button" name="xreload" value="Reload." onclick="act_reload();">
+<div style="vertical-align: top;">
+<img id="exitlock" class="button" style="visibility: hidden; border: 0px; display: inline; position: relative;" onclick="act_exitlock();"><input type="button" class="button" name="xout" value="Out." onclick="safelogout();">
+</div>
+</div>
+
+</div>
+
+
+<div class="subarea">
+<div id="txt" class="chattshort"></div>
+ <table class="chattshort_table"><tr><td style="width:1%; text-align: right;">
+ <div id="myname"></div>
+ </td><td>
+ <input id="txt_in" type="text" style="width: 100%;" onkeypress="chatt_checksend(this,event);">
+ </td></tr></table>
+
+<div id="flasou" style="text-align: left;"></div>
+<hr>
+<div id="heartbit" style="text-align: left;"></div>
+<hr>
+<div id="imgct" style="text-align: left;"></div>
+<hr>
+<div id="sandbox" style="text-align: left;"></div>
+<div id="sandbox2" style="text-align: left;"></div>
+<div id="sandbox3" style="text-align: left;"></div>
+<pre>
+<div id="xhrlog" style="text-align: left;"></div>
+</pre>
+<div id="xhrdeltalog" style="text-align: left;"></div>
+</div>
+</body>
+</html>
--- /dev/null
+<?php
+/*
+ * brisk - index_rd.php
+ *
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ *
+ */
+
+require_once("../Obj/brisk.phh");
+// require_once("../Obj/proxyscan.phh");
+require_once("Obj/briskin5.phh");
+
+// Use of proxies isn't allowed.
+// if (is_proxy()) {
+// sleep(5);
+// exit;
+// }
+
+log_load("LOAD: bin5/index_rd.php ".$QUERY_STRING);
+
+$first_loop = TRUE;
+$the_end = FALSE;
+
+if (DEBUGGING == "local" && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
+ echo "Debugging time!";
+ exit;
+}
+
+function shutta()
+{
+ log_rd2("bin5 SHUTTA!".connection_status());
+}
+
+
+register_shutdown_function(shutta);
+
+function unrecerror()
+{
+ GLOBAL $is_page_streaming;
+
+ $is_page_streaming = TRUE;
+ log_rd2("UNREC_ERROR");
+ return (sprintf('the_end=true; window.onunload = null; document.location.assign("../index.php");'));
+}
+
+function page_sync($sess, $page)
+{
+ GLOBAL $is_page_streaming;
+
+ $is_page_streaming = TRUE;
+ log_rd2("PAGE_SYNC");
+ return (sprintf('the_end=true; window.onunload = null; document.location.assign("%s");', $page));
+}
+
+
+
+
+function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step, $table_idx, $table_token)
+{
+ GLOBAL $is_page_streaming, $first_loop;
+
+ $ret = FALSE;
+ $bri = FALSE;
+
+ // log_rd2("M");
+ /* Sync check (read only without modifications */
+ ignore_user_abort(TRUE);
+ if (($sem = Briskin5::lock_data($table_idx)) != FALSE) {
+ // Aggiorna l'expire time lato server
+ if ($first_loop == TRUE) {
+ log_only("F");
+
+ // VERIFICARE TUTTE LE LOAD_DATA E PRENDERE CONTROMISURE NEL CASO FALLISCANO //
+
+ if (($bri = &Briskin5::load_data($table_idx, $table_token)) == FALSE) {
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+ if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+ log_auth($sess, "bin5::update lacc");
+ $user->lacc = time();
+
+ $bri->garbage_manager(FALSE);
+
+ Briskin5::save_data($bri);
+ $first_loop = FALSE;
+ }
+
+ log_lock("U");
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ }
+ else {
+ return (FALSE);
+ }
+
+ if (($proxy_step = step_get($sess)) != FALSE) {
+ // log_rd2("Postget".$proxy_step."zizi");
+
+ if ($cur_step == $proxy_step) {
+ log_lock("P");
+ return (FALSE);
+ }
+ else {
+ log_only2("R");
+ }
+ }
+ else {
+ log_only2("R");
+ }
+
+ if ($bri == FALSE) {
+ do {
+ ignore_user_abort(TRUE);
+ if (($sem = Briskin5::lock_data($table_idx)) == FALSE)
+ break;
+
+ log_lock("P");
+ if (($bri = &Briskin5::load_data($table_idx, $table_token)) == FALSE)
+ break;
+ } while (0);
+
+ if ($sem != FALSE)
+ Briskin5::unlock_data($sem);
+
+ ignore_user_abort(FALSE);
+ if ($bri == FALSE)
+ return (unrecerror());
+ }
+
+ if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
+ return (unrecerror());
+ }
+
+ /* Nothing changed, return. */
+ if ($cur_step == $user->step)
+ return;
+
+ log_rd2("do other ++".$cur_stat."++".$user->stat."++".$cur_step."++".$user->step);
+
+ if ($cur_step == -1) {
+ // FUNZIONE from_scratch DA QUI
+ ignore_user_abort(TRUE);
+ $sem = Briskin5::lock_data($table_idx);
+ $bri = &Briskin5::load_data($table_idx, $table_token);
+ if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+ if ($user->the_end)
+ $is_page_streaming = TRUE;
+
+
+ if ($user->trans_step != -1) {
+ log_rd2("TRANS USATO ".$user->trans_step);
+ $cur_step = $user->trans_step;
+ $user->trans_step = -1;
+
+
+ Briskin5::save_data($bri);
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ }
+ else {
+ log_rd2("TRANS NON ATTIVATO");
+
+// ARRAY_POP DISABLED
+// while (array_pop($user->comm) != NULL);
+// // $user->step_inc(COMM_N + 1);
+// Briskin5::save_data($bri);
+
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ }
+ }
+
+ if ($cur_step == -1) {
+ log_rd2("PRE-NEWSTAT.");
+
+ /***************
+ * *
+ * TABLE *
+ * *
+ ***************/
+ if ($user->stat == "table") {
+ $ret = show_table(&$bri,&$user,$user->step,FALSE,FALSE);
+
+ log_rd2("SENDED TO THE STREAM: ".$ret);
+ }
+ log_rd2("NEWSTAT: ".$user->stat);
+
+ $new_stat = $user->stat;
+ $new_subst = $user->subst;
+ $new_step = $user->step;
+ }
+ else {
+ ignore_user_abort(TRUE);
+ $sem = Briskin5::lock_data($table_idx);
+ if (($bri = &Briskin5::load_data($table_idx, $table_token)) == FALSE) {
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+ if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (unrecerror());
+ }
+ if ($cur_step < $user->step) {
+ do {
+ if ($cur_step + COMM_N < $user->step) {
+ if (($cur_stat != $user->stat)) {
+ $to_stat = $user->stat;
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (page_sync($user->sess, $to_stat == "table" ? "index.php" : "../index.php"));
+ }
+ log_rd2("lost history, refresh from scratch");
+ $new_step = -1;
+ break;
+ }
+ for ($i = $cur_step ; $i < $user->step ; $i++) {
+ $ii = $i % COMM_N;
+ log_wr("TRY RET ".$i." COMM_N ".COMM_N." II ".$ii);
+ $ret .= $user->comm[$ii];
+ }
+ $new_stat = $user->stat;
+ $new_subst = $user->subst;
+ $new_step = $user->step;
+ } while (0);
+
+ if ($user->the_end == TRUE) {
+ log_rd2("LOGOUT BYE BYE!!");
+ log_auth($user->sess, "Explicit logout.");
+ $tmp_sess = $user->sess;
+ $user->sess = "";
+ step_unproxy($tmp_sess);
+
+ $user->name = "";
+ $user->the_end = FALSE;
+
+ if ($user->subst == 'sitdown')
+ $bri->room_wakeup(&$user);
+ else if ($user->subst == 'standup')
+ $bri->room_outstandup(&$user);
+ else
+ log_rd2("LOGOUT FROM WHAT ???");
+
+ Briskin5::save_data($bri);
+ }
+ }
+
+ Briskin5::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ }
+
+
+ return ($ret);
+}
+
+/*
+ * MAIN
+ */
+
+/*
+ FROM THE EXTERN
+ sess
+ stat
+ step
+*/
+
+$is_page_streaming = ((stristr($HTTP_USER_AGENT, "linux") &&
+ (stristr($HTTP_USER_AGENT, "firefox") || stristr($HTTP_USER_AGENT, "iceweasel"))) ? FALSE : TRUE);
+
+
+header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
+header('Content-type: application/xml; charset="utf-8"',true);
+// header('Content-type: text/plain; charset="utf-8"',true);
+// header('Content-type: text/html; charset="utf-8"',true);
+
+if (!isset($myfrom))
+ $myfrom = "";
+if (!isset($subst))
+ $subst = "";
+log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming."USER_AGENT:".$HTTP_USER_AGENT);
+
+
+$endtime = time() + STREAM_TIMEOUT;
+$old_stat = $stat;
+$old_subst = $subst;
+$old_step = $ext_step = $step;
+
+for ($i = 0 ; time() < $endtime ; $i++) {
+ // log_rd("PRE MAIN ".$step);;
+ if (($ret = maincheck($sess, $old_stat, $old_subst, $old_step, &$stat, &$subst, &$step, $table_idx, $table_token)) != FALSE) {
+ echo '@BEGIN@';
+ // log_rd2(sprintf("\nSESS: [%s]\nOLD_STAT: [%s] OLD_SUBST: [%s] OLD_STEP: [%s] \nSTAT: [%s] SUBST: [%s] STEP: [%s] \nCOMM: [%s]\n", $sess, $old_stat, $old_subst, $old_step, $stat, $subst, $step, $ret));
+ echo "$ret";
+ echo ' @END@';
+ log_send("EXT_STEP: ".$ext_step." ENDTIME: [".$endtime."] ".$ret);
+ flush();
+ if ($is_page_streaming)
+ break;
+ }
+ $old_stat = $stat;
+ $old_subst = $subst;
+ $old_step = $step;
+ // log_rd("POST MAIN ".$step);;
+ usleep(400000);
+ if (($i % 5) == 0) {
+ // log_rd2("TIME: ".time());
+ echo '_';
+ flush();
+ }
+}
+
+?>
--- /dev/null
+<?php
+/*
+ * brisk - index_wr.php
+ *
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ *
+ */
+
+require_once("../Obj/brisk.phh");
+// require_once("../Obj/proxyscan.phh");
+require_once("Obj/briskin5.phh");
+
+// Use of proxies isn't allowed.
+// if (is_proxy()) {
+// sleep(5);
+// exit;
+//}
+
+if (DEBUGGING == "local" && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
+ echo "Debugging time!";
+ exit;
+}
+
+log_load("bin5/index_wr.php");
+
+/*
+ * MAIN
+ */
+log_wr('COMM: '.$mesg);
+
+if ($table_idx < 0 || $table_idx >= TABLE_N)
+ exit;
+
+$sem = Briskin5::lock_data($table_idx);
+
+if (($bri = &Briskin5::load_data($table_idx,$table_token)) == FALSE) {
+ echo "Bin5 Load data error";
+ log_wr("Bin5 Load data error");
+ Briskin5::unlock_data($sem);
+ exit;
+}
+
+if (($user = &$bri->get_user($sess, &$idx)) == FALSE) {
+ echo "Get User Error";
+ log_wr("Get User Error");
+ Briskin5::unlock_data($sem);
+ exit;
+}
+$argz = explode('|', $mesg);
+
+log_wr('POSTSPLIT: '.$argz[0]);
+
+if ($argz[0] == 'shutdown') {
+ log_auth($user_cur->sess, "Shutdown session. delegate to room gc the autologout");
+
+ log_rd2("bin5/index_wr.php: AUTO LOGOUT.");
+ if ($user->stat == 'table') {
+ $bri->table_wakeup(&$user);
+ // to force the logout
+ $user->lacc = 0;
+ }
+ else
+ log_rd2("SHUTDOWN FROM WHAT ???");
+}
+/*********************
+ * *
+ * STAT: table *
+ * *
+ *********************/
+else if ($user->stat == 'table') {
+ $user->laccwr = time();
+ $table = &$bri->table[$user->table];
+
+ if ($argz[0] == 'tableinfo') {
+ log_wr("PER DI TABLEINFO");
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_table_info(&$bri, &$table, $user->table_pos);
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+ }
+ else if ($argz[0] == 'chatt') {
+ $bri->chatt_send(&$user,$mesg);
+ }
+ else if ($argz[0] == 'logout') {
+ $remcalc = $argz[1];
+
+ if ($user->exitislock == TRUE) {
+ $remcalc++;
+ $user->exitislock = FALSE;
+ }
+
+ $logout_cont = TRUE;
+ if ($remcalc >= 3) {
+ $lockcalc = $table->exitlock_calc(&$bri->user, $user->table_pos);
+ if ($lockcalc < 3) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= $table->exitlock_show(&$bri->user, $user->table_pos);
+ $user->comm[$user->step % COMM_N] .= show_notify("<br>I dati presenti sul server non erano allineati con quelli inviati dal tuo browser, adesso lo sono. Riprova ora.", 2000, "torna alla partita.", 400, 100);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+ $logout_cont = FALSE;
+ }
+ }
+ else
+ $user->bantime = $user->laccwr + BAN_TIME;
+
+ if ($logout_cont == TRUE) {
+ $bri->table_wakeup(&$user);
+ }
+ }
+ else if ($argz[0] == 'exitlock') {
+ $user->exitislock = ($user->exitislock == TRUE ? FALSE : TRUE);
+ for ($ct = 0, $i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur[$i] = &$bri->user[$table->player[$i]];
+ if ($user_cur[$i]->exitislock == FALSE)
+ $ct++;
+ }
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $ret = sprintf('gst.st = %d;', $user_cur[$i]->step+1);
+ $ret .= sprintf('exitlock_show(%d, %s);', $ct,
+ ($user_cur[$i]->exitislock ? 'true' : 'false'));
+ $user_cur[$i]->comm[$user_cur[$i]->step % COMM_N] = $ret;
+ log_wr($user_cur[$i]->comm[$user_cur[$i]->step % COMM_N]);
+ $user_cur[$i]->step_inc();
+ }
+ }
+ else if ($user->subst == 'asta') {
+ if ($argz[0] == 'lascio' && $user->handpt <= 2) {
+ $index_cur = $table->gstart % BRISKIN5_PLAYERS_N;
+
+ log_wr(sprintf("GIOCO FINITO !!!"));
+
+ $table->mult *= 2;
+ $table->old_reason = sprintf("Ha lasciato %s perché aveva al massimo 2 punti.", xcape($user->name));
+
+ $table->game_next();
+ $table->game_init(&$bri->user);
+
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+
+ $ret = sprintf('gst.st = %d;', $user_cur->step+1);
+ $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ }
+ else if ($argz[0] == 'asta') {
+ $again = TRUE;
+
+ $index_cur = $table->gstart % BRISKIN5_PLAYERS_N;
+ if ($user->table_pos == $index_cur &&
+ $table->asta_pla[$index_cur]) {
+ $a_card = $argz[1];
+ $a_pnt = $argz[2];
+
+ log_wr("CI SIAMO a_card ".$a_card." asta_card ".$table->asta_card);
+
+ // Abbandono dell'asta
+ if ($a_card <= -1) {
+ log_wr("Abbandona l'asta.");
+ $table->asta_pla[$index_cur] = FALSE;
+ $user->asta_card = -1;
+ $table->asta_pla_n--;
+ $again = FALSE;
+ }
+ else if ($a_card <= 9) {
+ if ($a_card >= 0 && $a_card < 9 && $a_card > $table->asta_card)
+ $again = FALSE;
+ else if ($a_card == 9 && $a_pnt > ($table->asta_pnt >= 61 ? $table->asta_pnt : 60) && $a_pnt <= 120)
+ $again = FALSE;
+
+
+ if ($again == FALSE) {
+ log_wr("NUOVI ORZI.");
+ $user->asta_card = $a_card;
+ $table->asta_card = $a_card;
+ if ($a_card == 9) {
+ $user->asta_pnt = $a_pnt;
+ $table->asta_pnt = $a_pnt;
+ }
+ }
+ }
+
+
+
+ if ($again) { // Qualcosa non andato bene, rifare
+ $ret = sprintf('gst.st = %d; asta_pnt_set(%d);', $user->step+1,
+ ($table->asta_pnt > 60 ? $table->asta_pnt + 1 : 61) );
+ $user->comm[$user->step % COMM_N] = $ret;
+ $user->step_inc();
+
+ log_wr("Ripetere.");
+ }
+ else {
+ /* next step */
+ $showst = "show_astat(";
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+ $showst .= sprintf("%s%d", ($i == 0 ? "" : ", "),
+ ($user_cur->asta_card < 9 ? $user_cur->asta_card : $user_cur->asta_pnt));
+ }
+ if (BRISKIN5_PLAYERS_N == 3)
+ $showst .= ",-2,-2";
+ $showst .= ");";
+
+ $maxcard = -2;
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+ if ($maxcard < $user_cur->asta_card)
+ $maxcard = $user_cur->asta_card;
+ }
+
+ if (($table->asta_pla_n > ($maxcard > -1 ? 1 : 0)) &&
+ !($table->asta_card == 9 && $table->asta_pnt == 120)) {
+ log_wr("ALLOPPA QUI");
+ for ($i = 1 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $index_next = ($table->gstart + $i) % BRISKIN5_PLAYERS_N;
+ if ($table->asta_pla[$index_next]) {
+ log_wr("GSTART 1");
+ $table->gstart += $i;
+ break;
+ }
+ }
+
+
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+ $ret = sprintf('gst.st = %d; %s', $user_cur->step+1, $showst);
+ if ($user_cur->table_pos == ($table->gstart % BRISKIN5_PLAYERS_N))
+ $ret .= sprintf('dispose_asta(%d,%d, %s); remark_on();',
+ $table->asta_card + 1, $table->asta_pnt+1, ($user_cur->handpt <= 2 ? "true" : "false"));
+ else
+ $ret .= sprintf('dispose_asta(%d,%d, %s); remark_off();',
+ $table->asta_card + 1, -($table->asta_pnt+1), ($user_cur->handpt <= 2 ? "true" : "false"));
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ }
+ else if ($table->asta_pla_n == 0) {
+ log_wr("PASSANO TUTTI!");
+
+ log_wr(sprintf("GIOCO FINITO !!!"));
+
+ $table->old_reason = "Hanno passato tutti.";
+ $table->mult *= 2;
+
+ $table->game_next();
+ $table->game_init(&$bri->user);
+
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+
+ $ret = sprintf('gst.st = %d;', $user_cur->step+1);
+ $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ }
+ else {
+ log_wr("FINITA !");
+ // if a_pnt == 120 supergame ! else abbandono
+ if ($a_pnt == 120 || $user->asta_card != -1) {
+ $chooser = $index_cur;
+ for ($i = 1 ; $i < BRISKIN5_PLAYERS_N ; $i++)
+ if ($i != $chooser)
+ $table->asta_pla[$i] = FALSE;
+ }
+ else {
+ //"gst.st = ".($user->step+1)."; dispose_asta(".($table->asta_card + 1).",".-($table->asta_pnt).", true); remark_off();";
+ $user->comm[$user->step % COMM_N] = sprintf( "gst.st = %d; dispose_asta(%d, %d, false); remark_off();", $user->step+1, $table->asta_card + 1,-($table->asta_pnt));
+ $user->step_inc();
+ for ($i = 1 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $chooser = ($table->gstart + $i) % BRISKIN5_PLAYERS_N;
+ if ($table->asta_pla[$chooser]) {
+ break;
+ }
+ }
+ }
+ $table->asta_win = $chooser;
+
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+ $ret = sprintf('gst.st = %d; %s', $user_cur->step+1, $showst);
+
+ if ($i == $chooser) {
+ $ret .= "choose_seed(". $table->asta_card."); \$(\"asta\").style.visibility = \"hidden\"; remark_on();";
+ }
+ else {
+ $ret .= "remark_off();";
+ }
+
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ }
+ }
+ }
+ else {
+ log_wr("NON CI SIAMO");
+ }
+ }
+ /* asta::choose */
+ else if ($argz[0] == 'choose') {
+ if ($table->asta_win > -1 &&
+ $user->table_pos == $table->asta_win) {
+ $a_brisco = $argz[1];
+ if ($a_brisco >= 0 && $a_brisco < 40) {
+ $table->briscola = $a_brisco;
+ $table->friend = $table->card[$a_brisco]->owner;
+ log_wr("GSTART 2");
+ $table->gstart = ($table->mazzo+1) % BRISKIN5_PLAYERS_N;
+ log_wr("Setta la briscola a ".$a_brisco);
+
+ $chooser = $table->asta_win;
+ $user_chooser = &$bri->user[$table->player[$chooser]];
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+ $user_cur->subst = 'game';
+ $ret = sprintf('gst.st = %d; subst = "game";', $user_cur->step+1);
+
+
+ /* bg of caller cell */
+ $ret .= briscola_show($bri, $table, $user_cur);
+
+ /* first gamer */
+ if ($i == ($table->gstart % BRISKIN5_PLAYERS_N))
+ $ret .= "is_my_time = true; remark_on();";
+ else
+ $ret .= "is_my_time = false; remark_off();";
+
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+ /*
+ TUTTE LE VARIABILI DI STATO PER PASSARE A GIOCARE E LE
+ VAR PER PASSARE ALLA FASE DI GIOCO
+ */
+
+ }
+ }
+ }
+ }
+ else if ($user->subst == 'game') {
+ log_wr("state: table::game".$argz[0]);
+
+ if ($argz[0] == 'play') {
+ $a_play = $argz[1];
+ $a_x = $argz[2];
+ $a_y = $argz[3];
+
+ if (strpos($a_x, "px") != FALSE)
+ $a_x = substr($a_x,0,-2);
+ if (strpos($a_y, "px") != FALSE)
+ $a_y = substr($a_y,0,-2);
+
+ $loggo = sprintf("A_play %s, table_pos %d == %d, mazzo %d, gstart %d, card_stat %d, card_own %d",
+ $a_play, $user->table_pos, ($table->gstart % BRISKIN5_PLAYERS_N),
+ $table->mazzo, $table->gstart,
+ $table->card[$a_play]->stat, $table->card[$a_play]->owner);
+ log_wr("CIC".$loggo);
+
+ /* se era il suo turno e la carta era sua ed era in mano */
+ if ($a_play >=0 && $a_play < 40 &&
+ ($user->table_pos == (($table->gstart + $table->turn) % BRISKIN5_PLAYERS_N)) &&
+ $table->card[$a_play]->stat == 'hand' &&
+ $table->card[$a_play]->owner == $user->table_pos) {
+ log_wr(sprintf("User: %s Play: %d",$user->name, $a_play));
+
+ /* Change the card status. */
+ $table->card[$a_play]->play($a_x, $a_y);
+
+ /*
+ * !!!! TURN INCREMENTED BEFORE !!!!
+ */
+ $turn_cur = ($table->gstart + $table->turn) % BRISKIN5_PLAYERS_N;
+ $table->turn++;
+
+ $card_play = sprintf("card_play(%d,%d,%d,%d);|",
+ $user->table_pos, $a_play, $a_x, $a_y);
+ if (($table->turn % BRISKIN5_PLAYERS_N) != 0) { /* manche not finished */
+ $turn_nex = ($table->gstart + $table->turn) % BRISKIN5_PLAYERS_N;
+
+ $player_cur = "remark_off();";
+ $player_nex = $card_play . "is_my_time = true; remark_on();";
+ $player_oth = $card_play;
+ }
+ else if ($table->turn <= (BRISKIN5_PLAYERS_N * 8)) { /* manche finished */
+ $winner = calculate_winner($table);
+ log_wr("GSTART 3");
+ $table->gstart = $winner;
+ $turn_nex = ($table->gstart + $table->turn) % BRISKIN5_PLAYERS_N;
+
+ log_wr(sprintf("The winner is: [%d] [%s]", $winner, $bri->user[$table->player[$winner]]->name));
+ $card_take = sprintf("sleep(gst,2000);|cards_take(%d);|", $winner);
+ $player_cur = "remark_off();" . $card_take;
+ if ($turn_cur != $turn_nex)
+ $player_nex = $card_play . $card_take;
+ else
+ $player_nex = "";
+ if ($table->turn < (BRISKIN5_PLAYERS_N * 8)) /* game NOT finished */
+ $player_nex .= "is_my_time = true; remark_on();";
+ $player_oth = $card_play . $card_take;
+ }
+
+ log_wr(sprintf("Turn Cur %d Turn Nex %d",$turn_cur, $turn_nex));
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+
+ $ret = sprintf('gst.st = %d; ', $user_cur->step+1);
+
+
+ if ($i == $turn_cur) {
+ $ret .= $player_cur;
+ }
+ if ($i == $turn_nex) {
+ $ret .= $player_nex;
+ }
+ if ($i != $turn_cur && $i != $turn_nex) {
+ $ret .= $player_oth;
+ }
+
+ $retar[$i] = $ret;
+ }
+
+ if ($table->turn == (BRISKIN5_PLAYERS_N * 8)) { /* game finished */
+ log_wr(sprintf("GIOCO FINITO !!!"));
+
+ $plist = "$table->table_token|$user->table|$table->player_n";
+ $curtime = time();
+ log_legal($curtime, $user->sess, $user->name, "STAT:FINISH_GAME", $plist);
+
+ /* ************************************************ */
+ /* PRIMA LA PARTE PER LO SHOW DI CHI HA VINTO */
+ /* ************************************************ */
+ calculate_points(&$table);
+
+ $table->game_next();
+ $table->game_init(&$bri->user);
+
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+ $retar[$i] .= show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, TRUE);
+ }
+ }
+
+
+ for ($i = 0 ; $i < BRISKIN5_PLAYERS_N ; $i++) {
+ $user_cur = &$bri->user[$table->player[$i]];
+
+ $user_cur->comm[$user_cur->step % COMM_N] = $retar[$i];
+ $user_cur->step_inc();
+ }
+
+ log_wr(sprintf("TURN: %d",$table->turn));
+ /* Have played all the players ? */
+ /* NO: switch the focus and enable the next player to play. */
+
+ /* YES: calculate who win and go to the next turn. */
+ }
+ }
+ else
+ log_wr("NOSENSE");
+ }
+}
+log_wr("before save data");
+Briskin5::save_data($bri);
+
+Briskin5::unlock_data($sem);
+exit;
+?>
--- /dev/null
+* {
+margin: 0px;
+padding: 0px;
+ }
+
+body {
+ font-family: verdana, sans-serif; font-size: 14px;
+ }
+
+table {
+ font-family: verdana, sans-serif; font-size: 14px;
+ }
+
+h4
+{
+ margin-top: 8px;
+ margin-bottom: 8px;
+}
+
+ul
+{
+ list-style-image: url('img/brisk_item6.png');
+ }
+
+li
+{
+ vertical-align: middle;
+ margin-left: 40px;
+ }
+
+dd
+{
+ margin-left: 40px;
+ }
+
+table.ricapito
+{
+ margin: 8px auto 8px auto;
+ width: 80%;
+ border-collapse: collapse;
+ border-spacing: 0px;
+
+ filter: alpha(opacity=90);
+ moz-opacity: 0.90;
+ opacity: 0.90;
+
+ }
+
+table.ricapito td
+{
+ border: 1px solid black;
+/* background-color: #d6d6d6;*/
+ background-color: #f0f0f0;
+ color: black;
+ text-align: center;
+ padding: 4px;
+}
+
+table.ricapito th
+{
+ border: 1px solid black;
+ padding: 4px;
+ }
+
+table.ricapito th.thnobo
+{
+ border: 0px solid black;
+ }
+
--- /dev/null
+<?php
+header('Content-type: text/html; charset="utf-8"',true);
+?>
+<html>
+<head>
+<title>Brisk Meeting</title>
+<link rel="stylesheet" type="text/css" href="briskmeeting.css">
+<!-- <link rel="stylesheet" type="text/css" href="room.css">
+<link rel="stylesheet" type="text/css" href="bug.css"> -->
+<script type="text/javascript" src="commons.js"></script>
+</head>
+<body>
+<div style="margin: 40px auto auto auto; text-align: center;">
+<div style=" z-index: 0; margin: auto; background-color: #fafafa; background-repeat: no-repeat; background-image: URL('img/brisk_half.png'); background-position: center right; text-align: left; border: 1px solid black; position: relative; left: auto; width: 756px;">
+<img style="z-index: 50; position: absolute; border: 0px solid black; left: -26px; top: -26px; margin: 0px;" src="img/brisk_meeting_title_hi.png">
+<img style="z-index: 50; position: absolute; border: 0px solid black; left: -26px; top: 59px; margin: 0px;" src="img/brisk_meeting_title_low.png">
+<div style=" z-index: 0; margin: auto; text-align: left; padding: 70px 10px 10px 80px; border: 0px solid black; position: relative; left: auto;">
+<h4>Presentazioni</h4>
+Ciao a tutti,<br>
+siamo due assidui frequentatori del sito, Bego e Manuel(K2).<br>
+<br>
+Abbiamo organizzato due meeting per poterci incontrare fra briskisti,
+conoscerci meglio e soprattutto passare una giornata di divertimento
+giocando a briscola chiamata.<br>
+<h4>Date dei meeting</h4>
+<ul>
+<li>30 agosto - <a target="_blank" href="http://maps.google.com/maps?f=q&hl=it&geocode=&q=12,+via+roma,+paratico,+brescia,+italy&sll=37.0625,-95.677068&sspn=35.547176,84.023438&ie=UTF8&ll=45.665376,9.953957&spn=0.015326,0.041027&z=15">Sarnico (Bergamo)</a> sul lago d'Iseo</li>
+<li>7 settembre - <a target="_blank" href="http://maps.google.it/maps?f=q&hl=it&geocode=&q=ravadese,+parma,+italy&ie=UTF8&ll=44.859763,10.37384&spn=0.127277,0.198441&z=12" style="color:#0000FF;text-align:left">Ravadese (Parma)</a></li>
+</ul>
+<br>
+<h4>Informazioni utili</h4>
+
+<table class="ricapito" >
+<tr><th class="thnobo"></th><th>Sarnico (Bergamo)</th><th>Ravedese (Parma)</th></tr>
+<tr><th>Quando:</th><td>30 Agosto</td>
+<td>7 Settembre</td></tr>
+<tr><th>Dove:</th><td><b><a target="_blank" href="http://www.hotelstazioneparatico.it/">Hotel stazione</a></b><br><a target="_blank" href="http://maps.google.com/maps?f=q&hl=it&geocode=&q=12,+via+roma,+paratico,+brescia,+italy&sll=37.0625,-95.677068&sspn=35.547176,84.023438&ie=UTF8&ll=45.665376,9.953957&spn=0.015326,0.041027&z=15">Via Roma, 12</a><br>Sarnico (Bergamo)</td>
+<td><b>Per i riferimenti<br>esatti<br>contattate Manuel</b><br><a target="_blank" href="http://maps.google.it/maps?f=q&hl=it&geocode=&q=ravadese,+parma,+italy&ie=UTF8&ll=44.859763,10.37384&spn=0.127277,0.198441&z=12" style="color:#0000FF;text-align:left">Ravedese (Parma)</a></td></tr>
+<tr><th>Costo<br>del pranzo:</th><td>23 €(<a href="#" onmouseover="$('bg_menu').style.display = '';" onmouseout="$('bg_menu').style.display = 'none';">menu</a>)
+<div id="bg_menu" style="text-align: left; position: absolute; display: none; background: white; border: 1px solid black; padding: 4px;">
+pranzo:<br>
+<ul>
+<li>2 primi a scelta
+<li>2 secondi a scelta
+<li>contorno
+<li>dolce
+<li>caffè
+</ul>
+</div>
+</td><td>25 € (<a href="#" onmouseover="$('pr_menu').style.display = '';" onmouseout="$('pr_menu').style.display = 'none';">menu</a>)
+<div id="pr_menu" style="text-align: left; position: absolute; display: none; background: white; border: 1px solid black; padding: 4px;">
+ verso le 11:00:<br>
+<ul>
+<li>aperitivo
+</ul>
+pranzo:<br>
+<ul>
+<li>antipasto di salumi
+<li>tortelli di erbette
+<li>assaggio di gnocchi di zucca
+<li>assaggio di risotto (o forse crepes) al radicchio rosso
+<li>tagliata
+<li>pollo fritto con verdure fritte
+<li>frutta
+<li>bis di torte
+<li>caffè
+<li>acqua e vino
+</ul>
+</div></td></tr>
+<tr><th>Chiusura<br>prenotazioni:</th><td>28 Agosto</td><td>1 Settembre</td></tr>
+<tr><th>Possibilità <br>di cenare:</th><td>Sì</td><td>No, salvo <br>richieste di massa<br>(min 10 persone)</td></tr>
+<tr><th>Possibilità <br> di pernottare:</th><td>Sì</td><td>No</td></tr>
+<tr><th title="per informazioni e prenotazioni contattateci!">Contatti e prenotazioni:</th><td><a href="mailto:grandebego@hotmail.it, susy.b@live.it?subject=briskmeeting_bg">Bego</a></td><td><a href="mailto:MANUEL-K2@hotmail.it?subject=briskmeeting_pr">Manuel-K2</a></td></tr>
+
+</table>
+
+<h4>Come si articoleranno le giornate</h4>
+<ul>
+<li>ritrovo in tarda mattinata (9:30-10:00)</li>
+
+<li>saluti e convenevoli</li>
+
+<li>pranzo non troppo impegnativo</li>
+
+<li>prima e dopo pranzo <b>tanta e tanta briscola</b>.</li>
+</ul>
+<br>
+Il termine serale è lasciato naturalmente alle esigenze di ognuno.<br>
+<br>
+<b>Un particolare ringraziamento a Erica e Mary per l'aiuto dato
+nell'organizzazione del meeting di Parma.</b><br>
+
+<br>
+Saluti a tutti, Bego e Manuel.<br>
+<br>
+</div>
+</div>
+</div>
+<!-- </div> -->
+</body>
+</html>
--- /dev/null
+* {
+ font-family: verdana;
+}
+
+body
+{
+ text-align: center;
+ background-image: none;
+ background-color: white;
+ }
+
+div.bug_cont
+{
+ margin: auto;
+ width: 800px;
+ text-align: left;
+ font-size: 14px;
+ padding: 8px;
+ }
+
+div.bug_form_out
+{
+ display: none;
+ text-align: center;
+ }
+
+div.bug_form
+{
+ text-align: left;
+ margin: auto;
+ width: 90%;
+ padding: 8px;
+ background-color: #e0e0e0;
+ border: 1px solid #a0a0a0;
+ }
+
+div.bug_form_inn
+{
+ text-align: center;
+ }
+
+table.bug_form
+{
+ margin: auto;
+ }
\ No newline at end of file
--- /dev/null
+<html>
+<head>
+<title>B.U.G. - Gruppi di Utenti di Brisk</title>
+<link rel="stylesheet" type="text/css" href="brisk.css">
+<link rel="stylesheet" type="text/css" href="room.css">
+<link rel="stylesheet" type="text/css" href="bug.css">
+<script type="text/javascript" src="commons.js"></script>
+</head>
+<body>
+<img class="nobo" style="position: static;" src="img/bug_bannerbig93.png">
+<div class="bug_cont">
+<br>
+<h3>Chi siamo.</h3>
+Un gruppo di frequentatori abituali del sito che ha deciso di sviluppare al suo interno un progetto di aggregazione tra utenti.
+<br>
+<br>
+<h3>Cosa ci interessa.</h3>
+Prima di tutto giocare a briscola chiamata (per chattare o conoscere gente nuova pensiamo ci siano mille altri modi).
+
+<br>
+<br>
+<h3>Quali sono i nostri obiettivi.</h3>
+Favorire il formarsi di gruppi locali di persone - i B.U.G. per l'appunto - che si trovino dal vivo, e non solo on-line, a giocare insieme per qualche ora.<br>
+Seguire lo sviluppo e proporre nuove funzionalità di Brisk, sia per il gioco, sia per gli strumenti utili agli scopi dei B.U.G.<br>
+Agevolare il supporto a Brisk mettendosi a disposizione come punto di raccolta per donazioni collettive.
+<br>
+<br>
+<h3>Come fondare un B.U.G.</h3>
+DA SCRIVERE ... BLA BLA
+Sottoscrivere il manifesto
+BLA BLA
+
+<br>
+<a name="pre_form">
+<br><h3>Ti interessa ?</h3>
+Se ti piacerebbe fondare un B.U.G. o conoscere quali sono quelli più vicini a te <a href="#pre_form" onClick="$('bug_form_out').style.display = 'block'; window.location.href = '#pre_form';" >clicca qui e compila il form</a> per ricevere informazioni più dettagliate.<br><br>
+<div id="bug_form_out" class="bug_form_out">
+<div id="bug_form" class="bug_form">
+<h3> Richiesta di maggiori informazioni:</h3>
+<form>
+<div class="bug_form_inn">
+<table class="bug_form">
+<tr><td>Nome<sup>*</sup>: </td><td><input name="name" type="text" size="40"></td></tr>
+<tr><td>Cognome<sup>*</sup>: </td><td><input name="surname" type="text" size="40"></td></tr>
+<tr><td>Nickname: </td><td><input name="nick" type="text" size="40"></td></tr>
+<tr><td>Età : </td><td><input name="age" type="text" size="4"></td></tr>
+<tr><td>Mezzi di trasporto: </td><td><input name="trasp" type="text" size="40"></td></tr>
+<tr><td>Nazione<sup>*</sup>: </td><td><input name="nat" type="text" size="40"></td></tr>
+<tr><td>Provincia<sup>*</sup>: </td><td>
+<select>
+<option>Seleziona
+<option>MI
+<option>BG
+</select>
+</td>
+</tr>
+<tr><td>Città <sup>*</sup>: </td><td><input name="city" type="text" size="40"></td></tr>
+<tr><td style="vertical-align: top;">Domanda<sup>*</sup>: </td><td>
+<TEXTAREA NAME="quest" ROWS="6" COLS="30">
+</TEXTAREA>
+</td></tr>
+<tr><td></td><td style="text-align: right;"><br><input class="button" type="submit" name="sub" value="invia"></td></tr>
+</table>
+</div>
+</form>
+<sup>*</sup>: campi obbligatori.
+</div>
+</div>
+<br>
+<i><u>Gli amici di Brisk.</u></i>
+</div>
+</body>
+</html>
\ No newline at end of file
/*
* brisk - commons.js
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
var PLAYERS_N = 3;
var EXIT_BAN_TIME = 900;
+var cookiepath = "/brisk/";
function $(id) { return document.getElementById(id); }
})()
+function addEvent(obj,type,fn)
+{
+ if (obj.addEventListener) {
+ obj.addEventListener( type, fn, false);
+ }
+ else if (obj.attachEvent) {
+ obj["e"+type+fn] = fn;
+ obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
+ obj.attachEvent( "on"+type, obj[type+fn] );
+ }
+ else
+ throw new Error("Event registration not supported");
+}
+
+function removeEvent(obj,type,fn)
+{
+ if (obj.removeEventListener) {
+ obj.removeEventListener( type, fn, false );
+ }
+ else if (obj.detachEvent) {
+ obj.detachEvent( "on"+type, obj[type+fn] );
+ obj[type+fn] = null;
+ obj["e"+type+fn] = null;
+ }
+}
+
// var card_pos = RANGE 0 <= x < cards_ea_n
+function show_bigpict(obj, act, x, y)
+{
+ var big, sfx;
+
+ if (arguments.length > 4)
+ sfx = arguments[4];
+ else
+ sfx = '';
+
+ big = $(obj.id+"_big"+sfx);
+ if (act == "over") {
+ big.style.left = obj.offsetLeft + x+"px";
+ big.style.top = obj.offsetTop + y+"px";
+ big.style.visibility = "visible";
+ }
+ else {
+ big.style.visibility = "hidden";
+ }
+}
+
function rnd_int(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function update_images()
{
+ // if (g_imgct % 10 == 0) alert("g_imgct: "+g_imgct+" xx "+g_preload_img_arr[g_imgct]);
$("imgct").innerHTML = "Immagini caricate "+g_preload_imgsz_arr[g_imgct]+"%.";
- if (g_imgct < g_preload_img_arr.length)
- setTimeout(preload_images, 100, g_preload_img_arr, g_imgct);
- g_imgct++;
+ if (g_imgct+1 < g_preload_img_arr.length) {
+ g_imgct++;
+ setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
+ }
// $("imgct").innerHTML += "U";
}
function send_mesg(mesg)
{
var xhr_wr = createXMLHttpRequest();
- // xhr_wr.open('GET', 'index_wr.php?sess='+sess+'&mesg='+encodeURIComponent(mesg), true);
- xhr_wr.open('GET', 'index_wr.php?sess='+sess+'&mesg='+mesg, true);
+ var is_conn = (sess == "not_connected" ? false : true);
+
+ xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
xhr_wr.onreadystatechange = function() { return; };
xhr_wr.send(null);
+ if (!is_conn) {
+ if (xhr_wr.responseText != null) {
+ eval(xhr_wr.responseText);
+ }
+ }
}
/* Stat: CHAT and TABLE */
send_mesg("help");
}
+function act_tav()
+{
+ act_chatt('/tav '+$('txt_in').value);
+ $('txt_in').value = '';
+}
+
function act_about()
{
send_mesg("about");
}
+function act_roadmap()
+{
+ send_mesg("roadmap");
+}
+
+function act_whysupport()
+{
+ send_mesg("whysupport");
+}
+
function act_exitlock()
{
send_mesg("exitlock");
{
var res;
- if (g_exitlock < 3)
+ if (g_exitlock < 2)
res = window.confirm("Sei sicuro di volere abbandonare la partita?\nATTENZIONE: se esci adesso senza il consenso degli altri giocatori non potrai sederti ai tavoli per "+(Math.floor(EXIT_BAN_TIME/60))+" minuti.");
else
res = window.confirm("Sei sicuro di volere abbandonare la partita?");
if (this.step_n * this.deltat == this.time) {
this.step_n--;
}
- this.step_free = parseInt(this.step_n * this.free);
+ if (this.free < 1) {
+ this.step_free = parseInt(this.step_n * this.free);
+ }
},
start: function(st)
this.step_cur++;
setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
if (this.step_cur == this.step_free && this.st != null) {
- if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
+ if (this.st.st_loc < this.st.st_loc_new) {
// alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
this.st.st_loc++;
this.st = null;
// $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
var date = new Date();
// $("logz").innerHTML += "Timestop: " + date + "<br>";
+
+ if (this.action != null) {
+ eval(this.action);
+ }
+
if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
// alert("QUI2");
this.st.st_loc++;
this.st = null;
}
- if (this.action != null) {
- eval(this.action);
- }
if (this.srcend != null) {
this.img.src = this.srcend;
}
{
// alert("EA: "+ea);
$("name").innerHTML = so;
- $("name").title = so;
+ $("name").title = unescapeHTML(so);
$("name_ea").innerHTML = ea;
- $("name_ea").title = ea;
+ $("name_ea").title = unescapeHTML(ea);
$("name_ne").innerHTML = ne;
- $("name_ne").title = ne;
+ $("name_ne").title = unescapeHTML(ne);
$("name_nw").innerHTML = nw;
- $("name_nw").title = nw;
+ $("name_nw").title = unescapeHTML(nw);
$("name_we").innerHTML = we;
- $("name_we").title = we;
+ $("name_we").title = unescapeHTML(we);
return;
}
function table_init() {
var sux = new Array("", "_ea", "_ne", "_nw", "_we");
+ // console.log("table_init");
+
remark_off();
$("asta").style.visibility = "hidden";
$("caller").style.visibility = "hidden";
$("card"+sux[e]+i).style.visibility = "hidden";
}
for (i=0 ; i < PLAYERS_N ; i++) {
+ // console.log("shut: "+"takes"+sux[i]);
$("takes"+sux[i]).style.visibility = "hidden";
}
/* PRO CHATT */
function chatt_sub(name,str)
{
+ var must_scroll = false;
+
+ // alert ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight);
+
+ if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
+ must_scroll = true;
+
// alert("ARRIVA NAME: "+ name + " STR:"+str);
if (chatt_lines_n == CHATT_MAXLINES) {
$("txt").innerHTML = "";
$("txt").innerHTML += chatt_lines[chatt_lines_n];
chatt_lines_n++;
}
- $("txt").innerHTML;
- $("txt").scrollTop = 10000000;
+ // $("txt").innerHTML;
+
+
+ if (must_scroll) {
+ $("txt").scrollTop = 10000000;
+ }
+ // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
}
/*
$("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\"Esco.\" onclick=\"window.onunload = null; act_logout();\" type=\"button\">";
}
+function unescapeHTML(cont) {
+ var div = document.createElement('div');
+ var memo = "";
+ var i;
+
+ div.innerHTML = cont;
+ if (div.childNodes[0]) {
+ if (div.childNodes.length > 1) {
+ if (div.childNodes.toArray)
+ alert("si puo");
+ else {
+ var length = div.childNodes.length, results = new Array(length);
+ while (length--)
+ results[length] = div.childNodes[length];
+
+ for (i=0 ; i<results.length ; i++)
+ memo = memo + results[i].nodeValue;
+ }
+
+ return (memo);
+ }
+ else {
+ return (div.childNodes[0].nodeValue);
+ }
+ }
+ else {
+ return ('');
+ }
+}
+
function playsound(tag, sound) {
// g_withflash is a global var
if (g_withflash) {
$(tag).innerHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
'codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" id="mysound" WIDTH=1 HEIGHT=1>' +
-'<PARAM NAME="movie" VALUE="playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
+'<PARAM NAME="movie" VALUE="../playsound.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="false">' +
'<PARAM NAME=FlashVars VALUE="streamUrl='+sound+'">' +
-'<EMBED swliveconnect="true" name="mysound" src="playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
+'<EMBED swliveconnect="true" name="mysound" src="../playsound.swf" FlashVars="streamUrl='+sound+'" PLAY="true" LOOP="false" '+
' WIDTH=1 HEIGHT=1 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></OBJECT>';
}
}
+
+function topbanner_init()
+{
+// setInterval(topbanner_cb, 666);
+;
+}
+
+function topbanner_cb()
+{
+ var a, b;
+
+ a = $('topbanner').style.backgroundColor;
+ b = $('topbanner').style.borderLeftColor;
+
+ $('topbanner').style.backgroundColor = b;
+ $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
+
+ // console.log("A: "+a+" B: "+b);
+}
/*
* brisk - dnd.css
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/*
* brisk - dnd.js
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
{
alert("card_play_so: unreachable function.");
}
-function card_play_ne(card_idx, x, y)
-{
- // alert("card_play_nw: card_pos="+ card_pos+" card_idx="+card_idx+" x="+x+" y="+y);
-}
/* CARD_PLAY_EA */
function card_postplay_ea(card_pos)
movimg.start(gst);
}
}
-
-function cards_hidetake(win)
-{
-
-
-
-
-}
-/*
- window.onload = function() {
- $("log").innerHTML += " xxxxxxxxxxxxxxxxxxxxxONLOAD<br>"; 53;
-
-
- // $("imm2").style.left = 600;
- // $("imm2").style.top = 400;
- var zigu = new slowimg($("imm"),300,100,15,"fin");
- zigu.settime(1000);
- zigu.start();
- // setTimeout(function() { alert("FIN:" + fin); }, 5000);
- }
-*/
-
-
-
-/*
- window.onload = function() {
- //
- var greet = document.createElement("span");
- greet.style.backgroundColor = "yellow";
- greet.innerHTML = "Hello World!";
- $("sandbox").appendChild(greet);
- //
- cards_dispose_so();
-
- for (i=0 ; i < 8 ; i++) {
- Drag.init($("card" + i), card_mouseup_cb);
- }
- }
-*/
/*\r
* brisk - dom-drag.js\r
*\r
- * Copyright (C) 2006 matteo.nastasi@milug.org\r
+ * Copyright (C) 2006-2008 Matteo Nastasi\r
+ * mailto: nastasi@alternativeoutput.it \r
+ * matteo.nastasi@milug.org\r
+ * web: http://www.alternativeoutput.it\r
*\r
* This program is free software; you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
/*
* brisk - index.php
*
- * Copyright (C) 2006-2007 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
*/
-require_once("brisk.phh");
+require_once("Obj/brisk.phh");
+require_once("Obj/proxyscan.phh");
+
+// Use of proxies isn't allowed.
+if (!$G_is_local && is_proxy())
+ exit;
+
+require_once("briskin5/Obj/briskin5.phh");
if (DEBUGGING == "local" && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
echo "Debugging time!";
exit;
}
-log_load((isset($sess) ? $sess : "XXX"), "LOAD: index.php");
+log_load("index.php");
function main()
{
- GLOBAL $sess, $name, $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER;
-
+ GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local;
+ GLOBAL $sess, $name, $table_idx, $table_token, $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER;
+
$body = "";
$tables = "";
$standup = "";
if (isset($BRISK_SHOWHTML) == FALSE) {
$is_table = FALSE;
- $sem = lock_data();
- $bri = &load_data();
-
+ $sem = Room::lock_data();
+ log_main("lock Room");
+ $room = &Room::load_data();
+ $curtime = time();
+
/* Actions */
+
if (validate_sess($sess)) {
- $bri->garbage_manager(TRUE);
- if (($user = &$bri->get_user($sess, &$idx)) != FALSE) {
+ log_main("pre garbage_manager UNO");
+ $room->garbage_manager(TRUE);
+ log_main("post garbage_manager");
+ if (($user = &$room->get_user($sess, &$idx)) != FALSE) {
+ log_main("user stat: ".$user->stat);
if ($user->stat == "table") {
- header ("Location: table.php");
- unlock_data($sem);
+ if (Room::save_data(&$room) == FALSE) {
+ echo "ERRORE SALVATAGGIO\n";
+ exit;
+ }
+ log_main("unlock Room");
+ Room::unlock_data($sem);
+ setcookie("table_token", $user->table_token, $curtime + 31536000);
+ setcookie("table_idx", $user->table, $curtime + 31536000);
+ header ("Location: briskin5/index.php");
exit;
}
$ACTION = "room";
}
+
+ if (Room::save_data(&$room) == FALSE) {
+ echo "ERRORE SALVATAGGIO\n";
+ exit;
+ }
}
if ($ACTION == "login" && isset($name)) {
- $bri->garbage_manager(TRUE);
+
+ log_main("pre garbage_manager DUE");
+ $room->garbage_manager(TRUE);
/* try login */
- if (($user = &$bri->add_user(&$sess, &$idx, $name, $_SERVER['REMOTE_ADDR'])) != FALSE) {
+ if (($user = &$room->add_user(&$sess, &$idx, $name, $_SERVER['REMOTE_ADDR'])) != FALSE) {
$ACTION = "room";
+ log_legal($curtime, $user->sess, $user->name, "STAT:LOGIN", '');
+
+
// setcookie ("sess", "", time() + 180);
- $bri->standup_update(&$user);
+ $room->standup_update(&$user);
- if (save_data(&$bri) == FALSE) {
+ if (Room::save_data(&$room) == FALSE) {
echo "ERRORE SALVATAGGIO\n";
exit;
}
$body .= '<div class="urgmsg"><b>Il tuo nickname è già in uso.</b></div>';
}
}
- unlock_data($sem);
+ Room::unlock_data($sem);
}
/* Rendering. */
if ($ACTION == "room") {
$tables .= '<div class="room_tab">';
- $tables .= '<table class="room_tab" align="center">';
+ $tables .= '<table class="room_tab">';
for ($i = 0 ; $i < TABLES_N ; $i++) {
if ($i % 4 == 0)
$tables .= '<tr>';
$tables .= '</table></div>';
- $standup .= '<table class="room_standup" align="center"><tr><td>';
+ $standup .= '<table class="room_standup"><tr><td><div class="room_standup_orig" id="room_standup_orig"></div>';
$standup .= '<div class="room_ex_standup">';
- $standup .= '<div class="room_tit"><b>Giocatori in piedi</b></div>';
+ $standup .= '<div id="room_tit"><span class="room_titin"><b>Giocatori in piedi</b></span></div>';
$standup .= sprintf('<div id="standup" class="room_standup"></div>');
$standup .= '<div id="esco" class="esco"></div>';
$standup .= '</div></td></tr></table>';
-
- // $tables .= '</td></tr></table>';
-
- /*
- $tables .= '</td></tr><tr><td>';
- $tables .= '<table class="room_tab" align="center">';
- $tables .= '<tr><td>';
- $tables .= '<div class="room_ex_standup">';
- $tables .= '<b>Giocatori in piedi</b>';
-
- $tables .= sprintf('<div id="standup" class="room_standup"></div>');
- $tables .= '<div id="esco" class="esco"></div>';
- */
- // $tables .= '</td></tr></table>';
}
- $altout_propag = array( array ( 'url' => 'http://www.alternativeoutput.it',
- 'content' => '<img class="nobo" src="img/altout80x15.png">' ),
- array ( 'url' => 'http://virtualsky.alternativeoutput.it',
- 'content' => '<img class="nobo" src="img/virtualsky80x15a.gif">' )
+ $altout_propag = array( array ( 'id' => 'btn_altout',
+ 'url' => 'http://www.alternativeoutput.it',
+ 'content' => 'img/altout80x15.png',
+ 'content_big' => 'img/altout80x15.png'),
+ array ( 'id' => 'btn_virtualsky',
+ 'url' => 'http://virtualsky.alternativeoutput.it',
+ 'content' => 'img/virtualsky80x15a.gif',
+ 'content_big' => 'img/virtualsky_big.png')
);
// seed with microseconds since last "whole" second
srand ((double) microtime() * 1000000);
// $randval = rand(0,count($altout_propag)-1);
$randval = 1;
- $altout_carousel = sprintf('<a target="_blank" href="%s">%s</a>',
+ $altout_carousel = sprintf('<a target="_blank" href="%s"><img id="%s" class="nobo" src="%s" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a>',
$altout_propag[$randval]['url'],
+ $altout_propag[$randval]['id'],
$altout_propag[$randval]['content']);
+ $altout_carousel_big = sprintf('<img class="nobohide" id="%s_big" src="%s">',
+ $altout_propag[$randval]['id'],
+ $altout_propag[$randval]['content_big']);
+
$brisk_donate = file_get_contents(FTOK_PATH."/brisk_donate.txt");
if ($brisk_donate == FALSE)
$brisk_donate = "";
+
+
+
$brisk_header_form = '<div class="container">
<!-- =========== header =========== -->
<div id="header" class="header">
<table width="100%%" border="0" cols="3"><tr>
-<td align="left"><div style="padding-left: 8px;">
-
-
-
-<script type="text/javascript"><!--
+<td align="left"><div style="padding-left: 8px;">'.($G_is_local ? '' :
+'<script type="text/javascript"><!--
google_ad_client = "pub-5246925322544303";
google_ad_width = 234;
google_ad_height = 60;
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
-</script>
-
-
-
-</div></td>
-<td align="center">
-<!-- <table><tr><td> -->
-<div>
+</script>'
+).'</div></td>
+<td align="center">'.($G_with_topbanner ? '<table><tr><td>' : '').'<div style="text-align: center;">
<img class="nobo" src="img/brisk_logo64.png">
briscola chiamata in salsa ajax<br>
- </div>
-<!-- </td><td><div style="align: center; text-align:center; background-color: #f8f8f8; padding: 2px; border: 1px solid #ffae00;"><a href="http://www.linuxday.it"><img class="nobo" src="img/ld66.png"></a> 27/10/2007<br>OGGI!
- </td></tr></table>-->
-</td>
+ </div>'.($G_with_topbanner ? sprintf('</td><td>%s</td></tr></table>', $G_topbanner) : '').'</td>
<td align="right"><div style="padding-right: 8px;">
-
-
-
-<script type="text/javascript"><!--
+'.($G_is_local ? '' :
+'<script type="text/javascript"><!--
google_ad_client = "pub-5246925322544303";
google_ad_width = 234;
google_ad_height = 60;
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
-</script>
-
-
-
-</div></td>
+</script>'
+).'</div></td>
</td></table>
</div>';
<!-- =========== vertical menu =========== -->
<div class="topmenu">
<!-- <a target="_blank" href="/briskhome.php"></a> -->
-<img class="nobo" src="img/brisk_start.png" onmouseover="$(\'webstart\').style.visibility = \'visible\';">
-<div class="webstart" id="webstart" onmouseover="this.style.visibility = \'visible\';" onmouseout="this.style.visibility = \'hidden\';">
-<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php" title="homepage del progetto">homepage</a><br>
-<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#cose" title="di cosa si tratta">cos\'è</a><br>
-<a target="_blank" href="http://it.wikipedia.org/wiki/Briscola#Gioco_a_5" title="come si gioca">regole</a><br>
-<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#shots" title="screenshots dell\'applicazione">screenshoots</a><br>
-<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#comp" title="compatibilità con i browser">compatibilità</a><br>
-<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#sources" title="sorgenti dell\'applicazione">sorgenti</a><br>
-<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#mailing" title="come iscriversi alla mailing list">mailing list</a><br>
-
-<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#prop" title="come fare pubblicità a brisk!">propaganda</a><br>
-<a href="#" title="credits" onclick="act_about();">about</a><br>
-<a href="mailto:brisk@alternativeoutput.it" title="contatti">contatti</a><br>
+<div class="webstart_hilite">
+<img class="nobo" src="img/brisk_start.png" onmouseover="menu_show(\'menu_webstart\');">
+<div class="webstart" id="menu_webstart" onmouseover="menu_over(1,this);" onmouseout="menu_over(-1,this);">
+
+<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php"
+ onmouseover="menu_hide(0,1);"
+ title="homepage del progetto">homepage</a><br>
+
+<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#cose"
+ onmouseover="menu_hide(0,1);"
+ title="di cosa si tratta">cos\'è</a><br>
+
+<a target="_blank" href="http://it.wikipedia.org/wiki/Briscola#Gioco_a_5"
+ onmouseover="menu_hide(0,1);"
+ title="come si gioca">regole</a><br>
+
+<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#shots"
+ onmouseover="menu_hide(0,1);"
+ title="screenshots dell\'applicazione">screenshoots</a><br>
+
+<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#comp"
+ onmouseover="menu_hide(0,1);"
+ title="compatibilità con i browser">compatibilità</a><br>
+
+<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#sources"
+ onmouseover="menu_hide(0,1);"
+ title="sorgenti dell\'applicazione">sorgenti</a><br>
+
+<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#mailing"
+ onmouseover="menu_hide(0,1);"
+ title="come iscriversi alla mailing list">mailing list</a><br>
+
+<a target="_blank" href="http://www.alternativeoutput.it/briskhome.php#prop"
+ onmouseover="menu_hide(0,1);"
+ title="come fare pubblicità a brisk!">propaganda</a><br>
+<a href="#"
+ onmouseover="menu_hide(0,1);"
+ title="credits" onclick="act_about();">about</a><br>
+
+<a href="mailto:brisk@alternativeoutput.it"
+ onmouseover="menu_hide(0,1);"
+ title="contatti">contatti</a><br>
+
+<hr>
+
+<!--
+<a href="#"
+ onmouseover="menu_hide(0,1);"
+ title="perché supportare brisk?" onclick="act_whysupport();">supportare?</a><br>
+-->
+<a href="#"
+ onmouseover="menu_hide(0,1);"
+ title="prossime funzionalità implementate" onclick="act_roadmap();">roadmap</a><br>
+
+<a href="#" title="foto dei raduni di briskisti"
+ onmouseover="menu_show(\'menu_raduni\');">raduni</a><br>
+
+<div id="menu_raduni" class="webstart">
+<a href="http://www.anomalia.it/mop/photoo"
+ target="_blank" onmouseover="menu_hide(0,2);"
+ title="Torneo di Milano del 17/05/2008" >Milano 05/08</a><br>
+
+<a href="http://www.anomalia.it/mop/photoo?album=brisk_pc0806"
+ target="_blank" onmouseover="menu_hide(0,2);"
+ title="Raduno di Piacenza del del 15/06/2008" >Piacenza 06/08</a><br>
+</div>
+</div>
</div>
<br><br><br>
sponsored by:<br><br>'.$altout_carousel.'<br>
-<a target="_blank" href="http://www.dynamica.it"><img class="nobo" src="img/dynamica.png"></a><br><br>
+<a target="_blank" href="http://www.dynamica.it"><img class="nobo" id="btn_dynamica" src="img/dynamica.png" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br><br>
supported by:<br><br>
-<a target="_blank" href="http://www.briscolachiamata.it"><img class="nobo" src="img/brichi.png"></a><br><br>
+<a target="_blank" href="http://www.briscolachiamata.it"><img class="nobo" id="btn_brichi" src="img/brichi.png" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br>
+<a target="_blank" href="http://www.forumolimpia.it"><img class="nobo" id="btn_foroli" src="img/forumolimpia.gif" onMouseOver="show_bigpict(this, \'over\',100,10);" onMouseOut="show_bigpict(this, \'out\',0,0);"></a><br><br>
<div id="proflashext" class="proflashext"><div id="proflash" class="proflash">
</div><br><br></div>
%s
%s
-</div>';
+<img class="nobohide" id="btn_dynamica_big" src="img/dynamica_big.png">
+<img class="nobohide" id="btn_brichi_big" src="img/brichi_big.png">
+<img class="nobohide" id="btn_foroli_big" src="img/forumolimpia_big.png">
+'.$altout_carousel_big.'</div>';
/* Templates. */
if ($ACTION == 'login') {
+ header('Content-type: text/html; charset="utf-8"',true);
?>
<html>
<head>
<title>Brisk</title>
<link rel="shortcut icon" href="img/brisk_ico.png">
<script type="text/javascript" src="dnd.js"></script>
+<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="dom-drag.js"></script>
<script type="text/javascript" src="commons.js"></script>
<script type="text/javascript" src="xhr.js"></script>
<script type="text/javascript" src="AC_OETags.js"></script>
<link rel="stylesheet" type="text/css" href="brisk.css">
<link rel="stylesheet" type="text/css" href="room.css">
-</head>
-<body>
-<SCRIPT type="text/javascript">
+
+<SCRIPT type="text/javascript"><!--
var g_withflash = false;
+ var g_is_spawn = 0;
+ var gst = new globst();
+ var topbanner_sfx, topbanner_dx;
+ var sess = "not_connected";
+
window.onload = function() {
+ menu_init();
+ topbanner_init();
+
g_withflash = DetectFlashVer(6,0,0);
if (g_withflash == false) {
$("proflash").innerHTML = 'Audio con Flash.<br><a href="http://www.macromedia.com/"><img class="nobo" style="padding: 4px; width:73; height: 19;" src="img/download_now_flash.gif"></a>';
$("proflashext").innerHTML = "";
$("nameid").focus();
}
+ //-->
</SCRIPT>
+</head>
+<body>
<?php
printf($brisk_header_form);
printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
<br>
<div style="text-align: center;">
<br><br><br>
-Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
+Digita il tuo nickname per accedere ai tavoli della briscola.<br>
<form method="post" action="">
+<table style="margin: auto;"><tr><td>
<input id="nameid" name="name" type="text" size="24" maxlength="12" value="">
+</td><td>
<input id="sub" value="entra" type="submit" class="button">
+</td></tr></table>
</form>
+(se usi firefox e qualcosa non funziona<br>prova a ricaricare la pagina con <b>Ctrl + F5</b>)<br>
</div></td></tr></table>
<br><br><br><br>
<?php
}
else if ($ACTION == 'room') {
+ header('Content-type: text/html; charset="utf-8"',true);
?>
<html>
<head>
<title>Brisk</title>
<link rel="shortcut icon" href="img/brisk_ico.png">
<script type="text/javascript" src="dnd.js"></script>
+<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="dom-drag.js"></script>
<script type="text/javascript" src="commons.js"></script>
+<script type="text/javascript" src="ticker.js"></script>
<script type="text/javascript" src="xhr.js"></script>
<script type="text/javascript" src="preload_img.js"></script>
<script type="text/javascript" src="AC_OETags.js"></script>
<link rel="stylesheet" type="text/css" href="brisk.css">
<link rel="stylesheet" type="text/css" href="room.css">
-</head>
-<body>
-<SCRIPT type="text/javascript">
+<SCRIPT type="text/javascript"><!--
var sess;
+ var tra = null;
var stat = "";
var subst = "";
var gst = new globst();
+ var g_is_spawn = 0;
+ var topbanner_sfx, topbanner_dx;
var g_withflash = false;
var g_imgct= 0;
else {
?>
// alert("INDEX START");
+ menu_init();
+ topbanner_init();
xhr_rd = createXMLHttpRequest();
sess = "<?php echo "$sess"; ?>";
-
+ tra = new train($('room_tit'));
window.onunload = onunload_cb;
g_withflash = DetectFlashVer(6,0,0);
if (g_withflash == false) {
}
?>
}
-
+ //-->
</SCRIPT>
+</head>
+<body>
<?php
printf($brisk_header_form);
printf("<table class=\"floaty\"><tr><td class=\"floatyleft\">\n");
</td></tr></table>
<!-- =========== bottom =========== -->
- <div id="bottom" class="bottom" style="/* background-color: green; */">
+ <div id="bottom" class="bottom">
<b>Chat</b><br>
<div id="txt" class="chatt">
</div>
- <table align=center style="width: 98%; margin: auto;"><tr><td style="width:1%; text-align: right;">
+<div style="text-align: center; ">
+ <table style="width: 98%; margin: auto;"><tr><td id="tickbut" class="tickbut"><img class="tickbut" src="img/train.png" onclick="act_tav();" title="scrivi un invito al tavolo e clicca"></td><td style="width:1%; text-align: center;">
<div id="myname"></div>
</td><td>
<input id="txt_in" type="text" style="width: 100%;" onkeypress="chatt_checksend(this,event);">
</td></tr></table>
</div>
+</div>
<div id="heartbit"></div>
<div id="sandbox"></div>
<div id="imgct"></div>
/*
* brisk - index_rd.php
*
- * Copyright (C) 2006-2007 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
*/
-require_once("brisk.phh");
+require_once("Obj/brisk.phh");
+// require_once("Obj/proxyscan.phh");
+require_once("briskin5/Obj/briskin5.phh");
-log_load($sess, "LOAD: index_rd.php ".$QUERY_STRING);
+// Use of proxies isn't allowed.
+// if (is_proxy()) {
+// sleep(5);
+// exit;
+//}
+log_load("index_rd.php");
$first_loop = TRUE;
$the_end = FALSE;
function shutta()
{
- log_rd2("SHUTTA!", connection_status());
+ log_rd2("SHUTTA!".connection_status());
}
GLOBAL $is_page_streaming;
$is_page_streaming = TRUE;
- log_rd2("XXX", "UNREC_ERROR");
+ log_rd2("UNREC_ERROR:".var_export(debug_backtrace()));
return (sprintf('the_end=true; window.onunload = null; document.location.assign("index.php");'));
}
-function page_sync($sess, $page)
+function page_sync($sess, $page, $table_idx, $table_token)
{
GLOBAL $is_page_streaming;
+ log_rd2("page_sync:".var_export(debug_backtrace()));
+
$is_page_streaming = TRUE;
- log_rd2($sess, "PAGE_SYNC");
- return (sprintf('the_end=true; window.onunload = null; document.location.assign("%s");', $page));
+
+ log_rd2("PAGE_SYNC");
+ return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); the_end=true; window.onunload = null; document.location.assign("%s");', $table_idx, $table_token, $page));
}
GLOBAL $is_page_streaming, $first_loop;
$ret = FALSE;
- $bri = FALSE;
+ $room = FALSE;
- log_rd2($sess, "M");
+ // log_rd2("M");
/* Sync check (read only without modifications */
ignore_user_abort(TRUE);
- if (($sem = lock_data()) != FALSE) {
+ if (($sem = Room::lock_data()) != FALSE) {
// Aggiorna l'expire time lato server
if ($first_loop == TRUE) {
- log_only($sess, "F");
- $bri = &load_data();
- if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
- unlock_data($sem);
+ log_only("F");
+ $room = &Room::load_data();
+ if (($user = &$room->get_user($sess, $idx)) == FALSE) {
+ Room::unlock_data($sem);
ignore_user_abort(FALSE);
return (unrecerror());
}
log_auth($sess, "update lacc");
$user->lacc = time();
- $bri->garbage_manager(FALSE);
+ log_main("pre garbage_manager TRE");
+ $room->garbage_manager(FALSE);
- save_data($bri);
+ Room::save_data($room);
$first_loop = FALSE;
}
- log_only($sess, "U");
- unlock_data($sem);
+ log_lock("U");
+ Room::unlock_data($sem);
ignore_user_abort(FALSE);
}
else {
}
if (($proxy_step = step_get($sess)) != FALSE) {
- // log_rd2($sess, "Postget".$proxy_step."zizi");
+ // log_rd2("Postget".$proxy_step."zizi");
if ($cur_step == $proxy_step) {
- log_only2($sess, "P");
+ log_lock("P");
return (FALSE);
}
else {
- log_only2($sess, "R");
+ log_only2("R");
}
}
else {
- log_only2($sess, "R");
+ log_only2("R");
}
- if ($bri == FALSE) {
- ignore_user_abort(TRUE);
- if (($sem = lock_data()) != FALSE) {
- log_only($sess, "P");
- $bri = &load_data();
- unlock_data($sem);
- ignore_user_abort(FALSE);
- }
- else {
+ if ($room == FALSE) {
+ do {
+ ignore_user_abort(TRUE);
+ if (($sem = Room::lock_data()) == FALSE)
+ break;
+
+ log_lock("P");
+ if (($room = &Room::load_data()) == FALSE)
+ break;
+ } while (0);
+
+ if ($sem != FALSE)
+ Room::unlock_data($sem);
+
+ ignore_user_abort(FALSE);
+ if ($room == FALSE)
return (FALSE);
- }
}
- if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
+ if (($user = &$room->get_user($sess, $idx)) == FALSE) {
return (unrecerror());
}
/* Nothing changed, return. */
if ($cur_step == $user->step)
- return;
+ return (FALSE);
- log_rd2($sess, "do other ++".$cur_stat."++".$user->stat."++".$cur_step."++".$user->step);
+ log_rd2("do other ++".$cur_stat."++".$user->stat."++".$cur_step."++".$user->step);
if ($cur_step == -1) {
// FUNZIONE from_scratch DA QUI
ignore_user_abort(TRUE);
- $sem = lock_data();
- $bri = &load_data();
- if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
- unlock_data($sem);
+ $sem = Room::lock_data();
+ $room = &Room::load_data();
+ if (($user = &$room->get_user($sess, $idx)) == FALSE) {
+ Room::unlock_data($sem);
ignore_user_abort(FALSE);
return (unrecerror());
}
- if ($user->the_end)
+ if ($user->the_end) {
+ log_rd2("main_check: the end".var_export(debug_backtrace()));
$is_page_streaming = TRUE;
-
+ }
if ($user->trans_step != -1) {
- log_rd2($sess, "TRANS USATO ".$user->trans_step);
+ log_rd2("TRANS USATO ".$user->trans_step);
$cur_step = $user->trans_step;
$user->trans_step = -1;
- save_data($bri);
- unlock_data($sem);
+ Room::save_data($room);
+ Room::unlock_data($sem);
ignore_user_abort(FALSE);
}
else {
- log_rd2($sess, "TRANS NON ATTIVATO");
- unlock_data($sem);
- ignore_user_abort(FALSE);
+ log_rd2("TRANS NON ATTIVATO");
+// ARRAY_POP DISABLED
+// log_rd2("TRANS NON ATTIVATO, clean del comm array");
+// while (($el = array_pop($user->comm)) != NULL) {
+// log_rd2("clean element [".$el."]");
+// }
+// // $user->step_inc(COMM_N + 1);
+// Room::save_data($room);
+// // $new_step = $user->step;
+
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
}
}
if ($cur_step == -1) {
- log_rd2($sess, "PRE-NEWSTAT.");
+ log_rd2("PRE-NEWSTAT: ".$user->stat);
if ($user->stat == 'room') {
- log_rd($sess, "roomma");
- $ret .= show_room(&$bri, &$user);
+ log_rd("roomma ".$user->step);
+ $ret .= $room->show_room($user->step, &$user);
+
+ // TODO uncomment and test
+ /* NOTE the sets went common */
+ $new_stat = $user->stat;
+ $new_subst = $user->subst;
+ $new_step = $user->step;
}
/***************
* *
* TABLE *
* *
***************/
- else if ($user->stat == 'table') {
- $ret = show_table(&$bri,&$user,$user->step,FALSE,FALSE);
-
- log_rd2($sess, "SENDED TO THE STREAM: ".$ret);
+ else if ($user->stat == 'table') {
+ log_load("RESYNC");
+ return (page_sync($user->sess, "briskin5/index.php", $user->table, $user->table_token));
}
- log_rd2($sess, "NEWSTAT: ".$user->stat);
-
- $new_stat = $user->stat;
- $new_subst = $user->subst;
- $new_step = $user->step;
+ log_rd2("NEWSTAT: ".$user->stat);
}
else {
ignore_user_abort(TRUE);
- $sem = lock_data();
- $bri = &load_data();
- if (($user = &$bri->get_user($sess, $idx)) == FALSE) {
- unlock_data($sem);
+ $sem = Room::lock_data();
+ $room = &Room::load_data();
+ if (($user = &$room->get_user($sess, $idx)) == FALSE) {
+ Room::unlock_data($sem);
ignore_user_abort(FALSE);
return (unrecerror());
}
if ($cur_step + COMM_N < $user->step) {
if (($cur_stat != $user->stat)) {
$to_stat = $user->stat;
- unlock_data($sem);
+ Room::unlock_data($sem);
ignore_user_abort(FALSE);
- return (page_sync($user->sess, $to_stat == "table" ? "table.php" : "index.php"));
+ log_load("RESYNC");
+ return (page_sync($user->sess, ($to_stat == "table" ? "briskin5/index.php" : "index.php"), $user->table, $user->table_token));
}
- log_rd2($sess, "lost history, refresh from scratch");
- $new_step = -1;
+ log_rd2("lost history, refresh from scratch");
+ $new_step = -1;
break;
}
for ($i = $cur_step ; $i < $user->step ; $i++) {
- log_rd2($sess, "ADDED TO THE STREAM: ".$user->comm[$i % COMM_N]);
+ log_rd2("ADDED TO THE STREAM: ".$user->comm[$i % COMM_N]);
$ret .= $user->comm[$i % COMM_N];
}
$new_stat = $user->stat;
} while (0);
if ($user->the_end == TRUE) {
- log_rd2($sess, "LOGOUT BYE BYE!!");
+ log_rd2("LOGOUT BYE BYE!!");
log_auth($user->sess, "Explicit logout.");
- $tmp_sess = $user->sess;
- $user->sess = "";
- step_unproxy($tmp_sess);
-
- $user->name = "";
- $user->the_end = FALSE;
-
- if ($user->subst == 'sitdown')
- $bri->room_wakeup(&$user);
+
+ $user->reset();
+
+ if ($user->subst == 'sitdown') {
+ log_load("ROOM WAKEUP");
+ $room->room_wakeup(&$user);
+ }
else if ($user->subst == 'standup')
- $bri->room_outstandup(&$user);
+ $room->room_outstandup(&$user);
else
- log_rd2($sess, "LOGOUT FROM WHAT ???");
+ log_rd2("LOGOUT FROM WHAT ???");
- save_data($bri);
+ Room::save_data($room);
}
}
- unlock_data($sem);
+ Room::unlock_data($sem);
ignore_user_abort(FALSE);
}
*/
$is_page_streaming = ((stristr($HTTP_USER_AGENT, "linux") &&
- stristr($HTTP_USER_AGENT, "firefox")) ? FALSE : TRUE);
+ (stristr($HTTP_USER_AGENT, "firefox") || stristr($HTTP_USER_AGENT, "iceweasel"))) ? FALSE : TRUE);
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
+header('Content-type: application/xml; charset="utf-8"',true);
+// header('Content-type: text/plain; charset="utf-8"',true);
+// header('Content-type: text/html; charset="utf-8"',true);
if (!isset($myfrom))
$myfrom = "";
if (!isset($subst))
$subst = "";
-log_rd2($sess, "FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming);
+log_rd2("FROM OUTSIDE - STAT: ".$stat." SUBST: ".$subst." STEP: ".$step." MYFROM: ".$myfrom. "IS_PAGE:" . $is_page_streaming);
$endtime = time() + STREAM_TIMEOUT;
$old_step = $ext_step = $step;
for ($i = 0 ; time() < $endtime ; $i++) {
- // log_rd($sess, "PRE MAIN ".$step);;
+ // log_rd("PRE MAIN ".$step);;
if (($ret = maincheck($sess, $old_stat, $old_subst, $old_step, &$stat, &$subst, &$step)) != FALSE) {
echo '@BEGIN@';
- // log_rd2($sess, sprintf("\nSESS: [%s]\nOLD_STAT: [%s] OLD_SUBST: [%s] OLD_STEP: [%s] \nSTAT: [%s] SUBST: [%s] STEP: [%s] \nCOMM: [%s]\n", $sess, $old_stat, $old_subst, $old_step, $stat, $subst, $step, $ret));
+ // log_rd2(sprintf("\nSESS: [%s]\nOLD_STAT: [%s] OLD_SUBST: [%s] OLD_STEP: [%s] \nSTAT: [%s] SUBST: [%s] STEP: [%s] \nCOMM: [%s]\n", $sess, $old_stat, $old_subst, $old_step, $stat, $subst, $step, $ret));
echo "$ret";
echo ' @END@';
- log_send($sess, "EXT_STEP: ".$ext_step." ENDTIME: [".$endtime."] ".$ret);
+ log_send("IS_PAGE: ".($is_page_streaming == TRUE ? "TRUE" : "FALSE")."EXT_STEP: ".$ext_step." ENDTIME: [".$endtime."] ".$ret);
flush();
if ($is_page_streaming)
break;
$old_stat = $stat;
$old_subst = $subst;
$old_step = $step;
- // log_rd($sess, "POST MAIN ".$step);;
+ // log_rd("POST MAIN ".$step);;
usleep(400000);
if (($i % 5) == 0) {
- // log_rd2($sess, "TIME: ".time());
+ // log_rd2("TIME: ".time());
echo '_';
flush();
}
/*
* brisk - index_wr.php
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
*/
-require_once("brisk.phh");
+require_once("Obj/brisk.phh");
+// require_once("Obj/proxyscan.phh");
+require_once("briskin5/Obj/briskin5.phh");
+
+// Use of proxies isn't allowed.
+// if (is_proxy()) {
+// sleep(5);
+// exit;
+// }
+log_load("index_wr.php");
+
if (DEBUGGING == "local" && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
echo "Debugging time!";
exit;
}
-log_load($sess, "LOAD: index_wr.php");
-
/*
* MAIN
*/
-log_wr($sess, 'COMM: '.$mesg);
-
-$sem = lock_data();
-$bri = &load_data();
-if (($user = &$bri->get_user($sess, &$idx)) == FALSE) {
- echo "Get User Error";
- log_wr($sess, "Get User Error");
- unlock_data($sem);
+
+/* if the IP is banned, exit without do nothing */
+if (array_search($_SERVER['REMOTE_ADDR'], $G_black_list) !== FALSE) {
+ sleep(5);
+ exit;
+}
+
+$is_spawn = FALSE;
+
+log_wr('COMM: '.$mesg);
+
+$sem = Room::lock_data();
+if (($room = &Room::load_data()) == FALSE) {
+ echo "Load data error";
+ log_wr("Load data error");
+ Room::unlock_data($sem);
+ exit;
+}
+if (($user = &$room->get_user($sess, &$idx)) == FALSE) {
+ Room::unlock_data($sem);
+ $argz = explode('|', $mesg);
+
+ if ($argz[0] == 'help') {
+ echo show_notify(str_replace("\n", " ", $G_room_help), 0, "torna ai tavoli", 600, 500);
+ }
+ else if ($argz[0] == 'about') {
+ echo show_notify(str_replace("\n", " ", $G_room_about), 0, "torna ai tavoli", 400, 200);
+ }
+ else if ($argz[0] == 'roadmap') {
+ echo show_notify(str_replace("\n", " ", $G_room_roadmap), 0, "torna ai tavoli", 400, 200);
+ }
+ else if ($argz[0] == 'whysupport') {
+ echo show_notify(str_replace("\n", " ", $G_room_whysupport), 0, "torna ai tavoli", 400, 200);
+ }
+ else {
+ log_wr("Get User Error");
+ echo "Get User Error";
+ }
exit;
}
$argz = explode('|', $mesg);
+log_wr('POSTSPLIT: '.$argz[0]);
+
if ($argz[0] == 'shutdown') {
- log_auth($user_cur->sess, "Shutdown session.");
- $tmp_sess = $user->sess;
- $user->sess = "";
- step_unproxy($tmp_sess);
- $user->name = "";
- $user->the_end = FALSE;
-
- log_rd2($user->sess, "AUTO LOGOUT.");
+ log_auth($user->sess, "Shutdown session.");
+
+ $user->reset();
+
+ log_rd2("AUTO LOGOUT.");
if ($user->subst == 'sitdown' || $user->stat == 'table')
- $bri->room_wakeup(&$user);
+ $room->room_wakeup(&$user);
else if ($user->subst == 'standup')
- $bri->room_outstandup(&$user);
+ $room->room_outstandup(&$user);
else
- log_rd2($sess, "SHUTDOWN FROM WHAT ???");
+ log_rd2("SHUTDOWN FROM WHAT ???");
}
/******************
* *
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
$user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_help), 0, "torna ai tavoli", 600, 500);
- log_wr($sess, $user->comm[$user->step % COMM_N]);
+ log_wr($user->comm[$user->step % COMM_N]);
$user->step_inc();
}
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
$user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_about), 0, "torna ai tavoli", 400, 200);
- log_wr($sess, $user->comm[$user->step % COMM_N]);
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'roadmap') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_roadmap), 0, "torna ai tavoli", 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'whysupport') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_whysupport), 0, "torna ai tavoli", 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
$user->step_inc();
}
else if ($argz[0] == 'chatt') {
- $bri->chatt_send(&$user,$mesg);
+ $room->chatt_send(&$user,$mesg);
}
/**********************
* *
else if ($user->subst == 'standup') {
if ($argz[0] == 'sitdown') {
+ log_wr("SITDOWN command");
+
if ($user->the_end == TRUE) {
- log_wr($sess, "INFO:SKIP:argz == sitdown && the_end == TRUE => ignore request.");
- unlock_data($sem);
+ log_wr("INFO:SKIP:argz == sitdown && the_end == TRUE => ignore request.");
+ Room::unlock_data($sem);
+ exit;
+ }
+
+ // Take parameters
+ $table_idx = $argz[1];
+ $table = &$room->table[$table_idx];
+
+ $curtime = time();
+
+ if ($G_shutdown || $table->wakeup_time > $curtime) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ $dt = date("H:i ", $curtime);
+ if ($G_shutdown)
+ $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","<b>Il server sta per essere riavviato, non possono avere inizio nuove partite.</b>");', $dt.NICKSERV);
+ else
+ $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","<b>Il tavolo si è appena liberato, ci si potrà sedere tra %d secondi.</b>");', $dt.NICKSERV, $table->wakeup_time - $curtime);
+
+ $user->step_inc();
+ Room::save_data($room);
+ Room::unlock_data($sem);
exit;
}
+
/* TODO: refact to a function */
if ($user->bantime > $user->laccwr) {
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= show_notify("<br>Ti sei alzato da un tavolo senza il consenso degli altri giocatori. Dovrai aspettare ancora ".secstoword($user->bantime - $user->laccwr)." prima di poterti sedere nuovamente.", 2000, "Torna in piedi.", 400, 100);
+ $user->comm[$user->step % COMM_N] .= show_notify("<br>Ti sei alzato da un tavolo senza il consenso degli altri giocatori. Dovrai aspettare ancora ".secstoword($user->bantime - $user->laccwr)." prima di poterti sedere nuovamente.", 2000, "resta in piedi.", 400, 100);
$user->step_inc();
- save_data($bri);
- unlock_data($sem);
+ Room::save_data($room);
+ Room::unlock_data($sem);
exit;
}
- // Take parameters
- $table_idx = $argz[1];
- $table = &$bri->table[$table_idx];
-
if ($table->player_n == PLAYERS_N) {
- log_wr($sess, "WARN:FSM: Sitdown unreachable, table full.");
- unlock_data($sem);
+ log_wr("WARN:FSM: Sitdown unreachable, table full.");
+ Room::unlock_data($sem);
exit;
}
-
+
// set new status
$user->subst = "sitdown";
$user->table = $table_idx;
$user->table_pos = $table->user_add($idx);
+ log_wr("MOP before");
+
if ($table->player_n == PLAYERS_N) {
+ log_wr("MOP inall");
+
// Start game for this table.
- log_wr($sess, "Start game!");
+ log_wr("Start game!");
- $table->init(&$bri->user);
- $table->game_init(&$bri->user);
- $curtime = time();
+ //
+ // START THE SPAWN HERE!!!!
+ //
+
+ $curtime = time();
+
+ // Create new spawned table
+ $bri_sem = Briskin5::lock_data($table_idx);
+ $table_token = uniqid("");
+ $room->table[$table_idx]->table_token = $table_token;
+ $room->table[$table_idx]->table_start = $curtime;
+
+ $plist = "$table_token|$user->table|$table->player_n";
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $plist .= '|'.$room->user[$table->player[$i]]->sess;
+ }
+ log_legal($curtime, $user->sess, $user->name, "STAT:CREATE_GAME", $plist);
+
+ if (($bri =& new Briskin5(&$room, $table_idx, $table_token)) == FALSE)
+ log_wr("bri create: FALSE");
+ else
+ log_wr("bri create: ".serialize($bri));
- for ($i = 0 ; $i < $table->player_n ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- log_wr($sess, "Pre if!");
-
- $ret = "";
- $ret .= sprintf('gst.st_loc++; gst.st=%d; the_end=true; window.onunload = null ; document.location.assign("table.php");|', $user_cur->step+1);
-
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->trans_step = $user_cur->step + 1;
- log_wr($sess, "TRANS ATTIVATO");
-
-
- $user_cur->stat_set('table');
- $user_cur->subst = 'asta';
- $user_cur->laccwr = $curtime;
- $user_cur->step_inc();
-
- $user_cur->comm[$user_cur->step % COMM_N] = show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, FALSE);
- $user_cur->step_inc();
- }
+ // init table
+ $bri_table =& $bri->table[0];
+ $bri_table->init(&$bri->user);
+ $bri_table->game_init(&$bri->user);
+ //
+ // Init spawned users.
+ //
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $bri_user_cur = &$bri->user[$i];
+ $user_cur = &$room->user[$table->player[$i]];
+
+ $bri_user_cur->stat_set('table');
+ $bri_user_cur->subst = 'asta';
+ $bri_user_cur->laccwr = $curtime;
+
+ $bri_user_cur->trans_step = $user_cur->step + 1;
+ $bri_user_cur->comm[$bri_user_cur->step % COMM_N] = "";
+ $bri_user_cur->step_inc();
+ $bri_user_cur->comm[$bri_user_cur->step % COMM_N] = show_table(&$bri,&$bri_user_cur,$bri_user_cur->step+1,TRUE, FALSE);
+
+ $bri_user_cur->step_inc();
+
+ log_wr("TRY PRESAVE: ".$bri_user_cur->step." TRANS STEP: ".$bri_user_cur->trans_step);
+
+ log_wr("Pre if!");
+
+ // ARRAY_POP DISABLED
+ // // CHECK
+ while (array_pop($user_cur->comm) != NULL);
+
+ $ret = "";
+ $ret .= sprintf('gst.st_loc++; gst.st=%d; createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); the_end=true; window.onunload = null ; document.location.assign("briskin5/index.php");|', $user_cur->step+1, $table_idx, $table_token);
+
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->trans_step = $user_cur->step + 1;
+ log_wr("TRANS ATTIVATO");
+
+
+ $user_cur->stat_set('table');
+ $user_cur->subst = 'asta';
+ $user_cur->laccwr = $curtime;
+ $user_cur->step_inc();
+ }
+ log_wr("presave bri");
+ Briskin5::save_data($bri);
+ Briskin5::unlock_data($bri_sem);
+ log_wr("postsave bri");
}
+ // change room
+ $room->room_sitdown(&$user, $table_idx);
+
+ log_wr("MOP finish");
+
- $bri->room_sitdown(&$user, $table_idx);
}
else if ($argz[0] == 'logout') {
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= sprintf('postact_logout();');
+ $user->comm[$user->step % COMM_N] .= 'postact_logout();';
$user->the_end = TRUE;
$user->step_inc();
}
**********************/
else if ($user->subst == 'sitdown') {
if ($argz[0] == 'wakeup') {
- $bri->room_wakeup(&$user);
+ $room->room_wakeup(&$user);
}
else if ($argz[0] == 'logout') {
- $bri->room_wakeup(&$user);
+ $room->room_wakeup(&$user);
$user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= sprintf('postact_logout();');
+ $user->comm[$user->step % COMM_N] .= 'postact_logout();';
$user->the_end = TRUE;
$user->step_inc();
}
}
}
-/*********************
- * *
- * STAT: table *
- * *
- *********************/
-else if ($user->stat == 'table') {
- $user->laccwr = time();
- $table = &$bri->table[$user->table];
-
- if ($argz[0] == 'tableinfo') {
- log_wr($sess, "PER DI TABLEINFO");
- $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= show_table_info(&$bri, &$table, $user->table_pos);
- log_wr($sess, $user->comm[$user->step % COMM_N]);
- $user->step_inc();
- }
- else if ($argz[0] == 'chatt') {
- $bri->chatt_send(&$user,$mesg);
- }
- else if ($argz[0] == 'logout') {
- $remcalc = $argz[1];
-
- if ($user->exitislock == TRUE) {
- $remcalc++;
- $user->exitislock = FALSE;
- }
-
- $logout_cont = TRUE;
- if ($remcalc >= 3) {
- $lockcalc = $table->exitlock_calc(&$bri->user, $user->table_pos);
- if ($lockcalc < 3) {
- $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
- $user->comm[$user->step % COMM_N] .= $table->exitlock_show(&$bri->user, $user->table_pos);
- $user->comm[$user->step % COMM_N] .= show_notify("<br>I dati presenti sul server non erano allineati con quelli inviati dal tuo browser, adesso lo sono. Riprova ora.", 2000, "Torna alla partita.", 400, 100);
-
- log_wr($sess, $user->comm[$user->step % COMM_N]);
- $user->step_inc();
- $logout_cont = FALSE;
- }
- }
- else
- $user->bantime = $user->laccwr + BAN_TIME;
-
- if ($logout_cont == TRUE) {
- $bri->room_wakeup(&$user);
- }
- }
- else if ($argz[0] == 'exitlock') {
- $user->exitislock = ($user->exitislock == TRUE ? FALSE : TRUE);
- for ($ct = 0, $i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur[$i] = &$bri->user[$table->player[$i]];
- if ($user_cur[$i]->exitislock == FALSE)
- $ct++;
- }
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $ret = sprintf('gst.st = %d;', $user_cur[$i]->step+1);
- $ret .= sprintf('exitlock_show(%d, %s);', $ct,
- ($user_cur[$i]->exitislock ? 'true' : 'false'));
- $user_cur[$i]->comm[$user_cur[$i]->step % COMM_N] = $ret;
- log_wr($sess, $user_cur[$i]->comm[$user_cur[$i]->step % COMM_N]);
- $user_cur[$i]->step_inc();
- }
- }
- else if ($user->subst == 'asta') {
- if ($argz[0] == 'lascio' && $user->handpt <= 2) {
- $index_cur = $table->gstart % PLAYERS_N;
-
- log_wr($sess, sprintf("GIOCO FINITO !!!"));
-
- $table->mult *= 2;
- $table->old_reason = sprintf("Ha lasciato %s perche` aveva al massimo 2 punti.", $user->name);
-
- $table->game_next();
- $table->game_init(&$bri->user);
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
-
- $ret = sprintf('gst.st = %d;', $user_cur->step+1);
- $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE);
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
- }
- else if ($argz[0] == 'asta') {
- $again = TRUE;
-
- $index_cur = $table->gstart % PLAYERS_N;
- if ($user->table_pos == $index_cur &&
- $table->asta_pla[$index_cur]) {
- $a_card = $argz[1];
- $a_pnt = $argz[2];
-
- log_wr($sess, "CI SIAMO a_card ".$a_card." asta_card ".$table->asta_card);
-
- // Abbandono dell'asta
- if ($a_card <= -1) {
- log_wr($sess, "Abbandona l'asta.");
- $table->asta_pla[$index_cur] = FALSE;
- $user->asta_card = -1;
- $table->asta_pla_n--;
- $again = FALSE;
- }
- else if ($a_card <= 9) {
- if ($a_card >= 0 && $a_card < 9 && $a_card > $table->asta_card)
- $again = FALSE;
- else if ($a_card == 9 && $a_pnt > ($table->asta_pnt >= 61 ? $table->asta_pnt : 60) && $a_pnt <= 120)
- $again = FALSE;
-
-
- if ($again == FALSE) {
- log_wr($sess, "NUOVI ORZI.");
- $user->asta_card = $a_card;
- $table->asta_card = $a_card;
- if ($a_card == 9) {
- $user->asta_pnt = $a_pnt;
- $table->asta_pnt = $a_pnt;
- }
- }
- }
-
-
-
- if ($again) { // Qualcosa non andato bene, rifare
- $ret = sprintf('gst.st = %d; asta_pnt_set(%d);', $user->step+1,
- ($table->asta_pnt > 60 ? $table->asta_pnt + 1 : 61) );
- $user->comm[$user->step % COMM_N] = $ret;
- $user->step_inc();
-
- log_wr($sess, "Ripetere.");
- }
- else {
- /* next step */
- $showst = "show_astat(";
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- $showst .= sprintf("%s%d", ($i == 0 ? "" : ", "),
- ($user_cur->asta_card < 9 ? $user_cur->asta_card : $user_cur->asta_pnt));
- }
- if (PLAYERS_N == 3)
- $showst .= ",-2,-2";
- $showst .= ");";
-
- $maxcard = -2;
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- if ($maxcard < $user_cur->asta_card)
- $maxcard = $user_cur->asta_card;
- }
-
- if (($table->asta_pla_n > ($maxcard > -1 ? 1 : 0)) &&
- !($table->asta_card == 9 && $table->asta_pnt == 120)) {
- log_wr($sess,"ALLOPPA QUI");
- for ($i = 1 ; $i < PLAYERS_N ; $i++) {
- $index_next = ($table->gstart + $i) % PLAYERS_N;
- if ($table->asta_pla[$index_next]) {
- log_wr($sess,"GSTART 1");
- $table->gstart += $i;
- break;
- }
- }
-
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- $ret = sprintf('gst.st = %d; %s', $user_cur->step+1, $showst);
- if ($user_cur->table_pos == ($table->gstart % PLAYERS_N))
- $ret .= sprintf('dispose_asta(%d,%d, %s); remark_on();',
- $table->asta_card + 1, $table->asta_pnt+1, ($user_cur->handpt <= 2 ? "true" : "false"));
- else
- $ret .= sprintf('dispose_asta(%d,%d, %s); remark_off();',
- $table->asta_card + 1, -($table->asta_pnt+1), ($user_cur->handpt <= 2 ? "true" : "false"));
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
- }
- else if ($table->asta_pla_n == 0) {
- log_wr($sess, "PASSANO TUTTI!");
-
- log_wr($sess, sprintf("GIOCO FINITO !!!"));
-
- $table->old_reason = "Hanno passato tutti.";
- $table->mult *= 2;
-
- $table->game_next();
- $table->game_init(&$bri->user);
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
-
- $ret = sprintf('gst.st = %d;', $user_cur->step+1);
- $ret .= show_table(&$bri,&$user_cur,$user_cur->step+1, TRUE, TRUE);
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
- }
- else {
- log_wr($sess, "FINITA !");
- // if a_pnt == 120 supergame ! else abbandono
- if ($a_pnt == 120 || $user->asta_card != -1) {
- $chooser = $index_cur;
- for ($i = 1 ; $i < PLAYERS_N ; $i++)
- if ($i != $chooser)
- $table->asta_pla[$i] = FALSE;
- }
- else {
- //"gst.st = ".($user->step+1)."; dispose_asta(".($table->asta_card + 1).",".-($table->asta_pnt).", true); remark_off();";
- $user->comm[$user->step % COMM_N] = sprintf( "gst.st = %d; dispose_asta(%d, %d, false); remark_off();", $user->step+1, $table->asta_card + 1,-($table->asta_pnt));
- $user->step_inc();
- for ($i = 1 ; $i < PLAYERS_N ; $i++) {
- $chooser = ($table->gstart + $i) % PLAYERS_N;
- if ($table->asta_pla[$chooser]) {
- break;
- }
- }
- }
- $table->asta_win = $chooser;
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- $ret = sprintf('gst.st = %d; %s', $user_cur->step+1, $showst);
-
- if ($i == $chooser) {
- $ret .= "choose_seed(". $table->asta_card."); \$(\"asta\").style.visibility = \"hidden\"; remark_on();";
- }
- else {
- $ret .= "remark_off();";
- }
-
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
- }
- }
- }
- else {
- log_wr($sess, "NON CI SIAMO");
- }
- }
- /* asta::choose */
- else if ($argz[0] == 'choose') {
- if ($table->asta_win > -1 &&
- $user->table_pos == $table->asta_win) {
- $a_brisco = $argz[1];
- if ($a_brisco >= 0 && $a_brisco < 40) {
- $table->briscola = $a_brisco;
- $table->friend = $table->card[$a_brisco]->owner;
- log_wr($sess,"GSTART 2");
- $table->gstart = ($table->mazzo+1) % PLAYERS_N;
- log_wr($sess, "Setta la briscola a ".$a_brisco);
-
- $chooser = $table->asta_win;
- $user_chooser = &$bri->user[$table->player[$chooser]];
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- $user_cur->subst = 'game';
- $ret = sprintf('gst.st = %d; subst = "game";', $user_cur->step+1);
-
-
- /* bg of caller cell */
- $ret .= briscola_show($bri, $table, $user_cur);
-
- /* first gamer */
- if ($i == ($table->gstart % PLAYERS_N))
- $ret .= "is_my_time = true; remark_on();";
- else
- $ret .= "is_my_time = false; remark_off();";
-
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->step_inc();
- }
- /*
- TUTTE LE VARIABILI DI STATO PER PASSARE A GIOCARE E LE
- VAR PER PASSARE ALLA FASE DI GIOCO
- */
-
- }
- }
- }
- }
- else if ($user->subst == 'game') {
- log_wr($sess, "state: table::game".$argz[0]);
-
- if ($argz[0] == 'play') {
- $a_play = $argz[1];
- $a_x = $argz[2];
- $a_y = $argz[3];
-
- if (strpos($a_x, "px") != FALSE)
- $a_x = substr($a_x,0,-2);
- if (strpos($a_y, "px") != FALSE)
- $a_y = substr($a_y,0,-2);
-
- $loggo = sprintf("A_play %s, table_pos %d == %d, mazzo %d, gstart %d, card_stat %d, card_own %d",
- $a_play, $user->table_pos, ($table->gstart % PLAYERS_N),
- $table->mazzo, $table->gstart,
- $table->card[$a_play]->stat, $table->card[$a_play]->owner);
- log_wr($sess, "CIC".$loggo);
-
- /* se era il suo turno e la carta era sua ed era in mano */
- if ($a_play >=0 && $a_play < 40 &&
- ($user->table_pos == (($table->gstart + $table->turn) % PLAYERS_N)) &&
- $table->card[$a_play]->stat == 'hand' &&
- $table->card[$a_play]->owner == $user->table_pos) {
- log_wr($sess, sprintf("User: %s Play: %d",$user->name, $a_play));
-
- /* Change the card status. */
- $table->card[$a_play]->play($a_x, $a_y);
-
- /*
- * !!!! TURN INCREMENTED BEFORE !!!!
- */
- $turn_cur = ($table->gstart + $table->turn) % PLAYERS_N;
- $table->turn++;
-
- $card_play = sprintf("card_play(%d,%d,%d,%d);|",
- $user->table_pos, $a_play, $a_x, $a_y);
- if (($table->turn % PLAYERS_N) != 0) { /* manche not finished */
- $turn_nex = ($table->gstart + $table->turn) % PLAYERS_N;
-
- $player_cur = "remark_off();";
- $player_nex = $card_play . "is_my_time = true; remark_on();";
- $player_oth = $card_play;
- }
- else if ($table->turn <= (PLAYERS_N * 8)) { /* manche finished */
- $winner = calculate_winner($table);
- log_wr($sess,"GSTART 3");
- $table->gstart = $winner;
- $turn_nex = ($table->gstart + $table->turn) % PLAYERS_N;
-
- log_wr($sess, sprintf("The winner is: [%d] [%s]", $winner, $bri->user[$table->player[$winner]]->name));
- $card_take = sprintf("sleep(gst,2000);|cards_take(%d);|cards_hidetake($d);",
- $winner, $winner);
- $player_cur = "remark_off();" . $card_take . "|";
- if ($turn_cur != $turn_nex)
- $player_nex = $card_play . $card_take . "|";
- else
- $player_nex = "";
- if ($table->turn < (PLAYERS_N * 8)) /* game NOT finished */
- $player_nex .= "is_my_time = true; remark_on();";
- $player_oth = $card_play . $card_take;
- }
-
- log_wr($sess, sprintf("Turn Cur %d Turn Nex %d",$turn_cur, $turn_nex));
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
-
- $ret = sprintf('gst.st = %d; ', $user_cur->step+1);
-
-
- if ($i == $turn_cur) {
- $ret .= $player_cur;
- }
- if ($i == $turn_nex) {
- $ret .= $player_nex;
- }
- if ($i != $turn_cur && $i != $turn_nex) {
- $ret .= $player_oth;
- }
-
- $retar[$i] = $ret;
- }
-
-
-
-
- if ($table->turn == (PLAYERS_N * 8)) { /* game finished */
- log_wr($sess, sprintf("GIOCO FINITO !!!"));
-
- /* ************************************************ */
- /* PRIMA LA PARTE PER LO SHOW DI CHI HA VINTO */
- /* ************************************************ */
- calculate_points(&$table);
-
- $table->game_next();
- $table->game_init(&$bri->user);
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- $retar[$i] .= show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, TRUE);
- }
- }
-
-
- for ($i = 0 ; $i < PLAYERS_N ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
-
- $user_cur->comm[$user_cur->step % COMM_N] = $retar[$i];
- $user_cur->step_inc();
- }
-
- log_wr($sess, sprintf("TURN: %d",$table->turn));
- /* Have played all the players ? */
- /* NO: switch the focus and enable the next player to play. */
-
- /* YES: calculate who win and go to the next turn. */
- }
- }
- else
- log_wr($sess, "NOSENSE");
- }
-}
-log_wr($sess, "before save data");
-save_data($bri);
+log_wr("before save data");
+Room::save_data($room);
-unlock_data($sem);
+Room::unlock_data($sem);
exit;
?>
+++ /dev/null
-<?php
-/*
- * brisk - info_main.php
- *
- * Copyright (C) 2006 matteo.nastasi@milug.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details. You should have received a
- * copy of the GNU General Public License along with this program; if
- * not, write to the Free Software Foundation, Inc, 59 Temple Place -
- * Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- *
- */
-
-define( FTOK_PATH, "/var/lib/brisk");
-define(MAX_PLAYERS, 5);
-define(SESS_LEN, 13);
-
-if (MAX_PLAYERS == 5)
- exit;
-
-class User {
- var $name;
- var $sess;
- var $table;
-
- function User($name, $sess, $table = "") {
- $this->name = $name;
- $this->sess = $sess;
- $this->table = $table;
- }
-}
-
-class brisco {
- var $user;
-
- function brisco () {
- $this->user = array();
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $this->user[$i] = new User("", "", "");
- }
- }
-}
-
-function init_data()
-{
- $brisco = new brisco();
-
- return $brisco;
-}
-
-function load_data()
-{
- if (($tok = ftok(FTOK_PATH."/main", "B")) == -1) {
- echo "FTOK FAILED";
- exit;
- }
- echo "FTOK ".$tok."<br>";
- if (($res = sem_get($tok)) == FALSE) {
- echo "SEM_GET FAILED";
- exit;
- }
- if (sem_acquire($res)) {
- if ($shm = shm_attach($tok)) {
- echo "fin qui<br>";
- $bri = @shm_get_var($shm, $tok);
- }
-
- shm_detach($shm);
- }
- sem_release($res);
-
- return ($bri);
-}
-
-
-function save_data($bri)
-{
- $ret = FALSE;
- $shm = FALSE;
- $isacq = FALSE;
-
- if (($tok = ftok(FTOK_PATH."/main", "B")) == -1)
- return (FALSE);
-
- if (($res = sem_get($tok)) == FALSE)
- return (FALSE);
-
- do {
- if (sem_acquire($res) == FALSE)
- break;
- $isacq = TRUE;
-
- if (($shm = shm_attach($res)) == FALSE)
- break;
-
- if (shm_put_var($shm, $res, $bri) == FALSE)
- break;
- $ret = TRUE;
- } while (0);
-
- if ($shm)
- shm_detach($shm);
-
- if ($isacq)
- sem_release($res);
-
- return ($ret);
-}
-
-function &check_session($bri, $sess)
-{
- if (strlen($sess) == SESS_LEN) {
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- if (strcmp($sess, $bri->user[$i]->sess) == 0) {
- // find it
- return ($bri->user[$i]);
- }
- }
- }
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- if ($bri->user[$i]->sess == "") {
- $bri->user[$i]->sess = uniqid("");
- return ($bri->user[$i]);
- }
- }
-
- return (NULL);
-}
-
-function duplicated_name($bri, $name)
-{
- if (!isset($name))
- return (FALSE);
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- if (strcmp($bri->user[$i]->name,$name) == 0) {
- return (TRUE);
- }
- }
- return (FALSE);
-}
-
-function main() {
- GLOBAL $sess, $name;
- $bri = load_data();
-
- echo "<plaintext>";
- var_dump($bri);
-}
-
-main();
-?>
--- /dev/null
+ var g_menu_tree = null;
+ var g_menu_ct = 0;
+ var g_menu_st = 0;
+ var g_menu_cb = null;
+
+ function menu_init() {
+ g_menu_tree = new Array(null, null, null);
+
+ g_menu_tree[0] = new Array();
+ g_menu_tree[0][0] = $('menu_webstart');
+ g_menu_tree[1] = new Array();
+ g_menu_tree[1][0] = $('menu_raduni');
+ }
+
+ function menu_show(id) {
+ $(id).style.visibility = 'visible';
+ }
+
+ function menu_over(over,obj) {
+ g_menu_ct += over;
+ g_menu_st ++;
+
+
+ if (over < 0) {
+ g_menu_cb = setTimeout(menu_hide, 0, g_menu_st, 0);
+ }
+ else {
+ if (g_menu_cb != null) {
+ clearTimeout(g_menu_cb);
+ g_menu_cb = null;
+ }
+ }
+ }
+
+
+function menu_hide(st,lev) {
+ if (st == g_menu_st || lev > 0) {
+ for (e = lev ; e < g_menu_tree.length ; e++) {
+ if (g_menu_tree[e] != null) {
+ for (i = 0 ; i < g_menu_tree[e].length ; i++) {
+ if (g_menu_tree[e][i] != null) {
+ g_menu_tree[e][i].style.visibility = "hidden";
+ }
+ }
+ }
+ }
+ if (st == g_menu_st && lev == 0) {
+ g_menu_ct = 0;
+ g_menu_st = 0;
+ }
+ }
+}
+
var g_preload_img_arr = new Array(
- "img/brisk_table_sand0.jpg", "img/brisk_table_sand4.jpg", "img/brisk_table_sand1.jpg", "img/brisk_table_sand3.jpg",
- "img/brisk_table_sand2.jpg", "img/brisk_caller_sand4.png", "img/brisk_caller_sand0.png", "img/brisk_caller_sand2.png",
- "img/brisk_caller_sand1.png", "img/brisk_caller_sand3.png", "img/asta.png", "img/brisk_banner.png",
- "img/bg_capodanno.jpg", "img/33_ea.png", "img/33_we.png", "img/31_we.png",
- "img/35_ea.png", "img/35_we.png", "img/31_ea.png", "img/23_ea.png",
- "img/33.png", "img/23_we.png", "img/31.png", "img/35.png",
- "img/13_ea.png", "img/23.png", "img/13_we.png", "img/cover_ea.png",
- "img/cover_we.png", "img/cover.png", "img/32_ea.png", "img/32_we.png",
- "img/13.png", "img/32.png", "img/10_we.png", "img/10_ea.png",
- "img/27_we.png", "img/27_ea.png", "img/30_we.png", "img/34_we.png",
- "img/10.png", "img/30_ea.png", "img/36_we.png", "img/36_ea.png",
- "img/34_ea.png", "img/30.png", "img/37_we.png", "img/38_we.png",
- "img/36.png", "img/37_ea.png", "img/38_ea.png", "img/38.png",
- "img/27.png", "img/34.png", "img/37.png", "img/virtualsky80x15a.gif",
- "img/39_we.png", "img/03_we.png", "img/39_ea.png", "img/03_ea.png",
- "img/39.png", "img/03.png", "img/17_ea.png", "img/17_we.png",
- "img/20.png", "img/20_ea.png", "img/12_we.png", "img/20_we.png",
- "img/11_ea.png", "img/12_ea.png", "img/22_we.png", "img/02_ea.png",
- "img/02_we.png", "img/22_ea.png", "img/11_we.png", "img/25_we.png",
- "img/17.png", "img/25_ea.png", "img/00_ea.png", "img/28_ea.png",
- "img/00_we.png", "img/24_we.png", "img/28_we.png", "img/24_ea.png",
- "img/11.png", "img/12.png", "img/22.png", "img/02.png",
- "img/28.png", "img/00.png", "img/25.png", "img/14_ea.png",
- "img/14_we.png", "img/24.png", "img/09_we.png", "img/09_ea.png",
- "img/09.png", "img/14.png", "img/04_ea.png", "img/04_we.png",
- "img/04.png", "img/19.png", "img/19_ea.png", "img/19_we.png",
- "img/21_ea.png", "img/21.png", "img/21_we.png", "img/06.png",
- "img/06_ea.png", "img/06_we.png", "img/05.png", "img/16_we.png",
- "img/16_ea.png", "img/05_we.png", "img/26_ea.png", "img/26_we.png",
- "img/05_ea.png", "img/01_we.png", "img/01_ea.png", "img/16.png",
- "img/01.png", "img/07.png", "img/07_ea.png", "img/08_ea.png",
- "img/08_we.png", "img/07_we.png", "img/08.png", "img/26.png",
- "img/18_ea.png", "img/18_we.png", "img/18.png", "img/15_ea.png",
- "img/15_we.png", "img/29_we.png", "img/29_ea.png", "img/29.png",
- "img/15.png", "img/brisk_logo64.png", "img/download_now_flash.gif", "img/asta3.png",
- "img/asta8.png", "img/asta7.png", "img/asta4.png", "img/astapasso.png",
- "img/asta3_ro.png", "img/asta8_ro.png", "img/asta7_ro.png", "img/asta5.png",
- "img/asta4_ro.png", "img/asta9.png", "img/astalascio.png", "img/asta0.png",
- "img/asta5_ro.png", "img/astapasso_ro.png", "img/astapashalf.png", "img/asta1.png",
- "img/asta6.png", "img/asta0_ro.png", "img/asta9_ro.png", "img/asta2.png",
- "img/brisk_donate.gif", "img/astalascio_ro.png", "img/virtualsky80x15.png", "img/asta1_ro.png",
- "img/astapashalf_ro.png", "img/asta6_ro.png", "img/astaptsub.png", "img/asta2_ro.png",
- "img/astaptsub_ro.png", "img/brisk_homebutt.png", "img/dynamica.png", "img/brichi.png",
- "img/exitlock2n.png", "img/exitlock1n.png", "img/exitlock1y.png", "img/exitlock3n.png",
- "img/altout80x15.png", "img/exitlock0n.png", "img/exitlock3y.png", "img/exitlock2y.png",
- "img/brisk_logo80x15.png", "img/exitlock0y.png", "img/brisk_start.png", "img/noimg.png",
+ "briskin5/img/brisk_table_sand0.jpg", "briskin5/img/brisk_table_sand4.jpg",
+ "briskin5/img/brisk_table_sand1.jpg", "briskin5/img/brisk_table_sand3.jpg",
+ "briskin5/img/brisk_table_sand2.jpg", "img/bg_spawn2.jpg",
+ "briskin5/img/brisk_caller_sand4.png", "briskin5/img/brisk_caller_sand0.png",
+ "briskin5/img/brisk_caller_sand2.png", "briskin5/img/brisk_caller_sand1.png",
+ "briskin5/img/brisk_caller_sand3.png", "img/virtualsky_big.png",
+ "img/brichi_big.png", "img/forumolimpia_big.png",
+ "briskin5/img/33_ea.png", "briskin5/img/33_we.png",
+ "briskin5/img/31_we.png", "img/dynamica_big.png",
+ "briskin5/img/35_ea.png", "briskin5/img/35_we.png",
+ "briskin5/img/31_ea.png", "briskin5/img/23_ea.png",
+ "briskin5/img/33.png", "briskin5/img/23_we.png",
+ "briskin5/img/31.png", "briskin5/img/35.png",
+ "briskin5/img/13_ea.png", "briskin5/img/23.png",
+ "briskin5/img/13_we.png", "briskin5/img/cover_ea.png",
+ "briskin5/img/cover_we.png", "briskin5/img/cover.png",
+ "briskin5/img/32_ea.png", "briskin5/img/32_we.png",
+ "briskin5/img/13.png", "briskin5/img/32.png",
+ "briskin5/img/10_we.png", "briskin5/img/10_ea.png",
+ "briskin5/img/27_we.png", "briskin5/img/27_ea.png",
+ "briskin5/img/30_we.png", "briskin5/img/34_we.png",
+ "briskin5/img/10.png", "briskin5/img/30_ea.png",
+ "briskin5/img/36_we.png", "briskin5/img/36_ea.png",
+ "briskin5/img/34_ea.png", "briskin5/img/30.png",
+ "briskin5/img/37_we.png", "briskin5/img/38_we.png",
+ "briskin5/img/36.png", "briskin5/img/37_ea.png",
+ "briskin5/img/38_ea.png", "briskin5/img/38.png",
+ "briskin5/img/27.png", "briskin5/img/34.png",
+ "briskin5/img/37.png", "img/virtualsky80x15a.gif",
+ "briskin5/img/39_we.png", "briskin5/img/03_we.png",
+ "briskin5/img/39_ea.png", "briskin5/img/03_ea.png",
+ "briskin5/img/39.png", "briskin5/img/03.png",
+ "briskin5/img/17_ea.png", "briskin5/img/17_we.png",
+ "briskin5/img/20.png", "briskin5/img/20_ea.png",
+ "briskin5/img/12_we.png", "briskin5/img/20_we.png",
+ "briskin5/img/11_ea.png", "briskin5/img/12_ea.png",
+ "briskin5/img/22_we.png", "briskin5/img/02_ea.png",
+ "briskin5/img/02_we.png", "briskin5/img/22_ea.png",
+ "briskin5/img/11_we.png", "briskin5/img/25_we.png",
+ "briskin5/img/17.png", "briskin5/img/25_ea.png",
+ "briskin5/img/00_ea.png", "briskin5/img/28_ea.png",
+ "briskin5/img/00_we.png", "briskin5/img/24_we.png",
+ "briskin5/img/28_we.png", "briskin5/img/24_ea.png",
+ "briskin5/img/11.png", "briskin5/img/12.png",
+ "briskin5/img/22.png", "briskin5/img/02.png",
+ "briskin5/img/28.png", "briskin5/img/00.png",
+ "briskin5/img/25.png", "briskin5/img/14_ea.png",
+ "briskin5/img/14_we.png", "briskin5/img/24.png",
+ "briskin5/img/09_we.png", "briskin5/img/09_ea.png",
+ "briskin5/img/09.png", "briskin5/img/14.png",
+ "briskin5/img/04_ea.png", "briskin5/img/04_we.png",
+ "briskin5/img/04.png", "briskin5/img/19.png",
+ "briskin5/img/19_ea.png", "briskin5/img/19_we.png",
+ "briskin5/img/21_ea.png", "briskin5/img/21.png",
+ "briskin5/img/21_we.png", "briskin5/img/06.png",
+ "briskin5/img/06_ea.png", "briskin5/img/06_we.png",
+ "briskin5/img/05.png", "briskin5/img/16_we.png",
+ "briskin5/img/16_ea.png", "briskin5/img/05_we.png",
+ "briskin5/img/26_ea.png", "briskin5/img/26_we.png",
+ "briskin5/img/05_ea.png", "briskin5/img/01_we.png",
+ "briskin5/img/01_ea.png", "briskin5/img/16.png",
+ "briskin5/img/01.png", "briskin5/img/07.png",
+ "briskin5/img/07_ea.png", "briskin5/img/08_ea.png",
+ "briskin5/img/08_we.png", "briskin5/img/07_we.png",
+ "briskin5/img/08.png", "briskin5/img/26.png",
+ "briskin5/img/18_ea.png", "briskin5/img/18_we.png",
+ "briskin5/img/18.png", "briskin5/img/15_ea.png",
+ "briskin5/img/15_we.png", "briskin5/img/29_we.png",
+ "briskin5/img/29_ea.png", "briskin5/img/29.png",
+ "briskin5/img/15.png", "img/brisk_logo64.png",
+ "img/download_now_flash.gif", "briskin5/img/asta3.png",
+ "briskin5/img/asta8.png", "briskin5/img/asta7.png",
+ "briskin5/img/asta4.png", "briskin5/img/astapasso.png",
+ "briskin5/img/asta3_ro.png", "briskin5/img/asta8_ro.png",
+ "briskin5/img/asta7_ro.png", "briskin5/img/asta5.png",
+ "briskin5/img/asta4_ro.png", "briskin5/img/asta9.png",
+ "briskin5/img/astalascio.png", "briskin5/img/asta0.png",
+ "briskin5/img/asta5_ro.png", "briskin5/img/astapasso_ro.png",
+ "briskin5/img/astapashalf.png", "briskin5/img/asta1.png",
+ "briskin5/img/asta6.png", "briskin5/img/asta0_ro.png",
+ "briskin5/img/asta9_ro.png", "briskin5/img/asta2.png",
+ "img/brisk_donate.gif", "briskin5/img/astalascio_ro.png",
+ "briskin5/img/asta1_ro.png", "briskin5/img/astapashalf_ro.png",
+ "briskin5/img/asta6_ro.png", "briskin5/img/astaptsub.png",
+ "briskin5/img/asta2_ro.png", "briskin5/img/astaptsub_ro.png",
+ "img/dynamica.png", "img/brichi.png",
+ "img/forumolimpia.gif", "briskin5/img/exitlock2n.png",
+ "briskin5/img/exitlock1n.png", "briskin5/img/exitlock1y.png",
+ "briskin5/img/exitlock3n.png", "img/altout80x15.png",
+ "briskin5/img/exitlock0n.png", "briskin5/img/exitlock3y.png",
+ "briskin5/img/exitlock2y.png", "briskin5/img/exitlock0y.png",
+ "img/brisk_start.png", "img/noimg.png",
"img/brisk_ico.png");
var g_preload_imgsz_arr = new Array(
- "5.2", "10.5", "15.7", "21.0", "26.2", "27.9", "29.6", "31.3",
- "33.0", "34.7", "36.1", "37.1", "37.8", "38.3", "38.8", "39.4",
- "39.9", "40.5", "41.0", "41.5", "42.1", "42.6", "43.1", "43.7",
- "44.2", "44.7", "45.2", "45.7", "46.3", "46.8", "47.3", "47.8",
- "48.3", "48.8", "49.3", "49.8", "50.3", "50.8", "51.3", "51.8",
- "52.3", "52.8", "53.3", "53.8", "54.3", "54.8", "55.3", "55.7",
- "56.2", "56.7", "57.2", "57.7", "58.2", "58.7", "59.2", "59.6",
- "60.1", "60.6", "61.1", "61.6", "62.0", "62.5", "63.0", "63.4",
- "63.9", "64.3", "64.8", "65.3", "65.7", "66.2", "66.6", "67.1",
- "67.6", "68.0", "68.5", "68.9", "69.4", "69.8", "70.3", "70.7",
- "71.2", "71.7", "72.1", "72.6", "73.0", "73.5", "73.9", "74.3",
- "74.8", "75.2", "75.7", "76.1", "76.6", "77.0", "77.4", "77.8",
- "78.3", "78.7", "79.1", "79.5", "80.0", "80.4", "80.8", "81.2",
- "81.6", "82.0", "82.4", "82.8", "83.2", "83.6", "84.0", "84.4",
- "84.8", "85.2", "85.6", "86.0", "86.4", "86.8", "87.2", "87.6",
- "88.0", "88.3", "88.7", "89.1", "89.5", "89.9", "90.3", "90.7",
- "91.0", "91.4", "91.8", "92.2", "92.5", "92.9", "93.3", "93.6",
- "94.0", "94.2", "94.5", "94.6", "94.8", "95.0", "95.2", "95.4",
- "95.6", "95.7", "95.9", "96.1", "96.2", "96.4", "96.5", "96.7",
- "96.8", "96.9", "97.1", "97.2", "97.3", "97.5", "97.6", "97.7",
- "97.8", "98.0", "98.1", "98.2", "98.3", "98.4", "98.5", "98.6",
- "98.8", "98.9", "98.9", "99.0", "99.1", "99.2", "99.3", "99.3",
- "99.4", "99.5", "99.5", "99.6", "99.7", "99.7", "99.8", "99.9",
- "99.9", "100.0");
+ "5.0", "10.1", "15.1", "20.2", "25.2", "27.9", "29.6", "31.2",
+ "32.9", "34.5", "36.1", "37.7", "38.9", "39.9", "40.4", "40.9",
+ "41.4", "42.0", "42.5", "43.0", "43.5", "44.0", "44.5", "45.1",
+ "45.6", "46.1", "46.6", "47.1", "47.6", "48.1", "48.6", "49.1",
+ "49.6", "50.1", "50.5", "51.0", "51.5", "52.0", "52.5", "53.0",
+ "53.4", "53.9", "54.4", "54.9", "55.3", "55.8", "56.3", "56.8",
+ "57.2", "57.7", "58.2", "58.7", "59.1", "59.6", "60.1", "60.5",
+ "61.0", "61.5", "61.9", "62.4", "62.9", "63.3", "63.8", "64.2",
+ "64.7", "65.1", "65.6", "66.0", "66.5", "66.9", "67.3", "67.8",
+ "68.2", "68.7", "69.1", "69.6", "70.0", "70.4", "70.9", "71.3",
+ "71.7", "72.2", "72.6", "73.1", "73.5", "73.9", "74.4", "74.8",
+ "75.2", "75.6", "76.1", "76.5", "76.9", "77.4", "77.8", "78.2",
+ "78.6", "79.0", "79.4", "79.8", "80.2", "80.7", "81.1", "81.5",
+ "81.9", "82.2", "82.6", "83.0", "83.4", "83.8", "84.2", "84.6",
+ "85.0", "85.4", "85.7", "86.1", "86.5", "86.9", "87.3", "87.6",
+ "88.0", "88.4", "88.8", "89.1", "89.5", "89.9", "90.3", "90.6",
+ "91.0", "91.4", "91.7", "92.1", "92.5", "92.8", "93.2", "93.5",
+ "93.9", "94.2", "94.6", "94.8", "95.0", "95.2", "95.4", "95.6",
+ "95.7", "95.9", "96.1", "96.2", "96.4", "96.5", "96.7", "96.8",
+ "97.0", "97.1", "97.2", "97.4", "97.5", "97.6", "97.7", "97.9",
+ "98.0", "98.1", "98.2", "98.3", "98.4", "98.6", "98.7", "98.8",
+ "98.9", "99.0", "99.0", "99.1", "99.2", "99.3", "99.3", "99.4",
+ "99.5", "99.5", "99.6", "99.7", "99.7", "99.8", "99.9", "99.9",
+ "100.0");
/*
* brisk - room.css
*
- * Copyright (C) 2006-2007 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
div.container {
/* border:1px solid gray; */
+ position: relative;
width:100%;
margin:0px;
padding: 0px;
}
div.header {
- /* border: 1px solid yellow; */
+ /* border: 1px solid yellow; */
align: center;
text-align: center;
font-size: 12px;
div.topmenu {
/* border: 1px solid red; */
- width:90px;
+ width:94px;
margin:0;
text-align: center;
align: center;
font-size: 10px;
- padding:4px;
+ padding:2px;
}
div.proflash {
}
div.room_tit {
- /* background-color: orange; */
+ position: relative;
+ top: 6px;
align: left;
text-align: left;
margin: 0px;
- padding: 6px;
+ /* background-color: orange; */
+ /* clip: auto; */
+ /* overflow: hidden; */
+}
+
+span.room_titin {
+ position: relative;
+ left: 6px;
+ top: 6px;
+ z-index: 100;
+ background-color: white;
}
table.floaty {
table.room_tab td {
/* background-color: yellow; */
+ width: 25%;
height: 110px;
vertical-align: top;
border: 1px solid gray;
top: 26px;
width: 100%;
height: 80px;
- overflow: auto;
padding: 0px;
margin: 0px;
+ /* background-color: orange; */
+ overflow: auto;
+ clip: auto;
}
table.room_standup {
+ position: relative;
/* margin-left: 4px; */
width: 100%;
border: 1px solid gray;
table.room_standup td {
/* background-color: yellow; */
+ position: relative;
border: 0px none gray;
vertical-align: top;
+ align: left;
}
div.room_ex_standup {
align: left;
text-align: left;
padding: 0px;
-
+ overflow: hidden;
}
table.table_standup {
- /* background-color: red; */
+ /* background-color: red; */
border-spacing: 0px;
width: 100%;
text-align: right;
top: 2px;
right: 4px;
+ z-index: 10;
}
.chatt {
height: 100px;
overflow: auto;
border: 1px solid gray;
- padding: 2px;
+ /* padding: 2px; */
vertical-align: text-bottom;
}
}
.proxhr {
- /* background-color: green; */
+ position: relative;
+ top: 10px;
+ width: 100%;
align: center;
text-align: center;
- width: 100%;
- top: 28px;
+ /* background-color: green; */
+}
+
+.webstart_hilite {
+ background: #ffd780;
+ border: 1px solid #ffae00;
+ padding: 6px;
+ text-align: center;
}
.webstart {
z-index: 20;
visibility: hidden;
border: 1px solid gray;
- align: left;
text-align: left;
- /* width: 100px;
- height: 300px; */
+ width: 100px;
padding: 8px;
-
}
.webstart a:link {
line-height: 20px;
text-decoration: none;
}
+
+.topbanner {
+ position: relative;
+ align: center;
+ text-align:center;
+ background-color: #f8f8f8;
+ padding: 4px;
+ border: 1px solid #000000;
+}
+
+.topbanner a:link {
+ color: black;
+ line-height: 16px;
+ text-decoration: none;
+}
+
+.topbanner a:visited {
+ color: black;
+ line-height: 16px;
+ text-decoration: none;
+}
+
+.topbanner a:hover {
+ color: RGB(255,174,0);
+ line-height: 16px;
+ text-decoration: none;
+}
+
+.train {
+ position: absolute;
+ border: 0px solid blue;
+ visibility: hidden;
+ left: 0px;
+ top: 0px;
+ width: 0px;
+ height: 50px;
+ z-index: 10;
+ /*background-color: #ff00ff;
+ clip: auto;
+ overflow: hidden; */
+}
+
+.wagon {
+ position: absolute;
+ background-color: white;
+ border: 1px solid green;
+ cursor: pointer;
+ left: 0px;
+ top: 2px;
+ font-size: 10px;
+ font-weight: bold;
+ padding: 4px;
+ z-index: 10;
+ /* visibility: hidden; */
+}
+
+.wagon_disable {
+ position: absolute;
+ background-color: #aaaaaa;
+ border: 1px solid green;
+ cursor: default;
+ left: 0px;
+ top: 2px;
+ font-size: 10px;
+ font-weight: bold;
+ font-color: #999999;
+ padding: 4px;
+ /*z-index: -1;*/
+ /* visibility: hidden; */
+}
+
+.wagon_disable2 {
+ position: absolute;
+ cursor: default;
+ background-color: #555555;
+ border: 1px solid green;
+ left: 0px;
+ top: 2px;
+ font-size: 10px;
+ font-color: #333333;
+ padding: 4px;
+ /* z-index: -1; */
+ /* visibility: hidden; */
+}
+
+.notebox {
+ background-color: #ffffff;
+ border: 1px solid red;
+ padding: 4px;
+ position: absolute;
+ visibility: hidden;
+ /* z-index: 15px; */
+}
+
+.room_standup_orig {
+ position: absolute;
+}
+
+td.tickbut {
+ visibility: hidden;
+ width: 0px;
+ text-align: left;
+ vertical-align: top;
+ /* background-color: red; */
+ padding: 0px;
+}
+
+img.tickbut {
+ border: 0px solid black;
+ cursor: pointer;
+ margin-top:4px;
+}
+++ /dev/null
-/*
- * brisk - table.css
- *
- * Copyright (C) 2006 matteo.nastasi@milug.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details. You should have received a
- * copy of the GNU General Public License along with this program; if
- * not, write to the Free Software Foundation, Inc, 59 Temple Place -
- * Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- *
- */
-
-.chattshort {
- height: 70px;
- overflow: auto;
- border: 1px solid grey;
- vertical-align: text-bottom;
- /* font-size: 10pt;*/
-}
-
-.txtt {
- /* font-size: 10pt;*/
-}
-
-img.tableinfo {
- position: absolute;
- left: 619;
- top: 550;
- border-width: 0px;
- visibility: visible;
-}
-
-img.tablereload {
- position: absolute;
- left: 667;
- top: 550;
- border-width: 0px;
- visibility: visible;
-}
-
-img.tableout {
- position: absolute;
- left: 730;
- top: 550;
- border-width: 0px;
- visibility: visible;
-}
-
-img.card {
- position: absolute;
- border-style: solid;
- border-width: 1px;
- border-color: grey;
- visibility: hidden;
-}
-
-
-img.astacard {
- position: absolute;
- /* visibility: visible; */
- border-width: 0px;
-}
-
-img.cover {
- position: absolute;
- border-style: solid;
- border-width: 1px;
- border-color: lightgrey;
- visibility: hidden;
-}
-
-.chooseed {
- /* background-color: yellow; */
- visibility: hidden;
- position:absolute;
- width: 200px;
- height: 200px;
- top: 250px;
- left: 300px;
-}
-
-.asta {
- /* background-color: yellow; */
- visibility: hidden;
- position: absolute;
- width: 200px;
- height: 200px;
- top: 250px;
- left: 300px;
-}
-
-img.seed0 {
- position: absolute;
- left: 0px;
- top: 55px;
-}
-
-img.seed1 {
- position: absolute;
- left: 43px;
- top: 55px;
-}
-
-img.seed2 {
- position: absolute;
- left: 93px;
- top: 55px;
-}
-
-img.seed3 {
- position: absolute;
- left: 143px;
- top: 55px;
-}
-
-.area {
- display: block;
- margin-left: auto;
- margin-right: auto;
- position: relative;
- text-align: center;
- width: 800px;
- height: 600px;
-}
-
-.subarea {
- top: 0px;
-}
-
-.points {
- /* position: relative; */
-
- margin-top: 8px;
- margin-left:auto;
- margin-right:auto;
- border-style: solid;
- border-width: 0px;
- border-color: black;
- border-collapse: collapse;
-}
-
-.td_points {
- border-style: solid;
- border-width: 1px;
- border-color: black;
- border-collapse: collapse;
- display: table-cell;
- text-align: right;
- padding: 2px;
-}
-
-div.table_commands {
- display: inline;
- position: absolute;
- right: 2px;
- bottom: 15px;
-}
-
-.remark0 {
- position: absolute;
- width: 199px;
- height: 200px;
- left: 299;
- top: 249;
- border-style: solid;
- border-width: 0px;
- border-color: green;
- z-index: 0;
-}
-
-.remark1 {
- position: absolute;
- width: 199px !important;
- width: 207px;
- height: 200px !important;
- height: 208px;
- left: 296;
- top: 246;
- border-style: solid;
- border-width: 4px;
- border-color: green;
- z-index: 0;
-}
-
-.remark2 {
- position: absolute;
- width: 199px !important;
- width: 203px;
- height: 200px !important;
- height: 204px;
- left: 298;
- top: 248;
- border-style: solid;
- border-width: 2px;
- border-color: green;
- z-index: 0;
-}
-
-.punti {
- position: absolute;
- width: 68;
- height: 50;
- margin-top: 4px;
- /*
- border-style: solid;
- border-width: 1px;
- border-color: blu;
- */
- align: center;
- text-align: center;
-}
-
-.puntifield {
- /* position: absolute; */
- align: center;
- text-align: center;
-}
-
-.pubinfo {
- /* background-color: red; */
- color: grey;
- visibility: visible;
- position: absolute;
- top: 475px;
- left: 200px;
- width: 400px;
- height: 125px;
-}
-
-.public {
- /* background-color: red; */
- visibility: hidden;
- position: absolute;
- display: table;
- top: 450px;
- left: 300px;
- width: 200px;
- height: 100px;
- overflow: hidden;
- z-index: 8;
-}
-
-.pubacard {
- border-width: 0px;
- position: relative;
- display: block;
- margin-left: auto;
- margin-right: auto;
-}
-
-
-
-.pubinfo_we {
- color: grey;
- visibility: visible;
- position: absolute;
- top: 250px;
- left: 175px;
- width: 125px;
- height: 200px;
-}
-
-.public_we {
- /* background-color: red; */
- visibility: hidden;
- position: absolute;
- top: 250px;
- left: 175px;
- display: table;
- width: 125px;
- height: 200px;
- overflow: hidden;
-}
-
-.pubinfo_nw {
- /* background-color: red; */
- color: grey;
- visibility: visible;
- position: absolute;
- top: 125px;
- left: 200px;
- width: 200px;
- height: 125px;
-}
-
-.public_nw {
- /* background-color: red; */
- visibility: hidden;
- position: absolute;
- top: 125px;
- left: 200px;
- display: table;
- width: 200px;
- height: 125px;
- overflow: hidden;
-}
-
-.public_ne {
- /* background-color: red; */
- visibility: hidden;
- position: absolute;
- top: 125px;
- left: 400px;
- display: table;
- width: 200px;
- height: 125px;
- overflow: hidden;
-}
-
-.pubinfo_ne {
- /* background-color: red; */
- color: grey;
- visibility: visible;
- position: absolute;
- top: 125px;
- left: 400px;
- width: 200px;
- height: 125px;
-}
-
-
-
-.public_ea {
- /* background-color: red; */
- visibility: hidden;
- position: absolute;
- top: 250px;
- left: 500px;
- display: table;
- width: 125px;
- height: 200px;
- overflow: hidden;
-}
-
-.pubinfo_ea {
- /* background-color: red; */
- color: grey;
- visibility: visible;
- position: absolute;
- top: 250px;
- left: 500px;
- width: 125px;
- height: 200px;
-}
-
-.vert_midfloat {
- position: relative;
-#position: absolute;
- _top: 50%;
- left: 0px;
- width: 100%;
- display: table-cell;
- vertical-align: middle;
-}
-
-.vert_innfloat {
-#position: relative;
-#top: -50%;
- text-align: center;
-}
-
-.vert_innfloat_so {
- /* border-style: solid;
- border-width: 1px;
- border-color: black;
-
- background-color: white; */
-#position: relative;
-#top: -50%;
- text-align: center;
-}
-
-.pubacard_ea {
- border-width: 0px;
- position: relative;
- display: block;
- margin-left: auto;
- margin-right: auto;
-}
-
-.pubacard_ne {
- border-width: 0px;
- position: relative;
- display: block;
- margin-left: auto;
- margin-right: auto;
-}
-
-.pubacard_nw {
- border-width: 0px;
- position: relative;
- display: block;
- margin-left: auto;
- margin-right: auto;
-}
-
-.pubacard_we {
- border-width: 0px;
- position: relative;
- display: block;
- margin-left: auto;
- margin-right: auto;
-}
-
-
-/* CALLER */
-.caller {
- background-repeat: no-repeat;
- visibility: hidden;
- position: absolute;
- left: 0px;
- top: 475px;
- width: 200px;
- height: 125px;
-}
-
-.callerinfo {
- /* background-color: red; */
- /* visibility: visible; */
- position: absolute;
- /* font-size: 10pt;*/
- left: 5px;
- top: 55px;
- width: 115px;
- height: 65px;
-}
-
-img.callerimg {
- position: absolute;
- left: 133px;
- top: 10px;
-}
-
-
+++ /dev/null
-/*
- * brisk - table.js
- *
- * Copyright (C) 2006 matteo.nastasi@milug.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details. You should have received a
- * copy of the GNU General Public License along with this program; if
- * not, write to the Free Software Foundation, Inc, 59 Temple Place -
- * Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- *
- */
-
-function background_set()
-{
- $("bg").style.backgroundImage = 'url("img/brisk_table_sand'+table_pos+'.jpg")';
-}
+++ /dev/null
-<?php
-/*
- * brisk - table.php
- *
- * Copyright (C) 2006 matteo.nastasi@milug.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details. You should have received a
- * copy of the GNU General Public License along with this program; if
- * not, write to the Free Software Foundation, Inc, 59 Temple Place -
- * Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- *
- */
-?>
-<html>
-<head>
-<title>Brisk - Tavolo</title>
-<link rel="shortcut icon" href="img/brisk_ico.png">
-<script type="text/javascript" src="dnd.js"></script>
-<script type="text/javascript" src="dom-drag.js"></script>
-<script type="text/javascript" src="commons.js"></script>
-<script type="text/javascript" src="xhr.js"></script>
-<script type="text/javascript" src="preload_img.js"></script>
-<script type="text/javascript" src="table.js"></script>
-<script type="text/javascript" src="AC_OETags.js"></script>
-<link rel="stylesheet" type="text/css" href="brisk.css">
-<link rel="stylesheet" type="text/css" href="table.css">
-</head>
-<body>
-<SCRIPT type="text/javascript">
- var sess;
- var stat = "table";
- var subst = "none";
- var table_pos = "";
- var myfrom = "table_php";
- var g_withflash = false;
-
-var asta_ptr;
-var area_ptr;
-
-var gst = new globst();
-gst.st = <?php
-require_once("brisk.phh");
-
-log_load($sess, "LOAD: table.php");
-
-if (isset($laststate) == false) {
- $laststate = -1;
-}
-echo $laststate;
-?>;
-
-var g_imgct= 0;
-var g_imgtot = g_preload_img_arr.length;
-var g_exitlock = 0;
-
-window.onload = function() {
- g_withflash = DetectFlashVer(6,0,0);
- remark_off();
- table_init();
- xhr_rd = createXMLHttpRequest();
- sess = "<?php echo "$sess"; ?>";
-
- window.onunload = onunload_cb;
-
- setTimeout(xhr_rd_poll, 0, sess);
- // setTimeout(preload_images, 0, g_preload_img_arr, g_imgct);
-}
-</SCRIPT>
-<div id="bg" class="area">
-
-<div id="remark" class="remark0"></div>
-<img id="card0" src="img/00.png" class="card">
-<img id="card1" src="img/01.png" class="card">
-<img id="card2" src="img/02.png" class="card">
-<img id="card3" src="img/03.png" class="card">
-<img id="card4" src="img/04.png" class="card">
-<img id="card5" src="img/05.png" class="card">
-<img id="card6" src="img/06.png" class="card">
-<img id="card7" src="img/07.png" class="card">
-<img id="takes" src="img/cover.png" class="cover">
-<img id="card_ne0" src="img/cover.png" class="cover">
-<img id="card_ne1" src="img/cover.png" class="cover">
-<img id="card_ne2" src="img/cover.png" class="cover">
-<img id="card_ne3" src="img/cover.png" class="cover">
-<img id="card_ne4" src="img/cover.png" class="cover">
-<img id="card_ne5" src="img/cover.png" class="cover">
-<img id="card_ne6" src="img/cover.png" class="cover">
-<img id="card_ne7" src="img/cover.png" class="cover">
-<img id="takes_ne" src="img/cover.png" class="cover">
-<img id="card_nw0" src="img/cover.png" class="cover">
-<img id="card_nw1" src="img/cover.png" class="cover">
-<img id="card_nw2" src="img/cover.png" class="cover">
-<img id="card_nw3" src="img/cover.png" class="cover">
-<img id="card_nw4" src="img/cover.png" class="cover">
-<img id="card_nw5" src="img/cover.png" class="cover">
-<img id="card_nw6" src="img/cover.png" class="cover">
-<img id="card_nw7" src="img/cover.png" class="cover">
-<img id="takes_nw" src="img/cover.png" class="cover">
-<img id="card_ea0" src="img/cover_ea.png" class="cover">
-<img id="card_ea1" src="img/cover_ea.png" class="cover">
-<img id="card_ea2" src="img/cover_ea.png" class="cover">
-<img id="card_ea3" src="img/cover_ea.png" class="cover">
-<img id="card_ea4" src="img/cover_ea.png" class="cover">
-<img id="card_ea5" src="img/cover_ea.png" class="cover">
-<img id="card_ea6" src="img/cover_ea.png" class="cover">
-<img id="card_ea7" src="img/cover_ea.png" class="cover">
-<img id="takes_ea" src="img/cover_ea.png" class="cover">
-<img id="card_we0" src="img/cover_we.png" class="cover">
-<img id="card_we1" src="img/cover_we.png" class="cover">
-<img id="card_we2" src="img/cover_we.png" class="cover">
-<img id="card_we3" src="img/cover_we.png" class="cover">
-<img id="card_we4" src="img/cover_we.png" class="cover">
-<img id="card_we5" src="img/cover_we.png" class="cover">
-<img id="card_we6" src="img/cover_we.png" class="cover">
-<img id="card_we7" src="img/cover_we.png" class="cover">
-<img id="takes_we" src="img/cover_we.png" class="cover">
-<div id="asta" class="asta">
- <img id="asta0" src="img/asta0.png" class="astacard">
- <img id="asta1" src="img/asta1.png" class="astacard">
- <img id="asta2" src="img/asta2.png" class="astacard">
- <img id="asta3" src="img/asta3.png" class="astacard">
- <img id="asta4" src="img/asta4.png" class="astacard">
- <img id="asta5" src="img/asta5.png" class="astacard">
- <img id="asta6" src="img/asta6.png" class="astacard">
- <img id="asta7" src="img/asta7.png" class="astacard">
- <img id="asta8" src="img/asta8.png" class="astacard">
- <img id="asta9" src="img/asta9.png" class="astacard">
- <div id="astaptdiv" class="punti">
- <input class="puntifield" id="astapt" name="astapt" type="text" maxsize="3" size="3" value="61">
- </div>
- <img id="astaptsub" src="img/astaptsub_ro.png" class="astacard">
- <img id="astapasso" src="img/astapasso_ro.png" class="astacard">
- <img id="astalascio" src="img/astalascio_ro.png" class="astacard">
-</div>
-<div id="name" class="pubinfo"></div>
-<div id="public" class="public">
- <div class="vert_midfloat">
- <div id="pubasta" class="vert_innfloat_so">
- <img id="pubacard" src="img/astapasso_ro.png" class="pubacard">
- <div id="pubapnt"></div>
- </div>
- </div>
-</div>
-<div id="name_ea" class="pubinfo_ea"></div>
-<div id="public_ea" class="public_ea">
- <div class="vert_midfloat">
- <div id="pubasta_ea" class="vert_innfloat">
- <img id="pubacard_ea" src="img/astapasso_ro.png" class="pubacard_ea">
- <div id="pubapnt_ea"></div>
- </div>
- </div>
-</div>
-<div id="name_ne" class="pubinfo_ne"></div>
-<div id="public_ne" class="public_ne">
- <div class="vert_midfloat">
- <div id="pubasta_ne" class="vert_innfloat">
- <img id="pubacard_ne" src="img/astapasso_ro.png" class="pubacard_ne">
- <div id="pubapnt_ne"></div>
- </div>
- </div>
-</div>
-<div id="name_nw" class="pubinfo_nw"></div>
-<div id="public_nw" class="public_nw">
- <div class="vert_midfloat">
- <div id="pubasta_nw" class="vert_innfloat">
- <img id="pubacard_nw" src="img/astapasso_ro.png" class="pubacard_nw">
- <div id="pubapnt_nw"></div>
- </div>
- </div>
-</div>
-<div id="name_we" class="pubinfo_we"></div>
-<div id="public_we" class="public_we">
- <div class="vert_midfloat">
- <div id="pubasta_we" class="vert_innfloat">
- <img id="pubacard_we" src="img/astapasso_ro.png" class="pubacard_we">
- <div id="pubapnt_we"></div>
- </div>
- </div>
-</div>
-<div id="chooseed" class="chooseed">
-Hai vinto l'asta.<br> Scegli il seme:
-<img id="seed0" src="img/00.png" class="seed0">
-<img id="seed1" src="img/10.png" class="seed1">
-<img id="seed2" src="img/20.png" class="seed2">
-<img id="seed3" src="img/30.png" class="seed3">
-</div>
-<div id="caller" class="caller">
-<div id="callerinfo" class="callerinfo">Info</div>
-<img id="callerimg" src="img/noimg.png" class="callerimg">
-</div>
-<div class="table_commands">
-<input type="button" class="button" name="xinfo" value="Info." onclick="act_tableinfo();">
-<input type="button" class="button" name="xreload" value="Reload." onclick="act_reload();">
-<div style="vertical-align: top;">
-<img id="exitlock" class="button" style="visibility: hidden; border: 0px; display: inline; position: relative;" onclick="act_exitlock();"><input type="button" class="button" name="xout" value="Out." onclick="safelogout();">
-</div>
-</div>
-
-</div>
-
-
-<div class="subarea">
-<div id="txt" class="chattshort"></div>
- <table align=center style="width: 98%; margin: auto;"><tr><td style="width:1%; text-align: right;">
- <div id="myname"></div>
- </td><td>
- <input id="txt_in" type="text" style="width: 100%;" onkeypress="chatt_checksend(this,event);">
- </td></tr></table>
-
-<div id="flasou"></div>
-<hr>
-<div id="heartbit"></div>
-<hr>
-<div id="imgct"></div>
-<hr>
-<div id="sandbox"></div>
-<div id="sandbox2"></div>
-<div id="sandbox3"></div>
-<pre>
-<div id="xhrlog"></div>
-</pre>
-<div id="xhrdeltalog"></div>
-</div>
-</body>
-</html>
--- /dev/null
+/*
+ * brisk - ticker.js
+ *
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ *
+ */
+
+function train(anc) {
+ var box;
+ this.anc = anc;
+
+ box = document.createElement("div");
+ box.className = "train";
+ box.id = "train";
+ box.style.left = "0px";
+ box.style.width = "0px";
+ box.style.height = "0px";
+ box.anc = this;
+
+ addEvent(box, "mouseover", function() { this.anc.stop_move(); } );
+ addEvent(box, "mouseout", function() { this.anc.start_move(); } );
+
+ this.box = box;
+ this.anc.appendChild(box);
+
+}
+
+train.prototype = {
+ anc: null,
+ first: null,
+ box: null,
+ notebox: null,
+ width: 0,
+ deltat: 250,
+ deltas: 10,
+ xend: 0,
+ timout: null,
+ clickable: true,
+
+ show: function()
+ {
+ $('tickbut').style.visibility = "hidden";
+ $('tickbut').style.width = "0px";
+
+ this.clickable = true;
+ this.box.style.visibility = "visible";
+ },
+
+ hide: function()
+ {
+ $('tickbut').style.visibility = "visible";
+ $('tickbut').style.width = "20px";
+
+ this.clickable = false;
+ for (cur = this.first ; cur != null ; cur = cur.next) {
+ if (cur.notebox != null) {
+ cur.cb_mouseout();
+ }
+ }
+
+ },
+
+ add: function(table, title)
+ {
+ var last, wag, curx;
+ var dostart = 0;
+
+ for (cur = this.first ; cur != null ; cur = cur.next) {
+ if (cur.table == table)
+ return;
+ }
+
+ wag = new wagon(this, table, title);
+ if (this.first == null) {
+ this.first = wag;
+ dostart = 1;
+ }
+ else {
+ for (cur = this.first ; cur.next != null ; cur = cur.next);
+ cur.next = wag;
+ }
+
+ this.redraw();
+ this.xend = -this.widthbox_get();
+
+ if (dostart) {
+ this.start();
+ }
+
+ },
+
+ rem: function(table)
+ {
+ var prev = null, remo = null;
+
+ if (this.first == null) {
+ return;
+ }
+
+ if (this.first.table == table) {
+ remo = this.first;
+ }
+
+ for (cur = this.first ; cur != null ; cur = cur.next) {
+ // recalculate the width and replace wagons
+ if (cur.table == table) {
+ remo = cur;
+ break;
+ }
+ }
+
+ if (remo != null) {
+ remo.box.className = "wagon_disable";
+ removeEvent(remo.box, "mouseover", function() { this.anc.cb_mouseover(); } );
+ removeEvent(remo.box, "click", function() { this.anc.cb_click(); } );
+ setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 3000, [ this, remo ]);
+ }
+
+ this.redraw();
+ },
+
+ rem_obj: function(obj)
+ {
+ var prev = null, remo = null;
+
+ if (this.first == null) {
+ return;
+ }
+
+
+ if (this.first == obj) {
+ remo = this.first;
+ this.first = this.first.next;
+ }
+
+ for (cur = this.first ; cur != null ; cur = cur.next) {
+ // recalculate the width and replace wagons
+ if (cur == obj) {
+ remo = cur;
+
+ if (prev != null) {
+ prev.next = cur.next;
+ }
+ break;
+ }
+ prev = cur;
+ }
+
+ this.redraw();
+
+ if (this.first == null) {
+ clearTimeout(this.timout);
+ this.timout = null;
+ }
+ },
+
+ stop_move: function()
+ {
+ this.deltas = 0;
+ },
+
+ start_move: function()
+ {
+ this.deltas = 10;
+ },
+
+ shut_wagon: function(args)
+ {
+ var curw;
+
+ obj = arguments[0][0];
+ wag = arguments[0][1];
+
+ if (wag.shut_step == 0) {
+ wag.box.className = "wagon_disable";
+ wag.shut_step = 1;
+ }
+ else {
+ if (wag.shut_step == 1) {
+ wag.w = wag.widthbox_get();
+ wag.box.className = "wagon_disable2";
+ wag.box.style.padding = "0px";
+ wag.box.style.width = (wag.w-2)+"px";
+ wag.box.style.height = (wag.h-2)+"px"; // 2 for border width
+ wag.table = "";
+ wag.box.innerHTML = "";
+ wag.shut_step = 2;
+ }
+ curw = wag.widthbox_get() - 10;
+ wag.w = curw + 2; // 2 for border pixels
+ if (curw <= 0) {
+ wag.cb_mouseout();
+
+ obj.box.removeChild(wag.box);
+ obj.rem_obj(wag);
+
+ return;
+ }
+ else {
+ wag.box.style.width = curw+"px";
+ wag.box.style.padding = "0px";
+ }
+ }
+ this.redraw();
+ setTimeout(function(){ arguments[0][0].shut_wagon(arguments[0]); }, 250, [ obj, wag ]);
+ },
+
+ redraw: function()
+ {
+ var maxw = 0, maxh = 0, curh;
+
+ for (cur = this.first ; cur != null ; cur = cur.next) {
+ // recalculate the width and replace wagons
+ maxw += 2 + (maxw == 0 ? 0 : 2) + cur.width_get();
+ curh = cur.height_get();
+ maxh = (maxh < curh ? curh : maxh);
+ }
+ maxh += 2;
+ curx = 0;
+
+ for (cur = this.first ; cur != null ; cur = cur.next) {
+ // recalculate the width and replace wagons
+ cur.left_set(curx);
+ curx += cur.width_get() + 4;
+ }
+
+ this.box.style.width = maxw+"px";
+ this.box.style.height = maxh+"px";
+ },
+
+ resetx: function()
+ {
+ this.deltas = 10;
+ this.clickable = true;
+
+ this.box.style.left = this.anc.offsetWidth+"px";
+ },
+
+
+ start: function()
+ {
+ this.resetx();
+ if (this.timout == null) {
+ this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
+ }
+ },
+
+ animate: function()
+ {
+ this.box.style.left = (parseInt(this.box.style.left) - this.deltas)+"px";
+
+// if (parseInt(this.box.style.left) >= this.xend) {
+// this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
+// }
+// else {
+// this.box.style.left = this.anc.offsetWidth+"px";
+// this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
+// }
+ if (parseInt(this.box.style.left) < this.xend) {
+ this.box.style.left = this.anc.offsetWidth+"px";
+ }
+ this.timout = setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
+ },
+
+ widthbox_get: function()
+ {
+ return (this.box.offsetWidth);
+ },
+
+ heightbox_get: function()
+ {
+ return (this.box.offsetHeight);
+ },
+
+ widthanc_get: function()
+ {
+ return (this.anc.offsetWidth);
+ },
+
+ heightanc_get: function()
+ {
+ return (this.anc.offsetHeight);
+ }
+} // train class end
+
+
+
+function wagon(anc, table, title) {
+ var box;
+ var othis = this;
+ this.anc = anc;
+
+ box = document.createElement("div");
+ box.className = "wagon";
+ box.anc = this;
+ this.table = table;
+ this.title = title;
+ box.innerHTML = "Tavolo "+table;
+ this.box = box;
+ this.box.setAttribute("title", unescapeHTML(title));
+
+ addEvent(this.box, "mouseover", function() { this.anc.cb_mouseover(); } );
+ addEvent(this.box, "mouseout", function() { this.anc.cb_mouseout(); } );
+ addEvent(this.box, "click", function() { this.anc.cb_click(); } );
+
+ this.anc.box.appendChild(box);
+
+ this.w = this.widthbox_get();
+ this.h = this.heightbox_get();
+}
+
+wagon.prototype = {
+ prev: null,
+ next: null,
+ table: 55,
+ anc: null,
+ w: 0,
+ h: 0,
+ x: 0,
+ box: null,
+ shut_step: 0,
+
+ width_get: function()
+ {
+ return (this.w);
+ },
+
+ height_get: function()
+ {
+ return (this.h);
+ },
+
+ widthbox_get: function()
+ {
+ return (this.box.offsetWidth);
+ },
+
+ heightbox_get: function()
+ {
+ return (this.box.offsetHeight);
+ },
+
+ widthnotebox_get: function()
+ {
+ return (this.notebox.offsetWidth);
+ },
+
+ heightnotebox_get: function()
+ {
+ return (this.notebox.offsetHeight);
+ },
+
+ left_set: function(x)
+ {
+ this.box.style.left = x+"px";
+ },
+
+ cb_click: function()
+ {
+ if (this.anc.clickable == true) {
+ act_sitdown(this.table);
+ }
+ },
+
+ cb_mouseover: function()
+ {
+ var notebox, deltax;
+
+ notebox = document.createElement("div");
+ notebox.className = "notebox";
+ notebox.id = "wagon_note";
+
+ notebox.innerHTML = $("table"+this.table).innerHTML;
+ $("room_standup_orig").appendChild(notebox);
+
+ deltax = 0;
+ deltax = parseInt(getStyle(this.anc.box, "left", "left")) +
+ parseInt(getStyle(this.box, "left", "left")) +
+ ((this.box.offsetWidth - notebox.offsetWidth) / 2);
+
+ notebox.style.left = deltax + "px";
+ notebox.style.top = (-10 -notebox.offsetHeight)+"px";
+ notebox.style.visibility = "visible";
+ notebox.anc = this;
+
+ this.notebox = notebox;
+
+ return;
+ },
+
+ cb_mouseout: function()
+ {
+ if (this.notebox != null) {
+ $("room_standup_orig").removeChild(this.notebox);
+ this.notebox = null;
+ }
+ }
+
+} // wagon class end
+++ /dev/null
-<?php
-/*
- * brisk - unrecerror.php
- *
- * Copyright (C) 2006 matteo.nastasi@milug.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details. You should have received a
- * copy of the GNU General Public License along with this program; if
- * not, write to the Free Software Foundation, Inc, 59 Temple Place -
- * Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- *
- */
-
-?>
-<html>
-<body>
-<h2> UNRECOVERABLE ERROR </h2>
-non doveva capitare.
-</body>
-</html>
\ No newline at end of file
/*
* brisk - xhr.js
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2008 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
xhr_rd_newctx = "";
/* NOTE document.uniqueID exists only under IE */
- // alert("di qui3");
+ // if (g_is_spawn == 1)
+ // alert("di qui3: "+(g_is_spawn == 1 ? "&table_idx="+g_table_idx : ""));
xhr_rd.open('GET', 'index_rd.php?sess='+sess+"&stat="+stat+"&subst="+subst+"&step="+step+"&onlyone="+(document.uniqueID ? "TRUE" : "FALSE")+"&myfrom="+myfrom, true);
// try {
xhr_rd.onreadystatechange = function() { xhr_rd_cb(xhr_rd); }