-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviewpodcast.php
220 lines (217 loc) · 6.23 KB
/
viewpodcast.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?php
/**
* Parameters you need to change
*
*
*/
$websiteTitle="Pingstkyrkan Eskilstuna podcast";
$otherPodcastsTitle="Andra Pingstkyrkan Eskilstuna podcast";
$descriptionForAllFiles="Predikan från Pingstkyrkan Eskilstuna";
$listen_InLocalLanguage="Lyssna";
$hits_InLocalLanguage="Visningar";
/*
* End of parameters you need to change.
*
* There should be no need to change below this line
*/
function getFileStats($files_dir,$filename){
$statsFile = $files_dir.$filename.'.stats';
$stats = 0;
if(file_exists($statsFile)){
try {
$stats=unserialize(file_get_contents($statsFile));
} catch (\Throwable $e) { // For PHP 7
$stats=0;
} catch (\Exception $e) { // For PHP 5
$stats=0;
}
}
return $stats;
}
function getFullHost()
{
$protocole = $_SERVER['REQUEST_SCHEME'].'://';
$host = $_SERVER['HTTP_HOST'] . '/';
$project = explode('/', $_SERVER['REQUEST_URI']);
array_pop($project);
array_shift($project);
$path = implode('/', $project);
return $protocole . $host . $path;
}
$base_url = getFullHost();
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?=$websiteTitle?></title>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel="shortcut icon" type="image/x-icon" href="<?=$base_url?>/fav.ico" />
<style>
@viewport {
width: device-width ;
zoom: 1.0 ;
}
@-ms-viewport {
width: device-width ;
}
.descriptionbox{
border-style: solid;
border-width:1px;
height:80px;
flex-grow:1;
overflow:hidden;
overflow-y: scroll;
}
.imagebox{
width:150px;
height:150px;
}
.imagemp3{
max-width:150px;
}
.titlespan{
font-size:1.5em;
}
.audiocontrol{
width:350px;
display:none;
}
.listenbutton{
font-size:1.5em;margin:10px;
}
@media screen and (orientation:portrait) {
.titlespan{
font-size:3em;
}
.descriptionbox{
font-size:2em;
border-style: solid;
border-width:1px;
height:120px;
flex-grow:1;
overflow:hidden;
overflow-y: scroll;
}
.imagebox{
width:250px;
height:250px;
}
.imagemp3{
max-width:250px;
}
.audiocontrol{
transform: scale(2.0);
margin-left:180px;
margin-top:40px;
display:none;
}
.listenbutton{
font-size:3em;
margin:10px;
}
}
</style>
</head>
<body>
<a href="<?=$base_url.'/rss.php'?>"><img src="feedicon.png"/></a>
<span class="titlespan"><?=$websiteTitle?></span>
<?php
$getid3_dir = "getid3/";
require_once($getid3_dir . 'getid3.php');
$getid3_engine = new getID3;
$files_dir = getcwd().'/upload/';
$file_path = $files_dir .'/'.$_GET["podcast"].'.mp3';
$id3_info = $getid3_engine->analyze($file_path);
getid3_lib::CopyTagsToComments($id3_info);
$date = date('l F d, Y', strtotime(date(DateTime::RFC2822, filemtime($file_path))));
$title = $id3_info["comments_html"]["title"][0];
$description = $descriptionForAllFiles;
$image = $base_url.'/upload/'.$_GET['podcast'].'.jpg';
$enclosure = $base_url.'/stats.php?filename='.$_GET['podcast'].'.mp3';
?>
<div style="border-style: groove;margin:10px;display:block">
<div style="display:flex">
<div class="imagebox" >
<?php if(strlen($image)>0){ ?>
<img class="imagemp3" src="<?=$image?>"/>
<?php } ?>
</div>
<div style="flex-grow:1">
<div class="descriptionbox">
<p><strong><?=$title?></strong></p>
<p><span style="font-size:0.75em"><?=$hits_InLocalLanguage.' '.getFileStats($files_dir,$_GET['podcast'].'.mp3'). '. ' ?></span><?=$description?></p>
</div>
<div style="">
<audio class="audiocontrol" style="display:inline" controls='controls'>
<source src='<?=$enclosure?>' type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
</div>
</div>
</div>
<div style="border-style: groove;margin-top:150px;display:block">
<span class="titlespan"><?=$otherPodcastsTitle?></span>
</div>
<?php
$rss = new DOMDocument();
$myfile=require('rsscore.php');
$rss->loadXml($myfile );
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$imgObj = $node->getElementsByTagNameNS("http://www.itunes.com/dtds/podcast-1.0.dtd", "image")->item(0);
$image=$imgObj?$imgObj->getAttribute('href'):'';
$link=$node->getElementsByTagName('link')->item(0)->nodeValue;
$filename=explode('=',$link)[1];
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $link,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
'enclosure' => $node->getElementsByTagName('enclosure')->item(0)->getAttribute('url'),
'image' => $image,
);
$feed[$filename]=$item;
}
krsort($feed);
$i=0;
foreach($feed as $key=>$value){
$i++;
$title = str_replace(' & ', ' & ', $value['title']);
$link = $value['link'];
$description = str_replace("\r\n","<br/>",$value['desc']);
$description = str_replace("\n","<br/>",$description);
$date = date('l F d, Y', strtotime($value['date']));
$image = $value['image'];
$enclosure = $value['enclosure'];
?>
<div style="border-style: groove;margin:10px;display:block">
<div style="display:flex">
<div class="imagebox" >
<?php if(strlen($image)>0){ ?>
<img class="imagemp3" src="<?=$image?>"/>
<?php } ?>
</div>
<div style="flex-grow:1">
<div class="descriptionbox">
<p><strong><?=$title?></strong></p>
<p><span style="font-size:0.75em"><?=$hits_InLocalLanguage.' '.getFileStats($files_dir,$key). '. ' ?></span><?=$description?></p>
</div>
<button class="listenbutton" type="button"
onclick="getElementById('abc<?=$i?>').setAttribute('src', '<?=$enclosure?>');getElementById('cba<?=$i?>').style.display = 'inline';getElementById('cba<?=$i?>').load();getElementById('cba<?=$i?>').play();this.style.display = 'none';">
<?=$listen_InLocalLanguage?></button>
<div style="display:block">
<audio id="cba<?=$i?>" class="audiocontrol" controls='controls'>
<source id="abc<?=$i?>" src="" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
</div>
</div>
</div>
<?php
}
?>
</body>
</html>