推荐应用

Discuz多国语言翻译

Discuz多国语言翻译

文库系统/文档系统

文库系统/文档系统

美食菜谱发布菜谱

美食菜谱发布菜谱

漫画阅读中心

漫画阅读中心

小说阅读中心

小说阅读中心

语言包切换基本文件

语言包切换基本文件

成语闯关

成语闯关

谷歌登錄Google登錄

谷歌登錄Google登錄

轻APP

轻APP

网上祭祀祭拜扫墓

网上祭祀祭拜扫墓

手机MP4视频上传

手机MP4视频上传

彩票开奖号码公布

彩票开奖号码公布

DZX泰语/傣语

DZX泰语/傣语

DZX日文版(日本语)

DZX日文版(日本语)

解析附件类型显示小图标attachtype函数新增docx/pptx/xls格式显示

发布于 2013-09-06
//解析附件类型(在/static/image/filetype/下应该有对应的小图标图片)
function attachtype($type, $returnval = 'html') {

  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 => 'Ds.gif',//新增docx格式小图标
      15 => 'Es.gif',//新增xls格式小图标
      16 => 'PS.gif',//新增pptx格式小图标
    );

  if(is_numeric($type)) {
    $typeid = $type;
  } else {
    if(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("/^docx\t/", $type)){//新增docx格式小图标
      $typeid = 14;
    }elseif(preg_match("/^xls\t/", $type)){//新增xls格式小图标
      $typeid = 15;
    }elseif(preg_match("/^pptx\t/", $type)){//新增pptx格式小图标
      $typeid = 16;
    }
    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;
    }
  }
  if($returnval == 'html') {
    return '';
  } elseif($returnval == 'id') {
    return $typeid;
  }
}
扫一扫添加有偿QQ
扫一扫添加微信客服