Beispiel #1
0
function unrar()
{
    global $PHP_SELF, $options, $list, $L;
    require_once CLASS_DIR . "rar.php";
    ?>
<script type="text/javascript">
/* <![CDATA[ */
function unrar_setCheckboxes(act, filestounrar) {
  var elts = document.getElementsByName('filestounrar['+filestounrar+'][]');
  var elts_cnt = (typeof(elts) != 'undefined') ? elts.length : 0;
  if (elts_cnt) {
    for (var i = 0; i < elts_cnt; i++) {
      elts[i].checked = (act == 1 || act == 0) ? act : elts[i].checked ? 0 : 1;
    }
  }
}
/* ]]> */
</script>
  <form name="unrar_files" method="post" action="<?php 
    echo $PHP_SELF;
    ?>
">
    <table align="center">
      <tr>
        <td>
          <table>
<?php 
    $rar_passl_needed = false;
    $any_file_tounrar = false;
    for ($i = 0; $i < count($_GET["files"]); $i++) {
        $file = $list[$_GET["files"][$i]];
        ?>
            <tr align="center">
              <td colspan="2" class="rar-table-main">
                <input type="hidden" name="files[<?php 
        echo $i;
        ?>
]" value="<?php 
        echo $_GET["files"][$i];
        ?>
" />
                <?php 
        echo $L->sprintf($L->say['_filefr'], htmlentities(basename($file["name"])));
        ?>
                <br />
                <a href="javascript:unrar_setCheckboxes(1, <?php 
        echo $i;
        ?>
);"><?php 
        echo $L->say['chk_all'];
        ?>
</a> |
                <a href="javascript:unrar_setCheckboxes(0, <?php 
        echo $i;
        ?>
);"><?php 
        echo $L->say['chk_unchk'];
        ?>
</a> |
                <a href="javascript:unrar_setCheckboxes(2, <?php 
        echo $i;
        ?>
);"><?php 
        echo $L->say['chk_invert'];
        ?>
</a>
              </td>
            </tr>

            <tr>
              <td colspan="2" class="rar-table-side">
                &nbsp;
<?php 
        unset($rar);
        $rar = new rlRar($file["name"], $options['check_these_before_unzipping'] ? $options['forbidden_filetypes'] : array('.xxx'));
        if ($rar->rar_return === false) {
            echo $L->say['_unrar'];
        } else {
            $rar_list = $rar->listthem(@$_GET['passwords'][$i], $options['download_dir'], $i);
            if ($rar_list[0] == 'PASS') {
                $rar_passl_needed = true;
                echo $L->say['_passlist'];
            } elseif ($rar_list['NEEDP'] == true) {
                echo $L->say['_passext'];
            } elseif ($rar_list[0] == 'ERROR') {
                echo $L->sprintf($L->say['_unrarerr'], $rar_list[1] . ' ' . $rar_list[2]);
            }
        }
        ?>
                <input type="<?php 
        echo $rar_list['NEEDP'] == true ? 'password' : 'hidden';
        ?>
" name="passwords[]" value="<?php 
        echo $_GET['passwords'][$i];
        ?>
" />
                &nbsp;
              </td>
            </tr>
<?php 
        if ($rar_list[0] == 'LIST') {
            $any_file_tounrar = true;
            $rar_list = $rar_list[2];
            foreach ($rar_list as $rar_key => $rar_item) {
                ?>
            <tr>
              <td class="rar-table-left">
                <input type="checkbox" name="filestounrar[<?php 
                echo $i;
                ?>
][]" checked="checked" value="<?php 
                echo base64_encode($rar_key);
                ?>
" />
              </td>
              <td class="rar-table-right"><?php 
                echo $rar_key . ' (' . bytesToKbOrMbOrGb($rar_item['size']) . ')';
                ?>
</td>
            </tr>
<?php 
            }
        }
        ?>
            <tr>
              <td colspan="2" class="rar-table-top" style="border-top:1px solid #666;">&nbsp;</td>
            </tr>
<?php 
    }
    ?>
          </table>
        </td>
      </tr>
      <tr>
        <td align="center">
          <input type="hidden" name="act" value="<?php 
    echo $rar_passl_needed ? 'unrar' : 'unrar_go';
    ?>
" />
          <input type="submit" value="<?php 
    echo $rar_passl_needed ? $L->say['_trylist'] : $L->say['_unrarsel'];
    ?>
" />
        </td>
      </tr>
      <tr>
        <td>
        </td>
      </tr>
    </table>
  </form>
<?php 
}