-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrecently_played.php
95 lines (62 loc) · 2.67 KB
/
recently_played.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
85
86
87
88
89
90
91
92
93
94
95
<?php
function displaycover($album, $ratio, $param='cover', $AlbumsToBeHighlighted = -1, $highlightcounter = 0){
/******
This is a frozen -and slightly modified- version from displaycover 20220729 from index.html
* Please keep track of issue in the original function if any
* and correct this one
*/
if (file_exists('./d/covers.txt')){
if ($highlightcounter<$AlbumsToBeHighlighted){
$ratio=$ratio*2;
}
$coversfile=trim(file_get_contents('./d/covers.txt'));
$coverslines=explode("\n", $coversfile);
$i=0;
$url=null;
while ($i<count($coverslines)){
if ($coverslines[$i]===html_entity_decode($album)){
if (isset($coverslines[$i+1])){
$url=$coverslines[$i+1];
}
}
$i++;
$i++;
}
if (isset($url)){
$output='';
$output.='<img style="width:100%;" onload="if(!get_page_init()){init_page();}" src="./covers/'.rawurlencode($url).'" alt="'.$album.'" id="'.$param.'_'.htmlspecialchars($album).'"/>';
return $output;
}
else {
return '<img style="width:100%;" onload="if(!get_page_init()){init_page();}" src="./favicon.png" alt="'.$album.'" id="'.$param.'_'.htmlspecialchars($album).'"/>';
}
}
else{
return '<img style="width:100%;" onload="if(!get_page_init()){init_page();}" src="./favicon.png" alt="'.$album.'" id="'.$param.'_'.htmlspecialchars($album).'"/>';
}
}
$recents=Array();
if (file_exists('./d/recent.dat')){
$recents=unserialize(file_get_contents('./d/recent.dat'));
}
$allowedAlbums=Array();
if (file_exists('./d/recently_generated_albums.dat')){
$allowedAlbums=unserialize(file_get_contents('./d/recently_generated_albums.dat'));
}
$counter=0;
$recentsr=array_reverse($recents);
echo 'Recently played: <a href="javascript:void(0);" onclick="this.innerHTML=\'refreshing...\';displayRecentlyPlayed();">refresh</a> / <a href="javascript:void(0);" onclick="hideRecentlyPlayed();">hide</a><br/>';
foreach ($recentsr as $recent){
if (!isset($recent['jailed'])){
$recent['jailed']=false;
}
if(in_array($recent['album'], $allowedAlbums)&&!$recent['jailed']&&$counter<10){
$counter++;
echo '<span style="width:10%;float:left;margin-left:auto;margin-right:auto;"><a href="javascript:page_init=false;arr=[encodeURIComponent(\''.str_replace("'", "\\'", html_entity_decode($recent['album'])).'\')];update_ajax_body(\'./?album=\'+encodeURI(JSON.stringify(arr))+\'&autoplay=true\');">'.displaycover($recent['album'], 10, 'mini'.rand(0,1000)).'</a><br/>';
echo htmlspecialchars(round((time()-intval($recent['date']))/60));
echo ' mn<br/>';
//echo ' <a href="#social" style="'.$recent['who']['color'].'">'.htmlspecialchars($recent['who']['nick']).'</a>';
echo '</span>';
}//if allowedAlbum
}
?>