Exemple #1
0
        $file_extension = $regs[2];
        $file['file_name'] = $file_name . ($size ? "_" . $size : "") . "." . $file_extension;
        $file['file_path'] = is_local_file($image_row['image_media_file']) ? dirname($image_row['image_media_file']) . "/" . $file['file_name'] : MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $file['file_name'];
    }
    if ($user_info['user_level'] != ADMIN) {
        $sql = "UPDATE " . IMAGES_TABLE . "\n            SET image_downloads = image_downloads + 1\n            WHERE image_id = {$image_id}";
        $site_db->query($sql);
    }
    if (!empty($file['file_path'])) {
        @set_time_limit(120);
        if ($remote_url) {
            redirect($file['file_path']);
        }
        if ($action == "zip" && !preg_match("/\\.zip\$/i", $file['file_name']) && function_exists("gzcompress") && function_exists("crc32")) {
            include ROOT_PATH . "includes/zip.php";
            $zipfile = new zipfile();
            $zipfile->add_file(file_get_contents($file['file_path']), $file['file_name']);
            $zipfile->send(get_file_name($file['file_name']) . ".zip");
        } else {
            send_file($file['file_name'], $file['file_path']);
        }
        exit;
    } else {
        echo $lang['download_error'] . "\n<!-- EMPTY FILE PATH //-->";
        exit;
    }
} else {
    echo $lang['download_error'] . "\n<!-- NO ACTION SPECIFIED //-->";
    exit;
}
exit;