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 'project_auto_approval_user' => 'project_auto_approval',
38 'shell_host' => 'use_shell',
42 static function account_manager_type($v) { return in_array($v, array('pgsql', 'UNIX')); }
43 static function chroot($v) { return is_dir($v); }
44 static function config_path($v) { return is_dir($v); }
45 static function data_path($v) { return is_dir($v); }
46 static function default_theme($v) { return db_numrows(db_query_params('SELECT * FROM themes WHERE dirname=$1', array($v))) === 1; }
47 static function extra_config_dirs($v) { return is_dir($v); }
48 static function ftp_upload_dir($v) { return is_dir($v); }
49 static function gitweb_cmd($v) { return is_file($v); }
50 static function groupdir_prefix($v) { return is_dir($v); }
51 static function homedir_prefix($v) { return is_dir($v); }
52 static function installation_environment($v) { return in_array($v, array('production', 'integration', 'development')); }
53 static function jpgraph_path($v) { return is_dir($v); }
54 static function log_path($v) { return is_dir($v); }
55 static function mailman_path($v) { return is_dir($v); }
56 static function plugins_path($v) { return is_dir($v); }
57 static function project_auto_approval_user($v) { return db_numrows(db_query_params('SELECT * FROM users WHERE user_name=$1', array($v))) === 1; }
58 static function repos_path($v) { return is_dir($v); }
59 static function scm_snapshots_path($v) { return is_dir($v); }
60 static function scm_tarballs_path($v) { return is_dir($v); }
61 static function sendmail_path($v) { return is_file($v); }
62 static function session_key($v) { return ($v !== 'foobar'); }
63 static function source_path($v) { return is_dir($v); }
64 static function news_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
65 static function stats_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
66 static function template_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
67 static function peer_rating_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
68 static function themes_root($v) { return is_dir($v); }
69 static function upload_dir($v) { return is_dir($v); }
70 static function url_root($v) { return is_dir($v); }
73 site_admin_header(array('title'=>_('Configuration Manager')));
75 echo "<h2>".sprintf (_('Configuration from the config API (*.ini files)'))."</h2>" ;
77 $title_arr = array(_('Variable'),_('Configured value'),_('Result (possibly after interpolation)'));
78 echo $HTML->listTableTop($title_arr);
80 $c = FusionForgeConfig::get_instance () ;
82 $sections = $c->get_sections () ;
84 array_unshift ($sections, 'core') ;
86 foreach ($sections as $section) {
87 if ($section == 'core') {
93 echo '<tr><th colspan="3"><strong>'.sprintf (_('Section %s'), $section)."</strong></th></tr>\n" ;
95 $variables = $c->get_variables ($section) ;
97 foreach ($variables as $var) {
98 if (isset($config_depends_on[$var]) &&
99 (!$c->get_value($section, $config_depends_on[$var]))) {
102 $v = $c->get_value ($section, $var) ;
104 if (method_exists('configCheck', $var)) {
105 $class = configCheck::$var($v)? 'class="good_value"': 'class="wrong_value"';
109 echo '<tr '. $HTML->boxGetAltRowStyle($counter++) .'><td>'.$var ;
110 if ($c->is_bool ($section, $var)) {
114 print htmlspecialchars($c->get_raw_value ($section, $var)) ;
115 print "</td><td $class>" ;
116 if ($c->is_bool ($section, $var)) {
123 print htmlspecialchars($v);
125 print "</td></tr>\n" ;
129 echo $HTML->listTableBottom();
131 site_admin_footer(array());
133 function get_absolute_filename($filename) {
134 // Check for absolute path
135 if (realpath($filename) == $filename) {
139 // Otherwise, treat as relative path
140 $paths = explode(':', get_include_path());
141 foreach ($paths as $path) {
142 if (substr($path, -1) == '/') {
143 $fullpath = $path.$filename;
145 $fullpath = $path.'/'.$filename;
147 if (file_exists($fullpath)) {
157 // c-file-style: "bsd"