home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / forums / mimeinc.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  3.9 KB  |  114 lines

  1. <?
  2. ######################################################################
  3. # Modulo Splatt Forum per PHP-NUKE 
  4. #-------------------------
  5. # Versione: 3.1
  6. #
  7. # Copyright (c) 2002 by:
  8. #
  9. # Giorgio Ciranni (~Splatt~)
  10. # (http://www.splatt.it)
  11. # (webmaster@splatt.it)
  12. #
  13. #
  14. # Supporto tecnico disponibile sul Forum di www.splatt.it
  15. ######################################################################
  16. # PHP-NUKE Add-On 2.0 :
  17. # =====================
  18. #
  19. #              PHPBB Integration 1.0.BETA
  20. #        Brought to you by PHPNuke Add-On Team
  21. #
  22. # Copyright (c) 2000 by Richard Tirtadji AKA King Richard (rtirtadji@hotmail.com)
  23. #                       Hutdik Hermawan AKA hotFix (hutdik76@hotmail.com)
  24. # http://www.phpnuke.web.id
  25. #
  26. #
  27. ######################################################################
  28. # PHPBB
  29. #
  30. # Copyright (C) 2000 by James Atkinson (james@totalgeek.org)
  31. # http://www.phpbb.com
  32. #
  33. #
  34. ######################################################################
  35. ######################################################################
  36. # Gestione Mime Type
  37. # -------------------------------------------------------------------
  38. # Realizzato da  : JoyDivision
  39. #            url : http://www.bergamoblog.it
  40. #          email : joydivision@bergamoblog.it
  41. ######################################################################
  42. # Splatt Forum is free software. You can redistribute it and/or modify
  43. # it under the terms of the GNU General Public License as published by
  44. # the Free Software Foundation; either version 2 of the License.
  45. # Splatt Forum is distributed in the hope that it will be useful,
  46. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  47. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  48. # GNU General Public License for more details.
  49. #
  50. # You should have received a copy of the GNU General Public License
  51. # along with this program; if not, write to the Free Software
  52. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
  53. # 02111-1307  USA
  54. ######################################################################
  55.  
  56. if (!file_exists(realpath("modules/$name")."/mimetype.txt")){
  57.     $fp = fopen(realpath("modules/$name")."/mimetype.txt","w");
  58.     fclose($fp);
  59.     unset($fp);
  60. }
  61.  
  62. ######################################################################
  63. # Funzione : SetMime()
  64. # Input    : fileext  - file Extension
  65. #            mimetype - associated mimetype
  66. # Outut    : NONE
  67. #
  68. # Setta nel file contenente tutti i mime-type un nuovo mime associato
  69. # all'estensione (se non esiste giα)
  70. ######################################################################
  71. function SetMime($fileext, $mimetype){
  72.     global $name;
  73.     $MimeFN = realpath("modules/$name")."/mimetype.txt";
  74.     $fp = fopen($MimeFN,"r+");
  75.     flock($fp,LOCK_EX);
  76.     $fileext.="|";
  77.     $fcontent = fread($fp,filesize($MimeFN));
  78.     $pos=strpos($fcontent,$fileext);
  79.     if (!$pos){
  80.         $fcontent.=$fileext.$mimetype."||\n";
  81.         rewind($fp);
  82.         fwrite($fp,$fcontent);
  83.     }
  84.     flock($fp,LOCK_UN);
  85.     fclose($fp);
  86.     unset($fp);
  87. }
  88.  
  89. ######################################################################
  90. # Funzione : GetMime()
  91. # Input    : fileext  - file Extension
  92. # Outpu    : mimetype - associated mimetype
  93. #
  94. # Ritorna il mimetype associato all'estensione specificata
  95. ######################################################################
  96. function GetMime($fileext){
  97.     global $name;
  98.     $MimeFN = realpath("modules/$name")."/mimetype.txt";
  99.     $fileext.="|";
  100.     $fp = fopen($MimeFN,"r");
  101.     $fcontent = fread($fp,filesize($MimeFN));
  102.     fclose($fp);
  103.     unset($fp);
  104.     $pos=strpos($fcontent,$fileext);
  105.     if (is_string($pos) && !$pos){
  106.        $mimetype = "text/plain";
  107.     } else {
  108.        $mimetype = substr($fcontent,$pos);
  109.        $mimetype = substr($mimetype,0,strpos($mimetype,"||"));
  110.        $mimetype = substr($mimetype,strpos($mimetype,"|")+1);
  111.     }
  112.     return($mimetype);
  113. }
  114. ?>