Subversion Repositories fileformats

Rev

Rev 2 | 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.         $dupcheck = array();
  10.         foreach (@explode("\n",@file_get_contents($url))as $x) {
  11.                 if (isset($x[0])&&$x[0]!=='#'&&preg_match_all('#([^\s]+)#',$x,$out)&&isset($out[1])&&($c=count($out[1]))>1) {
  12.                         for ($i=1;$i<$c;$i++) {
  13.                                 if (!isset($dupcheck[$out[1][$i]])) {
  14.                                         $s[] = "\t'".$out[1][$i]."' => '".$out[1][0]."'";
  15.                                         $dupcheck[$out[1][$i]] = true;
  16.                                 }
  17.                         }
  18.                 }
  19.         }
  20.         return @sort($s) ? "\$mime_types = array(\n".implode($s,",\n")."\n);" : false;
  21. }
  22.  
  23. $res = generateUpToDateMimeArray(APACHE_MIME_TYPES_URL);
  24. if (!$res) exit(1);
  25.  
  26. $out = "";
  27. $out .= "<?php\n";
  28. $out .= "\n";
  29. $out .= "// Generated ".date('Y-m-d H:i:s')."\n";
  30. $out .= "// Source: ".APACHE_MIME_TYPES_URL."\n";
  31. $out .= "\n";
  32. $out .= $res;
  33. file_put_contents(__DIR__.'/mimetype_lookup.inc.php', $out);
  34. exit(0);
  35.  
  36.