-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_code.php
68 lines (66 loc) · 1.47 KB
/
get_code.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
function sanitizeClassPath($classPath)
{
$matches = explode ('.',$classPath);
foreach($matches as &$match)
{
$match = preg_replace('/[^a-zA-Z0-9_]/','',$match);
}
return implode($matches,'/').'.java';
}
$svn_root = 'http://technobotts.svn.beanstalkapp.com/all/Robocup/';
$urls = array(
'robot' => 'Soccer/trunk/New%20Robot/src/',
'sensors' => 'Utils/trunk/Sensors/src/',
'omni pilots' => 'Utils/trunk/OmniPilots/',
'data manipulation' => 'Utils/trunk/Data%20Manipulation/'
);
$project = isset($_GET['project']) ? $_GET['project'] : 'robot';
$classPath = isset($_GET['class']) ? $_GET['class'] : false;
$format = isset($_GET['pretty']) ? $_GET['pretty'] : false;
?><?php
if(isset($urls[$project]) && $classPath)
{
$url = $svn_root.$urls[$project];
$classPath = sanitizeClassPath($classPath);
$code = @file_get_contents($url.$classPath);
if($code)
{
if($format)
{
require('../geshi.php');
$geshi = new GeSHi($code, 'java');
$geshi->enable_classes();
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
?>
<html>
<head>
<title><?php echo $classPath ?></title>
<link rel="stylesheet" type="text/css" href="/geshi/java.css" />
</head>
<body>
<?php
echo $geshi->parse_code();
?>
</body>
</html>
<?php
}
else
{
header('content-type: text/plain');
echo $code;
}
}
else
{
header('content-type: text/plain');
echo "File Not Found";
}
}
else
{
echo "Not valid arguments";
}
?>