iconlookup.php
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <?php 
  2. /*
  3.  * FCKeditor - The text editor for internet
  4.  * Copyright (C) 2003-2005 Frederico Caldeira Knabben
  5.  * 
  6.  * Licensed under the terms of the GNU Lesser General Public License:
  7.  *  http://www.opensource.org/licenses/lgpl-license.php
  8.  * 
  9.  * For further information visit:
  10.  *  http://www.fckeditor.net/
  11.  * 
  12.  * File Name: iconlookup.php
  13.  *  (!)
  14.  * 
  15.  * File Authors:
  16.  *  Grant French (grant@mcpuk.net)
  17.  */
  18. function iconLookup($mime,$ext) {
  19. $mimeIcons=array(
  20. "image"=>"image.jpg",
  21. "audio"=>"sound.jpg",
  22. "video"=>"video.jpg",
  23. "text"=>"document2.jpg",
  24. "text/html"=>"html.jpg",
  25. "application"=>"binary.jpg",
  26. "application/pdf"=>"pdf.jpg",
  27. "application/msword"=>"document2.jpg",
  28. "application/postscript"=>"postscript.jpg",
  29. "application/rtf"=>"document2.jpg",
  30. "application/vnd.ms-excel"=>"document2.jpg",
  31. "application/vnd.ms-powerpoint"=>"document2.jpg",
  32. "application/x-tar"=>"tar.jpg",
  33. "application/zip"=>"tar.jpg",
  34. "message"=>"email.jpg",
  35. "message/html"=>"html.jpg",
  36. "model"=>"kmplot.jpg",
  37. "multipart"=>"kmultiple.jpg"
  38. );
  39. $extIcons=array(
  40. "pdf"=>"pdf.jpg",
  41. "ps"=>"postscript.jpg",
  42. "eps"=>"postscript.jpg",
  43. "ai"=>"postscript.jpg",
  44. "ra"=>"real_doc.jpg",
  45. "rm"=>"real_doc.jpg",
  46. "ram"=>"real_doc.jpg",
  47. "wav"=>"sound.jpg",
  48. "mp3"=>"sound.jpg",
  49. "ogg"=>"sound.jpg",
  50. "eml"=>"email.jpg",
  51. "tar"=>"tar.jpg",
  52. "zip"=>"tar.jpg",
  53. "bz2"=>"tar.jpg",
  54. "tgz"=>"tar.jpg",
  55. "gz"=>"tar.jpg",
  56. "rar"=>"tar.jpg",
  57. "avi"=>"video.jpg",
  58. "mpg"=>"video.jpg",
  59. "mpeg"=>"video.jpg",
  60. "jpg"=>"image.jpg",
  61. "gif"=>"image.jpg",
  62. "png"=>"image.jpg",
  63. "jpeg"=>"image.jpg",
  64. "nfo"=>"info.jpg",
  65. "xls"=>"spreadsheet.jpg",
  66. "csv"=>"spreadsheet.jpg",
  67. "html"=>"html.jpg",
  68. "doc"=>"document2.jpg",
  69. "rtf"=>"document2.jpg",
  70. "txt"=>"document2.jpg",
  71. "xla"=>"document2.jpg",
  72. "xlc"=>"document2.jpg",
  73. "xlt"=>"document2.jpg",
  74. "xlw"=>"document2.jpg",
  75. "txt"=>"document2.jpg"
  76. );
  77. if ($mime!="text/plain") {
  78. //Check specific cases
  79. $mimes=array_keys($mimeIcons);
  80. if (in_array($mime,$mimes)) {
  81. return $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/images/".$mimeIcons[$mime];
  82. } else {
  83. //Check for the generic mime type
  84. $mimePrefix="text";
  85. $firstSlash=strpos($mime,"/"); 
  86. if ($firstSlash!==false) $mimePrefix=substr($mime,0,$firstSlash);
  87. if (in_array($mimePrefix,$mimes)) {
  88. return $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/images/".$mimeIcons[$mimePrefix];
  89. } else {
  90. return $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/images/empty.jpg";
  91. }
  92. }
  93. } else {
  94. $extensions=array_keys($extIcons);
  95. if (in_array($ext,$extensions)) {
  96. return $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/images/".$extIcons[$ext];
  97. } else {
  98. return $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/images/empty.jpg";
  99. }
  100. }
  101. return $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF'])."/images/empty.jpg";
  102. }
  103. ?>