Ready for 7.10.29 development.
This commit is contained in:
commit
c806f99b7b
4236 changed files with 1217679 additions and 0 deletions
60
lib/WebGUI/Macro/Include.pm
Normal file
60
lib/WebGUI/Macro/Include.pm
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package WebGUI::Macro::Include;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use FileHandle;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::Include
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Macro for returning the contents of a file from the filesystem.
|
||||
|
||||
=head2 process ( filename )
|
||||
|
||||
process will return internationalized error messages if an illegal file
|
||||
is read (password, group of config file) or if the file could not be found.
|
||||
|
||||
=head3 filename
|
||||
|
||||
The complete path to a file in the local filesystem.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my (@param, $temp, $file);
|
||||
@param = @_;
|
||||
my $i18n = WebGUI::International->new($session,'Macro_Include');
|
||||
if ($param[0] =~ /passwd/i || $param[0] =~ /shadow/i || $param[0] =~ m{\.conf$}i) {
|
||||
return $i18n->get('security');
|
||||
}
|
||||
$file = FileHandle->new($param[0],"r");
|
||||
if ($file) {
|
||||
local $/;
|
||||
$temp = $file->getline();
|
||||
$file->close;
|
||||
} else {
|
||||
$temp = $i18n->get('not found');
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue