PageRenderTime 53ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/patches/Servicios/sbin/www/m3uAll.php

https://github.com/frisco82/HMR600.com-Firmware
PHP | 336 lines | 267 code | 45 blank | 24 comment | 90 complexity | 65bab94fba2298d69efb0d38ea2badb4 MD5 | raw file
  1. <?php
  2. //This file will allow to create Play List (mylist.All).
  3. session_start();
  4. error_reporting(0);
  5. $_SESSION['redirect'] = $_SERVER['REQUEST_URI'];
  6. include '/tmp/lang.php';
  7. //if login option is true check login status
  8. $file = "/usr/local/etc/setup.php";
  9. $fp = fopen($file, 'r');
  10. $fileData = fread($fp, filesize($file));
  11. fclose($fp);
  12. $line = explode("\n", $fileData);
  13. $i = 1;
  14. while ($i <= 5) {
  15. $dataPair = explode('=', $line[$i]);
  16. if ($dataPair[0] == "Login" && $dataPair[1] == "true") {
  17. if ($_SESSION['loggedIn'] != 1) {
  18. header("Location:login_form.php");
  19. exit;
  20. }
  21. }
  22. $i++;
  23. }
  24. $root = "/tmp/usbmounts";
  25. //$root = "/tmp/hdd/volumes"; // this will the the root position of this script
  26. //Set our root position and make sure the URL input is not manually manipulated
  27. if ((substr($_GET['dir'],0,2) != '/.') and (substr($_GET['dir'],0,1) != '.') and ($_GET['dir'] != '')) {
  28. $mydir = $root . $_GET['dir'];
  29. $mediapath = $_GET['dir']; }
  30. else {
  31. $mydir = $root;
  32. }
  33. $uplink = substr_replace($_GET['dir'],'',strlen($_GET['dir'])-strlen(strrchr( $_GET['dir'],'/')));
  34. //Get and sort the directory listing
  35. $files = myscan($mydir);
  36. sort($files);
  37. //Common functions used
  38. function myscan($dir) {
  39. $arrfiles = array();
  40. $arrfiles = opendir($dir);
  41. while (false !== ($filename = readdir($arrfiles))) {
  42. $files[] = $filename;
  43. }
  44. return $files;
  45. }
  46. $HDDInfo = shell_exec("df -h|grep /dev/scsi/host0/bus0/target0/lun0/part1");
  47. sscanf($HDDInfo,"%s %s %s %s", $aaa,$HDDTotal, $HDDUsed, $HDDFree);
  48. ?>
  49. <script language=javascript>
  50. checked=false;
  51. function checkedAll(playlist) {
  52. var aa= document.getElementById('playlist');
  53. if (checked == false)
  54. {
  55. checked = true
  56. }else{
  57. checked = false
  58. }
  59. for (var i =0; i < aa.elements.length; i++){
  60. aa.elements[i].checked = checked;
  61. }
  62. }
  63. function checkAllmylist(mylist) {
  64. var aa= document.getElementById('mylist');
  65. if (checked == false)
  66. {
  67. checked = true
  68. }else{
  69. checked = false
  70. }
  71. for (var i =0; i < aa.elements.length; i++){
  72. aa.elements[i].checked = checked;
  73. }
  74. }
  75. function addlist(){
  76. flg = 0;
  77. for(i=0;i<document.playlist.length;i++){
  78. if(document.playlist[i].checked == true){
  79. flg = 1;
  80. break;
  81. }else{
  82. flg = 0;
  83. }
  84. }
  85. if(flg == 0){
  86. alert("<?echo $STR_NoFileToAdd;?>");
  87. return false;
  88. }
  89. document.playlist.target = 'gframe';
  90. document.playlist.action="./m3uAllList.php?dir=<? echo $mediapath;?>";
  91. document.playlist.submit();
  92. }
  93. function removelist(){
  94. flg = 0;
  95. for(i=0;i<document.mylist.length;i++){
  96. if(document.mylist[i].checked == true){
  97. flg = 1;
  98. break;
  99. }else{
  100. flg = 0;
  101. }
  102. }
  103. if(flg == 0){
  104. alert("<?echo $STR_NoFileToRemove;?>");
  105. return false;
  106. }
  107. document.mylist.target = 'gframe';
  108. document.mylist.action="./m3uAllListremove.php?dir=<? echo $mediapath;?>";
  109. document.mylist.submit();
  110. }
  111. //for select option
  112. function goto(form){
  113. var index=form.select_media.selectedIndex
  114. if (form.select_media.options[index].value != "0") {
  115. location=form.select_media.options[index].value;
  116. }
  117. }
  118. /*function Restart(){
  119. document.mylist.target = 'gframe';
  120. document.mylist.action = 'restart.php';
  121. document.mylist.submit();
  122. }
  123. function Playit(){
  124. document.mylist.target = 'gframe';
  125. document.mylist.action = 'play.php?dir=playAll';
  126. document.mylist.submit();
  127. }*/
  128. </script>
  129. <HTML>
  130. <head>
  131. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  132. <title><?echo $STR_MyListTitle;?></title>
  133. <link href="dlf/styles.css" rel="stylesheet" type="text/css">
  134. </head>
  135. <body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 oncontextmenu="return false;">
  136. <table width="987" height="94" background="dlf/top_menu.jpg" border="0" cellspacing="0" cellpadding="0">
  137. <tr>
  138. <td width=30%><img src="dlf/icon_other.jpg" height="94" width="189"/></td>
  139. <td width=40% align="center"><font face="arial" color="#ff0000"><h2><?echo $STR_MyListAllTitle;?></h2></font></td>
  140. <td width=28% align="right" valign=bottom>
  141. <FORM NAME="form1">
  142. <font color='white' face='Arial' size='2'><?echo $STR_SelectMyList;?></font>
  143. <select name="select_media" class="listbox" ONCHANGE="goto(this.form)">
  144. <option value="m3uAll.php?dir=<?echo $mediapath;?>"><?echo $STR_All;?></option>
  145. <option value="m3uVideo.php?dir=<?echo $mediapath;?>"><?echo $STR_Video;?></option>
  146. <option value="m3uMusic.php?dir=<?echo $mediapath;?>"><?echo $STR_Audio;?></option>
  147. <option value="m3uPhoto.php?dir=<?echo $mediapath;?>"><?echo $STR_Photo;?></option>
  148. </select>
  149. </FORM>
  150. </td>
  151. <td width=2%></td>
  152. </tr>
  153. </table>
  154. <center>
  155. <table cellspacing="0" cellpadding="0" border="0" width=950 height=500>
  156. <tr>
  157. <td align=center><font face='Arial' size='2' color='white'><?echo $STR_FileList;?></td>
  158. <td></td>
  159. <td align=center><font face='Arial' size='2' color='white'><?echo $STR_MyListTitle;?></td>
  160. </tr>
  161. <tr><td cellspacing="0" cellpadding="0" border="0" height=500 width=500 valign="top">
  162. <div id="listingcontainer1">
  163. <table cellspacing="0" cellpadding="0" border="0">
  164. <tr height=18><td></td></tr>
  165. <tr><td width=10></td>
  166. <td>
  167. <div id="listing1">
  168. <?
  169. echo "<form id='playlist' name='playlist' method='post' enctype='multipart/form-data'>";
  170. if ($mediapath != ''){
  171. echo "<input type='checkbox' name='selectall' onclick='checkedAll(playlist);'><font color= 'white' face='Arial' size='2'>".$STR_SelectAll;
  172. }
  173. if(!$_GET["dir"]==''){
  174. echo '<table width="500" cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'"><tr><td>';
  175. echo "<table><tr><td><img src='dlf/dirup.png' align='center'>";
  176. echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $uplink ."'>" . $STR_ParentDirectory . "</a></td></tr></table>";
  177. echo "</td></tr></table>";
  178. }
  179. for ($x=0; $x<sizeof($files); $x++) {
  180. if (($files[$x] != '.') and ($files[$x] != "..") and ($files[$x] != "Recycled") and ($files[$x] != "System Volume Information") and (substr($files[$x],0,1) != ".") and ($files[$x] != "lost+found")){
  181. // echo "<div>";
  182. if(is_dir($mydir . "/" . $files[$x])) {
  183. $files1[$x] = $files[$x];
  184. if (($aaa!= "") && ($mediapath == "") && (substr($files1[$x],0, 3) == "sda")){
  185. $files1[$x] = str_replace("sda", "HDD", $files1[$x]);
  186. echo '<table width="500" height="3" cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'">';
  187. echo '<tr><td>';
  188. echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><img src='dlf/folder.png' align='center'>";
  189. echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $mediapath . "/" . $files[$x] . "' class='rollover'>" . $files1[$x] . "</td>";
  190. //echo "It works only for Internal HDD.";
  191. echo "</tr></table>";
  192. echo "</td></tr></table>";
  193. }
  194. else if (($aaa!= "") && (substr($mediapath,0, 4) == "/sda")){
  195. $files1[$x] = str_replace("sda", "HDD", $files1[$x]);
  196. echo '<table width="500" height="3" cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'">';
  197. echo '<tr><td>';
  198. echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><img src='dlf/folder.png' align='center'>";
  199. echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $mediapath . "/" . $files[$x] . "' class='rollover'>" . $files1[$x] . "</td>";
  200. //echo "It works only for Internal HDD.";
  201. echo "</tr></table>";
  202. echo "</td></tr></table>";
  203. }
  204. }
  205. }
  206. }
  207. for ($x=0; $x<sizeof($files); $x++) {
  208. if (($files[$x] != '.') and ($files[$x] != "..")) {
  209. //echo "<div>";
  210. if(!is_dir($mydir . "/" . $files[$x])) {
  211. if ((strtolower(strrchr($files[$x],'.')) == ".wma")||(strtolower(strrchr($files[$x],'.')) == ".mp3")||(strtolower(strrchr($files[$x],'.')) == ".wav")||(strtolower(strrchr($files[$x],'.')) == ".mp2")||(strtolower(strrchr($files[$x],'.')) == ".aac")||(strtolower(strrchr($files[$x],'.')) == ".ac3")||(strtolower(strrchr($files[$x],'.')) == ".dts")||(strtolower(strrchr($files[$x],'.')) == ".png")||(strtolower(strrchr($files[$x],'.')) == ".jpeg")|| (strtolower(strrchr($files[$x],'.')) == ".jpg")||(strtolower(strrchr($files[$x],'.')) == ".bmp")||(strtolower(strrchr($files[$x],'.')) == ".gif")||(strtolower(strrchr($files[$x],'.')) == ".tif")||(strtolower(strrchr($files[$x],'.')) == ".wmv")||(strtolower(strrchr($files[$x],'.')) == ".mpg")|| (strtolower(strrchr($files[$x],'.')) == ".avi") ||(strtolower(strrchr($files[$x],'.')) == ".dat")||(strtolower(strrchr($files[$x],'.')) == ".mpeg")||(strtolower(strrchr($files[$x],'.')) == ".divx")||(strtolower(strrchr($files[$x],'.')) == ".xvid")||(strtolower(strrchr($files[$x],'.')) == ".mkv")||(strtolower(strrchr($files[$x],'.')) == ".mov")||(strtolower(strrchr($files[$x],'.')) == ".asf")||(strtolower(strrchr($files[$x],'.')) == ".ts")||(strtolower(strrchr($files[$x],'.')) == ".ogm")||(strtolower(strrchr($files[$x],'.')) == ".mp4")
  212. ||(strtolower(strrchr($files[$x],'.')) == ".flv")||(strtolower(strrchr($files[$x],'.')) == ".m4v") ||(strtolower(strrchr($files[$x],'.')) == ".flac")){
  213. echo '<table width="500" cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'">';
  214. echo "<tr> <td>";
  215. echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><input type='checkbox' name='playlist[]' value='$files[$x]'>";
  216. echo "<td colspan='200'><font color= 'white' face='Arial' size='2'>" . $files[$x] . "</font></td>";
  217. echo "</tr></table>";
  218. echo "</td></tr></table>";
  219. }
  220. }
  221. }
  222. }
  223. echo "</div>";
  224. ?>
  225. </td></tr></table>
  226. </td>
  227. <td align=middle>
  228. <font color='white' face='Arial' size='2'><?echo $STR_Add;?>
  229. <input type="button" class='btn_2' name="add" value=" => " onclick='javascript:addlist();';>
  230. </form>
  231. <form id='mylist' name='mylist' method='post' enctype='multipart/form-data'>
  232. <?echo $STR_Remove;?></font>
  233. <input type="button" class='btn_2' name="remove" value=" <= " onclick='javascript:removelist();';>
  234. </td>
  235. <td valign='top'>
  236. <div id="listingcontainer1">
  237. <table cellspacing="0" cellpadding="0" border="0">
  238. <tr height=18><td></td></tr>
  239. <tr><td width=10></td>
  240. <td>
  241. <?
  242. // echo "<div style='width: 450; height: 500; overflow: scroll; border: 1px solid #A7C5FF; background: transparent ;'>";
  243. echo '<div id="listing1">';
  244. echo "<input type='checkbox' name='selectall' onclick='checkAllmylist(playlist);'><font color='white' face='Arial' size='2'>" . $STR_SelectAll;
  245. $filename = "/usr/local/etc/mylist.All";
  246. if (file_exists($filename)) {
  247. $fp = fopen($filename, 'r');
  248. $fileData = fread($fp, filesize($filename));
  249. fclose($fp);
  250. }else{
  251. $fp = fopen($filename, 'w');
  252. //fwrite($fp, "#My List\n");
  253. $fileData = fread($fp, filesize($filename));
  254. fclose($fp);
  255. }
  256. $line = explode("\n", $fileData);
  257. $count = count($line);
  258. for ($i=0; $i<$count-1; $i++){
  259. echo '<table width=600 cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'">';
  260. echo "<tr> <td>";
  261. echo "<input type='checkbox' name='mylist[]' value='$line[$i]'>";
  262. echo "<font color='white' face='Arial' size='2'>";
  263. echo $line[$i];
  264. echo "</td></tr></table>";
  265. }
  266. ?>
  267. </div>
  268. </td></tr></table>
  269. </td>
  270. </tr>
  271. </table>
  272. <table border=0 width=955><tr><td width=850>&nbsp
  273. <font color='white' face='Arial' size='2'>
  274. <?
  275. $mediapath1 = $mediapath;
  276. if ($aaa!= ""){
  277. $mediapath1 = str_replace("sda", "HDD", $mediapath1);
  278. }
  279. echo $mediapath1;
  280. ?>
  281. </td>
  282. <!--td align=right><input type=button class='btn_2' onclick="javascript:Playit();" value="Play"></td>
  283. <td align=right><input type=button class='btn_2' onclick="javascript:Restart();" value="Reboot"></td-->
  284. <td align=right><input type=button class='btn_2' onclick="window.close()" value="<?echo $STR_Close;?>"></td>
  285. </tr>
  286. </table>
  287. </center>
  288. <iframe name='gframe' width=0 height=0 style="display:none"></iframe>
  289. </body>
  290. </HTML>