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
15 * This file is part of GForge.
17 * GForge is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * GForge is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with GForge; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 require_once('../env.inc.php');
33 require_once('pre.php');
34 require_once('common/include/account.php');
35 require_once('www/admin/admin_utils.php');
37 if (!$sys_use_project_vhost) {
41 session_require(array('group'=>'1','admin_flags'=>'A'));
43 if (getStringFromRequest('add')) {
44 $groupname = getStringFromRequest('groupname');
45 $vhost_name = getStringFromRequest('vhost_name');
46 //$group_id = getIntFromRequest('group_id');
50 $group = &group_get_object_by_name($groupname);
51 if (!$group || !is_object($group)) {
52 exit_error('Error','Could Not Get Group');
53 } elseif ($group->isError()) {
54 exit_error('Error',$group->getErrorMessage());
57 $group_id = $group->getID();
59 if (valid_hostname($vhost_name)) {
61 $homedir = account_group_homedir($group->getUnixName());
62 $docdir = $homedir.'/htdocs/';
63 $cgidir = $homedir.'/cgi-bin/';
67 INSERT INTO prweb_vhost(vhost_name, docdir, cgidir, group_id)
68 VALUES ('$vhost_name','$docdir','$cgidir',$group_id)
71 if (!$res || db_affected_rows($res) < 1) {
72 $feedback .= $Language->getText('admin_vhost','error_adding_vhost') .db_error();
74 $feedback .= $Language->getText('admin_vhost','virtual_host'). "<strong>".$vhost_name."</strong>" .$Language->getText('admin_vhost','scheduled_for_creation'). "<em>".$group->getUnixName()."</em>";
78 $feedback .= "<strong>" .$Language->getText('admin_vhost','the_provided_group'). "</strong>";
85 if (getStringFromRequest('tweakcommit')) {
86 $vhostid = getIntFromRequest('vhostid');
87 $docdir = getStringFromRequest('docdir');
88 $cgidir = getStringFromRequest('cgidir');
94 WHERE vhostid=$vhostid
97 if (!$res || db_affected_rows($res) < 1) {
98 $feedback .= $Language->getText('admin_vhost','error_updating_vhost') .db_error();
100 $feedback .= $Language->getText('admin_vhost','virtual_host_entry_updated');
106 site_admin_header(array('title'=>$Language->getText('admin_vhost','title')));
109 <h3><?php echo $Language->getText('admin_vhost','virtual_host_administration'); ?></h3>
111 <form name="madd" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
113 <strong><?php echo $Language->getText('admin_vhost','add_virtual_host'); ?></strong>
118 <td><?php echo $Language->getText('admin_vhost','group_unix_name'); ?></td>
119 <td><input type="text" name="groupname" /></td>
123 <td><?php echo $Language->getText('admin_vhost','virtual_host_name'); ?></td>
124 <td><input type="text" name="vhost_name" /></td>
128 <input type="submit" name="add" value="<?php echo $Language->getText('admin_vhost','add_virtual_host'); ?>" />
134 <strong><?php echo $Language->getText('admin_vhost','tweak_directories'); ?></strong>
137 <form name="tweak" method="post" action="<?php echo getStringFromServer('PHP_SELF'); ?>">
140 <td><?php echo $Language->getText('admin_vhost','virtual_host'); ?></td><td><input type="text" name="vhost_name" /></td>
141 <td><input type="submit" value="<?php echo $Language->getText('admin_vhost','get_info'); ?>" /></td>
145 <input type="hidden" name="tweak" value="1" />
150 if (getStringFromRequest('tweak')) {
151 $vhost_name = getStringFromRequest('vhost_name');
154 SELECT vhostid,vhost_name,docdir,cgidir,unix_group_name
155 FROM prweb_vhost,groups
156 WHERE vhost_name='$vhost_name'
157 AND prweb_vhost.group_id=groups.group_id
160 if (db_numrows($res_vh) > 0) {
162 $row_vh = db_fetch_array($res_vh);
164 print '<p><strong>'.$Language->getText('admin_vhost','update_record').'</strong></p><hr />';
167 $title[]=$Language->getText('admin_vhost','vhost_id');
168 $title[]=$Language->getText('admin_vhost','vhost_name');
169 $title[]=$Language->getText('admin_vhost','group');
170 $title[]=$Language->getText('admin_vhost','htdocs_dir');
171 $title[]=$Language->getText('admin_vhost','cgi_dir');
172 $title[]=$Language->getText('admin_vhost','operations');
175 <form name="update" method="post" action="'.getStringFromServer('PHP_SELF').'">
177 '.$GLOBALS['HTML']->listTableTop($title).'
178 <tr><td>'.$row_vh['vhostid'].'</td>
179 <td>'.$row_vh['vhost_name'].'</td>
180 <td><a href="'.$GLOBALS['sys_urlprefix'].'/projects/'.$row_vh['unix_group_name'].'">'.$row_vh['unix_group_name'].'</a></td>
181 <td><input maxlength="255" type="text" name="docdir" value="'.$row_vh['docdir'].'" /></td>
182 <td><input type="text" name="cgidir" value="'.$row_vh['cgidir'].'" /></td><td><input maxlength="255" type="submit" value="'.$Language->getText('admin_vhost','update').'" /></tr>
183 '.$GLOBALS['HTML']->listTableBottom().'
185 <input type="hidden" name="tweakcommit" value="1" />
186 <input type="hidden" name="vhostid" value="'.$row_vh['vhostid'].'" />
190 echo $Language->getText('admin_vhost','no_such_host') . $vhost_name;
195 site_admin_footer(array());