initial commit

This commit is contained in:
2016-10-23 20:05:05 +02:00
commit 2b6108425b
56 changed files with 9071 additions and 0 deletions
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

+9
View File
@@ -0,0 +1,9 @@
<?php
$msg = $_GET['key'];
if (isset($msg)) {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$len = strlen($msg);
socket_sendto($sock, $msg, $len, 0, 'localhost', 5100);
socket_close($sock);
}
?>
+75
View File
@@ -0,0 +1,75 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="/PiRadio16.gif" />
<link rel="stylesheet" href="styles.css">
<title>PiRadio mini web interface - config page</title>
</head>
<body>
<b>PiRadio</b><div id="config"><a href="index.html">radio</a></div></br>
<hr>
<?php
$msg = $_GET['file'];
if (isset($msg)) {
if ($msg == "restart") {
$end = "xxx";
} elseif ($msg == "stations") {
echo "Not implemented...";
} elseif ($msg == "network") {
echo "Not implemented...";
} elseif ($msg == "rss") {
$rss_link = $_POST["rss_link"];
file_put_contents('/var/lib/radiod/rss', $rss_link);
chmod("/var/lib/radiod/rss", 0755);
$rss_link_new = file_get_contents( "/var/lib/radiod/rss" );
echo "New RSS config:<br>";
echo "<b>".$rss_link_new."</b>";
} elseif ($msg == "radio") {
$rss = (isset($_POST['rss'])) ? "rss=yes" : "rss=no";
$bright = (isset($_POST['bright'])) ? "bright=yes" : "bright=no";
$media_update = (isset($_POST['media_update'])) ? "media_update=yes" : "media_update=no";
$pandora_available = (isset($_POST['pandora_available'])) ? "pandora_available=yes" : "pandora_available=no";
$piradio = file_get_contents( "/etc/radiod.conf" );
$piradio_new = preg_replace("/\nrss *= *.*/", "\n".$rss, $piradio);
$piradio_new = preg_replace("/\nbright *= *.*/", "\n".$bright, $piradio_new);
$piradio_new = preg_replace("/\nmedia_update *= *.*/", "\n".$media_update, $piradio_new);
$piradio_new = preg_replace("/\npandora_available *= *.*/", "\n".$pandora_available, $piradio_new);
$piradio_array = parse_ini_string($piradio_new);
$rss = ($piradio_array['rss']) ? "yes" : "no";
$bright = ($piradio_array['bright']) ? "yes" : "no";
$media_update = ($piradio_array['media_update']) ? "yes" : "no";
$pandora_available = ($piradio_array['pandora_available']) ? "yes" : "no";
echo "New Global PiRadio config:<br>";
echo "<b>";
echo "RSS in standby: ".$rss."<br>";
echo "LCD high brightness: ".$bright."<br>";
echo "Always update library: ".$media_update."<br>";
echo "Pandora available: ".$pandora_available."<br>";
file_put_contents('/etc/radiod.conf', $piradio_new);
chmod("/etc/radiod.conf", 0755);
} elseif ($msg == "pandora") {
$login = 'user = '.$_POST["login"];
$password = 'password = '.$_POST["password"];
$proxy = 'control_proxy = '.$_POST["proxy"];
/* Folder /home/pi/.config/ musi miec uprawnienia 755
inaczej nie da sie stad odczytac plik w nim umieszczony */
$pandora = file_get_contents( "/home/pi/.config/pianobar/config" );
$pandora_new = preg_replace("/\nuser *= *.*/", "\n".$login, $pandora);
$pandora_new = preg_replace("/\npassword *= *.*/", "\n".$password, $pandora_new);
$pandora_new = preg_replace("/\ncontrol_proxy *= *.*/", "\n".$proxy, $pandora_new);
$pandora_array = parse_ini_string($pandora_new);
echo "New Pandora config:<br>";
echo "<b>";
echo "Login: ".$pandora_array['user']."<br>";
echo "Password: ".$pandora_array['password']."<br>";
echo "Proxy: ".$pandora_array['control_proxy']."</b><br>";
file_put_contents('/home/pi/.config/pianobar/config', $pandora_new);
chmod("/home/pi/.config/pianobar/config", 0755);
}
}
?>
<hr>
<a href="config.php?command=restart"><button>PiRadio restart</button></a>
<a href="config.php?command=reboot"><button>System reboot</button></a>
</body>
+122
View File
@@ -0,0 +1,122 @@
<?php
$msg = $_GET['command'];
if (isset($msg)) {
if ($msg == "restart") {
$end = shell_exec('sudo ./scripts/restart.sh');
} elseif ($msg == "reboot") {
$end = shell_exec('sudo ./scripts/reboot.sh');
/* UWAGA! Kazdy skrypt uruchamiany przez sudo
musi byc dopisany w pliku /etc/sudoers */
}
}
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="/PiRadio16.gif" />
<link rel="stylesheet" href="styles.css">
<title>PiRadio mini web interface - config page</title>
</head>
<body>
<b>PiRadio</b><div id="config"><a href="index.html">radio</a></div></br>
<hr>
Global PiRadio config<br>
<form action="changeconf.php?file=radio" method="post">
<pre>
<?php
$piradio = file_get_contents( "/etc/radiod.conf" );
$piradio_array = parse_ini_string($piradio);
echo "<b>";
echo '<input type="checkbox" name="rss" value="rss" ';
if ( $piradio_array['rss'] ) {
echo 'checked>';
} else {
echo '>';
}
echo ' RRS in standby.<br>';
echo '<input type="checkbox" name="bright" value="bright" ';
if ( $piradio_array['bright'] ) {
echo 'checked>';
} else {
echo '>';
}
echo ' LCD high brightness.<br>';
echo '<input type="checkbox" name="media_update" value="media_update" ';
if ( $piradio_array['media_update'] ) {
echo 'checked>';
} else {
echo '>';
}
echo ' Always update library.<br>';
echo '<input type="checkbox" name="pandora_available" value="pandora_available" ';
if ( $piradio_array['pandora_available'] ) {
echo 'checked>';
} else {
echo '>';
}
echo ' Pandora available.';
echo '</b><br>';
?>
<button type="submit" name="submit">Save Global PiRadio config</button>
</pre>
</form>
<hr>
Media network folder config
<form action="changeconf.php?file=network" method="post">
<?php
/* Folder /var/lib/radiod/ musi miec uprawnienia 755
inaczej nie da sie stad odczytac plik w nim umieszczony */
$netshare = file_get_contents( "/var/lib/radiod/share" );
echo "<input type='text' name='media' value='";
echo $netshare;
echo "' style='width: 100%'>";
?>
<br><button type="submit" name="submit">Save network folder config</button>
</form>
<hr>
RSS config
<form action="changeconf.php?file=rss" method="post">
<?php
/* Folder /var/lib/radiod/ musi miec uprawnienia 755
inaczej nie da sie stad odczytac plik w nim umieszczony */
$rss = file_get_contents( "/var/lib/radiod/rss" );
echo "<input type='text' name='rss_link' value='";
echo $rss;
echo "' style='width: 100%'>";
?>
<br><button type="submit" name="submit">Save RSS config</button>
</form>
<hr>
Pandora config
<form action="changeconf.php?file=pandora" method="post"><pre>
<?php
/* Folder /home/pi/.config/ musi miec uprawnienia 755
inaczej nie da sie stad odczytac plik w nim umieszczony */
$pandora = file_get_contents( "/home/pi/.config/pianobar/config" );
$pandora_array = parse_ini_string($pandora);
/* print_r($pandora_array); */
echo "<b>";
echo "Login: <input type='text' name='login' value='".$pandora_array['user']."'><br>";
echo "Password: <input type='text' name='password' value='".$pandora_array['password']."'><br>";
echo "Proxy: <input type='text' name='proxy' value='".$pandora_array['control_proxy']."'></b><br>";
?>
<button type="submit" name="submit">Save Pandora config</button>
</pre></form>
<hr>
Radio stations config
<form action="changeconf.php?file=stations" method="post">
<?php
/* Folder /var/lib/radiod/ musi miec uprawnienia 755
inaczej nie da sie stad odczytac plik w nim umieszczony */
$stations = file_get_contents( "/var/lib/radiod/stationlist" );
echo '<textarea rows="20" cols="80" name="stations">';
echo $stations;
echo '</textarea>';
?>
<br><button type="submit" name="submit">Save radio stations list</button>
</form>
<hr>
<a href="config.php?command=restart"><button>PiRadio restart</button></a>
<a href="config.php?command=reboot"><button>System reboot</button></a>
</body>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

