mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Merge branch 'master' of github.com:openvk/openvk
This commit is contained in:
commit
6f2bed678d
7 changed files with 62 additions and 11 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
17
Web/Models/shell/processVideo.ps1
Normal file
17
Web/Models/shell/processVideo.ps1
Normal 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
|
|
@ -99,7 +99,7 @@
|
|||
<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>
|
||||
<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">
|
||||
|
|
|
@ -11,7 +11,22 @@ 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
|
||||
|
@ -19,6 +34,13 @@ class Shell
|
|||
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`);
|
||||
}
|
||||
|
||||
|
@ -41,14 +63,25 @@ class Shell
|
|||
function execute(?int &$result = nullptr): string
|
||||
{
|
||||
$stdout = [];
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ p {
|
|||
.home_button {
|
||||
position: absolute;
|
||||
width: 145px;
|
||||
text-indent: -999px;
|
||||
height: 42px;
|
||||
}
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue