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 From 5ad07e817a65d058b493bbeaaf00b8d60fe13f27 Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Fri, 18 Sep 2015 00:45:58 +0000 Subject: Revert ShareX / URL change commits These commits are ShareX issues, not Pomf issues. Allowing these commits to be in the source reduces maintainability. This reverts commits bbcffe8d745937677352edf25e6a250ca8fd507b, 943e7e62a8ca814d47168bcebf2cc92dbce9a45a and partially 1411bce1dc13bf6fea66b5899ba29d50d5c53bb0. --- static/classes/Response.class.php | 2 +- static/upload.php | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'static') diff --git a/static/classes/Response.class.php b/static/classes/Response.class.php index c44230d..4f18a12 100755 --- a/static/classes/Response.class.php +++ b/static/classes/Response.class.php @@ -129,7 +129,7 @@ class Response private static function html_success($files) { foreach ($files as $file) { - $result .= "".$file['url']."
"; + $result .= "".$file['url']."
"; } return $result; diff --git a/static/upload.php b/static/upload.php index 21ae386..0504e54 100644 --- a/static/upload.php +++ b/static/upload.php @@ -93,10 +93,11 @@ function upload_file($file) $result = $q->fetch(); if ($result['count'] > 0) { unlink($file->tempfile); + return array( 'hash' => $file->get_sha1(), 'name' => $file->name, - 'url' => $result['filename'], + 'url' => POMF_URL.$result['filename'], 'size' => $file->size, ); } @@ -131,10 +132,11 @@ function upload_file($file) $q->bindValue(':exp', null, PDO::PARAM_STR); $q->bindValue(':del', sha1($file->tempfile), PDO::PARAM_STR); $q->execute(); + return array( 'hash' => $file->get_sha1(), 'name' => $file->name, - 'url' => $newname, + 'url' => POMF_URL.$newname, 'size' => $file->size, ); } else { @@ -194,7 +196,6 @@ function refiles($files) } $type = isset($_GET['output']) ? $_GET['output'] : 'json'; - $response = new Response($type); if (isset($_FILES['files'])) { @@ -211,5 +212,3 @@ if (isset($_FILES['files'])) { } else { $response->error(400, 'No input file(s)'); } - - -- cgit v1.2.3 From 25b7f821e9a572c2bded5f7a95785e5fde592c82 Mon Sep 17 00:00:00 2001 From: pantsucat Date: Fri, 18 Sep 2015 11:36:51 +1000 Subject: Fix url generation bug --- static/classes/Response.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'static') diff --git a/static/classes/Response.class.php b/static/classes/Response.class.php index 4f18a12..951e39e 100755 --- a/static/classes/Response.class.php +++ b/static/classes/Response.class.php @@ -115,7 +115,7 @@ class Response private static function text_success($files) { foreach ($files as $file) { - $result .= POMF_URL.$files[0]['url']; + $result .= $file['url']."\n"; } return $result; -- cgit v1.2.3