<?php
require_once "../lib/config.php";

class kyczipdl extends System {
    
    /**
     *
     * @var zipdl
     */
    private static $instance = null;
    
    public function __construct(){
        parent::__construct();
    }
    
    /**
     *
     * renders the content of a zip file to be downloaded
     *
     */
    public function render(){        
        $downloadable = urldecode($this->getDataGet("f"));
        
        if(!@file_exists($downloadable)){
            http_response_code(404);
            
            die("404 Not Found");
        }
        
        header("Content-Type: application/zip");
        header("Content-Disposition: attachment; filename=\"".basename($downloadable)."\"");
        header("Content-Length: ".filesize($downloadable));
        
        readfile($downloadable);
        
        unlink($downloadable);
    }
    
    public static function getInstance(){        
        if(is_null(self::$instance)){
            self::$instance = new kyczipdl();
        }
        
        return self::$instance;
    }
}

kyczipdl::getInstance()->render();