Просмотр файла download/include/jad_file.php

Размер файла: 1.89Kb
  1. <?php
  2.  
  3. $sql->query("SELECT * FROM `down_files` WHERE `id` = '$id' AND (`type` = 2 OR `type` = 3) LIMIT 1");
  4. $res_down = $sql->fetch();
  5.  
  6. if ($sql->num_rows() == 0 || !is_file($res_down['dir'] . '/' . $res_down['name']) || format($res_down['name']) != 'jar' || ($res_down['type'] == 3 && !$admin)) {
  7. include H.'engine/includes/head.php'; echo display_error('Файл не найден<br /><a href="index.php">К категориям</a>');
  8. include H.'engine/includes/foot.php';
  9. }
  10.  
  11. if (isset($_GET['more'])) {
  12. $more = abs(intval($_GET['more']));
  13. $rsql->query("SELECT * FROM `down_more` WHERE `id` = '$more' LIMIT 1");
  14. $res_more = $sql->fetch();
  15. if (!$sql->num_rows() || !is_file($res_down['dir'] . '/' . $res_more['name']) || format($res_more['name']) != 'jar') {
  16. include H.'engine/includes/head.php'; echo display_error('Файл не найден<br /><a href="index.php">К категориям</a>');
  17. include H.'engine/includes/foot.php';
  18. }
  19. $down_file = $res_down['dir'] . '/' . $res_more['name'];
  20. $jar_file = $res_more['name'];
  21. }
  22. else {
  23. $down_file = $res_down['dir'] . '/' . $res_down['name'];
  24. $jar_file = $res_down['name'];
  25. }
  26.  
  27. if (!isset($_SESSION['down_' . $id])) {
  28. $sql->query("UPDATE `down_files` SET `field`=`field`+1 WHERE `id`='$id'");
  29. $_SESSION['down_' . $id] = 1;
  30. }
  31.  
  32. $size = filesize($down_file);
  33. require_once H.'engine/classes/zip.php';
  34. $zip = new PclZip($down_file);
  35. $content = $zip->extract(PCLZIP_OPT_BY_NAME, 'META-INF/MANIFEST.MF', PCLZIP_OPT_EXTRACT_AS_STRING);
  36. header('Content-type: text/vnd.sun.j2me.app-descriptor');
  37. header('Content-Disposition: attachment; filename="' . basename($down_file) . '.jad";');
  38. echo $content[0]['content'] . "\n" . 'MIDlet-Jar-Size: ' . $size . "\n" . 'MIDlet-Jar-URL: ' . $home . '/' . str_replace($filesroot, $dir_load, $res_down['dir']) . '/' . $jar_file;
  39. exit;