Author Topic: [FIX] - Register.php  (Read 9911 times)

0 Members and 1 Guest are viewing this topic.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
[FIX] - Register.php
« on: September 08, 2007, 05:40:00 PM »
Detail: Check valid chars before register account in DB.

Action: Register

Find:

Quote
$user_name = (isset($HTTP_POST_VARS['user_name'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_name'])) : "";
$user_name = ereg_replace("( ){2,}", " ", $user_name);
$user_password = (isset($HTTP_POST_VARS['user_password'])) ? trim($HTTP_POST_VARS['user_password']) : "";  
$user_email = (isset($HTTP_POST_VARS['user_email'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_email'])) : "";
$user_showemail = (isset($HTTP_POST_VARS['user_showemail'])) ? intval($HTTP_POST_VARS['user_showemail']) : 0;
$user_allowemails = (isset($HTTP_POST_VARS['user_allowemails'])) ? intval($HTTP_POST_VARS['user_allowemails']) : 1;
$user_invisible = (isset($HTTP_POST_VARS['user_invisible'])) ? intval($HTTP_POST_VARS['user_invisible']) : 0;
$user_homepage = (isset($HTTP_POST_VARS['user_homepage'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_homepage'])) : "";
$user_icq = (isset($HTTP_POST_VARS['user_icq'])) ? ((intval(trim($HTTP_POST_VARS['user_icq']))) ? intval(trim($HTTP_POST_VARS['user_icq'])) : "") : "";

replace:

Code: [Select]
$user_name = (isset($HTTP_POST_VARS['user_name'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['user_name'])) : "";
$user_name = preg_replace("/'[^a-z0-9_-]+/i", "", $user_name);
$user_name = preg_replace("/( ){2,}+/i", " ", $user_name);
$user_name = format_text(trim($user_name), 2);
$user_password = (isset($HTTP_POST_VARS['user_password'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['user_password'])) : "";  
$user_password = preg_replace("/[^A-Za-z0-9_-]+/i", "", $user_password);  
$user_password = format_text(trim($user_password), 2);
$user_email = (isset($HTTP_POST_VARS['user_email'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['user_email'])) : "";
  if (isset($user_email)) {  
      if (function_exists('mailchek') && !function_exists('check_email') && mailchek($user_email, 2)) {        
          } elseif (function_exists('check_email') && !function_exists('mailchek') && check_email($user_email)) {              
      }              
  }
$user_showemail = (isset($HTTP_POST_VARS['user_showemail'])) ? intval($HTTP_POST_VARS['user_showemail']) : 0;
$user_showemail = preg_replace("/[^0-9]+/i", "", $user_showemail);
$user_allowemails = (isset($HTTP_POST_VARS['user_allowemails'])) ? intval($HTTP_POST_VARS['user_allowemails']) : 1;
$user_allowemails = preg_replace("/[^0-9]+/i", "", $user_allowemails);
$user_invisible = (isset($HTTP_POST_VARS['user_invisible'])) ? intval($HTTP_POST_VARS['user_invisible']) : 0;
$user_invisible = preg_replace("/[^0-9]+/i", "", $user_invisible);
  if (isset($HTTP_POST_VARS['user_homepage']) && preg_match('@^(?:http|https://)?([^/]+)@i', $HTTP_POST_VARS['user_homepage'])) {
  $user_homepage = (isset($HTTP_POST_VARS['user_homepage'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['user_homepage'])) : "";
  }
$user_icq = (isset($HTTP_POST_VARS['user_icq'])) ? ((intval(trim($HTTP_POST_VARS['user_icq']))) ? intval(trim($HTTP_POST_VARS['user_icq'])) : "") : "";
$user_icq = preg_replace("/[^0-9]+/i", "", $user_icq);
« Last Edit: August 27, 2011, 02:19:07 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [FIX] - Register.php
« Reply #1 on: September 14, 2007, 10:19:45 PM »
Find:

Quote
$site_email->register_vars(array(
          "user_name" => $row[$user_table_fields['user_name']],
          "site_name" => $config['site_name']
        ));
        $site_email->set_body("activation_success", $config['language_dir']);
        $site_email->send_email();

replace:

Code: [Select]
$site_email->register_vars(array(
          "user_name" => format_text(trim($row[$user_table_fields['user_name']]), 2),
          "site_name" => format_text($config['site_name'], 2)
        ));
        $site_email->set_body("activation_success", $config['language_dir']);
        $site_email->send_email();
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [FIX] - Register.php
« Reply #2 on: September 17, 2007, 03:26:56 PM »
I fix 1st post for $user_name and $user_password.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

 

Post your comments here