#!/usr/bin/perl
#

$date_cmd2 =`/bin/date '+%d/%m/%Y'`;
$date2 = $date_cmd2;

$prog = substr ($0, rindex ($0, '/') + 1);
if ($#ARGV < 0) {             # imprimo usage si lo paso sin args
 print "usage: $prog nomarch(s)\n";
 print "  use: Saca los ^M de nomarch(s)\n";
 exit;
 }

foreach $nomarch (@ARGV) {
 if (! -e "$nomarch") {print "ERROR: no existe $nomarch inexistant\n";next;}
 open (FILEIN,"$nomarch") || die "ERROR: no puedo leer $nomarch: $!\n";

 $fileout = $nomarch;
 print $fileout if ($fileout =~ s/\?//);
 print $fileout if ($fileout =~ s/\&//);

 open (FILEOUT,">$fileout.html") || die "ERROR: no puedo crear $fileout.html: $!\n";

# Header fondos.com.ar 

 print FILEOUT "\n<!--#include file=\"header.html\" -->\n";
 print FILEOUT "<a href=/english/mplayer/doc>Documentation Index</a>";
 print FILEOUT "\n<pre>";

# print FILEOUT "\n <h3>Noticias WifiNetNews $date2</h3>\n";
# print FILEOUT "\n <font face=arial size=2>\n";


 $print=1;
 while (<FILEIN>) {


#     if($_ =~ /read more about it<\/a>/) {
#	 $print=1; }

#     if($_ =~ /<!--#-->/) {
#	$print=2;
#    } 

#     if($_ =~ /\/\/-->/) {
#         $print=1; }


#     if($_ =~ /Recent Entries|Syndicate this site with RSS/) {
#	 $print=2;
#    exit;
#     }


     if ($print == 1 ) {

         $_ =~ s/height=\"100%\"//gi;
	 $_ =~ s/<p styl.*?>//gi;
         $_ =~ s/<li>|<LI>//gi;
	 $_ =~ s/function image()//gi;
         $_ =~ s/<!--#-->//gi;
	 $_ =~ s/SecurityForumX Postings//gi;
	 $_ =~ s/15 Newest Messages//gi;
	 $_ =~ s/Recent SNP News Articles//gi;
	 $_ =~ s/<form.*?>//gi;
	 $_ =~ s/<\/form>//gi;
	 $_ =~ s/<input.*?>//gi;


	 $_ =~ s/Sign up for your FREE subscription to <br> InfoSecurity Magazine's twice weekly Security Wire Digest//gi;

         $_ =~ s/Cartoons provided under license by the Copyright holder//gi;
         $_ =~ s/Randy Glasbergen//gi;

	 $_ =~ s/M\341s Noticias//gi;
         $_ =~ s/<.*?bar_portada1.gif.*?>//gi;
         $_ =~ s/<.*?www.es.ad4Portal.com.*?>//gi;
	 $_ =~ s/<.*?bar_canal.*?>//gi;
	 $_ =~ s/<.*?ciberkiosko.*?>//gi;
	 $_ =~ s/<.*?semana-telcos.*?>//gi;
	 $_ =~ s/<.*?bar_portada.*?>//gi;
	 $_ =~ s/<.*?espai_blanc.gif.*?>//gi;
 	 $_ =~ s/<td.*?>//gi;
	 $_ =~ s/<tr.*?>//gi;
	 $_ =~ s/<TD.*?>//gi;
         $_ =~ s/<TR.*?>//gi;
	 $_ =~ s/<tbody>//gi;
         $_ =~ s/<\/tbody>//gi;
         $_ =~ s/<\/div>//gi;
	 $_ =~ s/<table.*?>//gi;
	 $_ =~ s/<\/td.*?>|<\/tr>|<\/TD.*?>|<\/TR.*?>|<\/table>//gi;

         $_ =~ s/width=625/width=\"1\"/gi;

	 $_ =~ s/<img .*?>//gi;
         $_ =~ s/<div.*?>//gi;
	 $_ =~ s/<font.*?>|<\/font>//gi;
	 $_ =~ s/<span.*?>|<\/span>//gi;
	 $_ =~ s/<SCRIPT.*?>|<\/SCRIPT>//gi;
	 $_ =~ s/<NOSCRIPT.*?>|<\/NOSCRIPT>//gi;
	 $_ =~ s/<b>|<i>|<\/b>|<\/i>|<center>|<\/center>//gi;

         $_ =~ s/src="\//src="http:\/\/www.noticias.com\//gi;


#         $_ =~ s/.htm/.htm.new.html/gi;

	 $_ =~ s/www.securitynewsportal.com\/cgi-bin\/news5.cgi\?target=//gi;

#	 $_ =~ s/href=\"http:\/\/www.noticias.com\//HREF=\"http:\/\/www.wifi.com.ar\/noticias\/intercom\/www.noticias.com\//gi;

#	 $_ =~ s/href=\"http:\/\/www.laempresa.net\//HREF=\"http:\/\/www.wifi.com.ar\/noticias\/laempresa\/www.laempresa.net\//gi;


#         $_ =~ s/href=\'/HREF=\'http:\/\/argentina.deremate.com\//g;


	 print FILEOUT $_;
     }

  }

# footer fondos.com.ar


# print FILEOUT "\n<a href=http://www.wifi.com.ar/firewall.html><img src=\"http://www.wifi.com.ar/gifs/logo_ad.gif\" width=188 height=80 align=right border=0></a>";

# print FILEOUT "\n<p><center><a href=\"http://www.wifi.com.ar/noticias/incluir.html\">Webmaster! Agregue noticias WIFI.com.ar a su sitio en 2 minutos!</a></center> ";

  print FILEOUT "\n<a href=/doc>Indice de la Documentaci&oacute;n</a>";
  print FILEOUT "\n</pre><!--#include file=\"footer.html\" -->\n";


 close (FILEIN);
 close (FILEOUT);

print "$nomarch\n";
# unlink ($nomarch) || die "ERROR: no puedo borrar archivo original $nomarch: $!\n";
# rename("$fileout.html",$nomarch) || die "ERROR: no puedo renombrar $fileout.html a $nomarch: $!\n";

}

