dz!x系列自定义添加附件图标教程

[复制链接]
查看2666 | 回复0 | 2020-2-9 08:22 | 显示全部楼层 |阅读模式
dz!x系列自定义添加附件图标教程
这里我们拿自定义的apk作为自定义添加的附件,图标添加教程如下:
首先自己要准备好一个apk图标,将apk图  上传到目录:static\image\filetype 保存为apk.png
打开文件,路径为:\source\function\function_attachment.php
然后搜索:
  1. function attachtype($type, $returnval = 'html') {
  2.         static $attachicons = array(
  3.                         1 => 'unknown.gif',
  4.                         2 => 'binary.gif',
  5.                         3 => 'zip.gif',
  6.                         4 => 'rar.gif',
  7.                         5 => 'msoffice.gif',
  8.                         6 => 'text.gif',
  9.                         7 => 'html.gif',
  10.                         8 => 'real.gif',
  11.                         9 => 'av.gif',
  12.                         10 => 'flash.gif',
  13.                         11 => 'image.gif',
  14.                         12 => 'pdf.gif',
  15.                         13 => 'torrent.gif'
  16.                 );
复制代码
替换为下面代码:
  1. function attachtype($type, $returnval = 'html') {
  2.         static $attachicons = array(
  3.                         1 => 'unknown.gif',
  4.                         2 => 'binary.gif',
  5.                         3 => 'zip.gif',
  6.                         4 => 'rar.gif',
  7.                         5 => 'msoffice.gif',
  8.                         6 => 'text.gif',
  9.                         7 => 'html.gif',
  10.                         8 => 'real.gif',
  11.                         9 => 'av.gif',
  12.                         10 => 'flash.gif',
  13.                         11 => 'image.gif',
  14.                         12 => 'pdf.gif',
  15.                         13 => 'apk.png',
  16.                         14 => 'torrent.gif'
  17.                 );
复制代码
最后一步再搜索:
  1. if(is_numeric($type)) {
  2.                 $typeid = $type;
  3.         } else {
  4.                 if(preg_match("/bittorrent|^torrent\t/", $type)) {
  5.                         $typeid = 13;
  6.                 } elseif(preg_match("/pdf|^pdf\t/", $type)) {
  7.                         $typeid = 12;
  8.                 } elseif(preg_match("/image|^(jpg|gif|png|bmp)\t/", $type)) {
  9.                         $typeid = 11;
  10.                 } elseif(preg_match("/flash|^(swf|fla|flv|swi)\t/", $type)) {
  11.                         $typeid = 10;
  12.                 } elseif(preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/", $type)) {
  13.                         $typeid = 9;
  14.                 } elseif(preg_match("/real|^(ra|rm|rv)\t/", $type)) {
  15.                         $typeid = 8;
  16.                 } elseif(preg_match("/htm|^(php|js|pl|cgi|asp)\t/", $type)) {
  17.                         $typeid = 7;
  18.                 } elseif(preg_match("/text|^(txt|rtf|wri|chm)\t/", $type)) {
  19.                         $typeid = 6;
  20.                 } elseif(preg_match("/word|powerpoint|^(doc|ppt)\t/", $type)) {
  21.                         $typeid = 5;
  22.                 } elseif(preg_match("/^rar\t/", $type)) {
  23.                         $typeid = 4;
  24.                 } elseif(preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/", $type)) {
  25.                         $typeid = 3;
  26.                 } elseif(preg_match("/octet-stream|^(exe|com|bat|dll)\t/", $type)) {
  27.                         $typeid = 2;
  28.                 } elseif($type) {
  29.                         $typeid = 1;
  30.                 } else {
  31.                         $typeid = 0;
  32.                 }
  33.         }
复制代码
替换为:
  1. if(is_numeric($type)) {
  2.                 $typeid = $type;
  3.         } else {
  4.                 if(preg_match("/bittorrent|^torrent\t/", $type)) {
  5.                         $typeid = 14;
  6.                 } elseif(preg_match("/apk|^apk\t/", $type)) {
  7.                         $typeid = 13;
  8.                 } elseif(preg_match("/pdf|^pdf\t/", $type)) {
  9.                         $typeid = 12;
  10.                 } elseif(preg_match("/image|^(jpg|gif|png|bmp)\t/", $type)) {
  11.                         $typeid = 11;
  12.                 } elseif(preg_match("/flash|^(swf|fla|flv|swi)\t/", $type)) {
  13.                         $typeid = 10;
  14.                 } elseif(preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)\t/", $type)) {
  15.                         $typeid = 9;
  16.                 } elseif(preg_match("/real|^(ra|rm|rv)\t/", $type)) {
  17.                         $typeid = 8;
  18.                 } elseif(preg_match("/htm|^(php|js|pl|cgi|asp)\t/", $type)) {
  19.                         $typeid = 7;
  20.                 } elseif(preg_match("/text|^(txt|rtf|wri|chm)\t/", $type)) {
  21.                         $typeid = 6;
  22.                 } elseif(preg_match("/word|powerpoint|^(doc|ppt)\t/", $type)) {
  23.                         $typeid = 5;
  24.                 } elseif(preg_match("/^rar\t/", $type)) {
  25.                         $typeid = 4;
  26.                 } elseif(preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)\t/", $type)) {
  27.                         $typeid = 3;
  28.                 } elseif(preg_match("/octet-stream|^(exe|com|bat|dll)\t/", $type)) {
  29.                         $typeid = 2;
  30.                 } elseif($type) {
  31.                         $typeid = 1;
  32.                 } else {
  33.                         $typeid = 0;
  34.                 }
  35.         }
复制代码
覆盖前记得先备份,覆盖后记得后台更新缓存即可。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-4-16