shell bypass 403

UnknownSec Shell

: /scripts/ [ drwxr-xr-x ]

name : process_site_templates
#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/process_site_templates          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

use strict;

ProcessSiteTemplates::run(@ARGV) unless caller;

package ProcessSiteTemplates;

use Getopt::Long qw(GetOptionsFromArray);
use Try::Tiny;

use File::Basename;

use Cpanel::Template        ();
use Cpanel::JSON            ();
use Cpanel::PwCache         ();
use Cpanel::SafeDir::MK     ();
use Cpanel::SafeRun::Errors ();
use Cpanel::Tar             ();

sub usage {
    my $exit_code = shift || 0;
    print <<EO_USAGE;
process_site_templates --source=/path/to/site/templates --target=/path/to/target/directory

Process Site Publisher templates from a source directory in order to generate HTML files in the target directory.
This script overwrites any existing files in the target directory.

    Options:
      --define para1=val1 Provide a value for a parameter that the template uses.

EO_USAGE

    require POSIX;
    POSIX::_exit($exit_code);
    return;
}

sub bail_out {
    my ($msg) = @_;
    print STDERR "Error: $msg\n\n";
    usage(1);
    return;
}

my ( $source, $target, $config, %parameters, $help, $tt, $bu_file, $config_file, $homedir );

sub run {
    my (@args) = @_;

    die "Do not run this script as the root user" if ( $> == 0 );

    $homedir = Cpanel::PwCache::gethomedir();

    my %parameters = ();

    GetOptionsFromArray(
        \@args,
        'source=s' => \$source,
        'target=s' => \$target,
        'config=s' => \$config,
        'define=s' => \%parameters,
        'help'     => \$help,
    ) || usage(1);

    if ($help) {
        usage(0);
    }

    unless ( $target && -d $target && $target =~ m/^\// ) {
        bail_out("The target directory ($target) is invalid.");
    }

    my $config_dir = $homedir . '/site_publisher/configurations';
    unless ( -d $config_dir ) {
        Cpanel::SafeDir::MK::safemkdir($config_dir);
    }
    chmod 0700, $config_dir;

    $config_file = join( '-', split( /\/+/, $target ) );
    $config_file =~ s{^-}{};
    $config_file .= '.json';
    $config_file = $config_dir . '/' . $config_file;

    my $data_file = $target . '/configurations.json';

    my $current_settings = {};

    if ( -e $config_file ) {
        eval { $current_settings = Cpanel::JSON::LoadFile($config_file) };
    }
    elsif ( -e $data_file ) {
        eval { $current_settings = Cpanel::JSON::LoadFile($data_file) };
        save_settings($current_settings);
    }
    unlink $data_file;

    try {
        do_archive();
    }
    catch {
        die "Unable to create a backup of the target directory: $_";
    };

    if ($config) {
        if ( -e $config ) {
            eval { $current_settings = Cpanel::JSON::LoadFile($config) };
        }
        else {
            die "Unable to read config file: $config";
        }
    }

    unless ( $source && -d $source ) {
        if ( $current_settings->{path} && $current_settings->{template} ) {
            $source = $current_settings->{path} . '/' . $current_settings->{template};
        }

        bail_out("The source directory ($source) is invalid.") unless $source && -d $source;
    }

    foreach my $k ( keys %parameters ) {
        $current_settings->{$k} = $parameters{$k};
    }

    try {
        process_templates($current_settings);
    }
    catch {
        my $msg = $_;

        if ( $bu_file && -e $bu_file ) {
            restore_target();
        }

        die "Publication of site template failed: $msg";
    };

    my $template = basename($source);
    my $path     = dirname($source);
    $current_settings->{'template'} = $template;
    $current_settings->{'path'}     = $path;

    save_settings($current_settings);

    return 1;
}

sub process_templates {
    my ( $data, $current_dir ) = @_;

    my $template_dir = $source;
    $template_dir .= '/' . $current_dir if ($current_dir);
    return unless ( -d $template_dir && opendir my $dh, $template_dir );

    my $dest_dir = $target;
    $dest_dir .= '/' . $current_dir if ($current_dir);
    die "The system could not create the destination directory: $dest_dir." unless ( -d $dest_dir || mkdir $dest_dir, 0755 );

    my @sub_directories = ();
    foreach my $tmpl ( readdir($dh) ) {
        next if $tmpl =~ m/^\./;
        next if $tmpl eq 'meta.json';
        next if $tmpl eq 'preview.png';
        next if $tmpl =~ m/README/i;

        if ( -d $template_dir . '/' . $tmpl ) {
            push @sub_directories, $current_dir . '/' . $tmpl;
            next;
        }

        my $dest = $tmpl;
        if ( $tmpl =~ m/\.tt$/ ) {
            $dest =~ s/\.tt$//;
            $data->{template_file} = $tmpl;
            die unless open( my $fh, '>', $dest_dir . '/' . $dest );
            my ( $success, $output ) = Cpanel::Template::process_template(
                'site_template',
                $data,
                {
                    'print_yn'     => 0,
                    'include_path' => [ $template_dir, $source ],
                }
            );
            print {$fh} $$output;
            close $fh;
        }
        else {
            my $ret = Cpanel::SafeRun::Errors::saferunonlyerrors( '/bin/cp', '-f', $template_dir . '/' . $tmpl, $dest_dir . '/' . $dest );
            die $ret if scalar grep ( /cannot/i, split( /\n/, $ret ) );
        }
    }
    close $dh;

    foreach my $sub (@sub_directories) {
        process_templates( $data, $sub );
    }

    return 1;
}

