HMR600.com-Firmware /patches/Servicios/sbin/www/m3uAll.php

Language PHP Lines 336
MD5 Hash 65bab94fba2298d69efb0d38ea2badb4
Repository https://github.com/frisco82/HMR600.com-Firmware.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<?php
//This file will allow to create Play List (mylist.All).
session_start();
error_reporting(0);
$_SESSION['redirect'] = $_SERVER['REQUEST_URI'];
include '/tmp/lang.php';
//if login option is true check login status
$file = "/usr/local/etc/setup.php";
$fp = fopen($file, 'r');
$fileData = fread($fp, filesize($file));
fclose($fp);
$line = explode("\n", $fileData);
$i = 1;
while ($i <= 5) {
        $dataPair = explode('=', $line[$i]);
        if ($dataPair[0] == "Login" && $dataPair[1] == "true") {
                if ($_SESSION['loggedIn'] != 1) {
                       header("Location:login_form.php");
                        exit;
                }
        }
        $i++;
}

$root = "/tmp/usbmounts";
//$root = "/tmp/hdd/volumes";  // this will the the root position of this script

//Set our root position and make sure the URL input is not manually manipulated
if ((substr($_GET['dir'],0,2) != '/.') and (substr($_GET['dir'],0,1) != '.') and ($_GET['dir'] != '')) {
    $mydir = $root . $_GET['dir'];
    $mediapath =  $_GET['dir']; }
else {
    $mydir = $root;
}

$uplink = substr_replace($_GET['dir'],'',strlen($_GET['dir'])-strlen(strrchr( $_GET['dir'],'/')));

//Get and sort the directory listing
$files = myscan($mydir);
sort($files);

//Common functions used
function myscan($dir) {
    $arrfiles = array();
    $arrfiles = opendir($dir);
    while (false !== ($filename = readdir($arrfiles))) {
           $files[] = $filename;
    }
    return $files;
}

$HDDInfo = shell_exec("df -h|grep /dev/scsi/host0/bus0/target0/lun0/part1");
sscanf($HDDInfo,"%s %s %s %s", $aaa,$HDDTotal, $HDDUsed, $HDDFree);
?>

<script language=javascript>

checked=false;
function checkedAll(playlist) {
	var aa= document.getElementById('playlist');
	 if (checked == false)
          {
			checked = true
          }else{
	        checked = false
          }
	for (var i =0; i < aa.elements.length; i++){
		 aa.elements[i].checked = checked;
	}
}

function checkAllmylist(mylist) {
	var aa= document.getElementById('mylist');
	 if (checked == false)
          {
	           checked = true
          }else{
	           checked = false
          }
	for (var i =0; i < aa.elements.length; i++){
		 aa.elements[i].checked = checked;
	}
}


function addlist(){
	flg = 0;
	for(i=0;i<document.playlist.length;i++){
		if(document.playlist[i].checked == true){
			flg = 1;
			break;
		}else{
			flg = 0;
		}
	}

	if(flg == 0){
		alert("<?echo $STR_NoFileToAdd;?>");
		return false;
	}
	document.playlist.target = 'gframe';
	document.playlist.action="./m3uAllList.php?dir=<? echo $mediapath;?>";
	document.playlist.submit();
}

function removelist(){
	flg = 0;
	for(i=0;i<document.mylist.length;i++){
		if(document.mylist[i].checked == true){
		flg = 1;
		break;
		}else{
		flg = 0;
		}
	}

	if(flg == 0){
		alert("<?echo $STR_NoFileToRemove;?>");
		return false;
	}

	document.mylist.target = 'gframe';
	document.mylist.action="./m3uAllListremove.php?dir=<? echo $mediapath;?>";
	document.mylist.submit();
}

//for select option
function goto(form){
	var index=form.select_media.selectedIndex
	if (form.select_media.options[index].value != "0") {
		location=form.select_media.options[index].value;
	}
}

/*function Restart(){
	document.mylist.target = 'gframe';
	document.mylist.action = 'restart.php';
	document.mylist.submit();
}

function Playit(){
	document.mylist.target = 'gframe';
	document.mylist.action = 'play.php?dir=playAll';
	document.mylist.submit();
}*/
</script>


<HTML>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?echo $STR_MyListTitle;?></title>
	<link href="dlf/styles.css" rel="stylesheet" type="text/css">
</head>

<body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 oncontextmenu="return false;">
	<table width="987" height="94" background="dlf/top_menu.jpg" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width=30%><img src="dlf/icon_other.jpg" height="94" width="189"/></td>
          	<td width=40% align="center"><font face="arial" color="#ff0000"><h2><?echo $STR_MyListAllTitle;?></h2></font></td>
			<td width=28% align="right" valign=bottom>
				<FORM NAME="form1">
				<font color='white' face='Arial' size='2'><?echo $STR_SelectMyList;?></font>
				<select name="select_media"  class="listbox" ONCHANGE="goto(this.form)">
					<option value="m3uAll.php?dir=<?echo $mediapath;?>"><?echo $STR_All;?></option>
					<option value="m3uVideo.php?dir=<?echo $mediapath;?>"><?echo $STR_Video;?></option>
					<option value="m3uMusic.php?dir=<?echo $mediapath;?>"><?echo $STR_Audio;?></option>
					<option value="m3uPhoto.php?dir=<?echo $mediapath;?>"><?echo $STR_Photo;?></option>
				</select>
				</FORM>
			</td>
			<td width=2%></td>
	    </tr>
	</table>

	<center>
    <table cellspacing="0" cellpadding="0" border="0" width=950 height=500>

		<tr>
			<td align=center><font face='Arial' size='2' color='white'><?echo $STR_FileList;?></td>
			<td></td>
			<td align=center><font face='Arial' size='2' color='white'><?echo $STR_MyListTitle;?></td>
		</tr>



		<tr><td cellspacing="0" cellpadding="0" border="0" height=500 width=500 valign="top">
			<div id="listingcontainer1">

			<table cellspacing="0" cellpadding="0" border="0">
			<tr height=18><td></td></tr>
			<tr><td width=10></td>
			
			<td>
			<div id="listing1">

