3 * Site Admin page for maintaining groups' Virtual Hosts
6 * - add a VHOST entry for group
7 * - query properties of VHOST entry
8 * - edit some database (by going to group's DB Admin page)
9 * - register existing database in system
11 * Copyright 1999-2001 (c) VA Linux Systems
13 * This file is part of FusionForge.
15 * FusionForge is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * FusionForge is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with FusionForge; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 require_once('../env.inc.php');
31 require_once $gfcommon.'include/pre.php';
32 require_once $gfcommon.'include/account.php';
33 require_once $gfwww.'admin/admin_utils.php';
35 if (!forge_get_config('use_project_vhost')) {
36 exit_disabled('home');
39 session_require_global_perm ('forge_admin');
41 if (getStringFromRequest('add')) {
42 $groupname = getStringFromRequest('groupname');
43 $vhost_name = getStringFromRequest('vhost_name');
44 //$group_id = getIntFromRequest('group_id');
48 $group = group_get_object_by_name($groupname);
49 if (!$group || !is_object($group)) {
51 } elseif ($group->isError()) {
52 exit_error($group->getErrorMessage(),'home');
55 $group_id = $group->getID();
57 if (valid_hostname($vhost_name)) {
59 $homedir = account_group_homedir($group->getUnixName());
60 $docdir = $homedir.'/htdocs/';
61 $cgidir = $homedir.'/cgi-bin/';
64 $res = db_query_params ('
65 INSERT INTO prweb_vhost(vhost_name, docdir, cgidir, group_id)
74 if (!$res || db_affected_rows($res) < 1) {
75 $error_msg .= _('Error adding VHOST: ') .db_error();
77 $feedback .= _('Virtual Host: ').$vhost_name._(' scheduled for creation on group ').$group->getUnixName();
80 $error_msg .= _('Vhost not valid');
83 $warning_msg .= _('Missing group name');
87 if (getStringFromRequest('tweakcommit')) {
88 $vhostid = getIntFromRequest('vhostid');
89 $docdir = getStringFromRequest('docdir');
90 $cgidir = getStringFromRequest('cgidir');
92 $res = db_query_params ('
103 if (!$res || db_affected_rows($res) < 1) {
104 $error_msg .= _('Error updating VHOST entry: ') .db_error();
106 $feedback .= _('Virtual Host entry updated.');
112 site_admin_header(array('title'=>_('Site admin')));
115 <h3><?php echo _('Virtual Host Administration'); ?></h3>
117 <form name="madd" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
119 <strong><?php echo _('Add Virtual Host'); ?></strong>
124 <td><?php echo _('Project Unix Name'); ?></td>
125 <td><input type="text" name="groupname" /></td>
129 <td><?php echo _('Virtual Host Name'); ?></td>
130 <td><input type="text" name="vhost_name" /></td>
134 <input type="submit" name="add" value="<?php echo _('Add Virtual Host'); ?>" />
140 <strong><?php echo _('Tweak Directories'); ?></strong>
143 <form name="tweak" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
146 <td><?php echo _('Virtual Host:'); ?></td><td><input type="text" name="vhost_name" /></td>
147 <td><input type="submit" value="<?php echo _('Get Info'); ?>" /></td>
151 <input type="hidden" name="tweak" value="1" />
156 if (getStringFromRequest('tweak')) {
157 $vhost_name = getStringFromRequest('vhost_name');
159 $res_vh = db_query_params ('
160 SELECT vhostid,vhost_name,docdir,cgidir,unix_group_name,group_id
161 FROM prweb_vhost,groups
163 AND prweb_vhost.group_id=groups.group_id
165 array($vhost_name)) ;
168 if (db_numrows($res_vh) > 0) {
170 $row_vh = db_fetch_array($res_vh);
172 print '<div class="feedback">'._('Update Record:').'</div>';
175 $title[]=_('VHOST ID');
176 $title[]=_('VHOST Name');
178 $title[]=_('Htdocs Dir');
179 $title[]=_('CGI Dir');
180 $title[]=_('Operations');
183 <form name="update" method="post" action="'.getStringFromServer('PHP_SELF').'">
185 '.$GLOBALS['HTML']->listTableTop($title).'
186 <tr><td>'.$row_vh['vhostid'].'</td>
187 <td>'.$row_vh['vhost_name'].'</td>
188 <td>'.util_make_link_g ($row_vh['unix_group_name'],$row_vh['group_id'],$row_vh['unix_group_name']).'</td>
189 <td><input maxlength="255" type="text" name="docdir" value="'.$row_vh['docdir'].'" /></td>
190 <td><input type="text" name="cgidir" value="'.$row_vh['cgidir'].'" /></td><td><input maxlength="255" type="submit" value="'._('Update').'" /></tr>
191 '.$GLOBALS['HTML']->listTableBottom().'
193 <input type="hidden" name="tweakcommit" value="1" />
194 <input type="hidden" name="vhostid" value="'.$row_vh['vhostid'].'" />
198 echo '<div class="warning">'._('No such VHOST: ') . $vhost_name.'</div>';
203 site_admin_footer(array());
207 // c-file-style: "bsd"