[How To] Update existing v3.3 Main Events to PHP 7.4

Hi,

recently my server updated its PHP version from 7.2 to the 7.4.18 version. In my 3.3 version of Maian Events only a few errors showed up, so I'm gonna tell you how to fix them till David don't release the new version (no rush David, take all the time you need).

You only have to edit 2 files. Remember to make a backup of the files before editing them.

1st File:

/control/classes/system/class.errors.php

Find:

function msFatalErr() {
  global $MSEH;
  $error = error_get_last();
  if ($error['type'] == E_ERROR || $error['type'] == 4) {
    $string = '[Error Code: ' . $error['type'] . '] ' . $error['message'] . linending();
    $string .= '[Date/Time: ' . date('j F Y @ H:iA') . ']' . linending();
    $string .= '[Fatal error on line ' . $error['line'] . ' in file ' . $error['file'] . ']';
    if (ERR_HANDLER_DISPLAY) {
      echo '<div style="background:#ff9999"><p style="padding:10px;color:#fff">A fatal error has occurred. For more details please view "' . ERR_HANDLER_LOG_FOLDER . '/' . FILE_FATAL_ERR_LOG_FILE . '".</div>';
    }
    $MSEH->fatalErr($string);
  }
}

and replace it with:

function msFatalErr() {
  global $MSEH;
  $error = error_get_last();
  if ((isset($error['type']) && $error['type'] == E_ERROR) || (isset($error['type']) && $error['type'] == 4)) {
    $string = '[Error Code: ' . $error['type'] . '] ' . $error['message'] . linending();
    $string .= '[Date/Time: ' . date('j F Y @ H:iA') . ']' . linending();
    $string .= '[Fatal error on line ' . $error['line'] . ' in file ' . $error['file'] . ']';
    if (ERR_HANDLER_DISPLAY) {
      echo '<div style="background:#ff9999"><p style="padding:10px;color:#fff">A fatal error has occurred. For more details please view "' . ERR_HANDLER_LOG_FOLDER . '/' . FILE_FATAL_ERR_LOG_FILE . '".</div>';
    }
    $MSEH->fatalErr($string);
  }
}


2nd file:

/control/functions.php

Find:

function mswCD($data) {
  if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    $sybase = strtolower(@ini_get('magic_quotes_sybase'));
    if (empty($sybase) || $sybase == 'off') {
      // Fixes issue of new line chars not parsing between single quotes..
      $data = str_replace('\n', '\\\n', $data);
      return stripslashes($data);
    }
  }
  return $data;
}

and replace it with:

function mswCD($data) {
  if (function_exists('get_magic_quotes_gpc')) {
    $sybase = strtolower(@ini_get('magic_quotes_sybase'));
    if (empty($sybase) || $sybase == 'off') {
      // Fixes issue of new line chars not parsing between single quotes..
      $data = str_replace('\n', '\\\n', $data);
      return stripslashes($data);
    }
  }
  return $data;
}

And find in the same file:

function mswSQL($data) {
  if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
    $sybase = strtolower(@ini_get('magic_quotes_sybase'));
    if (empty($sybase) || $sybase == 'off') {
      $data = stripslashes($data);
    } else {
      $data = mswDAP($data);
    }
  }
  $data = ((isset($GLOBALS['___mysqli_dbcon']) && is_object($GLOBALS['___mysqli_dbcon'])) ? mysqli_real_escape_string($GLOBALS['___mysqli_dbcon'], $data) : ((trigger_error("Fix the mysqli_real_escape_string() call, this code does not work.", E_USER_ERROR)) ? "" : ""));
  return $data;
}

And replace it with:

function mswSQL($data) {
  if (function_exists('get_magic_quotes_gpc')) {
    $sybase = strtolower(@ini_get('magic_quotes_sybase'));
    if (empty($sybase) || $sybase == 'off') {
      $data = stripslashes($data);
    } else {
      $data = mswDAP($data);
    }
  }
  $data = ((isset($GLOBALS['___mysqli_dbcon']) && is_object($GLOBALS['___mysqli_dbcon'])) ? mysqli_real_escape_string($GLOBALS['___mysqli_dbcon'], $data) : ((trigger_error("Fix the mysqli_real_escape_string() call, this code does not work.", E_USER_ERROR)) ? "" : ""));
  return $data;
}

Save both files, upload them and your version of Maian Events will be ready for PHP 7.4