6 * The rest Copyright 2002-2005 (c) GForge Team
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 This file creates the root directories for the FTP
29 require_once $gfwww.'include/squal_pre.php';
30 require $gfcommon.'include/cron_utils.php';
34 if ($sys_use_ftpuploads) {
36 // Add the groups from the gforge database
38 $res=db_query_params ('SELECT group_id,unix_group_name FROM groups WHERE status=$1 AND type_id=$2',
41 for($i = 0; $i < db_numrows($res); $i++) {
42 $groups[] = db_result($res,$i,'unix_group_name');
46 // Create home dir for groups
48 foreach($groups as $group) {
50 //create an FTP upload dir for this project
51 $destdir = $sys_ftp_upload_dir.'/'.$group;
52 if (util_is_root_dir($destdir)) {
53 $err .= "Trying to access root directory\n";
57 if (!is_dir($destdir)) {
58 if (!@mkdir($destdir)) {
59 $err .= 'Could not create dir: '.$destdir."\n";
62 // Unfortunately some versions of PHP don't set the mode properly when
63 // specified on the mkdir command, so we need to do it here
64 if (!@chmod($destdir, 0770)) {
65 $err .= 'Could not chmod dir: '.$destdir."\n";
68 if (!@chown($destdir, $sys_apache_user)) {
69 $err .= 'Could not chown dir: '.$destdir."\n";
72 if (!@chgrp($destdir, $sys_apache_group)) {
73 $err .= 'Could not chgrp dir: '.$destdir."\n";