/
file.php
85 lines (74 loc) · 1.76 KB
/
file.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
if(iCMS!=1) exit;
require './cfg/content.php';
#Get record to ASSOC $file
if(!$file = $db->query('SELECT f.*,c.opt FROM '.PRE.'files f INNER JOIN '.
PRE.'cats c ON f.cat=c.ID WHERE c.access!=3 AND f.ID='.$id)->fetch(2)) return;
#Disabled
if(!$file['access'])
{
if(!admit($file['cat'],'CAT')) return;
$view->info(sprintf($lang['NVAL'], $file['name']), null, 'warning');
}
#Tag title
$view->title = $file['name'];
#Meta description
if($file['dsc']) $view->desc = $file['dsc'];
#Remote file
$remote = strpos($file['file'], ':');
#Size and URL
if($remote OR file_exists('./'.$file['file']))
{
$file['url'] = isset($cfg['fgets']) ? url('get/'.$id) : $file['file'];
if(!$file['size'] && !$remote)
{
$size = filesize($file['file']);
if($file['size'] > 1048575)
{
$file['size'] = round($size/1048576) . ' MB';
}
else
{
$file['size'] = round($size/1024) . ' KB';
}
}
}
else
{
$file['size'] = 'File not found';
$file['url'] = '#';
}
#Mark
if(isset($cfg['frate']) && $file['opt'] & 4)
{
$view->css(SKIN_DIR.'rate.css');
$rate = 'vote.php?type=2&id='.$id;
}
else
{
$rate = 0;
}
#Date, author
$file['date'] = genDate($file['date'], true);
$file['author'] = autor($file['author']);
#Template
$view->add('file', array(
'file' => &$file,
'path' => catPath($file['cat']),
'rates' => $rate,
'edit' => admit($file['cat'],'CAT') ? url('edit/2/'.$id, 'ref') : false,
'root' => isset($cfg['allCat']) ? $lang['cats'] : $lang['files'],
'cats' => url(isset($cfg['allCat']) ? 'cats' : 'cats/files')
));
#Tags
if(isset($cfg['tags']))
{
include './lib/tags.php';
tags($id, 2);
}
#Comments
if(isset($cfg['fcomm']) && $file['opt']&2)
{
require './lib/comm.php';
comments($id, 2);
}