MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/scripts.20110531.215904.25158/unsetupfp4
#!/usr/bin/perl
# cpanel - unsetupfp4                             Copyright(c) 2010 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

BEGIN { unshift @INC, '/usr/local/cpanel'; }

require 5.006;

use strict;
use Cpanel::DomainIp                ();
use Cpanel::AccessIds::SetUids      ();
use Cpanel::AcctUtils::DomainOwner  ();
use Cpanel::Config::LoadCpUserFile  ();
use Cpanel::Config::userdata::Load  ();
use Cpanel::Config::userdata::Cache ();
use Cpanel::FrontpageAdmin          ();
use Cpanel::StringFunc              ();
use Cpanel::Config                  ();
use Cpanel::Errors                  ();
use Cpanel::SafeFind                ();

my $domain = shift(@ARGV);
$domain =~ s/\n//g;
$domain =~ s/^www\.//g;

my $subweb = shift(@ARGV);
$subweb =~ s/\.\.//g;
$subweb =~ s/\///g;
$subweb =~ m/([\w\.\-]+)/;
$subweb = $1;

my (@DOMAINS) = @ARGV;

$| = 1;

my $owsadm_bin = '/usr/local/frontpage/version5.0/bin/owsadm.exe';
if ( !-e $owsadm_bin ) {
    die "Frontpage extensions are not installed on this system!";
}

my $main_port = Cpanel::Config::get_main_httpd_port(1);
my $ssl_port  = Cpanel::Config::get_ssl_httpd_port(1);

$0 = "unsetupfp - $domain";

if ( $domain eq "" ) {
    if ( -t STDIN ) {
        print "What is the servername you want to setup? ";
        $domain = <STDIN>;
        chomp($domain);
    }
    else { Cpanel::Errors::deaderror("stdin is not a tty and no domain was given to us"); }
}

if ( Cpanel::FrontpageAdmin::check_fpfakeout($owsadm_bin) == -1 ) {

    # Warnings are already printed in check_fpfakeout()
    exit 1;
}

my $ud_cache = Cpanel::Config::userdata::Cache::load_cache();

if ( !$ud_cache->{$domain} ) {
    Cpanel::Errors::deaderror('No Server found');
}

if ( $ud_cache->{$domain}->[2] =~ /parked|addon/ ) {
    if ( !grep( /^\Q$domain\E$/, @DOMAINS ) ) {
        push @DOMAINS, $domain;
    }
    $domain = $ud_cache->{$domain}->[3];
}

my $userdata = Cpanel::Config::userdata::Load::load_userdata_domain( $ud_cache->{$domain}->[0], $domain );

my $servername = $userdata->{'servername'}   || $domain;
my $docroot    = $userdata->{'documentroot'} || $ud_cache->{$domain}->[4];
my $user       = $userdata->{'user'}         || $ud_cache->{$domain}->[0];

my $cpuser = Cpanel::Config::LoadCpUserFile::loadcpuserfile($user);
my %ALLDOMAINS = map { $_ => 1 } @{ $cpuser->{'DOMAINS'} };
$ALLDOMAINS{$domain} = 1;

my $fsubweb = '';
my $pass    = 'x';
if ( $subweb && $subweb ne '' ) {
    $fsubweb = '/' . $subweb;
}

my $group = getgrgid( ( getpwnam($user) )[3] );    #group is always the user even with fileprotect

if ( !$subweb || $subweb eq '' ) {
    Cpanel::FrontpageAdmin::fpcmd( $user, $servername, $main_port, $owsadm_bin, '-o', 'uninstall', '-t', 'apache-fp', '-m', $servername, '-p', $main_port, '-xUser', $user, '-xGroup', $group, '-u', $user, '-pw', $pass, '-servconf', '/usr/local/apache/conf/httpd.conf' );
    if ( $? != 0 && $? != 1 ) { Cpanel::Errors::undeaderror("$!\n"); }

    my @fp_files;
    foreach my $ddomain ( @DOMAINS, $domain ) {
        if ( $ALLDOMAINS{$ddomain} ) {
            if ( opendir my $ulacs, '/usr/local/apache/conf/sites' ) {
                push @fp_files, map { "/usr/local/apache/conf/sites/$_" } grep { /^(?:www\.)?\Q$ddomain\E\.conf$/ } readdir( $ulacs );
                closedir $ulacs;
            }
            if ( opendir my $ulfp, '/usr/local/frontpage' ) {
                push @fp_files, map { "/usr/local/frontpage/$_" } grep { /^(?:www\.)?\Q$ddomain\E\:\d+\.cnf$/ } readdir( $ulfp );
                closedir $ulfp;
            }
        }
    }
    # Delete any FrontPage config files we found
    if ( @fp_files ) {
        unlink @fp_files;
    }

    Cpanel::AccessIds::SetUids::setuids($user);
}
else {
    Cpanel::AccessIds::SetUids::setuids($user);
    Cpanel::FrontpageAdmin::removesubweb( $docroot, $subweb );
}

chdir '/';
chdir $docroot;
chdir "${docroot}${fsubweb}";

if ( -d $docroot && $docroot =~ /.*\/.*\// ) {
    print "Cleaning up .htaccess files...";
    Cpanel::SafeFind::find(
        {
            wanted => sub {
                if ( $File::Find::name =~ m/\/_vti_[^\/]+$/ || Cpanel::StringFunc::endmatch( $File::Find::name, '/_private' ) ) {
                    $File::Find::name =~ m/(.*)/;
                    system( 'rm', '-rf', $1 );
                }

                if ( Cpanel::StringFunc::endmatch( $File::Find::name, '/.htaccess' ) ) {
                    $File::Find::name =~ m/(.*)/;
                    Cpanel::FrontpageAdmin::purge_fp_htaccess($1);
                }
            },
            no_chdir => 1
        },
        "${docroot}${fsubweb}"
    );
    print "Done\n";
}

if (@DOMAINS) {
    print "Frontpage was uninstalled on the following domains: " . join( ' ', @DOMAINS ) . "\n";
}
else {
    print "Frontpage was uninstalled on the domain: " . $domain . "\n";
}

sub getdlist {
    my $sr = shift;
    $sr =~ s/^www\.//g;
    return ( $sr, 'www.' . $sr );
}