/** * Uninstall webtools * * @param string $path * @return void */ public static function uninstall($path) { $path = rtrim(realpath($path), '/') . '/'; if (PHP_OS == 'WINNT') { $path = str_replace("\\", '/', $path); } if (!is_dir($path . 'public/')) { throw new \Exception('Document root cannot be located'); } TBootstrap::uninstall($path); CodeMirror::uninstall($path); if (is_file($path . 'public/webtools.config.php')) { unlink($path . 'public/webtools.config.php'); } if (is_file($path . 'public/webtools.php')) { unlink($path . 'public/webtools.php'); } }
/** * Installs webtools * */ public static function install($path) { $path = rtrim(realpath($path), '/') . '/'; $tools = realpath(__DIR__ . '/../../../'); if (PHP_OS == 'WINNT') { $path = str_replace("\\", '/', $path); $tools = str_replace("\\", '/', $tools); } if (!is_dir($path . 'public/')) { throw new \Exception('Document root cannot be located'); } TBootstrap::install($path); CodeMirror::install($path); copy($tools . '/webtools.php', $path . 'public/webtools.php'); if (!file_exists($configPath = $path . 'public/webtools.config.php')) { $code = "<?php\ndefine('PTOOLSPATH', '{$tools}');\n/* you can set ADMINIP as IP 192.168.0.1 or SUBNET 192. or 10.0.2. or 86.84.124. */\ndefine('ADMINIP', '192.168.');\n"; file_put_contents($configPath, $code); } }
/** * Uninstall webtools * * @param string $path * @return bool * * @throws \Exception */ public static function uninstall($path) { $path = realpath($path) . DIRECTORY_SEPARATOR; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $path = str_replace("\\", '/', $path); } if (!is_dir($path . 'public/')) { throw new \Exception('Document root cannot be located'); } $bootstrap = new Bootstrap(); $bootstrap->uninstall($path); $codeMirror = new CodeMirror(); $codeMirror->uninstall($path); $jQuery = new JQuery(); $jQuery->uninstall($path); if (is_file($path . 'public/webtools.config.php')) { unlink($path . 'public/webtools.config.php'); } if (is_file($path . 'public/webtools.php')) { unlink($path . 'public/webtools.php'); } return true; }
/** * Installs webtools * */ public static function install($path) { if (!is_dir('public/')) { throw new \Exception("Document root cannot be located"); } TBootstrap::install($path); CodeMirror::install($path); copy($path . 'webtools.php', 'public/webtools.php'); $webToolsConfigPath = "public/webtools.config.php"; if (PHP_OS == "WINNT") { $pToolsPath = str_replace("\\", "/", $path); } else { $pToolsPath = $path; } $code = "<?php\n\ndefine(\"PTOOLSPATH\", \"" . realpath($pToolsPath) . "\");\n\n"; if (!file_exists($webToolsConfigPath)) { file_put_contents($webToolsConfigPath, $code); } }