ispCP - Board - Support
Code modifications for a good reading - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Development Area (/forum-1.html)
+--- Forum: Suggestions (/forum-2.html)
+--- Thread: Code modifications for a good reading (/thread-2057.html)



Code modifications for a good reading - Nuxwin - 12-30-2007 05:18 AM

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


RE: Code modifications for a good reading - raphael - 01-03-2008 03:43 AM

Feel free to go ahead, I've done similar changes in the past