4 * Show source code of a given file.
6 * Copyright 2002 (C) GForge Development Team
7 * Copyright 2010 (c) Franck Villaume
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';
30 if (!forge_get_config('show_source')) {
31 exit_permission_denied('home');
34 $file = getStringFromRequest('file');
37 exit_missing_param('',array(_('A file must be specified for this page.')),'home');
40 if (strstr($file,'..')) {
41 exit_error(_('The file argument is invalid.'),'home');
44 $dir = dirname($file);
46 // If this is a legal dir, then it is under the docroot, else use basename
48 $fname = getStringFromServer('DOCUMENT_ROOT') . $file;
50 $fname = basename($file);
53 if (!file_exists($fname) || @is_dir($fname)) {
54 exit_error(_('Cannot find specified file to display.'),'home');
57 $HTML->header(array('title'=>sprintf(_('Source of %1$s'), $file)));
62 $HTML->footer(array());
66 // c-file-style: "bsd"