From: Matteo Nastasi (mop) Date: Mon, 4 Mar 2013 06:35:46 +0000 (+0100) Subject: customizable support icon finalized X-Git-Tag: v4.7.1~7 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=507a79a6e6c512a2b0ac0af6e067f5a8845b7d9c;p=brisk.git customizable support icon finalized --- diff --git a/sql/sql.d/053-user-enh.sql b/sql/sql.d/053-user-enh.sql index 6969d96..e5c6b44 100644 --- a/sql/sql.d/053-user-enh.sql +++ b/sql/sql.d/053-user-enh.sql @@ -1,2 +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 +ALTER TABLE #PFX#users ADD COLUMN last_dona integer DEFAULT 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 4c9c26e..53c46a7 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -716,6 +716,7 @@ class Client_prefs { { $thiz = new Client_prefs(); if ($thiz->json_load($json) == FALSE) { + unset($thiz); return (FALSE); } @@ -733,17 +734,36 @@ class Client_prefs { function json_load($json_s) { - if (gettype($json_s) == "string") { - if (($json = json_decode($json_s)) == FALSE) - return FALSE; - } - else { - $json = $json_s; - } - $this->listen = $json->listen; - $this->supp_comp = $json->supp_comp; + $ret = FALSE; + + do { + if (gettype($json_s) == "string") { + if (($json = json_decode($json_s)) == FALSE) + break; + } + else { + $json = $json_s; + } + if ($this->listen < 0 || $this->listen > 2) + break; + $this->listen = $json->listen; + + if (mb_strlen($json->supp_comp, "ASCII") != 12) + break; - return TRUE; + for ($i = 0, $idx = 0 ; $i < 12 ; $i++) { + if (($json->supp_comp[$i] >= '0' && $json->supp_comp[$i] <= '9') || + ($json->supp_comp[$i] >= 'a' && $json->supp_comp[$i] <= 'f')) + continue; + break; + } + if ($i < 12) + break; + $this->supp_comp = $json->supp_comp; + $ret = TRUE; + } while (FALSE); + + return ($ret); } function store($user, $is_save) @@ -754,7 +774,9 @@ 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 ($user->rec != FALSE && $user->rec->last_dona > 1356994800) { + $user->rec->supp_comp = $this->supp_comp; + } if ($is_save) $user->store_set(); } @@ -2196,18 +2218,28 @@ class Room $content = ' j_stand_cont( [ '; + $user_cur_id = $user->idx_get(); for ($i = 0 , $ct = 0 ; $i < MAX_PLAYERS ; $i++) { if ($this->user[$i]->sess == "" || $this->user[$i]->stat != "room" || $this->user[$i]->name == "") continue; $flags = $this->user[$i]->flags; - + + // sql record exists AND last donate > 2013-01-01 + if ($this->user[$i]->rec != FALSE && $this->user[$i]->rec->last_dona > 1356994800) { + $supp_comp_s = sprintf(', "%s"', $this->user[$i]->rec->supp_comp); + } + else { + $supp_comp_s = ''; + } + if ($this->user[$i]->subst == "standup") { - if ($user->idx_get() == $i) { + if ($user_cur_id == $i) { $flags |= 1; } - $content .= sprintf('%s[ %d, "%s" ]',($ct > 0 ? ', ' : ''), $flags, xcape($this->user[$i]->name)); + $content .= sprintf('%s[ %d, "%s"%s ]',($ct > 0 ? ', ' : ''), $flags, + xcape($this->user[$i]->name), $supp_comp_s); $ct++; } } @@ -2231,18 +2263,24 @@ class Room if ($user->stat != 'room') return; + $user_cur_id = $user->idx_get(); $content = "[ "; for ($i = 0 ; $i < $table->player_n ; $i++) { $user_cur = $this->user[$table->player[$i]]; $flags = $user_cur->flags; - if ($user->idx_get() == $table->player[$i]) + if ($user_cur_id == $table->player[$i]) $flags |= 1; log_main($user_cur->name. sprintf(" IN TABLE [%d]", $table_idx)); - - $content .= sprintf('%s[ %d, "%s" ]',($i == 0 ? '' : ', '), $flags, xcape($user_cur->name)); + if ($user_cur->rec != FALSE && $user_cur->rec->last_dona > 1356994800) + $supp_comp_s = sprintf(', "%s"', $user_cur->rec->supp_comp); + else + $supp_comp_s = ''; + + $content .= sprintf('%s[ %d, "%s"%s ]',($i == 0 ? '' : ', '), $flags, + xcape($user_cur->name), $supp_comp_s); } $content .= ' ]'; diff --git a/web/commons.js b/web/commons.js index 5968260..4cf95dc 100644 --- a/web/commons.js +++ b/web/commons.js @@ -847,7 +847,7 @@ function user_dec_and_state(el) var val_el; content = user_decorator(el); - content += state_add(el[0]); + content += state_add(el[0],(typeof(el[2]) != 'undefined' ? el[2] : null)); return (content); } diff --git a/web/index.php b/web/index.php index a5e1ebc..fc9442b 100644 --- a/web/index.php +++ b/web/index.php @@ -118,7 +118,21 @@ $mlang_room = array( 'userpasserr' => array('it' => 'Utente e/o password errati 'listaut_desc' => array('it' => 'leggi soltanto i messaggi degli utenti con password', 'en' => 'listen messages only from authenticated users'), 'listisol_desc'=> array('it' => 'visualizza Brisk come se fosse solo per utenti con password', - 'en' => 'show Brisk like an authenticated user only site'), + 'en' => 'show Brisk like an authenticated user only site'), + 'suppcomp_tit' => array('it' => 'personalizza la tua S', + 'en' => 'customize your S'), + 'suppcomp_r' => array('it' => 'rosso', + 'en' => 'red'), + 'suppcomp_g' => array('it' => 'verde', + 'en' => 'green'), + 'suppcomp_b' => array('it' => 'blu', + 'en' => 'blue'), + 'suppcomp_fg' => array('it' => 'colore', + 'en' => 'color'), + 'suppcomp_bg' => array('it' => 'sfondo', + 'en' => 'background'), + 'suppcomp_range' => array('it' => '(0-255)', + 'en' => '(0-255)'), 'tit_splash' => array('it' => 'splash', 'en' => 'splash'), 'splash_desc' => array('it' => 'attiva la finestra di splash', @@ -1228,48 +1242,68 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi +rec != FALSE && $user->rec->last_dona > 1356994800) { +?>
-
-xx + - + title="''"> + + title="''"> + + title="''"> + + + title="''"> + + title="''"> + + title="''"> + -
+
+ + - xx - xx - xx
+ + - xx - xx - xx
+
- - + + + + + + + + +


