コード例 #1
0
<?php

require_once '../vendor/autoload.php';
use IcecastAuth\IcecastAuth;
$IceAuth = new IcecastAuth();
// Setup
$IceAuth->setAuthCallback('\\authFunc');
// set the callback for authentification
$IceAuth->setAuthErrorCallback('\\logError');
$IceAuth->setAddMountCallback('\\logAddMount');
$IceAuth->setRemoveMountCallback('\\logRemoveMount');
$IceAuth->setAddListenerCallback('\\logAddList');
$IceAuth->setRemoveListenerCallback('\\logRemoveList');
$IceAuth->setAuthHeader('HTTP/1.1 200 OK');
// Execute
$IceAuth->execute();
// Authetication will work if there is a parameter azerty in the stream url called by user (ex : http://myserver.com/mystream.mp3?azerty=1)
function authFunc($parameters)
{
    if (isset($parameters['azerty'])) {
        return true;
    } else {
        return false;
    }
}
// Will log Authetication errors in the a file
function logErrors($parameters)
{
    _log('Acces refused', $parameters);
}
function logAddList($parameters)
コード例 #2
0
ファイル: basic-usage.php プロジェクト: gbrousse/IcecastAuth
<?php

require_once '../vendor/autoload.php';
use IcecastAuth\IcecastAuth;
$IceAuth = new IcecastAuth();
// Setup
$IceAuth->setAuthCallback('\\authFunc');
// set the callback for authentification
// Execute
$IceAuth->execute();
// Authetication will work if there is a parameter azerty in the stream url called by user (ex : http://myserver.com/mystream.mp3?azerty=1)
function authFunc($parameters)
{
    if (isset($parameters['azerty'])) {
        return true;
    } else {
        return false;
    }
}
/* MOUNT CONFIGURATION ON ICECAST SERVER
<mount>
    <mount-name>/mystream.mp3</mount-name>
    <authentication type="url">
    	<option name="listener_add" value="[URL OF THIS SCRIPT]"/>
        <option name="auth_header" value="icecast-auth-user: 1"/>
    </authentication>
</mount>  
 */
コード例 #3
0
 /**
  * @covers IcecastAuth\IcecastAuth::altOnError
  * @covers IcecastAuth\IcecastAuth::getLastError
  */
 public function testErrors()
 {
     $iceAuth = new IcecastAuth();
     $this->assertFalse($iceAuth->setAddListenerCallback('test'));
     $this->assertEquals($iceAuth->getLastError(), 'test : Unknown function');
 }