+112
View File
@@ -0,0 +1,112 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="/PiRadio16.gif" />
<link rel="stylesheet" href="styles.css">
<title>PiRadio mini web interface</title>
<script src="jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function() {
$("#wyswietlacz").load("lcd.php");
var refreshId = setInterval(function() {
$("#wyswietlacz").load("lcd.php");
}, 1000);
$.ajaxSetup({ cache: false });
$("#player").load("player.php");
});
</script>
</head>
<body>
<b>PiRadio</b><div id="config"><a href="config.php">config</a></div><hr>
<div id="wyswietlacz">
<br><br><br><br>
</div>
<div id="kursory">
<button id="UPbutton">^</button><br>
<button id="LEFTbutton">&lt;</button>
<button id="OKbutton">OK</button>
<button id="RIGHTbutton">&gt;</button><br>
<button id="DOWNbutton">v</button>
</div>
<div id="lewebuttony">
<button id="SLEEPbutton">&nbsp;&nbsp;SLEEP&nbsp;&nbsp;</button>
<button id="WAKEUPbutton">WAKEUP</button>
<br>
<button id="CHDOWNbutton">|&lt;&lt; PREV</button>
<button id="CHUPbutton">NEXT &gt;&gt;|</button>
<br>
<button id="RADIObutton">&nbsp;RADIO&nbsp;</button>
<button id="MEDIAbutton">PLAYER</button>
<button id="PANDORAbutton">PANDORA</button>
</div>
<div id="nadole">
<div id="player">
</div>
<button id="VDOWNbutton">VOL-</button>
<button id="VUPbutton">VOL+</button>
<button id="MUTEbutton">MUTE</button>
</div>
<script>
$("#OKbutton").click(function() {
$.post("button.php?key=KEY_OK");
});
$("#UPbutton").click(function() {
$.post("button.php?key=KEY_UP");
});
$("#DOWNbutton").click(function() {
$.post("button.php?key=KEY_DOWN");
});
$("#LEFTbutton").click(function() {
$.post("button.php?key=KEY_LEFT");
});
$("#RIGHTbutton").click(function() {
$.post("button.php?key=KEY_RIGHT");
});
$("#SLEEPbutton").click(function() {
$.post("button.php?key=KEY_SLEEP");
setTimeout(function(){
$("#player").load("player.php");
}, 1500);
});
$("#WAKEUPbutton").click(function() {
$.post("button.php?key=KEY_WAKEUP");
setTimeout(function(){
$("#player").load("player.php");
}, 1500);
});
$("#CHUPbutton").click(function() {
$.post("button.php?key=KEY_CHANNELUP");
});
$("#CHDOWNbutton").click(function() {
$.post("button.php?key=KEY_CHANNELDOWN");
});
$("#VUPbutton").click(function() {
$.post("button.php?key=KEY_VOLUMEUP");
});
$("#VDOWNbutton").click(function() {
$.post("button.php?key=KEY_VOLUMEDOWN");
});
$("#MUTEbutton").click(function() {
$.post("button.php?key=KEY_MUTE");
});
$("#RADIObutton").click(function() {
$.post("button.php?key=KEY_RADIO");
setTimeout(function(){
$("#player").load("player.php");
}, 4000);
});
$("#MEDIAbutton").click(function() {
$.post("button.php?key=KEY_MEDIA");
setTimeout(function(){
$("#player").load("player.php");
}, 5500);
});
$("#PANDORAbutton").click(function() {
$.post("button.php?key=KEY_PANDORA");
setTimeout(function(){
$("#player").load("player.php");
}, 5500);
});
</script>
</body>
+368
View File
@@ -0,0 +1,368 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Apache2 Debian Default Page: It works</title>
<style type="text/css" media="screen">
* {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
body, html {
padding: 3px 3px 3px 3px;
background-color: #D8DBE2;
font-family: Verdana, sans-serif;
font-size: 11pt;
text-align: center;
}
div.main_page {
position: relative;
display: table;
width: 800px;
margin-bottom: 3px;
margin-left: auto;
margin-right: auto;
padding: 0px 0px 0px 0px;
border-width: 2px;
border-color: #212738;
border-style: solid;
background-color: #FFFFFF;
text-align: center;
}
div.page_header {
height: 99px;
width: 100%;
background-color: #F5F6F7;
}
div.page_header span {
margin: 15px 0px 0px 50px;
font-size: 180%;
font-weight: bold;
}
div.page_header img {
margin: 3px 0px 0px 40px;
border: 0px 0px 0px;
}
div.table_of_contents {
clear: left;
min-width: 200px;
margin: 3px 3px 3px 3px;
background-color: #FFFFFF;
text-align: left;
}
div.table_of_contents_item {
clear: left;
width: 100%;
margin: 4px 0px 0px 0px;
background-color: #FFFFFF;
color: #000000;
text-align: left;
}
div.table_of_contents_item a {
margin: 6px 0px 0px 6px;
}
div.content_section {
margin: 3px 3px 3px 3px;
background-color: #FFFFFF;
text-align: left;
}
div.content_section_text {
padding: 4px 8px 4px 8px;
color: #000000;
font-size: 100%;
}
div.content_section_text pre {
margin: 8px 0px 8px 0px;
padding: 8px 8px 8px 8px;
border-width: 1px;
border-style: dotted;
border-color: #000000;
background-color: #F5F6F7;
font-style: italic;
}
div.content_section_text p {
margin-bottom: 6px;
}
div.content_section_text ul, div.content_section_text li {
padding: 4px 8px 4px 16px;
}
div.section_header {
padding: 3px 6px 3px 6px;
background-color: #8E9CB2;
color: #FFFFFF;
font-weight: bold;
font-size: 112%;
text-align: center;
}
div.section_header_red {
background-color: #CD214F;
}
div.section_header_grey {
background-color: #9F9386;
}
.floating_element {
position: relative;
float: left;
}
div.table_of_contents_item a,
div.content_section_text a {
text-decoration: none;
font-weight: bold;
}
div.table_of_contents_item a:link,
div.table_of_contents_item a:visited,
div.table_of_contents_item a:active {
color: #000000;
}
div.table_of_contents_item a:hover {
background-color: #000000;
color: #FFFFFF;
}
div.content_section_text a:link,
div.content_section_text a:visited,
div.content_section_text a:active {
background-color: #DCDFE6;
color: #000000;
}
div.content_section_text a:hover {
background-color: #000000;
color: #DCDFE6;
}
div.validator {
}
</style>
</head>
<body>
<div class="main_page">
<div class="page_header floating_element">
<img src="/icons/openlogo-75.png" alt="Debian Logo" class="floating_element"/>
<span class="floating_element">
Apache2 Debian Default Page
</span>
</div>
<!-- <div class="table_of_contents floating_element">
<div class="section_header section_header_grey">
TABLE OF CONTENTS
</div>
<div class="table_of_contents_item floating_element">
<a href="#about">About</a>
</div>
<div class="table_of_contents_item floating_element">
<a href="#changes">Changes</a>
</div>
<div class="table_of_contents_item floating_element">
<a href="#scope">Scope</a>
</div>
<div class="table_of_contents_item floating_element">
<a href="#files">Config files</a>
</div>
</div>
-->
<div class="content_section floating_element">
<div class="section_header section_header_red">
<div id="about"></div>
It works!
</div>
<div class="content_section_text">
<p>
This is the default welcome page used to test the correct
operation of the Apache2 server after installation on Debian systems.
If you can read this page, it means that the Apache HTTP server installed at
this site is working properly. You should <b>replace this file</b> (located at
<tt>/var/www/html/index.html</tt>) before continuing to operate your HTTP server.
</p>
<p>
If you are a normal user of this web site and don't know what this page is
about, this probably means that the site is currently unavailable due to
maintenance.
If the problem persists, please contact the site's administrator.
</p>
</div>
<div class="section_header">
<div id="changes"></div>
Configuration Overview
</div>
<div class="content_section_text">
<p>
Debian's Apache2 default configuration is different from the
upstream default configuration, and split into several files optimized for
interaction with Debian tools. The configuration system is
<b>fully documented in
/usr/share/doc/apache2/README.Debian.gz</b>. Refer to this for the full
documentation. Documentation for the web server itself can be
found by accessing the <a href="/manual">manual</a> if the <tt>apache2-doc</tt>
package was installed on this server.
</p>
<p>
The configuration layout for an Apache2 web server installation on Debian systems is as follows:
</p>
<pre>
/etc/apache2/
|-- apache2.conf
| `-- ports.conf
|-- mods-enabled
| |-- *.load
| `-- *.conf
|-- conf-enabled
| `-- *.conf
|-- sites-enabled
| `-- *.conf
</pre>
<ul>
<li>
<tt>apache2.conf</tt> is the main configuration
file. It puts the pieces together by including all remaining configuration
files when starting up the web server.
</li>
<li>
<tt>ports.conf</tt> is always included from the
main configuration file. It is used to determine the listening ports for
incoming connections, and this file can be customized anytime.
</li>
<li>
Configuration files in the <tt>mods-enabled/</tt>,
<tt>conf-enabled/</tt> and <tt>sites-enabled/</tt> directories contain
particular configuration snippets which manage modules, global configuration
fragments, or virtual host configurations, respectively.
</li>
<li>
They are activated by symlinking available
configuration files from their respective
*-available/ counterparts. These should be managed
by using our helpers
<tt>
<a href="http://manpages.debian.org/cgi-bin/man.cgi?query=a2enmod">a2enmod</a>,
<a href="http://manpages.debian.org/cgi-bin/man.cgi?query=a2dismod">a2dismod</a>,
</tt>
<tt>
<a href="http://manpages.debian.org/cgi-bin/man.cgi?query=a2ensite">a2ensite</a>,
<a href="http://manpages.debian.org/cgi-bin/man.cgi?query=a2dissite">a2dissite</a>,
</tt>
and
<tt>
<a href="http://manpages.debian.org/cgi-bin/man.cgi?query=a2enconf">a2enconf</a>,
<a href="http://manpages.debian.org/cgi-bin/man.cgi?query=a2disconf">a2disconf</a>
</tt>. See their respective man pages for detailed information.
</li>
<li>
The binary is called apache2. Due to the use of
environment variables, in the default configuration, apache2 needs to be
started/stopped with <tt>/etc/init.d/apache2</tt> or <tt>apache2ctl</tt>.
<b>Calling <tt>/usr/bin/apache2</tt> directly will not work</b> with the
default configuration.
</li>
</ul>
</div>
<div class="section_header">
<div id="docroot"></div>
Document Roots
</div>
<div class="content_section_text">
<p>
By default, Debian does not allow access through the web browser to
<em>any</em> file apart of those located in <tt>/var/www</tt>,
<a href="http://httpd.apache.org/docs/2.4/mod/mod_userdir.html">public_html</a>
directories (when enabled) and <tt>/usr/share</tt> (for web
applications). If your site is using a web document root
located elsewhere (such as in <tt>/srv</tt>) you may need to whitelist your
document root directory in <tt>/etc/apache2/apache2.conf</tt>.
</p>
<p>
The default Debian document root is <tt>/var/www/html</tt>. You
can make your own virtual hosts under /var/www. This is different
to previous releases which provides better security out of the box.
</p>
</div>
<div class="section_header">
<div id="bugs"></div>
Reporting Problems
</div>
<div class="content_section_text">
<p>
Please use the <tt>reportbug</tt> tool to report bugs in the
Apache2 package with Debian. However, check <a
href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?ordering=normal;archive=0;src=apache2;repeatmerged=0">existing
bug reports</a> before reporting a new bug.
</p>
<p>
Please report bugs specific to modules (such as PHP and others)
to respective packages, not to the web server itself.
</p>
</div>
</div>
</div>
<div class="validator">
</div>
</body>
</html>
Vendored Executable
+5
View File
File diff suppressed because one or more lines are too long
Executable
+18
View File
@@ -0,0 +1,18 @@
<?php
$line1 = file_get_contents( "/tmp/radiod/line1.txt" );
$line2 = file_get_contents( "/tmp/radiod/line2.txt" );
$line3 = file_get_contents( "/tmp/radiod/line3.txt" );
$line4 = file_get_contents( "/tmp/radiod/line4.txt" );
$line1 = str_replace(" ","&nbsp;",$line1);
$line2 = str_replace(" ","&nbsp;",$line2);
$line3 = str_replace(" ","&nbsp;",$line3);
$line4 = str_replace(" ","&nbsp;",$line4);
echo $line1;
echo "</br>";
echo $line2;
echo "</br>";
echo $line3;
echo "</br>";
echo $line4;
echo "</br>";
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
$line1 = file_get_contents( "/tmp/radiod/line1.txt" );
$czyplayer = strpos($line1, "*");
if ($czyplayer != false) {
list($realHost,)=explode(':',$_SERVER['HTTP_HOST']);
echo '<audio controls><source src="http://';
echo $realHost;
echo ':8001/mpd" type="audio/mp3">Your browser does not support the audio element.</audio>';
}
?>
+1
View File
@@ -0,0 +1 @@
reboot
+1
View File
@@ -0,0 +1 @@
service radiod restart
+66
View File
@@ -0,0 +1,66 @@
body {
background-color: lightgrey;
max-width: 800px;
align: center;
}
/*
#nadole {
position:fixed;
bottom:100px;
}
*/
#nadole {
text-align: center;
width: 200px;
}
#wyswietlacz {
border: 1px solid white;
background-color: black;
color: yellow;
font-family: "Lucida Console", Monaco, monospace;
padding: 5px;
}
#lewebuttony {
/* float: left; */
text-align: center;
width: 200;
height: 150;
}
#kursory {
float: right;
text-align: center;
width: 150;
height: 125;
}
#config {
float: right;
text-align: center;
width: 60;
height: 20;
background-color: black;
color: white;
text-decoration: bold;
}
#config a {
text-decoration: none;
color: white;
}
button {
background-color: lightgrey;
color: black;
padding: 7px 12px;
text-align: center;
text-decoration: none;
font-weight: bold;
display: inline-block;
border: 2px solid #555555;
border-radius: 8px;
margin: 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
}
button:hover {
background-color: #555555; /* Dark Grey */
color: white;
}