From 7d85cc2c680866f3fbf1ef016a57a3796ff22829 Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 30 Nov 2025 13:16:48 +0100 Subject: [PATCH 1/9] Update info.xml Changieren Version to 0.2.4 and supports Nextcloud 32 --- appinfo/info.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 0c39953..d09fb3c 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ OCC Web OCC Commands in a web terminal - 0.2.3 + 0.2.4 agpl Adphi OCCWeb @@ -15,7 +15,7 @@ https://github.com/adphi/occweb https://github.com/adphi/occweb/raw/main/appinfo/screenshot.png - + From 974b35b3e594cb2253a2ecd5a50b10de44d0744d Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 11:30:31 +0100 Subject: [PATCH 2/9] Update info.xml Compatbility with Nextcloud 33.x --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index d09fb3c..4a698f2 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -15,7 +15,7 @@ https://github.com/adphi/occweb https://github.com/adphi/occweb/raw/main/appinfo/screenshot.png - + From 703154e091d065d787b72002c817bb671c55fc0a Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 16:32:14 +0100 Subject: [PATCH 3/9] Text is always LTR especially for RTL languages. --- css/style.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/css/style.css b/css/style.css index 6141904..b4fda40 100644 --- a/css/style.css +++ b/css/style.css @@ -773,3 +773,15 @@ terminal .terminal-output > div { .prompt span, .cursor-line span span, .command div span{ color: #009ae3 !important; } + +/* Keep terminal content left-aligned even when Nextcloud runs in RTL mode */ +html[dir="rtl"] #app-content.terminal, +html[dir="rtl"] #app-content .terminal, +html[dir="rtl"] #app-content .terminal-output, +html[dir="rtl"] #app-content .terminal-output > div > div, +html[dir="rtl"] #app-content .cmd, +html[dir="rtl"] #app-content .cmd div, +html[dir="rtl"] #app-content .cmd .prompt { + direction: ltr; + text-align: left; +} From 8438c2bb2a59bea999bfe16a4f1bb273b9b1889e Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 16:36:48 +0100 Subject: [PATCH 4/9] Warning dialogue before a long command is excuted. --- js/index.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/js/index.js b/js/index.js index 4641951..df715dd 100644 --- a/js/index.js +++ b/js/index.js @@ -1,6 +1,42 @@ (function (OC, window, $, undefined) { 'use strict'; $(function() { + var longRunningCommandPatterns = [ + /^files:scan(?:\s|$)/, + /^files:transfer-ownership(?:\s|$)/, + /^encryption:/, + /^fulltextsearch:/, + /^preview:generate-all(?:\s|$)/, + /^versions:cleanup(?:\s|$)/, + /^trashbin:cleanup(?:\s|$)/, + /^db:add-missing-indices(?:\s|$)/, + /^db:add-missing-columns(?:\s|$)/, + /^db:add-missing-primary-keys(?:\s|$)/, + /^maintenance:repair(?:\s|$)/ + ]; + + function isPotentiallyLongRunning(command) { + var normalizedCommand = (command || '').trim().toLowerCase(); + if (!normalizedCommand) { + return false; + } + return longRunningCommandPatterns.some(function(pattern) { + return pattern.test(normalizedCommand); + }); + } + + function confirmLongRunningCommand(command) { + if (!isPotentiallyLongRunning(command)) { + return true; + } + + return window.confirm( + 'Warning: "' + command + '" can take a long time on large instances and may timeout in the browser.\n\n' + + 'Recommendation: Run this command via CLI/SSH for better reliability.\n\n' + + 'Do you want to run it anyway?' + ); + } + function scrollToBottom(){ var html = $('html'); html.scrollTop(html.prop('scrollHeight')); @@ -16,6 +52,10 @@ this.reset(); break; default: + if (!confirmLongRunningCommand(command)) { + term.echo('\nCommand canceled.'); + break; + } var occCommand = { command: command }; From d6127d4a09acc50a44a09f45b52e715797652f16 Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 16:49:42 +0100 Subject: [PATCH 5/9] OCC endpoints are now limited to administrators. --- lib/Controller/OccController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Controller/OccController.php b/lib/Controller/OccController.php index 3ead8c1..7990b63 100644 --- a/lib/Controller/OccController.php +++ b/lib/Controller/OccController.php @@ -49,6 +49,7 @@ public function __construct($AppName, IRequest $request, $userId) /** * @NoCSRFRequired + * @AdminRequired */ public function index() { @@ -73,6 +74,7 @@ private function run($input) /** * @param string $command * @return DataResponse + * @AdminRequired */ public function cmd($command) { @@ -83,6 +85,9 @@ public function cmd($command) return new DataResponse($response); } + /** + * @AdminRequired + */ public function list() { $defs = $this->symphonyApplication->all(); $cmds = array(); @@ -92,4 +97,3 @@ public function list() { return new DataResponse($cmds); } } - From 08d7bc68430e7a5ddc5d00a4bc0ece161e33d30e Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 16:53:04 +0100 Subject: [PATCH 6/9] Only metadata will be logged. Sensible data will be cropped. --- lib/Controller/OccController.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/Controller/OccController.php b/lib/Controller/OccController.php index 7990b63..e84a3fb 100644 --- a/lib/Controller/OccController.php +++ b/lib/Controller/OccController.php @@ -78,10 +78,24 @@ private function run($input) */ public function cmd($command) { - $this->logger->debug($command); - $input = new StringInput($command); + $startedAt = microtime(true); + $rawCommand = trim((string)$command); + $commandName = strtok($rawCommand, ' ') ?: 'unknown'; + + $this->logger->info('occweb command started', [ + 'user' => $this->userId, + 'command' => $commandName, + ]); + + $input = new StringInput($rawCommand); $response = $this->run($input); - $this->logger->debug($response); + + $this->logger->info('occweb command finished', [ + 'user' => $this->userId, + 'command' => $commandName, + 'duration_ms' => (int)round((microtime(true) - $startedAt) * 1000), + ]); + return new DataResponse($response); } From 2c8645ca450eba3b5b5a673a05cd91f290b995b3 Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 16:56:21 +0100 Subject: [PATCH 7/9] Code is now much more robust with updates. --- lib/Controller/OccController.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/Controller/OccController.php b/lib/Controller/OccController.php index e84a3fb..bfae7ef 100644 --- a/lib/Controller/OccController.php +++ b/lib/Controller/OccController.php @@ -20,7 +20,6 @@ class OccController extends Controller private $userId; private $application; - private $symphonyApplication; private $output; public function __construct($AppName, IRequest $request, $userId) @@ -41,10 +40,7 @@ public function __construct($AppName, IRequest $request, $userId) ); $this->application->setAutoExit(false); $this->output = new OccOutput(OutputInterface::VERBOSITY_NORMAL, true); - $this->application->loadCommands(new StringInput(""), $this->output); - $reflectionProperty = new \ReflectionProperty(Application::class, 'application'); - $reflectionProperty->setAccessible(true); - $this->symphonyApplication = $reflectionProperty->getValue($this->application); + $this->application->loadCommands(new StringInput(""), $this->output); } /** @@ -103,11 +99,22 @@ public function cmd($command) * @AdminRequired */ public function list() { - $defs = $this->symphonyApplication->all(); - $cmds = array(); - foreach ($defs as $d) { - array_push($cmds, $d->getName()); + $output = $this->run(new StringInput('list --raw')); + $lines = preg_split('/\r\n|\r|\n/', (string)$output); + $cmds = []; + + foreach ($lines as $line) { + $line = trim($line); + if ($line === '') { + continue; + } + + $parts = preg_split('/\s+/', $line, 2); + if (!empty($parts[0])) { + $cmds[] = $parts[0]; + } } - return new DataResponse($cmds); + + return new DataResponse(array_values(array_unique($cmds))); } } From 72f93ffd3234d36b04c1b3489b3d7e752470c0df Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 17:01:04 +0100 Subject: [PATCH 8/9] Improved error handling. --- lib/Controller/OccOutput.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Controller/OccOutput.php b/lib/Controller/OccOutput.php index 5f0c0d0..74891b2 100644 --- a/lib/Controller/OccOutput.php +++ b/lib/Controller/OccOutput.php @@ -12,6 +12,7 @@ class OccOutput extends BufferedOutput implements ConsoleOutputInterface { private $consoleSectionOutputs = []; + private $errorOutput; private $stream; /** @@ -21,13 +22,16 @@ class OccOutput extends BufferedOutput implements ConsoleOutputInterface */ public function getErrorOutput(): OutputInterface { - // TODO: Implement getErrorOutput() method. - return $this; + if ($this->errorOutput === null) { + // Keep compatibility when no explicit stderr output is configured. + $this->errorOutput = $this; + } + return $this->errorOutput; } public function setErrorOutput(OutputInterface $error) { - + $this->errorOutput = $error; } /** From 7e8309eaed5e4faf2c86cdba9bda99077c1f216f Mon Sep 17 00:00:00 2001 From: Alishara Date: Sun, 15 Mar 2026 17:03:23 +0100 Subject: [PATCH 9/9] Changed version to 0.3.0 --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 4a698f2..45c1f76 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ OCC Web OCC Commands in a web terminal - 0.2.4 + 0.3.0 agpl Adphi OCCWeb