View file download/include/recount.php

File size: 1.04Kb
<?php

if ($admin)
 {
    if(isset($_GET['cat'])) {
        $req = mysql_query("SELECT `dir`, `name` FROM `down_files` WHERE `id` = '$id' AND `type` = 1 LIMIT 1");
        if (mysql_num_rows($req)) {
            $res = mysql_fetch_assoc($req);
            $dir_files = mysql_result(mysql_query("SELECT COUNT(*) FROM `down_files` WHERE `type` = '2' AND `dir` LIKE '" . ($res['dir'] . '/' . $res['name']) . "%'"), 0);
            mysql_query("UPDATE `down_files` SET `total` = '$dir_files' WHERE `id` = '$id'");
        }
    }
    else {
        $req_down = mysql_query("SELECT `dir`, `name`, `id` FROM `down_files` WHERE `type` = 1");
        while ($res_down = mysql_fetch_assoc($req_down)) {
            $dir_files = mysql_result(mysql_query("SELECT COUNT(*) FROM `down_files` WHERE `type` = '2' AND `dir` LIKE '" . ($res_down['dir'] . '/' . $res_down['name']) . "%'"), 0);
            mysql_query("UPDATE `down_files` SET `total` = '$dir_files' WHERE `id` = '" . $res_down['id']  . "'");
        }
    }
}
header('location: index.php?id=' . $id);