Need explanation with Icecast URL authentication - drupal-7

Foreword: I am stuck due to poor coding skills and a lack of understanding of the details of the URL authentication. I am not a coder but an amateur who usually get by with a little help from Google.
Challenge 1:
I am trying to set Icecast up in such a way that the audio stream can only be heard when you log in to my website. The method is called URL authentication by Icecast. Here is the link to the official documentation:
https://icecast.org/docs/icecast-2.4.0/auth.html
My problem: I understand that I have to integrate certain queries in the icecast.xml that are then answered by the player on my website. Unfortunately, I don't know where to integrate these codes. In a file in the webroot? In the header of the player page?
Challenge 2:
Another thing is that the player is working, but when I hit the pause button and restart the player 10 minutes later the song picks up there I paused the player even though the radio stream is already 2 titles ahead. So the cover art does not match the audio.
I guess that also has something to do with certain tweaks in the icecast.xml. Again ... I don't know how to add these tweaks and how to address them on my website (same issue as with the authentication).
Due to royalty issues, my website is behind a firewall for the time being.
Can anyone shed some light on my questions?
I included the code of my icecast.xml and of the iFrame that contains the player.
Best wishes,
Paul
This is the iFrame that contains the Drupal website and the HTML5 player:
<html>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta name=viewport content="width=device-width, initial-scale=1">
<style type="text/css">
html, body {
background: #333333;
height: 100%;
margin: 0px;
padding: 0px;
border: 0px;
}
iframe {
width: 100%;
height: 92%;
margin: 0px;
padding: 0px;
border: none;
display: block;
}
</style>
<body>
<?php
print('<iframe id="drupal_site" src="http://test.zoootradio.com" height="92%" width="100%" frameborder="0"></iframe>');
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.
print('<audio id="player" controls>');
print('<source src="http://192.168.2.50:8000/zr.mp3" type="audio/mpeg">');
print('</audio>');
?>
</body>
</html>
This is my icecast.xml file:
<icecast>
<location>Earth</location>
<admin>icemaster#localhost</admin>
<limits>
<clients>15</clients>
<sources>1</sources>
<queue-size>524288</queue-size>
<client-timeout>30</client-timeout>
<header-timeout>15</header-timeout>
<source-timeout>10</source-timeout>
<burst-on-connect>1</burst-on-connect>
<burst-size>65535</burst-size>
</limits>
<authentication>
<!-- Sources log in with username 'source' -->
<source-password>XXXXXXX</source-password>
<!-- Relays log in with username 'relay' -->
<relay-password>XXXXXXX</relay-password>
<!-- Admin logs in with the username given below -->
<admin-user>XXXXXXX</admin-user>
<admin-password>XXXXXXX</admin-password>
</authentication>
<hostname>192.168.2.50</hostname>
<!-- You may have multiple <listener> elements -->
<listen-socket>
<port>8000</port>
<!-- <bind-address>127.0.0.1</bind-address> -->
<!-- <shoutcast-mount>/stream</shoutcast-mount> -->
</listen-socket>
<http-headers>
<header name="Access-Control-Allow-Origin" value="*" />
</http-headers>
<mount type="normal">
<mount-name>/zr.mp3</mount-name>
<authentication type="url">
<option name="stream_auth" value="http://test.zoootradio.com/player"/>
</authentication>
</mount>
<fileserve>1</fileserve>
<paths>
<!-- basedir is only used if chroot is enabled -->
<basedir>/usr/share/icecast2</basedir>
<!-- Note that if <chroot> is turned on below, these paths must both
be relative to the new root, not the original root -->
<logdir>/var/log/icecast2</logdir>
<webroot>/usr/share/icecast2/web</webroot>
<adminroot>/usr/share/icecast2/admin</adminroot>
<!-- <pidfile>/usr/share/icecast2/icecast.pid</pidfile> -->
<alias source="/" destination="/status.xsl"/>
<!-- The certificate file needs to contain both public and private part.
Both should be PEM encoded.
<ssl-certificate>/usr/share/icecast2/icecast.pem</ssl-certificate>
-->
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<!-- <playlistlog>playlist.log</playlistlog> -->
<loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
<!-- If logarchive is enabled (1), then when logsize is reached
the logfile will be moved to [error|access|playlist].log.DATESTAMP,
otherwise it will be moved to [error|access|playlist].log.old.
Default is non-archive mode (i.e. overwrite)
-->
<!-- <logarchive>1</logarchive> -->
</logging>
<security>
<chroot>0</chroot>
<!--
<changeowner>
<user>nobody</user>
<group>nogroup</group>
</changeowner>
-->
</security>

