From a92961f24072bc4c3881bf0e2f609562f3703471 Mon Sep 17 00:00:00 2001 From: pantsucat Date: Fri, 18 Sep 2015 10:27:07 +1000 Subject: Add text response class This allows for text only output which removes the complexity of many bash uploader scripts. --- static/classes/Response.class.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'static') diff --git a/static/classes/Response.class.php b/static/classes/Response.class.php index e9f647d..c44230d 100755 --- a/static/classes/Response.class.php +++ b/static/classes/Response.class.php @@ -12,6 +12,11 @@ class Response header('Content-Type: text/plain; charset=UTF-8'); $this->type = $response_type; break; + case 'text': + header('Content-Type: text/plain; charset=UTF-8'); + $this->type = $response_type; + break; + case 'html': header('Content-Type: text/html;charset=utf-8'); $this->type = 'html'; @@ -34,6 +39,9 @@ class Response case 'gyazo': $response = $this->gyazo_error($code, $desc); break; + case 'text': + $response = $this->text_error($code, $desc); + break; case 'html': $response = $this->html_error($code, $desc); break; @@ -60,6 +68,9 @@ class Response case 'gyazo': $response = $this->gyazo_success($files); break; + case 'text': + $response = $this->text_success($files); + break; default: $response = $this->json_success($files); break; @@ -96,6 +107,20 @@ class Response { return POMF_URL.$files[0]['url']; } + private static function txt_error($code, $description) + { + return 'ERROR: ('.$code.') '.$description; + } + + private static function text_success($files) + { + foreach ($files as $file) { + $result .= POMF_URL.$files[0]['url']; + } + + return $result; + } + private static function html_error($code, $description) { return 'ERROR: ('.$code.') '.$description; -- cgit v1.2.3