From 7ea5b129e6ea03cabdbd67e566f0e352486cdd30 Mon Sep 17 00:00:00 2001 From: hatstand0 Date: Thu, 25 Sep 2014 23:42:41 +1000 Subject: Fix thumbnail width/height in API The API currently has the thumbnail widths and heights switched around --- inc/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index a8ae9eed..d7b28ee9 100644 --- a/inc/api.php +++ b/inc/api.php @@ -41,8 +41,8 @@ class Api { ); $this->fileFields = array( - 'thumbheight' => 'tn_w', - 'thumbwidth' => 'tn_h', + 'thumbheight' => 'tn_h', + 'thumbwidth' => 'tn_w', 'height' => 'w', 'width' => 'h', 'size' => 'fsize', -- cgit v1.3 From d27cddaaccc68eaa1b37b3a0694ba3e40a8fe049 Mon Sep 17 00:00:00 2001 From: hatstand0 Date: Fri, 26 Sep 2014 00:09:14 +1000 Subject: Add file hash to API The API currently lacks the Base64 encoded file hash 4chan's API provides, which assists in file de-duplication by archive software. --- inc/api.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index d7b28ee9..3769a9c9 100644 --- a/inc/api.php +++ b/inc/api.php @@ -113,6 +113,7 @@ class Api { $apiPost['ext'] = substr($file->file, $dotPos); $dotPos = strrpos($file->file, '.'); $apiPost['tim'] = substr($file->file, 0, $dotPos); + $apiPost['md5'] = base64_encode(md5_file($file->file_path, true)); } return $apiPost; -- cgit v1.3 From ef53af04ec42359d66489b10dee0f4f1778c3b0a Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 27 Sep 2014 11:31:30 +0200 Subject: fix a recently added md5 api field --- inc/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index 3769a9c9..31cf2293 100644 --- a/inc/api.php +++ b/inc/api.php @@ -113,7 +113,7 @@ class Api { $apiPost['ext'] = substr($file->file, $dotPos); $dotPos = strrpos($file->file, '.'); $apiPost['tim'] = substr($file->file, 0, $dotPos); - $apiPost['md5'] = base64_encode(md5_file($file->file_path, true)); + $apiPost['md5'] = base64_encode(hex2bin($post->filehash)); } return $apiPost; -- cgit v1.3 From d266908ca92c003ca81de899b0ae7d8cd9d948a4 Mon Sep 17 00:00:00 2001 From: clsr Date: Thu, 16 Oct 2014 17:08:39 +0200 Subject: Fix API: Swap image width/height, make replies an integer, fix original filename --- inc/api.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index 31cf2293..600b1096 100644 --- a/inc/api.php +++ b/inc/api.php @@ -43,10 +43,9 @@ class Api { $this->fileFields = array( 'thumbheight' => 'tn_h', 'thumbwidth' => 'tn_w', - 'height' => 'w', - 'width' => 'h', + 'height' => 'h', + 'width' => 'w', 'size' => 'fsize', - 'file' => 'filename', ); if (isset($config['api']['extra_fields']) && gettype($config['api']['extra_fields']) == 'array'){ @@ -65,6 +64,8 @@ class Api { 'fsize' => 1, 'omitted_posts' => 1, 'omitted_images' => 1, + 'replies' => 1, + 'images' => 1, 'sticky' => 1, 'locked' => 1, 'last_modified' => 1 @@ -108,10 +109,9 @@ class Api { if (isset($post->files) && $post->files && !$threadsPage) { $file = $post->files[0]; $this->translateFields($this->fileFields, $file, $apiPost); + $apiPost['filename'] = substr($file->name, 0, strrpos($file->name, '.')); $dotPos = strrpos($file->file, '.'); - $apiPost['filename'] = substr($file->file, 0, $dotPos); $apiPost['ext'] = substr($file->file, $dotPos); - $dotPos = strrpos($file->file, '.'); $apiPost['tim'] = substr($file->file, 0, $dotPos); $apiPost['md5'] = base64_encode(hex2bin($post->filehash)); } -- cgit v1.3 From 49079e57fb52fd694f0fc173778270e1f0e7a433 Mon Sep 17 00:00:00 2001 From: clsr Date: Thu, 16 Oct 2014 17:26:58 +0200 Subject: Fix expanded tabs --- inc/api.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index 600b1096..c9608f06 100644 --- a/inc/api.php +++ b/inc/api.php @@ -64,8 +64,8 @@ class Api { 'fsize' => 1, 'omitted_posts' => 1, 'omitted_images' => 1, - 'replies' => 1, - 'images' => 1, + 'replies' => 1, + 'images' => 1, 'sticky' => 1, 'locked' => 1, 'last_modified' => 1 @@ -109,7 +109,7 @@ class Api { if (isset($post->files) && $post->files && !$threadsPage) { $file = $post->files[0]; $this->translateFields($this->fileFields, $file, $apiPost); - $apiPost['filename'] = substr($file->name, 0, strrpos($file->name, '.')); + $apiPost['filename'] = substr($file->name, 0, strrpos($file->name, '.')); $dotPos = strrpos($file->file, '.'); $apiPost['ext'] = substr($file->file, $dotPos); $apiPost['tim'] = substr($file->file, 0, $dotPos); -- cgit v1.3 From 50b80e9e2452cfffadeb6918150736a4dde7834a Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:06:44 +0100 Subject: ... (slug api) --- inc/api.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index c9608f06..351943a3 100644 --- a/inc/api.php +++ b/inc/api.php @@ -33,6 +33,7 @@ class Api { 'sticky' => 'sticky', 'locked' => 'locked', 'bump' => 'last_modified', + 'slug' => 'semantic_url', ); $this->threadsPageFields = array( -- cgit v1.3 From 6c4d3941fa729558f4a5313081c85b0a06202e54 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:22:29 +0100 Subject: api fix --- inc/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index c9608f06..661ee109 100644 --- a/inc/api.php +++ b/inc/api.php @@ -109,7 +109,7 @@ class Api { if (isset($post->files) && $post->files && !$threadsPage) { $file = $post->files[0]; $this->translateFields($this->fileFields, $file, $apiPost); - $apiPost['filename'] = substr($file->name, 0, strrpos($file->name, '.')); + $apiPost['filename'] = isset($file->name) ? substr($file->name, 0, strrpos($file->name, '.')) : ""; $dotPos = strrpos($file->file, '.'); $apiPost['ext'] = substr($file->file, $dotPos); $apiPost['tim'] = substr($file->file, 0, $dotPos); -- cgit v1.3 From 4a22ee9245b81e9a94bcc18128cf9ad10d19d901 Mon Sep 17 00:00:00 2001 From: 8chan Date: Thu, 30 Oct 2014 05:33:01 -0700 Subject: Extra files and IDs in API Conflicts: inc/api.php --- inc/api.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index ac3b1325..eb99d3fb 100644 --- a/inc/api.php +++ b/inc/api.php @@ -86,11 +86,22 @@ class Api { } } + private function translateFile($file, $post, &$apiPost) { + $this->translateFields($this->fileFields, $file, $apiPost); + $apiPost['filename'] = @substr($file->name, 0, strrpos($file->name, '.')); + $dotPos = strrpos($file->file, '.'); + $apiPost['ext'] = substr($file->file, $dotPos); + $apiPost['tim'] = substr($file->file, 0, $dotPos); + $apiPost['md5'] = base64_encode(hex2bin($post->filehash)); + } + private function translatePost($post, $threadsPage = false) { + global $config, $board; $apiPost = array(); $fields = $threadsPage ? $this->threadsPageFields : $this->postFields; $this->translateFields($fields, $post, $apiPost); + if (isset($config['poster_ids'])) $apiPost['id'] = poster_id($post->ip, $post->thread, $board['uri']); if ($threadsPage) return $apiPost; // Handle country field @@ -109,12 +120,19 @@ class Api { // Note: 4chan only supports one file, so only the first file is taken into account for 4chan-compatible API. if (isset($post->files) && $post->files && !$threadsPage) { $file = $post->files[0]; - $this->translateFields($this->fileFields, $file, $apiPost); - $apiPost['filename'] = isset($file->name) ? substr($file->name, 0, strrpos($file->name, '.')) : ""; - $dotPos = strrpos($file->file, '.'); - $apiPost['ext'] = substr($file->file, $dotPos); - $apiPost['tim'] = substr($file->file, 0, $dotPos); - $apiPost['md5'] = base64_encode(hex2bin($post->filehash)); + $this->translateFile($file, $post, $apiPost); + if (sizeof($post->files) > 1) { + $extra_files = array(); + foreach ($post->files as $i => $f) { + if ($i == 0) continue; + + $extra_file = array(); + $this->translateFile($f, $post, $extra_file); + + $extra_files[] = $extra_file; + } + $apiPost['extra_files'] = $extra_files; + } } return $apiPost; -- cgit v1.3 From e35d261ff48e38ea109e29feeed7f8edaaf82b4a Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 05:32:38 +0200 Subject: enable embed field for api --- inc/api.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index eb99d3fb..f8f2a71c 100644 --- a/inc/api.php +++ b/inc/api.php @@ -1,4 +1,4 @@ - 'sticky', 'locked' => 'locked', 'bump' => 'last_modified', + 'embed' => 'embed', 'slug' => 'semantic_url', ); -- cgit v1.3 From 5a9af83ba64fcc5547f3c5206121cff3992a3663 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 05:50:52 +0200 Subject: better slugify support for api --- inc/api.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index f8f2a71c..a057f4ed 100644 --- a/inc/api.php +++ b/inc/api.php @@ -34,7 +34,6 @@ class Api { 'locked' => 'locked', 'bump' => 'last_modified', 'embed' => 'embed', - 'slug' => 'semantic_url', ); $this->threadsPageFields = array( @@ -117,6 +116,10 @@ class Api { } } + if ($config['slugify'] && !$post->thread) { + $apiPost['semantic_url'] = $post->slug; + } + // Handle files // Note: 4chan only supports one file, so only the first file is taken into account for 4chan-compatible API. if (isset($post->files) && $post->files && !$threadsPage) { -- cgit v1.3 From 8cf28682e74baf592df8b0949e76922fa76de08e Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Fri, 3 Apr 2015 08:03:15 -0400 Subject: Removed tab at start of api.php to fix ban list and possibly other stuff --- inc/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/api.php') diff --git a/inc/api.php b/inc/api.php index a057f4ed..b77fa3f8 100644 --- a/inc/api.php +++ b/inc/api.php @@ -1,4 +1,4 @@ -