PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/patches/Servicios/sbin/www/destination.php

https://github.com/frisco82/HMR600.com-Firmware
PHP | 321 lines | 255 code | 46 blank | 20 comment | 63 complexity | b8980661809cc01b35cf2e665b668540 MD5 | raw file
  1. <HTML>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title> </title>
  5. <link rel="stylesheet" type="text/css" href="dlf/styles.css" />
  6. </head>
  7. <body marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 oncontextmenu="return false;">
  8. <?
  9. error_reporting(0);
  10. include '/tmp/lang.php';
  11. $filetypes = array (
  12. 'zip' => 'archive.png',
  13. 'rar' => 'archive.png',
  14. 'tar' => 'archive.png',
  15. 'exe' => 'exe.gif',
  16. 'setup' => 'setup.gif',
  17. 'txt' => 'text.png',
  18. 'htm' => 'html.gif',
  19. 'html' => 'html.gif',
  20. 'fla' => 'fla.gif',
  21. 'bin' => 'binary.png',
  22. 'xls' => 'xls.gif',
  23. 'doc' => 'doc.gif',
  24. 'ppt' => 'ppt.gif',
  25. 'sig' => 'sig.gif',
  26. 'pdf' => 'pdf.gif',
  27. 'psd' => 'psd.gif',
  28. 'gz' => 'archive.png',
  29. 'asc' => 'sig.gif',
  30. 'wmv' => 'video.png',
  31. 'mpg' => 'video.png',
  32. 'avi' => 'video.png',
  33. 'dat' => 'video.png',
  34. 'mpeg' => 'video.png',
  35. 'divx' => 'video.png',
  36. 'xvid' => 'video.png',
  37. 'mkv' => 'video.png',
  38. 'm4v' => 'video.png',
  39. 'mov' => 'video.png',
  40. 'asf' => 'video.png',
  41. 'ts' => 'video.png',
  42. 'ogm' => 'video.png',
  43. 'vob' => 'video.png',
  44. 'mp4' => 'video.png',
  45. 'wma' => 'audio.png',
  46. 'mp3' => 'audio.png',
  47. 'flac' => 'audio.png',
  48. 'wav' => 'audio.png',
  49. 'mp2' => 'audio.png',
  50. 'aac' => 'audio.png',
  51. 'ac3' => 'audio.png',
  52. 'dts' => 'audio.png',
  53. 'png' => 'photo.png',
  54. 'jpeg' => 'photo.png',
  55. 'jpg' => 'photo.png',
  56. 'png' => 'photo.png',
  57. 'bmp' => 'photo.png',
  58. 'gif' => 'photo.png',
  59. 'tif' => 'photo.png',
  60. );
  61. $id = $_POST['user_id'];
  62. $pass = $_POST['user_pass'];
  63. $Netshare_path = substr($_GET['dir'],0,12);
  64. if ($Netshare_path == "/tmp/myshare"){
  65. $mydir = $_GET['dir'];
  66. $mediapath = stripslashes($_GET['dir']);
  67. if ($mydir != "/tmp/myshare"){
  68. $uplink = substr_replace($_GET['dir'],'',strlen($_GET['dir'])-strlen(strrchr( $_GET['dir'],'/')));
  69. //check whether already mounted?
  70. $mydir1 = $mydir;
  71. $mydir1 = str_replace("(", "\(", $mydir1);
  72. $mydir1 = str_replace(")", "\)", $mydir1);
  73. $mydir1 = str_replace(" ", "\ ", $mydir1);
  74. $cmd = "mount |grep ".$mydir1;
  75. exec($cmd, $output1, $result1);
  76. if((substr($mydir, -4) == ".smb") || (substr($mydir, -4) == ".nfs") and ($output1[0] == "")){
  77. $ShareName = '/tmp/myshare/.cmd'.strrchr( $mydir,'/');
  78. $ShareName = str_replace("(", "\(", $ShareName);
  79. $ShareName = str_replace(")", "\)", $ShareName);
  80. $ShareName = str_replace(" ", "\ ", $ShareName);
  81. //mount
  82. $cmd = $ShareName . ' ' . $id . ' ' . $pass;
  83. exec($cmd, $output, $result);
  84. if ($result != 0){
  85. //$share = strrchr( $mydir,'/');
  86. //echo "<script>alert('Can not mount $share');</script>";
  87. //echo "<script>alert('mydirectory.....$mydir');</script>";
  88. echo "<script>window.open('smblogin.php?dir=$mydir', 'All', 'width=350,height=150');</script>";
  89. echo "<script>location.href='delete.php?dir=$uplink';</script>";
  90. }else if($id != ''){
  91. echo "<script>location.href='destination.php?dir=$mydir';</script>";
  92. }
  93. }
  94. $files = myscan($mydir);
  95. sort($files);
  96. //$mydir = str_replace("(", "\(", $mydir);
  97. //$mydir = str_replace(")", "\)", $mydir);
  98. $command = 'cd ' .$mydir1.';ls -alh > /tmp/aaa' ;
  99. shell_exec($command);
  100. $file1 = "/tmp/aaa";
  101. $fp1 = fopen($file1, 'r');
  102. //$fileData1 = fread($fp1, filesize($file1));
  103. $j=0;
  104. while (!feof($fp1)) {
  105. $line1[$j++] = fgets($fp1, 4096);
  106. }
  107. fclose($fp1);
  108. }else{
  109. $file = "/tmp/myshare/share.list";
  110. $fp = fopen($file, 'r');
  111. //$fileData = fread($fp, filesize($file));
  112. $j=0;
  113. while (!feof($fp)) {
  114. $files[$j++] = fgets($fp, 4096);
  115. }
  116. fclose($fp);
  117. }
  118. }else{
  119. $root = "/tmp/usbmounts";
  120. if ((substr($_GET['dir'],0,2) != '/.') and (substr($_GET['dir'],0,1) != '.') and ($_GET['dir'] != '')) {
  121. $mydir = $root . $_GET['dir'];
  122. $mediapath = stripslashes($_GET['dir']);
  123. }else{
  124. $mydir = $root;
  125. }
  126. $uplink = substr_replace($_GET['dir'],'',strlen($_GET['dir'])-strlen(strrchr( $_GET['dir'],'/')));
  127. $files = myscan($mydir);
  128. sort($files);
  129. $mydir1 = $mydir;
  130. $mydir1 = str_replace("(", "\(", $mydir1);
  131. $mydir1 = str_replace(")", "\)", $mydir1);
  132. $command = 'cd ' .str_replace(" ", "\ ", $mydir1).';ls -alh > /tmp/aaa' ;
  133. shell_exec($command);
  134. $file1 = "/tmp/aaa";
  135. $fp1 = fopen($file1, 'r');
  136. //$fileData1 = fread($fp1, filesize($file1));
  137. $j=0;
  138. while (!feof($fp1)) {
  139. $line1[$j++] = fgets($fp1, 4096);
  140. }
  141. fclose($fp1);
  142. }
  143. function myscan($dir) {
  144. $arrfiles = array();
  145. $arrfiles = opendir(stripslashes($dir));
  146. while (false !== ($filename = readdir($arrfiles))) {
  147. $files[] = $filename;
  148. }
  149. return $files;
  150. }
  151. //to deetct internal HDD exists or not
  152. $HDDInfo = shell_exec("df -h|grep /dev/scsi/host0/bus0/target0/lun0/part1");
  153. sscanf($HDDInfo,"%s %s %s %s", $aaa,$HDDTotal, $HDDUsed, $HDDFree);
  154. //echo "<div style='width: 450; height: 500; overflow: scroll; border: 1px solid #A7C5FF; background: transparent ;'>";
  155. //echo '<div id="listingcontainer1">';
  156. echo '<div id="listing1">';
  157. if(!$_GET["dir"]==''){
  158. 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>';
  159. echo "<table><tr><td><img src='dlf/dirup.png' align='center'>";
  160. echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $uplink ."'>" . $STR_ParentDirectory . "</a></td></tr></table>";
  161. echo "</td></tr></table>";
  162. }
  163. if ($Netshare_path == "/tmp/myshare"){
  164. for ($x=0; $x<($j-1); $x++) {
  165. if ($mydir == "/tmp/myshare"){
  166. 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\'">';
  167. echo '<tr><td>';
  168. echo "<table><tr><td><img src='dlf/folder.png' align='center'>";
  169. echo "<td width=380><a href=\"" . $_SERVER['PHP_SELF'] . "?dir=" . $mediapath . "/" . $files[$x] . "\" class='rollover'>" . $files[$x] . "</td>";
  170. echo "</tr></table>";
  171. echo "</td></tr></table>";
  172. }else if(substr($line1[$x],0,1) == 'd'){
  173. 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")){
  174. 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\'">';
  175. echo "<tr> <td>";
  176. echo "<table cellspacing='1' cellpadding='0'><tr>";
  177. echo "<td><img src='dlf/folder.png' align='center'>";
  178. echo "<td width=380><a href=\"" . $_SERVER['PHP_SELF'] . "?dir=" . $mediapath . "/" . $files[$x] . "\" class='rollover'>" . $files[$x] . "</td>";
  179. echo "</tr></table>";
  180. echo "</td>";
  181. echo "<td width='370'></td>";
  182. echo "</tr></table>";
  183. }
  184. }
  185. }
  186. }else{
  187. for ($x=0; $x<($j-1); $x++) {
  188. 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")) {
  189. if (substr($line1[$x],0,1) == 'd'){
  190. $files1[$x] = $files[$x];
  191. if ($aaa!= ""){
  192. $files1[$x] = str_replace("sda", "HDD", $files1[$x]);
  193. $files1[$x] = str_replace("sdb1", "USB1", $files1[$x]);
  194. $files1[$x] = str_replace("sdc1", "USB2", $files1[$x]);
  195. $files1[$x] = str_replace("sdd1", "USB3", $files1[$x]);
  196. $files1[$x] = str_replace("sdb", "USB", $files1[$x]);
  197. $files1[$x] = str_replace("sdc", "USB", $files1[$x]);
  198. }else{
  199. $files1[$x] = str_replace("sda1", "USB1", $files1[$x]);
  200. $files1[$x] = str_replace("sdb1", "USB2", $files1[$x]);
  201. $files1[$x] = str_replace("sdc1", "USB3", $files1[$x]);
  202. $files1[$x] = str_replace("sdd1", "USB4", $files1[$x]);
  203. $files1[$x] = str_replace("sdb", "USB", $files1[$x]);
  204. $files1[$x] = str_replace("sdc", "USB", $files1[$x]);
  205. }
  206. 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\'">';
  207. echo "<tr> <td>";
  208. //if ($mediapath != "")
  209. echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><img src='dlf/folder.png' align='center'>";
  210. echo "<td colspan='200'><a href='" . $_SERVER['PHP_SELF'] . "?dir=" . $mediapath . "/" . $files[$x] . "'>" . $files1[$x] . "</td>";
  211. echo "</tr></table>";
  212. echo "</td></tr></table>";
  213. }
  214. }
  215. }
  216. }
  217. //for NetShares
  218. if (($mediapath == "") and ($Netshare_path != "/tmp/myshare")){
  219. 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\'">';
  220. echo '<tr><td>';
  221. echo "<table cellspacing='1' cellpadding='0'><tr><td><img src='dlf/folder.png' align='center'>";
  222. echo "<td width=380><a href=\"" . $_SERVER['PHP_SELF'] . "?dir=/tmp/myshare\" class='rollover'>Network Shares</td>";
  223. echo "</tr></table>";
  224. echo "</td>";
  225. echo "<td width='370'></td>";
  226. echo "</tr></table>";
  227. }
  228. //for NetShares
  229. for ($x=0; $x<($j-1); $x++) {
  230. //if (($files[$x] != '.') and ($files[$x] != "..")) {
  231. //echo "<div>";
  232. //if(!is_dir($mydir . "/" . $files[$x])) {
  233. if ((substr($line1[$x],0,1) != 'd') and ($mydir != "/tmp/myshare")){
  234. if (($files[$x] != "mylist.All") and ($files[$x] != "mylist.Music") and ($files[$x] != "mylist.Picture") and ($files[$x] != "mylist.Video") and ($files[$x] != "keyword.data")){
  235. $ext = strtolower(substr($files[$x], strrpos($files[$x], '.')+1));
  236. if($filetypes[$ext]) {
  237. $icon = $filetypes[$ext];
  238. } else {
  239. $icon = 'unknown.png';
  240. }
  241. echo '<table width="500" cellspacing="0" cellpadding="0" border="0" onMouseOver="this.style.backgroundImage= \'url(dlf/rollover_bar.png)\'" onMouseOut="this.style.backgroundImage=\'none\'">';
  242. echo "<tr> <td>";
  243. echo "<table cellspacing='1' cellpadding='0' border='0'><tr><td><img src='dlf/" . $icon . "' align='center'>";
  244. echo "<td colspan='200'><font face='Arial' color='white' size='2'>" . $files[$x] . "</font></td>";
  245. echo "</tr></table>";
  246. echo "</td></tr></table>";
  247. }
  248. }
  249. //}
  250. }
  251. $mediapath1 = $mediapath;
  252. if ($aaa!= ""){
  253. $mediapath1 = str_replace("sda", "HDD", $mediapath1);
  254. $mediapath1 = str_replace("sdb1", "USB1", $mediapath1);
  255. $mediapath1 = str_replace("sdc1", "USB2", $mediapath1);
  256. $mediapath1 = str_replace("sdd1", "USB3", $mediapath1);
  257. $mediapath1 = str_replace("sdb", "USB", $mediapath1);
  258. $mediapath1 = str_replace("sdc", "USB", $mediapath1);
  259. $mediapath1 = str_replace("/tmp/myshare", "/NetShare", $mediapath1);
  260. }else{
  261. $mediapath1 = str_replace("sda1", "USB1", $mediapath1);
  262. $mediapath1 = str_replace("sdb1", "USB2", $mediapath1);
  263. $mediapath1 = str_replace("sdc1", "USB3", $mediapath1);
  264. $mediapath1 = str_replace("sdd1", "USB4", $mediapath1);
  265. $mediapath1 = str_replace("sdb", "USB", $mediapath1);
  266. $mediapath1 = str_replace("sdc", "USB", $mediapath1);
  267. $mediapath1 = str_replace("/tmp/myshare", "/NetShare", $mediapath1);
  268. }
  269. ?>
  270. <script language=javascript>
  271. parent.document.filelist.new_path.value='<?echo $mediapath1;?>';
  272. parent.document.filelist.new_path1.value='<?echo $mediapath;?>';
  273. </script>
  274. </body>
  275. </HTML>