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 (!$sys_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 .= _('Virtual Host:'). "<strong>".$vhost_name."</strong>" ._('scheduled for creation on group'). "<em>".$group->getUnixName()."</em>";
81 $feedback .= "<strong>" ._('The provided group name does not exist'). "</strong>";
88 if (getStringFromRequest('tweakcommit')) {
89 $vhostid = getIntFromRequest('vhostid');
90 $docdir = getStringFromRequest('docdir');
91 $cgidir = getStringFromRequest('cgidir');
93 $res = db_query_params ('
104 if (!$res || db_affected_rows($res) < 1) {
105 $feedback .= _('Error updating VHOST entry:') .db_error();
107 $feedback .= _('Virtual Host entry updated.');
113 site_admin_header(array('title'=>_('Site admin')));
116 <h3><?php echo _('Virtual Host Administration'); ?></h3>
118 <form name="madd" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
120 <strong><?php echo _('Add Virtual Host'); ?></strong>
125 <td><?php echo _('Group Unix Name'); ?></td>
126 <td><input type="text" name="groupname" /></td>
130 <td><?php echo _('Virtual Host Name'); ?></td>
131 <td><input type="text" name="vhost_name" /></td>
135 <input type="submit" name="add" value="<?php echo _('Add Virtual Host'); ?>" />
141 <strong><?php echo _('Tweak Directories'); ?></strong>
144 <form name="tweak" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
147 <td><?php echo _('Virtual Host:'); ?></td><td><input type="text" name="vhost_name" /></td>
148 <td><input type="submit" value="<?php echo _('Get Info'); ?>" /></td>
152 <input type="hidden" name="tweak" value="1" />
157 if (getStringFromRequest('tweak')) {
158 $vhost_name = getStringFromRequest('vhost_name');
160 $res_vh = db_query_params ('
161 SELECT vhostid,vhost_name,docdir,cgidir,unix_group_name,group_id
162 FROM prweb_vhost,groups
164 AND prweb_vhost.group_id=groups.group_id
166 array($vhost_name)) ;
169 if (db_numrows($res_vh) > 0) {
171 $row_vh = db_fetch_array($res_vh);
173 print '<p><strong>'._('Update Record:').'</strong></p><hr />';
176 $title[]=_('VHOST ID');
177 $title[]=_('VHOST Name');
179 $title[]=_('Htdocs Dir');
180 $title[]=_('CGI Dir');
181 $title[]=_('Operations');
184 <form name="update" method="post" action="'.getStringFromServer('PHP_SELF').'">
186 '.$GLOBALS['HTML']->listTableTop($title).'
187 <tr><td>'.$row_vh['vhostid'].'</td>
188 <td>'.$row_vh['vhost_name'].'</td>
189 <td>'.util_make_link_g ($row_vh['unix_group_name'],$row_vh['group_id'],$row_vh['unix_group_name']).'</td>
190 <td><input maxlength="255" type="text" name="docdir" value="'.$row_vh['docdir'].'" /></td>
191 <td><input type="text" name="cgidir" value="'.$row_vh['cgidir'].'" /></td><td><input maxlength="255" type="submit" value="'._('Update').'" /></tr>
192 '.$GLOBALS['HTML']->listTableBottom().'
194 <input type="hidden" name="tweakcommit" value="1" />
195 <input type="hidden" name="vhostid" value="'.$row_vh['vhostid'].'" />
199 echo _('No such VHOST:') . $vhost_name;
204 site_admin_footer(array());
208 // c-file-style: "bsd"