forked from hellovai/online-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
45 lines (41 loc) · 1.35 KB
/
index.php
File metadata and controls
45 lines (41 loc) · 1.35 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
<? include('include.php');
if($PASS) {
$_SERVER['REQUEST_URI_PATH'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$segments = explode('/', $_SERVER['REQUEST_URI_PATH']);
if( sizeof($segments) > 3 ) {
$outDir = $segments[3];
if(file_exists(basePath() . "/data/" . $outDir)){
$fileName = basePath() . "/data/" . $outDir . "/" . $outDir;
if(filesize($fileName . ".prog") > 0) {
$fin = fopen($fileName . ".prog", 'r');
$orig = fread($fin, filesize($fileName . ".prog"));
fclose($fin);
} else {
$orig = "";
}
if(filesize($fileName . ".comp") > 0){
$readFILE = $fileName . ".comp";
}else{
$readFILE = $fileName . ".out";
}
if(filesize($readFILE) < 5*1024 ) {
$fout = fopen($readFILE, 'r');
$out = fread($fout, filesize($readFILE));
fclose($fout);
} else {
$out = "Your output was too large to be displayed";
}
$args = array("lang" => $languages, "data" => $orig, "output" => $out, "location"=>$outDir);
get_page('display', $args);
}else{
$str = "Sorry! This is a broken link! If you had your code here, it may have expired.<br />In order to preserve your code, try talking to me, if you know me, and I'll hook you up.";
get_page('error', array("error"=>$str) );
}
} else {
$args = array("lang" => $languages);
get_page('home', $args);
}
} else {
get_page("site_down");
}
?>