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_stat_day = array( 'normal match'=> array( 'it' => 'Partite normali',
28 'en' => 'Normal matches' ),
29 'special match' => array( 'it' => 'Partite speciali',
30 'en' => 'Special matches'),
32 'info_total'=> array( 'it' => 'totali',
36 ini_set("max_execution_time", "240");
38 require_once($G_base."Obj/brisk.phh");
39 require_once($G_base."Obj/user.phh");
40 require_once($G_base."Obj/auth.phh");
41 require_once($G_base."Obj/dbase_${G_dbasetype}.phh");
42 require_once($G_base."briskin5/Obj/briskin5.phh");
43 require_once($G_base."briskin5/Obj/placing.phh");
44 require_once($G_base."spush/brisk-spush.phh");
48 GLOBAL $G_alarm_passwd, $sess, $_POST, $_SERVER;
52 $ip = $_SERVER["REMOTE_ADDR"];
54 $private = md5($G_alarm_passwd.$ip.$sess);
55 $cmd = array ("cmd" => "userauth", "sess" => $sess, "private" => $private, "the_end" => "true");
56 $cmd_ser = cmd_serialize($cmd);
57 $cmd_len = mb_strlen($cmd_ser, "ASCII");
60 if (($socket = stream_socket_client("unix://".USOCK_PATH."2")) == FALSE)
62 if (($rwr = fwrite($socket, $cmd_ser, $cmd_len)) == FALSE
66 if (($buf = fread($socket, 4096)) == FALSE)
68 $res = cmd_deserialize($buf);
69 if (!isset($res['val']) || $res['val'] != 200)
79 function main($action) {
80 GLOBAL $G_dbpfx, $G_alarm_passwd, $f_mailusers, $sess, $_POST, $_SERVER;
82 if (check_auth() == FALSE) {
83 echo "Authentication failed";
87 if (isset($f_mailusers)) {
91 if ($action == "listnew") {
97 if (($bdb = BriskDB::create()) == FALSE) {
98 log_crit("stat-day: database connection failed");
102 // retrieve list of active tournaments
104 SELECT usr.*, guar.login AS guar_login
106 JOIN %susers AS guar ON guar.code = usr.guar_code
107 WHERE ( (usr.type & (CAST (X'%x' as integer))) = (CAST (X'%x' as integer)) )
108 AND usr.disa_reas = %d;",
110 USER_FLAG_TY_ALL, USER_FLAG_TY_DISABLE,
111 USER_DIS_REA_NU_TOBECHK);
112 if (($usr_pg = pg_query($bdb->dbconn->db(), $usr_sql)) == FALSE) {
113 log_crit("stat-day: select from tournaments failed");
117 $usr_n = pg_numrows($usr_pg);
118 printf("Number of tournaments: %d\n", $usr_n);
121 // loop on tournaments
122 for ($i = 0 ; $i < $usr_n ; $i++) {
123 // log_crit("stat-day: LOOP i");
124 $usr_obj = pg_fetch_object($usr_pg, $i);
126 $tab_lines .= sprintf("<tr><td><input name=\"f_newuser%d\" type=\"checkbox\" CHECKED></td><td>%s</td><td></td></tr>\n",
127 $usr_obj->code, eschtml($usr_obj->login), eschtml($usr_obj->guar_login));
132 <form action="<?php echo "$PHP_SELF"; ?>" method="POST">
138 <input type="submit" name="f_mailusers" value="Done">
148 if (!isset($f_action)) {