q("SELECT * FROM `_sys_files` WHERE `id` = '".intval($_GET['id'])."'"); if ($core_db->r()) { if ($core_db->f('private') == 1) { session_start(); $sess_id = session_id(); $dbAuth = $core_db->new_db(); $dbAuth->q('SELECT `id` FROM `_sys_user_sessions` WHERE `session_id` = "'.db_escape_string($sess_id).'" '); // Неавторизированному пользователю пустая картинка if (!$dbAuth->nr()) { header('Content-Disposition: attachment; filename=empty.gif'); header('Content-type: image/gif'); die(base64_decode($transparentPixelGif)); } } header('Content-Disposition: attachment; filename=' . $core_db->f('realname')); header('Content-type: ' . $core_db->f('ext')); die(file_get_contents(_FILES_DIR_ . $core_db->f('filename'))); } else { $transparentPixelGif = 'R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; header('Content-type: image/gif'); header('Content-Disposition: attachment; filename=empty.gif'); die(base64_decode($transparentPixelGif)); }