Exemplo n.º 1
0
function main()
{
    global $lang;
    global $fileid;
    global $catid;
    global $user;
    global $site;
    global $category;
    global $file;
    if (!is_bool($catid) && is_numeric($catid)) {
        try {
            $category = new CodeKBCategory($catid, $user);
        } catch (Exception $e) {
            $site->addcontent(notice($lang['category']['nosuchcat']));
            return false;
        }
    }
    try {
        $file = new CodeKBFile($fileid, $user);
    } catch (Exception $e) {
        $site->addcontent(notice($lang['file']['nosuchfile']));
        return false;
    }
    if (!$file->downloadable()) {
        $site->addcontent(notice($lang['file']['nosuchfile']));
        return false;
    }
    if ($category) {
        $site->navigation($category, $file->entry());
        $catid = $category->id();
        $site->catid($catid);
    }
    return true;
}