+function error($message, $status = 500)
+{
+ http_response_code($status);
+ if ($page = @fopen('widget.html', 'r')) {
+ # copy static page contents until page body
+ while (!feof($page)) {
+ print $line = fgets($page);
+ if (preg_match('/<body\b/', $line)) break;
+ }
+ }
+ else {
+ print '<html><body>';
+ }
+ print "<p>$message</p>\n";
+ print "</body>\n</html>\n";
+ exit;
+}
+