From f4d8908d8067f138421a166d3ebb774dd64e3d73 Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko <50026114+maksalees@users.noreply.github.com> Date: Sun, 20 Mar 2022 00:00:52 +0200 Subject: [PATCH 1/5] L10n (English): Remove extra screening Closes #503 --- locales/en.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en.strings b/locales/en.strings index bb9d16cb..63fa33a1 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -773,7 +773,7 @@ "error_repost_fail" = "Failed to share post"; "forbidden" = "Access error"; -"forbidden_comment" = "This user\'s privacy settings do not allow you to look at his page."; +"forbidden_comment" = "This user's privacy settings do not allow you to look at his page."; "changes_saved" = "Changes saved"; "changes_saved_comment" = "New data will appear on your page"; From 02cf4358687b6c435a7eb1c3019a991bff9f04cb Mon Sep 17 00:00:00 2001 From: Celestora Date: Sun, 20 Mar 2022 17:37:52 +0200 Subject: [PATCH 2/5] Allow Shell to be used on WinNT --- Web/Util/Shell/Shell.php | 43 +++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/Web/Util/Shell/Shell.php b/Web/Util/Shell/Shell.php index 2bf1e214..d3f58165 100644 --- a/Web/Util/Shell/Shell.php +++ b/Web/Util/Shell/Shell.php @@ -11,17 +11,39 @@ class Shell $functions = array_map(function($x) { return trim($x); }, explode(" ", ini_get("disable_functions"))); - return !in_array("system", $functions); + if(in_array("system", $functions)) + return FALSE; + + if(Shell::isPowershell()) { + exec("WHERE powershell", $_x, $_c); + unset($_x); + + return $_c === 0; + } + + return TRUE; + } + + static function isPowershell(): bool + { + return strncasecmp(PHP_OS, 'WIN', 3) === 0; } static function commandAvailable(string $name): bool { if(!Shell::shellAvailable()) throw new Exceptions\ShellUnavailableException; - + + if(Shell::isPowershell()) { + exec("WHERE $name", $_x, $_c); + unset($_x); + + return $_c === 0; + } + return !is_null(`command -v $name`); } - + static function __callStatic(string $name, array $arguments): object { if(!Shell::commandAvailable($name)) @@ -41,14 +63,25 @@ class Shell function execute(?int &$result = nullptr): string { $stdout = []; - exec($this->command, $stdout, $result); + + if(Shell::isPowershell()) { + $cmd = escapeshellarg($this->command); + exec("powershell -Command $this->command", $stdout, $result); + } else { + exec($this->command, $stdout, $result); + } return implode(PHP_EOL, $stdout); } function start(): string { - system("nohup " . $this->command . " > /dev/null 2>/dev/null &"); + if(Shell::isPowershell()) { + $cmd = escapeshellarg($this->command); + pclose(popen("start /b powershell -Command $this->command", "r")); + } else { + system("nohup " . $this->command . " > /dev/null 2>/dev/null &"); + } return $this->command; } From 71c744c41f088b9497a71773677e3558ec82fe2e Mon Sep 17 00:00:00 2001 From: Celestora Date: Sun, 20 Mar 2022 18:01:48 +0200 Subject: [PATCH 3/5] Add video uploading support for Windows Untested, but should mark as resoved #506 --- Web/Models/Entities/Video.php | 4 +++- Web/Models/shell/processVideo.ps1 | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Web/Models/shell/processVideo.ps1 diff --git a/Web/Models/Entities/Video.php b/Web/Models/Entities/Video.php index 17500e8d..f57159b7 100644 --- a/Web/Models/Entities/Video.php +++ b/Web/Models/Entities/Video.php @@ -41,7 +41,9 @@ class Video extends Media mkdir($dirId); $dir = $this->getBaseDir(); - Shell::bash(__DIR__ . "/../shell/processVideo.sh", OPENVK_ROOT, $filename, $dir, $hash)->start(); #async :DDD + $ext = Shell::isPowershell() ? "ps1" : "sh"; + $cmd = Shell::isPowershell() ? "powershell" : "bash"; + Shell::$cmd(__DIR__ . "/../shell/processVideo.$ext", OPENVK_ROOT, $filename, $dir, $hash)->start(); #async :DDD } catch(ShellUnavailableException $suex) { exit(OPENVK_ROOT_CONF["openvk"]["debug"] ? "Shell is unavailable" : VIDEOS_FRIENDLY_ERROR); } catch(UnknownCommandException $ucex) { diff --git a/Web/Models/shell/processVideo.ps1 b/Web/Models/shell/processVideo.ps1 new file mode 100644 index 00000000..8e87442e --- /dev/null +++ b/Web/Models/shell/processVideo.ps1 @@ -0,0 +1,17 @@ +$ovkRoot = $args[0] +$file = $args[1] +$dir = $args[2] +$hash = $args[3] +$hashT = $hash.substring(0, 2) +$temp = [System.IO.Path]::GetTempFileName() +$temp2 = [System.IO.Path]::GetTempFileName() + +Move-Item $file $temp + +# video stub logic was implicitly deprecated, so we start processing at once +ffmpeg -i $temp -ss 00:00:01.000 -vframes 1 "$dir$hashT/$hash.gif" +start /B /Low /Wait /Shared ffmpeg -i $temp -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 -vf scale=640x360,setsar=1:1 -y $temp2 + +Move-Item $temp2 "$dir$hashT/$hash.ogv" +Remove-Item $temp +Remove-Item $temp2 \ No newline at end of file From 88cbde660b53f3498f1d2be38df53dc9b520dffc Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Mon, 21 Mar 2022 16:00:01 +0300 Subject: [PATCH 4/5] Show only the custom instance name in the header It was funny to see the text "OpenVK" floating on the blank space in some of the screenshots of users. :^) --- Web/Presenters/templates/@layout.xml | 4 ++-- Web/static/css/style.css | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index ef2ccfdb..84fade03 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -98,8 +98,8 @@
-