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 GForge.
15 * GForge 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 * GForge 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 GForge; 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 $gfwww.'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')) {
39 session_require(array('group'=>'1','admin_flags'=>'A'));
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)) {
50 exit_error('Error','Could Not Get Group');
51 } elseif ($group->isError()) {
52 exit_error('Error',$group->getErrorMessage());
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 $feedback .= _('Error adding VHOST:') .db_error();
77 $feedback .= sprintf(_("Virtual host <strong>%s</strong> scheduled for creation on group <em>%s</em>"),
78 $vhost_name, $group->getUnixName());
82 $feedback .= "<strong>" ._('The provided group name does not exist'). "</strong>";
89 if (getStringFromRequest('tweakcommit')) {
90 $vhostid = getIntFromRequest('vhostid');
91 $docdir = getStringFromRequest('docdir');
92 $cgidir = getStringFromRequest('cgidir');
94 $res = db_query_params ('
105 if (!$res || db_affected_rows($res) < 1) {
106 $feedback .= _('Error updating VHOST entry:') .db_error();
108 $feedback .= _('Virtual Host entry updated.');
114 site_admin_header(array('title'=>_('Site admin')));
117 <h3><?php echo _('Virtual Host Administration'); ?></h3>
119 <form name="madd" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
121 <strong><?php echo _('Add Virtual Host'); ?></strong>
126 <td><?php echo _('Group Unix Name'); ?></td>
127 <td><input type="text" name="groupname" /></td>
131 <td><?php echo _('Virtual Host Name'); ?></td>
132 <td><input type="text" name="vhost_name" /></td>
136 <input type="submit" name="add" value="<?php echo _('Add Virtual Host'); ?>" />
142 <strong><?php echo _('Tweak Directories'); ?></strong>
145 <form name="tweak" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
148 <td><?php echo _('Virtual Host:'); ?></td><td><input type="text" name="vhost_name" /></td>
149 <td><input type="submit" value="<?php echo _('Get Info'); ?>" /></td>
153 <input type="hidden" name="tweak" value="1" />
158 if (getStringFromRequest('tweak')) {
159 $vhost_name = getStringFromRequest('vhost_name');
161 $res_vh = db_query_params ('
162 SELECT vhostid,vhost_name,docdir,cgidir,unix_group_name,group_id
163 FROM prweb_vhost,groups
165 AND prweb_vhost.group_id=groups.group_id
167 array($vhost_name)) ;
170 if (db_numrows($res_vh) > 0) {
172 $row_vh = db_fetch_array($res_vh);
174 print '<p><strong>'._('Update Record:').'</strong></p><hr />';
177 $title[]=_('VHOST ID');
178 $title[]=_('VHOST Name');
180 $title[]=_('Htdocs Dir');
181 $title[]=_('CGI Dir');
182 $title[]=_('Operations');
185 <form name="update" method="post" action="'.getStringFromServer('PHP_SELF').'">
187 '.$GLOBALS['HTML']->listTableTop($title).'
188 <tr><td>'.$row_vh['vhostid'].'</td>
189 <td>'.$row_vh['vhost_name'].'</td>
190 <td>'.util_make_link_g ($row_vh['unix_group_name'],$row_vh['group_id'],$row_vh['unix_group_name']).'</td>
191 <td><input maxlength="255" type="text" name="docdir" value="'.$row_vh['docdir'].'" /></td>
192 <td><input type="text" name="cgidir" value="'.$row_vh['cgidir'].'" /></td><td><input maxlength="255" type="submit" value="'._('Update').'" /></tr>
193 '.$GLOBALS['HTML']->listTableBottom().'
195 <input type="hidden" name="tweakcommit" value="1" />
196 <input type="hidden" name="vhostid" value="'.$row_vh['vhostid'].'" />
200 echo _('No such VHOST:') . $vhost_name;
205 site_admin_footer(array());
209 // c-file-style: "bsd"