From: <jgr...@us...> - 2003-06-09 18:31:17
|
Update of /cvsroot/popfile/engine/UI In directory sc8-pr-cvs1:/tmp/cvs-serv20343/UI Modified Files: HTML.pm Log Message: Comment updates, make jump_to_message and password_page play nice together, add the last ten lines of the log output to the configuration page, change the way that session keys are generated Index: HTML.pm =================================================================== RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v retrieving revision 1.166 retrieving revision 1.167 diff -C2 -d -r1.166 -r1.167 *** HTML.pm 7 Jun 2003 03:13:13 -0000 1.166 --- HTML.pm 9 Jun 2003 18:31:12 -0000 1.167 *************** *** 56,60 **** # folder (by default messages/) and is updated by the load_history_cache__ method # ! # Access to the history cache is formatted $self->{history}{file}{subkey} where # the file is the name of the file that is related to this history entry. # --- 56,60 ---- # folder (by default messages/) and is updated by the load_history_cache__ method # ! # Access to the history cache is formatted $self->{history__}{file}{subkey} where # the file is the name of the file that is related to this history entry. # *************** *** 71,75 **** # # The history_keys array stores the list of keys in the history hash and are a ! # (perhaps strict) subset of the keys of $self->{history} set by calls to # sory_filter_history. history_keys references the elements on history that are # in the current filter, sort or search set. --- 71,75 ---- # # The history_keys array stores the list of keys in the history hash and are a ! # (perhaps strict) subset of the keys of $self->{history__} set by calls to # sory_filter_history. history_keys references the elements on history that are # in the current filter, sort or search set. *************** *** 117,158 **** --- 117,171 ---- # Checking for updates if off by default + $self->config_( 'update_check', 0 ); # Sending of statistics is off + $self->config_( 'send_stats', 0 ); # The size of a history page + $self->config_( 'page_size', 20 ); # Only accept connections from the local machine for the UI + $self->config_( 'local', 1 ); # Use the default skin + $self->config_( 'skin', 'SimplyBlue' ); # Keep the history for two days + $self->config_( 'history_days', 2 ); # The last time we checked for an update using the local epoch + $self->config_( 'last_update_check', 0 ); # The user interface password + $self->config_( 'password', '' ); # The last time (textual) that the statistics were reset + $self->config_( 'last_reset', localtime ); # We start by assuming that the user speaks English like the # perfidious Anglo-Saxons that we are... :-) + $self->config_( 'language', 'English' ); # If this is 1 then when the language is loaded we will use the language string identifier as the # string shown in the UI. This is used to test whether which identifiers are used where. + $self->config_( 'test_language', 0 ); # If 1, Messages are saved to an archive when they are removed or expired from the history cache + $self->config_( 'archive', 0, 1 ); # The directory where messages will be archived to, in sub-directories for each bucket + $self->config_( 'archive_dir', 'archive' ); *************** *** 161,176 **** --- 174,194 ---- # bucket directory # 0 <= directory name < archive_classes + $self->config_( 'archive_classes', 0 ); # Load skins + load_skins($self); # Load the list of available user interface languages + load_languages($self); # Calculate a session key + change_session_key($self); # The parent needs a reference to the url handler function + $self->{url_handler_} = \&url_handler__; *************** *** 304,307 **** --- 322,328 ---- if ( defined( $self->{form_}{redirect} ) ) { $url = $self->{form_}{redirect}; + if ( $url =~ s/\?(.*)// ) { + $self->parse_form__( $1 ); + } } else { $url = '/'; *************** *** 317,321 **** if ( ( (!defined($self->{form_}{session})) || ($self->{form_}{session} eq '' ) || ( $self->{form_}{session} ne $self->{session_key__} ) ) && ( $self->config_( 'password' ) ne '' ) ) { ! password_page( $self, $client, 0, $url ); return 1; } --- 338,376 ---- if ( ( (!defined($self->{form_}{session})) || ($self->{form_}{session} eq '' ) || ( $self->{form_}{session} ne $self->{session_key__} ) ) && ( $self->config_( 'password' ) ne '' ) ) { ! ! # Since the URL that has caused us to hit the password page might have information stored in the ! # form hash we need to extract it out (except for the session key) and package it up so that ! # the password page can redirect to the right place if the correct password is entered. This ! # is especially important for the XPL functionality. ! ! my $redirect_url = $url . '?'; ! ! foreach my $k (keys %{$self->{form_}}) { ! ! # Skip the session key since we are in the process of ! # assigning a new one through the password page ! ! if ( $k ne 'session' ) { ! ! # If we are dealing with an array of values (see parse_form__ ! # for details) then we need to unpack it into separate entries), ! # we ignore non-array values since all values have an array equivalent ! ! if ( $k =~ /^(.+)_array$/ ) { ! my $field = $1; ! ! foreach my $v (@{$self->{form_}{$k}}) { ! $redirect_url .= "$field=$v&" ! } ! } ! } ! } ! ! $redirect_url =~ s/&$//; ! ! $self->log_( "Correct password will redirect to $redirect_url" ); ! ! password_page( $self, $client, 0, $redirect_url ); ! return 1; } *************** *** 962,965 **** --- 1017,1038 ---- } + if ( $self->global_config_( 'debug' ) != 0 ) { + my @log_entries = @{$self->last_ten_log_entries()}; + + if ( $#log_entries >= -1 ) { + $body .= '<p><tt>'; + foreach my $line (@log_entries) { + $line =~ s/[\"\r\n]//g; + my $full_line = $line; + $line =~ /^(.{0,80})/; + $line = "$1..."; + + $body .= "<a title=\"$full_line\">$line</a><br>"; + } + + $body .= '</tt>'; + } + } + $body .= "</td>\n</tr>\n</table>\n"; *************** *** 2550,2554 **** $bucket =~ s/[\r\n]//g; } else { ! print "Error: " . $self->global_config_( 'msgdir' ) . "$filename: $!\n"; } return ( $reclassified, $bucket, $usedtobe, $magnet ); --- 2623,2627 ---- $bucket =~ s/[\r\n]//g; } else { ! $self->log_( "Error: " . $self->global_config_( 'msgdir' ) . "$filename: $!" ); } return ( $reclassified, $bucket, $usedtobe, $magnet ); *************** *** 3344,3348 **** # change_session_key # ! # Changes the session key # # --------------------------------------------------------------------------------------------- --- 3417,3428 ---- # change_session_key # ! # Changes the session key, the session key is a randomly chosen 6 to 10 character key that ! # protects and identifies sessions with the POPFile user interface. At the current time ! # it is primarily used for two purposes: to prevent a malicious user telling the browser to ! # hit a specific URL causing POPFile to do something undesirable (like shutdown) and to ! # handle the password mechanism: if the session key is wrong the password challenge is ! # made. ! # ! # The characters valid in the session key are A-Z, a-z and 0-9 # # --------------------------------------------------------------------------------------------- *************** *** 3351,3357 **** my ( $self ) = @_; $self->{session_key__} = ''; ! for my $i (0 .. 7) { ! $self->{session_key__} .= chr(rand(1)*26+65); } } --- 3431,3452 ---- my ( $self ) = @_; + my @chars = ( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'U', 'V', 'W', 'X', 'Y', + 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A' ); + $self->{session_key__} = ''; ! ! my $length = int( 6 + rand(4) ); ! ! for my $i (0 .. $length) { ! my $random = $chars[int( rand(36) )]; ! ! # Just to add spice to things we sometimes lowercase the value ! ! if ( rand(1) < rand(1) ) { ! $random = lc($random); ! } ! ! $self->{session_key__} .= $random; } } *************** *** 3374,3378 **** next if ( /[ \t]*#/ ); ! if ( /([^ ]+)[ \t]+(.+)/ ) { my $id = $1; my $msg = ($self->config_( 'test_language' ))?$1:$2; --- 3469,3473 ---- next if ( /[ \t]*#/ ); ! if ( /([^\t ]+)[ \t]+(.+)/ ) { my $id = $1; my $msg = ($self->config_( 'test_language' ))?$1:$2; |