4 ###APPDATE: Sat Oct 6 02:39:49 2007
6 ###APPDESC: Convert tidywenku1 to tidywenku2
11 $ARGV[0]="-h" unless(@ARGV);
13 exit(system("plhelp",$0,@ARGV)) if($_ eq "-h" || $_ eq "--help");
23 my $SIGN='<div align="right" id="sign">WenkuV2.0 Geek@MYPLACE</b><br>' . `date` . '</div>';
24 buildRule
qr/<div[^<>]*id\s*=\s*["']*sign\s*["']*[^<>]*>.*$/,$SIGN;
25 buildRule
qr/<\/script
>/,"</script
>" . "\n" .
26 '<script language="JavaScript
" src="file
:///c:/windows
/wenku.js"></script
>' . "\n" .
27 '<script language
="JavaScript" src
="file:///etc/wenku.js"></script
>' . "\n";
28 buildRule qr/<link[^<>]*wenku.css[^<>]*>/,
29 '<link rel
="stylesheet" href
="wenku.css" type
="text/css">' . "\n" .
30 '<link rel
="stylesheet" href
="file:///c:/windows/wenku.css" type
="text/css">' . "\n" .
31 '<link rel
="stylesheet" href
="file:///etc/wenku.css" type
="text/css">' . "\n";
33 my $TEMPFILE=`mktemp`;
37 return 0 unless(-w $filename);
38 system("cp","-f",$filename,$TEMPFILE) and return 0;
39 if(-r $TEMPFILE and -w $filename) {
40 open(TEMP,"<",$TEMPFILE) or die("$!\n");
41 open(FH,">",$filename) or die("$!\n");
42 #open(FH,">/dev/stdout") or die("$!\n");
45 for(my $i=0;$i<@PAT;$i++) {
46 $LINE =~ s/$PAT[$i]/$REP[$i]/g;
48 $LINE =~ s/='([^']*)'/="$1"/g;
49 print FH ($LINE,"\n");
59 foreach my $cur(@ARGV) {
60 if(-f $cur and $cur =~ m/\.(htm|html)$/i) {
61 print STDERR ("$cur ... \r");
63 print STDERR ("$cur [Done] \n");
66 print STDERR ("$cur [Failed] \n");
70 foreach my $sub(glob("$cur/*")) {
71 if($sub =~ m/\.(htm|html)$/i) {
72 print STDERR ("$sub ... \r");
76 print STDERR ("$cur [Done] \n");
79 print STDERR ("$cur [Ingored]\n");