// проверка на существование файла |
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_files` WHERE `id` = '".intval($_GET['id'])."'"),0)==1){ |
$file=mysql_fetch_array(mysql_query("SELECT * FROM `forum_files` WHERE `id` = '".intval($_GET['id'])."' LIMIT 1")); |
if (is_file(H.'sys/forum/files/'.$file['id'].'.frf') && isset($user) && $user['level']>=1 && isset($_GET['del'])){ |
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL){ |
$link =$_SERVER['HTTP_REFERER']; |
}else{ |
$link='/index.php';} |
mysql_query("DELETE FROM `forum_files` WHERE `id` = '$file[id]' LIMIT 1"); |
unlink(H.'sys/forum/files/'.$file['id'].'.frf'); |
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL){ |
header("Location: $_SERVER[HTTP_REFERER]"); |
}else{ |
header("Location: /forum/index.php?".SID);} |
}else if (is_file(H.'sys/forum/files/'.$file['id'].'.frf')){ |
mysql_query("UPDATE `forum_files` SET `count` = '".($file['count']+1)."' WHERE `id` = '$file[id]' LIMIT 1"); |
DownloadFile(H.'sys/forum/files/'.$file['id'].'.frf', $file['name'].'.'.$file['ras'],$file['type']); |
exit;} |
function DownloadFile($filename, $name, $mimetype='application/octet-stream'){ |
if (!file_exists($filename)) |
die('Файл не найден'); |
$from=0; |
$size=filesize($filename); |
$to=$size; |
if(isset($_SERVER['HTTP_RANGE'])){ |
if (eregi ('bytes=-([0-9]*)',$_SERVER['HTTP_RANGE'],$range)){ // если указан отрезок от конца файла |
$from=$size-$range[1]; |
$to=$size; |
}elseif(eregi('bytes=([0-9]*)-',$_SERVER['HTTP_RANGE'],$range)){ // если указана только начальная метка |
$from=$range[1]; |
$to=$size; |
}elseif(eregi('bytes=([0-9]*)-([0-9]*)',$_SERVER['HTTP_RANGE'],$range)){ // если указан отрезок файла |
$from=$range[1]; |
$to=$range[2];} |
header('HTTP/1.1 206 Partial Content'); |
$cr='Content-Range: bytes '.$from .'-'.$to.'/'.$size; |
}else{ |
header('HTTP/1.1 200 Ok');} |
$etag=md5($filename); |
$etag=substr($etag, 0, 8) . '-' . substr($etag, 8, 7) . '-' . substr($etag, 15, 8); |
header('ETag: "'.$etag.'"'); |
header('Accept-Ranges: bytes'); |
header('Content-Length: ' .($to-$from)); |
if(isset($cr)){ |
header($cr);} |
header('Connection: close'); |
header('Content-Type: ' . $mimetype); |
header('Last-Modified: ' . gmdate('r', filemtime($filename))); |
header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($filename))." GMT"); |
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 3600)." GMT"); |
$f=fopen($filename, 'rb'); |
if(eregi('^image/',$mimetype)){ |
header('Content-Disposition: filename="'.$name.'";'); |
}else{ |
header('Content-Disposition: attachment; filename="'.$name.'";');} |
fseek($f, $from, SEEK_SET); |
$size=$to; |
$downloaded=0; |
while(!feof($f) and ($downloaded<$size)){ |
$block = min(1024*8, $size - $downloaded); |
echo fread($f, $block); |
$downloaded += $block; |
flush();} |
fclose($f);} |
php_value register_globals off |
php_value session.use_trans_sid 1 |
DirectoryIndex index.php |
AddDefaultCharset UTF-8 |
Options -Indexes |
php_value session.cookie_lifetime 0 |
Options SymLinksIfOwnerMatch |
RewriteEngine On |
##Попадаем в редактирование поста |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)/cit index.php?id_forum=$1&id_razdel=$2&id_them=$3&id_post=$4&act=cit&page=end [L,QSA] |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)/msg index.php?id_forum=$1&id_razdel=$2&id_them=$3&id_post=$4&act=msg&page=end [L,QSA] |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)/edit index.php?id_forum=$1&id_razdel=$2&id_them=$3&id_post=$4&act=edit&page=end [L,QSA] |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)/delete index.php?id_forum=$1&id_razdel=$2&id_them=$3&id_post=$4&act=delete&page=end [L,QSA] |
##Попадаем в тему |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/d_file([0-9]*)$ index.php?id_forum=$1&id_razdel=$2&id_them=$3&f_del=$4&page=end [L,QSA] |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/new$ index.php?id_forum=$1&id_razdel=$2&id_them=$3&act=new&page=end [L,QSA] |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/?$ index.php?id_forum=$1&id_razdel=$2&id_them=$3 [L,QSA] |
RewriteRule ^([0-9]*)/([0-9]*)/([0-9]*)/mark/(.*)$ index.php?id_forum=$1&id_razdel=$2&id_them=$3&mark=$4 [L,QSA] |
##Попадаем в раздел |
RewriteRule ^([0-9]*)/([0-9]*)/?$ index.php?id_forum=$1&id_razdel=$2 [L,QSA] |
##Попадаем в подфорум |
RewriteRule ^([0-9]*)/?$ index.php?id_forum=$1 [L,QSA] |
## Файлы |
RewriteRule ^files/delete/([0-9]*)/ files.php?id=$1&del [L,QSA] |
RewriteRule ^files/([0-9]*)/ files.php?id=$1 [L,QSA] |