-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathresults.php
84 lines (77 loc) · 2.47 KB
/
results.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php require_once('assets/includes/sonicflow.php'); ?>
<?php include('header.html'); ?>
<?php
$provider = $_GET['provider'];
$searchResults;
$providerName;
switch ($provider) {
case 'sonicflow':
$search_song = mb_ereg_replace('\\s\\s+', " ", trim($_GET['search_song']));
$search_album = mb_ereg_replace('\\s\\s+', " ", trim($_GET['search_album']));
$search_artist = mb_ereg_replace('\\s\\s+', " ", trim($_GET['search_artist']));
$search = $search_song . ' ' . $search_album . ' ' . $search_artist;
$search = trim(mb_ereg_replace('\\s\\s+', " ", $search));
$searchResults = getSonicFlowResults($search_song, $search_album, $search_artist);
$providerName = "SonicFlow";
// If nothing is in SonicFlow, then default to Grooveshark
if (count($searchResults) > 0) {
break;
} else {
$provider = "grooveshark";
}
case 'grooveshark':
if (!isset($search)) {
$search = trim($_GET['searchString']);
}
$searchResults = getGroovesharkResults($search);
$providerName = "Grooveshark";
break;
default:
$searchResults = NULL;
break;
}
if (is_null($searchResults)) {
?>
<div class="errorMessage">
<p>Something went wrong. Please hit the back button and try
again.</p>
</div>
<?php
} else {
$numResults = count($searchResults);
?>
<p><span id="resultCount"><?php echo $numResults; ?></span>
results in <?php echo $providerName; ?> for
"<span id="searchPhrase"><?php echo $search; ?></span>":</p>
<div class="results">
<ul class="songs">
<?php
foreach ($searchResults as $s) {
?>
<li onclick="submit(<?php echo $s->id; ?>);">
<img class="albumArt" src="<?php echo getArtLoc($s->albumId); ?>" alt="Song Album" />
<div class="songTitle"><?php echo $s->title; ?></div>
<div class="songArtist"><?php echo $s->artist; ?></div>
<div class="songAlbum"><?php echo $s->album; ?></div>
<form id="<?php echo $s->id;?>" action="addsong.php" method="post">
<input type="hidden" name="id" value="<?php echo $s->id; ?>" />
</form>
</li>
<?php
}
?>
</ul>
</div>
<?php
}
if ($provider == 'sonicflow') {
?>
<form action="results.php" method="get">
<input type="submit" value="Song not listed" />
<input type="hidden" name="searchString" value="<?php echo $search ?>" />
<input type="hidden" name="provider" value="grooveshark" />
<form>
<?php
}
?>
<?php include('footer.html'); ?>