fix tabletree

This commit is contained in:
System Administrator 2023-01-30 18:28:45 +03:00
parent e4527ad94e
commit b3f6cfcbd7
2 changed files with 14 additions and 12 deletions

43
src/Process.php Normal file
View file

@ -0,0 +1,43 @@
<?php
namespace ctiso;
if (!function_exists('str_getcsv')) {
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
$fiveMBs = 1024;
$fp = fopen("php://temp/maxmemory:$fiveMBs", 'r+');
if (is_resource($fp)) {
fputs($fp, $input);
rewind($fp);
$data = fgetcsv($fp, 1000, $delimiter, $enclosure);
fclose($fp);
}
return $data;
}
}
function process_exists($pid) {
if (PHP_OS == 'WINNT') {
$processes = explode("\n", shell_exec("tasklist.exe /NH /FO CSV"));
foreach($processes as $process) {
if ($process != "") {
$csv = str_getcsv($process);
if ($pid == $csv[1]) return true;
}
}
return false;
} else {
return file_exists("/proc/$pid");
}
}
function create_single_proces($fpid, $fn) {
if (file_exists($fpid)) {
print_r(realpath($fpid));
if (process_exists(file_get_contents($fpid))) {
return 1;
}
}
call_user_func($fn);
return 0;
}