sub do_archive {
    $bu_file = join( '-', split( /\/+/, $target ) );
    $bu_file =~ s{^-}{};
    $bu_file .= '-' . $$ . '-' . time();

    my $bu_dir = $homedir . '/site_publisher/backups';
    unless ( -d $bu_dir ) {
        Cpanel::SafeDir::MK::safemkdir($bu_dir);
    }
    chmod 0700, $bu_dir;

    # discard things older than 30 days
    if ( opendir( my $dh, $bu_dir ) ) {
        my @old_files = grep /-\d+-\d+\.tar\.gz$/, readdir($dh);
        closedir $dh;

        my $current = time();
        my $cutoff  = $current - 30 * 24 * 60 * 60;

        foreach my $f (@old_files) {
            my @pots  = split( /-/, $f );
            my $stamp = $pots[-1];
            $stamp =~ s{\.tar\.gz$}{};
            if ( $stamp < $cutoff ) {
                unlink $bu_dir . '/' . $f;
            }
        }
    }

    $bu_file = $bu_dir . '/' . $bu_file . '.tar.gz';
    my $ret = Cpanel::SafeRun::Errors::saferunonlyerrors( Cpanel::Tar::load_tarcfg()->{'bin'}, '-c', '-v', '-z', '-f', $bu_file, $target );
    die $ret if scalar grep ( /error/i, split( /\n/, $ret ) );

    return;
}

sub restore_target {
    Cpanel::SafeRun::Errors::saferunnoerror( '/usr/bin/rm', '-rf', '--', $target );
    chdir '/';
    Cpanel::SafeRun::Errors::saferunnoerror( Cpanel::Tar::load_tarcfg()->{'bin'}, '-x', '-v', '-z', '-f', $bu_file );

    return;
}

sub save_settings {
    my ($settings) = @_;
    my $orig_mask = umask 0077;
    my $out_fh;
    unless ( open( $out_fh, '>', $config_file ) ) {
        die "The system could not save settings to the file: $config_file";
    }

    require Cpanel::JSON::Sanitize;
    print {$out_fh} Cpanel::JSON::Dump( Cpanel::JSON::Sanitize::sanitize_for_dumping($settings) );
    close $out_fh;
    umask $orig_mask;

    return;
}

1;

© 2025 UnknownSec
Display on the page Footer | Anyleson - Learning Platform
INR (₹)
India Rupee
$
United States Dollar

Display on the page Footer

Privacy Policy

Effective Date: 24 August , 2024

At Anyleson, we are committed to protecting your privacy and ensuring that your personal information is handled securely and responsibly. This Privacy Policy outlines how we collect, use, and safeguard your data when you use our platform.


Information We Collect


  1. Personal Information:

    • Name, email address, phone number, and billing details.

    • Account login credentials (username and password).



  2. Course Usage Data:

    • Progress and activity within courses.

    • Feedback and reviews submitted for courses.



  3. Technical Information:

    • IP address, browser type, device information, and cookies for improving website functionality.



  4. Communication Data:

    • Information from your interactions with our customer support.




How We Use Your Information


  1. To Provide Services:

    • Process course purchases, registrations, and access to content.



  2. To Improve User Experience:

    • Analyze user behavior to enhance course offerings and platform features.



  3. To Communicate:

    • Send updates, notifications, and promotional offers (only if you’ve opted in).



  4. For Legal Compliance:

    • Meet legal or regulatory requirements and prevent fraud.




How We Protect Your Information


  1. Data Encryption: All sensitive data is encrypted during transmission using SSL.

  2. Access Control: Only authorized personnel have access to personal information.

  3. Secure Storage: Data is stored on secure servers with regular security updates.


Sharing Your Information

We do not sell, rent, or trade your personal data. However, we may share your information with:


  1. Service Providers:

    • Payment processors and hosting services that assist in delivering our platform.



  2. Legal Authorities:

    • When required by law or to protect our legal rights.




Your Rights


  1. Access and Update: You can view and update your personal information in your account settings.

  2. Request Deletion: You have the right to request deletion of your data by contacting us.

  3. Opt-Out: You can opt out of receiving promotional emails by clicking the “unsubscribe” link in our emails.


Cookies Policy

We use cookies to enhance your experience by:


  • Remembering your preferences.

  • Analyzing website traffic.
    You can manage your cookie preferences through your browser settings.


Third-Party Links

Our platform may contain links to third-party websites. We are not responsible for their privacy practices and recommend reviewing their privacy policies.


Policy Updates

We may update this Privacy Policy from time to time. Changes will be posted on this page, and the "Effective Date" will be updated. Please review the policy periodically.


Contact Us

If you have any questions or concerns about our Privacy Policy or how your data is handled, please contact us at:

Email: support@anyleson.comThank you for trusting Anyleson with your learning journey!