diff options
| author | pantsucat <contact@pantsu.cat> | 2015-09-18 02:27:07 +0200 |
|---|---|---|
| committer | pantsucat <contact@pantsu.cat> | 2015-09-18 02:27:07 +0200 |
| commit | 3117188a94f288a318ea64cb9c87baec251893c3 (patch) | |
| tree | 30e9084b3ac722f56456a0f9c83a642057ce5e27 | |
| parent | 00647b3c4e969767c1dc05fd0a51f6819530cd6c (diff) | |
Add text response class
| -rwxr-xr-x | static/classes/Response.class.php | 25 |
1 files changed, 25 insertions, 0 deletions
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; |
