联系我们:416326801#qq.com(#改成@)

Latest from the blog

Discuz修改附件图标

标签: PHP Discuz

Discuz有一部分不常用的附件图标是问号,下面操作步骤可以自定义Discuz附件图标。

1、准备图标,一般是正方形的png或gif文件,建议大小64*64或128*128。

2、上传图标到目录:/static/image/filetype,修改为自定义名字,例如mobi.png

3、修改源码文件:/source/function/function_attachment.php

4、修改部分参考示例代码的第17-20、36-31行

附件图标.png

<?php
static $attachicons = array(
    1 => 'unknown.gif',
    2 => 'binary.gif',
    3 => 'zip.gif',
    4 => 'rar.gif',
    5 => 'msoffice.gif',
    6 => 'text.gif',
    7 => 'html.gif',
    8 => 'real.gif',
    9 => 'av.gif',
    10 => 'flash.gif',
    11 => 'image.gif',
    12 => 'pdf.gif',
    13 => 'torrent.gif',
    14 => 'book.png',
    15 => 'ebook.png',
    16 => 'mobi.png',
    17 => 'azw3.png',
    18 => 'epub.png',
);

if( is_numeric($type) ) {
    $typeid = $type;
} else {
    if( preg_match("/epub|^epub\t/", $type) ) {
        $typeid = 18;
    } elseif( preg_match("/azw3|^azw3\t/", $type) ) {
        $typeid = 17;
    } elseif( preg_match("/mobi|^mobi\t/", $type) ) {
        $typeid = 16;
    } elseif( preg_match("/bittorrent|^torrent\t/", $type) ) {
        $typeid = 13;
    } elseif( preg_match("/pdf|^pdf\t/", $type) ) {
        $typeid = 12;
    } elseif( preg_match("/image|^(jpg|gif|png|bmp)\t/", $type) ) {
        $typeid = 11;
    } elseif( preg_match("/flash|^(swf|fla|flv|swi)\t/", $type) ) {
        $typeid = 10;
    } elseif( preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/", $type) ) {
        $typeid = 9;
    } elseif( preg_match("/real|^(ra|rm|rv)\t/", $type) ) {
        $typeid = 8;
    } elseif( preg_match("/htm|^(php|js|pl|cgi|asp)\t/", $type) ) {
        $typeid = 7;
    } elseif( preg_match("/text|^(txt|rtf|wri|chm)\t/", $type) ) {
        $typeid = 6;
    } elseif( preg_match("/word|powerpoint|^(doc|ppt)\t/", $type) ) {
        $typeid = 5;
    } elseif( preg_match("/^rar\t/", $type) ) {
        $typeid = 4;
    } elseif( preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/", $type) ) {
        $typeid = 3;
    } elseif( preg_match("/octet-stream|^(exe|com|bat|dll)\t/", $type) ) {
        $typeid = 2;
    } elseif( $type ) {
        $typeid = 1;
    } else {
        $typeid = 0;
    }
}
?>