public function testSetLogFileFail()
 {
     // tricky to test: given logfile must exist but we don't have the
     // path to error.log - test for failure only
     $this->dl->setLogFile('does-not-exist.log');
     // there is no getLogFile() method ...
     $this->assertEquals('', $this->dl->getLogFile());
 }
Example #2
0
/**
*   Download a backup file
*
*   @param  string  $file   Filename (without the path)
*   @return void
*   @note   Filename should have been sanitized and checked before calling this.
*
*/
function DBADMIN_download($file)
{
    global $_CONF;
    require_once $_CONF['path_system'] . 'classes/downloader.class.php';
    $dl = new downloader();
    $dl->setLogFile($_CONF['path'] . 'logs/error.log');
    $dl->setLogging(true);
    $dl->setDebug(true);
    $dl->setPath($_CONF['backup_path']);
    $dl->setAllowedExtensions(array('sql' => 'application/x-gzip-compressed', 'gz' => 'application/x-gzip-compressed'));
    $dl->downloadFile($file);
}
Example #3
0
     echo COM_endBlock();
     echo COM_siteFooter();
 }
 if (DB_count($_TABLES['nxfile_filesubmissions'], 'id', $fid) > 0) {
     include_once $_CONF['path_system'] . 'classes/downloader.class.php';
     $query = DB_query("SELECT cid,ftype,fname,tempname FROM {$_TABLES['nxfile_filesubmissions']} WHERE id={$fid}");
     list($cid, $ftype, $fname, $tname) = DB_fetchARRAY($query);
     $directory = $_FMCONF['storage_path'] . $cid . '/submissions/';
     $logfile = $_CONF['path'] . 'logs/error.log';
     if ($ftype == "file") {
         $pos = strrpos($tname, '.') + 1;
         $ext = strtolower(substr($tname, $pos));
         $download = new downloader();
         $download->_setAvailableExtensions($_FMCONF['downloadfiletypes']);
         $download->setAllowedExtensions($_FMCONF['downloadfiletypes']);
         $download->setLogFile($logfile);
         $download->setLogging(true);
         $download->setPath($directory);
         $download->downloadFile($tname);
         DB_query("UPDATE {$_TABLES['nxfile_filedetail']} SET hits = hits +1 WHERE fid='{$fid}' ");
         if ($download->areErrors()) {
             echo $LANG_FMERR['download1'];
             echo $download->printWarnings();
             echo $download->printErrors();
             return false;
         }
     } else {
         $url = $fname;
         if ($fd = fopen($url, "rb")) {
             $pos = strrpos($url, "/") + 1;
             $fname = substr($url, $pos);
Example #4
0
$A = DB_fetchArray($res, false);
//  If a file was found, do the download.
//  Otherwise refresh to the home page and log it.
if (is_array($A) && !empty($A['file'])) {
    $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}.");
Example #5
0
// | along with this program; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
// |                                                                           |
// +---------------------------------------------------------------------------+
/**
* For really strict webhosts, this file an be used to show images in pages that
* serve the images from outside of the webtree to a place that the webserver
* user can actually write too
*
* @author   Tony Bibbs, tony AT tonybibbs DOT com
*
*/
require_once 'lib-common.php';
require_once $_CONF['path_system'] . 'classes/downloader.class.php';
$downloader = new downloader();
$downloader->setLogFile($_CONF['path_log'] . 'error.log');
$downloader->setLogging(true);
$downloader->setAllowedExtensions(array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'png' => 'image/x-png'));
COM_setArgNames(array('mode', 'image'));
$mode = COM_applyFilter(COM_getArgument('mode'));
$image = COM_applyFilter(COM_getArgument('image'));
if (strstr($image, '..')) {
    // Can you believe this, some jackass tried to relative pathing to access
    // files they shouldn't have access to?
    COM_accessLog('Someone tried to illegally access files using getimage.php');
    exit;
}
// Set the path properly
switch ($mode) {
    case 'show':
    case 'articles':
Example #6
0
/**
 * Require Downloader Class
 */
require_once $_CONF['path'] . 'system/classes/downloader.class.php';
// Incoming variable filter
$vars = array('id' => 'number');
paypal_filterVars($vars, $_REQUEST);
// This sql does double duty of getting the file name to download and making sure that the
// user has 'permission' to get it
$sql = "SELECT d.id, d.file, d.product_type, d.active FROM " . "{$_TABLES['paypal_products']} as d LEFT JOIN {$_TABLES['paypal_purchases']} as p " . "ON d.id = p.product_id WHERE d.id = {$_REQUEST['id']} AND " . "((p.user_id = {$_USER['uid']} AND (p.expiration > NOW() OR p.expiration IS NULL)) " . "OR (d.price <= 0)) LIMIT 1";
$res = DB_query($sql);
$A = DB_fetchArray($res);
// If a file was found, do the download.  Otherwise refresh to the home page and log it.
if (!empty($A['file']) && $A['product_type'] == '1' && $A['active'] == '1') {
    $dwnld = new downloader();
    $dwnld->setLogFile($_CONF['path_log'] . 'paypal_downloads.log');
    $dwnld->setLogging(true);
    $dwnld->setAllowedExtensions($_PAY_CONF['allowedextensions']);
    $dwnld->setPath($_PAY_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 " . "{$_REQUEST['id']} but for some reason could not. Download path is set to: " . $_PAY_CONF['download_path'], 1);
        COM_errorLog("PAYPAL-DWNLD: {$errs}", 1);
        echo COM_refresh($_CONF['site_url']);
    } else {
        $dwnld->_logItem('Download Success', "{$_USER['username']} successfully downloaded " . "the file with id {$_REQUEST['id']}.");
        $sql = "INSERT INTO {$_TABLES['paypal_downloads']} SET product_id = {$A['id']}, " . "file = '{$A['file']}', user_id = {$_USER['uid']}, " . "dl_date = NOW()";
        DB_query($sql);
    }