-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcore.php
More file actions
34 lines (29 loc) · 1.18 KB
/
core.php
File metadata and controls
34 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// Collection of utility functions used by user-facing web scripts.
empty($keepCWD) and chdir(__DIR__);
error_reporting(-1);
ignore_user_abort(false);
setlocale(LC_ALL, 'en_US.UTF-8');
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
set_error_handler(function ($severity, $msg, $file, $line) {
throw new ErrorException($msg, 0, $severity, $file, $line);
}, -1);
// Specifically doesn't use JSON_PRETTY_PRINT to always return a single line as
// required by api.php (SSE data in chat and WatchdogSSE, possibly other cases).
function encodeJsonLine($data) {
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
// Used in place of htmlspecialchars() strictly when inserting a
// JSON-conforming $str into a <script> or <template> block that is
// part of an HTML 5 document. Taken from NoDash's
// _.escape() documentation.
//
// Usually used to embed value of a variable: var x = <?=...
function escapeHtmlScriptJSON($str) {
return preg_replace('~<(!--|/?script)~iu', '\\x3C$1', $str);
}
function mailAdmin($id, $title, $body) {
$headers = 'Content-Type: text/plain; charset=utf-8';
return mail("herowo+$id", "[HeroWO] $title", $body, $headers);
}