5 * Copyright (C) 2014 Matteo Nastasi
6 * mailto: nastasi@alternativeoutput.it
7 * matteo.nastasi@milug.org
8 * web: http://www.alternativeoutput.it
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details. You should have received a
19 * copy of the GNU General Public License along with this program; if
20 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
21 * Suite 330, Boston, MA 02111-1307, USA.
27 $mlang_umgmt = array( 'nu_psubj' => array( 'it' => 'Brisk: credenziali di accesso.',
28 'en' => 'Brisk: credentials.'),
29 'nu_ptext' => array( 'it' =>
30 'Ciao, sono l\' amministratore del sito di Brisk.
32 La verifica del tuo indirizzo di posta elettronica e del tuo nickname è andata a buon fine, per accedere al sito
33 d\'ora in poi potrai utilizzare l\' utente \'%s\' e la password \'%s\'.
35 Benvenuto e buone partite, mop.',
36 'en' => 'EN ptext [%s] [%s]'),
37 'nu_phtml' => array( 'it' => 'Ciao, sono l\' amministratore del sito di Brisk.<br><br>
38 La verifica del tuo indirizzo di posta elettronica e del tuo nickname è andata a buon fine, per accedere al sito d\'ora in poi potrai usare l\' utente \'%s\' e la password \'%s\'.<br>
39 Benvenuto e buone partite, mop.<br>',
40 'en' => 'EN phtml [%s] [%s]')
44 ini_set("max_execution_time", "240");
46 require_once($G_base."Obj/brisk.phh");
47 require_once($G_base."Obj/user.phh");
48 require_once($G_base."Obj/auth.phh");
49 require_once($G_base."Obj/mail.phh");
50 require_once($G_base."Obj/dbase_${G_dbasetype}.phh");
51 require_once($G_base."briskin5/Obj/briskin5.phh");
52 require_once($G_base."briskin5/Obj/placing.phh");
53 require_once($G_base."spush/brisk-spush.phh");
57 GLOBAL $G_alarm_passwd, $sess, $_POST, $_SERVER;
61 $ip = $_SERVER["REMOTE_ADDR"];
63 $private = md5($G_alarm_passwd.$ip.$sess);
64 $cmd = array ("cmd" => "userauth", "sess" => $sess, "private" => $private, "the_end" => "true");
65 $cmd_ser = cmd_serialize($cmd);
66 $cmd_len = mb_strlen($cmd_ser, "ASCII");
69 if (($socket = stream_socket_client("unix://".USOCK_PATH."2")) == FALSE)
72 if (($rwr = fwrite($socket, $cmd_ser, $cmd_len)) == FALSE
77 if (($buf = fread($socket, 4096)) == FALSE)
79 $res = cmd_deserialize($buf);
81 if (!isset($res['val']) || $res['val'] != 200)
96 GLOBAL $G_dbpfx, $G_lang, $G_alarm_passwd, $mlang_umgmt, $f_mailusers, $sess, $_POST, $_SERVER;
98 if (check_auth() == FALSE) {
99 echo "Authentication failed";
103 if (isset($_POST['f_accept'])) {
106 else if (isset($_POST['f_delete'])) {
111 if ($action == "accept") {
112 if (($bdb = BriskDB::create()) == FALSE) {
113 log_crit("stat-day: database connection failed");
117 foreach($_POST as $key => $value) {
118 if (substr($key, 0, 9) != "f_newuser")
121 $id = (int)substr($key, 9);
126 // retrieve list of active tournaments
128 SELECT usr.*, guar.login AS guar_login
130 JOIN %susers AS guar ON guar.code = usr.guar_code
131 WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
132 AND usr.disa_reas = %d AND usr.code = %d;",
134 USER_FLAG_TY_ALL, USER_FLAG_TY_DISABLE,
135 USER_DIS_REA_NU_TOBECHK, $id);
136 if (($usr_pg = pg_query($bdb->dbconn->db(), $usr_sql)) == FALSE) {
137 log_crit("stat-day: select from tournaments failed");
140 $usr_obj = pg_fetch_object($usr_pg, 0);
142 printf("KEY: %s: %s %s<br>\n", $id, $value, $usr_obj->login);
144 $passwd = passwd_gen();
146 if (($bdb->user_update_passwd($usr_obj->code, $passwd)) == FALSE) {
151 if (($bdb->user_update_flag_ty($usr_obj->code,
152 USER_FLAG_TY_DISABLE, USER_DIS_REA_NU_TOBECHK,
153 USER_FLAG_TY_NORM, USER_DIS_REA_NU_NONE)) == FALSE) {
159 $subj = $mlang_umgmt['nu_psubj'][$G_lang];
160 $body_txt = sprintf($mlang_umgmt['nu_ptext'][$G_lang],
161 $usr_obj->login, $passwd);
162 $body_htm = sprintf($mlang_umgmt['nu_phtml'][$G_lang],
163 $usr_obj->login, $passwd);
165 if (brisk_mail($usr_obj->email, $subj, $body_txt, $body_htm) == FALSE) {
167 fprintf(STDERR, "ERROR: mail send FAILED\n");
175 if (($bdb = BriskDB::create()) == FALSE) {
176 log_crit("stat-day: database connection failed");
180 // retrieve list of active tournaments
182 SELECT usr.*, guar.login AS guar_login
184 JOIN %susers AS guar ON guar.code = usr.guar_code
185 WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
186 AND usr.disa_reas = %d;",
188 USER_FLAG_TY_ALL, USER_FLAG_TY_DISABLE,
189 USER_DIS_REA_NU_TOBECHK);
190 if (($usr_pg = pg_query($bdb->dbconn->db(), $usr_sql)) == FALSE) {
191 log_crit("stat-day: select from tournaments failed");
195 $usr_n = pg_numrows($usr_pg);
197 for ($i = 0 ; $i < $usr_n ; $i++) {
198 $usr_obj = pg_fetch_object($usr_pg, $i);
200 $tab_lines .= sprintf("<tr><td><input name=\"f_newuser%d\" type=\"checkbox\" CHECKED></td><td>%s</td><td></td></tr>\n",
201 $usr_obj->code, eschtml($usr_obj->login), eschtml($usr_obj->guar_login));
206 <form action="<?php echo "$PHP_SELF"; ?>" method="POST">
212 <input type="submit" name="f_accept" value="Accept">
213 <input type="submit" name="f_delete" value="Delete">