PDA

View Full Version : Request: I believe this can be easily done but the problem is...


romanticyao
04-01-2003, 11:09 AM
:cry: I do not know how :banana:

i've just bought and installed HiveMail on my website and have it integrated with my vbulletin.

so now my user will automatically have an e-mail account setup for them once they register on my forum with the same user name and password... that sounds great and that's really what i was dreaming.

But then i realize I am exposed to a huge problem!!! I am going to have a international forum where people from everywhere are welcome(mainly asians) probably they are going to use all different languages such as Chinese,Japanese,Korean ect. for their username.

As you all know e-mail address can only contain letter from alphabet and Arabic numerals, obviously none of those asian languages would work. for example,if one of my user register as ijij(username), then he will get a e-mail address like this: ijij@mysite.com, any e-mail address look like that is totally useless.

Here comes my request, can someone make me a hack that restricts usernames, so I can prevent my users have their username registered in different languages that contain illegal letters?

it would be easier if we limit the range...let's say,

first of all, no space is allowed, user can only register their username with following a to z, 0 to 9 and something else that can be used in e-mail address...

Please help, really painful problem :cross-eyed:

romanticyao
04-01-2003, 11:22 AM
by the way, adding unwanted chars to admin cp/settings/illegal usernames doesn't work for me at all, there are thousands of individual characters just in one asian language, each character function as an "a" or "z"or whatever...

noppid
04-01-2003, 11:44 AM
Modify the username check used during registration to make sure only charaters from an array you define are used. A pre-processor to the built in one or mod the internal. I'd prefer pre-processing with a hack to moddin' original code. A nice tight loop to check the username and approve or bail out with a default invalid username message should do it.

romanticyao
04-01-2003, 11:47 AM
Today at 08:44 AM noppid said this in Post #3 (https://vborg.vbsupport.ru/showthread.php?postid=376311#post376311)
Modify the username check used during registration to make sure only charaters from an array you define are used. A pre-processor to the built in one or mod the internal. I'd prefer pre-processing with a hack to moddin' original code. A nice tight loop to check the username and approve or bail out with a default invalid username message should do it.


thank you, but sorry i still don't know how to do it.

noppid
04-01-2003, 11:53 AM
Define your list of approved charaters and I'll see wot I can do. It does not seem like a big deal...Hope I don't eat those words!

romanticyao
04-01-2003, 11:55 AM
Today at 08:53 AM noppid said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=376315#post376315)
Define your list of approved charaters and I'll see wot I can do. It does not seem like a big deal...Hope I don't eat those words!


lol. thank you! you guys are great. :banana:

noppid
04-01-2003, 11:59 AM
You forgot the list of charaters you want to allow.

romanticyao
04-01-2003, 12:08 PM
sorry about that, the list is simple:

first, no space in front, end or in-between of username.

seond, username may only contain alphanumeric characters, underscores (_) and dots (.), must start with a letter(not a number) and must be a minimum length of 2 characters.

that means only those letters are allowed in username:

a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y, z

and the numbers

0,1,2,3,4,5,6,7,8,9,

and "_ " " . "

noppid
04-01-2003, 12:12 PM
Cool, another cup of coffee and I'll try it out.

As I said, if I don't hit a wall and eat my words, you'll have something in a couple hours.

romanticyao
04-01-2003, 12:16 PM
That's very nice of you! thank you.

by the way, i am not sure if my list covered everything, just follow the basic rules for an e-mail address.

cheers!

Logician
04-01-2003, 01:09 PM
<a href="https://vborg.vbsupport.ru/showthread.php?s=&threadid=38725&highlight=register.php" target="_blank">https://vborg.vbsupport.ru/showt...t=register.php</a>

noppid
04-01-2003, 01:57 PM
Well there seems to be a solution already, but here's a way of doing it I came up with. It's a bit more code.


<?php
$alphas =
array( "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
"1","2","3","4","5","6","7","8","9","0",".","_");

$badfirsts=array( "1","2","3","4","5","6","7","8","9","0",".","_");

$username="user._1234";
$n=0;
$OK=0;
$badchar=0;
// make sure our name is more then 2 characters long. (redundant to vB code if min can be set to two )
if (strlen($username)< 2 ) {
//eval("standarderror(\"".gettemplate("error_usernametooshort")."\");");
echo "exit on strlen < then 2";
exit;
}

// make sure the first char is not a space (redundant, not necessary)
if ($username[0] == " " ) {
//eval("standarderror(\"".gettemplate("error_usernametaken")."\");");
echo "exit on first char == space";
exit;
}

// check each charater for validity
while(strlen($username)>$n) {
foreach ($alphas as $c ){
if ( $c == $username[$n] ) {
$OK=1;
if ($n == 0 ){
foreach ( $badfirsts as $b ) {
if ( $b == $username[$n] ) {
$OK=0;
$badchar = 1;
}
}
}
if ( $OK || $badchar) {
break;
}
}

} // end for each alphas

// if charater not OK stop reg and show error page
// else reset OK var and increment counter to check next char
if ( !$OK ) {
//eval("standarderror(\"".gettemplate("error_usernametaken")."\");");
echo "exit on " . $username[$n] . " is not a valid char";
exit;
}
else {
$OK = 0;
echo $username[$n];
$n++ ;
}


} // end while

echo "exit NORMAL.";

?>


You can name it something.php and test the code on your site by playing with the $username var. There are echo statements for the errors to test it. The evals should be changed to point to a new template as pointed out in the other hacks if used.