3 # This is a very simple Perl script to expand server-side includes
4 # in the directory it is run, and direct subdirectories. It will
5 # work only on SSI directives of the form
7 # <!--#include virtual="filename" -->
9 # Filename must be relative to the directory the file appears in.
11 # Nov 30, 1996 - Alexei Kosut <akosut@apache.org>
13 # ====================================================================
14 # Copyright (c) 1996-1999 The Apache Group. All rights reserved.
16 # Redistribution and use in source and binary forms, with or without
17 # modification, are permitted provided that the following conditions
20 # 1. Redistributions of source code must retain the above copyright
21 # notice, this list of conditions and the following disclaimer.
23 # 2. Redistributions in binary form must reproduce the above copyright
24 # notice, this list of conditions and the following disclaimer in
25 # the documentation and/or other materials provided with the
28 # 3. All advertising materials mentioning features or use of this
29 # software must display the following acknowledgment:
30 # "This product includes software developed by the Apache Group
31 # for use in the Apache HTTP server project (http://www.apache.org/)."
33 # 4. The names "Apache Server" and "Apache Group" must not be used to
34 # endorse or promote products derived from this software without
35 # prior written permission.
37 # 5. Products derived from this software may not be called "Apache"
38 # nor may "Apache" appear in their names without prior written
39 # permission of the Apache Group.
41 # 6. Redistributions of any form whatsoever must retain the following
43 # "This product includes software developed by the Apache Group
44 # for use in the Apache HTTP server project (http://www.apache.org/)."
46 # THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
47 # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
50 # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
57 # OF THE POSSIBILITY OF SUCH DAMAGE.
58 # ====================================================================
60 # This software consists of voluntary contributions made by many
61 # individuals on behalf of the Apache Group and was originally based
62 # on public domain software written at the National Center for
63 # Supercomputing Applications, University of Illinois, Urbana-Champaign.
64 # For more information on the Apache Group and the Apache HTTP server
65 # project, please see <http://www.apache.org/>.
67 # Put a list of dirs (except ..) into @dirs
69 opendir DIR, "." or die "Could not open directory: $!";
70 @dirs = grep !/^\.\.$/, (grep -d, readdir DIR);
73 foreach $dir (@dirs) {
74 print "Entering directory $dir\n";
75 opendir SUBDIR, "$dir" or die "Could not open subdir $dir: $!";
76 foreach $file (grep /\.html$/, readdir SUBDIR) {
77 print "Expanding file $dir/$file\n";
78 rename "$dir/$file", "$dir/${file}.old";
79 open READ, "$dir/${file}.old" or die "Couldn't read $dir/$file: $!";
80 open WRITE, ">$dir/$file" or die "Couldn't write $dir/$file: $!";
82 if ($r =~ /<!--#include virtual="(.*)" -->/) {
83 ($pre, $include, $post) = ($`, $1, $');
86 open INC, "$dir/$include" or
87 print "Could not include file $dir/$include: $!";
88 print WRITE while (<INC>);
99 unlink "$dir/$file.old";