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
12 require_once('env.inc.php');
13 require_once $gfwww.'include/pre.php';
15 global $sys_show_source;
16 if (!$sys_show_source) {
17 exit_permission_denied();
20 $file = getStringFromRequest('file');
23 exit_error(_('Missing File Argument'), _('A file must be specified for this page.'));
26 if (strstr($file,'..')) {
27 exit_error(_('Invalid File Argument'), _('The file argument is invalid.'));
30 $dir = dirname($file);
32 // If this is a legal dir, then it is under the docroot, else use basename
34 $fname = getStringFromServer('DOCUMENT_ROOT') . $file;
36 $fname = basename($file);
39 if (!file_exists($fname) || @is_dir($fname)) {
40 exit_error(_('File Not Found'), _('Cannot find specified file to display.'));
43 $HTML->header(array('title'=>sprintf(_('Source of %1$s'), $file)));
48 $HTML->footer(array());
52 // c-file-style: "bsd"