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 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 $gfwww.'include/squal_pre.php';
56 require $gfcommon.'include/cron_utils.php';
58 setup_gettext_from_sys_lang();
59 define('USER_DEFAULT_GROUP','users');
63 if (!isset($groupdir_prefix)) { // this should be set in local.inc
64 $groupdir_prefix = '/home/groups';
67 if (!is_dir($groupdir_prefix)) {
68 @mkdir($groupdir_prefix,0755,true);
71 if (!isset($homedir_prefix)) { // this should be set in local.inc
72 $$homedir_prefix = '/home';
75 if (!is_dir($homedir_prefix)) {
76 @mkdir($homedir_prefix,0755,true);
79 $res = db_query_params ('SELECT distinct users.user_name,users.unix_pw,users.user_id
80 FROM users,user_group,groups
81 WHERE users.user_id=user_group.user_id
82 AND user_group.group_id=groups.group_id
84 AND user_group.cvs_flags IN (0,1)
86 ORDER BY user_id ASC',
90 $users =& util_result_column_to_array($res,'user_name');
92 $group_res = db_query_params ('SELECT unix_group_name, (is_public=1 AND enable_anonscm=1 AND type_id=1) AS enable_pserver FROM groups WHERE status=$1 AND type_id=1',
95 $groups = util_result_column_to_array($group_res,'unix_group_name');
99 // this is where we give a user a home
101 foreach($users as $user) {
102 if (is_dir($homedir_prefix."/".$user)) {
105 @mkdir($homedir_prefix."/".$user);
107 system("chown $user:".USER_DEFAULT_GROUP." ".$homedir_prefix."/".$user);
112 // Create home dir for groups
114 foreach($groups as $group) {
116 //test if the FTP upload dir exists and create it if not
117 if (!is_dir($sys_ftp_upload_dir)) {
118 @mkdir($sys_ftp_upload_dir,0755,true);
121 //create an FTP upload dir for this project
122 if (forge_get_config('use_ftpuploads')) {
123 if (!is_dir($sys_ftp_upload_dir.'/'.$group)) {
124 @mkdir($sys_ftp_upload_dir.'/'.$group);
128 if (is_dir($groupdir_prefix."/".$group)) {
131 @mkdir($groupdir_prefix."/".$group);
132 @mkdir($groupdir_prefix."/".$group."/htdocs");
133 @mkdir($groupdir_prefix."/".$group."/cgi-bin");
134 $g =& group_get_object_by_name($group);
138 // Read in the template file
140 $fo=fopen(dirname(__FILE__).'/../utils/default_page.php','r');
143 $err .= 'Default Page Not Found';
146 $contents .= fread($fo, 8192);
151 // Change some defaults in the template file
153 //$contents=str_replace('<domain>',forge_get_config('web_host'),$contents);
154 //$contents=str_replace('<project_description>',$g->getDescription(),$contents);
155 //$contents=str_replace('<project_name>',$g->getPublicName(),$contents);
156 //$contents=str_replace('<group_id>',$g->getID(),$contents);
157 //$contents=str_replace('<group_name>',$g->getUnixName(),$contents);
159 $contents=str_replace('##comment##', _('Default Web Page for groups that haven\'t setup their page yet'), $contents);
160 $contents=str_replace('##purpose##', _('Please replace this file with your own website'), $contents);
161 $contents=str_replace('##welcome_to##', sprintf(_('Welcome to %s'), $g->getPublicName()), $contents);
162 $contents=str_replace('##body##',
164 _("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>."),
165 "http://".forge_get_config('web_host').'/projects/'.$g->getUnixName()),
168 // Write the file back out to the project home dir
170 $fw=fopen($groupdir_prefix."/".$group."/htdocs/index.html",'w');
171 fwrite($fw,$contents);
174 system("chown -R $sys_apache_user:$sys_apache_group $groupdir_prefix/$group");