3 * FusionForge Config File edit page
8 * Copyright 2005 GForge, LLC
9 * http://fusionforge.org/
11 * Daniel A. PĂ©rez danielperez.arg@gmail.com
13 * This file is part of FusionForge. FusionForge is free software;
14 * you can redistribute it and/or modify it under the terms of the
15 * GNU General Public License as published by the Free Software
16 * Foundation; either version 2 of the Licence, or (at your option)
19 * FusionForge is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 require_once('../env.inc.php');
30 require_once $gfcommon.'include/pre.php';
31 require_once $gfwww.'admin/admin_utils.php';
33 $config_depends_on = array(
34 'ftp_upload_dir' => 'use_ftp',
35 'https_port' => 'use_ssl',
36 'images_secure_url' => 'use_ssl',
37 'jabber_host' => 'use_jabber',
38 'jabber_port' => 'use_jabber',
39 'jabber_password' => 'use_jabber',
40 'jabber_user' => 'use_jabber',
41 'project_auto_approval_user' => 'project_auto_approval',
42 'shell_host' => 'use_shell',
46 static function account_manager_type($v) { return ($v === 'pgsql'); }
47 static function chroot($v) { return is_dir($v); }
48 static function config_path($v) { return is_dir($v); }
49 static function data_path($v) { return is_dir($v); }
50 static function default_theme($v) { return db_numrows(db_query_params('SELECT * FROM themes WHERE dirname=$1', array($v))) === 1; }
51 static function extra_config_dirs($v) { return is_dir($v); }
52 static function ftp_upload_dir($v) { return is_dir($v); }
53 static function gitweb_cmd($v) { return is_file($v); }
54 static function groupdir_prefix($v) { return is_dir($v); }
55 static function homedir_prefix($v) { return is_dir($v); }
56 static function installation_environment($v) { return in_array($v, array('production', 'integration', 'development')); }
57 static function jpgraph_path($v) { return is_dir($v); }
58 static function log_path($v) { return is_dir($v); }
59 static function mailman_path($v) { return is_dir($v); }
60 static function plugins_path($v) { return is_dir($v); }
61 static function project_auto_approval_user($v) { return db_numrows(db_query_params('SELECT * FROM users WHERE user_name=$1', array($v))) === 1; }
62 static function repos_path($v) { return is_dir($v); }
63 static function scm_snapshots_path($v) { return is_dir($v); }
64 static function scm_tarballs_path($v) { return is_dir($v); }
65 static function sendmail_path($v) { return is_file($v); }
66 static function session_key($v) { return ($v !== 'foobar'); }
67 static function source_path($v) { return is_dir($v); }
68 static function news_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
69 static function stats_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
70 static function template_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
71 static function peer_rating_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
72 static function themes_root($v) { return is_dir($v); }
73 static function upload_dir($v) { return is_dir($v); }
74 static function url_root($v) { return is_dir($v); }
77 site_admin_header(array('title'=>_('Configuration Manager')));
79 echo "<h2>".sprintf (_('Configuration from the config API (*.ini files)'))."</h2>" ;
81 $title_arr = array(_('Variable'),_('Configured value'),_('Result (possibly after interpolation)'));
82 echo $HTML->listTableTop($title_arr);
84 $c = FusionForgeConfig::get_instance () ;
86 $sections = $c->get_sections () ;
88 array_unshift ($sections, 'core') ;
90 foreach ($sections as $section) {
91 if ($section == 'core') {
97 echo '<tr><th colspan="3"><strong>'.sprintf (_('Section %s'), $section)."</strong></th></tr>\n" ;
99 $variables = $c->get_variables ($section) ;
100 natsort($variables) ;
101 foreach ($variables as $var) {
102 if (isset($config_depends_on[$var]) &&
103 (!$c->get_value($section, $config_depends_on[$var]))) {
106 $v = $c->get_value ($section, $var) ;
108 if (method_exists('configCheck', $var)) {
109 $class = configCheck::$var($v)? 'class="good_value"': 'class="wrong_value"';
113 echo '<tr '. $HTML->boxGetAltRowStyle($counter++) .'><td>'.$var ;
114 if ($c->is_bool ($section, $var)) {
118 print htmlspecialchars($c->get_raw_value ($section, $var)) ;
119 print "</td><td $class>" ;
120 if ($c->is_bool ($section, $var)) {
127 print htmlspecialchars($v);
129 print "</td></tr>\n" ;
133 echo $HTML->listTableBottom();
135 site_admin_footer(array());
137 function get_absolute_filename($filename) {
138 // Check for absolute path
139 if (realpath($filename) == $filename) {
143 // Otherwise, treat as relative path
144 $paths = explode(':', get_include_path());
145 foreach ($paths as $path) {
146 if (substr($path, -1) == '/') {
147 $fullpath = $path.$filename;
149 $fullpath = $path.'/'.$filename;
151 if (file_exists($fullpath)) {
161 // c-file-style: "bsd"