| $dir = "./"; |
| opendir(DIR, $dir) or die $!; |
| while( defined( $fdir = readdir DIR) ) { |
| if( -d "$dir$fdir" ) { |
| opendir(BIN, "$dir$fdir") or die "Can't open $fdir: $!"; |
| while( defined ($file = readdir BIN) ) { |
| if( $file =~ /main\.html/ ) { |
| open FILE, "$dir$fdir/$file" or die $!; |
| $whole = ""; |
| $mode = 0; |
| while( $line = <FILE> ) { |
| $mode = 2 if( $line =~ /<\/body/ ); |
| $whole .= $line if( $mode == 1 ); |
| $mode = 1 if( $line =~ /<body/ ); |
| } |
| close FILE; |
| $orig = $whole; |
| |
| if( $whole =~ /BORDER=0 CELLSPACING/i ) { |
| print "$dir$fdir/$file\n"; |
| $whole =~ s/<h3>/<h4>/ig; |
| $whole =~ s/<\/h3>/<\/h4>/ig; |
| $whole =~ s/<h2>/<h3>/ig; |
| $whole =~ s/<\/h2>/<\/h3>/ig; |
| $whole =~ s/<h1>/<h2>/ig; |
| $whole =~ s/<\/h1>/<\/h2>/ig; |
| $whole =~ s/<font class="indextop">(.*)<\/font>/<h1>$1<\/h1>/ig; |
| $whole =~ s/<span class="indextop">(.*)<\/span>/<h1>$1<\/h1>/ig; |
| $whole =~ s/<span class="indexsub">(.*)<\/span>//ig; |
| $whole =~ s/<img src="[\.\/]*\/images\/Idea.jpg".*?>//is; |
| $whole =~ s/<p id="header">.*?<br>//is; |
| $whole =~ s/<p id="header">//is; |
| |
| while( $whole =~ /^(.*)<table.*?>(.*?)<\/table>(.*)$/is ) { |
| $n = $2; |
| $m = $1; |
| $p = $3; |
| $n =~ s/<.*?class=indextop.*?>(.*?)<\/font>/<h1>$1<\/h1>/is; |
| $n =~ s/<td .*?ALIGN=LEFT VALIGN=TOP .*?BGCOLOR="#0080C0">(.*?)<\/td>/<h2>$1<\/h2>/isg; |
| $n =~ s/<td.*?>//isg; |
| $n =~ s/<\/td>//isg; |
| $n =~ s/<tr>//isg; |
| $n =~ s/<\/tr>//isg; |
| $n =~ s/<b><font.*?>(.*?)<\/font><\/b>/$1/isg; |
| $n =~ s/<font.*?>(.*?)<\/font>/$1/isg; |
| $whole = $m . $n . $p; |
| } |
| $whole = "<?php\n include(\$_SERVER['DOCUMENT_ROOT'] . \"\/eclipse.org-common\/system\/include-before-definitions.php\");\n\n\$pageTitle = \"\";\n\$pageKeywords = \"\";\n\$pageAuthor = \"\";\n\n\include(\$_SERVER['DOCUMENT_ROOT'] . \"\/eclipse.org-common\/system\/include-after-definitions.php\");\n?>\n <div id=\"maincontent\">\n <div id=\"midcolumn\">" . $whole; |
| $whole = $whole . "<\/div>\n<\/div>\n<?php\n include(\$_SERVER['DOCUMENT_ROOT'] . \"\/eclipse.org-common\/system\/include-end-of-page.php\");\n?>\n"; |
| |
| |
| if( $orig ne $whole ) { |
| print "Changed $file\n"; |
| open FILE, ">$dir$fdir/index.php" or die $!; |
| print FILE $whole; |
| close FILE; |
| open FILE, ">$dir$fdir/index.html" or die $!; |
| print FILE "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\"><html><head><META HTTP-EQUIV=Refresh CONTENT=\"0; URL=index.php\"></head><body>Replaced by <a href=\"index.php\">the new page</a></body></html>\n"; |
| close FILE; |
| open FILE, ">$dir$fdir/main.html" or die $!; |
| print FILE "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\"><html><head><META HTTP-EQUIV=Refresh CONTENT=\"0; URL=index.php\"></head><body>Replaced by <a href=\"index.php\">the new page</a></body></html>\n"; |
| close FILE; |
| exit 1; |
| } |
| } |
| } |
| } |
| closedir(BIN); |
| } |
| } |
| closedir(DIR); |