Частичная синхронизация с CMS
This commit is contained in:
parent
312f18a20a
commit
b26e521657
62 changed files with 827 additions and 5992 deletions
41
src/process.php
Normal file
41
src/process.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue