version 1.14, 2006/04/07 22:15:34
|
version 1.17, 2006/09/28 20:47:13
|
Line 32 use strict;
|
Line 32 use strict;
|
use Apache::lonnet; |
use Apache::lonnet; |
use Crypt::IDEA; |
use Crypt::IDEA; |
use Time::HiRes qw(gettimeofday); |
use Time::HiRes qw(gettimeofday); |
|
use LONCAPA; |
|
|
sub encryptseed { |
sub encryptseed { |
my $seed=$env{'course.'.$env{'request.course.id'}.'.internal.encseed'}; |
my $seed=$env{'course.'.$env{'request.course.id'}.'.internal.encseed'}; |
$seed=~s/[^0-9a-f]/0/g; |
$seed=~s/[^0-9a-f]/0/g; |
Line 45 sub unencrypted {
|
Line 46 sub unencrypted {
|
my $uri=shift; |
my $uri=shift; |
$uri=~s/^\/enc\/(\d+)\///; |
$uri=~s/^\/enc\/(\d+)\///; |
my $cmdlength=$1; |
my $cmdlength=$1; |
|
# strip any added extension |
|
$uri=~s/\.[^.]*//; |
my $seed=&encryptseed(); |
my $seed=&encryptseed(); |
unless ($seed) { |
unless ($seed) { |
return '/'.$uri; |
return '/'.$uri; |
} |
} |
$uri=&Apache::lonnet::unescape($uri); |
$uri=&unescape($uri); |
my $cipher=new IDEA $seed; |
my $cipher=new IDEA $seed; |
my $decuri=''; |
my $decuri=''; |
for (my $encidx=0;$encidx<length($uri);$encidx+=16) { |
for (my $encidx=0;$encidx<length($uri);$encidx+=16) { |
Line 101 sub encrypted {
|
Line 104 sub encrypted {
|
$encuri.=unpack("H16", |
$encuri.=unpack("H16", |
$cipher->encrypt(substr($uri,$encidx,8))); |
$cipher->encrypt(substr($uri,$encidx,8))); |
} |
} |
return '/enc/'.$cmdlength.'/'.&Apache::lonnet::escape($encuri); |
return '/enc/'.$cmdlength.'/'.&escape($encuri); |
} |
} |
|
|
sub check_encrypt { |
sub check_encrypt { |
Line 128 sub encrypt_ref {
|
Line 131 sub encrypt_ref {
|
if (!$value) { next; } |
if (!$value) { next; } |
my $href=&Apache::lonnet::hreflocation($Apache::lonxml::pwd[-1],$value); |
my $href=&Apache::lonnet::hreflocation($Apache::lonxml::pwd[-1],$value); |
if ($href !~ /^http:/) { |
if ($href !~ /^http:/) { |
|
# IE really wants an extension |
|
my ($extension) = ($href =~ m/(\.[^.]*)$/); |
$href = &Apache::lonenc::encrypted($href,$force_enc); |
$href = &Apache::lonenc::encrypted($href,$force_enc); |
|
$href .= $extension; |
} |
} |
$token->[2]->{$name}=$href; |
$token->[2]->{$name}=$href; |
} |
} |