Example #1
0
    $dwnld = new downloader();
    $logfile = $_PP_CONF['logfile'];
    if (!file_exists($logfile)) {
        $fp = fopen($logfile, "w+");
        if (!$fp) {
            COM_errorLog("Failed to create {$logfile}", 1);
        } else {
            fwrite($fp, "**** Created Logfile ***\n");
        }
    }
    if (file_exists($logfile)) {
        $dwnld->setLogFile($logfile);
        $dwnld->setLogging(true);
    } else {
        $dwnld->setLogginf(false);
    }
    $dwnld->setAllowedExtensions($_PP_CONF['allowedextensions']);
    $dwnld->setPath($_PP_CONF['download_path']);
    $dwnld->downloadFile($A['file']);
    // Check for errors
    if ($dwnld->areErrors()) {
        $errs = $dwnld->printErrors(false);
        COM_errorLog("PAYPAL-DWNLD: {$_USER['username']} tried to download " . "the file with id {$id} but for some reason could not", 1);
        COM_errorLog("PAYPAL-DWNLD: {$errs}", 1);
        echo COM_refresh($_CONF['site_url']);
    }
    $dwnld->_logItem('Download Success', "{$_USER['username']} successfully downloaded " . "the file with id {$id}.");
} else {
    COM_errorLog("PAYPAL-DWNLD: {$_USER['username']}/{$_USER['uid']} " . "tried to download the file with id {$id} " . "but this is not a downloadable file", 1);
    echo COM_refresh($_CONF['site_url'] . '/index.php?msg=07&plugin=paypal');
}