61 $result =
self::exec(
'findExeByPid',
'TASKLIST /FO CSV /NH /FI "PID eq ' . $pid .
'"', 5);
63 $expResult = explode(
'","',
$result[0]);
64 if (is_array($expResult) && count($expResult) > 2 && isset($expResult[0]) && !empty($expResult[0])) {
65 return substr($expResult[0], 1);
86 $rowExp = explode(
' ', preg_replace(
'/\s+/',
' ', $row));
87 if (count($rowExp) == 5 &&
Util::endWith($rowExp[1],
':' .
$port) && $rowExp[3] ==
'LISTENING') {
88 $pid = intval($rowExp[4]);
91 return $exe .
' (' . $pid .
')';
106 public static function exitApp($restart =
false)
110 $content =
'PING 1.1.1.1 -n 1 -w 2000 > nul' . PHP_EOL;
111 $content .=
'"' .
$bearsamppRoot->getExeFilePath() .
'" -quit -id={bearsampp}' . PHP_EOL;
113 $basename =
'restartApp';
117 $basename =
'exitApp';
146 $expResult = explode(
' ', $row);
147 if (count($expResult) == 3) {
148 return trim($expResult[2]);
177 if (!
$bearsamppBins->getFilezilla()->getService()->isInstalled()) {
195 self::exec(
'uninstallFilezillaService',
'"' .
$bearsamppBins->getFilezilla()->getExe() .
'" /uninstall',
true,
false);
196 return !
$bearsamppBins->getFilezilla()->getService()->isInstalled();
206 if (!file_exists($path .
'/init.bat')) {
210 self::exec(
'initializeMysql',
'CMD /C "' . $path .
'/init.bat"', 60);
225 self::exec(
'installPostgresqlService', $cmd,
true,
false);
227 if (!
$bearsamppBins->getPostgresql()->getService()->isInstalled()) {
249 self::exec(
'uninstallPostgresqlService', $cmd,
true,
false);
250 return !
$bearsamppBins->getPostgresql()->getService()->isInstalled();
260 if (!file_exists($path .
'/init.bat')) {
264 self::exec(
'initializePostgresql',
'CMD /C "' . $path .
'/init.bat"', 15);
278 self::exec(
'createSymlink',
'"' .
$bearsamppCore->getLnExe() .
'" --absolute --symbolic --traditional --1023safe "' . $src .
'" ' .
'"' . $dest .
'"',
true,
false);
317 $cmd =
'sc config ' . $serviceName .
' DisplayName= "' . $displayName .
'"';
318 self::exec(
'setServiceDisplayName', $cmd,
true,
false);
329 $cmd =
'sc description ' . $serviceName .
' "' . $desc .
'"';
330 self::exec(
'setServiceDescription', $cmd,
true,
false);
341 $cmd =
'sc config ' . $serviceName .
' start= ' . $startType;
342 self::exec(
'setServiceStartType', $cmd,
true,
false);
355 return self::exec($basename, $content,
false,
false,
true, $silent);
370 public static function exec($basename, $content, $timeout =
true, $catchOutput =
true, $standalone =
false, $silent =
true, $rebuild =
true)
381 $content .=
'> "' . $resultFile .
'"' . (!
Util::endWith($content,
'2') ?
' 2>&1' :
'');
385 $header =
'@ECHO OFF' . PHP_EOL . PHP_EOL;
388 $footer = PHP_EOL . (!$standalone ? PHP_EOL .
'ECHO ' . self::END_PROCESS_STR .
' > "' . $checkFile .
'"' :
'');
391 file_put_contents($scriptPath, $header . $content . $footer);
392 $bearsamppWinbinder->exec($scriptPath,
null, $silent);
395 $timeout = is_numeric($timeout) ? $timeout : ($timeout ===
true ?
$bearsamppConfig->getScriptsTimeout() :
false);
396 $maxtime = time() + $timeout;
397 $noTimeout = $timeout ===
false;
399 if (file_exists($checkFile)) {
400 $check = file($checkFile);
401 if (!empty($check) && trim($check[0]) == self::END_PROCESS_STR) {
402 if ($catchOutput && file_exists($resultFile)) {
409 if ($maxtime < time() && !$noTimeout) {
417 self::writeLog(
'-> content: ' . str_replace(PHP_EOL,
' \\\\ ', $content));
424 $rebuildResult = array();
428 $rebuildResult[] = $row;
static findExeByPid($pid)
static exec($basename, $content, $timeout=true, $catchOutput=true, $standalone=false, $silent=true, $rebuild=true)
static execStandalone($basename, $content, $silent=true)
static setServiceDisplayName($serviceName, $displayName)
static removeSymlink($link)
static createSymlink($src, $dest)
static exitApp($restart=false)
static installPostgresqlService()
static uninstallFilezillaService()
static initializePostgresql($path)
static initializeMysql($path)
static uninstallPostgresqlService()
static setServiceDescription($serviceName, $desc)
static setServiceStartType($serviceName, $startType)
static getTmpFile($ext, $customName=null)
static getProcessUsingPort($port)
static installFilezillaService()
static startWith($string, $search)
static endWith($string, $search)
static random($length=32, $withNumeric=true)
static logDebug($data, $file=null)
static logInfo($data, $file=null)
static logWarning($data, $file=null)
static formatWindowsPath($path)
static killBins($refreshProcs=false)