isSMTP(); // Set the SMTP server host $mail->Host = Config::get('smtp_server'); // Do we require authentication? $mail->SMTPAuth = Config::get('smtp_auth'); // Do we encrypt as well? $mail->SMTPSecure = Config::get('smtp_secure'); // Set the port to the SMTP server $mail->Port = Config::get('smtp_port'); // If authentication is required log in as well if (Config::get('smtp_auth')) { $mail->Username = Config::get('smtp_username'); $mail->Password = base64_decode(Config::get('smtp_password')); } // Add a reply-to header $mail->addReplyTo(Config::get('smtp_replyto_mail'), Config::get('smtp_replyto_name')); // Set a from address as well $mail->setFrom(Config::get('smtp_from_email'), Config::get('smtp_from_name')); // Set the addressee foreach ($to as $email => $name) { $mail->addBCC($email, $name); } // Subject line $mail->Subject = $subject; // Set body $mail->Body = $body; // Send the message $send = $mail->send(); // Clear the addressee list $mail->clearAddresses(); // If we got an error return the error if (!$send) { return $mail->ErrorInfo; } // Else just return whatever return $send; } function error_handler($errno, $errstr, $errfile, $errline) { // Remove ROOT path from the error string and file location $errstr = str_replace(ROOT, '', $errstr); $errfile = str_replace(ROOT, '', $errfile); switch ($errno) { case E_ERROR: case E_USER_ERROR: $error = 'FATAL ERROR: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; break; case E_WARNING: case E_USER_WARNING: $error = 'WARNING: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; break; case E_NOTICE: case E_USER_NOTICE: $error = 'NOTICE: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; break; default: $error = 'Unknown error type [' . $errno . ']: ' . $errstr . ' on line ' . $errline . ' in ' . $errfile; } // Truncate all previous outputs ob_clean(); ob_end_clean(); // Check for dev mode $detailed = Config::local('dev', 'show_errors'); // Build page $errorPage = ' Sakura Internal Error

An error occurred while executing the script.

To prevent potential security risks or data loss Sakura has stopped execution of the script.

'; if (isset($errid)) { $errorPage .= '

The error and surrounding data has been logged.

' . (!$detailed ? 'Report the following text to a staff member' : 'Logged as') . '

' . $errid . '
'; } else { $errorPage .= '

Sakura was not able to log this error which could mean that there was an error with the database connection. If you\'re the system administrator check the database credentials and make sure the server is running and if you\'re not please let the system administrator know about this error if it occurs again.

'; } if ($detailed) { $errorPage .= '

Summary

' . $error . '

Backtraces

'; foreach (debug_backtrace() as $num => $trace) { $errorPage .= '

#' . $num . '

';

            foreach ($trace as $key => $val) {
                $errorPage .=
                str_pad(
                    '[' . $key . ']',
                    12
                ) . '=> ' . (
                    is_array($val) || is_object($val) ?
                    json_encode($val) :
                    $val
                ) . "\r\n";
            }

            $errorPage .= '
'; } } $errorPage .= '
'; // Die and display error message die($errorPage); }