-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrender.php
More file actions
44 lines (38 loc) · 1.19 KB
/
render.php
File metadata and controls
44 lines (38 loc) · 1.19 KB
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
<?php
require_once 'includes/config.php';
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
$projectname = 'projects' . DIRECTORY_SEPARATOR . $session['user']['projectfolder'];
$filename = $projectname . $_POST['file'];
if (strstr($filename, '..') !== false) {
die('Sorry, you have tried to write to an invalid filename: ' . $filename);
}
$fp = fopen($filename, 'w');
fwrite($fp, $_POST['code']);
fclose($fp);
$explodedfile = explode('/', $_POST['file']);
$exercisedirectory = "$projectname/$explodedfile[1]/";
switch ($_POST['action']) {
case 'Run This File':
header('Location: ' . $projectname . $_POST['file']);
break;
case 'Run Index File':
header('Location: ' . $exercisedirectory);
break;
default:
// do nothing
break;
}