3 * FusionForge Config File edit page
5 * Daniel A. PĂ©rez danielperez.arg@gmail.com
6 * Copyright 2005 GForge, LLC
7 * Copyright 2013, Franck Villaume - TrivialDev
8 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'admin/admin_utils.php';
30 $config_depends_on = array(
31 'ftp_upload_dir' => 'use_ftp',
32 'https_port' => 'use_ssl',
33 'images_secure_url' => 'use_ssl',
34 'project_auto_approval_user' => 'project_auto_approval',
35 'shell_host' => 'use_shell',
39 static function account_manager_type($v) { return in_array($v, array('pgsql', 'UNIX')); }
40 static function chroot($v) { return is_dir($v); }
41 static function config_path($v) { return is_dir($v); }
42 static function data_path($v) { return is_dir($v); }
43 static function default_theme($v) { return db_numrows(db_query_params('SELECT * FROM themes WHERE dirname=$1', array($v))) === 1; }
44 static function extra_config_dirs($v) { return is_dir($v); }
45 static function ftp_upload_dir($v) { return is_dir($v); }
46 static function gitweb_cmd($v) { return is_file($v); }
47 static function groupdir_prefix($v) { return is_dir($v); }
48 static function homedir_prefix($v) { return is_dir($v); }
49 static function installation_environment($v) { return in_array($v, array('production', 'integration', 'development')); }
50 static function log_path($v) { return is_dir($v); }
51 static function mailman_path($v) { return is_dir($v); }
52 static function plugins_path($v) { return is_dir($v); }
53 static function project_auto_approval_user($v) { return db_numrows(db_query_params('SELECT * FROM users WHERE user_name=$1', array($v))) === 1; }
54 static function repos_path($v) { return is_dir($v); }
55 static function scm_snapshots_path($v) { return is_dir($v); }
56 static function scm_tarballs_path($v) { return is_dir($v); }
57 static function sendmail_path($v) { return is_file($v); }
58 static function session_key($v) { return ($v !== 'foobar'); }
59 static function source_path($v) { return is_dir($v); }
60 static function news_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
61 static function stats_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
62 static function template_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
63 static function peer_rating_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
64 static function themes_root($v) { return is_dir($v); }
65 static function upload_dir($v) { return is_dir($v); }
66 static function url_root($v) { return is_dir($v); }
69 site_admin_header(array('title'=>_('Configuration Manager')));
71 echo "<h2>".sprintf (_('Configuration from the config API (*.ini files)'))."</h2>" ;
73 $title_arr = array(_('Variable'),_('Configured value'),_('Result (possibly after interpolation)'));
74 echo $HTML->listTableTop($title_arr);
76 $c = FusionForgeConfig::get_instance () ;
78 $sections = $c->get_sections () ;
80 array_unshift ($sections, 'core') ;
82 foreach ($sections as $section) {
83 if ($section == 'core') {
89 echo '<tr><th colspan="3"><strong>'.sprintf (_('Section %s'), $section)."</strong></th></tr>\n" ;
91 $variables = $c->get_variables ($section) ;
93 foreach ($variables as $var) {
94 if (isset($config_depends_on[$var]) &&
95 (!$c->get_value($section, $config_depends_on[$var]))) {
98 $v = $c->get_value ($section, $var) ;
100 if (method_exists('configCheck', $var)) {
101 $class = configCheck::$var($v)? 'class="good_value"': 'class="wrong_value"';
105 echo '<tr '. $HTML->boxGetAltRowStyle($counter++) .'><td>'.$var ;
106 if ($c->is_bool ($section, $var)) {
110 print htmlspecialchars($c->get_raw_value ($section, $var)) ;
111 print "</td><td $class>" ;
112 if ($c->is_bool ($section, $var)) {
119 print htmlspecialchars($v);
121 print "</td></tr>\n" ;
125 echo $HTML->listTableBottom();
127 site_admin_footer(array());
129 function get_absolute_filename($filename) {
130 // Check for absolute path
131 if (realpath($filename) == $filename) {
135 // Otherwise, treat as relative path
136 $paths = explode(':', get_include_path());
137 foreach ($paths as $path) {
138 if (substr($path, -1) == '/') {
139 $fullpath = $path.$filename;
141 $fullpath = $path.'/'.$filename;
143 if (file_exists($fullpath)) {
153 // c-file-style: "bsd"