以下为网上摘录,在8.7中实测,并修改了部分文件
pw论坛只有三种格式图标,在后面找了很久没找到,今天自已修改部分代码,修改方法如下:
为下文方便说明,现在规定下面2个单词定义
type指:附件类别名称,比如大家可以将后缀为bmp、png、jpg等的一类附件定义为img这样一个类别
ifupload指:一个type对应的一个唯一编号,比如下面例子中的img--->1,txt--->2
下面以添加music,pdf,torrent这三个类别文件图标为例
1、修改根目录thread.php
找到:
$attachtype = array('1'=>'img','2'=>'txt','3'=>'zip');
添加相应格式图标进去:
添加格式:,'ifupload'=>'type'
如:
$attachtype = array('1'=>'img','2'=>'txt','3'=>'zip','5'=>'music','6'=>'pdf','4'=>'torrent');
2、修改lib文件夹下的getinfo.class.php
找到:
$attachtype = array('img','txt','zip');
添加相应格式图标进去:
添加格式:,'type'
如:
$attachtype = array('img','txt','zip','pdf','music','torrent');
3、修改lib文件夹下的upload.class.php
找到:
elseif ($upload['ext'] == 'txt') {
if (preg_match('/(onload|submit|post|form)/i', readover($source))) {
P_unlink($source);
uploadmsg('upload_content_error');
}
$upload['type'] = 'txt';
}
添加相应的图标进去:
添加格式:elseif ($upload['ext'] == '附件后缀')(多个后缀有的不同,详细看下面例子) {
$upload['type'] = 'type';
}
如:
elseif ($upload['ext'] == 'txt') {
if (preg_match('/(onload|submit|post|form)/i', readover($source))) {
P_unlink($source);
uploadmsg('upload_content_error');
}
$upload['type'] = 'txt';
}elseif ($upload['ext'] == 'pdf') {
$upload['type'] = 'pdf';
}elseif (in_array($upload['ext'], array('mp3','mp4','avi','rmvb'))) {
$upload['type'] = 'music';
}elseif (in_array($upload['ext'], array('torrent','bittorrent'))) {
$upload['type'] = 'torrent';
}
4、修改require文件夹下updateforum.php
找到:
switch($type) {
case 'img': $r=1;break;
case 'txt': $r=2;break;
添加相应格式图标进去:
添加格式:case 'type': $r=ifupload;break;
如:
switch($type) {
case 'img': $r=1;break;
case 'txt': $r=2;break;
case 'zip': $r=3;break;
case 'pdf': $r=6;break;
case 'music': $r=5;break;
case 'torrent': $r=4;break;
default:$r=0;
}
5、修改lib/upload文件夹下attupload.class.php
找到:
$this->ifupload = ($rt['type'] == 'img' ? 1 : ($rt['type'] == 'txt' ? 2 : 3));
修改格式:用以下方法完全替换掉
如:
$this->ifupload = ($rt['type'] == 'img' ? 1 : ($rt['type'] == 'txt' ? 2 : ($rt['type'] == 'music' ? 5 : ($rt['type'] == 'pdf' ? 6 : ($rt['type'] == 'torrent' ? 4 : 3)))));
6、修改require文件夹下postfunc.php
找到:
$ifupload = 3; $type = 'zip';
修改格式:用以下方法完全替换掉
如:
if ($attach_ext == 'pdf') {
$ifupload = 6;
$type = 'pdf';
}elseif(in_array($attach_ext,array('mp3','mp4','avi','rmvb'))){
$ifupload = 5;
$type = 'music';
}elseif($attach_ext == 'torrent'){
$ifupload = 4;
$type = 'torrent';
}
else {
$ifupload = 3; $type = 'zip';
}
别忘了把图标放在images/wind/file文件夹!就是风格模板图片的file文件夹
以后要继续添加其它文件格式,只要修改以上这几处即可 |