From 188f961f7c57ad75e6b2c03bdb295530b0ee0930 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 22 Jun 2022 20:39:47 +0200 Subject: [PATCH] add some stuff to the api, to match vichan's api at the request of a user. fixed the delete-stray-images script --- inc/api.php | 3 +++ tools/delete-stray-images.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/inc/api.php b/inc/api.php index a60d9b41..cf507302 100644 --- a/inc/api.php +++ b/inc/api.php @@ -95,6 +95,9 @@ class Api { $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); if (isset ($file->thumb) && $file->thumb) { $apiPost['spoiler'] = $file->thumb === 'spoiler'; } diff --git a/tools/delete-stray-images.php b/tools/delete-stray-images.php index 1c334afd..36962730 100755 --- a/tools/delete-stray-images.php +++ b/tools/delete-stray-images.php @@ -23,10 +23,10 @@ foreach ($boards as $board) { $valid_thumb = array(); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - $files = json_decode($post['files']); + $files = json_decode($post['files']); foreach ($files as $i => $f) { if ($f->file != 'deleted' && $f->file != 'spoiler' && $f->file != 'file'){ - $valid_src[] = $f->filename; + $valid_src[] = $f->file; $valid_thumb[] = $f->thumb; } }