1 - "URL auth"
Your icecast.xml does not contain any definition, so you don't have URL-auth configured.
What are you really trying to achieve?
2 - pause
Streams can't be paused, don't try to do it, it will break things. If you stop a stream, make sure that you do it in a way that makes the browser actually drop the connection.
Also you should always use a 'cache buster' or other way to ensure that the browser does not try to use cached stream content. (See my other answers on related topics here)

Related

Infinite redirecting loop CoovaChilli

I'm working with an accesspoint with OPENWRT and I want to redirect the hosts connected via Wifi to a concrete page. The problem is that when I turn on the browser appears infinite loop saying "redirecting", and this all the time.
I have tried to modify the chilli config file by adding:
HS_REDIRSSL=on
HS_SSLKEYFILE=/etc/chilli/key.pem
HS_SSLCERTFILE=/etc/chilli/cert.pem
but I'm still having the same problem. Could someone help me?
This is my html code to redirect the hosts:
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://footanalytics.com/" />
</head>
<body>
<font size="3" face="verdana" color="black">
<i>REDIRECTING</i>
</font>
</body>
</html>
Thank you
Try with this, edit this file: /etc/config/coovachilli, at the end of this file:
config general 'hotspot2'
option mode 'norad'
option net '192.168.3.254/24'
option enabled '1'
option externalpage '1'
option uamlogoutip '1.1.1.1'
option defidletimeout '600'
option defsessiontimeout '600'
option period '3'
option day '1'
option externadress 'http://example.com'
enabled '1' enables the wifi
external page '1' enables the option to redirect you to a requiered page when you connect to wifi
externadress defines the adrees where you want to be redirected
Don't touch the other options, they are configured by default.
bernat

google cloud engine metadata query

I have set a metadata groupip="10.0.0.2 10.0.0.3 10.0.0.4" in the project metadata. I am trying to query it using the following command:
curl 'http://metadata/computeMetadata/v1/projectid/groupip/' -H "Metadata-Flavor: Google"
As answer instead of the IP's I am getting the following:
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}bod
y{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/im
ages/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;t
ext-decoration:none}a img{border:0}#media screen and (max-width:772px){body{background:none;margin-top:0;max-width:
none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp
.png) no-repeat;margin-left:-5px}#media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.c
om/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//w
ww.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}#media only screen and (-webkit-min-d
evice-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.
png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL <code>/computeMetadata/v1/projectid/groupip/</code> was not found on this server. <ins>Th
at’s all we know.</ins>
In the same way that you get an instance's metadata via instance/attributes/xyz, so you can get the project's metadata via project/attributes/xyz.
curl http://metadata/computeMetadata/v1/project/attributes/groupip -H "Metadata-Flavor: Google"
To make sure you actually added the project-level metadata correctly, list all project attributes:
And more generally, keep shortening the URL to list ancestors:

Including style sheets in a PDF in cakePHP

