home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / pear-dh-ini2xml < prev    next >
Text File  |  2008-07-02  |  1KB  |  61 lines

  1. #!/usr/bin/php
  2. <?php
  3. /**
  4.  * Converts the old-style INI-language files into XML-files that
  5.  * are used from version 0.14.0+.
  6.  * 
  7.  * @version     $Id: pear-dh-ini2xml,v 1.1 2005/10/14 21:40:51 luckec Exp $
  8.  * @author      Carsten Lucke <luckec@php.net>
  9.  */
  10.  
  11. $frame = <<<EOT
  12. <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
  13. <driver-data>
  14.     <holidays>
  15.     
  16.         __DATA__
  17.         
  18.     </holidays>
  19. </driver-data>
  20. EOT;
  21.  
  22. $template = <<<EOT
  23.     
  24.         <holiday>
  25.             <internal-name>__INTERNALNAME__</internal-name>
  26.             <translation>__TRANSLATION__</translation>
  27.         </holiday>
  28.         
  29. EOT;
  30.  
  31. array_shift($_SERVER['argv']);
  32.  
  33. if ($_SERVER['argc'] < 1) {
  34.     die('Call this file from command line: ini2xml.php <file-to-convert> [<file-to-convert> [...]]' . "\n");
  35. }
  36.  
  37. foreach ($_SERVER['argv'] as $filename) {
  38.     $newFilename = str_replace('.ini', '.xml', $filename);
  39.     $contents = parse_ini_file($filename);
  40.     $_xml = '';
  41.     
  42.     foreach ($contents as $internalName => $translation) {
  43.         $_tmp = str_replace('__INTERNALNAME__', $internalName, $template);
  44.         $_tmp = str_replace('__TRANSLATION__', $translation, $_tmp);
  45.         
  46.         $_xml .= $_tmp;
  47.     }
  48.     
  49.     $c = str_replace('__DATA__', $_xml, $frame);
  50.     $fp = fopen($newFilename, 'w');
  51.     fwrite($fp, $c, strlen($c));
  52.     
  53.     
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. ?>