diff --git a/include/classes/user.class.php b/include/classes/user.class.php index a8d0f308..7cb0d58b 100644 --- a/include/classes/user.class.php +++ b/include/classes/user.class.php @@ -741,9 +741,11 @@ class User extends Base { $this->setErrorMessage('Username exceeding character limit'); return false; } - if (!$this->bitcoin->validateaddress($coinaddress)) { - $this->setErrorMessage('Coin address is not valid'); - return false; + if (!is_null($coinaddress)) { + if (!$this->bitcoin->validateaddress($coinaddress)) { + $this->setErrorMessage('Coin address is not valid'); + return false; + } } if (preg_match('/[^a-z_\-0-9]/i', $username)) { $this->setErrorMessage('Username may only contain alphanumeric characters'); @@ -841,7 +843,7 @@ class User extends Base { } else { $this->setErrorMessage( 'Unable to register' ); $this->debug->append('Failed to insert user into DB: ' . $this->mysqli->error); - if ($stmt->sqlstate == '23000') $this->setErrorMessage( 'Username or email already registered' ); + if ($stmt->sqlstate == '23000') $this->setErrorMessage( 'Username, email or Coinaddress already registered' ); return false; } return false; diff --git a/include/config/global.inc.dist.php b/include/config/global.inc.dist.php index ca1069dd..9d4e0343 100644 --- a/include/config/global.inc.dist.php +++ b/include/config/global.inc.dist.php @@ -15,6 +15,12 @@ $config['version_url'] = 'https://raw.githubusercontent.com/MPOS/php-mpos/master */ $config['skip_config_tests'] = false; +/** + * Unless you disable this, we'll do a check for a valid coin address on registration. + * https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-coin-address-check + */ +$config['check_valid_coinaddress'] = true; + /** * Defines * Debug setting and salts for hashing passwords diff --git a/include/pages/register/register.inc.php b/include/pages/register/register.inc.php index 60d988c6..87f856ee 100644 --- a/include/pages/register/register.inc.php +++ b/include/pages/register/register.inc.php @@ -26,10 +26,15 @@ if ($setting->getValue('disable_invitations') && $setting->getValue('lock_regist if ($setting->getValue('recaptcha_enabled') != 1 || $setting->getValue('recaptcha_enabled_registrations') != 1 || $rsp->is_valid) { // Check if recaptcha is enabled, process form data if valid or disabled isset($_POST['token']) ? $token = $_POST['token'] : $token = ''; - if ($user->register(@$_POST['username'], @$_POST['coinaddress'], @$_POST['password1'], @$_POST['password2'], @$_POST['pin'], @$_POST['email1'], @$_POST['email2'], @$_POST['tac'], $token)) { - (!$setting->getValue('accounts_confirm_email_disabled')) ? $_SESSION['POPUP'][] = array('CONTENT' => 'Please check your mailbox to activate this account') : $_SESSION['POPUP'][] = array('CONTENT' => 'Account created, please login'); + isset($_POST['coinaddress']) ? $validcoinaddress = $_POST['coinaddress'] : $validcoinaddress = NULL; + if ($config['check_valid_coinaddress'] AND empty($validcoinaddress)) { + $_SESSION['POPUP'][] = array('CONTENT' => 'Please enter a valid Wallet Address', 'TYPE' => 'alert alert-danger'); } else { - $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to create account: ' . $user->getError(), 'TYPE' => 'alert alert-danger'); + if ($user->register(@$_POST['username'], $validcoinaddress, @$_POST['password1'], @$_POST['password2'], @$_POST['pin'], @$_POST['email1'], @$_POST['email2'], @$_POST['tac'], $token)) { + (!$setting->getValue('accounts_confirm_email_disabled')) ? $_SESSION['POPUP'][] = array('CONTENT' => 'Please check your mailbox to activate this account') : $_SESSION['POPUP'][] = array('CONTENT' => 'Account created, please login'); + } else { + $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to create account: ' . $user->getError(), 'TYPE' => 'alert alert-danger'); + } } } } else { diff --git a/include/smarty_globals.inc.php b/include/smarty_globals.inc.php index b94b661d..b45b1eda 100644 --- a/include/smarty_globals.inc.php +++ b/include/smarty_globals.inc.php @@ -63,6 +63,7 @@ $aGlobal = array( 'reward' => $config['reward_type'] == 'fixed' ? $config['reward'] : $block->getAverageAmount(), 'price' => $setting->getValue('price'), 'twofactor' => $config['twofactor'], + 'coinaddresscheck' => $config['check_valid_coinaddress'], 'csrf' => $config['csrf'], 'config' => array( 'date' => $setting->getValue('system_date_format', '%m/%d/%Y %H:%M:%S'), diff --git a/templates/bootstrap/register/default.tpl b/templates/bootstrap/register/default.tpl index 722f903f..2f49357b 100644 --- a/templates/bootstrap/register/default.tpl +++ b/templates/bootstrap/register/default.tpl @@ -22,11 +22,13 @@ + {if $GLOBAL.coinaddresscheck|default:"1"}