#!/usr/local/cpanel/3rdparty/bin/perl
# Copyright 2026 WebPros International, LLC
# 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 TEAM_RESET_DIR { return '/var/cpanel/team_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();
clean_session_handoff_records();
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 );
clean_expired_files( TEAM_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 );
clean_expired_files( TEAM_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;
}
# Expired per-user session handoff records (Cpanel::Session::Handoff). Unlike
# every other sweep here these are not reaped by whatever reads them: a record is
# staged for an account whether or not that account has an interface that ever
# reads one, so an unread record's expiry passes and nothing removes the file.
# The module owns both the record's location and its expiry, so the sweep lives
# there and this only schedules it.
sub clean_session_handoff_records {
print lh()->maketext('Searching for expired session handoff records …') . "\n" if $VERBOSE;
require Cpanel::Session::Handoff;
my $removed = Cpanel::Session::Handoff::reap_expired();
print " " . lh()->maketext( 'The system removed [quant,_1,record,records].', $removed ) . "\n" if $VERBOSE;
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;
}
return;
}
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.
* expired per-user session handoff records.
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
}
Zerion Mini Shell 1.0
Video Chat en Casa - Ganar dinero haciendo videochat en casa - Page 2
Convierte tu perfil en una experiencia: un diseño que transmite profesionalismo, sensualidad y confianza, ideal para elevar tu marca personal en Chaturbate. Ver Demo Las instrucciones con imagenes estan disponibles…
Diseño creado para modelos que quieren destacar: visual atractivo, estructura clara y una presencia que engancha y retiene audiencia. Ver Demo Las instrucciones con imagenes estan disponibles en este articulo.…
Más que un perfil, una vitrina: este diseño está pensado para destacar tu imagen, comunicar tu estilo y atraer usuarios desde el primer vistazo. Ver Demo Las instrucciones con imagenes…
Haz que tu perfil trabaje por ti: un diseño limpio y sensual que resalta tu esencia, ordena tu información y convierte visitas en fans reales. Ver Demo Las instrucciones con…
Transforma tu perfil en Chaturbate con un diseño profesional y llamativo: este estilo potencia tu presencia visual, destaca tu personalidad y hace que tu bio sea más atractiva para los…
Diseño de perfil para Chaturbate: visual atractivo, estilo sensual y una atmósfera que invita a quedarse, interactuar y disfrutar de cada momento del show. Ver Demo Las instrucciones con imagenes…
Un espacio pensado para provocar curiosidad y conexión: miradas que hablan, conversaciones que fluyen y una experiencia íntima donde el respeto y la diversión van de la mano. Ver Demo…
Un perfil atractivo y divertido diseñado para conectar y entretener: invita a los visitantes a disfrutar, compartir momentos y explorar deseos con un toque abierto y juguetón, con reglas claras…
Una biografia con imagenes de fondo grandes, que se pueden cambiar con tus fotos (a peticion). Ten en cuenta que si decides personalizar el diseño, tus fotos deben ser tambien…
Una biografia con diversos elementos como bolsos, maquillajes, tacones… Todo esto, sobre un fondo blanco y repartidos en varias secciones. Ver Demo Las instrucciones con imagenes estan disponibles en este…