Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Blocking "User Creation" with special characters and spaces in "Username"?  (Read 2594 times)

0 Members and 1 Guest are viewing this topic.

fmk

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
    • FMKz Test Bed

Hi Guys,

A newbie + no programmer.

I need help with blocking "User Creation" with special characters and spaces in Usernames. I have edited text instructions in lang/english.php accordingly but want such attempts to be prohibited.

http://igallery.khanz.net

Thanks in advance.
Logged
FMK

Love doesn't stop by my door, I am always infatuated with new things.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765

What shall happen if you detect unwanted characters? Do you want to automatically replace them? Do you want to display an error message? Which characters to you want to allow?
Logged

fmk

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
    • FMKz Test Bed

Allowed characters - Users must register with either "firstname.lastname" or "firstname" or "lastname. I want a-z allowed and No spaces, and special characters like hyphen, underscores, etc. My users are able to register with a space in the user name.

Q-What shall happen if unwanted characters are detected?
A-Page should return an error asking user for correction. Form data should not be lost though.

Q-Do you want to automatically replace them?
A-Its a nice idea, but users may get confused, so No.
Logged
FMK

Love doesn't stop by my door, I am always infatuated with new things.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765

Open register.php, find
Code: [Select]
    if (utf_strlen($user_name) < 2) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['username_warning2'] . '</li>';
    }
and replace with
Code: [Select]
    if (utf_strlen($user_name) < 2) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . $lang_register_php['username_warning2'] . '</li>';
    } elseif (preg_match('/[^A-Za-z]/', $user_name)) {
        $error .= '<li style="list-style-image:url(images/icons/stop.png)">' . 'Username must only contain a-z' . '</li>';
    }
Logged

fmk

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 28
    • FMKz Test Bed

Works great. Thanks a lot Andre.
Logged
FMK

Love doesn't stop by my door, I am always infatuated with new things.
Pages: [1]   Go Up
 

Page created in 0.016 seconds with 19 queries.