Example #1
0
        list($cid, $fname, $ftype, $mimetype) = DB_fetchARRAY($query);
    }
    // Make sure user has access
    if (!fm_getPermission($cid, 'view')) {
        echo COM_refresh($_CONF['site_url'] . '?msg=1&plugin=nexfile');
        exit;
    }
    if ($ftype == "file") {
        $directory = $_FMCONF['storage_path'] . $cid . '/';
        $logfile = $_CONF['path'] . 'logs/error.log';
        $pos = strrpos($fname, '.') + 1;
        $ext = substr($fname, $pos);
        // Open this file and stream it to the end user
        $download = new downloader();
        if (!empty($mimetype)) {
            $download->addAvailableExtensions(array($ext => $mimetype));
        }
        $download->setLogFile($logfile);
        $download->setLogging(true);
        $download->setPath($directory);
        $download->downloadFile($fname);
        DB_query("UPDATE {$_TABLES['nxfile_filedetail']} SET hits = hits +1 WHERE fid='{$fid}' ");
        DB_query("INSERT INTO {$_TABLES['nxfile_downloads']} (uid,fid,remote_ip,date) VALUES ('{$_USER['uid']}',{$fid},'{$_SERVER['REMOTE_ADDR']}',NOW() )");
        if ($download->areErrors()) {
            $err = $download->printWarnings();
            $err .= "\n" . $download->printErrors();
            COM_errorLog("nexFile: Download error for user: {$_USER['uid']} - file: {$fname}. {$err}");
            return false;
        }
    }
} elseif ($_GET['op'] == "incoming") {