PageRenderTime 53ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/patches/Servicios/sbin/www/unzip_file.php

https://github.com/frisco82/HMR600.com-Firmware
PHP | 34 lines | 26 code | 5 blank | 3 comment | 8 complexity | f1f90ac4d3f0bd04c4953739e0f5052b MD5 | raw file
  1. <?
  2. header('Content-Type: text/html; charset=utf-8');
  3. error_reporting(0);
  4. include '/tmp/lang.php';
  5. $dir = $_GET['dir'];
  6. //$target_dir = "/tmp/usbmounts" . $_GET['dir'];
  7. $filename = $_GET['file'];
  8. //echo "<script>alert('$filename');</script>";
  9. if (substr($dir, 0, 12) == "/tmp/myshare")
  10. $target_dir = $_GET['dir'];
  11. else
  12. $target_dir = "/tmp/usbmounts" . $_GET['dir'];
  13. $target_dir = str_replace("(", "\(", $target_dir);
  14. $target_dir = str_replace(")", "\)", $target_dir);
  15. $target_dir = str_replace(" ", "\ ", $target_dir);
  16. $filename = str_replace(" ", "\ ", $filename);
  17. $filename = str_replace("(", "\(", $filename);
  18. $filename = str_replace(")", "\)", $filename);
  19. if (strtolower(strrchr($filename,'.')) == ".zip"){
  20. $cmd = "unzip " . $filename." -d ".$target_dir;
  21. }else if (strtolower(strrchr($filename,'.')) == ".tar"){
  22. $cmd = "tar xf " . $filename." -C ".$target_dir;
  23. }else if (strtolower(strrchr($filename,'.')) == ".bz2"){
  24. $cmd = "tar -xjvf " . $filename." -C ".$target_dir;
  25. }
  26. //echo "<script>alert('$cmd');</script>";
  27. exec($cmd);
  28. echo "<script>parent.document.location.href = 'unzip.php?dir=$dir';</script>";
  29. ?>