#!/usr/local/bin/perl # ## text.pl ## ######################## # # make the sanitisation of texte.html files # ########################## # Set the variables ##$file_dir = "/usr/local/etc/httpd/htdocs/demos"; ##$file_dir_url = "http://www.freescripts.com/demos"; $file_dir = "."; $file_dir_url = "."; # These specify the directory where all the files you want links added for # are located. The first is their path on the server, the second is # thier URL. $input_file = "texte0.html"; $output_file = "texte.html"; # # That's all there is to it. You can edit the resulting file to your heart's # content. Be sure to chmod the script to 755. This script can (and should) # be run from the Unix shell rather than a browser. (A web browser should # be able to run it, but then the resulting file will be owned by nobody # and the directory where the file is created would need by be chmod 777) ################# sub header { @hdr = ( "\nDocumentation \n", "\n", "<\/head>\n\n", "\n\n" ); return @hdr; } sub footer { @ftr = ( "\n<\BODY>\n<\HTML>\n", ); return @ftr; } sub listdir { # dirname opendir(FILES,"$_[0]"); @allfiles = grep(!/^\.\.?$/,readdir(FILES)); closedir(FILES); @allfiles = sort(@allfiles); return @allfiles; } sub substitute { s&
&&g; s&&&g; s&&&g; s&&&g; s&ALIGN="JUSTIFY"&&g; s&WIDTH="[0-9]*?%"&&g; s& FACE="[\w ]*?"&&g; s&&&g; s&&&g; s&&&g; s&BGCOLOR="#ffffff"&&g; s&Img00&IMG00&g; s&.gif&.GIF&g; } #---------------------------------------------------------- rename $output_file,$input_file; open(INPUT,"<$input_file"); open(OUTPUT,">$output_file"); #print OUTPUT header; while() { substitute; print OUTPUT; } close (INPUT); close (OUTPUT); exit; foreach $file (listdir(".")) { if ( -d $file ) { print "\n-- $file\n"; print NEW "

$file

\n
    "; foreach $elt (listdir($file)) { if ( -f "$file\\$elt" ) { print NEW "
  • $elt
  • \n"; } } print NEW "
\n\n"; } } print NEW footer; close(NEW); exit;