class Client_prefs {
var $listen;
- function Client_prefs($listen)
+ function Client_prefs()
{
- $this->listen = $listen;
+ }
+
+ static function from_user($user)
+ {
+ $thiz = new Client_prefs();
+ $thiz->user_load($user);
+
+ return ($thiz);
+ }
+
+ static function from_json($json)
+ {
+ $thiz = new Client_prefs();
+ if ($thiz->json_load($json) == FALSE) {
+ return (FALSE);
+ }
+
+ return ($thiz);
+ }
+
+ function user_load($user)
+ {
+ fprintf(STDERR, "QQ %s: %x\n", __FUNCTION__, $user->flags);
+ $this->listen = ($user->flags & USER_FLAG_MAP_AUTH) >> 2;
+
+ fprintf(STDERR, "QQ %s: LISTEN: %d\n", __FUNCTION__, $this->listen);
+ }
+
+ 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;
+
+ return TRUE;
+ }
+
+ function store($user, $is_save)
+ {
+ // save into DB
+ fprintf(STDERR, "QQ %s::%s PRE: %x\n", __CLASS__, __FUNCTION__,
+ $user->flags & (~USER_FLAG_S_ALL & ~USER_FLAG_AUTH));
+ $user->flags_set(($this->listen << 2), USER_FLAG_MAP_AUTH);
+ fprintf(STDERR, "QQ %s::%s %x\n", __CLASS__, __FUNCTION__,
+ $user->flags);
+ if ($is_save)
+ $user->store_set();
}
}
$ret = sprintf('gst.st = %d; ', $user_step);
- // for test: $prefs = new Client_prefs(USER_FLAG_LISTAUTH >> 2);
- $prefs = new Client_prefs(($user->flags & USER_FLAG_MAP_AUTH) >> 2);
+ $prefs = Client_prefs::from_user($user);
$ret .= sprintf('prefs_load(\'%s\', false, false);', json_encode($prefs));
if(false) {
$this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
$this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
-
if ($authenticate != FALSE) {
- $this->user[$idx]->code = $authenticate->code_get();
- $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
-
- if (isset($cookie['CO_list'])) {
- if (strcmp($cookie['CO_list'], "auth") == 0) {
- $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
- $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
- }
- if (strcmp($cookie['CO_list'], "isolation") == 0) {
- $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
- $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH;
+ $this->user[$idx]->code = $authenticate->code_get();
+ if (0 == 1) {
+ // all this part is included in the db server
+ $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
+
+ if (isset($cookie['CO_list'])) {
+ fprintf(STDERR, "QQ: %s CO_list: [%s]\n", __FUNCTION__, $cookie['CO_list']);
+ if (strcmp($cookie['CO_list'], "auth") == 0) {
+ $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+ $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
+ }
+ if (strcmp($cookie['CO_list'], "isolation") == 0) {
+ $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+ $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH;
+ }
+ else {
+ $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+ }
+ }
}
else {
- $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+ fprintf(STDERR, "QQ: CO_list not set flags: %x\n", __FUNCTION__, $this->user[$idx]->flags);
}
- }
}
-
+ fprintf(STDERR, "QQ %s: flag %x\n", __FUNCTION__, $this->user[$idx]->flags);
if ($ghost > -1) {
log_main("ghost: rename!");
$ghost_user = $this->user[$ghost];
$content = ob_get_contents();
ob_end_clean();
- fprintf(STDERR, "\n\nCONTENT [%s]\n\n", $content);
+ // fprintf(STDERR, "\n\nCONTENT [%s]\n\n", $content);
$s_a_p->pendpage_try_addflush($new_socket, 20, $enc, $header_out, $content);
return TRUE;
$this->login = $login;
$this->pass = $pass;
$this->email = $email;
+ fprintf(STDERR, "QQ: %s: %x\n", __FUNCTION__, $type);
$this->type = $type;
}
function type_get()
{
+ fprintf(STDERR, "TYPE GET: %d\n", $this->type);
return $this->type;
}
return ($user_obj);
}
- function user_update_login_time($id, $lintm)
+ function user_update_login_time($code, $lintm)
{
GLOBAL $G_dbpfx;
- $user_sql = sprintf("UPDATE %susers SET (lintm) = (date 'epoch' + %d * INTERVAL '1 second') WHERE code = %d;", $G_dbpfx, $lintm, $id);
+ $user_sql = sprintf("UPDATE %susers SET (lintm) = (date 'epoch' + %d * INTERVAL '1 second') WHERE code = %d;", $G_dbpfx, $lintm, $code);
// $user_pg = $this->query($user_sql);
// $row_n = pg_affected_rows($user_pg);
return TRUE;
}
+
+ function user_update_flags($code, $flags)
+ {
+ GLOBAL $G_dbpfx;
+
+ $user_sql = sprintf("UPDATE %susers SET (type) = (%d) WHERE code = %d;", $G_dbpfx, $flags, $code);
+ fprintf(STDERR, "REQUEST [%s]\n", $user_sql);
+ if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) {
+ return FALSE;
+ }
+ fprintf(STDERR, "REQUEST GOOD [%s]\n", $user_sql);
+
+ return TRUE;
+ }
function login_verify($login, $pass)
{
$cont_comp = $content;
}
$cont_comp_l = mb_strlen($cont_comp, "ASCII");
- printf("CHUNK: [%s]\n", $content);
+ // printf("CHUNK: [%s]\n", $content);
return (sprintf("%X\r\n", $cont_comp_l).$cont_comp."\r\n");
}
}
$write = NULL;
$except = NULL;
- $num_changed_sockets = @stream_select($read, $write, $except, 5, 500000);
+ $num_changed_sockets = @stream_select($read, $write, $except, 0, 500000);
if ($num_changed_sockets == 0) {
printf(" no data in 5 secs, splash [%d]\n", $G_with_splash);
if ($response != "") {
// echo "SPIA: [".substr($response, 0, 60)."...]\n";
- echo "SPIA: [".$response."]\n";
+ // echo "SPIA: [".$response."]\n";
$response_l = mb_strlen($response, "ASCII");
$wret = @fwrite($sock, $response);
if ($wret < $response_l) {
function User() {
}
- function create(&$room, $idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
+ static function create(&$room, $idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") {
if (($thiz = new User()) == FALSE)
return (FALSE);
}
- function myclone($from)
+ static function myclone($from)
{
if (($thiz = new User()) == FALSE)
return (FALSE);
return ($thiz);
}
- function spawn($from, $table, $table_pos)
+ static function spawn($from, $table, $table_pos)
{
if (($thiz = new User()) == FALSE)
return (FALSE);
return ($thiz);
}
+ function flags_set($flags, $mask)
+ {
+ $flags_old = $this->flags & (~$mask);
+ $this->flags = ($flags_old | ($flags & $mask));
+ }
+
+ function store_set()
+ {
+ if (($bdb = BriskDB::create()) == FALSE) {
+ return FALSE;
+ }
+ return ($bdb->user_update_flags($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH))));
+ }
+
function rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from)
{
$this->rd_endtime = $curtime + RD_ENDTIME_DELTA;
}
*/
- function spawn($from, &$bri, $table, $table_pos, $get, $post, $cookie)
+ static function spawn($from, &$bri, $table, $table_pos, $get, $post, $cookie)
{
if (($thiz = new Bin5_user()) == FALSE)
return (FALSE);
</table>
-<hr style="color: red;">
-
-
<div style="width: 95%; /* background-color: red; */ margin: auto; text-align: left;">
<br><br>
-<input type="checkbox" name="pref_ring_endauct" id="pref_ring_endauct" onclick="pref_ring_endauct_set(this);"><?php echo $mlang_room['itm_ringauc'][$G_lang] ?>
+ <!-- <input type="checkbox" name="pref_ring_endauct" id="pref_ring_endauct" onclick="pref_ring_endauct_set(this);"><?php /* echo $mlang_room['itm_ringauc'][$G_lang]; */ ?> -->
</div>
}
$is_spawn = FALSE;
-
+
log_wr(0, 'index_wr.php: COMM: '.xcapemesg($mesg));
log_wr('COMM: '.xcapemesg($mesg));
-
+
$curtime = time();
$dt = date("H:i ", $curtime);
-
+
if (($user = $room->get_user($sess, &$idx)) == FALSE) {
$argz = explode('|', xcapemesg($mesg));
else if ($argz[0] == 'whysupport') {
echo show_notify(str_replace("\n", " ", $G_room_whysupport[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lng], 400, 200);
}
- else if ($argz[0] == 'prefs') {
- fprintf(STDERR, "\n\n PREFS \n\n");
- }
else {
log_wr("Get User Error");
echo "Get User Error:" + $argz[0];
return TRUE;
}
-
-
$argz = explode('|', xcapemesg($mesg));
log_wr('POSTSPLIT: '.$argz[0]);
if ($argz[0] == 'ping') {
log_wr("PING RECEIVED");
}
+ else if ($argz[0] == 'prefs') {
+ fprintf(STDERR, "\n\n PREFS pre\n\n");
+ if (!isset($post['prefs'])) {
+ return FALSE;
+ }
+
+ $prefs = Client_prefs::from_json($post['prefs']);
+ fprintf(STDERR, "\n\n PREFS [%s]\n\n", print_r($prefs, TRUE));
+
+ $prefs->store($user, TRUE);
+
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs),
+ 'false');
+ $user->step_inc();
+ echo "1";
+ return TRUE;
+ }
else if ($argz[0] == 'shutdown') {
log_auth($user->sess, "Shutdown session.");
if (typeof(g_prefs) == 'undefined')
return false;
-
/* listen management */
- if (g_prefs.listen != prefs_new.listen) {
+ 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]) {
function prefs_save()
{
+ var ret;
+
if (typeof(g_prefs) == 'undefined')
return false;
- console.log(server_request('mesg', 'prefs', '__POST__', 'prefs', JSON.stringify(g_prefs)));
- // close the win:
- // $('preferences').style.visibility = 'hidden';
+ ret = server_request('mesg', 'prefs','__POST__', 'prefs', JSON.stringify(g_prefs));
+
+ if (ret == 1)
+ $('preferences').style.visibility = 'hidden';
}
function prefs_update()
break;
}
- /* TODO SAVE TEMPORARY */
/* from form to struct */
- console.log("Prefs_update");
prefs_apply(prefs_new, true, true);
}