Hello,
I am trying to do something unusual and it has me stumped. I am looking to
change the Env variable for RemoteUser essentially. What I would like to
happen is that the user would choose a name from the dropdown box populated
by the list in test.txt. Once the user chooses that name, the home
directory is then pointed to the chosen name and the user is able to see the
files listed in the new directory. I have included the snippet that I have
been trying to accomplish this with and would gladly appreciate some
feedback on how to make this happen.
#my $user_file = "/Volumes/data01/cgi-bin/rem_user.txt";
my $user_file = "test.txt";
# The code sections generate the pulldown boxes in the slug form.
#
# Freeform fields are populated from cookies with inline perl.
#
print $query->header ( );
print <<END_HTML;
<HTML>
<head>
<script language="JavaScript">
function changeUser(user){
remoteuser = $user;
homedir = "/Volumes/data01/Users/$remoteuser";
alert("$homedir");
}
</script>
<link rel="stylesheet" href="/catch.css" type="text/css" />
</head>
<body>
<div id="Header">
<div id="MainText">
<form action="/cgi-bin/slugreg"
enctype="multipart/form-data" name="dataBuild" onSubmit="return
verify(this.form)" method="post">
<h3> SLUG ENTRY FORM</h3>
<table>
<tr><td>
<span CLASS="intable">
Select User Name:
</td><td>
END_HTML
################################################## ##########################
###########################
###Start Media Manager special###
open (REMUSER, "$user_file") || Error('open','file');
#read (REMUSER);
my @users = <REMUSER>;
close (REMUSER);
print "<select name='uname'>\n";
foreach (@users){
print "<option value='$_'>$_'";
}
print "</select>\n";
sub Error {
print "Content type: text/html\n\n";
print "The server cannot $_[0] the $_[1]: $! \n";
exit;
}
################################################## ##########################
##########################
print <<END_HTML;
</td><td>
<input type="button" name="test" value="Change User!"
onClick="changeUser(document.dataBuild.uname.optio ns[document.dataBuild.unam
e.selectedIndex].value)">
</td></tr>
<tr><td>
<span CLASS="intable">
Select File You've Uploaded:
</td><td>
<select name="photo">
END_HTML
# -------------------------------- code /
html ---------------------------------
# This code generates a list of files in their home directory for the file
pulldown box
opendir(DIRHANDLE, "$homedir");
while ($name = readdir(DIRHANDLE)) {
open(FILEHANDLE, "$homedir/$name");
if ((-f FILEHANDLE) and ($name ne ".htaccess") and ($name ne ".DS_Store"))
{
print "<option value='$name'>$name\n";
#end if
}
#end while
}