http authentication?

Ask Questions or make comments about Mp3 Toolbox
Post Reply
mr_t
Posts: 3
Joined: Fri Apr 01, 2005 12:35 pm

http authentication?

Post by mr_t » Fri Apr 01, 2005 12:48 pm

Hi

First, Mp3 Toolbox is great! Thanks!

Second, I have a question about authertication. I'm running Debian and apache.

First entry in mp3toolbox_conf.php says:
---------
*/
$private_server = "Yes";
---------

authlist.php is like this:

----------
*/

$authuser[0] = 'admin';
$authpass[0] = 'somepass';

$authuser[1] = 'someuser';
$authpass[1] = 'someotherpass';
?>
----------

I've restarted apache, and was under impression some login window might pop up, but nothing. Maybe it's some setting in apache I'm missing. Anyone have a clue? Thanks.

User avatar
Jay
Will work for food (Administrator)
Posts: 2867
Joined: Mon Jan 14, 2002 12:48 am
Location: Next Door
Contact:

Post by Jay » Fri Apr 01, 2005 3:40 pm

well apache has nothing to do with this process so restarting it will not change the behavior.

Post the complete configuration file.
- Jay

mr_t
Posts: 3
Joined: Fri Apr 01, 2005 12:35 pm

Post by mr_t » Fri Apr 01, 2005 3:58 pm

<?php
/************************************************************/
/* The First ever truely independent php broadcast solution */
/* M P 3 */
/* T O O L B O X */
/************************************************************/
/*****************************************************************************
Mp3 ToolBox v. 1.0 beta 5
=========================
mp3toolbox_conf.php
=========================
License
=======
You are hereby granted to use MP3 ToolBox for personal or
commercial use.

If you plan to use parts or the whole code in your own
project be sure to include a nice credit to the original
author.

www.radiotoolbox.com cannot be held liable for the use of
this code. If you are weary about using this script then
please delete it now.

While I have tried my best to tie up the security loose ends
there may still be security problems with this script.

Credit
======
Written and Designed by Jay Krivanek
Location: www.radiotoolbox.com/mp3toolbox

*****************************************************************************/

/***********************/
/* Basic Configuration */
/***********************/

/* Source Location (this can be multiple directories)
*/
$source_dir[0] = "/mnt/hda3//mp3";
$category[0] = "mp3";

/* Private Server: This setting tells Radio Toolbox that only authorized viewers are allowed
to view the contents of the index or listen or download the streams. To add accounts to
the mp3 toolbox private server mode, use the authlist.php file. Private Server mode should
be considered experimental. It also uses Basic HTTP authorization. So any client wishing to
listen to content must have a player which supports HTTP authorization (i.e. Winamp)
*/
$private_server = "Yes";

/* Downloadable (do you want people to download your music directly from the server?
*/
$downloadable = "No";

/* Size Mode: this determines the format of the Size entries in the size column
of your mp3toolbox index.
*/
$size_mode = "MB";

/* Recurse Directories, set this to Yes if you would like to have Mp3 ToolBox recurse directories
entered above.
*/
$recurse_dir = true;

/* This is the location of your template file, this can be a relative or absolute path to the template file
this file is responsible for changing the look of mp3toolbox.
*/
$skin_file = "alt_template.php";

/* Agent Block: This was added to allow you to customize which user-agents should be blocked
from the audio content, this is allowed in order to further curtail stream ripping, however
there is no absolute solution. Example of entries could be "Mozilla" to block
Mozilla based browser like Internet Explorer or Netscape, or in a list "Mozilla|RMA" to
block audio content from the browser above and Real Player. This feature is
based on regular expressions, so beware of using . in a name because . means everything
*/
$agent_block = "Nothing";

/* ID3v1.1 tag template: If the mp3 being listened to has an ID3v1 or ID3v1.1 tag it will be
used for display, the following template allows you to tell mp3toolbox what info you would
like to show from the tag and how. Tagging is similar to Winamp.
%1 = ID3 Artist %4 = ID3 Year %7 = ID3v1.1 Track Number
%2 = ID3 Title %5 = ID3 Comment
%3 = ID3 Album %6 = ID3 Genre

NOTE: Currently there is no support for ID3v2 tags.
*/
$title_format = "%1 - %2";

