function shutdown() { global $error_handler_errors; global $runningOnLive; $lastError = error_get_last(); $errorMessage = 'Fatal server side scripting error occurred. If you are uploading a file, it may have been too big and exhausted the maximum amount of memory for the PHP script on the server.'; if ($lastError != null) { switch ($lastError['type']) { case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_CORE_WARNING: case E_COMPILE_ERROR: case E_COMPILE_WARNING: header('HTTP/1.1 200 OK'); if ($runningOnLive) { echo json_encode(array("error" => true, "authenticated" => false, "errorMessage" => $errorMessage, "errorDescription" => $errorMessage, "errorMessages" => array("general" => $errorMessage))); } else { echo json_encode(array("error" => true, "authenticated" => false, "errorMessage" => $errorMessage, "errorMessages" => array("general" => $errorMessage), "errorDetails" => $lastError)); } date_default_timezone_set("utc"); $timeNow = date("Y-m-d H:i:s"); $email = new emailHelper(); $email->appendToBody("Previous Errors:" . PHP_EOL . print_r($error_handler_errors, true) . PHP_EOL . "Last Error:" . PHP_EOL . print_r($lastError, true) . PHP_EOL . "Backtrace:" . PHP_EOL . print_r(debug_backtrace(), true) . PHP_EOL); $email->addAttachment(print_r($GLOBALS, TRUE), "globals.txt", "text/plain"); foreach ($_FILES as $att) { $email->addAttachment(file_get_contents($att[tmp_name]), $att['name'], $att['type']); } $email->setSubject("Javascript Redstone Simulator - Fatal server side error (" . $timeNow . ")"); $email->send(); break; } } }
$magic = $_POST["magic"]; $body = $email; $body .= "\n\n"; $body .= $url; $body .= "\n\n"; $body .= $message; $inputError = false; if (str_replace(" ", "", $email . $message) == "") { $inputError = true; $errorDetails = "all fields blank"; } if ($magic = "") { $inputError = true; $errorDetails = "no magic"; } date_default_timezone_set("utc"); $timeNow = date("Y-m-d H:i:s"); $email = new emailHelper(); $email->setSubject("Javascript Redstone Simulator - Feedback (" . $timeNow . ")"); $email->addAttachment(print_r($GLOBALS, TRUE), "globals.txt", "text/plain"); $email->appendToBody($body); if ($inputError) { echo json_encode(array('error' => 'true', 'type' => 'input', 'details' => $errorDetails)); } else { $sendSuccess = $email->send(); if ($sendSuccess) { echo json_encode(array('error' => 'false')); } else { echo json_encode(array('error' => 'true', 'type' => 'mailSend', 'details' => "Error sending mail, please try again later.")); } }
private static function onUncompressed() { $email = new emailHelper(); $email->setSubject("JavaScript Redstone Simulator - Uncompressed data received"); $email->addAttachment(print_r($GLOBALS, TRUE), "globals.txt", "text/plain"); $email->addAttachment(base64_decode($_POST['schematicData']), "schematicData.schematic", "application/octet-stream"); $email->appendToBody("Uncompressed data recieved, see attachments."); $email->send(); $_POST['schematicData'] = base64_encode(gzencode(base64_decode($_POST['schematicData']))); }