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
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 require_once('../../env.inc.php');
28 require_once $gfwww.'include/pre.php';
29 require_once $gfwww.'project/admin/project_admin_utils.php';
31 if (!forge_get_config('use_project_vhost')) {
35 $group_id = getIntFromRequest('group_id');
36 session_require(array('group'=>$group_id,'admin_flags'=>'A'));
38 $group = &group_get_object($group_id);
40 if (!$group || !is_object($group)) {
41 exit_error('Error','Error creating group object');
42 } else if ($group->isError()) {
43 exit_error('ERROR',$group->getErrorMessage());
46 if (getStringFromRequest('createvhost')) {
47 $vhost_name = getStringFromRequest('vhost_name');
49 $homedir = account_group_homedir($group->getUnixName());
50 $docdir = $homedir.'/htdocs/';
51 $cgidir = $homedir.'/cgi-bin/';
53 if (valid_hostname($vhost_name)) {
55 $res = db_query_params('INSERT INTO prweb_vhost(vhost_name, docdir, cgidir, group_id)
56 values ($1, $2, $3, $4)', array($vhost_name, $docdir, $cgidir, $group->getID()));
58 if (!$res || db_affected_rows($res) < 1) {
59 $feedback .= "Cannot insert VHOST entry: ".db_error();
61 $feedback .= _('Virtual Host scheduled for creation.');
62 $group->addHistory('Added vhost '.$vhost_name.' ','');
67 $feedback .= sprintf(_('Not a valid hostname - %1$s'), $vhost_name);
73 if (getStringFromRequest('deletevhost')) {
74 $vhostid = getStringFromRequest('vhostid');
76 //schedule for deletion
78 $res = db_query_params ('
85 $row_vh = db_fetch_array($res);
87 $res = db_query_params ('
88 DELETE FROM prweb_vhost
95 if (!$res || db_affected_rows($res) < 1) {
96 $feedback .= "Could not delete VHOST entry:".db_error();
98 $feedback .= _('VHOST deleted');
99 $group->addHistory('Virtual Host '.$row_vh['vhost_name'].' Removed','');
105 project_admin_header(array('title'=>_('Virtual Host Management'),'group'=>$group->getID()));
111 <?php printf(_('<strong><span style="text-decoration:underline">Add New Virtual Host</span></strong><p>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>. <p>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>%4$s.%5$s</em>.'), $group->getUnixName(), forge_get_config('web_host'), forge_get_config ('forge_name'), $group->getUnixName(), forge_get_config('web_host')) ?>
114 <form name="new_vhost" action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group->getID().'&createvhost=1'; ?>" method="post">
117 <td> <?php echo _('New Virtual Host <em>(e.g. vhost.org)</em>') ?> </td>
118 <td> <input type="text" size="15" maxlength="255" name="vhost_name" /> </td>
119 <td> <input type="submit" value="<?php echo _('Create') ?>" /> </td>
126 $res_db = db_query_params('
129 WHERE group_id=$1', array($group->getID()));
131 if (db_numrows($res_db) > 0) {
134 $title[]=_('Virtual Host');
135 $title[]=_('Operations');
136 echo $GLOBALS['HTML']->listTableTop($title);
138 while ($row_db = db_fetch_array($res_db)) {
141 <td>'.$row_db['vhost_name'].'</td>
142 <td>[ <strong><a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group->getID().'&vhostid='.$row_db['vhostid'].'&deletevhost=1">'._('Delete').'</a></strong>]
148 echo $GLOBALS['HTML']->listTableBottom();
151 echo '<p>'._('No VHOSTs defined').'No VHOSTs defined</p>';
154 project_admin_footer(array());