PageRenderTime 19ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/classes/options/unzip.php

http://rapidleech36b.googlecode.com/
PHP | 96 lines | 95 code | 1 blank | 0 comment | 16 complexity | b2a9ea5d9e9677ebfa79f5a43e96afd7 MD5 | raw file
  1. <?php
  2. function unzip() {
  3. global $list, $PHP_SELF, $L;
  4. ?>
  5. <form method="post" action="<?php echo $PHP_SELF; ?>">
  6. <input type="hidden" name="act" value="unzip_go" />
  7. <table align="center">
  8. <tr>
  9. <td>
  10. <table>
  11. <?php
  12. for($i = 0; $i < count ( $_GET ["files"] ); $i ++) {
  13. $file = $list [$_GET ["files"] [$i]];
  14. require_once (CLASS_DIR . "unzip.php");
  15. if (file_exists($file['name'])) {
  16. $zip = new dUnzip2 ( $file['name'] );
  17. $flist = $zip->getList();
  18. ?>
  19. <tr><td align="center">
  20. <input type="hidden" name="files[]" value="<?php echo $_GET['files'][$i]; ?>" />
  21. <b><?php echo basename($file['name']); ?></b> (<?php echo count($flist).' '.$L->say['_filefolder']; ?>)
  22. </td></tr>
  23. <tr><td>
  24. <div style="overflow-y:scroll; height:150px; padding-left:5px;">
  25. <?php
  26. foreach ($flist as $property) {
  27. echo($property['file_name'].'<br />');
  28. }
  29. ?>
  30. </div>
  31. </td></tr>
  32. <?php
  33. }
  34. }
  35. ?>
  36. </table>
  37. </td>
  38. <td><input type="submit" name="submit" value="<?php echo $L->say['_unzip']; ?>" /></td>
  39. </tr>
  40. <tr><td></td></tr>
  41. </table>
  42. </form>
  43. <?php
  44. }
  45. function unzip_go() {
  46. global $list, $options, $L;
  47. require_once (CLASS_DIR . "unzip.php");
  48. $any_file_unzippped = false;
  49. for($i = 0; $i < count ( $_POST ["files"] ); $i ++) {
  50. $file = $list [$_POST ["files"] [$i]];
  51. if (file_exists ( $file ["name"] )) {
  52. $zip = new dUnzip2 ( $file ["name"] );
  53. $allf = $zip->getList ();
  54. $file_inside_zip_exists = false;
  55. $forbidden_inside_zip = false;
  56. foreach ($allf as $k => $properties) {
  57. if (file_exists($options['download_dir'].basename($properties['file_name']))) {
  58. $file_inside_zip_exists = true; break;
  59. }
  60. }
  61. if ($options['check_these_before_unzipping']) {
  62. foreach ( $allf as $k => $property ) {
  63. $zfiletype = strrchr ( $property ['file_name'], "." );
  64. if (is_array ( $options['forbidden_filetypes'] ) && in_array ( strtolower ( $zfiletype ), $options['forbidden_filetypes'] )) {
  65. $forbidden_inside_zip = true; break;
  66. }
  67. }
  68. }
  69. if ($file_inside_zip_exists) {
  70. echo 'Some file(s) inside <b>'.htmlentities(basename($file["name"])).'</b> already exist on download directory';
  71. echo "<br /><br />";
  72. } elseif ($forbidden_inside_zip) {
  73. echo $L->sprintf($L->say['_err_filetype'], $zfiletype)."<br /><br />";
  74. } else {
  75. $zip->unzipAll ( $options['download_dir'] );
  76. if ($zip->getList () != false) {
  77. $any_file_unzippped = true;
  78. echo '<b>'.htmlentities(basename($file["name"])).'</b>&nbsp;unzipped successfully<br /><br />';
  79. foreach ($allf as $k => $properties) {
  80. $efile = realpath($options['download_dir']).'/'.basename($properties['file_name']);
  81. if (is_file($efile)) {
  82. $time = getNowzone(@filemtime($efile)); while (isset($list[$time])) { $time++; }
  83. $list[$time] = array("name" => $efile, "size" => bytesToKbOrMbOrGb(filesize($efile)), "date" => $time);
  84. }
  85. }
  86. if (!updateListInFile($list)) { echo $L->say['couldnt_upd_list']."<br /><br />"; }
  87. }
  88. else {
  89. echo "File <b>".$file["name"]."</b> not found!<br /><br />";
  90. }
  91. }
  92. }
  93. }
  94. }
  95. ?>