Пример #1
0
if ($moderators) {
    $mods_array = unserialize($moderators);
}
$is_admmod = $pun_user['g_id'] == PUN_ADMIN || $pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array) ? true : false;
$can_download = !$file_download && $pun_user['g_file_download'] == 1 || $file_download == 1 || $is_admmod;
// author of post always can download his attachments
// other users can has rights or not
$is_image = preg_match('/^image\\/(?:.*)$/i', $mime);
if (!$can_download && !($poster_id == $pun_user['id'])) {
    if ($is_image) {
        // show noaccess icon instead of image
        $location = PUN_ROOT . $pun_config['file_thumb_path'] . 'err_access.gif';
        $mime = 'image/gif';
    } else {
        message('Access denied');
    }
}
if (!is_file($location)) {
    error($location . ' - this file does not exist', __FILE__, __LINE__);
}
$db->query('UPDATE `' . $db->prefix . 'attachments` SET `downloads` = `downloads` + 1 WHERE `id`=' . $aid) or error('Unable to update download counter', __FILE__, __LINE__, $db->error());
$getf = new Getf();
$getf->get(file_get_contents($location), $file, $mime == 'application/octet-stream' ? null : $mime, !$is_image);
exit;
/*
header('Content-type: '.$mime);
header('Content-Disposition: attachment; filename="'.$file.'";');
header('Accept-Ranges: bytes');
header('Content-Length: '.filesize($location));
exit(file_get_contents($location));
*/
Пример #2
0
$_GET['go'] = isset($_GET['go']) ? $_GET['go'] : '';
if (isset($_GET['get']) && Gmanager::getInstance()->is_file($_GET['get'])) {
    if (isset($_GET['f'])) {
        $archive = Helper_Archive::isArchive(Helper_System::getType(Helper_System::basename($_GET['get'])));
        if ($archive && $archive != Archive::FORMAT_GZ) {
            $obj = new Archive();
            $f = $obj->setFormat($archive)->setFile($_GET['get'])->factory()->lookFile($_GET['f'], true);
        } else {
            $f = '';
        }
        $name = Helper_System::basename($_GET['f']);
    } else {
        $f = Gmanager::getInstance()->file_get_contents($_GET['get']);
        $name = Helper_System::basename($_GET['get']);
    }
    Getf::download($f, $name, true, false);
    exit;
}
if (Registry::get('currentType') == 'link') {
    $realpath = Registry::get('current');
} else {
    $realpath = Gmanager::getInstance()->realpath(Registry::get('current'));
    if ($realpath && Registry::get('currentType') == 'dir') {
        $realpath .= '/';
    }
}
$realpath = $realpath ? htmlspecialchars(str_replace('\\', '/', $realpath), ENT_COMPAT) : Registry::get('hCurrent');
Gmanager::getInstance()->sendHeader();
if ($_GET['go'] == 'phpinfo') {
    header('Content-Type: text/html; charset=UTF-8');
    phpinfo();
Пример #3
0
$_GET['go'] = isset($_GET['go']) ? $_GET['go'] : '';
if (isset($_GET['get']) && Gmanager::getInstance()->is_file($_GET['get'])) {
    if (isset($_GET['f'])) {
        $archive = Helper_Archive::isArchive(Helper_System::getType(Helper_System::basename($_GET['get'])));
        if ($archive && $archive != Archive::FORMAT_GZ) {
            $obj = new Archive();
            $f = $obj->setFormat($archive)->setFile($_GET['get'])->factory()->lookFile($_GET['f'], true);
        } else {
            $f = '';
        }
        $name = Helper_System::basename($_GET['f']);
    } else {
        $f = Gmanager::getInstance()->file_get_contents($_GET['get']);
        $name = Helper_System::basename($_GET['get']);
    }
    Getf::download($f, $name, true);
    exit;
}
if (Registry::get('currentType') == 'link') {
    $realpath = Registry::get('current');
} else {
    $realpath = Gmanager::getInstance()->realpath(Registry::get('current'));
    if ($realpath && Registry::get('currentType') == 'dir') {
        $realpath .= '/';
    }
}
$realpath = $realpath ? htmlspecialchars(str_replace('\\', '/', $realpath), ENT_COMPAT) : Registry::get('hCurrent');
Gmanager::getInstance()->sendHeader();
if ($_GET['go'] == 'phpinfo') {
    header('Content-Type: text/html; charset=UTF-8');
    phpinfo();