-/* else if ($argz[0] == 'warranty') { */
-/* GLOBAL $cli_name, $cli_email; */
-
-/* $mesg_to_user = ""; */
-
-/* log_wr("INFO:SKIP:argz == warranty name: [".$cli_name."] AUTH: ".($user->flags & USER_FLAG_AUTH)); */
-/* if ($user->flags & USER_FLAG_AUTH) { */
-/* if (($wa_lock = Warrant::lock_data(TRUE)) != FALSE) { */
-/* if (($fp = @fopen(LEGAL_PATH."/warrant.txt", 'a')) != FALSE) { */
-/* /\* Unix time | session | nickname | IP | where was | mesg *\/ */
-/* fwrite($fp, sprintf("%ld|%s|%s|%s|\n", $curtime, xcapelt($user->name), xcapelt(urldecode($cli_name)), xcapelt(urldecode($cli_email)))); */
-/* fclose($fp); */
-/* } */
-/* Warrant::unlock_data($wa_lock); */
-/* $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; */
-/* /\* MLANG: "<br>Il nominativo è stato inoltrato all\'amministratore.<br><br>Nell\'arco di pochi giorni vi verrà<br><br>notificata l\'avvenuta registrazione." *\/ */
-/* $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['warrrepl'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 150); */
-/* $user->step_inc(); */
-/* echo "1"; */
-/* } */
-/* else { */
-/* /\* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" *\/ */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]); */
-/* } */
-
-/* } */
-/* else { */
-/* /\* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" *\/ */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['warrmust'][$G_lang]); */
-/* } */
-
-/* if ($mesg_to_user != "") { */
-/* $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; */
-
-/* $user->comm[$user->step % COMM_N] .= $mesg_to_user; */
-/* $user->step_inc(); */
-/* } */
-/* } */
-/* else if ($argz[0] == 'mesgtoadm') { */
-/* GLOBAL $cli_subj, $cli_mesg; */
-
-/* $mesg_to_user = ""; */
-
-/* log_wr("INFO:SKIP:argz == mesgtoadm name: [".$user->name."] AUTH: ".($user->flags & USER_FLAG_AUTH)); */
-/* if ($user->flags & USER_FLAG_AUTH) { */
-/* if (($wa_lock = Warrant::lock_data(TRUE)) != FALSE) { */
-/* if (($bdb = BriskDB::create()) != FALSE) { */
-/* $bdb->users_load(); */
-
-/* if (($ema = $bdb->getmail($user->name)) != FALSE) { */
-/* // mail("nastasi", */
-/* mail("brisk@alternativeoutput.it", urldecode($cli_subj), urldecode($cli_mesg), sprintf("From: %s <%s>", $user->name, $ema)); */
-/* } */
-
-/* if (($fp = @fopen(LEGAL_PATH."/messages.txt", 'a')) != FALSE) { */
-/* /\* Unix time | session | nickname | IP | where was | mesg *\/ */
-/* fwrite($fp, sprintf("%ld|%s|%s|%s\n", $curtime, $user->name, */
-/* xcapelt(urldecode($cli_subj)), xcapelt(urldecode($cli_mesg)))); */
-/* fclose($fp); */
-/* } */
-/* Warrant::unlock_data($wa_lock); */
-/* $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; */
-/* /\* MLANG: "" *\/ */
-/* $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['mesgrepl'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110); */
-/* $user->step_inc(); */
-/* echo "1"; */
-/* } */
-/* else { */
-/* /\* MLANG: "<b>Il database è temporaneamente irraggiungibile, riprova più tardi o contatta l\'amministratore.</b>" *\/ */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['coerrdb'][$G_lang]); */
-/* $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; */
-/* } */
-/* } */
-/* else { */
-/* /\* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" *\/ */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]); */
-/* } */
-
-/* } */
-/* else { */
-/* /\* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" *\/ */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['mesgmust'][$G_lang]); */
-/* } */
-
-/* if ($mesg_to_user != "") { */
-/* $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; */
-
-/* $user->comm[$user->step % COMM_N] .= $mesg_to_user; */
-/* $user->step_inc(); */
-/* } */
-/* } */
-
-
-
-/* else if ($argz[0] == 'poll') { */
-/* GLOBAL $G_with_poll, $G_poll_name, $cli_choose, $cli_poll_name; */
-
-/* $poll_lock = FALSE; */
-/* $mesg_to_user = ""; */
-
-/* $fp = FALSE; */
-/* $echont = "0"; */
-
-/* /\* */
-/* DONE - autorizzato ? */
-/* DONE - ci sono poll attivi ? */
-/* - verifica che il poll_name del client sia uguale a quello sul server */
-/* DONE - lock */
-/* DONE - apro file r+ con fallback in w+ */
-/* DONE - vedo se ha già votato */
-/* DONE - se si: messaggio di voto già dato */
-/* se no: accetto il voto e lo segno; messaggio */
-/* chiudo file */
-/* *\/ */
-
-/* $dobreak = FALSE; */
-/* do { */
-/* log_wr("INFO:SKIP:argz == poll name: [".$cli_name."] AUTH: ".($user->flags & USER_FLAG_AUTH)); */
-/* if (($user->flags & USER_FLAG_AUTH) != USER_FLAG_AUTH) { */
-/* // MLANG: <b>Per partecipare al sondaggio devi essere autenticato.</b> */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['pollmust'][$G_lang]); */
-/* log_wr("break1"); */
-/* break; */
-/* } */
-
-/* if ($G_with_poll == FALSE && $G_poll_name != FALSE && $G_poll_name != "") { */
-/* $mesg_to_user = show_notify($mlang_indwr['pollnone'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110); */
-/* log_wr("break2"); */
-/* break; */
-/* } */
-
-/* if ($cli_choose == "" || !isset($cli_choose)) { */
-/* $mesg_to_user = show_notify($mlang_indwr['pollchoo'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110); */
-/* log_wr("break2.5"); */
-/* break; */
-/* } */
-
-/* if (($poll_lock = Poll::lock_data(TRUE)) == FALSE) { */
-/* /\* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" *\/ */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]); */
-/* log_wr("break3"); */
-/* break; */
-/* } */
-
-/* if (($fp = @fopen(LEGAL_PATH."/".$G_poll_name.".txt", 'r+')) == FALSE) */
-/* $fp = @fopen(LEGAL_PATH."/".$G_poll_name.".txt", 'w+'); */
-
-/* if ($fp == FALSE) { */
-/* $mesg_to_user = sprintf('chatt_sub("%s", [2, "%s"],"%s");', $dt, NICKSERV, $mlang_indwr['commerr'][$G_lang]); */
-/* log_wr("break4"); */
-/* break; */
-/* } */
-
-/* log_wr("poll: cp"); */
-/* fseek($fp, 0); */
-
-/* log_wr("poll: cp2"); */
-/* while (!feof($fp)) { */
-/* log_wr("poll: cp3"); */
-/* $bf = fgets($fp, 4096); */
-/* log_wr("poll: cp3.1"); */
-/* $arli = csplitter($bf, '|'); */
-/* if (count($arli) == 0) */
-/* break; */
-/* log_wr("poll: cp3.2"); */
-/* if (strcasecmp($arli[1], $user->name) == 0) { */
-/* $mesg_to_user = show_notify($mlang_indwr['pollagai'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110); */
-/* $dobreak = TRUE; */
-/* break; */
-/* } */
-/* } */
-/* log_wr("poll: cp4"); */
-
-/* if ($dobreak) { */
-/* log_wr("break5"); */
-/* break; */
-/* } */
-
-/* /\* Unix time | nickname | choose *\/ */
-/* fwrite($fp, sprintf("%ld|%s|%s\n", $curtime, xcapelt($user->name), xcapelt(urldecode($cli_choose)))); */
-/* fflush($fp); */
-/* $mesg_to_user = show_notify($mlang_indwr['pollrec'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110); */
-/* $echont = "1"; */
-/* log_wr("poll: cp5"); */
-/* } while (0); */
-
-/* if ($fp != FALSE) */
-/* fclose($fp); */
-
-/* if ($poll_lock != FALSE) */
-/* Poll::unlock_data($poll_lock); */
-
-/* if ($mesg_to_user != "") { */
-/* $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; */
-
-/* $user->comm[$user->step % COMM_N] .= $mesg_to_user; */
-/* $user->step_inc(); */
-/* } */
-
-/* echo "$echont"; */
-/* } */
-
-/******************
- * *
- * STAT: room *
- * *
- ******************/
+ else if ($argz[0] == 'warranty') {
+ if (($cli_name = gpcs_var('cli_name', $get, $post, $cookie)) === FALSE)
+ $cli_name = "";
+
+ if (($cli_email = gpcs_var('cli_email', $get, $post, $cookie)) === FALSE)
+ $cli_email = "";
+
+ $mesg_to_user = "";
+
+ log_wr("INFO:SKIP:argz == warranty name: [".$cli_name."] CERT: ".$user->is_cert());
+ if ($user->is_cert()) {
+ if (0 == 1) {
+ if (($wa_lock = Warrant::lock_data(TRUE)) != FALSE) {
+ if (($fp = @fopen(LEGAL_PATH."/warrant.txt", 'a')) != FALSE) {
+ /* Unix time | session | nickname | IP | where was | mesg */
+ fwrite($fp, sprintf("%ld|%s|%s|%s|\n", $curtime, xcapelt($user->name), xcapelt(trim(urldecode($cli_name))), xcapelt(trim(urldecode($cli_email)))));
+ fclose($fp);
+ }
+ Warrant::unlock_data($wa_lock);
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ /* MLANG: "<br>Il nominativo è stato inoltrato all\'amministratore.<br><br>Nell\'arco di pochi giorni vi verrà<br><br>notificata l\'avvenuta registrazione." */
+ $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['warrrepl'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 150);
+ $user->step_inc();
+ echo "1";
+ }
+ else {
+ /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['commerr'][$G_lang]);
+ }
+ } // 0 == 1
+ else {
+ // check existence of username or email
+ $is_trans = FALSE;
+ do {
+ if (($bdb = BriskDB::create()) == FALSE)
+ break;
+
+ $cli_name = trim(urldecode($cli_name));
+ $cli_email = trim(urldecode($cli_email));
+
+ // check for already used fields
+ if (($idret = $bdb->check_record_by_login_or_email($cli_name, $cli_email)) != 0) {
+ $mesg_to_user = nickserv_msg($dt, ($idret == 1 ? $mlang_indwr['nu_loginau'][$G_lang] :
+ ($idret == 2 ? $mlang_indwr['nu_emailau'][$G_lang]
+ : $mlang_indwr['unknownerr'][$G_lang])));
+ break;
+ }
+ $bdb->transaction('BEGIN');
+ $is_trans = TRUE;
+ // insert the new user disabled with reason NU_MAILED
+ if (($usr_obj = $bdb->user_add($cli_name, 'THE_PASS', $cli_email,
+ USER_FLAG_TY_DISABLE | USER_FLAG_TY_NORM,
+ USER_DIS_REA_NU_MAILED, $user->code)) == FALSE) {
+ fprintf(STDERR, "ERROR: user_add FAILED\n");
+ break;
+ }
+ if (($mail_code = $bdb->mail_reserve_code()) == FALSE) {
+ fprintf(STDERR, "ERROR: mail reserve code FAILED\n");
+ break;
+ }
+ $hash = md5($curtime . $G_alarm_passwd . $cli_name . $cli_email);
+
+ $confirm_page = sprintf("%s://%s/%s/mailmgr.php?f_act=checkmail&f_code=%d&f_hash=%s",
+ $G_proto, $G_domain, $G_webbase, $mail_code, $hash);
+ $subj = $mlang_indwr['nu_msubj'][$G_lang];
+ $body_txt = sprintf($mlang_indwr['nu_mtext'][$G_lang],
+ $user->name, $cli_name, $confirm_page);
+ $body_htm = sprintf($mlang_indwr['nu_mhtml'][$G_lang],
+ $user->name, $cli_name, $confirm_page);
+
+ $mail_item = new MailDBItem($mail_code, $usr_obj->code, MAIL_TYP_CHECK,
+ $curtime, $subj, $body_txt, $body_htm, $hash);
+
+ if (brisk_mail($cli_email, $subj, $body_txt, $body_htm) == FALSE) {
+ // mail error
+ fprintf(STDERR, "ERROR: mail send FAILED\n");
+ break;
+ }
+ // save the mail
+ if ($mail_item->store($bdb) == FALSE) {
+ // store mail error
+ fprintf(STDERR, "ERROR: store mail FAILED\n");
+ break;
+ }
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ /* MLANG: "<br>Il nominativo è stato inoltrato all\'amministratore.<br><br>Nell\'arco di pochi giorni vi verrà<br><br>notificata l\'avvenuta registrazione." */
+ $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['warrrepl'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 150);
+ $user->step_inc();
+ echo "1";
+ $bdb->transaction('COMMIT');
+ } while(FALSE);
+ $bdb->transaction('ROLLBACK');
+ }
+
+ }
+ else {
+ /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" */
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['warrmust'][$G_lang]);
+ }
+
+ if ($mesg_to_user != "") {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ $user->comm[$user->step % COMM_N] .= $mesg_to_user;
+ $user->step_inc();
+ }
+ }
+ else if ($argz[0] == 'mesgtoadm') {
+ if (($cli_subj = gpcs_var('cli_subj', $get, $post, $cookie)) === FALSE)
+ $cli_subj = "";
+
+ if (($cli_mesg = gpcs_var('cli_mesg', $get, $post, $cookie)) === FALSE)
+ $cli_mesg = "";
+
+ $mesg_to_user = "";
+
+ log_wr("INFO:SKIP:argz == mesgtoadm name: [".$user->name."] AUTH: ".$user->is_auth());
+ if ($user->is_auth()) {
+ if (($wa_lock = Warrant::lock_data(TRUE)) != FALSE) {
+ if (($bdb = BriskDB::create()) != FALSE) {
+ $bdb->users_load();
+
+ if (($ema = $bdb->getmail($user->name)) != FALSE) {
+ // mail("nastasi",
+ mail("brisk@alternativeoutput.it", urldecode($cli_subj), urldecode($cli_mesg), sprintf("From: %s <%s>", $user->name, $ema));
+ }
+
+ if (($fp = @fopen(LEGAL_PATH."/messages.txt", 'a')) != FALSE) {
+ /* Unix time | session | nickname | IP | where was | mesg */
+ fwrite($fp, sprintf("%ld|%s|%s|%s\n", $curtime, $user->name,
+ xcapelt(urldecode($cli_subj)), xcapelt(urldecode($cli_mesg))));
+ fclose($fp);
+ }
+ Warrant::unlock_data($wa_lock);
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ /* MLANG: "" */
+ $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['mesgrepl'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110);
+ $user->step_inc();
+ echo "1";
+ }
+ else {
+ /* MLANG: "<b>Il database è temporaneamente irraggiungibile, riprova più tardi o contatta l\'amministratore.</b>" */
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['coerrdb'][$G_lang]);
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ }
+ }
+ else {
+ /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['commerr'][$G_lang]);
+ }
+
+ }
+ else {
+ /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>" */
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['mesgmust'][$G_lang]);
+ }
+
+ if ($mesg_to_user != "") {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ $user->comm[$user->step % COMM_N] .= $mesg_to_user;
+ $user->step_inc();
+ }
+ }
+
+
+
+ else if ($argz[0] == 'poll') {
+ GLOBAL $G_with_poll, $G_poll_name;
+ if (($cli_choose = gpcs_var('cli_choose', $get, $post, $cookie)) === FALSE)
+ $cli_choose = "";
+
+ if (($cli_poll_name = gpcs_var('cli_poll_name', $get, $post, $cookie)) === FALSE)
+ $cli_poll_name = "";
+
+ $poll_lock = FALSE;
+ $mesg_to_user = "";
+
+ $fp = FALSE;
+ $echont = "0";
+
+ /*
+ DONE - autorizzato ?
+ DONE - ci sono poll attivi ?
+ - verifica che il poll_name del client sia uguale a quello sul server
+ DONE - lock
+ DONE - apro file r+ con fallback in w+
+ DONE - vedo se ha già votato
+ DONE - se si: messaggio di voto già dato
+ se no: accetto il voto e lo segno; messaggio
+ chiudo file
+ */
+
+ $dobreak = FALSE;
+ do {
+ log_wr("INFO:SKIP:argz == poll name: [".$cli_poll_name."] AUTH: ".$user->is_auth());
+ if ( ! $user->is_auth() || $user->is_appr() ) {
+ // MLANG: <b>Per partecipare al sondaggio devi essere autenticato.</b>
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['pollmust'][$G_lang]);
+ log_wr("break1");
+ break;
+ }
+
+ if ($G_with_poll == FALSE && $G_poll_name != FALSE && $G_poll_name != "") {
+ $mesg_to_user = show_notify($mlang_indwr['pollnone'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110);
+ log_wr("break2");
+ break;
+ }
+
+ if ($cli_choose == "" || !isset($cli_choose)) {
+ $mesg_to_user = show_notify($mlang_indwr['pollchoo'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110);
+ log_wr("break2.5");
+ break;
+ }
+
+ if (($poll_lock = Poll::lock_data(TRUE)) == FALSE) {
+ /* MLANG: "<b>E\' occorso un errore durante il salvataggio, riprova o contatta l\'amministratore.</b>" */
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['commerr'][$G_lang]);
+ log_wr("break3");
+ break;
+ }
+
+ if (($fp = @fopen(LEGAL_PATH."/".$G_poll_name.".txt", 'r+')) == FALSE)
+ $fp = @fopen(LEGAL_PATH."/".$G_poll_name.".txt", 'w+');
+
+ if ($fp == FALSE) {
+ $mesg_to_user = nickserv_msg($dt, $mlang_indwr['commerr'][$G_lang]);
+ log_wr("break4");
+ break;
+ }
+
+ log_wr("poll: cp");
+ fseek($fp, 0);
+
+ log_wr("poll: cp2");
+ while (!feof($fp)) {
+ log_wr("poll: cp3");
+ $bf = fgets($fp, 4096);
+ log_wr("poll: cp3.1");
+ $arli = csplitter($bf, '|');
+ if (count($arli) == 0)
+ break;
+ log_wr("poll: cp3.2");
+ if (strcasecmp($arli[1], $user->name) == 0) {
+ $mesg_to_user = show_notify($mlang_indwr['pollagai'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110);
+ $dobreak = TRUE;
+ break;
+ }
+ }
+ log_wr("poll: cp4");
+
+ if ($dobreak) {
+ log_wr("break5");
+ break;
+ }
+
+ /* Unix time | nickname | choose */
+ fwrite($fp, sprintf("%ld|%s|%s\n", $curtime, xcapelt($user->name), xcapelt(urldecode($cli_choose))));
+ fflush($fp);
+ $mesg_to_user = show_notify($mlang_indwr['pollrec'][$G_lang], 0, $mlang_indwr['btn_close'][$G_lang], 400, 110);
+ $echont = "1";
+ log_wr("poll: cp5");
+ } while (0);
+
+ if ($fp != FALSE)
+ fclose($fp);
+
+ if ($poll_lock != FALSE)
+ Poll::unlock_data($poll_lock);
+
+ if ($mesg_to_user != "") {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ $user->comm[$user->step % COMM_N] .= $mesg_to_user;
+ $user->step_inc();
+ }
+
+ echo "$echont";
+ }
+
+ /******************
+ * *
+ * STAT: room *
+ * *
+ ******************/