I am using dompdf to generate PDFs for some of the views and that is working just fine. The problem is that I cannot include the css files anywhere, and only css included in the <style> tags inside the view itself is taken into consideration.
Here is the controller action:
public function view_pdf($id=null){
ini_set('memory_limit','512M');
$event = $this->Event->findById($id);
$evt_data=new \DateTime($event['Event']['date']);
$this->set('event', $event);
$this->layout='event';
}
Here is the layout:
require_once(APP . 'Vendor' . DS . 'dompdf' . DS . 'dompdf_config.inc.php');
spl_autoload_register('DOMPDF_autoload');
$dompdf = new DOMPDF();
$dompdf->set_paper = 'A4';
$dompdf->load_html(utf8_decode($content_for_layout), Configure::read('App.encoding'));
$dompdf->render();
echo $dompdf->stream('Event.pdf');
And here is the view itself (shortened version):
<style>
div.content-event{
background: gray;
color: black;
padding: 20px;
}
</style>
<div class="content-event" style="margin-bottom: 80px">
<div class="heading">
<div class="row">
<div class="col-md-12">
<h3><?php echo $event['Event']['name']; ?></h3>
</div>
</div>
</div>
I have tried to include the css files in the usual way, like: echo $this->Html->css('event');, in both the view and the layout, but this is just not taking any action.
Any help or guidance is much appreciated.
You can include CSS file like following:-
<link rel="stylesheet" type="text/css" href="<?php echo APP.'webroot'.DS.'css'.DS.'event.css'; ?>" media="all" />
Put your css file into webroot/css folder.
Archana's answer appears to be valid, but I wanted to provide a bit more context. When you load a document using $dompdf->load_html() dompdf has no information about the source of the file. When you provide links to external resources dompdf sets the currently executing file on the local file system as the base path.
Essentially URLs will be parsed in the following manner:
relative URLs (e.g. css/styles.css) will be evaluated relative to the currently executing file
absolute URLs (e.g. /css/styles.css) will be evaluated relative to the file system root
URLs with a domain (e.g. http://example.com/css/styles.css) will be evaluated as written
When you make the following call to HTMLHelper::css:
$this->Html->css('styles')
CakePHP will produce a style reference similar to the following:
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
Based on the parsing rules I outlined above that reference will be read from the filesystem root. And unless you have a root folder called "css" with your stylesheet in it that reference will be invalid. The reason Archana's answer works is that you're providing a path from the root of the file system to the file (e.g. /inet/www/cakesite/app/webroot/css/styles.css).
It's a bit easier to get a handle on external resource references if you specify a domain. In that manner dompdf will access the resource via your web server as would any web browser. This type of reference does require a bit more attention to your dompdf and server configuration.
You might find the following questions helpful on how to construct a URL:
Q: How to get the base Url in cakephp?
Q: base_url in CakePHP

An image to be displayed inline in a JavaMail created message shows up twice in Apple Mail – but not Outlook?

An image to be displayed inline in a JavaMail created message shows up twice in Apple Mail – but not Outlook?
EmailMaster sends a test email message that includes:
1) an image sent with the email to be displayed inline in the title when the message is opened
2) a link to an image that has to be downloaded from a remote URL after the message is displayed.
The goal is for the message to be fully rendered when it is opened (owl). Not require the reader download it before seeing full message.
The code below works perfectly when the message is opened in a client like Outlook.
-- the Owl image displayed in line when its opened, and
-- the underline must be downloaded.
When AppleMail opens the message the Owl is displayed twice. The screen show:
-- the owl as a standalone image,
-- then the message with the owl correctly displayed in the Title.
I can’t post a screen shot, but I put a screen shot of the AppleMail screen at
http://america-3.org/images/shot.jpg
Can anyone point me to the cause of the problem? Or a solution?
HTML code added as one MimeBodyPart.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="cid:fonts" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.text-blue-12 {font-family: Verdana, Arial, Helvetica, sans-serif;
text-decoration: none; font-weight: normal;
font-size:12pt; color: #0F0F0F}
body { margin: 0; padding: 0; background-color: #1A4576; width: 480px;}
tr {width:100%; background-color: white;}
-->
</style>
</head>
<body>
<table width='480px' cellspacing='0' cellpadding='6' class='text-blue-12' align="center">
<tr><td style='text-align: center;'>
Hello! <img src='cid:owl'>
</td></tr>
<tr><td style='text-align: center;'>
<img align="center" alt="Shadow" class="kmImage"
src="https://d3k81ch9hvuctc.cloudfront.net/assets/email/bottom_shadow_444.png"
width="600" style="border: 0; height: auto; line-height: 100%;
outline:none; text-decoration: none; max-width: 100%; padding-bottom: 0;
display: inline; vertical-align: bottom" />
</td></tr>
<tr><td>
This is test # 1005. The Table should be a 480px wide and centered.
If not there is a problem.
</td></tr>
<tr><td>
Yours truly,
GLB
</td></tr>
</table>
</body>
</html>
Extract of Java Class I use to test JavaMail code
public class EmailMaster {
/* JavaMail attempts to use IPv6 to connect. Windows IPv4.
* The error message will be "Network Unreachable: Connect.
* To fix it, I ran this code from the command window
* setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true
* I tried to set _JAVA_OPTIONS as an environment variable but that didn't
* work.
*/
/* the constructor instantiates EmailMaster.
* It parses a ".properties" text file that provides the everything
* needed to define a message:
* -- send from, reply to, subject etc. Strings
* -- local paths to one or more files:
* .. a text file containing the to addresses.
* .. the HTML file that holds the message body,
* .. one of more images to be displayed inline
* in the HTML message body. I used one.
* .. one or more files to be attached to the msg. I used one.
*/
/* then it calls sendEmail() to read through the list of addresses
* and sends an individual email to each address*/
sendEmail () {
/*this section of code is done once. */
Session session = Session.getInstance(this.sessionParameters);
SMTPTransport tr = new SMTPTransport(session, new URLName (host));
tr.connect(...); // this is successful
/* the method loops through this section for every to address provided*/
Message msg = new MimeMessage(session);
msg.setReplyTo(this.replyToAddress);// read from properties file
msg.setSentDate(new java.util.Date());// read from properties file
msg.setSubject(this.subject);// read from properties file
msg.setFrom(this.fromAddress);// read from properties file
msg.setRecipient(RecipientType.TO, singleToAddress);// read from properties file
MimeMultipart mmp = new MimeMultipart();
/* add a MimeBodyPart for each image be displayed inline the HTML text */
for (MimeBodyPart part : this.imagesBodyParts.values()) {
mmp.addBodyPart(part);
/* add a MimeBodyPart for each HTML page in the message. */
for (MimeBodyPart part : this.attachmentBodyParts.values()) {
mmp.addBodyPart(part);
}
mmp.addBodyPart(this.msgPart);
msg.setContent(mmp);
msg.saveChanges();
tr.sendMessage(msg, msg.getAllRecipients());
}
}
There's a limit to how much control you have over how mail readers display messages. In the end, you may not be able to accomplish what you're trying to do with all mail readers. That said, there's some issues with the code you posted...
You've got a double nested "for" loop that first adds an image body part, then adds a bunch of attachment (html?) body parts, then sends the message, then adds more of both to the same message, then sends the message again, and so on. Surely this isn't what you intended.
If you want the message to include a single html part and some image parts that are referenced by the html part, you need to create a multipart/related message, and the image parts need Content-ID headers. This JavaMail FAQ entry will point you in the right direction.
Finally, you should never be calling the constructor for SMTPTransport directly. Instead, you should use the Session.getTransport method.

wpf webBrowser NavigateToString script error

I want to use the Wpf webBrowser control to render math equations.
I've downloaded MathJax, and included it in my Visual studio project.
I've tryed to load one of the MathJax example. This is the html code i'm using:
<!DOCTYPE html>
<html>
<head>
<title>MathJax MathML Test Page</title>
<!-- Copyright (c) 2010-2012 Design Science, Inc. -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript" src="MathJax-Reduced/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"></script>
</head>
<body>
<p>
When
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mi>a</mi><mo>≠</mo><mn>0</mn>
</math>,
there are two solutions to
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mi>a</mi><msup><mi>x</mi><mn>2</mn></msup>
<mo>+</mo> <mi>b</mi><mi>x</mi>
<mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn>
</math>
and they are
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>x</mi> <mo>=</mo>
<mrow>
<mfrac>
<mrow>
<mo>−</mo>
<mi>b</mi>
<mo>±</mo>
<msqrt>
<msup><mi>b</mi><mn>2</mn></msup>
<mo>−</mo>
<mn>4</mn><mi>a</mi><mi>c</mi>
</msqrt>
</mrow>
<mrow> <mn>2</mn><mi>a</mi> </mrow>
</mfrac>
</mrow>
</math>
</p>
</body>
</html>
Everything is working fine with the following code:
string curDir = Directory.GetCurrentDirectory();
this.webBrowser1.Navigate(new Uri(String.Format("file:///{0}/test-1.html", curDir)));
But if i try this code:
string s = File.ReadAllText(Directory.GetCurrentDirectory() + "\\test-1.html");
this.webBrowser1.NavigateToString(s);
i get a Script Error:
An error has occurred in the script on this page.
Line: 1
Char: 1
Error: Syntax Error
Code: 0
URL: about:MathJax-Reduced/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full
What's wrong? It would be really helpful to use something similar to the last code, so i can avoid to save a file just to load it...
Note that the URL in the error is about:MathJax-Reduced/unpacked..., which is an about URL not the file:// URL that you had in the first case. I suspect that is the cause of the problem. That suggests that the NavigateToString function is using about:blank or a similar URL as the base URL for the page, so MathJax is getting the wrong path to itself. Note that you lose the actual page location when reading it from the file and loading it as a string. That means you may have to load MathJax from an absolute URL rather than a relative one (i.e., include the file:// and path to the MathJax-Reduced directory).

Resources