From e51f90f7565182cf2fa13e54aa4235becbe72beb Mon Sep 17 00:00:00 2001 From: redrun Date: Mon, 6 Jan 2025 23:51:09 -0600 Subject: [PATCH 1/2] Validator: Fix zero-size files (no curl fetches!) Fixes #119, by removing the Validator code that would fetch MP3 files from remote servers. This was useful before Uploader became prevalent, but we no longer need the feature now. --- application/controllers/private/Validator.php | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/application/controllers/private/Validator.php b/application/controllers/private/Validator.php index d91e9f2f..d39d343c 100644 --- a/application/controllers/private/Validator.php +++ b/application/controllers/private/Validator.php @@ -298,10 +298,6 @@ function copy_project_files() { $file_name = $this->_copy_file($local_file, $copy_to_dir); } - else - { - $file_name = $this->_get_file($section->listen_url, $copy_to_dir); - } if (!$file_name) continue; @@ -528,38 +524,6 @@ function _copy_file($local_file, $copy_to_dir) return ($copied) ? $file_name : false; } - function _get_file($file_url, $copy_to_dir) - { - set_time_limit(0); - - $file_name = $this->_get_file_name_from_url($file_url); - - $fp = fopen($copy_to_dir . '/' . $file_name, 'w'); - - $ch = curl_init($file_url); - - curl_setopt_array($ch, array( - CURLOPT_URL => $file_url, - CURLOPT_RETURNTRANSFER => 1, - //CURLOPT_FILE => $fp, - CURLOPT_TIMEOUT => 50 - - )); - - $results = curl_exec($ch); - if (curl_errno($ch)) - { - return false; - } - - curl_close($ch); - - fwrite($fp, $results); //old style, let me debug something. TODO: update - fclose($fp); - - return $file_name; - } - function _get_file_name_from_url($url) { $query_marker = strpos($url, '?'); @@ -851,15 +815,6 @@ function test_copy_file() echo $copied; } - function test_copy_remote_file() - { - $listen_url = 'http://upload.librivox.org/share/uploads/rg/aristopia_00_holford.mp3'; - $listen_url = 'https://librivox.local/librivox-validator-books/the_secret_garden_1308/aristopia_00_holford.mp3'; - $copy_to_dir = 'C:/test_files/'; - - $this->_get_file($listen_url, $copy_to_dir); - } - function test_get_file() { //echo 'TEST'; @@ -897,10 +852,6 @@ function test_get_file() { $file_name = $this->_copy_file($local_file, $copy_to_dir); } - else - { - $file_name = $this->_get_file($section->listen_url, $copy_to_dir); - } if (!$file_name) { From 724e9d98a3e02be410b7300d6bd991a552e19740 Mon Sep 17 00:00:00 2001 From: redrun Date: Tue, 7 Jan 2025 00:20:19 -0600 Subject: [PATCH 2/2] Cleanup: skip sending unused JSON This data, when returned by this endpoint, is never used in the js client[1]. It also causes server-side warnings! A little bit of progress for #153. [1]: https://github.com/LibriVox/librivox-catalog/blob/master/public_html/js/private/validator/index.js#L29 --- application/controllers/private/Validator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/private/Validator.php b/application/controllers/private/Validator.php index d39d343c..fc34d2d2 100644 --- a/application/controllers/private/Validator.php +++ b/application/controllers/private/Validator.php @@ -324,7 +324,7 @@ function copy_project_files() $this->librivox_id3tag->_update_section($section->id, array('file_name' => $file_name, 'playtime' => $playtime)); } - $this->ajax_output(array('message' => 'Files copied.', 'tags' => $tag_data, 'full_tags' => $fullid3_tags), TRUE); + $this->ajax_output(array('message' => 'Files copied.'), TRUE); } function get_file_tags()