From: Matteo Nastasi (mop) Date: Fri, 1 Mar 2013 18:11:49 +0000 (+0100) Subject: supp_comp partial support (db/prefs management, usage is missing) X-Git-Tag: v4.7.1~8 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=b65dddf6cb8fdc5a98719ed170ca38c2059b362c;p=brisk.git supp_comp partial support (db/prefs management, usage is missing) --- diff --git a/TODO.txt b/TODO.txt index da73ad3..abc81bf 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,6 +3,12 @@ FEATURES | ----------+ + + - improved S + . db update (add components, maybe single string) + . filter in index.php + . filter in index_wr.php + - prefs API: . prefs_assign(content): assign json content as output var . prefs_apply(prefs_new): apply new content to g_prefs and system diff --git a/sql/sql.d/053-user-enh.sql b/sql/sql.d/053-user-enh.sql new file mode 100644 index 0000000..6969d96 --- /dev/null +++ b/sql/sql.d/053-user-enh.sql @@ -0,0 +1,2 @@ +ALTER TABLE #PFX#users ADD COLUMN last_dona timestamp DEFAULT to_timestamp(0) -- last donate +ALTER TABLE #PFX#users ADD COLUMN supp_comp text DEFAULT 'ff0000ffff00' -- fg/bg supporter color \ No newline at end of file diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 803d28b..4c9c26e 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -698,6 +698,7 @@ class Delay_Manager class Client_prefs { var $listen; + var $supp_comp; function Client_prefs() { @@ -725,6 +726,7 @@ class Client_prefs { { fprintf(STDERR, "QQ %s: %x\n", __FUNCTION__, $user->flags); $this->listen = ($user->flags & USER_FLAG_MAP_AUTH) >> 2; + $this->supp_comp = $user->rec->supp_comp; fprintf(STDERR, "QQ %s: LISTEN: %d\n", __FUNCTION__, $this->listen); } @@ -738,7 +740,8 @@ class Client_prefs { else { $json = $json_s; } - $this->listen = $json->listen; + $this->listen = $json->listen; + $this->supp_comp = $json->supp_comp; return TRUE; } @@ -751,6 +754,7 @@ class Client_prefs { $user->flags_set(($this->listen << 2), USER_FLAG_MAP_AUTH); fprintf(STDERR, "QQ %s::%s %x\n", __CLASS__, __FUNCTION__, $user->flags); + $user->rec->supp_comp = $this->supp_comp; if ($is_save) $user->store_set(); } @@ -1875,6 +1879,8 @@ class Room $this->user[$idx]->bantime = 0; $this->user[$idx]->ip = $ip; + $this->user[$idx]->rec = $authenticate; + fprintf(STDERR, "MOP: [%s]\n", $authenticate->supp_comp); $this->user[$idx]->flags = $user_type; $this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00); $this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00); diff --git a/web/Obj/dbase_base.phh b/web/Obj/dbase_base.phh index 345b06f..3cb94d8 100644 --- a/web/Obj/dbase_base.phh +++ b/web/Obj/dbase_base.phh @@ -29,21 +29,25 @@ class LoginDBItem { var $pass; var $email; var $type; + var $last_dona; + var $supp_comp; - function LoginDBItem($code, $login, $pass, $email, $type) + function LoginDBItem($code, $login, $pass, $email, $type, $last_dona, $supp_comp) { - $this->code = $code; - $this->login = $login; - $this->pass = $pass; - $this->email = $email; - fprintf(STDERR, "QQ: %s: %x\n", __FUNCTION__, $type); - $this->type = $type; + $this->code = $code; + $this->login = $login; + $this->pass = $pass; + $this->email = $email; + $this->type = $type; + $this->last_dona = $last_dona; + $this->supp_comp = $supp_comp; } static function LoginDBItemFromRecord($rec) { $ret = new LoginDBItem($rec->code, $rec->login, $rec->pass, - $rec->email, $rec->type); + $rec->email, $rec->type, $rec->last_dona, + $rec->supp_comp); return ($ret); } @@ -70,10 +74,19 @@ class LoginDBItem { function type_get() { - fprintf(STDERR, "TYPE GET: %d\n", $this->type); return $this->type; } + function last_dona_get() + { + return $this->last_dona; + } + + function supp_comp_get() + { + return $this->supp_comp; + } + } ?> \ No newline at end of file diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index 3c72851..20f4725 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -173,11 +173,12 @@ class BriskDB return TRUE; } - function user_update_flags($code, $flags) + function user_prefs_update($code, $flags, $supp_comp) { GLOBAL $G_dbpfx; - $user_sql = sprintf("UPDATE %susers SET (type) = (%d) WHERE code = %d;", $G_dbpfx, $flags, $code); + $user_sql = sprintf("UPDATE %susers SET (type, supp_comp) = (%d, '%s') WHERE code = %d;", + $G_dbpfx, $flags, $supp_comp, $code); fprintf(STDERR, "REQUEST [%s]\n", $user_sql); if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) { return FALSE; diff --git a/web/Obj/user.phh b/web/Obj/user.phh index f31d78b..416dbb4 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -121,6 +121,7 @@ class User { var $table_pos; // idx on the table var $table_token;// token that identify a game on a table var $flags; // Bitfield with: AUTHENTICATE: 0x02 + var $rec; // field with user db record or FALSE var $the_end; // Flag to change the end of the session var $chat_lst; // Last chat line @@ -173,7 +174,8 @@ class User { $thiz->exitislock = TRUE; $thiz->flags = 0x00; - + $thiz->rec = FALSE; + $thiz->chattime = array_fill(0, CHAT_N, 0); $thiz->chat_cur = 0; $thiz->chat_lst = ""; @@ -218,6 +220,7 @@ class User { $this->exitislock = $from->exitislock; $this->flags = $from->flags; + $this->rec = $from->rec; $this->chattime = array(); for ($i = 0 ; $i < CHAT_N ; $i++) @@ -282,6 +285,7 @@ class User { $thiz->the_end = $from->the_end; $thiz->flags = $from->flags; + $thiz->rec = $from->rec; $thiz->chattime = array_fill(0, CHAT_N, 0); $thiz->chat_cur = 0; @@ -310,7 +314,8 @@ class User { if (($bdb = BriskDB::create()) == FALSE) { return FALSE; } - return ($bdb->user_update_flags($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)))); + return ($bdb->user_prefs_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)), + $this->rec->supp_comp)); } function rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from) diff --git a/web/commons.js b/web/commons.js index f522ad5..5968260 100644 --- a/web/commons.js +++ b/web/commons.js @@ -49,6 +49,18 @@ var mlang_commons = { 'imgload_a' : { 'it' : 'Immagine caricate ', function $(id) { return document.getElementById(id); } +function dec2hex(d, padding) +{ + var hex = Number(d).toString(16); + padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding; + + while (hex.length < padding) { + hex = "0" + hex; + } + + return hex; +} + function getStyle(x,IEstyleProp, MozStyleProp) { if (x.currentStyle) { diff --git a/web/index.php b/web/index.php index 0b16ecd..a5e1ebc 100644 --- a/web/index.php +++ b/web/index.php @@ -848,6 +848,7 @@ supported by:
+ @@ -882,7 +883,7 @@ supported by:
// alert(window.onbeforeunload); g_brow = get_browser_agent(); - g_prefs = new client_prefs(); + g_prefs = new client_prefs(null); spo_slide = new sideslide($('spon_caro'), 80, 20); sup_slide = new sideslide($('supp_caro'), 80, 20); @@ -988,6 +989,7 @@ echo "$body"; ?> + @@ -1025,7 +1027,7 @@ echo "$body"; ?> window.onload = function() { g_brow = get_browser_agent(); - g_prefs = new client_prefs(); + g_prefs = new client_prefs(null); spo_slide = new sideslide($('spon_caro'), 80, 20); sup_slide = new sideslide($('supp_caro'), 80, 20); @@ -1204,26 +1206,68 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi +
- - -
+
+ +
+ + + + + + + + + + + + +
+xx +
+ xx + xx + xx
+ xx + xx + xx
+ +
+
diff --git a/web/prefs.js b/web/prefs.js new file mode 100644 index 0000000..4fe20b8 --- /dev/null +++ b/web/prefs.js @@ -0,0 +1,211 @@ +var l_list_all = 0x00; +var l_list_auth = 0x01; +var l_list_isol = 0x02; + +function client_prefs(old) +{ + if (old != null) { + this.listen = old.listen; + this.supp_comp = old.supp_comp; + } +} + +client_prefs.prototype = { + listen: -1, + supp_comp: 'ff00ffff00' +} + +function prefs_assign(content) +{ + var prefs_new; + var s; + + s = "prefs_new = " + content; + eval(s); + + return (prefs_new); +} + +var prefs_list_idx = new Array( 0x00, 0x01, 0x02 ); +var prefs_list_id = new Array( "all", "auth", "isol" ); + +function prefs_apply(prefs_new, is_update, is_volat) +{ + var i; + var relo = false; + + if (typeof(g_prefs) == 'undefined') + return false; + /* listen management */ + if (g_prefs.listen != prefs_new.listen || is_update) { + for (i = 0 ; i < prefs_list_idx.length ; i++) { + set_checked_value($('ra_listen_'+prefs_list_id[i]), prefs_new.listen); + if (prefs_new.listen == prefs_list_idx[i]) { + if (!is_volat) + $('list_'+prefs_list_id[i]).style.color = 'red'; + $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang]; + } + else { + if (!is_volat) + $('list_'+prefs_list_id[i]).style.color = 'black'; + } + } + + relo = true; + } + + // supporter component management + if (g_prefs.supp_comp != prefs_new.supp_comp || is_update) { + $('s_img').src = 'suprend.php?comp='+prefs_new.supp_comp; + } + + if (relo || !is_update) { + for (i = g_tables_auth_n ; i < g_tables_n ; i++) { + if (i % 4 == 0) { + $('tr_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : ''); + } + + $('td_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : ''); + } + if (prefs_new.listen == l_list_isol) { + tra.hide_noauth(); + } + else { + tra.show_noauth(); + } + + if (false) { + // ricalculation of standup area + if (standup_data_old != null) { + standup_data = standup_data_old; + standup_data_old = null; + j_stand_cont(standup_data); + } + } + } + + g_prefs.listen = prefs_new.listen; + g_prefs.supp_comp = prefs_new.supp_comp; +} + +function prefs_load(content, is_update, is_volat) +{ + var prefs_new; + + // console.log('prefs_load('+content+')'); + + if ((prefs_new = prefs_assign(content)) == null) + return false; + + return prefs_apply(prefs_new, is_update, is_volat); +} + +function prefs_save() +{ + var ret; + + if (typeof(g_prefs) == 'undefined') + return false; + + ret = server_request('mesg', 'prefs','__POST__', 'prefs', JSON.stringify(g_prefs)); + + if (ret == 1) + $('preferences').style.visibility = 'hidden'; +} + +function prefs_update(field) +{ + var i; + var prefs_new; + var relo = false; + + // console.log("prefs_update("+field+")"); + + if (typeof(g_prefs) == 'undefined') + return false; + + prefs_new = new client_prefs(g_prefs); + + if (field == 'listen') { + /* listen management */ + for (i = 0 ; i < prefs_list_idx.length ; i++) { + prefs_new.listen = get_checked_value($('ra_listen_'+prefs_list_id[i])); + if (prefs_new.listen != '') + break; + } + } + else if (field == 'supp') { + prefs_new.supp_comp = "" + dec2hex($('s_fg_r').value, 2) + dec2hex($('s_fg_g').value, 2) + dec2hex($('s_fg_b').value, 2) + dec2hex($('s_bg_r').value, 2) + dec2hex($('s_bg_g').value, 2) + dec2hex($('s_bg_b').value, 2); + } + + /* from form to struct */ + prefs_apply(prefs_new, true, true); +} + +function list_set(what, is_update, info) +{ + var i; + var relo = false; + var old_st = readCookie("CO_list"); + + if (what == 'auth') { + $('list_auth').style.color = 'red'; + $('list_isol').style.color = 'black'; + $('list_all').style.color = 'black'; + if (old_st == 'isolation') + relo = true; + g_listen = l_list_auth; + } + else if (what == 'isolation') { + $('list_auth').style.color = 'black'; + $('list_isol').style.color = 'red'; + $('list_all').style.color = 'black'; + if (old_st != 'isolation') + relo = true; + g_listen = l_list_isol; + } + else { + $('list_auth').style.color = 'black'; + $('list_isol').style.color = 'black'; + $('list_all').style.color = 'red'; + if (old_st == 'isolation') + relo = true; + g_listen = l_list_all; + } + + set_checked_value($('ra_listen_auth'), what); + set_checked_value($('ra_listen_isol'), what); + set_checked_value($('ra_listen_all'), what); + + $('list_info').innerHTML = info; + if (is_update) { + createCookie("CO_list", what, 24*365, cookiepath); + } + + + if (relo || !is_update) { + for (i = g_tables_auth_n ; i < g_tables_n ; i++) { + + if (i % 4 == 0) { + $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : ''); + } + + $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : ''); + } + if (what == 'isolation') { + tra.hide_noauth(); + } + else { + tra.show_noauth(); + } + + if (false) { + // ricalculation of standup area + if (standup_data_old != null) { + standup_data = standup_data_old; + standup_data_old = null; + j_stand_cont(standup_data); + } + } + } +} diff --git a/web/room.js b/web/room.js index 2572555..82e6fcc 100644 --- a/web/room.js +++ b/web/room.js @@ -29,18 +29,6 @@ */ -var l_list_all = 0x00; -var l_list_auth = 0x01; -var l_list_isol = 0x02; - -function client_prefs() -{ -} - -client_prefs.prototype = { - listen: -1 -} - function state_add(flags) { var content = "", supercont = ""; @@ -704,192 +692,6 @@ function j_pollbox(form) return (false); } -function prefs_assign(content) -{ - var prefs_new; - var s; - - s = "prefs_new = " + content; - eval(s); - - return (prefs_new); -} - -var prefs_list_idx = new Array( 0x00, 0x01, 0x02 ); -var prefs_list_id = new Array( "all", "auth", "isol" ); - -function prefs_apply(prefs_new, is_update, is_volat) -{ - var i; - var relo = false; - - if (typeof(g_prefs) == 'undefined') - return false; - /* listen management */ - if (g_prefs.listen != prefs_new.listen || is_update) { - for (i = 0 ; i < prefs_list_idx.length ; i++) { - set_checked_value($('ra_listen_'+prefs_list_id[i]), prefs_new.listen); - if (prefs_new.listen == prefs_list_idx[i]) { - if (!is_volat) - $('list_'+prefs_list_id[i]).style.color = 'red'; - $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang]; - } - else { - if (!is_volat) - $('list_'+prefs_list_id[i]).style.color = 'black'; - } - } - - relo = true; - } - - - // TO BE ANALYZED !!! - // if (is_update) { - // createCookie("CO_list", what, 24*365, cookiepath); - // } - - - if (relo || !is_update) { - for (i = g_tables_auth_n ; i < g_tables_n ; i++) { - if (i % 4 == 0) { - $('tr_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : ''); - } - - $('td_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : ''); - } - if (prefs_new.listen == l_list_isol) { - tra.hide_noauth(); - } - else { - tra.show_noauth(); - } - - if (false) { - // ricalculation of standup area - if (standup_data_old != null) { - standup_data = standup_data_old; - standup_data_old = null; - j_stand_cont(standup_data); - } - } - } - - g_prefs.listen = prefs_new.listen; -} - -function prefs_load(content, is_update, is_volat) -{ - var prefs_new; - - if ((prefs_new = prefs_assign(content)) == null) - return false; - - return prefs_apply(prefs_new, is_update, is_volat); -} - -function prefs_save() -{ - var ret; - - if (typeof(g_prefs) == 'undefined') - return false; - - ret = server_request('mesg', 'prefs','__POST__', 'prefs', JSON.stringify(g_prefs)); - - if (ret == 1) - $('preferences').style.visibility = 'hidden'; -} - -function prefs_update() -{ - var i; - var prefs_new; - var relo = false; - - if (typeof(g_prefs) == 'undefined') - return false; - - prefs_new = new client_prefs(); - - /* listen management */ - for (i = 0 ; i < prefs_list_idx.length ; i++) { - prefs_new.listen = get_checked_value($('ra_listen_'+prefs_list_id[i])); - if (prefs_new.listen != '') - break; - } - - /* from form to struct */ - prefs_apply(prefs_new, true, true); -} - -function list_set(what, is_update, info) -{ - var i; - var relo = false; - var old_st = readCookie("CO_list"); - - if (what == 'auth') { - $('list_auth').style.color = 'red'; - $('list_isol').style.color = 'black'; - $('list_all').style.color = 'black'; - if (old_st == 'isolation') - relo = true; - g_listen = l_list_auth; - } - else if (what == 'isolation') { - $('list_auth').style.color = 'black'; - $('list_isol').style.color = 'red'; - $('list_all').style.color = 'black'; - if (old_st != 'isolation') - relo = true; - g_listen = l_list_isol; - } - else { - $('list_auth').style.color = 'black'; - $('list_isol').style.color = 'black'; - $('list_all').style.color = 'red'; - if (old_st == 'isolation') - relo = true; - g_listen = l_list_all; - } - - set_checked_value($('ra_listen_auth'), what); - set_checked_value($('ra_listen_isol'), what); - set_checked_value($('ra_listen_all'), what); - - $('list_info').innerHTML = info; - if (is_update) { - createCookie("CO_list", what, 24*365, cookiepath); - } - - - if (relo || !is_update) { - for (i = g_tables_auth_n ; i < g_tables_n ; i++) { - - if (i % 4 == 0) { - $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : ''); - } - - $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : ''); - } - if (what == 'isolation') { - tra.hide_noauth(); - } - else { - tra.show_noauth(); - } - - if (false) { - // ricalculation of standup area - if (standup_data_old != null) { - standup_data = standup_data_old; - standup_data_old = null; - j_stand_cont(standup_data); - } - } - } -} function sideslide(domobj, height, step) { diff --git a/web/suprend.php b/web/suprend.php new file mode 100644 index 0000000..910ff8e --- /dev/null +++ b/web/suprend.php @@ -0,0 +1,32 @@ += '0' && $comps[$i] <= '9') || + ($comps[$i] >= 'a' && $comps[$i] <= 'f')) { + if (($i % 2) == 1) { + $c[$idx] = hexdec(substr($comps, $i-1, 2)); + $idx++; + } + continue; + } + exit; +} + +header ('Content-type: image/png'); +$img_r = @imagecreatefrompng("img/sup_msk_r.png"); +$img_y = @imagecreatefrompng("img/sup_msk_y.png"); + +$ret = imagefilter($img_r, IMG_FILTER_COLORIZE, $c[0], $c[1], $c[2], 0); +$ret = imagefilter($img_y, IMG_FILTER_COLORIZE, $c[3], $c[4], $c[5], 0); + +imagecopy($img_r, $img_y, 0,0, 0,0, 21, 16); + +imagesavealpha($img_r, TRUE); + +imagepng($img_r); +?>