6 * The rest Copyright 2002-2005 (c) GForge Team
9 * This file is part of FusionForge.
11 * FusionForge 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 * FusionForge 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 blank user home directories and
28 creates a group home directory with a template in it.
33 <VirtualHost 192.168.1.5>
34 ServerName gforge.company.com
35 ServerAlias *.gforge.company.com
36 VirtualDocumentRoot /home/groups/%1/htdocs
37 VirtualScriptAlias /home/groups/%1/cgi-bin
39 <Directory /home/groups>
40 Options Indexes FollowSymlinks
46 LogFormat "%h %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" gforge
47 CustomLog "|/usr/local/sbin/cronolog /home/groups/%1/logs/%Y/%m/%d/gforge.log" gforge
48 # Ensure that we don't try to use SSL on SSL Servers
49 <IfModule apache_ssl.c>
54 require_once dirname(__FILE__).'/../www/env.inc.php';
55 require_once $gfcommon.'include/pre.php';
56 require $gfcommon.'include/cron_utils.php';
58 setup_gettext_from_sys_lang();
59 define('USER_DEFAULT_GROUP','users');
63 if (forge_get_config('groupdir_prefix') == '') { // this should be set in configuration
67 if (!is_dir(forge_get_config('groupdir_prefix'))) {
68 @mkdir(forge_get_config('groupdir_prefix'),0755,true);
71 if (forge_get_config('homedir_prefix') == '') { // this should be set in configuration
75 if (!is_dir(forge_get_config('homedir_prefix'))) {
76 @mkdir(forge_get_config('homedir_prefix'),0755,true);
79 $active_projects = group_get_active_projects() ;
81 foreach ($active_projects as $project) {
82 foreach ($project->getUsers() as $u) {
83 $unames[] = $u->getUnixName() ;
86 $unames = array_unique ($unames) ;
87 foreach($unames as $uname) {
88 if (is_dir(forge_get_config('homedir_prefix')."/".$uname)) {
91 @mkdir(forge_get_config('homedir_prefix')."/".$uname);
93 system("chown $uname:".USER_DEFAULT_GROUP." ".forge_get_config('homedir_prefix')."/".$uname);
96 //test if the FTP upload dir exists and create it if not
97 if (!is_dir(forge_get_config('ftp_upload_dir'))) {
98 @mkdir(forge_get_config('ftp_upload_dir'),0755,true);
101 foreach($active_projects as $project) {
102 $groupname = $project->getUnixName() ;
103 //create an FTP upload dir for this project
104 if (forge_get_config('use_ftp_uploads')) {
105 if (!is_dir(forge_get_config('ftp_upload_dir').'/'.$groupname)) {
106 @mkdir(forge_get_config('ftp_upload_dir').'/'.$groupname);
110 if (is_dir(forge_get_config('groupdir_prefix')."/".$groupname)) {
113 @mkdir(forge_get_config('groupdir_prefix')."/".$groupname);
114 @mkdir(forge_get_config('groupdir_prefix')."/".$groupname."/htdocs");
115 @mkdir(forge_get_config('groupdir_prefix')."/".$groupname."/cgi-bin");
118 // Read in the template file
120 $fo=fopen(dirname(__FILE__).'/../utils/default_page.php','r');
123 $err .= 'Default Page Not Found';
126 $contents .= fread($fo, 8192);
131 // Change some defaults in the template file
133 $contents=str_replace('##comment##', _('Default Web Page for groups that haven\'t setup their page yet'), $contents);
134 $contents=str_replace('##purpose##', _('Please replace this file with your own website'), $contents);
135 $contents=str_replace('##welcome_to##', sprintf(_('Welcome to %s'), $project->getPublicName()), $contents);
136 $contents=str_replace('##body##',
138 _("We're Sorry but this Project hasn't yet uploaded their personal webpage yet. <br /> Please check back soon for updates or visit <a href=\"%s\">the project page</a>."),
139 util_make_url ('/projects/'.$project->getUnixName())),
142 // Write the file back out to the project home dir
144 $fw=fopen(forge_get_config('groupdir_prefix')."/".$groupname."/htdocs/index.html",'w');
145 fwrite($fw,$contents);
149 if (forge_get_config('use_manual_uploads')) {
150 $incoming = forge_get_config('groupdir_prefix')/$groupname."/incoming" ;
151 if (!is_dir($incoming))
157 system("chown -R ".forge_get_config('apache_user').":".forge_get_config('apache_group')." forge_get_config('groupdir_prefix')/$groupname");