public static function kill($pid) { $pid = intval($pid); if (!empty($pid)) { Vbs::killProc($pid); } }
public function __construct($args) { global $neardBs, $neardConfig, $neardLang, $neardBins, $neardWinbinder; $neardWinbinder->reset(); $this->wbWindow = $neardWinbinder->createAppWindow($neardLang->getValue(Lang::CHANGE_BROWSER_TITLE), 490, 350, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP); $this->wbLabelExp = $neardWinbinder->createLabel($this->wbWindow, $neardLang->getValue(Lang::CHANGE_BROWSER_EXP_LABEL), 15, 15, 470, 50); $currentBrowser = $neardConfig->getBrowser(); $this->wbRadioButton[] = $neardWinbinder->createRadioButton($this->wbWindow, $currentBrowser, true, 15, 40, 470, 20, true); $yPos = 70; $installedBrowsers = Vbs::getInstalledBrowsers(); foreach ($installedBrowsers as $installedBrowser) { if ($installedBrowser != $currentBrowser) { $this->wbRadioButton[] = $neardWinbinder->createRadioButton($this->wbWindow, $installedBrowser, false, 15, $yPos, 470, 20); $yPos += 30; } } $this->wbRadioButtonOther = $neardWinbinder->createRadioButton($this->wbWindow, $neardLang->getValue(Lang::CHANGE_BROWSER_OTHER_LABEL), false, 15, $yPos, 470, 15); $this->wbInputBrowse = $neardWinbinder->createInputText($this->wbWindow, null, 30, $yPos + 30, 190, null, 20, WBC_READONLY); $this->wbBtnBrowse = $neardWinbinder->createButton($this->wbWindow, $neardLang->getValue(Lang::BUTTON_BROWSE), 225, $yPos + 25, 110); $neardWinbinder->setEnabled($this->wbBtnBrowse[WinBinder::CTRL_OBJ], false); $this->wbProgressBar = $neardWinbinder->createProgressBar($this->wbWindow, self::GAUGE_SAVE, 15, 287, 275); $this->wbBtnSave = $neardWinbinder->createButton($this->wbWindow, $neardLang->getValue(Lang::BUTTON_SAVE), 300, 282); $this->wbBtnCancel = $neardWinbinder->createButton($this->wbWindow, $neardLang->getValue(Lang::BUTTON_CANCEL), 387, 282); $neardWinbinder->setEnabled($this->wbBtnSave[WinBinder::CTRL_OBJ], empty($currentBrowser) ? false : true); $neardWinbinder->setHandler($this->wbWindow, $this, 'processWindow'); $neardWinbinder->mainLoop(); $neardWinbinder->reset(); }
public function __construct($args) { global $neardBs, $neardCore, $neardConfig, $neardBins, $neardTools, $neardApps, $neardHomepage; if (file_exists($neardCore->getExec())) { return; } // Start loading Util::startLoading(); // Refresh hostname $neardConfig->replace(Config::CFG_HOSTNAME, gethostname()); // Refresh launch startup $neardConfig->replace(Config::CFG_LAUNCH_STARTUP, Util::isLaunchStartup() ? Config::ENABLED : Config::DISABLED); // Check browser $currentBrowser = $neardConfig->getBrowser(); if (empty($currentBrowser) || !file_exists($currentBrowser)) { $neardConfig->replace(Config::CFG_BROWSER, Vbs::getDefaultBrowser()); } // Rebuild hosts file Util::refactorWindowsHosts(); // Process neard.ini file_put_contents($neardBs->getIniFilePath(), Util::utf8ToCp1252(TplApp::process())); // Process Console config TplConsole::process(); // Process Sublimetext config TplSublimetext::process(); // Process Websvn config TplWebsvn::process(); // Process Gitlist config TplGitlist::process(); // Refresh PEAR version cache file $neardBins->getPhp()->getPearVersion(); // Rebuild alias homepage $neardHomepage->refreshAliasContent(); }
private function setValue($key, $subkey, $entry, $value, $type) { global $neardCore, $neardLang; $basename = 'registrySetValue'; $resultFile = Vbs::getResultFile($basename); $this->latestError = null; $strKey = $key; if ($key == self::HKEY_CLASSES_ROOT) { $key = '&H80000000'; } elseif ($key == self::HKEY_CURRENT_USER) { $key = '&H80000001'; } elseif ($key == self::HKEY_LOCAL_MACHINE) { $key = '&H80000002'; } elseif ($key == self::HKEY_LOCAL_MACHINE) { $key = '&H80000003'; } $scriptContent = 'On Error Resume Next' . PHP_EOL; $scriptContent .= 'Err.Clear' . PHP_EOL . PHP_EOL; $scriptContent .= 'Const HKEY = ' . $key . PHP_EOL . PHP_EOL; $scriptContent .= 'Dim objShell, objRegistry, objFso, objFile, outFile, entryValue, newValue' . PHP_EOL . PHP_EOL; $scriptContent .= 'newValue = "' . (!empty($value) ? str_replace('"', '""', $value) : '') . '"' . PHP_EOL; $scriptContent .= 'outFile = "' . $resultFile . '"' . PHP_EOL; $scriptContent .= 'Set objShell = WScript.CreateObject("WScript.Shell")' . PHP_EOL; $scriptContent .= 'Set objRegistry = GetObject("winmgmts://./root/default:StdRegProv")' . PHP_EOL; $scriptContent .= 'Set objFso = CreateObject("Scripting.FileSystemObject")' . PHP_EOL; $scriptContent .= 'Set objFile = objFso.CreateTextFile(outFile, True)' . PHP_EOL . PHP_EOL; if (!empty($value)) { $scriptContent .= 'objRegistry.' . $type . ' HKEY, "' . $subkey . '", "' . $entry . '", newValue' . PHP_EOL; } elseif (!empty($entry)) { $scriptContent .= 'objRegistry.' . $type . ' HKEY, "' . $subkey . '", "' . $entry . '"' . PHP_EOL; } else { $scriptContent .= 'objRegistry.' . $type . ' HKEY, "' . $subkey . '"' . PHP_EOL; } $scriptContent .= 'If Err.Number <> 0 Then' . PHP_EOL; $scriptContent .= ' objFile.Write "' . self::REG_ERROR_ENTRY . '" & Err.Number & ": " & Err.Description' . PHP_EOL; $scriptContent .= 'Else' . PHP_EOL; if (!empty($value)) { $scriptContent .= ' entryValue = objShell.RegRead("' . $strKey . '\\' . $subkey . '\\' . $entry . '")' . PHP_EOL; $scriptContent .= ' If entryValue = newValue Then' . PHP_EOL; $scriptContent .= ' objFile.Write "' . self::REG_NO_ERROR . '"' . PHP_EOL; $scriptContent .= ' Else' . PHP_EOL; $scriptContent .= ' objFile.Write "' . self::REG_ERROR_SET . '" & newValue' . PHP_EOL; $scriptContent .= ' End If' . PHP_EOL; } else { $scriptContent .= ' objFile.Write "' . self::REG_NO_ERROR . '"' . PHP_EOL; } $scriptContent .= 'End If' . PHP_EOL; $scriptContent .= 'objFile.Close' . PHP_EOL; $result = Vbs::exec($basename, $resultFile, $scriptContent); $result = isset($result[0]) ? $result[0] : null; if ($subkey == self::ENV_KEY) { Batch::refreshEnvVars(); } $this->writeLog('SetValue ' . $strKey . '\\' . $subkey . '\\' . $entry); $this->writeLog('-> value: ' . $value); $this->writeLog('-> result: ' . $result); if (Util::startWith($result, self::REG_ERROR_SET)) { $this->latestError = sprintf($neardLang->getValue(Lang::REGISTRY_SET_ERROR_TEXT), str_replace(self::REG_ERROR_SET, '', $result)); return false; } elseif (Util::startWith($result, self::REG_ERROR_ENTRY)) { $this->latestError = $neardLang->getValue(Lang::ERROR) . ' ' . str_replace(self::REG_ERROR_ENTRY, '', $result); return false; } return $result == self::REG_NO_ERROR; }
public function findRepos($cache = true) { $result = array(); if ($cache) { if (file_exists($this->reposCacheFile)) { $repos = file($this->reposCacheFile); foreach ($repos as $repo) { array_push($result, trim($repo)); } } } else { if (!empty($this->repos)) { foreach ($this->repos as $repo) { $foundRepos = Vbs::findReposVbs($repo, '.svn', 'entries'); if (!empty($foundRepos)) { foreach ($foundRepos as $foundRepo) { array_push($result, $foundRepo); } } } } $strResult = implode(PHP_EOL, $result); file_put_contents($this->reposCacheFile, $strResult); } return $result; }
public static function enableLaunchStartup() { return Vbs::createShortcut(self::getStartupLnkPath()); }
private function checkBrowser() { global $neardConfig, $neardLang; $this->splash->setTextLoading($neardLang->getValue(Lang::STARTUP_CHECK_BROWSER_TEXT)); $this->splash->incrProgressBar(); $this->writeLog('Check browser'); $currentBrowser = $neardConfig->getBrowser(); if (empty($currentBrowser) || !file_exists($currentBrowser)) { $neardConfig->replace(Config::CFG_BROWSER, Vbs::getDefaultBrowser()); } }