/* Whether to convert a filename from "tO aDOOR yoU fROM aFar" to "To Adoor You From Afar"
Set to true if you would like this or false to use original case, this setting is
overridden if there is an ID3 tag detected.
*/
$pretty_titles = true;


/***********************/
/* Radio Configuration */
/***********************/

/* NOTE: In radio mode all mp3s must be set to the same sample rate. It is */
/* recommended that you use a sample rate that is divisable by 11 so choose */
/* 11Khz, 22Khz, 44Khz etc, files must also share the same Channel mode (stereo or */
/* mono), you can elect to use the $stream_* filter options below if you do not wish */
/* to worry about seperating certain files from others. VBR is NOT supported for */
/* sourcing a SHOUTcast server, however VBR files will work perfectly fine when */
/* listened to directly from the script or in Radio Style mode. */

/* What would you like to display as the title of your radio stream
*/
$station_name = "My Station";

/* Special Note: If you would like to give the illusion that the station is running
in real time, you should encode all of your mp3's to the same bitrate and enter it
here. This value is passed to a shoutcast server for listing on a yp. this value
is used when the $stream_bitrate filtration feature is not present.
*/
$base_bitrate = "128";

/* Stream Frequency: This feature was added as a safety check for the radio style portion.
Most players will find it difficult to bump their frequency during playback so it is
a good idea to keep the frequency consistant. Allowable and recommended settings are
11025, 22050, 44100 and if you want to be different in daring you can also use 12000,
24000, 48000 however these frequencies are not supported by all players,
or you can leave it blank if you just really don't care :)
*/
$stream_freq = "44100";

/* Stream Bitrate: This feature was added as a safety check for the radio style portion.
Some players may find it difficult to switch bitrates on the fly, unlike players like Winamp
or you may desire to keep a consistant bitrate throughout a stream, set this to any
valid constant bitrate 8, 16, 24, 32, 48, 56, 128, 192 etc etc. Leave blank if you
don't care. NOTE: by setting this filter you override the $base_bitrate variable setting.
*/
$stream_bitrate = "";

/* Stream Mode: This feature was added as a safety check for the radio style portion.
Most players will find it difficult to change the channel mode from stereo to mono or
vice versa during a stream playback. Set to Stereo to only play stereo files in a stream
or set to Mono to only play mono files in a stream (heh go figure). Leave blank if you wish
not to use this filter, however it is recommended that you do.
*/
$stream_mode = "Stereo";

/* This setting tell Mp3 Toolbox whether you want to allow it to shuffle your mp3's for
Radio Style playback
*/
$shuffle = "yes";

/* This setting allows mp3toolbox to trim what it thinks is silence at the end of a song
this feature is very experimental and mileage may vary depending on the MP3
*/
$silence_eleminator = "On";

/* This setting allows you to make the MP3 time become a countdown timer
for the currently playing MP3, really kind of trivial but great for
seeing how much of your mp3 is cut of by the silence eleminator feature.
*/
$time_mode = 'NONE';

/* The following options really only do anything if you plan on sourcing
a plublic SHOUTcast server with Mp3toolbox. With exceception to the
$url option which can be found in Winamp's minibrowser while playing
the stream.
*/

/* Genre you would like to appear in at the SHOUTcast directory
*/
$genre = "Variety";

/* Whether to publish to the SHOUTcast directory or not
*/
$publicize = 1;

/* Contact information for YP Directory
*/
$url = "http://www.radiotoolbox.com/";

$irc = "N/A";

$icq = "N/A";

$aim = "N/A";


/********************/
/* Playlist Options */
/********************/

/*******************************************************************************
Playlist Logic Scripting
If you are looking to control the output of the radio style a bit more
by adding your own promos between songs or by playing from certain directories
in a particular order you can use this feature NOTE: This feature is disabled
when directory recursing is off.
*******************************************************************************/

/* Enable the Playlist Scripting function here, set to true to turn on or false
for off. Note: This feature is disabled when directory recursing is off.
*/
$playlist_script = false;

/* Due to the nature of running a playlist script it may be neccessary to not repeat
a song within a certain amount of minutes. NOTE: this setting is only applied
when $playlist_script is enabled. Set to 0 if you prefer to not use this feature.
*/
$no_song_repeat_within = 60;

