6 * The rest Copyright 2002-2005 (c) GForge Team
7 * Copyright 2012, Franck Villaume - TrivialDev
8 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
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 along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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)) {
89 @mkdir(forge_get_config('homedir_prefix')."/".$uname);
91 system("chown $uname:".USER_DEFAULT_GROUP." ".forge_get_config('homedir_prefix')."/".$uname);
94 //test if the FTP upload dir exists and create it if not
95 if (!is_dir(forge_get_config('ftp_upload_dir'))) {
96 @mkdir(forge_get_config('ftp_upload_dir'), 0755, true);
99 foreach($active_projects as $project) {
100 $groupname = $project->getUnixName();
101 //create an FTP upload dir for this project
102 if (forge_get_config('use_ftp_uploads')) {
103 if (!is_dir(forge_get_config('ftp_upload_dir').'/'.$groupname)) {
104 @mkdir(forge_get_config('ftp_upload_dir').'/'.$groupname);
108 if (!is_dir(forge_get_config('groupdir_prefix')."/".$groupname)) {
109 @mkdir(forge_get_config('groupdir_prefix')."/".$groupname);
110 @mkdir(forge_get_config('groupdir_prefix')."/".$groupname."/htdocs");
111 @mkdir(forge_get_config('groupdir_prefix')."/".$groupname."/cgi-bin");
114 // Read in the template file
116 $fo = fopen(dirname(__FILE__).'/../utils/default_page.php', 'r');
119 $err .= 'Default Page Not Found';
122 $contents .= fread($fo, 8192);
127 // Change some defaults in the template file
129 $contents = str_replace('##comment##', _('Default Web Page for groups that haven\'t setup their page yet'), $contents);
130 $contents = str_replace('##purpose##', _('Please replace this file with your own website'), $contents);
131 $contents = str_replace('##welcome_to##', sprintf(_('Welcome to %s'), $project->getPublicName()), $contents);
132 $contents = str_replace('##body##',
134 _("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>."),
135 util_make_url('/projects/'.$project->getUnixName())),
138 // Write the file back out to the project home dir
140 $fw = fopen(forge_get_config('groupdir_prefix').'/'.$groupname.'/htdocs/index.html', 'w');
141 fwrite($fw, $contents);
145 if (forge_get_config('use_manual_uploads')) {
146 $incoming = forge_get_config('groupdir_prefix').'/'.$groupname.'/incoming';
147 if (!is_dir($incoming)) {
152 system('chown -R '.forge_get_config('apache_user').':'.forge_get_config('apache_group').' '.forge_get_config('groupdir_prefix').'/'.$groupname);