PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/patches/Servicios/sbin/www/m3uVideo.php

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