4 * Show source code of a given file.
6 * Given a file, show the source code for that file.
8 * Copyright 2002 (C) GForge Development Team
14 require_once('env.inc.php');
15 require_once $gfwww.'include/pre.php';
17 global $sys_show_source;
18 if (!$sys_show_source) {
19 exit_permission_denied();
22 $file = getStringFromRequest('file');
25 exit_error(_('Missing File Argument'), _('A file must be specified for this page.'));
28 if (strstr($file,'..')) {
29 exit_error(_('Invalid File Argument'), _('The file argument is invalid.'));
32 $dir = dirname($file);
34 // If this is a legal dir, then it is under the docroot, else use basename
36 $fname = getStringFromServer('DOCUMENT_ROOT') . $file;
38 $fname = basename($file);
41 if (!file_exists($fname) || @is_dir($fname)) {
42 exit_error(_('File Not Found'), _('Cannot find specified file to display.'));
45 $HTML->header(array('title'=>sprintf(_('Source of %1$s'), $file)));
50 $HTML->footer(array());
54 // c-file-style: "bsd"