Repository navigation
Expand file tree
/
Copy pathsave.php
More file actions
64 lines (52 loc) · 1.69 KB
/
Copy pathsave.php
File metadata and controls
64 lines (52 loc) · 1.69 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
require_once("auth.php");
?>
<?php
if(isset($_POST['file_name'])) {
$file=$_POST['file_name'];
$field = $_POST['field'];
$nodeName = $_POST['node_name'];
$result = file_put_contents($file, $_POST['data']);
// if ( $result ) echo 'Commited';
// Use taskd instead of sending directly
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "r")
);
$myCMD = "env NOCOLOR=1 /usr/local/bin/sudo /usr/local/bin/cbsd task owner=cbsdweb mode=new /usr/local/bin/cbsd nodescp norsync=1 $file $nodeName:node.$field";
$process = proc_open($myCMD, $descriptorspec, $pipes, null, null);
if (is_resource($process)) {
while (($buffer = fgets($pipes[1], 4096)) !== false) {
//nop
}
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
$return_value = proc_close($process);
if ($return_value!=0) {
echo "cbsd nodescp error";
exit($return_value);
}
// echo "exit code: $return_value\n";
}
$myCMD = "env NOCOLOR=1 /usr/local/bin/sudo /usr/local/bin/cbsd task owner=cbsdweb mode=new /usr/local/bin/cbsd retrinv node=$nodeName";
$process = proc_open($myCMD, $descriptorspec, $pipes, null, null);
if (is_resource($process)) {
while (($buffer = fgets($pipes[1], 4096)) !== false) {
//nop
}
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
$return_value = proc_close($process);
if ($return_value!=0) {
echo "cbsd retrinv error";
exit($return_value);
}
//location.reload();
echo "exit code: $return_value\n";
die;
}
}
?>