From e941e33787f5686885b88070a68005aa1eab5273 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Tue, 13 Oct 2015 07:13:59 +0200 Subject: [PATCH] apprentice self-registration completed --- web/brisk.css | 4 ++-- web/index.php | 22 +++++++++----------- web/index_wr.php | 36 ++++++++++++++++++++++++--------- web/mailmgr.php | 2 +- web/room.css | 48 ++++++++++++++++++++++---------------------- web/room.js | 9 +++++++-- webtest/mailtest.php | 14 ++++++------- webtest/test_db.php | 29 ++++++++++++++++++++++++-- 8 files changed, 103 insertions(+), 61 deletions(-) diff --git a/web/brisk.css b/web/brisk.css index c2eef51..bcf1636 100644 --- a/web/brisk.css +++ b/web/brisk.css @@ -40,8 +40,8 @@ body { background-color: #fafafa; background-repeat: no-repeat; background-position: center center; - margin:0px; - + margin: 0px; + height: 800px; padding: 0px; align: center; diff --git a/web/index.php b/web/index.php index a982dcf..99e4011 100644 --- a/web/index.php +++ b/web/index.php @@ -1106,29 +1106,25 @@ window.onload = function() {

-

+




-



-



-



-



-



@@ -1322,11 +1318,11 @@ xstm = new xynt_streaming(window, "", 80, 2, null / " +"" type="submit" onclick="this.form.elements['realsub'].value = 'invia';" class="button">      " +"" type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chiudi';"> @@ -1346,8 +1342,8 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi -       - +       + diff --git a/web/index_wr.php b/web/index_wr.php index 05e8a73..1d0b61e 100644 --- a/web/index_wr.php +++ b/web/index_wr.php @@ -2,7 +2,7 @@ /* * brisk - index_wr.php * - * 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 @@ -70,6 +70,10 @@ $mlang_indwr = array( 'unknownerr' => array( 'it' => 'errore sconosciuto', 'en' => '
You or someone with your same IP address is standing up from a table without the permission of the other players

You will wait '), 'badsit_b' => array( 'it' => ' prima di poterti sedere nuovamente.

Se non sei stato tu ad alzarti e possiedi un login con password, autenticandoti con quello, potrai accedere.', 'en' => ' before you can sit down again. If you don\'t leave the table and you have a login with a password, authenticating with this one you will access'), + 'nu_netguard' => array('it' => "Di recente è già arrivata una richiesta da un indirizzo IP simile al tuo, riprova tra qualche tempo.", + 'en' => "EN di recente è già arrivata una richiesta da un indirizzo IP simile al tuo, riprova tra qualche tempo."), + 'nu_unkerr' => array('it' => "Si è verificato un errore inatteso, contattare l'amministratore.", + 'en' => "EN Si è verificato un errore inatteso, contattare l'amministratore."), 'nu_loginau' => array('it' => "login già in uso", 'en' => "login already in use"), 'nu_emailau' => array('it' => "email già utilizzata", @@ -128,6 +132,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) log_load("index_wr.php"); $remote_addr = addrtoipv4($remote_addr_full); + $remote_ip = ip2int($remote_addr); if (($mesg = gpcs_var('mesg', $get, $post, $cookie)) === FALSE) unset($mesg); @@ -222,7 +227,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) 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] == 'apprendice') { + else if ($argz[0] == 'apprentice') { if (($cli_name = gpcs_var('cli_name', $get, $post, $cookie)) === FALSE) $cli_name = ""; @@ -237,7 +242,11 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) if (($bdb = BriskDB::create()) == FALSE) break; - // FIXME: CHECK IP AS PREVIOUS REQUIRER + // check IP address as previous requirer + if ($bdb->selfreg_check($remote_ip) == FALSE) { + $mesg_to_user = $mlang_indwr['nu_netguard'][$G_lang]; + break; + } $cli_name = urldecode($cli_name); $cli_email = urldecode($cli_email); @@ -278,12 +287,6 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) $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 @@ -291,8 +294,21 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie) break; } - echo "1"; + // check IP address as previous requirer + if ($bdb->selfreg_set($remote_ip) == FALSE) { + $mesg_to_user = $mlang_indwr['nu_unkerr'][$G_lang]; + break; + } + + if (brisk_mail($cli_email, $subj, $body_txt, $body_htm) == FALSE) { + // mail error + fprintf(STDERR, "ERROR: mail send FAILED\n"); + break; + } + $bdb->transaction('COMMIT'); + fprintf(STDERR, "REMOTE: %d\n", $remote_ip); + echo "1"; return TRUE; } while(FALSE); $bdb->transaction('ROLLBACK'); diff --git a/web/mailmgr.php b/web/mailmgr.php index 5ea14b6..c2e89ee 100644 --- a/web/mailmgr.php +++ b/web/mailmgr.php @@ -72,7 +72,7 @@ function main() { } $bdb->transaction('COMMIT'); - singlemsg("Verifica della e-mail andata a buon fine.", "Verifica della e-mail andata a buon fine."); + singlemsg("Verifica della e-mail andata a buon fine.", "Verifica della e-mail andata a buon fine.
Riceverai a breve una email con la tua nuova password.
Benvenuto!"); $errcode = 0; } while (FALSE); if ($errcode) { diff --git a/web/room.css b/web/room.css index d3af1ab..c709a3a 100644 --- a/web/room.css +++ b/web/room.css @@ -2,7 +2,7 @@ * brisk - room.css * * Copyright (C) 2006-2012 Matteo Nastasi - * mailto: nastasi@alternativeoutput.it + * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it * @@ -43,7 +43,7 @@ a.flat:hover { body.* { - margin:0px; + margin: 0px; padding: 0px; } @@ -71,7 +71,7 @@ div.topmenu { } div.proflash { - border: 1px solid gray; + border: 1px solid gray; background-color: RGB(246,246,246); text-align: center; align: center; @@ -89,7 +89,7 @@ div.bottom { top: -13px; align: center: text-align: center; - padding:2px; + padding:2px; clear:left; } @@ -106,7 +106,7 @@ span.room_titin { left: 6px; top: 6px; z-index: 20; - background-color: white; + background-color: white; } table.floaty { @@ -130,8 +130,8 @@ table.placings { table.placings td { - border: 1px solid gray; - padding: auto; + border: 1px solid gray; + padding: auto; margin: auto; vertical-align: top; text-align: center; @@ -198,10 +198,10 @@ table.room_tab td { div.room_div { - position: relative; + position: relative; } -div.table_act { +div.table_act { position: absolute; align: right; text-align: right; @@ -212,7 +212,7 @@ div.table_act { div.room_standup { - position: absolute; + position: absolute; vertical-align: "top"; top: 26px; width: 100%; @@ -224,7 +224,7 @@ div.room_standup { } table.room_standup { - position: relative; + position: relative; width: 100%; border: 1px solid gray; border-spacing: 0px; @@ -233,19 +233,19 @@ table.room_standup { table.room_standup td { position: relative; - border: 0px none gray; + border: 0px none gray; vertical-align: top; align: left; } -table.login { +table.login { margin: auto; border: 1px solid gray; margin-top: 8px; background-color: #f0f0f0 } -table.login td { +table.login td { padding: 4px; vertical-align: middle; } @@ -262,7 +262,7 @@ div.room_ex_standup { table.table_standup { border-spacing: 0px; - width: 100%; + width: 100%; margin: 0px; padding:0px; } @@ -299,7 +299,7 @@ div.esco { text-align: center; } -.proxhr { +.proxhr { position: relative; top: 10px; width: 100%; @@ -307,10 +307,10 @@ div.esco { text-align: center; } -.webstart_hilite { - background: #ffd780; +.webstart_hilite { + background: #ffd780; border: 1px solid #ffae00; - padding: 6px; + padding: 6px; text-align: center; } @@ -322,7 +322,7 @@ div.esco { visibility: hidden; border: 1px solid gray; text-align: left; - width: 100px; + width: 100px; padding: 8px; } @@ -439,19 +439,19 @@ div.esco { visibility: hidden; } -.room_standup_orig { +.room_standup_orig { position: absolute; } -td.tickbut { - visibility: hidden; +td.tickbut { + visibility: hidden; width: 0px; text-align: left; vertical-align: top; padding: 0px; } -img.tickbut { +img.tickbut { border: 0px solid black; cursor: pointer; margin-top:4px; diff --git a/web/room.js b/web/room.js index 0fd7ac1..89ee03c 100644 --- a/web/room.js +++ b/web/room.js @@ -523,12 +523,17 @@ function j_check_login(login, ret) } -function j_new_apprendice(form) +function j_new_apprentice(form) { var ret = { ret: '' }; var token; do { + if (form.elements['realsub'].value == "close") { + $('apprentice_div').style.display = 'none'; + break; + } + if (j_check_login(form.elements['nameid'].value, ret) == false || j_check_email(form.elements['emailid'].value, ret) == false) { @@ -693,7 +698,7 @@ function j_mesgtoadmbox(form) var no; do { - if (form.elements['realsub'].value == "chiudi") { + if (form.elements['realsub'].value == "cloid") { $('mesgtoadmbox').style.visibility = "hidden"; break; } diff --git a/webtest/mailtest.php b/webtest/mailtest.php index b1ad066..99dcac2 100644 --- a/webtest/mailtest.php +++ b/webtest/mailtest.php @@ -28,9 +28,9 @@ La verifica del tuo indirizzo di posta elettronica e del tuo nickname è andata d'ora in poi potrai utilizzare l' utente 'mopz' e la password 'ienxedsiyndo'. Benvenuto e buone partite, mop."; - $body_htm_full = "Ciao, sono l' amministratore del sito di Brisk.

-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 'mopz' e la password 'ienxedsiyndo'.
-Benvenuto e buone partite, mop.
"; + $body_htm_full = "Ciao, sono l' amministratore del sito di Brisk.

+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 'mopz' e la password 'ienxedsiyndo'.
+Benvenuto e buone partite, mop.
"; $html = 'mysòóbject testmy BòóodyClicca quì'; @@ -51,9 +51,9 @@ La verifica del tuo indirizzo di posta elettronica e del tuo nickname è andata d'ora in poi potrai utilizzare l' utente 'mopz' e la password 'ienxedsiyndo'. Benvenuto e buone partite, mop."; - $body_htm = "Ciao, sono l' amministratore del sito di Brisk.

-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 'mopz' e la password 'ienxedsiyndo'.
-Benvenuto e buone partite, mop.
"; + $body_htm = "Ciao, sono l' amministratore del sito di Brisk.

+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 'mopz' e la password 'ienxedsiyndo'.
+Benvenuto e buone partite, mop.
"; $body_htm_full = sprintf("%s%s", $subject, $body_htm); @@ -66,4 +66,4 @@ else { echo "ERROR"; } -?> \ No newline at end of file +?> diff --git a/webtest/test_db.php b/webtest/test_db.php index 8817058..21a77ad 100644 --- a/webtest/test_db.php +++ b/webtest/test_db.php @@ -2,7 +2,7 @@ /* * brisk - test_db.php * - * Copyright (C) 2014 Matteo Nastasi + * Copyright (C) 2014-2015 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -75,7 +75,7 @@ function main() { succ("CREATE TABLE test_ip"); foreach ($arr_ip as $i) { - $v = ip2int($i); + $v = ip2four($i); $msg = sprintf("  INSERT INTO test_ip [%s] val: [%d (%x)]", $i, $v, $v); if ($bdb->query(sprintf("INSERT INTO test_ip (ip, atime) VALUES (%d, '1999-01-08 04:05:06');", $v)) == FALSE) { @@ -85,6 +85,31 @@ function main() { } succ($msg); } + printf("
\n"); + foreach ($arr_ip as $i) { + $cmp = int2four(ip2int($i) & 0xffffff00); + $msk = int2four(0xffffff00); + $cmp_que = sprintf("SELECT * FROM test_ip WHERE (ip & %d = %d);", $msk, $cmp); + if (($cmp_pg = $bdb->query($cmp_que)) == FALSE) { + printf("%s
\n", $bdb->last_error()); + fail("SELECT * FROM test_ip"); + break; + } + succ($cmp_que); + + for ($r = 0 ; $r < pg_numrows($cmp_pg) ; $r++) { + $cmp_obj = pg_fetch_object($cmp_pg, $r); + + if ($ip_obj->ip & $msk != $cmp) { + fail(sprintf("  Expected: %s, retrieved: %s", int2ip($cmp), int2ip($ip_obj->ip & $msk))); + } + else { + succ(sprintf("  Expected: %s (%s)", int2ip($cmp), int2ip($cmp_obj->ip))); + } + // printf("RET IP: %d IP: %s
\n", $ip_obj->ip, $v)); + } + } + printf("
\n"); if (($ip_pg = $bdb->query(sprintf("SELECT * FROM test_ip ORDER BY code;"))) == FALSE) { printf("%s
\n", $bdb->last_error()); -- 2.17.1