makeWhatIsNew.pl
- $ERROR_FILE = 'c:\q\errors.log';
- $ALL_ERROR_FILE = 'c:\q\allerrors.log';
- $VALIDATOR = "c:\\q\\sp1_3\\bin\\nsgmls.exe -wxml -s -f $ERROR_FILE ";
- $ID_PREFIX = 'zvon';
- $START_DIR = 'c:\Zvon\ZvonXMLSource';
- $XML_DIR = 'c:\Zvon\ZvonXMLSource\Auto';
- use Cwd;
- use File::Path;
- use File::Basename;
- @created24h = ('createdLast24h.xml','Pages created in the last 24 hours','zvon19990713134754072');
- @created72h = ('createdLast72h.xml','Pages created in the last 72 hours','zvon19990713134846498');
- @created7days = ('createdLast7days.xml','Pages created in the last 7 days','zvon19990713134900420');
- @created30days = ('createdLast30days.xml','Pages created in the last 30 days','zvon19990713134913777');
- @modified24h = ('modifiedLast24h.xml','Pages modified in the last 24 hours','zvon19990713145713155');
- @modified72h = ('modifiedLast72h.xml','Pages modified in the last 72 hours','zvon19990713145728643');
- @modified7days = ('modifiedLast7days.xml','Pages modified in the last 7 days','zvon19990713145749527');
- @modified30days = ('modifiedLast30days.xml','Pages modified in the last 30 days','zvon19990713145808279');
- newXML(@created24h);
- newXML(@created72h);
- newXML(@created7days);
- newXML(@created30days);
- newXML(@modified24h);
- newXML(@modified72h);
- newXML(@modified7days);
- newXML(@modified30days);
- chdir $XML_DIR;
- system "xslall";
- sub newXML
- {
- chdir $START_DIR;
- $handle = $_[0];
- $handle =~ s/\.xml//;
- open $handle, ">$XML_DIR/$_[0]";
- print $handle "<automat id=\"$_[2]\"><title>$_[1]</title>";
- directory();
- print $handle '</automat>';
- close $handle;
- }
- sub directory
- {
- my (@list, $item);
- opendir DIR,".";
- @list = readdir DIR;
- #remove . and ..
- shift(@list);
- shift(@list);
-
- foreach $item (@list)
- {
- if (-f $item and $item =~ /\.xml/) {file($item);}
- if (-d $item and $item ne 'Auto') {
- chdir($item);
- directory($item);
- chdir ("..");
- }
- }
- }
- sub file
- {
- @temp = stat($_[0]);
- if ($handle =~ /created/) { $fileTime = $temp[10]}
- else {$fileTime = $temp[9];}
-
- $var = 1;
-
- if ($handle =~ /72h/) { $var = 3; }
- if ($handle =~ /7days/) { $var = 7; }
- if ($handle =~ /30days/) { $var = 30; }
-
- $period = time() - $var * 24*3600;
-
-
- if ($fileTime > $period)
- {
- open IN, $_[0];
- read IN, $source, 1000000;
- close IN;
-
- if (!($source =~ /id="$ID_PREFIX\d{17}"/)){return;};
- $id = $&;
- $id =~ s/id=//;
- $id =~ s/"//g;
-
- if (!($source =~ /<title.*?title>/)) {return;}
- print $handle "\n<item href=\"$id\">$& </item>";
- }
- }