
March 17th, 2006
02:59 PM
dahnhilla
Status: Offline!
neverside registering and subdomain
Hey,
I'm trying to acheive user profiles, like you have here eg. username.domain.com
I'm going to use SMF as my member base and forum, and my own gallery script, both work perfectly 
My question is related to this:
Because your neverside account will comes with a .neverside.com subdomain (Unavailable at the moment), we have to restrict the characters you can use in your username. You may only use letters, numbers, the underscore (_) character and the hyphen (-) character. Also, you may not use underscores or hyphens as the first or last character of your username, and you may not use adjacent ones.
How do you detect:
1. Underscores or hyphens at beginning or end (and remove them?)
2. Adjacent underscores/hyphens
2. How to remove anything that isnt a underscore, hyphen, number or letter?
Thanks!
___________________


March 18th, 2006
01:37 PM
Everywhere you go. There you are.
Status: Offline!
I'd say pass the entry data through a function, like so:
<?php
function boldme ($text)
{
$search = array(
'#\[b\](.*?)\[/b\]#' //this finds [b] text [/b]
);
$replace = array(
'<b>\\1</b>' //this replaces it with <b> Text </b>
);
return preg_replace($search , $replace, $text);
}
?>
I know that isn't what you're looking for exactly, thats just the method, I took that from my BBCode filter function. Just search for erroneous characters and replace them with ones that work. Or you could send back to the user that you can't have those certain characters, and force them to try again.
Theres probably a better way to do that, but I've never done anything like that, so I can only give you a suggestion.
Hope that helped, good luck.
___________________
Koreans stole my domain.
Last edited by Rook, March 18th, 2006 01:39 PM (Edited 1 times)

March 18th, 2006
02:38 PM
Neversidian
Status: Offline!
<?php
$finds = array('/[^a-z0-9_-]/i', '/(__|-_|_-|--)/', '/^([_-]+)/', '/([_-]+)$/');
echo preg_replace($finds, '', $username);
?>
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

March 19th, 2006
03:07 PM
dahnhilla
Status: Offline!
Bingo! That worked, thanks BigToach!
Also thank you Substance, yours would have worked too, but Toach put the characters into it, and i'm a lazy so n so 
NS rules 
___________________

Last edited by celldamage, March 19th, 2006 03:07 PM (Edited 1 times)

March 20th, 2006
03:27 AM
i do my crosswords in pen
Status: Offline!
Err... We can use underscores as the first character. For example, me! 

March 20th, 2006
05:20 AM
Neversidian
Status: Offline!
No we can't, remember I changed yours individually. You are the special one with it like that.
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

March 20th, 2006
06:58 AM
Nobody fucks with my title.
Status: Offline!
Plus your subdomain doesn't work: http://_jordan.neverside.com/
Sucks for you!
___________________
<3

March 20th, 2006
07:26 AM
Everywhere you go. There you are.
Status: Offline!
Originally posted by Noel:
I don't know if that was joke, but it works just fine for me:
___________________
Koreans stole my domain.

March 20th, 2006
08:37 AM
ruby on weapon
Status: Offline!
yep, works for me too 
___________________
digitalDream // complete Webdesign solution //
- - - - - - [ end signature ] - - - - - -

March 20th, 2006
01:08 PM
Neversidian
Status: Offline!
sux for noel it appears
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!