PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/patches/Servicios/sbin/www/m3uMusicList.php

https://github.com/frisco82/HMR600.com-Firmware
PHP | 73 lines | 39 code | 11 blank | 23 comment | 12 complexity | d9f02fcab976977b2192605884a28df9 MD5 | raw file
  1. <?
  2. header('Content-Type: text/html; charset=utf-8');
  3. error_reporting(0);
  4. include '/tmp/lang.php';
  5. //This file will write selected data to My Music Play list
  6. $data = $_POST['playlist'];
  7. $dir = $_GET['dir'];
  8. $filename = "/usr/local/etc/mylist.Music";
  9. if (file_exists($filename)) {
  10. $fp = fopen($filename, 'r');
  11. if (filesize($filename)>0){
  12. $fileData = fread($fp, filesize($filename));
  13. }
  14. fclose($fp);
  15. }
  16. if (substr($dir,0,5) == "/sda1"){
  17. $path = "C:" . substr($dir,5);
  18. }else if (substr($dir,0,5) == "/sda2"){
  19. $path = "D:" . substr($dir,5);;
  20. }else if (substr($dir,0,5) == "/sda3"){
  21. $path = "E:" . substr($dir,5);;
  22. }else if (substr($dir,0,5) == "/sda4"){
  23. $path = "F:" . substr($dir,5);;
  24. }
  25. $countdata = count($data);
  26. $countline = count($line);
  27. // for ($i=0; $i<$countdata; $i++){
  28. // for ($j=1; $j<$countline-1; $j++){
  29. // echo "<script>alert('$data[$i]');</script>";
  30. // echo "<script>alert('$line[$j]');</script>";
  31. // if (($countline > 2)and $data[$i] == substr(strrchr($line[$j], '/'),1)){
  32. // echo "<script>alert('$data[$i] file already exists!');</script>";
  33. //
  34. // }else{
  35. //
  36. // $m3ufile = fopen($filename, "a");
  37. // fwrite($m3ufile, $dir ."/". $data[$i]."\n");
  38. // fclose($m3ufile);
  39. // break;
  40. //
  41. // }
  42. // }
  43. // }
  44. $list = array();
  45. $list = explode("\n",$fileData);
  46. $list = array_map("trim", $list);
  47. for ($i=0; $i<$countdata; $i++){
  48. if (in_array($dir ."/". $data[$i],$list)){
  49. echo "<script>alert('$data[$i] $STR_FileExists');</script>";
  50. }else{
  51. $fd = fopen ($filename, "a") or die ("$STR_CantOpen $filename");
  52. $fout = fwrite ($fd, $path ."/". $data[$i]."\n");
  53. fclose($fd);
  54. }
  55. }
  56. echo "<script>parent.document.location.href = 'm3uMusic.php?dir=$dir';</script>";
  57. // foreach ($update as $this) {
  58. // $m3ufile = fopen($filename, "a");
  59. // fwrite($m3ufile, $dir ."/". $this."\n");
  60. // fclose($m3ufile);
  61. // }
  62. ?>