From 0d74e59634fb6b1e2c14c5dac928d299a48bf73f Mon Sep 17 00:00:00 2001 From: Junior Date: Wed, 16 Apr 2025 15:38:49 -0400 Subject: [PATCH] Only print author's name on book when searching or when it doesn't match the folder the book is in (usually multi-author) --- ajax/getcontents.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ajax/getcontents.php b/ajax/getcontents.php index 8a08b00..a4f81bd 100644 --- a/ajax/getcontents.php +++ b/ajax/getcontents.php @@ -28,6 +28,7 @@ if ( isset($_REQUEST['search']) && ($_REQUEST['search'] != "") ) { $searchfor = strtolower(str_replace(["\"", "'", "/", "\\"], "", $_REQUEST['search'])); $searchfor = "%{$searchfor}%"; } +$data["searching"] = $searching; $query = "SELECT email FROM amazon WHERE username=:username"; $sth = $globaldbh->prepare($query); @@ -61,7 +62,12 @@ if ( !$searching ) { } else { $item['folder'] = false; $item['fullpath'] = $row['path'] . "/" . $row['filename']; - $item['displayname'] = htmlspecialchars(basename($row['filename'])); + $dname = basename($row['filename']); + if ( (substr($row['path'], 1) == substr($row['filename'], 0, strlen(substr($row['path'], 1)))) && (strpos($row['filename'], " - ") !== false) ) { + $item['displayname'] = htmlspecialchars(substr(basename($row['filename']), strpos($row['filename'], " - ")+3)); + } else { + $item['displayname'] = htmlspecialchars(basename($row['filename'])); + } $item['id'] = $row['id']; if ( $cankindle && (substr($row['filename'], -4) == "epub") ) { $item['cankindle'] = true; @@ -104,6 +110,11 @@ if ( !$searching ) { $item['fullpath'] = $row['path'] . "/" . $row['filename']; $item['displayname'] = htmlspecialchars(basename($row['filename'])); $item['id'] = $row['id']; + if ( $cankindle && (substr($row['filename'], -4) == "epub") ) { + $item['cankindle'] = true; + } else { + $item['cankindle'] = false; + } $data['contents'][] = $item; } }