PHP Registration not working on 7.4 - does not write into db

Viewed 18

I let Rector rewrite most of the Code from PHP 5.x to PHP 7.4 - It runs now but the Registration is giving me some problems. It does not write the Registration fields into the Database. I don't know PHP enough to pinpoint the exact error and the error_log is also not giving me anything. Hope some of you can tell me what exactly is wrong:

public function register( &$messages ) {

  DB::query( 'DELETE FROM '.TABLE_USERS.' WHERE valid = 0 AND registered < NOW() - INTERVAL 30 MINUTE' );

  if( !preg_match('/^\w{2,20}$/', $_POST['name']) ) {
   $messages['nameInvalid'] = true;
  } else {
   $u = DB::getRow( 'SELECT * FROM '.TABLE_USERS.' WHERE name = :1', $_POST['name'] );
   if( !empty($u) ) {
    $messages['nameInUse'] = true;
   }
  }
 
  if (strlen($_POST['pass']) < 6) {
      $messages['passToShort'] = true;
  } elseif ($_POST['pass'] != $_POST['pass2']) {
      $messages['passNotEqual'] = true;
  }
 
  if( !preg_match( '/^[\.\w\-]{1,}@[\.\w\-]{2,}\.[\w]{2,}$/', $_POST['email'] ) ) {
   $messages['wrongEmail'] = true;
  } else {
   $u = DB::getRow( 'SELECT * FROM '.TABLE_USERS.' WHERE email = :1', $_POST['email'] );
   if( !empty($u) ) {
    $messages['emailInUse'] = true;
   }
  }


  if( !empty($messages) ) {
   return false;
  }
 
 
  $this->validationString = md5(uniqid(rand()));
 
  DB::insertRow( TABLE_USERS, array(
   'registered' => date('Y-m-d H:i:s'),
   'name' => $_POST['name'],
   'pass' => md5($_POST['pass']),
   'valid' => 0,
   'score' => 0,
   'images' => 0,
   'website' => '',
   'avatar' => Config::$images['avatarsPath'].'default.png',
   'remember' => $this->validationString,
   'admin' => 0,
   'email' => $_POST['email']
  ));
 
  if( Config::$vbbIntegration['enabled'] ) {
   global $vbulletin;
   $forum = new ForumOps($vbulletin);
   $user['name'] = $_POST['name'];
   $user['pass'] = $_POST['pass'];
   $user['email'] = $_POST['email'];
   echo $forum->register_newuser($user, false);
  }
 
  $mail = file_get_contents( Config::$templates.'registrationmail.txt' );
  preg_match( '/From: (?<from>.*?)\r?\nSubject: (?<subject>.*?)\r?\n\r?\n(?<text>.*)/sim', $mail, $mail );
  $mail['text'] = str_replace( '%validationString%', $this->validationString, $mail['text'] );
  $mail['text'] = str_replace( '%siteName%', Config::$siteName, $mail['text'] );
  $mail['text'] = str_replace( '%frontendPath%', Config::$frontendPath, $mail['text'] );
  $mail['text'] = str_replace( '%userName%', $_POST['name'], $mail['text'] );
 
  $mail['subject'] = str_replace( '%siteName%', Config::$siteName, $mail['subject'] );
  $mail['subject'] = str_replace( '%userName%', $_POST['name'], $mail['subject'] );
 
  mail( $_POST['email'], $mail['subject'], $mail['text'], 'FROM: '.$mail['from'] );
  return true;
}
}
0 Answers
Related