require
"sub.RecordSearchSetup"
;
require
"sub.RecordActions"
;
require
"sub.OperationsMenu"
;
require
"sub.RecordCreateProcess"
;
require
"sub.RecordCreateSetup"
;
require
"sub.RecordDisplay"
;
require
"sub.PreliminaryResults"
;
require
"sub.RecordModifySetup"
;
require
"sub.RecordModifyProcess"
;
require
"sub.RecordDeleteProcess"
;
require
"sub.Template"
;
require
"sub.Error"
;
sub
GetTableConfig {
my
(
$file
) =
$main::CONFIG_FILE
;
$file
=
&MsqlCGI::ConvertFileName
(
$file
,
$main::defaultTableDefDir
);
open
( F,
$file
) ||
&main::Error
(
"Couldn't open file \"$file\". Perhaps it doesn't exist"
);
$nCount
= -1;
$nLine
= 0;
$tableInfo
{
'priKeyArrNum'
} = -1;
while
( <F> ) {
$nLine
++;
chop
;
next
if
( (
$_
=~ /^\s*
(
$key
,
$value
) =
split
( /\s*=\s*/,
$_
, 2 );
if
(
$key
=~ /^DBHost$/i ) {
$tableInfo
{
'DBHost'
} =
$value
;
}
elsif
(
$key
=~ /^DBName$/i ) {
$tableInfo
{
'DBName'
} =
$value
;
}
elsif
(
$key
=~ /^TableName$/i ) {
$tableInfo
{
'TableName'
} =
$value
;
}
elsif
(
$key
=~ /^DBPort$/i ) {
$tableInfo
{
'DBPort'
} =
$value
;
}
elsif
(
$key
=~ /^AllowModify$/i ) {
$tableInfo
{
'AllowModify'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^AllowDelete$/i ) {
$tableInfo
{
'AllowDelete'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^AllowCreate$/i ) {
$tableInfo
{
'AllowCreate'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^AllowSearch$/i ) {
}
elsif
(
$key
=~ /^AllowDisplay$/i ) {
$tableInfo
{
'AllowDisplay'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^TemplateDir$/i ) {
$tableInfo
{
'TemplateDir'
} =
$value
;
}
elsif
(
$key
=~ /^HTMLFooterFile$/i ) {
$tableInfo
{
'HTMLFooterFile'
} =
$value
;
}
elsif
(
$key
=~ /^OperationsMenuTemplate$/i ) {
$tableInfo
{
'OperationsMenuTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^RecordSearchTemplate$/i ) {
$tableInfo
{
'RecordSearchTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^RecordDisplayTemplate$/i ) {
$tableInfo
{
'RecordDisplayTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^PreliminaryResultsTemplate$/i ) {
$tableInfo
{
'PreliminaryResultsTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^ErrorTemplate$/i ) {
$tableInfo
{
'ErrorTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^RecordCreateSuccessTemplate$/i ) {
$tableInfo
{
'RecordCreateSuccessTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^RecordModifySuccessTemplate$/i ) {
$tableInfo
{
'RecordModifySuccessTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^RecordDeleteSuccessTemplate$/i ) {
$tableInfo
{
'RecordDeleteSuccessTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^RecordModifySetupTemplate$/i ) {
$tableInfo
{
'RecordModifySetupTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^RecordCreateSetupTemplate$/i ) {
$tableInfo
{
'RecordCreateSetupTemplate'
} =
$value
;
}
elsif
(
$key
=~ /^newField$/i ) {
$nCount
++;
$nOption
= 0;
$element
[
$nCount
]->{
'displayEntry'
} =
"y"
;
$element
[
$nCount
]->{
'displayValue'
} =
"y"
;
}
elsif
(
$key
=~ /^fieldName$/i ) {
$element
[
$nCount
]->{
'fieldName'
} =
$value
;
}
elsif
(
$key
=~ /^description$/i ) {
$element
[
$nCount
]->{
'description'
} =
$value
;
}
elsif
(
$key
=~ /^special$/i ) {
$element
[
$nCount
]->{
'special'
} =
$value
;
}
elsif
(
$key
=~ /^specialArgs$/i ) {
$element
[
$nCount
]->{
'specialArgs'
} =
$value
;
}
elsif
(
$key
=~ /^dispFieldWhenCreate$/i ) {
$element
[
$nCount
]->{
'dispFieldWhenCreate'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^modFieldWhenCreate$/i ) {
$element
[
$nCount
]->{
'modFieldWhenCreate'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^dispFieldWhenModify$/i ) {
$element
[
$nCount
]->{
'dispFieldWhenModify'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^dispFieldWhenDisplay$/i ) {
$element
[
$nCount
]->{
'dispFieldWhenDisplay'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^displayValue$/i ) {
$element
[
$nCount
]->{
'displayValue'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^modFieldWhenModify$/i ) {
$element
[
$nCount
]->{
'modFieldWhenModify'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^modFieldWhenCreate$/i ) {
$element
[
$nCount
]->{
'modFieldWhenCreate'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^searchable$/i ) {
$element
[
$nCount
]->{
'searchable'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^summary$/i ) {
$element
[
$nCount
]->{
'summary'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^cgiType$/i ) {
$element
[
$nCount
]->{
'cgiType'
} =
$value
;
}
elsif
(
$key
=~ /^fieldType$/i ) {
$element
[
$nCount
]->{
'fieldType'
} =
$value
;
}
elsif
(
$key
=~ /^fieldSize$/i ) {
$element
[
$nCount
]->{
'fieldSize'
} =
$value
;
}
elsif
(
$key
=~ /^notNull$/i ) {
$element
[
$nCount
]->{
'notNull'
} =
$value
;
}
elsif
(
$key
=~ /^primaryKey$/i ) {
if
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) {
$element
[
$nCount
]->{
'primaryKey'
} = 1;
$tableInfo
{
'priKeyArrNum'
} =
$nCount
;
}
else
{
$element
[
$nCount
]->{
'primaryKey'
} = 0;
}
}
elsif
(
$key
=~ /^nonNull$/i ) {
$element
[
$nCount
]->{
'nonNull'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
elsif
(
$key
=~ /^cgiChecked$/ ) {
if
( (
$value
) &&
(
$element
[
$nCount
]->{cgiType} !~ /(checkbox|radio)/i ) ) {
&TError
( " can
't have a checked flag. it'
s not a
checkbox or a radio button element" );
}
else
{
$element
[
$nCount
]->{
'cgiChecked'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
}
elsif
(
$key
=~ /^cgiSize$/ ) {
if
( (
$value
) &&
(
$element
[
$nCount
]->{
'cgiType'
} !~ /(text|password|
select
)/i ) ) {
&TError
( " can
't have a cgiSize. it'
s not a
text or password element" );
}
else
{
$element
[
$nCount
]->{
'cgiSize'
} =
$value
;
}
}
elsif
(
$key
=~ /^cgiMaxLength$/ ) {
if
( (
$value
) &&
(
$element
[
$nCount
]->{
'cgiType'
} !~ /(text|password)/i ) ) {
&TError
( " can
't have a cgiSize. it'
s not a
text or password element" );
}
else
{
$element
[
$nCount
]->{
'cgiMaxLength'
} =
$value
;
}
}
elsif
(
$key
=~ /^value$/ ) {
$element
[
$nCount
]->{
'value'
} =
$value
;
}
elsif
(
$key
=~ /^cgiRows$/ ) {
if
( (
$value
) &&
(
$element
[
$nCount
]->{
'cgiType'
} !~ /textarea/i ) ) {
&TError
( " can
't have a Rows tag. it'
s not a
TextArea element" );
}
else
{
$element
[
$nCount
]->{
'cgiRows'
} =
$value
;
}
}
elsif
(
$key
=~ /^cgiCols$/ ) {
if
( (
$value
) &&
(
$element
[
$nCount
]->{
'cgiType'
} !~ /textarea/i ) ) {
&TError
( " can
't have a Cols tag. it'
s not a
TextArea element" );
}
else
{
$element
[
$nCount
]->{
'cgiCols'
} =
$value
;
}
}
elsif
(
$key
=~ /^cgiMultiple$/ ) {
if
( (
$value
) &&
(
$element
[
$nCount
]->{
'cgiType'
} !~ /
select
/i ) ) {
&TError
( " can
't have a cgiMultiple tag. it'
s not a
Select element" );
}
else
{
$element
[
$nCount
]->{
'cgiMultiple'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
}
elsif
(
$key
=~ /^cgiSelected$/ ) {
if
( (
$value
) &&
(
$element
[
$nCount
]->{
'cgiType'
} !~ /option/i ) ) {
&TError
( " can
't have a cgiSelected tag. it'
s not a
Option element" );
}
else
{
$element
[
$nCount
]->{
'cgiSelected'
} =
( (
$value
=~ /^y/i ) || (
$value
== 1 ) ) ? 1 : 0 ;
}
}
elsif
(
$key
=~ /^option$/i ) {
(
$optionValue
,
$optionName
) =
split
( /:/,
$value
, 2 );
$element
[
$nCount
]->{option}[
$nOption
]->{name} =
$optionName
;
$element
[
$nCount
]->{option}[
$nOption
]->{value} =
$optionValue
;
$nOption
++;
}
else
{
&TError
(
"the Key \"$key\" isn't recognized"
);
}
}
&main::DPrint
(
"There were $nCount entries in the table Def file."
);
if
(
$tableInfo
{priKeyArrNum} == -1 ) {
&main::Error
( "Sorry, it appears that this table does not have a
Primary Key. MsqlCGI will not function on tables
that
do
not have a primary Key." );
}
return
( \
%tableInfo
, \
@element
);
}
sub
TError {
(
$msg
) =
@_
;
&main::Error
(
"File: $file<br>Line $nLine<br>Element $nCount<p>$msg"
);
}
sub
CreateCGIString {
(
$pData
,
$type
,
$value
) =
@_
;
if
(
$type
!~ /^(SEARCH|MODIFY|CREATE)$/ ) {
&main::Error
( "The second parameter to CreateCGIString (
$type
) must
be one of SEARCH, MODIFY, or CREATE." );
}
$modStr
=
"_MsqlCGI_modify-"
.
$pData
->{
'fieldName'
};
$strMod
=
"<input type=hidden name=\"$modStr\" value=\"Yes\">"
;
$strConvValue
=
&ConvertValue
(
$value
,
$pData
);
if
(
$pData
->{
'special'
} ) {
$funcName
=
&GetSpecialFunctionName
(
$pData
,
"CreateCGIString"
);
(
$strMod
,
$strCGI
) = &{
$funcName
}(
$main::tableInfo
,
$pData
,
$type
,
$value
);
}
if
( ( (
$pData
->{
'special'
} ) && (
$strCGI
eq
"_MsqlCGI_Defer"
) ) ||
( !
$pData
->{
'special'
} ) ) {
$strCGI
=
""
;
if
(
$pData
->{
'cgiType'
} =~ /^(text|password)$/i ) {
if
(
$type
=~ /^modify$/i ) {
if
(
$pData
->{
'modFieldWhenModify'
} ) {
$strCGI
.=
"<INPUT TYPE=\"$pData->{'cgiType'}\" "
;
$strCGI
.=
"NAME=\"$pData->{'fieldName'}\" "
;
$strCGI
.=
"SIZE=$pData->{'cgiSize'} "
if
(
$pData
->{
'cgiSize'
} );
$strCGI
.=
"MAXLENGTH=$pData->{'cgiMaxLength'} "
if
(
$pData
->{
'cgiMaxLength'
} );
$strCGI
.=
"VALUE=\"$value\" "
if
(
$value
);
$strCGI
.=
">"
;
}
else
{
$strCGI
=
$strConvValue
;
$strMod
=
" "
;
}
}
elsif
(
$type
=~ /^search$/i ) {
$strCGI
.=
"<INPUT TYPE=\"$pData->{'cgiType'}\" "
;
$strCGI
.=
"NAME=\"$pData->{'fieldName'}\" "
;
$strCGI
.=
"SIZE=$pData->{'cgiSize'} "
if
(
$pData
->{
'cgiSize'
} );
$strCGI
.=
"MAXLENGTH=$pData->{'cgiMaxLength'} "
if
(
$pData
->{
'cgiMaxLength'
} );
$strCGI
.=
">"
;
}
elsif
(
$type
=~ /^create$/i ) {
if
(
$pData
->{
'modFieldWhenCreate'
} ) {
$strCGI
.=
"<INPUT TYPE=\"$pData->{'cgiType'}\" "
;
$strCGI
.=
"NAME=\"$pData->{'fieldName'}\" "
;
$strCGI
.=
"SIZE=$pData->{'cgiSize'} "
if
(
$pData
->{
'cgiSize'
} );
$strCGI
.=
"MAXLENGTH=$pData->{'cgiMaxLength'} "
if
(
$pData
->{
'cgiMaxLength'
} );
$strCGI
.=
"VALUE=\"$value\" "
if
(
$value
);
$strCGI
.=
">"
;
}
else
{
$strCGI
=
"Not Modifiable."
;
}
}
}
elsif
(
$pData
->{
'cgiType'
} =~ /^textarea$/i ) {
if
(
$type
=~ /^search/i ) {
$strCGI
.=
"<INPUT TYPE=\"text\" "
;
$strCGI
.=
"NAME=\"$pData->{'fieldName'}\" "
;
$strCGI
.=
"SIZE=30>"
;
}
elsif
(
$type
=~ /^create$/i ) {
if
(
$pData
->{
'modFieldWhenCreate'
} ) {
$strCGI
.=
"<TEXTAREA NAME=\"$pData->{'fieldName'}\" "
;
$strCGI
.=
"ROWS=$pData->{'cgiRows'} "
if
(
int
(
$pData
->{
'cgiRows'
} ) );
$strCGI
.=
"COLS=$pData->{'cgiCols'} "
if
(
int
(
$pData
->{
'cgiCols'
} ) );
$strCGI
.=
">$value</TEXTAREA>"
;
}
else
{
$strCGI
=
"Not Modifiable."
;
}
}
elsif
(
$type
=~ /^modify$/i ) {
if
(
$pData
->{
'modFieldWhenModify'
} ) {
$strCGI
.=
"<TEXTAREA NAME=\"$pData->{'fieldName'}\" "
;
$strCGI
.=
"ROWS=$pData->{'cgiRows'} "
if
(
int
(
$pData
->{
'cgiRows'
} ) );
$strCGI
.=
"COLS=$pData->{'cgiCols'} "
if
(
int
(
$pData
->{
'cgiCols'
} ) );
$strCGI
.=
">$value</TEXTAREA>"
;
}
else
{
$strCGI
=
$strConvValue
;
$strMod
=
" "
;
}
}
}
elsif
(
$pData
->{
'cgiType'
} =~ /^(radio|checkbox)$/i ) {
$typeStr
= (
$type
eq
"search"
) ?
"checkbox"
:
$pData
->{
'cgiType'
};
for
(
$i
= 0;
$i
<= $
$strCGI
.= <<EOF;
<input type=
"$typeStr"
name=
"$pData->{'fieldName'}"
EOF
if
( (
$type
=~ /^modify$/i ) && (
$pData
->{
'modFieldWhenModify'
} ) &&
(
$value
eq
$pData
->{
'option'
}[
$i
]->{
'value'
} ) ) {
$strCGI
.=
"Checked "
;
}
$strCGI
.=
<<EOF;
value="$pData->{'option'}[$i]->{'value'}">
$pData->{'option'}[$i]->{'name'}<br>
EOF
}
}
elsif
(
$pData
->{
'cgiType'
} =~ /^
select
$/i ) {
$strSize
=
"size=$pData->{'cgiSize'}"
if
(
$pData
->{
'cgiSize'
} );
$strMult
=
"Multiple"
if
(
$pData
->{
'cgiMultiple'
} );
$strCGI
=
<<EOF;
<SELECT name="$pData->{'fieldName'}"
$strSize $strMult>
EOF
if
(
$type
eq
"search"
) {
$strCGI
.=
<<EOF;
<option></option>
EOF
}
for
(
$i
= 0;
$i
<= $
$strCGI
.=
"<option"
;
if
( (
$type
=~ /^modify$/i ) && (
$pData
->{
'modFieldWhenModify'
} ) &&
(
$value
eq
$pData
->{
'option'
}[
$i
]->{
'value'
} ) ) {
$strCGI
.=
" Selected"
;
}
$strCGI
.=
">$pData->{'option'}[$i]->{'value'}\n"
;
EOF
}
$strCGI
.=
"</SELECT>\n"
;
}
}
return
(
$strMod
,
$strCGI
);
}
sub
ConvertValue {
local
(
$newValue
,
$pData
) =
@_
;
if
(
$pData
->{
'special'
} ) {
$funcName
=
&GetSpecialFunctionName
(
$pData
,
"ConvertValue"
);
(
$newValue
,
$bContinue
) = &{
$funcName
}(
$newValue
,
$pData
);
if
( !
$bContinue
) {
return
$newValue
;
}
}
if
(
$pData
->{
'cgiType'
} =~ /^(radio|checkbox)$/i ) {
for
(
$i
= 0;
$i
<= $
if
(
$newValue
eq
$pData
->{
'option'
}[
$i
]->{
'value'
} ) {
$newValue
=
$pData
->{
'option'
}[
$i
]->{
'name'
};
last
;
}
}
}
$newValue
=~ s/</
<
;/gi;
$newValue
=~ s/>/
>
;/gi;
$newValue
=~ s/\n/<br>\n/gi;
$newValue
=~ s/(\S*:\/\/\S*)/<a href=\"$1\">$1<\/a>/gi;
$newValue
=~ s/(\S*@\S*)/<a href=\"mailto:$1\">$1<\/a>/gi;
return
$newValue
;
}
sub
GetSpecialFunctionName {
local
(
$pData
,
$type
) =
@_
;
if
(
$type
!~ /^(CreateCGIString|ConvertValue|CreateQueryPart_Create|CreateQueryPart_Modify|CreateQueryPart_Search)$/ ) {
&main::Error
( "The Type: \"
$type
\" wasn't recognized in
GetSpecialFunctionName" );
}
&main::DPrint
(
"In GetSpecialFunctionName, $type, $pData->{'fieldName'}"
);
$specialName
=
$pData
->{
'special'
};
$subFileName
=
$main::pluginDir
.
"/sub."
.
$specialName
;
if
( -e
$subFileName
) {
require
"$subFileName"
;
}
else
{
&main::Error
( "The special subroutine file
$subFileName
doesn't
exist." );
}
$funcName
=
$funcName
=
$specialName
.
"::"
.
$type
;
return
$funcName
;
}
sub
GetElementStruct {
(
$key
) =
@_
;
for
(
$nCount
= 0;
$nCount
<= $
if
(
$main::tData
->[
$nCount
]->{
'fieldName'
} eq
$key
) {
return
$main::tData
->[
$nCount
];
}
}
return
undef
;
}
sub
GetElementStructNumber {
(
$key
) =
@_
;
for
(
$nCount
= 0;
$nCount
<= $
if
(
$main::tData
->[
$nCount
]->{
'fieldName'
} eq
$key
) {
&main::DPrint
(
"<b>Returning: $nCount</b>"
);
return
$nCount
;
}
}
&main::DPrint
(
"<b>Returning: undef</b>"
);
return
undef
;
}
sub
GetElementValue {
(
$fieldName
,
$param
) =
@_
;
$pData
=
&GetElementStruct
(
$fieldName
,
$main::tData
);
return
$pData
->{
$param
};
}
sub
SetupMsqlConnection {
$DBHost
=
$main::tableInfo
->{
'DBHost'
};
$DBPort
=
$main::tableInfo
->{
'DBPort'
};
$DBName
=
$main::tableInfo
->{
'DBName'
};
if
(
$DBHost
=~ /^localhost$/i ) {
&main::DPrint
(
"Connecting to db (local)"
);
$dbh
= Msql->Connect() ||
&main::Error
(
"Couldn't connect to the Database. $Msql::db_errstr"
);
}
else
{
&main::DPrint
(
"Connecting to db $DBHost on port $DBPort"
);
$ENV
{
'MSQL_TCP_PORT'
} =
$DBPort
;
$dbh
= Msql->Connect (
$DBHost
) ||
&main::Error
( "Couldn't
connect
to db Host
$DBHost
on Port
$DBPort
" );
}
&main::DPrint
(
"Selecting db: $DBName"
);
$dbh
->SelectDB (
$DBName
) ||
&main::Error
(
"Couldn't Select db $DBName"
);
return
$dbh
;
}
sub
StrToQueryStr {
local
(
$strValue
,
$fieldType
,
$queryType
) =
@_
;
&main::DPrint
(
"<b>$strValue, $fieldType</b>"
);
if
(
$queryType
!~ /^(SEARCH|CREATE|MODIFY)$/ ) {
&main::Error
( "Programmer Error: in StrToQueryStr, queryType must
be either
'SEARCH'
,
'MODIFY'
, or
'CREATE'
" );
}
if
(
$fieldType
eq
"char"
) {
if
( (
$queryType
eq
"SEARCH"
) ||
(
$queryType
eq
"MODIFY"
) ) {
if
(
$strValue
=~ /[\%\\\^]/ ) {
&main::Error
( "Sorry, you cannot
use
the characters <pre>
% \\ ^ </pre> in your query" );
}
}
&main::DPrint
(
"<b>$strValue</b>"
);
$strValue
=~ s/(['])/\\$1/gi;
&main::DPrint
(
"<b>$strValue</b>"
);
$strValue
=
"'$strValue'"
;
if
(
$strValue
eq
"''"
) {
$strValue
=
"NULL"
;
}
}
elsif
(
$fieldType
eq
"int"
) {
if
(
$strValue
=~ /\D/ ) {
&main::Error
(
"You must enter only a number in the numeric fields."
);
}
}
elsif
(
$fieldType
eq
"real"
) {
if
(
$strValue
!~ /[\d\.]/ ) {
&main::Error
( "You must enter only a Real Numbers in the real
number fields.");
}
}
return
$strValue
;
}
sub
ConvertFileName {
my
(
$fileName
,
$defDir
) =
@_
;
&main::DPrint
(
"In ConvertFileName, file is; $fileName, defDir is $defDir"
);
$fileName
=
$defDir
.
"/"
.
$fileName
if
( (
substr
(
$fileName
, 0, 1 ) ) !~ /[~\/]/ ) ;
&main::DPrint
(
"After first substitution: $fileName"
);
$fileName
=~ s/^~(\w*)/
if
( $1 ) {
(
$name
,
$passwd
,
$uid
,
$gid
,
$quota
,
$comment
,
$gcos
,
$dir
,
$shell
) =
getpwnam
( $1 );
$dir
}
else
{
(
$name
,
$passwd
,
$uid
,
$gid
,
$quota
,
$comment
,
$gcos
,
$dir
,
$shell
) =
getpwuid
( $< );
$dir
}/ge;
&main::DPrint
(
"After second substitution. Returning: $fileName"
);
return
$fileName
;
}
sub
main::DPrint {
if
(
$main::debug
== 1 ) {
print
"DEBUG: $_[0]<br>\n"
;
}
return
;
}
1;