blob: fc60a613fdc6ae09c0c18cb243bd1ec3ae1e0cb4 (
plain)
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
|
<?PHP
if (isset($_POST) && isset($_POST['token']) &&
$_POST['token'] === 'be688838ca8686e5c90689bf2ab585cef1137c999b48c70b92f67a5c34dc15697b5d11c982ed6d71be1e1e7f7b4e0733884aa97c3f7a339a8ed03577cf74be09';
) {
if (!isset($_POST['arch'])) {
http_response_code(400);
echo "400 Bad Request: Should specify arch field while post files";
die();
}
if (!empty($_FILES['file'])) {
$path = "/var/www/repo/". $_POST['arch'] . "/";
$path = $path . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
echo "The file " . basename( $_FILES['file']['name']) . " has been uploaded";
$sock = stream_socket_client('unix:///run/update-repo-notify.sock', $errno, $errst);
fwrite($sock, $['file']['name']."\r\n");
fclose($sock);
} else {
echo "There was an error uploading the file, please try again!";
}
} else if (isset($_POST['action'])) {
if ($_POST['action'] === 'UPLOADED') {
$sock = stream_socket_client('unix:///run/update-repo-notify.sock', $errno, $errst);
fwrite($sock, "EOF\r\n");
fclose($sock);
echo "200 OK STARTED";
} else if ($_POST['action'] === 'REQUIRE_CLEAN') {
shell_exec("/usr/bin/rm -rf /var/www/repo/". $_POST['arch'] . "*");
shell_exec("/usr/bin/mkdir /var/www/repo/". $_POST['arch']);
echo "200 OK CLEANED";
}
}
} else {
http_response_code(403);
}
?>
|