version 1.4, 2002/02/19 21:50:40
|
version 1.19, 2003/04/19 01:34:22
|
Line 99 sub des_decrypt {
|
Line 99 sub des_decrypt {
|
# Handler subroutines # |
# Handler subroutines # |
################################################################ |
################################################################ |
|
|
|
################################################################ |
|
# Anonymous Discussion Name Change Subroutines # |
|
################################################################ |
|
sub screennamechanger { |
|
my $r = shift; |
|
my $user = $ENV{'user.name'}; |
|
my $domain = $ENV{'user.domain'}; |
|
my %userenv = &Apache::lonnet::get |
|
('environment',['screenname','nickname']); |
|
my $screenname=$userenv{'screenname'}; |
|
my $nickname=$userenv{'nickname'}; |
|
my $bodytag=&Apache::loncommon::bodytag( |
|
'Change Your Nickname and Anonymous Screen Name'); |
|
$r->print(<<ENDSCREEN); |
|
<html> |
|
$bodytag |
|
|
|
<form name="server" action="/adm/preferences" method="post"> |
|
<input type="hidden" name="action" value="verify_and_change_screenname" /> |
|
<br />New screenname (shown if you post anonymously): |
|
<input type="text" size="20" value="$screenname" name="screenname" /> |
|
<br />New nickname (shown if you post non-anonymously): |
|
<input type="text" size="20" value="$nickname" name="nickname" /> |
|
<input type="submit" value="Change" /> |
|
</form> |
|
</body> |
|
</html> |
|
ENDSCREEN |
|
} |
|
|
|
sub verify_and_change_screenname { |
|
my $r = shift; |
|
my $user = $ENV{'user.name'}; |
|
my $domain = $ENV{'user.domain'}; |
|
# Screenname |
|
my $newscreen = $ENV{'form.screenname'}; |
|
$newscreen=~s/[^ \w]//g; |
|
my $message=''; |
|
if ($newscreen) { |
|
&Apache::lonnet::put('environment',{'screenname' => $newscreen}); |
|
&Apache::lonnet::appenv('environment.screenname' => $newscreen); |
|
$message='Set new screenname to '.$newscreen; |
|
} else { |
|
&Apache::lonnet::del('environment',['screenname']); |
|
&Apache::lonnet::delenv('environment\.screenname'); |
|
$message='Reset screenname'; |
|
} |
|
# Nickname |
|
$message.='<br />'; |
|
$newscreen = $ENV{'form.nickname'}; |
|
$newscreen=~s/[^ \w]//g; |
|
if ($newscreen) { |
|
&Apache::lonnet::put('environment',{'nickname' => $newscreen}); |
|
&Apache::lonnet::appenv('environment.nickname' => $newscreen); |
|
$message.='Set new nickname to '.$newscreen; |
|
} else { |
|
&Apache::lonnet::del('environment',['nickname']); |
|
&Apache::lonnet::delenv('environment\.nickname'); |
|
$message.='Reset nickname'; |
|
} |
|
|
|
my $bodytag=&Apache::loncommon::bodytag( |
|
'Change Your Nickname and Anonymous Screen Name'); |
|
$r->print(<<ENDVCSCREEN); |
|
<html> |
|
$bodytag |
|
</p> |
|
$message |
|
</body></html> |
|
ENDVCSCREEN |
|
} |
|
|
|
################################################################ |
|
# Colors # |
|
################################################################ |
|
|
|
sub colorschanger { |
|
my $r = shift; |
|
my $bodytag=&Apache::loncommon::bodytag( |
|
'Change Color Scheme for Current Role Type'); |
|
# figure out colors |
|
my $function='student'; |
|
if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { |
|
$function='coordinator'; |
|
} |
|
if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) { |
|
$function='admin'; |
|
} |
|
if (($ENV{'request.role'}=~/^(au|ca)/) || |
|
($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { |
|
$function='author'; |
|
} |
|
my $domain=&Apache::loncommon::determinedomain(); |
|
my %colortypes=('pgbg' => 'Page Background', |
|
'tabbg' => 'Header Background', |
|
'sidebg'=> 'Header Border', |
|
'font' => 'Font', |
|
'link' => 'Un-Visited Link', |
|
'vlink' => 'Visited Link', |
|
'alink' => 'Active Link'); |
|
my $chtable=''; |
|
foreach my $item (keys %colortypes) { |
|
my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); |
|
$chtable.='<tr><td>'.$colortypes{$item}.'</td><td bgcolor="'.$curcol. |
|
'"> </td><td><input name="'.$item. |
|
'" size="8" value="'.$curcol. |
|
'" /></td><td><a href="javascript:pjump('."'color','".$colortypes{$item}. |
|
"','".$curcol."','" |
|
.$item."','".$item."','psub'".');">Select</a></td></tr>'; |
|
} |
|
$r->print(<<ENDCOL); |
|
<html> |
|
<script> |
|
|
|
function pclose() { |
|
parmwin=window.open("/adm/rat/empty.html","LONCAPAparms", |
|
"height=350,width=350,scrollbars=no,menubar=no"); |
|
parmwin.close(); |
|
} |
|
|
|
function pjump(type,dis,value,marker,ret,call) { |
|
parmwin=window.open("/adm/rat/parameter.html?type="+escape(type) |
|
+"&value="+escape(value)+"&marker="+escape(marker) |
|
+"&return="+escape(ret) |
|
+"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms", |
|
"height=350,width=350,scrollbars=no,menubar=no"); |
|
|
|
} |
|
|
|
function psub() { |
|
pclose(); |
|
if (document.parmform.pres_marker.value!='') { |
|
document.parmform.action+='#'+document.parmform.pres_marker.value; |
|
var typedef=new Array(); |
|
typedef=document.parmform.pres_type.value.split('_'); |
|
if (document.parmform.pres_type.value!='') { |
|
if (typedef[0]=='date') { |
|
eval('document.parmform.recent_'+ |
|
document.parmform.pres_type.value+ |
|
'.value=document.parmform.pres_value.value;'); |
|
} else { |
|
eval('document.parmform.recent_'+typedef[0]+ |
|
'.value=document.parmform.pres_value.value;'); |
|
} |
|
} |
|
document.parmform.submit(); |
|
} else { |
|
document.parmform.pres_value.value=''; |
|
document.parmform.pres_marker.value=''; |
|
} |
|
} |
|
|
|
|
|
</script> |
|
$bodytag |
|
|
|
<form name="server" action="/adm/preferences" method="post"> |
|
<input type="hidden" name="action" value="verify_and_change_colors" /> |
|
<table border="2"> |
|
$chtable |
|
</table> |
|
<input type="submit" value="Change" /> |
|
</form> |
|
</body> |
|
</html> |
|
ENDCOL |
|
} |
|
|
|
sub verify_and_change_colors { |
|
my $r = shift; |
|
# figure out colors |
|
my $function='student'; |
|
if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { |
|
$function='coordinator'; |
|
} |
|
if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) { |
|
$function='admin'; |
|
} |
|
if (($ENV{'request.role'}=~/^(au|ca)/) || |
|
($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { |
|
$function='author'; |
|
} |
|
my $domain=&Apache::loncommon::determinedomain(); |
|
my %colortypes=('pgbg' => 'Page Background', |
|
'tabbg' => 'Header Background', |
|
'sidebg'=> 'Header Border', |
|
'font' => 'Font', |
|
'link' => 'Un-Visited Link', |
|
'vlink' => 'Visited Link', |
|
'alink' => 'Active Link'); |
|
|
|
my $message=''; |
|
# my $newscreen=''; |
|
# $newscreen=~s/\,$//; |
|
# if ($newscreen) { |
|
# &Apache::lonnet::put('environment',{'msgforward' => $newscreen}); |
|
# &Apache::lonnet::appenv('environment.msgforward' => $newscreen); |
|
# $message.='Set new message forwarding to '.$newscreen.'<br />'; |
|
# } else { |
|
# &Apache::lonnet::del('environment',['msgforward']); |
|
# &Apache::lonnet::delenv('environment\.msgforward'); |
|
# $message.='Reset message forwarding<br />'; |
|
# } |
|
|
|
my $bodytag=&Apache::loncommon::bodytag( |
|
'Change Color Scheme for Current Role Type'); |
|
$r->print(<<ENDVCCOL); |
|
<html> |
|
$bodytag |
|
</p> |
|
$message |
|
</body></html> |
|
ENDVCCOL |
|
} |
|
|
###################################################### |
###################################################### |
# password handler subroutines # |
# password handler subroutines # |
###################################################### |
###################################################### |
Line 135 sub passwordchanger {
|
Line 350 sub passwordchanger {
|
$lkey_npass2= hex($lkey_npass2); |
$lkey_npass2= hex($lkey_npass2); |
# Output javascript to deal with passwords |
# Output javascript to deal with passwords |
# Output DES javascript |
# Output DES javascript |
|
$r->print("<html><head>"); |
{ |
{ |
my $include = $r->dir_config('lonIncludes'); |
my $include = $r->dir_config('lonIncludes'); |
my $jsh=Apache::File->new($include."/londes.js"); |
my $jsh=Apache::File->new($include."/londes.js"); |
$r->print(<$jsh>); |
$r->print(<$jsh>); |
} |
} |
|
my $bodytag=&Apache::loncommon::bodytag('Change Password','', |
|
'onLoad="init();"'); |
$r->print(<<ENDFORM); |
$r->print(<<ENDFORM); |
|
</head> |
<body bgcolor="#FFFFFF" onLoad="init();"> |
$bodytag |
|
|
<script language="JavaScript"> |
<script language="JavaScript"> |
|
|
Line 170 sub passwordchanger {
|
Line 388 sub passwordchanger {
|
} |
} |
|
|
</script> |
</script> |
<h1>Preferences for $user</h1> |
|
<h3>$user is a member of domain $domain</h3> |
|
$errormessage |
$errormessage |
<p> |
|
Change password for $user |
|
</p> |
|
<p> |
<p> |
<!-- We seperate the forms into 'server' and 'client' in order to |
<!-- We seperate the forms into 'server' and 'client' in order to |
ensure that unencrypted passwords will not be sent out by a |
ensure that unencrypted passwords will not be sent out by a |
Line 257 ENDERROR
|
Line 471 ENDERROR
|
} |
} |
my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo); |
my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo); |
# |
# |
my $currentpass = &des_decrypt($ckey ,$currentpass); |
$currentpass = &des_decrypt($ckey ,$currentpass); |
my $newpass1 = &des_decrypt($n1key,$newpass1); |
$newpass1 = &des_decrypt($n1key,$newpass1); |
my $newpass2 = &des_decrypt($n2key,$newpass2); |
$newpass2 = &des_decrypt($n2key,$newpass2); |
# |
# |
if ($newpass1 ne $newpass2) { |
if ($newpass1 ne $newpass2) { |
&passwordchanger($r, |
&passwordchanger($r, |
Line 300 ENDERROR
|
Line 514 ENDERROR
|
# Inform the user the password has (not?) been changed |
# Inform the user the password has (not?) been changed |
if ($result =~ /^ok$/) { |
if ($result =~ /^ok$/) { |
$r->print(<<"ENDTEXT"); |
$r->print(<<"ENDTEXT"); |
<h2>Password for $user was successfully changed</h2> |
<h2>The password for $user was successfully changed</h2> |
ENDTEXT |
ENDTEXT |
} else { |
} else { |
# error error: run in circles, scream and shout |
# error error: run in circles, scream and shout |
$r->print(<<ENDERROR); |
$r->print(<<ENDERROR); |
<h2><font color="#ff0000">Password for $user was not changed</font></h2> |
<h2><font color="#ff0000">The password for $user was not changed</font></h2> |
There was an internal error when attempting to change your password. |
Please make sure your old password was entered correctly. |
Please contact your instructor or the domain coordinator. |
|
ENDERROR |
ENDERROR |
} |
} |
return; |
return; |
Line 317 ENDERROR
|
Line 530 ENDERROR
|
# other handler subroutines # |
# other handler subroutines # |
###################################################### |
###################################################### |
|
|
|
|
################################################################ |
################################################################ |
# Main handler # |
# Main handler # |
################################################################ |
################################################################ |
Line 330 sub handler {
|
Line 542 sub handler {
|
&Apache::loncommon::no_cache($r); |
&Apache::loncommon::no_cache($r); |
$r->send_http_header; |
$r->send_http_header; |
return OK if $r->header_only; |
return OK if $r->header_only; |
# Spit out the header |
# |
if ($ENV{'form.action'} eq 'changepass') { |
if ($ENV{'form.action'} eq 'changepass') { |
&passwordchanger($r); |
&passwordchanger($r); |
} elsif ($ENV{'form.action'} eq 'verify_and_change_pass') { |
} elsif ($ENV{'form.action'} eq 'verify_and_change_pass') { |
&verify_and_change_password($r); |
&verify_and_change_password($r); |
|
} elsif ($ENV{'form.action'} eq 'changescreenname') { |
|
&screennamechanger($r); |
|
} elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') { |
|
&verify_and_change_screenname($r); |
|
} elsif ($ENV{'form.action'} eq 'changemsgforward') { |
|
&msgforwardchanger($r); |
|
} elsif ($ENV{'form.action'} eq 'verify_and_change_msgforward') { |
|
&verify_and_change_msgforward($r); |
|
} elsif ($ENV{'form.action'} eq 'changecolors') { |
|
&colorschanger($r); |
|
} elsif ($ENV{'form.action'} eq 'verify_and_change_colors') { |
|
&verify_and_change_colors($r); |
|
} elsif ($ENV{'form.action'} eq 'debugtoggle') { |
|
if ($ENV{'user.name'} eq 'albertel' ) { |
|
if ($ENV{'user.debug'}) { |
|
&Apache::lonnet::delenv('user\.debug'); |
|
} else { |
|
&Apache::lonnet::appenv('user.debug' => 1); |
|
} |
|
} |
} else { |
} else { |
$r->print(<<ENDHEADER); |
$r->print(<<ENDHEADER); |
<html> |
<html> |
<head> |
<head> |
<title>LON-CAPA Preferences</title> |
<title>LON-CAPA Preferences</title> |
</head> |
</head> |
<body bgcolor="#FFFFFF" > |
|
<h1>Preferences for $user</h1> |
|
<h3>$user is a member of domain $domain</h3> |
|
ENDHEADER |
ENDHEADER |
|
$r->print(&Apache::loncommon::bodytag('Change Your Preferences')); |
# Determine current authentication method |
# Determine current authentication method |
my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain); |
my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain); |
if ($currentauth =~ /^(unix|internal):/) { |
if ($currentauth =~ /^(unix|internal):/) { |
$r->print(<<ENDPASSWORDFORM); |
$r->print(<<ENDPASSWORDFORM); |
<form name="client" action="/adm/preferences" method="post"> |
<form name="client" action="/adm/preferences" method="post"> |
<input type="hidden" name="action" value="changepass"> |
<input type="hidden" name="action" value="changepass" /> |
<input type="submit" value="Change password"> |
<input type="submit" value="Change password" /> |
</form> |
</form> |
ENDPASSWORDFORM |
ENDPASSWORDFORM |
# Other preference setting code should be added here |
} |
|
# Change screen name |
|
$r->print(<<ENDSCREENNAMEFORM); |
|
<form name="client" action="/adm/preferences" method="post"> |
|
<input type="hidden" name="action" value="changescreenname" /> |
|
<input type="submit" |
|
value="Change nickname and anonymous discussion screen name" /> |
|
</form> |
|
ENDSCREENNAMEFORM |
|
$r->print(<<ENDMSGFORWARDFORM); |
|
<form name="client" action="/adm/preferences" method="post"> |
|
<input type="hidden" name="action" value="changemsgforward" /> |
|
<input type="submit" value="Change message forwarding and notification addresses" /> |
|
</form> |
|
ENDMSGFORWARDFORM |
|
# The "about me" page |
|
my $aboutmeaction= |
|
'/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme'; |
|
$r->print(<<ENDABOUTME); |
|
<form name="client" action="$aboutmeaction" method="post"> |
|
<input type="hidden" name="action" value="changescreenname" /> |
|
<input type="submit" value="Edit the 'About Me' personal information screen" /> |
|
</form> |
|
ENDABOUTME |
|
$r->print(<<ENDCOLORFORM); |
|
<form name="client" action="/adm/preferences" method="post"> |
|
<input type="hidden" name="action" value="changecolors" /> |
|
<input type="submit" value="Change color scheme" /> |
|
</form> |
|
ENDCOLORFORM |
|
|
|
if ($ENV{'user.name'} eq 'albertel') { |
|
$r->print(<<ENDDEBUG); |
|
<form name="client" action="/adm/preferences" method="post"> |
|
<input type="hidden" name="action" value="debugtoggle" /> |
|
<input type="submit" value="Toggle Debug" /> |
|
Current Debug status is -$ENV{'user.debug'}-. |
|
</form> |
|
ENDDEBUG |
} |
} |
|
# Other preference setting code should be added here |
} |
} |
$r->print(<<ENDFOOTER); |
$r->print(<<ENDFOOTER); |
</body> |
</body> |
</html> |
</html> |
ENDFOOTER |
ENDFOOTER |
return OK; |
return OK; |
} |
} |
|
|
1; |
1; |
__END__ |
__END__ |