diff --git a/web/index_wr.php b/web/index_wr.php index 7cb9c35..347bf35 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -208,7 +208,9 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie) return FALSE; } - $prefs = Client_prefs::from_json($post['prefs']); + if (($prefs = Client_prefs::from_json($post['prefs'])) == FALSE) { + $prefs = Client_prefs::from_user($user); + } fprintf(STDERR, "\n\n PREFS [%s]\n\n", print_r($prefs, TRUE)); $prefs->store($user, TRUE); @@ -217,6 +219,16 @@ function index_wr_main(&$room, $remote_addr_full, $get, $post, $cookie) $user->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs), 'false'); $user->step_inc(); + + if ($user->stat == 'room' && $user->subst == 'standup') { + $room->standup_update($user); + } + else if ($user->stat == 'room' && $user->subst == 'sitdown') { + log_main("chatt_send pre table update"); + $room->table_update($user); + log_main("chatt_send post table update"); + } + echo "1"; return TRUE; } diff --git a/web/prefs.js b/web/prefs.js index 4fe20b8..5e658b4 100644 --- a/web/prefs.js +++ b/web/prefs.js @@ -1,6 +1,10 @@ -var l_list_all = 0x00; +var l_list_all = 0x00; var l_list_auth = 0x01; var l_list_isol = 0x02; +var prefs_list_idx = new Array( 0x00, 0x01, 0x02 ); +var prefs_list_id = new Array( "all", "auth", "isol" ); +var comps_name = new Array('s_fg_r', 's_fg_g', 's_fg_b', 's_bg_r', 's_bg_g', 's_bg_b'); + function client_prefs(old) { @@ -26,9 +30,6 @@ function prefs_assign(content) 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; @@ -56,6 +57,10 @@ function prefs_apply(prefs_new, is_update, is_volat) // supporter component management if (g_prefs.supp_comp != prefs_new.supp_comp || is_update) { + + for (i = 0 ; i < 6 ; i++) { + $(comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2,2), 16); + } $('s_img').src = 'suprend.php?comp='+prefs_new.supp_comp; } @@ -118,7 +123,6 @@ function prefs_update(field) var i; var prefs_new; var relo = false; - // console.log("prefs_update("+field+")"); if (typeof(g_prefs) == 'undefined') @@ -135,7 +139,25 @@ function prefs_update(field) } } 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); + for (i = 0 ; i < 6 ; i++) { + if (parseInt($(comps_name[i]).value) < 0 || parseInt($(comps_name[i]).value) > 255 || + isNaN(parseInt($(comps_name[i]).value))) { + break; + } + } + + if (i == 6) { + prefs_new.supp_comp = ""; + for (i = 0 ; i < 6 ; i++) { + prefs_new.supp_comp += dec2hex(parseInt($(comps_name[i]).value), 2); + } + } + + // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]"); + + for (i = 0 ; i < 6 ; i++) { + $(comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16); + } } /* from form to struct */ diff --git a/web/room.js b/web/room.js index 82e6fcc..f4bb465 100644 --- a/web/room.js +++ b/web/room.js @@ -29,7 +29,7 @@ */ -function state_add(flags) +function state_add(flags, comp) { var content = "", supercont = ""; var st, superst, name = "", supername = "", supersfx = ""; @@ -113,14 +113,19 @@ function state_add(flags) switch (superst) { case 0x20000: - supername = "superuser"+supersfx+".png"; + if (comp != null) { + supername = "suprend.php?comp="+comp+"&sfx="+supersfx; + } + else { + supername = "img/superuser"+supersfx+".png"; + } supertit = (g_lang == 'en' ? "Brisk Supporter" : "Brisk Supporter"); break; } } if (supername != "") { - content += ' '; + content += ' '; } if (name != "") { diff --git a/web/suprend.php b/web/suprend.php index 910ff8e..e620811 100644 --- a/web/suprend.php +++ b/web/suprend.php @@ -1,5 +1,17 @@