BUGS |
------+
- - Not triple chars between letters
+ DONE - Not sequence of 3 same chars
+ DONE . check server side with test
<release>
- Global vars checker
- usermgmt: add user delete
--- /dev/null
+#!/usr/bin/php
+<?php
+
+$G_base = "web/";
+
+require_once('test/Obj/test.phh');
+require_once('web/Obj/brisk.phh');
+
+printf("testing internal_encoding: ");
+if (mb_internal_encoding() != "UTF-8") {
+ printf("mb_internal_encoding from cli/php.ini: [%s], FIX with UTF-8\n", mb_internal_encoding());
+ exit(1);
+}
+else {
+ printf("UTF-8, OK\n");
+}
+
+$nam = array ("ò12345678912", "ò123456789123", "pippo", "pìppo", "zorrro", "pìììppo");
+
+if (mb_strlen($nam[0]) != 12) {
+ printf("mb_strlen not return expected len (12) but %d\n", mb_strlen($nam[0]));
+ exit(1);
+}
+
+for ($i = 0 ; $i < count($nam) ; $i++) {
+ printf("[%s] %s\n", $nam[$i], (login_consistency($nam[$i]) ? "TRUE" : "FALSE"));
+}
+
+?>
\ No newline at end of file
}
}
+function login_consistency($name)
+{
+ $old_c = '';
+ if (($len = mb_strlen($name)) > 12) {
+ return FALSE;
+ }
+ for ($i = 0 ; $i < mb_strlen($name) ; $i++) {
+ $c = mb_substr($name, $i, 1);
+ if (mb_ereg_match ("[a-zA-Z0-9]", $c)) {
+ if ($old_c != $c) {
+ $old_c = $c;
+ $old_ct = 1;
+ }
+ else {
+ $old_ct++;
+ if ($old_ct > 2) {
+ return (FALSE);
+ }
+ }
+ }
+ else {
+ return (FALSE);
+ }
+ }
+ return (TRUE);
+}
?>
// check existence of username or email
$is_trans = FALSE;
do {
+ error_log($cli_name);
+ if (login_consistency($cli_name) == FALSE) {
+ $mesg_to_user = "Il nickname non è conforme alle regole per la sua costruzione.";
+ break;
+ }
+
if (($bdb = BriskDB::create()) == FALSE) {
$mesg_to_user = "Connessione al database fallita";
break;
(login[i] >= 'A' && login[i] <= 'Z')) {
if (old_c != login[i]) {
old_c = login[i];
- old_ct = 0;
+ old_ct = 1;
}
else {
- if (old_ct > 3) {
+ if (old_ct > 2) {
// FIXME LANG
- ret.ret = (g_lang == 'en' ? "More than three contiguous '" + old_c + "' not allowed." :
- "Il nickname contiene più di tre caratteri '" + old_c + "' consecutivi.");
+ ret.ret = (g_lang == 'en' ? "More than two contiguous '" + old_c + "' not allowed." :
+ "Il nickname contiene più di 2 caratteri '" + old_c + "' consecutivi.");
return (false);
}
}