Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions incl/lib/mainLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,11 @@ public function songReupload($url){
if (filter_var($song, FILTER_VALIDATE_URL) == TRUE && substr($song, 0, 4) == "http") {
$song = str_replace(["?dl=0","?dl=1"],"",$song);
$song = trim($song);
$query = $db->prepare("SELECT count(*) FROM songs WHERE download = :download");
$query = $db->prepare("SELECT id FROM songs WHERE download = :download");
$query->execute([':download' => $song]);
$count = $query->fetchColumn();
if($count != 0){
return "-3";
$id = $query->fetchColumn();
if($id != false){
return $id;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code lacks the song existence check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a good PHPer, but $id != false should do the trick

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no issues with your code.

}
$name = ExploitPatch::remove(urldecode(str_replace([".mp3",".webm",".mp4",".wav"], "", basename($song))));
$author = "Reupload";
Expand Down
4 changes: 1 addition & 3 deletions tools/songAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
exit("Invalid captcha response");

$result = $gs->songReupload($_POST['songlink']);
if($result == "-4"){
if($result == "-4")
echo "This URL doesn't point to a valid audio file.";
}elseif($result == "-3")
echo "This song already exists in our database.";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the song exists in the database, it still returns the "song uploaded" message with the ID. It may be confusing. Consider adding "song already exists" but still returning the ID of the already uploaded song.

@Galster-dev Galster-dev Jul 2, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also thought about this, but the problem is about concept of this "API". It (mainlib function) is expected to return an integer where if > 0 then it is id, if <= 0 assume it failed. We should ask @Cvolton about designing this

@EMREOYUN EMREOYUN Jul 3, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still removes the capability of the error text "This song already exists in our database." Yes, your code still returns the ID of the song, very well but removing the existing error still be confusable.

I guess we need @Cvolton's opinion on that.

elseif($result == "-2")
echo "The download link isn't a valid URL";
else
Expand Down