makeWhatIsNew.pl

  1. $ERROR_FILE = 'c:\q\errors.log';
  2. $ALL_ERROR_FILE = 'c:\q\allerrors.log';
  3. $VALIDATOR = "c:\\q\\sp1_3\\bin\\nsgmls.exe -wxml -s -f $ERROR_FILE ";
  4. $ID_PREFIX = 'zvon';
  5. $START_DIR = 'c:\Zvon\ZvonXMLSource';
  6. $XML_DIR = 'c:\Zvon\ZvonXMLSource\Auto';
  7. use Cwd;
  8. use File::Path;
  9. use File::Basename;
  10. @created24h = ('createdLast24h.xml','Pages created in the last 24 hours','zvon19990713134754072');
  11. @created72h = ('createdLast72h.xml','Pages created in the last 72 hours','zvon19990713134846498');
  12. @created7days = ('createdLast7days.xml','Pages created in the last 7 days','zvon19990713134900420');
  13. @created30days = ('createdLast30days.xml','Pages created in the last 30 days','zvon19990713134913777');
  14. @modified24h = ('modifiedLast24h.xml','Pages modified in the last 24 hours','zvon19990713145713155');
  15. @modified72h = ('modifiedLast72h.xml','Pages modified in the last 72 hours','zvon19990713145728643');
  16. @modified7days = ('modifiedLast7days.xml','Pages modified in the last 7 days','zvon19990713145749527');
  17. @modified30days = ('modifiedLast30days.xml','Pages modified in the last 30 days','zvon19990713145808279');
  18. newXML(@created24h);
  19. newXML(@created72h);
  20. newXML(@created7days);
  21. newXML(@created30days);
  22. newXML(@modified24h);
  23. newXML(@modified72h);
  24. newXML(@modified7days);
  25. newXML(@modified30days);
  26. chdir $XML_DIR;
  27. system "xslall";
  28. sub newXML
  29. {
  30. chdir $START_DIR;
  31. $handle = $_[0];
  32. $handle =~ s/\.xml//;
  33. open $handle, ">$XML_DIR/$_[0]";
  34. print $handle "<automat id=\"$_[2]\"><title>$_[1]</title>";
  35. directory();
  36. print $handle '</automat>';
  37. close $handle;
  38. }
  39. sub directory
  40. {
  41. my (@list, $item);
  42. opendir DIR,".";
  43. @list = readdir DIR;
  44. #remove . and ..
  45. shift(@list);
  46. shift(@list);
  47. foreach $item (@list)
  48. {
  49. if (-f $item and $item =~ /\.xml/) {file($item);}
  50. if (-d $item and $item ne 'Auto') {
  51. chdir($item);
  52. directory($item);
  53. chdir ("..");
  54. }
  55. }
  56. }
  57. sub file
  58. {
  59. @temp = stat($_[0]);
  60. if ($handle =~ /created/) { $fileTime = $temp[10]}
  61. else {$fileTime = $temp[9];}
  62. $var = 1;
  63. if ($handle =~ /72h/) { $var = 3; }
  64. if ($handle =~ /7days/) { $var = 7; }
  65. if ($handle =~ /30days/) { $var = 30; }
  66. $period = time() - $var * 24*3600;
  67. if ($fileTime > $period)
  68. {
  69. open IN, $_[0];
  70. read IN, $source, 1000000;
  71. close IN;
  72. if (!($source =~ /id="$ID_PREFIX\d{17}"/)){return;};
  73. $id = $&;
  74. $id =~ s/id=//;
  75. $id =~ s/"//g;
  76. if (!($source =~ /<title.*?title>/)) {return;}
  77. print $handle "\n<item href=\"$id\">$& </item>";
  78. }
  79. }