Current time: 12-25-2024, 03:34 PM Hello There, Guest! (LoginRegister)


Post Reply 
Code modifications for a good reading
Author Message
Nuxwin
Unregistered

 
Post: #1
Code modifications for a good reading
Hello;

Sorry for my very long absence ...


This message just for you propose modification for directories (WWW) creation:

Example for ispcp-dmn-mngr file :


Replacement of this :

Code:
    #
    # Domain WWW directories;
    #

    $rs = make_dir(
                    "$www_dir/$dmn_name",
                    $sys_user,
                    $httpd_gid,
                    0770
                    );

    return $rs if ($rs != 0);

    $rs = make_dir(
                    "$www_dir/$dmn_name/cgi-bin",
                    $sys_user,
                    $sys_group,
                    0755
                    );

    return $rs if ($rs != 0);

    $rs = make_dir(
                    "$www_dir/$dmn_name/logs",
                    $sys_user,
                    $httpd_gid,
                    0770
                    );

    return $rs if ($rs != 0);

    $rs = make_dir(
                    "$www_dir/$dmn_name/phptmp",
                    $sys_user,
                    $httpd_gid,
                    0770
                    );

    return $rs if ($rs != 0);

    $rs = make_dir(
                    "$www_dir/$dmn_name/backups",
                    $sys_user,
                    $httpd_gid,
                    0770
                    );

    return $rs if ($rs != 0);

    $rs = make_dir(
                    "$www_dir/$dmn_name/errors",
                    $sys_user,
                    $sys_group,
                    0775
                    );

    return $rs if ($rs != 0);

    $rs = make_dir(
                    "$www_dir/$dmn_name/errors/inc",
                    $sys_user,
                    $sys_group,
                    0775
                    );

    return $rs if ($rs != 0);

by this :

Code:
my %directories = ( # directory_name => octal value
                     $dmn_name                         =>    0770,
                     $dmn_name.'/cgi-bin'           =>    0755,
                     $dmn_name.'/logs'               =>    0770,
                     $dmn_name.'/phptmp'          =>    0770,
                     $dmn_name.'/backups'         =>    0770,
                     $dmn_name.'/errors'             =>    0775,
                     $dmn_name.'/errors/inc'       =>    0775

                    );

my @grp = ($httpd_gid, $sys_group, $httpd_gid, $httpd_gid, $httpd_gid, $sys_group, $sys_group);

my $grp_value = undef;

    foreach (sort keys %directories) {
        
    $grp_value = shift @grp;

        $rs = make_dir(
                     "$www_dir/$_",
                     $sys_user,
                     $grp_value,
                     $directories{$_}
                    );

        return $rs if ($rs != 0);

    }

or

Code:
my %directories = ( # directory_name => octal value
                     $dmn_name                         =>    0770,
                     $dmn_name.'/cgi-bin'           =>    0755,
                     $dmn_name.'/logs'               =>    0770,
                     $dmn_name.'/phptmp'          =>    0770,
                     $dmn_name.'/backups'         =>    0770,
                     $dmn_name.'/errors'             =>    0775,
                     $dmn_name.'/errors/inc'       =>    0775

                    );

my $grp_value = undef;
my $cnt = '0';

    foreach (sort keys %directories) {
        
       if($cnt == '0' || $cnt > '4') {
           $grp_value = $httpd_gid;
       } else {
           $grp_value = $sys_group;
       }

        $rs = make_dir(
                     "$www_dir/$_",
                     $sys_user,
                     $grp_value,
                     $directories{$_}
                    );

        return $rs if ($rs != 0);
        
    $cnt++;

    }

Thank for your responses.

Nuxwin
12-30-2007 05:18 AM
Quote this message in a reply
raphael Offline
Member
***

Posts: 474
Joined: Apr 2007
Reputation: 8
Post: #2
RE: Code modifications for a good reading
Feel free to go ahead, I've done similar changes in the past
01-03-2008 03:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)