3 * Project Admin page to manage group's VHOST entries
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
7 * http://fusionforge.org/
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once '../../env.inc.php';
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfwww.'project/admin/project_admin_utils.php';
29 if (!forge_get_config('use_project_vhost')) {
33 $group_id = getIntFromRequest('group_id');
34 session_require_perm ('project_admin', $group_id) ;
36 $group = group_get_object($group_id);
38 if (!$group || !is_object($group)) {
39 exit_error('Error','Error creating group object');
40 } elseif ($group->isError()) {
41 exit_error('ERROR',$group->getErrorMessage());
44 if (getStringFromRequest('createvhost')) {
45 $vhost_name = getStringFromRequest('vhost_name');
47 $homedir = account_group_homedir($group->getUnixName());
48 $docdir = $homedir.'/htdocs/';
49 $cgidir = $homedir.'/cgi-bin/';
51 if (valid_hostname($vhost_name)) {
53 $res = db_query_params('INSERT INTO prweb_vhost(vhost_name, docdir, cgidir, group_id)
54 values ($1, $2, $3, $4)', array($vhost_name, $docdir, $cgidir, $group->getID()));
56 if (!$res || db_affected_rows($res) < 1) {
57 $feedback .= "Cannot insert VHOST entry: ".db_error();
59 $feedback .= _('Virtual Host scheduled for creation.');
60 $group->addHistory('Added vhost '.$vhost_name.' ','');
65 $feedback .= sprintf(_('Not a valid hostname - %s'), $vhost_name);
71 if (getStringFromRequest('deletevhost')) {
72 $vhostid = getStringFromRequest('vhostid');
74 //schedule for deletion
76 $res = db_query_params ('
83 $row_vh = db_fetch_array($res);
85 $res = db_query_params ('
86 DELETE FROM prweb_vhost
93 if (!$res || db_affected_rows($res) < 1) {
94 $feedback .= "Could not delete VHOST entry:".db_error();
96 $feedback .= _('VHOST deleted');
97 $group->addHistory('Virtual Host '.$row_vh['vhost_name'].' Removed','');
103 project_admin_header(array('title'=>_('Virtual Host Management'),'group'=>$group->getID()));
105 print '<h2>' . _('Add New Virtual Host') . '</h2>';
108 printf(_('To add a new virtual host - simply point a <strong>CNAME</strong> for <em>yourhost.org</em> at <strong>%1$s.%2$s</strong>. %3$s does not currently host mail (i.e. cannot be an MX) or DNS</strong>.'), $group->getUnixName(), forge_get_config ('web_host'), forge_get_config ('forge_name'));
112 printf(_('Clicking on “Create” will schedule the creation of the Virtual Host. This will be synced to the project webservers - such that <em>yourhost.org</em> will display the material at <em>%1$s.%2$s</em>.'), $group->getUnixName(), forge_get_config ('web_host'));
117 <form name="new_vhost" action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group->getID().'&createvhost=1'; ?>" method="post">
120 <td> <?php echo _('New Virtual Host <em>(e.g. vhost.org)</em>') ?> </td>
121 <td> <input type="text" size="15" maxlength="255" name="vhost_name" /> </td>
122 <td> <input type="submit" value="<?php echo _('Create') ?>" /> </td>
129 $res_db = db_query_params('
132 WHERE group_id=$1', array($group->getID()));
134 if (db_numrows($res_db) > 0) {
137 $title[]=_('Virtual Host');
138 $title[]=_('Operations');
139 echo $GLOBALS['HTML']->listTableTop($title);
141 while ($row_db = db_fetch_array($res_db)) {
144 <td>'.$row_db['vhost_name'].'</td>
145 <td>[ <strong><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group->getID().'&vhostid='.$row_db['vhostid'].'&deletevhost=1">'._('Delete').'</a></strong>]
151 echo $GLOBALS['HTML']->listTableBottom();
154 echo '<p>'._('No VHOSTs defined').'</p>';
157 project_admin_footer(array());