TAGS
+doc/relict_output.txt
+web/briskin5/players-corr.php
+
DONE - usermgmt extension
DONE - add close button
DONE - add apprentice icon
- - guarantee for apprentice
- - match counter
+ - match counters
+ . sql for match counters
+ . migration script for old users
Phase2
- - MENTORS
+ - new info system
+ - guarantee for apprentice
+
+ - MENTORS
- listen all
- BUDDY LIST
--- /dev/null
+#!/bin/bash
+su - -c "su - -c \"script -q -c \\\"screen -r\\\" /dev/null \" www-data"
--- /dev/null
+
+FINISH REASON:
+
+ 1) complete game | 2) all pass | 3) abandon because too less points
+ ----------------------+-------------------+----------------------------------------------
+ mult deps on win | mult_inc() | mult_inc()
+ calculate_points() | old_reason_set() | old_reason_set()
+ game_next(1) | game_next(1) | game_next(0)
+ game_init() | game_init() | game_init()
+
+ set old_reason
+ mult++
+ game_next(1)
+ game_init()
+
+ 3)
+ mult++
+ set old_reason
+ game_next(0)
+ game_init()
--- /dev/null
+--
+-- Table to manage mails sent to users
+--
+DROP TABLE #PFX#selfreg_chk;
+CREATE TABLE #PFX#selfreg_chk (
+ ip integer, -- ip v4 address
+ atime timestamp DEFAULT to_timestamp(0) -- access time
+ );
--- /dev/null
+#!/usr/bin/php
+<?php
+$a = array("127.0.0.1", "255.255.255.255", "255.255.0.0" );
+
+printf("INT_SIZE: %d\n", PHP_INT_SIZE);
+foreach ($a as $i) {
+ printf("VAL: %016x\n", ip2long($i));
+}
+
+?>
\ No newline at end of file
/*
* brisk - brisk.phh
*
- * Copyright (C) 2006-2014 Matteo Nastasi
+ * Copyright (C) 2006-2015 Matteo Nastasi
* mailto: nastasi@alternativeoutput.it
* matteo.nastasi@milug.org
* web: http://www.alternativeoutput.it
if ($sitted < PLAYERS_N) {
switch ($this->auth_type) {
case TABLE_AUTH_TY_CERT:
- if ($user->is_cert())
+ if ($user->is_cert() && !$user->is_appr())
$act = "sitcert";
else
$act = 'resercert';
break;
case TABLE_AUTH_TY_AUTH:
- if ($user->is_auth())
+ if ($user->is_auth() && !$user->is_appr())
$act = "sitreser";
else
$act = 'reserved';
/*
* brisk - dbase_pgsql.phh
*
- * Copyright (C) 2006-2012 Matteo Nastasi
+ * Copyright (C) 2006-2015 Matteo Nastasi
* mailto: nastasi@alternativeoutput.it
* matteo.nastasi@milug.org
* web: http://www.alternativeoutput.it
return (TRUE);
}
+ /*
+ $laddr is native php int (32 or 64 bit)
+ if ret True is ip is free
+ */
+ function selfreg_check($laddr)
+ {
+ GLOBAL $G_dbpfx, $G_selfreg_tout, $G_selfreg_mask;
+
+ $sere_sql = sprintf("DELETE from %sselfreg_chk WHERE atime < now();", $G_dbpfx);
+ if (($sere_pg = $this->query($sere_sql)) == FALSE) {
+ return (FALSE);
+ }
+
+ if (($sere_pg = $this->query($sere_sql)) == FALSE) {
+ return (FALSE);
+ }
+
+ $sere_sql = sprintf("SELECT * FROM %sselfreg_chk WHERE (ip & %d) = %d;",
+ $G_dbpfx, int2four($G_selfreg_mask), int2four($laddr & $G_selfreg_mask));
+ if (($sere_pg = $this->query($sere_sql)) == FALSE) {
+ return(FALSE);
+ }
+
+ $ret = pg_numrows($sere_pg);
+
+ if ($ret === FALSE) {
+ return(FALSE);
+ }
+ else if ($ret === 0) {
+ return(TRUE);
+ }
+ else if ($ret > 0) {
+ // already present
+ return(FALSE);
+ }
+ else {
+ // unreachable branch
+ return(FALSE);
+ }
+ }
+
+ /*
+ $laddr is native php int (32 or 64 bit)
+ if ret True is ip is free
+ */
+ function selfreg_set($laddr)
+ {
+ GLOBAL $G_dbpfx, $G_selfreg_tout, $G_selfreg_mask;
+
+ $newi_sql = sprintf("INSERT INTO %sselfreg_chk (ip, atime) VALUES (%d, now() + interval '%d seconds');",
+ $G_dbpfx, int2four($laddr & $G_selfreg_mask), $G_selfreg_tout);
+ if (($newi_pg = $this->query($newi_sql)) == FALSE) {
+ return(FALSE);
+ }
+ return(TRUE);
+ }
+
/*
to be able to add mail record code into the record itself I must reserve it before.
*/
return TRUE;
}
- function user_update_flag_ty($code, $old_type, $old_reas, $type, $reas)
+ function user_update_flag_ty($code, $type, $old_val, $old_reas, $new_val, $new_reas)
{
GLOBAL $G_dbpfx;
- // (u.type & (CAST (X'00ff0000' as integer)))
-
- $user_sql = sprintf("UPDATE %susers SET (type, disa_reas) = ((%d & (CAST (X'00ff0000' as integer))), %d)
-WHERE code = %d AND (type & CAST (X'%08x' as integer)) != 0 AND disa_reas = %d;",
- $G_dbpfx, $type, $reas, $code, $old_type, $old_reas);
+ $user_sql = sprintf("UPDATE %susers SET (type, disa_reas)
+ = (type & ~(CAST (X'%08x' as integer)) | (CAST (X'%08x' as integer)), %d)
+ WHERE code = %d AND (type & (CAST (X'%08x' as integer)))
+ = (CAST (X'%08x' as integer)) AND disa_reas = %d;",
+ $G_dbpfx, $type, ($new_val ? $type : 0), $new_reas,
+ $code, $type, ($old_val ? $type : 0), $old_reas);
if ( ! (($user_pg = $this->query($user_sql)) != FALSE && pg_affected_rows($user_pg) == 1) ) {
return FALSE;
<?php
-if (__FILE__ == realpath($argv[0])) {
+if (isset($argv) && __FILE__ == realpath($argv[0])) {
$G_base = "web/";
}
require_once("${G_base}Obj/class.phpmailer.php");
}
-if (__FILE__ == realpath($argv[0])) {
+if (isset($argv) && __FILE__ == realpath($argv[0])) {
$G_admin_mail = "brisk@alternativeoutput.it";
$to = "brisk@alternativeoutput.it";
return ($thiz);
}
+ function is_appr()
+ {
+ return ($this->flags & USER_FLAG_TY_APPR);
+ }
+
function is_auth()
{
return ($this->flags & USER_FLAG_AUTH);
var name, i, sp = "", cl = "";
var flags = user[0] & 0x03 | ((user[0] & 0x0c0000) >> 16);
- console.log(user[1]+" FLAGS: "+flags);
+ // console.log(user[1]+" FLAGS: "+flags);
for (i = 0 ; i < 4 ; i++) {
if (flags & (1 << i)) {
$not_allowed_msg = nickserv_msg($dt, sprintf($mlang_indwr['tabwait'][$G_lang],
$table->wakeup_time - $curtime));
}
- else if ($table->auth_type == TABLE_AUTH_TY_CERT && ( ! $user->is_cert() ) ) {
+ else if ( $table->auth_type == TABLE_AUTH_TY_CERT &&
+ (!$user->is_cert() || $user->is_appr()) ) {
$not_allowed_msg = nickserv_msg($dt, $mlang_indwr['mustcert'][$G_lang]);
}
- else if ($table->auth_type == TABLE_AUTH_TY_AUTH && ( ! $user->is_auth() ) ) {
+ else if ( $table->auth_type == TABLE_AUTH_TY_AUTH &&
+ (!$user->is_auth() || $user->is_appr()) ) {
$not_allowed_msg = nickserv_msg($dt, $mlang_indwr['mustauth'][$G_lang]);
}
else if ($user->flags & USER_FLAG_TY_FIRONLY && $table->player_n > 0) {
SELECT usr.*, guar.login AS guar_login
FROM %susers AS usr
JOIN %susers AS guar ON guar.code = usr.guar_code
- WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
+ WHERE usr.type & (CAST (X'%x' as integer)) = (CAST (X'%x' as integer))
AND usr.disa_reas = %d AND usr.code = %d;",
$G_dbpfx, $G_dbpfx,
USER_FLAG_TY_DISABLE, USER_FLAG_TY_DISABLE,
SELECT usr.*, guar.login AS guar_login
FROM %susers AS usr
JOIN %susers AS guar ON guar.code = usr.guar_code
- WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
- AND usr.disa_reas = %d
- ORDER BY usr.lintm;",
+ WHERE usr.type & (CAST (X'%x' as integer)) = (CAST (X'%x' as integer))
+ AND usr.disa_reas = %d ORDER BY usr.lintm;",
$G_dbpfx, $G_dbpfx,
USER_FLAG_TY_DISABLE, USER_FLAG_TY_DISABLE,
USER_DIS_REA_NU_ADDED);
SELECT usr.*, guar.login AS guar_login
FROM %susers AS usr
JOIN %susers AS guar ON guar.code = usr.guar_code
- WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
- AND usr.disa_reas = %d
- ORDER BY usr.lintm;",
+ WHERE usr.type & (CAST (X'%x' as integer)) = (CAST (X'%x' as integer))
+ AND usr.disa_reas = %d ORDER BY usr.lintm;",
$G_dbpfx, $G_dbpfx,
USER_FLAG_TY_DISABLE, USER_FLAG_TY_DISABLE,
USER_DIS_REA_NU_MAILED);
SELECT usr.*, guar.login AS guar_login
FROM %susers AS usr
JOIN %susers AS guar ON guar.code = usr.guar_code
- WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
+ WHERE usr.type & (CAST (X'%x' as integer)) = (CAST (X'%x' as integer))
AND usr.disa_reas = %d AND usr.code = %d;",
$G_dbpfx, $G_dbpfx,
- USER_FLAG_TY_ALL & ~USER_FLAG_TY_APPR, USER_FLAG_TY_DISABLE,
+ USER_FLAG_TY_DISABLE, USER_FLAG_TY_DISABLE,
USER_DIS_REA_NU_TOBECHK, $id);
if (($usr_pg = pg_query($bdb->dbconn->db(), $usr_sql)) == FALSE) {
log_crit("stat-day: select from tournaments failed");
SELECT usr.*, guar.login AS guar_login
FROM %susers AS usr
JOIN %susers AS guar ON guar.code = usr.guar_code
- WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
- AND usr.disa_reas = %d
- ORDER BY usr.lintm;",
+ WHERE usr.type & (CAST (X'%x' as integer)) = (CAST (X'%x' as integer))
+ AND usr.disa_reas = %d ORDER BY usr.lintm;",
$G_dbpfx, $G_dbpfx,
- USER_FLAG_TY_ALL & ~USER_FLAG_TY_APPR, USER_FLAG_TY_DISABLE,
+ USER_FLAG_TY_DISABLE, USER_FLAG_TY_DISABLE,
USER_DIS_REA_NU_TOBECHK);
if (($usr_pg = pg_query($bdb->dbconn->db(), $usr_sql)) == FALSE) {
log_crit("stat-day: select from tournaments failed");