-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcompile.php
55 lines (46 loc) · 2.29 KB
/
compile.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
<?php
if (!isset($_GET['id']))
die ("Illegal attempt to access compiler");
else if (!is_numeric($_GET['id']))
die ("Invalid File ID");
require_once("functions.php");
$id = $_GET['id'];
$compile = $sql->fetch("compile", $id);
$version = $sql->fetch($compile['Program']."versions", $compile['VerID']);
if ($compile === FALSE OR $compile === NULL)
die ("File ID not found");
if ($compile['Program'] == 'amxx')
{
if (count($version) == 7)
$folder = $version['Folder'];
else
$folder = ".";
@mkdir($general['compiled']."/$id");
$files = scandir($general['temp']."/$id/");
foreach ($files as $file)
if ($file != "." && $file != ".." && pathinfo($file, PATHINFO_EXTENSION) == "sma")
{
touch($general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt");
file_put_contents($general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt", "Compiling ".$file."\n", FILE_APPEND);
exec("cd ".$general['amxxcomp']."/$folder; ./amxxpc \"".$general['temp']."/$id/$file\" -o".$general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".amxx"." >> ".$general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt");
file_put_contents($general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt", "\n", FILE_APPEND);
}
}
else if ($compile['Program'] == 'sm')
{
if (count($version) == 7)
$folder = $version['Folder'];
else
$folder = ".";
@mkdir($general['compiled']."/$id");
$files = scandir($general['temp']."/$id/");
foreach ($files as $file)
if ($file != "." && $file != ".." && pathinfo($file, PATHINFO_EXTENSION) == "sp")
{
touch($general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt");
file_put_contents($general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt", "Compiling ".$file."\n", FILE_APPEND);
exec("cd ".$general['smcomp']."/$folder; ./spcomp \"".$general['temp']."/$id/$file\" -o".$general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".smx"." >> ".$general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt");
file_put_contents($general['compiled']."/$id/".pathinfo($file, PATHINFO_FILENAME).".txt", "\n", FILE_APPEND);
}
}
?>