<?
echo "<form id='playlist' name='playlist' method='post' enctype='multipart/form-data'>";
if ($mediapath != ''){
	echo "<input type='checkbox' name='selectall' onclick='checkedAll(playlist);'><font color= 'white' face='Arial' size='2'>".$STR_SelectAll;
}

if(!$_GET["dir"]==''){
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>';
echo "<table><tr><td><img src='dlf/dirup.png' align='center'>";
echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $uplink ."'>" . $STR_ParentDirectory . "</a></td></tr></table>";
echo "</td></tr></table>";
}


for ($x=0; $x<sizeof($files); $x++) {
	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")){
	//	echo "<div>";
		if(is_dir($mydir . "/" . $files[$x])) {
			$files1[$x] = $files[$x];
			if (($aaa!= "") && ($mediapath == "") && (substr($files1[$x],0, 3) == "sda")){
				$files1[$x] = str_replace("sda", "HDD", $files1[$x]);
			
				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\'">';
				echo '<tr><td>';
				echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><img src='dlf/folder.png' align='center'>";
				echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $mediapath . "/" . $files[$x] . "'   class='rollover'>" . $files1[$x] . "</td>";
				//echo "It works only for Internal HDD.";
				echo "</tr></table>";
				echo "</td></tr></table>";
			}
			else if (($aaa!= "") && (substr($mediapath,0, 4) == "/sda")){
				$files1[$x] = str_replace("sda", "HDD", $files1[$x]);
			
				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\'">';
				echo '<tr><td>';
				echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><img src='dlf/folder.png' align='center'>";
				echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $mediapath . "/" . $files[$x] . "'   class='rollover'>" . $files1[$x] . "</td>";
				//echo "It works only for Internal HDD.";
				echo "</tr></table>";
				echo "</td></tr></table>";
			}
        }
	}
}

for ($x=0; $x<sizeof($files); $x++) {
	if (($files[$x] != '.') and ($files[$x] != "..")) {
		//echo "<div>";
		if(!is_dir($mydir . "/" . $files[$x])) {
			 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")
				 ||(strtolower(strrchr($files[$x],'.')) == ".flv")||(strtolower(strrchr($files[$x],'.')) == ".m4v") ||(strtolower(strrchr($files[$x],'.')) == ".flac")){

				echo '<table width="500" cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'">';
				echo "<tr> <td>";
				echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><input type='checkbox' name='playlist[]' value='$files[$x]'>";
				echo "<td colspan='200'><font color= 'white' face='Arial' size='2'>" . $files[$x] . "</font></td>";
				echo "</tr></table>";
				echo "</td></tr></table>";
			}
		}
		
	}

}
	echo "</div>";
?>
			</td></tr></table>
        </td>

		<td align=middle>
			  <font color='white' face='Arial' size='2'><?echo $STR_Add;?>
		      <input type="button" class='btn_2' name="add" value=" => " onclick='javascript:addlist();';>
			  </form>

			  <form id='mylist' name='mylist' method='post' enctype='multipart/form-data'>
			  <?echo $STR_Remove;?></font>
		      <input type="button" class='btn_2' name="remove" value=" <= " onclick='javascript:removelist();';>
		</td>

		<td valign='top'>
		<div id="listingcontainer1">
		<table cellspacing="0" cellpadding="0" border="0">
		<tr height=18><td></td></tr>
		<tr><td width=10></td>
			<td>
			<?
//	echo "<div style='width: 450; height: 500; overflow: scroll; border: 1px solid #A7C5FF; background: transparent ;'>";
	echo '<div id="listing1">';

	echo "<input type='checkbox' name='selectall' onclick='checkAllmylist(playlist);'><font color='white' face='Arial' size='2'>" . $STR_SelectAll;

					$filename = "/usr/local/etc/mylist.All";
					if (file_exists($filename)) {
						$fp = fopen($filename, 'r');
						$fileData = fread($fp, filesize($filename));
						fclose($fp);
					}else{
						$fp = fopen($filename, 'w');
						//fwrite($fp, "#My List\n");
						$fileData = fread($fp, filesize($filename));
						fclose($fp);
					}

					$line = explode("\n", $fileData);
					$count = count($line);
					for ($i=0; $i<$count-1; $i++){
						echo '<table width=600 cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'">';
							echo "<tr> <td>";
							echo "<input type='checkbox' name='mylist[]' value='$line[$i]'>";
							echo "<font color='white' face='Arial' size='2'>";
							echo $line[$i];
						echo "</td></tr></table>";
					}
				?>
						</div>
			</td></tr></table>

		</td>
     </tr>
</table>
<table border=0 width=955><tr><td width=850>&nbsp
			<font color='white' face='Arial' size='2'>
			<?
			$mediapath1 = $mediapath;
			if ($aaa!= ""){
				$mediapath1 = str_replace("sda", "HDD", $mediapath1);
			}
			echo $mediapath1; 
			?>
		</td>
		<!--td align=right><input type=button class='btn_2' onclick="javascript:Playit();" value="Play"></td>
		<td align=right><input type=button class='btn_2' onclick="javascript:Restart();" value="Reboot"></td-->
		<td align=right><input type=button class='btn_2' onclick="window.close()" value="<?echo $STR_Close;?>"></td>
		</tr>
</table>
</center>

<iframe name='gframe' width=0 height=0 style="display:none"></iframe>
</body>
</HTML>
Back to Top