Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- /********************************************************************************/
- /* *****************************************/
- /* auto.php for Nifty Audio Player *****************************************/
- /* portions by http://digicave.org *****************************************/
- /* v.02 11/23/2008 *****************************************/
- /* *****************************************/
- /********************************************************************************/
- $file_dir = "media"; //change this to a folder name
- $omit_chars = 0; //how many characters to cut off the title's front
- $target = $file_dir;
- /********************************************************************************/
- /* *****************************************/
- /* CACHE PREVENTION DURING PLAYBACK *****************************************/
- /* *****************************************/
- /********************************************************************************/
- if (isset($_GET['nocache'])) {
- $fileonly = stripslashes($_GET['param']);
- $file = $target.'/'.$fileonly;
- $fh = fopen($file,"rb");
- while (!feof($fh))
- {
- header("Cache-Control: no-store, must-revalidate");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header("Content-Type: audio/mpeg");
- header('Content-Length: ' . filesize($file));
- print(fread($fh, (1*(1024*1024))));
- }
- fclose($fh);
- } else {
- print '
- <?xml version="1.0" encoding="utf-8"?>
- <!-- PROPERTY FORMAT LEGEND: -->
- <!--Rectangle: topColor,bottomColor,fillAlpha,cornerRadius,strokeColor,strokeAlpha,strokeWidth-->
- <!--Text: font,color,alpha,size,bold-->
- <!--Simple Property: color,alpha-->
- <music
- playerMode="1"
- displayTimeInfo="true"
- playerWidth="350"
- playerHeight="35"
- playerX="20"
- playerY="10"
- flyOut="bottom"
- autoStart="true"
- buttonSize="25"
- buttonPadding="5"
- buttonY="5"
- playInSequence="true"
- playerVolume="100"
- embedFonts="false"
- playerBg="282828,000000,100,5,171717,100,1"
- playerBgShine="FFFFFF,FFFFFF,10,5,333333,0,1"
- buttonBg="444444,000000,100,7,000000,100,1"
- buttonInnerStroke="363636,000000,100,7,333333,100,1"
- buttonBgHover="0D97F2,075d99,100,7,064B79,100,1"
- buttonIcon="888888,100"
- buttonIconHover="FFFFFF,100"
- displaySongText="Verdana,A4A4A4,100,10,false"
- displaySongTimeTotal="Arial,A4A4A4,100,10,false"
- displaySongTimeElapsed="Arial,FFFFFF,100,10,true"
- displaySongTextY="2"
- displaySongTimeY="2"
- pauseDisplayFor="2"
- songTitleScrollTime="3"
- sliderHeight="5"
- sliderY="21"
- sliderButtonWidth="10"
- sliderButtonHeight="10"
- sliderBg="000000,333333,100,3,0,0,0"
- sliderFill="0D97F2,075d99,100,3,0,0,0"
- sliderStramProgress="333333,444444,100,3,0,0,0"
- sliderButton="FFFFFF,666666,100,10,333333,100,1"
- volumeHeight="70"
- volumeBg="222222,000000,100,9,333333,100,1"
- volumeSliderBg="333333,444444,100,3,0,0,0"
- volumeSliderFill="0D97F2,075d99,100,3,0,0,0"
- volumeText="Arial,FFFFFF,100,10,false"
- volumeSliderButton="FFFFFF,666666,100,9,333333,100,1"
- listOpen="true"
- listHeight="180"
- listPadding="10"
- listScrollbarWidth="9"
- listBg="222222,000000,100,15,333333,100,1"
- listScrollbar="666666,100"
- listScrollbarBg="000000,100"
- listItemHeight="20"
- listItemBg="333333,100"
- listItemBgActive="075d99,100"
- listTitleText="Verdana,999999,100,10,false"
- listTitleTextActive="Verdana,FFFFFF,100,10,false"
- listTitleScrollTime="5"
- ><group>'."\n";
- clearstatcache();
- $sourcepath = $file_dir;
- // Replace \ by / and remove the final / if any
- $root = ereg_replace( "/$", "", ereg_replace( "[\\]", "/", $sourcepath ));
- // Search for mp3 files
- $results = m_find_in_dir( $root, ".*\.mp3" );
- if( false === $results ) {
- echo "'{$sourcepath}' is not a valid directory\n";
- } else {
- $xml_string= array();
- foreach ($results AS $file)
- {
- $file = substr($file, strlen($file_dir)+1);
- $filer = $_SERVER["SCRIPT_NAME"];
- $break = explode('/', $filer);
- $pfile = $break[count($break) - 1];
- // If you require your filenames to include _underscores, uncomment the next line
- //$file = str_replace(" ", "_", $file);
- $urlHurl = $pfile."?nocache&param=".rawurlencode($file);
- if(substr($file, -3) == "mp3")
- {
- // remove directory info from filename for display
- $file = preg_replace( '/^.+\/(.+)/', '$1', $file);
- $tmp_str = '<song title="'.substr(str_replace("_", " ", $file), $omit_chars, -4).'" file="'.$urlHurl.'" />'."\n";
- array_push($xml_string, $tmp_str);
- }
- }
- sort($xml_string);
- $xml_count = count($xml_string);
- for($i=0; $i<$xml_count; $i++)
- {
- print $xml_string[$i];
- }
- print '</group></music>';
- }
- }
- /**
- * Search for a file maching a regular expression
- *
- * @param string $root Root path
- * @param string $pattern POSIX regular expression pattern
- * @param boolean $recursive Set to true to walk the subdirectories recursively
- * @param boolean $case_sensitive Set to true for case sensitive search
- * @return array An array of string representing the path of the matching files, or false in case of error
- */
- function m_find_in_dir( $root, $pattern, $recursive = true, $case_sensitive = false ) {
- $result = array();
- if( $case_sensitive ) {
- if( false === m_find_in_dir__( $root, $pattern, $recursive, $result )) {
- return false;
- }
- } else {
- if( false === m_find_in_dir_i__( $root, $pattern, $recursive, $result )) {
- return false;
- }
- }
- return $result;
- }
- /**
- * @access private
- */
- function m_find_in_dir__( $root, $pattern, $recursive, &$result ) {
- $dh = @opendir( $root );
- if( false === $dh ) {
- return false;
- }
- while( $file = readdir( $dh )) {
- if( "." == $file || ".." == $file ){
- continue;
- }
- if( false !== @ereg( $pattern, "{$root}/{$file}" )) {
- $result[] = "{$root}/{$file}";
- }
- if( false !== $recursive && is_dir( "{$root}/{$file}" )) {
- m_find_in_dir__( "{$root}/{$file}", $pattern, $recursive, $result );
- }
- }
- closedir( $dh );
- return true;
- }
- /**
- * @access private
- */
- function m_find_in_dir_i__( $root, $pattern, $recursive, &$result ) {
- $dh = @opendir( $root );
- if( false === $dh ) {
- return false;
- }
- while( $file = readdir( $dh )) {
- if( "." == $file || ".." == $file ){
- continue;
- }
- if( false !== @eregi( $pattern, "{$root}/{$file}" )) {
- $result[] = "{$root}/{$file}";
- }
- if( false !== $recursive && is_dir( "{$root}/{$file}" )) {
- m_find_in_dir__( "{$root}/{$file}", $pattern, $recursive, $result );
- }
- }
- closedir( $dh );
- return true;
- }
- ?>
Add Comment
Please, Sign In to add comment