Subversion Repositories personal-webbase

Rev

Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. if (isset($_SERVER['SERVER_NAME']))
  4. {
  5.         die('Bitte f&uuml;hren Sie dieses Script separat &uuml;ber den PHP-Interpreter aus.');
  6. }
  7.  
  8. define('SHOW_OUTPUT', false);
  9.  
  10. /* --------------------------- */
  11.  
  12. function getAllFiles($directory, $recursive = true) {
  13.         $result = array();
  14.         $handle =  opendir($directory);
  15.         while ($datei = readdir($handle))
  16.         {
  17.                 if (($datei != '.') && ($datei != '..'))
  18.                 {
  19.                         $file = $directory.$datei;
  20.                         if (is_dir($file)) {
  21.                                 if ($recursive) {
  22.                                         $result = array_merge($result, getAllFiles($file.'/'));
  23.                                 }
  24.                         } else {
  25.                                 $result[] = $file;
  26.                         }
  27.                 }
  28.         }
  29.         closedir($handle);
  30.         return $result;
  31. }
  32.  
  33. function getHighestFileTimestamp($directory, $recursive = true) {
  34.         $allFiles = getAllFiles($directory, $recursive);
  35.         $highestKnown = 0;
  36.         foreach ($allFiles as $val) {
  37.                 // WebBase-Spezifisch: Die eigenen Revisionsdaten gelten nicht als Relevant!
  38.                 if (($val != $directory.'revision.inc.php') && ($val != $directory.'info.xml')) {
  39.                         $currentValue = filemtime($val);
  40.                         if ($currentValue > $highestKnown) $highestKnown = $currentValue;
  41.                 }
  42.         }
  43.         return $highestKnown;
  44. }
  45.  
  46. /* --------------------------- */
  47.  
  48. $dir = dirname($_SERVER['SCRIPT_NAME']);
  49. $dir .= '/../';
  50. $dir = realpath($dir);
  51.  
  52. chdir($dir);
  53.  
  54. $ary = array();
  55. $i = 0;
  56. $v = 'modules/';
  57. $verz = opendir($v);
  58.  
  59. while ($file = readdir($verz))
  60. {
  61.         if (($file != '.') && ($file != '..') && (is_dir($v.$file)))
  62.         {
  63.                 $i++;
  64.                 $ary[$i] = $file;
  65.         }
  66. }
  67.  
  68. closedir($verz);
  69. sort($ary);
  70.  
  71. foreach ($ary as $val)
  72. {
  73.         $mod_timestamp = getHighestFileTimestamp('modules/'.$val.'/');
  74.         $dat = date('Y-m-d', $mod_timestamp);
  75.  
  76.         if (file_exists('modules/'.$val.'/info.xml'))
  77.         {
  78.                 if (SHOW_OUTPUT) echo "Module '$val' has now the modification date '$dat'.\n";
  79.  
  80.                 $inhalt = file_get_contents('modules/'.$val.'/info.xml');
  81.                 $inhalt = preg_replace('/<version>(.+?)<\/version>/im', '<version>'.$dat.'</version>', $inhalt);
  82.  
  83.                 $handle = fopen('modules/'.$val.'/info.xml', 'w');
  84.                 fwrite($handle, $inhalt);
  85.                 fclose($handle);
  86.         }
  87. }
  88. unset($val);
  89.  
  90. /* --------------------------- */
  91.  
  92. $ary = array();
  93. $i = 0;
  94. $v = 'designs/';
  95. $verz = opendir($v);
  96.  
  97. while ($file = readdir($verz))
  98. {
  99.         if (($file != '.') && ($file != '..') && (is_dir($v.$file)))
  100.         {
  101.                 $i++;
  102.                 $ary[$i] = $file;
  103.         }
  104. }
  105.  
  106. closedir($verz);
  107. sort($ary);
  108.  
  109. foreach ($ary as $val)
  110. {
  111.         $mod_timestamp = getHighestFileTimestamp('designs/'.$val.'/');
  112.         $dat = date('Y-m-d', $mod_timestamp);
  113.  
  114.         if (file_exists('designs/'.$val.'/info.xml'))
  115.         {
  116.                 if (SHOW_OUTPUT) echo "Design '$val' has now the modification date '$dat'.\n";
  117.  
  118.                 $inhalt = file_get_contents('designs/'.$val.'/info.xml');
  119.                 $inhalt = preg_replace('/<version>(.+?)<\/version>/im', '<version>'.$dat.'</version>', $inhalt);
  120.  
  121.                 $handle = fopen('designs/'.$val.'/info.xml', 'w');
  122.                 fwrite($handle, $inhalt);
  123.                 fclose($handle);
  124.         }
  125. }
  126. unset($val);
  127.  
  128. /* --------------------------- */
  129.  
  130. if (file_exists('includes/revision.inc.php'))
  131. {
  132.         $mod_timestamp = getHighestFileTimestamp('./');
  133.         $dat = date('d.m.Y', $mod_timestamp);
  134.  
  135.         ob_start();
  136.         readfile('includes/revision.inc.php');
  137.         $buffer = ob_get_contents();
  138.         @ob_end_clean();
  139.  
  140.         $ary = explode("\n", $buffer);
  141.  
  142.         foreach ($ary as $val)
  143.         {
  144.                 $bry = explode(' = ', $val);
  145.  
  146.                 if ($bry[0] == '$rev_datum')
  147.                 {
  148.                         $buffer = str_replace('$rev_datum = '.$bry[1], '$rev_datum = \''.$dat.'\';', $buffer);
  149.                 }
  150.         }
  151.         unset($val);
  152.  
  153.         $handle = fopen('includes/revision.inc.php', 'w');
  154.         fwrite($handle, $buffer);
  155.         fclose($handle);
  156.  
  157.         if (SHOW_OUTPUT) echo "The system has now the modification date '$dat'.\n";
  158. }
  159.  
  160. if (SHOW_OUTPUT) {
  161.         die("\nDie Datumsangaben aller Module/Designs und die Revisionsinformation wurden aktualisiert!\n");
  162. }
  163.  
  164. ?>