kritbit

kritbit Commit Details


Date:2015-12-13 15:40:51 (9 years 8 days ago)
Author:Natalie Adams
Branch:master
Commit:0a8c8b6bd29127a28efaf1d5cc6cab8926c69abd
Parents: 19eced1537286fbe6b029dadeb285c3912bf73be
Message:Removing directory when script is invoked

Changes:

File differences

web/application/controllers/service.php
5858
5959
6060
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
6177
6278
6379
......
7288
7389
7490
91
92
93
94
95
96
97
98
7599
76100
77101
78
79
102
103
80104
81
82
83
105
106
107
84108
85109
86110
87111
88112
89113
90
91
114
115
92116
93
94
95
117
118
119
96120
97121
98122
}
}
// http://us3.php.net/manual/en/function.rmdir.php#117354
private function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir."/".$object))
rrmdir($dir."/".$object);
else
unlink($dir."/".$object);
}
}
rmdir($dir);
}
}
public function run() {
if (in_array($_SERVER["REMOTE_ADDR"], $this->config["ACCEPTED_IPS"])) { // not very secure - but worst case they fire off the run early
if (!file_exists("/tmp/kritbot")) {
$output = [];
$returnVar = 0;
$jobName = (isset($job->jobName) && !empty($job->jobName) && $job->jobName) ? $job->jobName : "----NOT-SET----";
$dir = __DIR__ . "/../tmp/" . $jobName;
if (is_dir($dir)) {
$this->rrmdir($dir . "/");
} else {
mkdir($dir, 0777, true);
}
$start = microtime(true);
// grumble grumble something something windows
if (stripos(php_uname("s"), "Win") !== false) {
file_put_contents("/tmp/kritscript.bat", $job->runScript);
exec("c:\\windows\\system32\\cmd.exe /c c:/tmp/kritscript.bat", $output, $returnVar);
file_put_contents("$dir/kritscript.bat", $job->runScript);
exec("c:\\windows\\system32\\cmd.exe /c $dir/kritscript.bat", $output, $returnVar);
} else {
file_put_contents("/tmp/kritscript", $job->runScript);
exec("/tmp/kritscript", $output, $returnVar);
chmod("/tmp/kritscript", 0777);
file_put_contents("$dir/kritscript", $job->runScript);
chmod("$dir/kritscript", 0777);
exec("$dir/kritscript", $output, $returnVar);
}
$end = microtime(true);
$delta = $end - $start;
$scriptOutput = implode("\n", $output);
if ($returnVar != 0) {
if (stripos(php_uname("s"), "Win") !== false) {
file_put_contents("/tmp/kritscript.bat", $job->failScript);
exec("c:\\windows\\system32\\cmd.exe /c c:/tmp/kirtscript.bat");
file_put_contents("$dir/failkritscript.bat", $job->failScript);
exec("c:\\windows\\system32\\cmd.exe /c $dir/failkirtscript.bat");
} else {
file_put_contents("/tmp/kritscript", $job->failScript);
exec("/tmp/kritscript", $output, $returnVar);
chmod("/tmp/kritscript", 0777);
file_put_contents("$dir/failkritscript", $job->failScript);
chmod("$dir/failkritscript", 0777);
exec("$dir/failkritscript", $output, $returnVar);
}
}
$historyObj = new \application\models\Histories();

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.07053s using 14 queries.