Esempio n. 1
0
function misc_downloadfile()
{
    global $set, $db, $apx, $user;
    $_REQUEST['id'] = (int) $_REQUEST['id'];
    if (!$_REQUEST['id']) {
        die('missing ID!');
    }
    if ($set['downloads']['regonly'] && !$user->info['userid']) {
        die('download only for registered users!');
    }
    $apx->lang->drop('detail', 'downloads');
    //Secure Check
    $res = $db->first("SELECT id,title,file,local,filesize,regonly," . PRE . "_downloads.limit,password FROM " . PRE . "_downloads WHERE ( id='" . $_REQUEST['id'] . "' " . iif(!$user->is_team_member(), "AND ( '" . time() . "' BETWEEN starttime AND endtime )") . " " . section_filter() . " ) LIMIT 1");
    if (!$res['id']) {
        die('file not found!');
    }
    if ($res['regonly'] && !$user->info['userid']) {
        die('download only for registered users!');
    }
    if (downloads_limit_is_reached($res['id'], $res['limit'])) {
        message($apx->lang->get('MSG_LIMITREACHED'), 'back');
    }
    if ($res['password'] && $_POST['password'] != $res['password']) {
        tmessage('pwdrequired', array('ID' => $_REQUEST['id'], 'SECHASH' => $_REQUEST['sechash']), 'downloads');
    }
    $checkhash = md5($_SERVER['HTTP_HOST'] . $res['file'] . date('Y/m/d', time() - TIMEDIFF));
    if ($checkhash != $_REQUEST['sechash']) {
        header("HTTP/1.1 301 Moved Permanently");
        header('location:' . str_replace('&', '&', mklink('downloads.php?id=' . $_REQUEST['id'], 'downloads,id' . $_REQUEST['id'] . urlformat($res['title']) . '.html')));
        exit;
    }
    //Statistik
    $thefsize = downloads_filesize($res);
    downloads_insert_stats($res['id'], $thefsize, $res['local']);
    //Datei senden
    if (!$res['local']) {
        header("HTTP/1.1 301 Moved Permanently");
        header('location:' . $res['file']);
        exit;
    } else {
        header("HTTP/1.1 301 Moved Permanently");
        header('location:' . HTTPDIR . getpath('uploads') . $res['file']);
        exit;
    }
}
Esempio n. 2
0
 $apx->tmpl->assign('AUTHOR', replace($res['author']));
 $apx->tmpl->assign('AUTHOR_LINK', replace($res['author_link']));
 $apx->tmpl->assign('MIRROR', downloads_mirrors($res['id'], $res['mirrors']));
 $apx->tmpl->assign('PICTURE', downloads_pictures($res['pictures']));
 //Download-Zeit
 $apx->tmpl->assign('TIME_MODEM', downloads_gettime($thefsize, 56));
 $apx->tmpl->assign('TIME_ISDN', downloads_gettime($thefsize, 64));
 $apx->tmpl->assign('TIME_ISDN2', downloads_gettime($thefsize, 128));
 $apx->tmpl->assign('TIME_DSL1000', downloads_gettime($thefsize, 1024));
 $apx->tmpl->assign('TIME_DSL2000', downloads_gettime($thefsize, 1024 * 2));
 $apx->tmpl->assign('TIME_DSL6000', downloads_gettime($thefsize, 1024 * 6));
 $apx->tmpl->assign('TIME_DSL10000', downloads_gettime($thefsize, 1024 * 10));
 $apx->tmpl->assign('TIME_DSL12000', downloads_gettime($thefsize, 1024 * 12));
 $apx->tmpl->assign('TIME_DSL16000', downloads_gettime($thefsize, 1024 * 16));
 //Download-Limit
 if (downloads_limit_is_reached($res['id'], $res['limit'])) {
     $apx->tmpl->assign('LIMIT', 1);
 }
 //Kategorie
 $apx->tmpl->assign('CATID', $res['catid']);
 $apx->tmpl->assign('CATTITLE', $catinfo['title']);
 $apx->tmpl->assign('CATTEXT', $catinfo['text']);
 $apx->tmpl->assign('CATICON', $catinfo['icon']);
 $apx->tmpl->assign('CATCOUNT', $catcount);
 $apx->tmpl->assign('CATLINK', mklink('downloads.php?catid=' . $catinfo['catid'], 'downloads,' . $catinfo['catid'] . ',1' . urlformat($catinfo['title']) . '.html'));
 //Pfad
 if (in_array('PATH', $parse)) {
     $apx->tmpl->assign('PATH', downloads_path($res['catid']));
 }
 //Galerie
 if ($apx->is_module('gallery') && $res['galid']) {