Advertisement
EpicKnarvik97

Music Search

Apr 25th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.79 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  3. <?php
  4. header('Content-type: text/html; charset=utf-8');
  5. mb_internal_encoding('UTF-8');
  6. mb_http_output('UTF-8');
  7. mb_http_input('UTF-8');
  8. if(!isset($_GET['loc'])){
  9.     $DIR = "G:/Musikk/";
  10. }else{
  11.     $DIR = "G:/Musikk/".$_GET['loc']."/";
  12. }
  13. $illegal = ["Audacity", "Spillelister", 'cgi-bin', '.', '..','._'];
  14. $legalExtension = ["mp3", "MP3", "", "m4a", "wav", "wma"];
  15. $OIR = "/musicdir/";
  16. $back = substr($_GET['loc'], 0, strrpos($_GET['loc'], "/"));
  17. $files = preg_grep('/^([^.])/', scandir($DIR));
  18. $Directories = [];
  19. $MP3 = [];
  20. $Others = [];
  21. if (strpos($_GET['loc'],'../') !== false) :
  22.     echo 'Illegal';
  23. else :
  24.     foreach($files as $file){
  25.         $file = iconv(mb_detect_encoding($file, mb_detect_order(), true), 'utf-8', $file);
  26.         if(!in_array($file, $illegal)){
  27.             if(in_array(pathinfo($file, PATHINFO_EXTENSION), $legalExtension)){
  28.                 if(is_dir($DIR.$file)){
  29.                     array_push($Directories, $file);
  30.                 }else{
  31.                     switch(pathinfo($file, PATHINFO_EXTENSION)){
  32.                         case "mp3":
  33.                         case "MP3":
  34.                         case "m4a":
  35.                             array_push($MP3, $file);
  36.                             break;
  37.                         default:
  38.                             array_push($Others, $file);
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.     }
  44.     echo "<a href='/musictest.php?loc=".$back."'>Back</a>";
  45.     if(!$Directories == []){echo "<br><br>Directories:";
  46.         if(!isset($_GET['loc'])){
  47.             foreach ($Directories as $Dirs){echo "<br><a href=\"/musictest.php?loc=".$Dirs."\">".$Dirs."</a>";}
  48.         }else{
  49.             foreach ($Directories as $Dirs){echo "<br><a href=\"/musictest.php?loc=".$_GET['loc']."/".$Dirs."\">".$Dirs."</a>";}
  50.         }
  51.     }else{
  52.         echo "<br>";
  53.     }
  54.     echo "<br>";
  55.     if(isset($_GET['loc']) && $Others !== []){displayOthers($_GET['loc'], $Others);}
  56.     if(isset($_GET['loc']) && $MP3 !== []){displayMusic($_GET['loc'], $MP3);}
  57.  
  58. endif;
  59.  
  60. function displayOthers($loc, $Filepahts){
  61.     echo "<br>Unstreamable files:";
  62.     foreach ($Filepahts as $SingleFile){
  63.         echo '<br><a target="_blank" href="/musicdir/'.$loc.'/'.$SingleFile.'">'.$SingleFile."</a>";
  64.     }
  65.     echo "<br>";
  66. }
  67.  
  68. function displayMusic($loc, $Filepaths){
  69. echo "<br>Streamable files:";
  70. echo '
  71. <br><br>
  72. <link href="/tools/jPlayer-2.9.2/dist/skin/blue.monday/css/jplayer.blue.monday.min.css" rel="stylesheet" type="text/css" />
  73. <script type="text/javascript" src="/tools/jPlayer-2.9.2/lib/jquery.min.js"></script>
  74. <script type="text/javascript" src="/tools/jPlayer-2.9.2/dist/jplayer/jquery.jplayer.min.js"></script>
  75. <script type="text/javascript" src="/tools/jPlayer-2.9.2/dist/add-on/jplayer.playlist.min.js"></script>
  76. <script type="text/javascript">
  77. //<![CDATA[
  78. $(document).ready(function(){
  79.     new jPlayerPlaylist({
  80.         jPlayer: "#jquery_jplayer_1",
  81.         cssSelectorAncestor: "#jp_container_1"
  82.     }, [
  83. ';
  84.     foreach ($Filepaths as $Path){
  85.         echo '{
  86.             title:"'.$Path.'",
  87.             free:true,
  88.             '.pathinfo($Path, PATHINFO_EXTENSION).':"/musicdir/'.$loc."/".$Path.'"
  89.         },';
  90.     }
  91. echo '
  92.     ], {
  93.         swfPath: "/tools/jPlayer-2.9.2/dist/jplayer",
  94.         supplied: "mp3,m4a,wav",
  95.         wmode: "window",
  96.         useStateClassSkin: true,
  97.         autoBlur: false,
  98.         smoothPlayBar: true,
  99.         keyEnabled: true
  100.     });
  101.    
  102. });
  103. //]]>
  104. </script>
  105. <div id="jquery_jplayer_1" class="jp-jplayer"></div>
  106. <div id="jp_container_1" class="jp-audio" role="application" aria-label="media player">
  107.     <div class="jp-type-playlist">
  108.         <div class="jp-gui jp-interface">
  109.             <div class="jp-controls">
  110.                 <button class="jp-previous" role="button" tabindex="0">previous</button>
  111.                 <button class="jp-play" role="button" tabindex="0">play</button>
  112.                 <button class="jp-next" role="button" tabindex="0">next</button>
  113.                 <button class="jp-stop" role="button" tabindex="0">stop</button>
  114.             </div>
  115.             <div class="jp-progress">
  116.                 <div class="jp-seek-bar">
  117.                     <div class="jp-play-bar"></div>
  118.                 </div>
  119.             </div>
  120.             <div class="jp-volume-controls">
  121.                 <button class="jp-mute" role="button" tabindex="0">mute</button>
  122.                 <button class="jp-volume-max" role="button" tabindex="0">max volume</button>
  123.                 <div class="jp-volume-bar">
  124.                     <div class="jp-volume-bar-value"></div>
  125.                 </div>
  126.             </div>
  127.             <div class="jp-time-holder">
  128.                 <div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
  129.                 <div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
  130.             </div>
  131.             <div class="jp-toggles">
  132.                 <button class="jp-repeat" role="button" tabindex="0">repeat</button>
  133.                 <button class="jp-shuffle" role="button" tabindex="0">shuffle</button>
  134.             </div>
  135.         </div>
  136.         <div class="jp-playlist">
  137.             <ul>
  138.                 <li>&nbsp;</li>
  139.             </ul>
  140.         </div>
  141.         <div class="jp-no-solution">
  142.             <span>Update Required</span>
  143.             To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
  144.         </div>
  145.     </div>
  146. </div>
  147. ';
  148. }
  149. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement