git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 74ec1c34 authored by Jonas Haraldsson's avatar Jonas Haraldsson

Move noSpamTracks() calls

Move noSpamTracks() calls from scrobble-utils.php to
submissions/1.2/index.php to filter out spam once per string and as
soon as possible
parent 81dff9fb
......@@ -48,8 +48,6 @@ function useridFromSID($session_id) {
function createArtistIfNew($artist) {
global $adodb;
$artist = NoSpamTracks($artist);
$id = $adodb->GetOne('SELECT id FROM Artist WHERE lower(name) = lower(' . $artist . ')');
if (!$id) {
......@@ -86,9 +84,6 @@ function createAlbumIfNew($artist, $album) {
function getTrackCreateIfNew($artist, $album, $track, $mbid) {
global $adodb;
$track = NoSpamTracks($track);
$artist = NoSpamTracks($artist);
if ($album != 'NULL') {
$res = $adodb->GetOne('SELECT id FROM Track WHERE lower(name) = lower(' . $track . ') AND lower(artist_name) = lower(' . $artist . ') AND lower(album_name) = lower(' . $album . ')');
} else {
......@@ -152,7 +147,7 @@ function scrobbleExists($userid, $artist, $track, $time) {
}
}
function NoSpamTracks($track) {
function noSpamTracks($track) {
// This function exists to remove things like '(PREVIEW: buy it at www.magnatune.com)' from track names.
$track = str_replace(' (PREVIEW: buy it at www.magnatune.com)', '', $track);
......
......@@ -53,6 +53,7 @@ for ($i = 0; $i < count($_POST['a']); $i++) {
}
$artist = trim($_POST['a'][$i]);
$artist = noSpamTracks($artist);
if (empty($artist)) {
//Add error message to db and skip to next scrobble
reportError("FAILED Track $i was submitted with empty artist field",
......@@ -70,6 +71,7 @@ for ($i = 0; $i < count($_POST['a']); $i++) {
}
$track = trim($_POST['t'][$i]);
$track = noSpamTracks($track);
if (empty($track)) {
//Add error message to db and skip to next scrobble
reportError("FAILED Track $i was submitted with empty track field",
......@@ -95,6 +97,7 @@ for ($i = 0; $i < count($_POST['a']); $i++) {
}
$album = trim($_POST['b'][$i]);
$album = noSpamTracks($album);
if (!empty($album)) {
switch (mb_detect_encoding($album)) {
case 'ASCII':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment