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

Размер файла: 1.05Kb
  1. <?php
  2.  
  3. if ($admin)
  4. {
  5. if(isset($_GET['cat'])) {
  6. $req = mysqli_query($sql->db, "SELECT `dir`, `name` FROM `down_files` WHERE `id` = '$id' AND `type` = 1 LIMIT 1");
  7. if (mysqli_num_rows($req)) {
  8. $res = mysqli_fetch_assoc($req);
  9. $dir_files = $sql->query("SELECT COUNT(*) FROM `down_files` WHERE `type` = '2' AND `dir` LIKE '" . ($res['dir'] . '/' . $res['name']) . "%'")->result();
  10. $sql->query("UPDATE `down_files` SET `total` = '$dir_files' WHERE `id` = '$id'");
  11. }
  12. }
  13. else {
  14. $req_down = mysqli_query($sql->db, "SELECT `dir`, `name`, `id` FROM `down_files` WHERE `type` = 1");
  15. while ($res_down = mysqli_fetch_assoc($req_down)) {
  16. $dir_files = $sql->query("SELECT COUNT(*) FROM `down_files` WHERE `type` = '2' AND `dir` LIKE '" . ($res_down['dir'] . '/' . $res_down['name']) . "%'")->result();
  17. $sql->query("UPDATE `down_files` SET `total` = '$dir_files' WHERE `id` = '" . $res_down['id'] . "'");
  18. }
  19. }
  20. }
  21. header('location: index.php?id=' . $id);