Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Blocking "User Creation" with special characters and spaces in "Username"?  (Read 2840 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: 15764

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: 15764

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.021 seconds with 19 queries.