root/trunk/src/main/core/lib/php/global_info.inc.php @ 169

Revision 169, 8.2 KB (checked in by david.vanenckevort@…, 3 years ago)

Makefile target for core.tgz fixed
Reference to unset variable in JobControl? fixed
Duplication of slashes in global_info.inc.php fixed, default for the site URL XSS safe

Line 
1<?php
2
3/*
4 Copyright 2001-2010 Sacha van Hijum
5 Copyright 2010 Netherlands Bioinformatics Centre
6 This software is co-developed by the Netherlands Bioinformatics Centre
7
8 This file is part of FG Web.
9
10 FG Web is free software: you can redistribute it and/or modify
11 it under the terms of the GNU Affero General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 FG Web is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU Affero General Public License for more details.
19
20 You should have received a copy of the GNU Affero General Public
21 License along with FG Web.  If not, see <http://www.gnu.org/licenses/>.
22*/
23
24/**
25 * This file builds the legacy configuration based on the new Configuration class.
26 * New modules should not use this file, but use the Configuration class
27 */
28require_once 'FGWeb/Logger.php';
29require_once 'FGWeb/Configuration.php';
30require_once 'FGWeb/MenuItem.php';
31
32$LOG = Logger::log_factory();
33
34$config = Configuration::get_instance();
35if ($config->hasErrors()) {
36        printf("<h1 class=\"error\">Configuration error</h1>");
37        $LOG->emerg(sprintf("Validation of the configuration returned the following errors: %s", implode($config->getErrors())));
38        die;
39}
40
41// For backwards compatibility we construct the global variables as used in previous versions
42// These are deprecated, do not extend this for new configuration
43$_SESSION['globals']['site_cpu'] = $config->getValue(Configuration::SECTION_GLOBALS, 'site_cpu', 'Super fast processor');
44
45// Local paths
46$_SESSION['globals']['root_dir'] = realpath(getenv('FGWEB_DIR')).'/';
47$_SESSION['globals']['tmp_dir'] = realpath($config->getValue(Configuration::SECTION_GLOBALS, 'tmp', $_SESSION['globals']['root_dir'].'/work')).'/';
48// These are hardcoded to subdirectories under the main fgweb directory
49$_SESSION['globals']['cgi_root'] = realpath($_SESSION['globals']['root_dir'].'/cgi-bin').'/';
50$_SESSION['globals']['user_dir'] = realpath($_SESSION['globals']['root_dir'].'/users').'/';
51$_SESSION['globals']['db_root'] = realpath($_SESSION['globals']['root_dir'].'/db').'/';
52$_SESSION['globals']['db_dir'] = realpath($_SESSION['globals']['db_root'].'/fgweb').'/';
53$_SESSION['globals']['www_root'] = realpath($_SESSION['globals']['root_dir'].'/html').'/';
54$_SESSION['globals']['www_lib'] = realpath($_SESSION['globals']['www_root'].'/lib').'/';
55
56// Public URLs
57$_SESSION['globals']['www_software'] = $config->getValue(Configuration::SECTION_URL, 'context', '/');
58$_SESSION['globals']['www_software_test'] = $config->getValue(Configuration::SECTION_URL, 'context_test', '/test/');
59
60$root_url = sprintf('http://%s:%s', $_SERVER['SERVER_ADDR'], $_SERVER['SERVER_PORT']);
61$_SESSION['globals']['www_root_url'] = $config->getValue(Configuration::SECTION_URL, 'site', $root_url);
62
63// These are hardcoded to subdirectories under the main fgweb directory
64$_SESSION['globals']['www_work_url'] = $_SESSION['globals']['www_root_url'].'work/';
65$_SESSION['globals']['www_lib_url'] = $_SESSION['globals']['www_root_url'].'lib/';
66$_SESSION['globals']['php_lib_url'] = $_SESSION['globals']['www_lib_url'].'php/';
67$_SESSION['globals']['css_dir'] = realpath($_SESSION['globals']['www_lib'].'css').'/';
68$_SESSION['globals']['javascript_dir'] = realpath($_SESSION['globals']['www_lib'].'javascript').'/';
69$_SESSION['globals']['css_images_dir'] = realpath($_SESSION['globals']['www_lib'].'images').'/';
70$_SESSION['globals']['images_dir'] = realpath($_SESSION['globals']['www_lib'].'images').'/';
71
72// section genbank
73$_SESSION['globals']['gbk_dir'] = realpath($config->getValue(Configuration::SECTION_GENBANK, 'dir', $_SESSION['globals']['root_dir'].'/data/genomes/')).'/';
74$_SESSION['globals']['gbk_dump'] = $config->getValue(Configuration::SECTION_GENBANK, 'dump', $_SESSION['globals']['tmp_dir'].'/php_dump_gbk_');
75$_SESSION['globals']['gbk_species_dump'] = $config->getValue(Configuration::SECTION_GENBANK, 'species_dump', $_SESSION['globals']['tmp_dir'].'/php_dump_gbk_species_');
76$_SESSION['globals']['gbk_dump_maxage'] = $config->getValue(Configuration::SECTION_GENBANK, 'dump_maxage', 24);
77
78// section layout
79$_SESSION['globals']['www_pagetitle'] = $config->getValue(Configuration::SECTION_LAYOUT, 'pagetitle', 'Bioinformatics @ NBIC');
80$_SESSION['globals']['www_meta_default_desc'] = $config->getValue(Configuration::SECTION_LAYOUT, 'meta_description', 'Bacterial Genomics bioinformatics webframework');
81$_SESSION['globals']['www_meta_default_keyw'] = $config->getValue(Configuration::SECTION_LAYOUT, 'meta_keywords', 'bioinformatics, genomics, transcriptomics, gene-regulatory networks, bacterial genomics, NBIC');
82$_SESSION['globals']['persistent_logo'] = $config->getValue(Configuration::SECTION_LAYOUT, 'logo', $_SESSION['globals']['www_lib_url'].'/images/logo_nbic.png');
83$_SESSION['globals']['persistent_logo_link'] = $config->getValue(Configuration::SECTION_LAYOUT, 'logo_link', 'http://www.nbic.nl/');
84$_SESSION['globals']['persistent_logo_alt'] = $config->getValue(Configuration::SECTION_LAYOUT, 'logo_alt', 'NBIC logo');
85
86// sidemenu
87$_SESSION['globals']['sidemenu'][1] = getMenuItem($config, '1', $_SESSION['globals']['www_root_url'], 'FG-web home');
88$_SESSION['globals']['sidemenu'][2] = getMenuItem($config, '2', 'http://www.nbic.nl/', 'NBIC home');
89$_SESSION['globals']['sidemenu']['terms'] = getMenuItem($config, 'terms', $_SESSION['globals']['php_lib_url'].'license.php', 'Terms of use');
90
91// mysql
92$_SESSION['globals']['mysql_db'] = $config->getValue(Configuration::SECTION_DATABASE, 'database', 'fgweb');
93$_SESSION['globals']['mysql_user'] = $config->getValue(Configuration::SECTION_DATABASE, 'user', 'fgweb');
94$_SESSION['globals']['mysql_password'] = $config->getValue(Configuration::SECTION_DATABASE, 'pass');
95
96// system tools
97$_SESSION['globals']['dos2unix_loc'] = realpath($config->getValue(Configuration::SECTION_SYSTOOLS, 'dos2unix_loc', '/usr/bin/dos2unix'));
98$_SESSION['globals']['shell_loc'] = realpath($config->getValue(Configuration::SECTION_SYSTOOLS, 'shell_loc', '/bin/bash'));
99$_SESSION['globals']['touch_loc'] = realpath($config->getValue(Configuration::SECTION_SYSTOOLS, 'touch_loc', '/bin/touch'));
100$_SESSION['globals']['nice_loc'] = realpath($config->getValue(Configuration::SECTION_SYSTOOLS, 'nice_loc', '/bin/nice'));
101$_SESSION['globals']['rm_loc'] = realpath($config->getValue(Configuration::SECTION_SYSTOOLS, 'rm_loc', '/bin/rm'));
102
103$_SESSION['globals']['genomemap_loc'] = realpath($config->getValue(Configuration::SECTION_TOOLS, 'genomemap', $_SESSION['globals']['cgi_root'].'/retrievedb/genomemap.pl'));
104$_SESSION['globals']['checkqueue_loc'] = realpath($config->getValue(Configuration::SECTION_TOOLS, 'checkqueue', $_SESSION['globals']['root_dir'].'/tools/fgweb/checkqueue.pl'));
105$_SESSION['globals']['checkupdate_loc'] =realpath($config->getValue(Configuration::SECTION_TOOLS, 'checkupdate', $_SESSION['globals']['root_dir'].'/tools/fgweb/checkupdate.pl'));
106$_SESSION['globals']['ps2png_loc'] = realpath($config->getValue(Configuration::SECTION_TOOLS, 'ps2png', $_SESSION['globals']['root_dir'].'/tools/ps2png'));
107$_SESSION['globals']['R_loc'] = realpath($config->getValue(Configuration::SECTION_TOOLS, 'R', '/usr/bin/R'));
108
109// module files - hardcoded values
110$_SESSION['globals']['run_file_wrapper'] = 'bg_runit.sh';
111$_SESSION['globals']['settings_file'] = 'settings.sh';
112$_SESSION['globals']['run_file'] = 'runit.sh';
113$_SESSION['globals']['run_output_file'] = 'run_output.txt';
114$_SESSION['globals']['run_output_details_file'] = 'run_output_details.txt';
115$_SESSION['globals']['output_html'] = 'output.html';
116
117// user files - hardcoded values
118$_SESSION['globals']['user_profile'] = 'user_profile.inc';
119$_SESSION['globals']['user_profile_php'] = 'user_profile.inc.php';
120$_SESSION['globals']['user_profile_csv'] = 'parameters.txt';
121
122// update service - hardcoded values
123$_SESSION['globals']['update_whatsnewfile'] = $_SESSION['globals']['tmp_dir'].'whatsnew.txt';
124$_SESSION['globals']['update_versionfile'] = $_SESSION['globals']['tmp_dir'].'version.txt';
125
126// Log the session if asked
127if ($config->getValue(Configuration::SECTION_GLOBALS, 'debug_dump_session', false) == true) {
128        // In a conditional since ob_start() can have side-effects.
129        ob_start();
130        var_dump($_SESSION);
131        $LOG->debug(ob_get_clean());
132}
133?>
Note: See TracBrowser for help on using the browser.