File: source.php

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (48 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
 *
 * Show source code of a given file.
 *
 * Given a file, show the source code for that file.
 *
 * Copyright 2002 (C) GForge Development Team
 *
 * @version   $Id: source.php 1608 2003-01-25 22:19:15Z rspisser $
 *
 */

require_once('pre.php');

global $sys_show_source;
if (!$sys_show_source) {
	exit_permission_denied();
}

if (!$file) {
	exit_error($Language->getText('source','missing_file'), $Language->getText('source','missing_file_text'));
}

if (strstr($file,'..')) {
	exit_error($Language->getText('source','invalid_argument'), $Language->getText('source','invalid_argument_text'));
}

$dir = dirname($file);

// If this is a legal dir, then it is under the docroot, else use basename
if ($dir) {
	$fname = $DOCUMENT_ROOT . $file;
} else {
	$fname = basename($file);
}

if (!file_exists($fname) || @is_dir($fname)) {
	exit_error($Language->getText('source','file_not_found'), $Language->getText('source','file_not_found_text'));
}

$HTML->header(array('title'=>$Language->getText('source','source_of',$file),'pagename'=>'viewsource'));

show_source($fname);


$HTML->footer(array());
?>