�&ǐk�@'bJ�h�ۊL'}T� :��'2�Z#$��n�a��� �>a��`��_3d�Qpt�/�P -��#5�,�M��� �pA:©�q�����NW��ډ�A���� �9nʺج���� �TSM��{J6?7��r�@�\����D��� �׶���s�f�TJj?"��D��`?��̒� b�#�%�C*v�$�{�$����5Ծ�F�s��y�e/8��h-�f�̰&(����Gj�L:U� 2�� ����v�_k����Y��gp,�k�WF�R������_C�R��N@���R�@�ߔ?A�w9���F("iNa-S���Q�o�3tDMLh*�#4k�T/iQ��Y*�G��m����)��8�hBm/�I�,g�ﯖ���Z��}�Cz�q@´��d.����L�ŕ�,��1�Z�܌�: ̪���F+J-'��c�tvJ8��]Q-��b��y �6;*J`r_�d ��'�G ~p��)'�C,�%F��E(��2�k�����lР�z�!�=t ��_�0��f7��� ;�p�|�U �% != 0; # Get available PHP packages my @php_common_pkgs = Cpanel::PackMan->instance->list( prefix => "ea-php*-php-common" ); my @available_pkgs = map { my $p = $_; $p =~ s/-php-common.*$//; $p } @php_common_pkgs; # Get installed PHP packages my $php = get_cpanel_proglang(); my $installed_packages_aref = $php->get_installed_packages(); my %installed_pkgs = map { $_ => 1 } @$installed_packages_aref; foreach my $pkg (@available_pkgs) { $installed_pkgs{$pkg} ? clean_installed_pkg_sessions( $pkg, $regex ) : clean_uninstalled_pkg_sessions( $pkg, $regex ); } return 0; } my $php; sub get_cpanel_proglang () { $php ||= Cpanel::ProgLang->new( type => 'php' ); return $php; } sub clean_installed_pkg_sessions ( $pkg, $regex ) { my $php = get_cpanel_proglang(); my $ini = $php->get_ini( 'package' => $pkg ); my $directives = $ini->get_basic_directives(); my ( $path, $maxlifetime ); foreach my $directive ( @{$directives} ) { $maxlifetime = $directive->{'value'} if $directive->{'key'} eq 'session.gc_maxlifetime'; $path = $directive->{'value'} if $directive->{'key'} eq 'session.save_path'; } return clean_sessions( $path, $regex, $maxlifetime ); } sub clean_uninstalled_pkg_sessions ( $pkg, $regex ) { # We can only really clean up the default path in '/var/cpanel/php/sessions' at this point # since there is no way to know what the customer was really using as their session path my $path = $Cpanel::ProgLang::Supported::php::Ini::SESSION_SAVE_PATH . '/' . $pkg; return clean_sessions( $path, $regex ); } sub clean_sessions ( $path, $regex, $maxlife = undef ) { # session.save_path could be commented out, in which case we will let PHP handle garbage collection. return 0 if !defined $path || !-d $path; $maxlife = $Cpanel::ProgLang::Supported::php::Ini::SESSION_MAXLIFETIME if !defined $maxlife; # get_basic_directives can return values with leading/trailing whitespace. s/^\s+|\s+$//g for ( $path, $maxlife ); $maxlife = $Cpanel::ProgLang::Supported::php::Ini::SESSION_MAXLIFETIME if $maxlife !~ /^\d+$/; my $time = time; opendir( my $dh, $path ) or die "Could not open directory $path: $!"; while ( my $file = readdir $dh ) { next if $file !~ m/$regex/i; my $ctime = ( stat("$path/$file") )[10]; unlink "$path/$file" if $time - $ctime > $maxlife; } return 1; } sub help { print <