Subversion Repositories fileformats

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/php
  2. <?php
  3.  
  4. define('APACHE_MIME_TYPES_URL','https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
  5.  
  6. function generateUpToDateMimeArray($url) {
  7.         // Based on https://www.php.net/manual/de/function.mime-content-type.php#107798 , modified
  8.         $s = array();
  9.         foreach (@explode("\n",@file_get_contents($url))as $x) {
  10.                 if (isset($x[0])&&$x[0]!=='#'&&preg_match_all('#([^\s]+)#',$x,$out)&&isset($out[1])&&($c=count($out[1]))>1) {
  11.                         for ($i=1;$i<$c;$i++) {
  12.                                 $s[] = "\t'".$out[1][$i]."' => '".$out[1][0]."'";
  13.                         }
  14.                 }
  15.         }
  16.         return @sort($s) ? "\$mime_types = array(\n".implode($s,",\n")."\n);" : false;
  17. }
  18.  
  19. $res = generateUpToDateMimeArray(APACHE_MIME_TYPES_URL);
  20. if (!$res) exit(1);
  21.  
  22. $out = "";
  23. $out .= "<?php\n";
  24. $out .= "\n";
  25. $out .= "// Generated ".date('Y-m-d H:i:s')."\n";
  26. $out .= "// Source: ".APACHE_MIME_TYPES_URL."\n";
  27. $out .= "\n";
  28. $out .= $res;
  29. file_put_contents(__DIR__.'/mimetype_lookup.inc.php', $out);
  30. exit(0);
  31.  
  32.