From: naoki i. <am...@us...> - 2008-04-18 12:41:46
|
Update of /cvsroot/popfile/engine/UI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14105/UI Modified Files: HTML.pm XMLRPC.pm Log Message: Change Log 1. Added 'Current active user sessions' section in the administration tab ( in the multiuser mode only ) 2. New function get_current_sessions() UI/HTML.pm Classifier/Bayes.pm POPFile/API.pm skins/default/administration-page.thtml languages/English.msg languages/Nihongo.msg This will allow administrators to check the current users' activities. NOTE : The administrator's session ( got by get_administrator_session_key ) is not be shown. 3. In the multiuser mode, the login user name is shown at the bottom of the UI UI/HTML.pm The login user name is shown instead of the last login user name. 4. XML-RPC stealth/server setting is now configured correctly UI/XMLRPC.pm 5. Add some status messages in the UI UI/HTML.pm UI/XMLRPC.pm Proxy/POP3.pm Proxy/SMTP.pm Proxy/NNTP.pm languages/English.msg languages/Nihongo.msg tests/TestHTML.script Magnet tab Administration tab 6. Avoid redirect to logout or shutdown page from the password page UI/HTML.pm 7. Password page for the single user mode is restored UI/HTML.pm 8. Update language file languages/Nihongo.msg 9. Minor changes of the skins skins/default/common-bottom.thtml skins/default/administration-page.thtml Current state of the test suite: TestBayesScript PASS TestBayes PASS TestConfiguration PASS * TestHistory PASS TestHTML PASS * TestHTTP PASS TestIMAP PASS TestInsertScript PASS * TestLogger PASS TestMailParse PASS TestModule PASS TestMQ PASS TestMutex PASS TestPipeScript PASS TestPOP3 PASS TestProxy PASS TestWordMangle PASS TestXMLRPC PASS * : TODO : needs to add tests for multi user support Index: HTML.pm =================================================================== RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v retrieving revision 1.390 retrieving revision 1.391 diff -C2 -d -r1.390 -r1.391 *** HTML.pm 17 Apr 2008 15:13:05 -0000 1.390 --- HTML.pm 18 Apr 2008 12:41:49 -0000 1.391 *************** *** 43,47 **** use MIME::Base64; use Crypt::CBC; - use Digest::MD5 qw( md5_hex ); # This is used to get the hostname of the current machine --- 43,46 ---- *************** *** 489,493 **** $self->global_config_( 'single_user' ) ) { ! $session = $self->classifier_()->get_single_user_session_key(); if ( defined ( $session ) ) { # $self->{sessions__}{$session}{lastused} = time; --- 488,494 ---- $self->global_config_( 'single_user' ) ) { ! # If admin has a password, then redirect to the password page ! ! $session = $self->classifier_()->get_session_key( 'admin', '' ); if ( defined ( $session ) ) { # $self->{sessions__}{$session}{lastused} = time; *************** *** 1234,1237 **** --- 1235,1239 ---- # Read the CGI parameters and set the configuration vars accordingly # Server / Stealth mode + if ( defined $self->{form_}->{apply_stealth} ) { my $current_single_user = $self->global_config_( 'single_user' ); *************** *** 1240,1246 **** --- 1242,1250 ---- if ( $self->{form_}->{ serveropt_html } ) { $self->config_( 'local', 0 ); + $self->status_message__( $templ, $self->language($session)->{Security_ServerModeUpdateUI} ); } else { $self->config_( 'local', 1 ); + $self->status_message__( $templ, $self->language($session)->{Security_StealthModeUpdateUI} ); } *************** *** 1252,1271 **** } } # Privacy options elsif ( $self->{form_}->{privacy} ) { ! $self->user_config_( $user, 'send_stats', $self->{form_}->{send_stats} ? 1 : 0 ); ! $self->user_config_( $user, 'update_check', $self->{form_}->{update_check} ? 1 : 0 ); } # Logger options elsif ( $self->{form_}->{submit_debug} ) { ! $self->module_config_( 'logger', 'level', $self->{form_}->{level} ); if ( ( defined($self->{form_}->{debug}) ) && ! ( ( $self->{form_}{debug} >= 1 ) && ! ( $self->{form_}{debug} <= 4 ) ) ) { ! $self->global_config_( 'debug', $self->{form_}{debug}-1 ); } } # HTML module options elsif ( $self->{form_}->{update_modules} ) { if ( defined($self->{form_}{ui_port}) ) { --- 1256,1312 ---- } } + # Privacy options + elsif ( $self->{form_}->{privacy} ) { ! if ( $self->{form_}->{send_stats} ) { ! $self->user_config_( $user, 'send_stats', 1 ); ! $self->status_message__( $templ, $self->language($session)->{Security_StatsOn} . "\n" . ! $self->language($session)->{Security_ExplainStats} ); ! } else { ! $self->user_config_( $user, 'send_stats', 0 ); ! $self->status_message__( $templ, $self->language($session)->{Security_StatsOff} ); ! } ! if ( $self->{form_}->{update_check} ) { ! $self->user_config_( $user, 'update_check', 1 ); ! $self->status_message__( $templ, $self->language($session)->{Security_UpdateOn} . "\n" . ! $self->language($session)->{Security_ExplainUpdate} ); ! } else { ! $self->user_config_( $user, 'update_check', 0 ); ! $self->status_message__( $templ, $self->language($session)->{Security_UpdateOff} ); ! } } + # Logger options + elsif ( $self->{form_}->{submit_debug} ) { ! my $logger_level = $self->{form_}->{level}; ! ! $self->module_config_( 'logger', 'level', $logger_level ); ! $self->status_message__( ! $templ, ! sprintf( $self->language($session)->{Configuration_Logger_LevelUpdate}, ! $self->language($session)->{"Configuration_Logger_Level$logger_level"} ) ); if ( ( defined($self->{form_}->{debug}) ) && ! ( ( $self->{form_}{debug} >= 1 ) && ! ( $self->{form_}{debug} <= 4 ) ) ) { ! my $debug = $self->{form_}{debug} - 1; ! my %debug_options = ( ! 0 => 'Configuration_None', ! 1 => 'Configuration_ToFile', ! 2 => 'Configuration_ToScreen', ! 3 => 'Configuration_ToScreenFile' ); ! ! $self->global_config_( 'debug', $debug ); ! $self->status_message__( ! $templ, ! sprintf( $self->language($session)->{Configuration_LoggerOutputUpdate}, ! $self->language($session)->{$debug_options{$debug}} ) ); } } + # HTML module options + elsif ( $self->{form_}->{update_modules} ) { if ( defined($self->{form_}{ui_port}) ) { *************** *** 1293,1296 **** --- 1334,1338 ---- # Set the template parameters + #$templ->param( 'Security_If_Password_Updated' => ( defined($self->{form_}{password} ) ) ); $templ->param( 'Configuration_UI_Port' => $self->config_( 'port' ) ); *************** *** 1317,1327 **** # Tell the user anything the dynamic UI was interested in sharing if ( defined( $status_message ) ) { $self->log_( 3, "dynamic security UI $name had status $status_message"); ! $self->status_message__($templ,$status_message); } if ( defined( $error_message ) ) { $self->log_( 3, "dynamic security UI $name had error $error_message"); ! $self->error_message__($templ, $error_message); } } --- 1359,1370 ---- # Tell the user anything the dynamic UI was interested in sharing + if ( defined( $status_message ) ) { $self->log_( 3, "dynamic security UI $name had status $status_message"); ! $self->status_message__( $templ, $status_message ); } if ( defined( $error_message ) ) { $self->log_( 3, "dynamic security UI $name had error $error_message"); ! $self->error_message__( $templ, $error_message ); } } *************** *** 1338,1348 **** # Tell the user anything the dynamic UI was interested in sharing if ( defined( $status_message ) ) { $self->log_( 3, "dynamic chain UI $name had status $status_message"); ! $self->status_message__($templ,$status_message); } if ( defined( $error_message ) ) { $self->log_( 3, "dynamic chain UI $name had error $error_message"); ! $self->error_message__($templ, $error_message); } } --- 1381,1392 ---- # Tell the user anything the dynamic UI was interested in sharing + if ( defined( $status_message ) ) { $self->log_( 3, "dynamic chain UI $name had status $status_message"); ! $self->status_message__( $templ, $status_message ); } if ( defined( $error_message ) ) { $self->log_( 3, "dynamic chain UI $name had error $error_message"); ! $self->error_message__( $templ, $error_message ); } } *************** *** 1397,1406 **** # Tell the user anything the dynamic UI was interested in sharing if ( defined( $status_message )) { ! $self->status_message__($templ,$status_message); $self->log_( 2, "dynamic config UI $name had status $status_message"); } if ( defined( $error_message )) { ! $self->error_message__($templ, $error_message); $self->log_( 2, "dynamic config UI $name had error $error_message"); } --- 1441,1451 ---- # Tell the user anything the dynamic UI was interested in sharing + if ( defined( $status_message )) { ! $self->status_message__( $templ, $status_message ); $self->log_( 2, "dynamic config UI $name had status $status_message"); } if ( defined( $error_message )) { ! $self->error_message__( $templ, $error_message ); $self->log_( 2, "dynamic config UI $name had error $error_message"); } *************** *** 1437,1440 **** --- 1482,1516 ---- } + # Current active sessions + + $templ->param( 'Configuration_If_Show_CurrentSessions' => 1); + my $active_sessions = $self->classifier_()->get_current_sessions( $session ); + my @active_sessions_data; + my $current_time = time; + my $odd = 1; + foreach my $active_session (@{$active_sessions}) { + my %row; + $row{CurrentSessions_UserName} = + $self->classifier_()->get_user_name_from_id( $session, $active_session->{userid} ); + $row{CurrentSessions_LastUsed} = + $self->pretty_date__( $active_session->{lastused}, 0, $session ); + my $idletime = $current_time - $active_session->{lastused}; + my $h = int( $idletime / 3600 ); + my $m = int( ( $idletime % 3600 ) / 60 ); + my $s = $idletime % 60; + if ( $h > 0 ) { + $row{CurrentSessions_IdleTime} = + sprintf( "%d:%02d:%02d", $h, $m, $s ); + } elsif ( $m > 0 ) { + $row{CurrentSessions_IdleTime} = + sprintf( "%02d:%02d", $m, $s ); + } else { + $row{CurrentSessions_IdleTime} = + sprintf( ":%02d", $s ); + } + push( @active_sessions_data, \%row ); + } + $templ->param( 'Configuration_Loop_CurrentSessions' => \@active_sessions_data ); + # If the single user mode (POPFile classic) is enabled or disabled # we should reflesh the UI *************** *** 1959,1965 **** $page, $session ); - my $error_message = ''; - my $status_message = ''; - if ( defined( $self->{form_}{delete} ) ) { for my $i ( 1 .. $self->{form_}{count} ) { --- 2035,2038 ---- *************** *** 1971,1974 **** --- 2044,2051 ---- $self->classifier_()->delete_magnet( $session, $mbucket, $mtype, $mtext ); + $self->status_message__( + $templ, + sprintf( $self->language($session)->{Magnet_RemovedMagnets}, + "$mtype: $mtext", $mbucket ) ); } } *************** *** 2033,2037 **** if ( exists( $magnets{$current_mtext} ) ) { $found = 1; ! $error_message .= sprintf( $self->language($session)->{Magnet_Error1}, "$mtype: $current_mtext", $bucket ) . "\n"; last; } --- 2110,2117 ---- if ( exists( $magnets{$current_mtext} ) ) { $found = 1; ! $self->error_message__( ! $templ, ! sprintf( $self->language($session)->{Magnet_Error1}, ! "$mtype: $current_mtext", $bucket ) ); last; } *************** *** 2046,2050 **** if ( ( $mtext =~ /\Q$from\E/ ) || ( $from =~ /\Q$mtext\E/ ) ) { $found = 1; ! $error_message .= sprintf( $self->language($session)->{Magnet_Error2}, "$mtype: $current_mtext", "$mtype: $from", $bucket ) . "\n"; last; } --- 2126,2133 ---- if ( ( $mtext =~ /\Q$from\E/ ) || ( $from =~ /\Q$mtext\E/ ) ) { $found = 1; ! $self->error_message__( ! $templ, ! sprintf( $self->language($session)->{Magnet_Error2}, ! "$mtype: $current_mtext", "$mtype: $from", $bucket ) ); last; } *************** *** 2078,2082 **** $self->classifier_()->create_magnet( $session, $mbucket, $mtype, $current_mtext ); if ( !defined( $self->{form_}{update} ) ) { ! $status_message .= sprintf( $self->language($session)->{Magnet_Error3}, "$mtype: $current_mtext", $mbucket ) . "\n"; } } --- 2161,2168 ---- $self->classifier_()->create_magnet( $session, $mbucket, $mtype, $current_mtext ); if ( !defined( $self->{form_}{update} ) ) { ! $self->status_message__( ! $templ, ! sprintf( $self->language($session)->{Magnet_Error3}, ! "$mtype: $current_mtext", $mbucket ) ); } } *************** *** 2086,2098 **** } - # Show error/status message - - if ( $error_message ne '' ) { - $self->error_message__( $templ, $error_message ); - } - if ( $status_message ne '' ) { - $self->status_message__( $templ, $status_message ); - } - # Current Magnets panel --- 2172,2175 ---- *************** *** 3412,3415 **** --- 3489,3497 ---- $self->history_()->get_slot_fields( $self->{form_}{view}, $session ); + if ( !defined($id) ) { + $self->http_redirect_( $client, "/history", $session ); + return 1; + } + my ( $header, $value ); if ( $magnet ne '' ) { *************** *** 3418,3426 **** } - if ( !defined($id) ) { - $self->http_redirect_( $client, "/history", $session ); - return 1; - } - my $mail_file = $self->history_()->get_slot_file( $self->{form_}{view} ); my $start_message = $self->{form_}{start_message} || 0; --- 3500,3503 ---- *************** *** 3614,3617 **** --- 3691,3702 ---- my $single_user = $self->global_config_( 'single_user' ); + if ( defined( $url ) ) { + # If the URL is '/logout' or '/shutdown', remove it + + if ( ( $url eq '/logout' ) || ( $url eq '/shutdown' ) ) { + $url = '/'; + } + } + $templ->param( 'Header_If_Password' => 1 ); $templ->param( 'Next_Url' => $url ); *************** *** 3708,3715 **** --- 3793,3802 ---- my $user = 1; + my $username = ''; my $can_admin = 0; if ( defined( $session ) ) { $user = $self->{sessions__}{$session}{user}; + $username = $self->classifier_()->get_user_name_from_session( $session ); $can_admin = $self->classifier_()->is_admin_session( $session ); } *************** *** 3743,3747 **** my %fixups = ( 'Skin_Root' => $root, ! 'Common_Bottom_LastLogin' => $self->{last_login__}, 'Common_Bottom_Version' => $self->version(), 'If_Show_Bucket_Help' => --- 3830,3837 ---- my %fixups = ( 'Skin_Root' => $root, ! 'Common_Bottom_LastLogin' => ! ( $self->global_config_( 'single_user' ) ? ! $self->{last_login__} : ! $username ), 'Common_Bottom_Version' => $self->version(), 'If_Show_Bucket_Help' => Index: XMLRPC.pm =================================================================== RCS file: /cvsroot/popfile/engine/UI/XMLRPC.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** XMLRPC.pm 20 Feb 2006 02:22:57 -0000 1.23 --- XMLRPC.pm 18 Apr 2008 12:41:49 -0000 1.24 *************** *** 257,266 **** if ( $name eq 'xmlrpc_local' ) { ! if ( $self->config_( 'local' ) == 1 ) { ! $templ->param( 'XMLRPC_local_on' => 1 ); ! } ! else { ! $templ->param( 'XMLRPC_local_on' => 0 ); ! } } } --- 257,262 ---- if ( $name eq 'xmlrpc_local' ) { ! $templ->param( 'XMLRPC_local_on' => $self->config_( 'local' ) ); ! return $self->config_( 'local' ); } } *************** *** 289,293 **** if ( $name eq 'xmlrpc_port' ) { if ( defined($$form{xmlrpc_port}) ) { ! if ( ( $$form{xmlrpc_port} >= 1 ) && ( $$form{xmlrpc_port} < 65536 ) ) { $self->config_( 'port', $$form{xmlrpc_port} ); $status = sprintf( $$language{Configuration_XMLRPCUpdate}, $self->config_( 'port' ) ); --- 285,289 ---- if ( $name eq 'xmlrpc_port' ) { if ( defined($$form{xmlrpc_port}) ) { ! if ( ( $$form{xmlrpc_port} =~ /^\d+$/ ) && ( $$form{xmlrpc_port} >= 1 ) && ( $$form{xmlrpc_port} < 65536 ) ) { $self->config_( 'port', $$form{xmlrpc_port} ); $status = sprintf( $$language{Configuration_XMLRPCUpdate}, $self->config_( 'port' ) ); *************** *** 299,303 **** if ( $name eq 'xmlrpc_local' ) { ! $self->config_( 'local', $$form{xmlrpc_local}-1 ) if ( defined($$form{xmlrpc_local}) ); } --- 295,308 ---- if ( $name eq 'xmlrpc_local' ) { ! if ( $$form{serveropt_xmlrpc} ) { ! $self->config_( 'local', 0 ); ! $status = $$language{Security_ServerModeUpdateXMLRPC}; ! } ! else { ! $self->config_( 'local', 1 ); ! $status = $$language{Security_StealthModeUpdateXMLRPC}; ! } ! ! return( $status, $error ); } |