/* Directories that should not follow the $no_song_repeat_within feature. Great for
When you need promos and ads to run but music to follow the no repeat feature.
*/
$noapply_repeat[0] = $source_dir[0]."/Promos";


/*******************************************************************************
Place your script here, the proper format for a script is something like this:

$playlist_scr[0] = $source_dir[0]; <-- this will make the first position in the script pull from $source_dir[0] from above (remember that directories are recursive)
$playlist_scr[1] = $source_dir[0]."/Promo"; <-- After a song from $playlist_scr[0] is played then a song from this directory is played.
$playlist_scr[2] = "/home/mp3/ads/"; <-- The playlist script is not restricted to only the directories listed above, you can use any directory on your file system that is available to php.

For those familiar with php, this is just a simple array of directory paths.
*******************************************************************************/

$playlist_scr[0] = $source_dir[0]."/MP3";
$playlist_scr[1] = $source_dir[0]."/Promos";

/*******************************************************************************
End Script
*******************************************************************************/

/******************************************************/
/*SHOUTcast-like options, (does not require shoutcast)*/
/******************************************************/

/* Intro File: Just like the good ole SHOUTcast intro file ;)
Be sure that the file follows the filtration criteria above, otherwise it won't
Play. Leave Blank or comment out to disable.
*/
#$intro_file = $source_dir[0]."/intro.mp3";

/* Intro Title: Place a custom welcome message while the intro file plays. Comment
or leave blank to disable Not quite in shoutcast but hey why not right?
*/
#$intro_msg = "This is my intro message, welcome";

/* Meta Interval: Very similar to the MetaInterval in the SHOUTcast Server
This tells the script how often to send title metadata. This also
controls how CPU hungry this script is in NON SHOUTcast source modes. The
lower the number the more cycles that will be consumed the higher the number
the less accurate the title streaming is. This setting also effects Download
and all stream functions. NOTE: You should leave this value
at the default of 8192 unless you are absolutely sure you need to change it.
This value should also be a multiple of 8.
*/
$MetaInterval = 8192;

/* Allow Relay: Another SHOUTcast-like feature, this determines weather shoutcast
servers will be able to use this script as a source.
*/
$AllowRelay = false;

/* Listener Time: Another SHOUTcast-like feature, this feature limits the connection time
for users of the Radio service in minutes. Setting this value to 0 will allow a client to
stay connected for an unlimited amount of time.
*/
$ListenerTimer = 0;


/********************/
/* Advanced Options */
/********************/

/* For Debugging purposes: leave this item set to false or commented
unless you are having issues with Mp3 toolbox, by setting this value
to true or uncommented, you will have mp3 toolbox generate a log of activity
and display certain details of mp3's in certain interfaces. It is not
recommended that you run in this mode for daily use.
*/
$debug = false;
?>

User avatar
Jay
Will work for food (Administrator)
Posts: 2867
Joined: Mon Jan 14, 2002 12:48 am
Location: Next Door
Contact:

Post by Jay » Fri Apr 01, 2005 5:37 pm

looks fine, should work.

Do you get any errors in PHP?
- Jay

mr_t
Posts: 3
Joined: Fri Apr 01, 2005 12:35 pm

Post by mr_t » Sat Apr 02, 2005 8:53 am

The weird thing is i put test.php in the same directory and it asked for authentication and printed it like it should.

----
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
?>
----
I stole the script from [url]http://fi2.php.net/features.http-auth[/url] btw.

Is there perhaps some difference between the scripts in how this $_SERVER['PHP_AUTH_USER'] thing is handled ? I think my version of PHP is 4.1.2-7.0.1 or something like that, if that makes any difference.
As usual, I'm completely lost here. This seems so trivial, but I just lack the knowledge on php. The debug option in toolbox doesn't give any errors, nor does apache. As for actual PHP logs, I haven't looked at those very hard yet. I think I have to enable the logging somehow first. That shall be my next challenge..

User avatar
Jay
Will work for food (Administrator)
Posts: 2867
Joined: Mon Jan 14, 2002 12:48 am
Location: Next Door
Contact:

Post by Jay » Sun Apr 03, 2005 3:08 am

you are probably right, try turning register globals on in the php.ini file and see if it operates properly.

Barring that they may have hidden it in this new method in which case a simple modification should be all that is needed to the code to get it working.
- Jay

Post Reply