#!/usr/bin/perl ###!C:/perl/bin/perl.exe # roqwikideploy; # Last updated: 2009-12-23 $version = '1.2'; $copyyear = '2009'; =head1 RoqWiki Deploy Deploys html files. =head2 Install 0. Download RoqWikiDeploy: 1. Put the file in the same directory as roqwiki. 2. Modify roqwiki.ini file 3. Browse to http://yourdomainname/yourdirectory/roqwikideploy.pl =head2 Further Configuration If you want to exclude html files from the deploy modify the roqwiki.ini file as shown: # exclude_files=file1,file2,...filex exclude_files=index.html,about.html =head1 ChangeLog 2008-04-18 :: 1.0 :: Initial release. 2008-05-19 :: 1.1 :: Added code for more visual flexibility. 2009-12-23 :: 1.1 :: Changed to use xml parameter file. =head1 Author roqet =head1 Copyright RoqWikiDeploy Perl script copyright 2008 roqet . RoqWikiDeploy can be distributed and modified under the terms of the GNU General Public License: http://www.gnu.org/copyleft/gpl.html This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. Updates and other scripts and software available at: http://www.roqet.org/software.html ~~~ 'l' - =cut use CGI qw/:standard/; use File::Copy; use XML::Simple; &parseform; undef @excludefiles; $paramfile = XMLin('./roqwiki.xml'); @excludefiles = split(',',$paramfile->{exclude_files}); if (!$key) { print "Content-type:text/html\n\n"; print '' . "\n"; print '' . "\n"; print '' . "\n"; print ' ' . "\n"; print ' Deploy Roqwiki' . "\n"; print ' ' . "\n"; print ' ' . "\n"; print ' ' . "\n"; print ' ' . "\n"; print '' . "\n"; print '' . "\n"; print '
' . "\n"; print '
' . "\n"; print '
' . "\n"; print '' . "\n"; print '

List of Files to be Deployed

' . "\n"; opendir(DIR, "./") or die "can't opendir ./: $!"; while (defined($file = readdir(DIR))) { if ($file =~ /.html/) { print ("
  • $file\n"); foreach $excluded (@excludefiles) { if ($excluded eq $file) { print (" - Exclude From Deploy\n"); last; } } } } closedir(DIR); print '

    ' . "\n"; print '' . "\n"; print '
  • ' . "\n"; print '
    ' . "\n"; print '
    ' . "\n"; print '' . "\n"; print ""; } elsif ($key eq 'deploy') { print "Content-type:text/html\n\n"; print '' . "\n"; print '' . "\n"; print '' . "\n"; print ' ' . "\n"; print ' Deploy Roqwiki' . "\n"; print ' ' . "\n"; print ' ' . "\n"; print ' ' . "\n"; print ' ' . "\n"; print '' . "\n"; print '' . "\n"; print '
    ' . "\n"; print '
    ' . "\n"; print '

    Deploy Status

    ' . "\n"; opendir(DIR, "./") or die "can't opendir ./: $!"; while (defined($file = readdir(DIR))) { if ($file =~ /.html/) { $copy = 1; foreach $excluded (@excludefiles) { if ($excluded eq $file) { $copy = 0; last; } } if ($copy) { print ("
  • Copying $file\n"); copy($file, '../') or warn "$file cannot be copied."; } } } closedir(DIR); print '
  • ' . "\n"; print '
    ' . "\n"; print '' . "\n"; print ""; } ############### # # # subroutines # # # ############### sub parseform { if( $ENV{'REQUEST_METHOD'} eq 'GET' ) { @pairs = split( /&/, $ENV{'QUERY_STRING'} ); } elsif( $ENV{'REQUEST_METHOD'} eq 'POST' ) { read( STDIN, $buffer, $ENV{'CONTENT_LENGTH'} ); @pairs = split( /&/, $buffer ); if( $ENV{'QUERY_STRING'} ) { @getpairs = split( /&/, $ENV{'QUERY_STRING'} ); push( @pairs, @getpairs ); } } else { print "Content-type:text/html\n\n"; print "Unrecognized Method - Use GET or POST."; } foreach $pair( @pairs ) { ( $key, $value ) = split( /=/, $pair ); $key =~ tr/+/ /; $value =~ tr/+/ /; $key =~ s/%(..)/pack("c", hex($1))/eg; $value =~ s/%(..)/pack("c", hex($1))/eg; $value =~ s///g; # ignore SSI if( $formdata{$key} ){$formdata{$key} .= ", $value";} else{ $formdata{$key} = $value; } } }