From 007ac6313b90e25faadcaf7d3952daa442f4b66b Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 17 Sep 2015 16:05:51 +0200 Subject: allow structured data in body --- it.class | 1 + 1 file changed, 1 insertion(+) (limited to 'it.class') diff --git a/it.class b/it.class index 05efbee..7416f81 100644 --- a/it.class +++ b/it.class @@ -204,6 +204,7 @@ static function error($p = array()) { $trace = it_debug::backtrace(array('skiplevels' => $p['backtraceskip'], 'skipfiles' => $p['skipfiles'])); # moved in here for performance in mass error case + $p['body'] = is_string($p['body']) ? $p['body'] : var_export($p['body'], true); if (strlen($p['body']) > 500000) { file_put_contents($datafn = "/tmp/alertdata/error-" . substr(md5($p['body']), 0, 2), $p['body']); -- cgit v1.2.3 From 044872a5afa7b7b2d3e758f32466bc331ac197ed Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 17 Sep 2015 17:57:36 +0200 Subject: no error body if NULL --- it.class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'it.class') diff --git a/it.class b/it.class index 7416f81..8c16c56 100644 --- a/it.class +++ b/it.class @@ -204,7 +204,7 @@ static function error($p = array()) { $trace = it_debug::backtrace(array('skiplevels' => $p['backtraceskip'], 'skipfiles' => $p['skipfiles'])); # moved in here for performance in mass error case - $p['body'] = is_string($p['body']) ? $p['body'] : var_export($p['body'], true); + $p['body'] = is_string($p['body']) || !$p['body'] ? $p['body'] : var_export($p['body'], true); if (strlen($p['body']) > 500000) { file_put_contents($datafn = "/tmp/alertdata/error-" . substr(md5($p['body']), 0, 2), $p['body']); -- cgit v1.2.3 From 745b56e0aecaa952aff61c47824a190f452cda36 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 12 Oct 2015 19:01:57 +0200 Subject: use pngcrush by default; smaller files, 10% performance hit --- it.class | 3 +++ 1 file changed, 3 insertions(+) (limited to 'it.class') diff --git a/it.class b/it.class index 8c16c56..2ab3c1d 100644 --- a/it.class +++ b/it.class @@ -693,6 +693,9 @@ static function imageconvert($p) if (in_array($type, explode(',', $p['types']))) # Valid type? $cmdoutput = it::exec('( ' . $ultratimeout . 'gm convert 2>&1 {-opts} {in} {type}:{out} || echo "SHELL ERROR $?" ) | grep -v " iCCP: "', $p); + if ($p['type'] == "png") + it::exec('(pngcrush.sh 2>/dev/null {out} {out}.tmp && mv {out}.tmp {out}); rm -f {out}.tmp', $p); + return $cmdoutput === ""; } -- cgit v1.2.3 From 5fc9447678d6079107a9c6fdc588cbd1679b76e7 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 12 Oct 2015 19:03:30 +0200 Subject: no need for subshell --- it.class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'it.class') diff --git a/it.class b/it.class index 2ab3c1d..f6a1713 100644 --- a/it.class +++ b/it.class @@ -694,7 +694,7 @@ static function imageconvert($p) $cmdoutput = it::exec('( ' . $ultratimeout . 'gm convert 2>&1 {-opts} {in} {type}:{out} || echo "SHELL ERROR $?" ) | grep -v " iCCP: "', $p); if ($p['type'] == "png") - it::exec('(pngcrush.sh 2>/dev/null {out} {out}.tmp && mv {out}.tmp {out}); rm -f {out}.tmp', $p); + it::exec('pngcrush.sh 2>/dev/null {out} {out}.tmp && mv {out}.tmp {out} || rm {out}.tmp', $p); return $cmdoutput === ""; } -- cgit v1.2.3 From 4e04d8fdf3befe81bd2a93190d5acb63059b131c Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 12 Oct 2015 19:49:09 +0200 Subject: dont pngcrush by default; runtime is prohibitive after all --- it.class | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'it.class') diff --git a/it.class b/it.class index f6a1713..9f9749e 100644 --- a/it.class +++ b/it.class @@ -652,6 +652,7 @@ static function cdist(/* $file1, ... */) * @param $p['types'] Comma separated list of accepted input types, default "bmp,eps,gif,jp2,jpg,png,svg,tif" * @param $p['quality'] JPEG quality (0-100), default is 75 * @param $p['keepalpha'] Don't add option --flatten to preserve alpha channel + * @param $p['pngcrush'] Use pngcrush for sm * @param $p['-opts'] Custom command line options to ImageMagick convert * @return Success of convert as true/false */ @@ -693,7 +694,7 @@ static function imageconvert($p) if (in_array($type, explode(',', $p['types']))) # Valid type? $cmdoutput = it::exec('( ' . $ultratimeout . 'gm convert 2>&1 {-opts} {in} {type}:{out} || echo "SHELL ERROR $?" ) | grep -v " iCCP: "', $p); - if ($p['type'] == "png") + if ($p['pngcrush'] && $p['type'] == "png") it::exec('pngcrush.sh 2>/dev/null {out} {out}.tmp && mv {out}.tmp {out} || rm {out}.tmp', $p); return $cmdoutput === ""; -- cgit v1.2.3 From 63b9d95ee4bce9188db0881159d163e35e2a19a4 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 14 Oct 2015 14:35:00 +0200 Subject: do not send mails if it::error was called in a function from e.g. @foo() --- it.class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'it.class') diff --git a/it.class b/it.class index 9f9749e..1b891f8 100644 --- a/it.class +++ b/it.class @@ -169,7 +169,7 @@ static function error($p = array()) if ($toscreen && !it::is_live()) $GLOBALS['debug_noredir'] = 1; - if (!$toscreen) # this error can only be sent by mail: find out if we want to suppress it + if (error_reporting() && !$toscreen) # not called with @ and this error can only be sent by mail: find out if we want to suppress it { if (!$p['id']) $sendmail = true; -- cgit v1.2.3 From d908cb0d4e147721970c7eff5bd24f112bdac4cd Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 29 Oct 2015 18:18:54 +0100 Subject: adapt backtraceskip to new it_debug::backtrace count --- it.class | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'it.class') diff --git a/it.class b/it.class index 1b891f8..073b2bf 100644 --- a/it.class +++ b/it.class @@ -144,7 +144,7 @@ static function error($p = array()) 'to' => $gods ? $gods : (get_current_user() ? get_current_user() : $_SERVER['SERVER_ADMIN']), 'graceperiod' => 60, 'timewindow' => 25*3600, - 'backtraceskip' => 0, + 'backtraceskip' => 1, 'blockmail' => 3600, 'omitdebuginfo' => false, 'failcount' => 2, -- cgit v1.2.3 From da71e326d6bbd7e531f0948cac99cf0c4d51ad6e Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 30 Oct 2015 15:37:17 +0100 Subject: minimal it::sort --- it.class | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'it.class') diff --git a/it.class b/it.class index 073b2bf..b097e60 100644 --- a/it.class +++ b/it.class @@ -1030,5 +1030,12 @@ static function json_decode($json) return ($data = json_decode($json)) === null && $json != 'null' ? it::error(array('title' => "invalid json", 'body' => $json)) : $data; } +static function sort($array, $mode = "") +{ + $func = it::replace(array('n' => ""), count_chars($mode, 3)) . "sort"; # count_chars sorts flags + $func($array, it::match('n', $mode) ? SORT_NUMERIC : 0); + + return $array; +} + } -?> -- cgit v1.2.3