Merge branch 'master' of github.com:openvk/openvk

This commit is contained in:
veselcraft 2022-03-21 17:16:11 +03:00
commit 6f2bed678d
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
7 changed files with 62 additions and 11 deletions

View file

@ -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) {

View file

@ -29,7 +29,7 @@ class Notes
function getUserNotes(User $user, int $page = 1, ?int $perPage = NULL): \Traversable
{
$perPage = $perPage ?? OPENVK_DEFAULT_PER_PAGE;
foreach($this->notes->where("owner", $user->getId())->where("deleted", 0)->page($page, $perPage) as $album)
foreach($this->notes->where("owner", $user->getId())->where("deleted", 0)->order("created DESC")->page($page, $perPage) as $album)
yield new Note($album);
}

View file

@ -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

View file

@ -98,8 +98,8 @@
<div class="layout">
<div id="xhead" class="dm"></div>
<div class="page_header {if $instance_name != OPENVK_DEFAULT_INSTANCE_NAME}page_custom_header{/if}">
<a href="/" class="home_button {if $instance_name != OPENVK_DEFAULT_INSTANCE_NAME}home_button_custom{/if}" title="{$instance_name}">{$instance_name}</a>
<div class="page_header{if $instance_name != OPENVK_DEFAULT_INSTANCE_NAME} page_custom_header{/if}">
<a href="/" class="home_button{if $instance_name != OPENVK_DEFAULT_INSTANCE_NAME} home_button_custom{/if}" title="{$instance_name}">{if $instance_name != OPENVK_DEFAULT_INSTANCE_NAME}{$instance_name}{/if}</a>
<div n:if="isset($thisUser) ? (!$thisUser->isBanned() XOR !$thisUser->isActivated()) : true" class="header_navigation">
{ifset $thisUser}
<div class="link">

View file

@ -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;
}

View file

@ -68,7 +68,6 @@ p {
.home_button {
position: absolute;
width: 145px;
text-indent: -999px;
height: 42px;
}

View file

@ -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";