Skip to content

Commit 05237b4

Browse files
danieldaniel
authored andcommitted
https://github.com/WWBN/AVideo/issues/8576
1 parent 3199cb1 commit 05237b4

File tree

6 files changed

+72
-87
lines changed

6 files changed

+72
-87
lines changed

objects/functions.php

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
stream_context_set_default([
43
'ssl' => [
54
'verify_peer' => false,
@@ -405,10 +404,10 @@ function status($statusarray) {
405404
}
406405
} else {
407406
echo json_encode(array_map(
408-
function ($text) {
409-
return nl2br($text);
410-
},
411-
$statusarray
407+
function ($text) {
408+
return nl2br($text);
409+
},
410+
$statusarray
412411
));
413412
}
414413
}
@@ -447,26 +446,25 @@ function parseSecondsToDuration($seconds) {
447446
return secondsToVideoTime($seconds);
448447
}
449448

450-
451449
function decideFromPlugin() {
452450
$advancedCustom = getAdvancedCustomizedObjectData();
453451
if (!empty($advancedCustom->showOnlyEncoderAutomaticResolutions)) {
454452
return array("mp4" => 7, "webm" => 8);
455453
}
456454
if (
457-
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
455+
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
458456
return array("mp4" => 80, "webm" => 87);
459457
}
460458
if (
461-
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD)) {
459+
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionSD)) {
462460
return array("mp4" => 77, "webm" => 84);
463461
}
464462
if (
465-
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
463+
empty($advancedCustom->doNotShowEncoderResolutionLow) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
466464
return array("mp4" => 79, "webm" => 86);
467465
}
468466
if (
469-
empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
467+
empty($advancedCustom->doNotShowEncoderResolutionSD) && empty($advancedCustom->doNotShowEncoderResolutionHD)) {
470468
return array("mp4" => 78, "webm" => 85);
471469
}
472470
if (empty($advancedCustom->doNotShowEncoderResolutionLow)) {
@@ -513,42 +511,42 @@ function decideFormatOrder() {
513511
} elseif (empty($_POST['webm']) || $_POST['webm'] === 'false') {
514512
// mp4 only
515513
if (
516-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
517-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
518-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
514+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
515+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
516+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
519517
) { // all resolutions
520518
error_log("decideFormatOrder: MP4 All");
521519
return (80);
522520
} elseif (
523-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
524-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
521+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
522+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
525523
) {
526524
error_log("decideFormatOrder: MP4 Low - HD");
527525
return (79);
528526
} elseif (
529-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
530-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
527+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
528+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
531529
) {
532530
error_log("decideFormatOrder: MP4 SD - HD");
533531
return (78);
534532
} elseif (
535-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
536-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
533+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
534+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
537535
) {
538536
error_log("decideFormatOrder: MP4 Low SD");
539537
return (77);
540538
} elseif (
541-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
539+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
542540
) {
543541
error_log("decideFormatOrder: MP4 HD");
544542
return (76);
545543
} elseif (
546-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
544+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
547545
) {
548546
error_log("decideFormatOrder: MP4 SD");
549547
return (75);
550548
} elseif (
551-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
549+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
552550
) {
553551
error_log("decideFormatOrder: MP4 LOW");
554552
return (74);
@@ -559,36 +557,36 @@ function decideFormatOrder() {
559557
} else {
560558
// mp4 and webm
561559
if (
562-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
563-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
564-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
560+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
561+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
562+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
565563
) { // all resolutions
566564
return (87);
567565
} elseif (
568-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
569-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
566+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
567+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
570568
) {
571569
return (86);
572570
} elseif (
573-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
574-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
571+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false' &&
572+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
575573
) {
576574
return (85);
577575
} elseif (
578-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
579-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
576+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false' &&
577+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
580578
) {
581579
return (84);
582580
} elseif (
583-
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
581+
!empty($_POST['inputHD']) && $_POST['inputHD'] !== 'false'
584582
) {
585583
return (83);
586584
} elseif (
587-
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
585+
!empty($_POST['inputSD']) && $_POST['inputSD'] !== 'false'
588586
) {
589587
return (82);
590588
} elseif (
591-
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
589+
!empty($_POST['inputLow']) && $_POST['inputLow'] !== 'false'
592590
) {
593591
return (81);
594592
} else {
@@ -668,8 +666,8 @@ function zipDirectory($destinationFile) {
668666
// Create recursive directory iterator
669667
/** @var SplFileInfo[] $files */
670668
$files = new RecursiveIteratorIterator(
671-
new RecursiveDirectoryIterator($rootPath),
672-
RecursiveIteratorIterator::LEAVES_ONLY
669+
new RecursiveDirectoryIterator($rootPath),
670+
RecursiveIteratorIterator::LEAVES_ONLY
673671
);
674672

675673
foreach ($files as $name => $file) {
@@ -1032,9 +1030,9 @@ function isURL200($url) {
10321030
$result = false;
10331031
foreach ($headers as $value) {
10341032
if (
1035-
strpos($value, '200') ||
1036-
strpos($value, '302') ||
1037-
strpos($value, '304')
1033+
strpos($value, '200') ||
1034+
strpos($value, '302') ||
1035+
strpos($value, '304')
10381036
) {
10391037
$result = true;
10401038
}
@@ -1105,8 +1103,8 @@ function isURLaVODVideo($url) {
11051103

11061104
// If the main playlist has an ENDLIST tag, it's a VOD
11071105
if (preg_match('/#EXT-X-ENDLIST/i', $content) ||
1108-
preg_match('/#EXT-X-PLAYLIST-TYPE:\s*VOD/i', $content) ||
1109-
preg_match('/URI=".+enc_[0-9a-z]+.key/i', $content)) {
1106+
preg_match('/#EXT-X-PLAYLIST-TYPE:\s*VOD/i', $content) ||
1107+
preg_match('/URI=".+enc_[0-9a-z]+.key/i', $content)) {
11101108
return true; // VOD content
11111109
}
11121110

@@ -1130,7 +1128,6 @@ function isURLaVODVideo($url) {
11301128
return true;
11311129
}
11321130

1133-
11341131
function _utf8_encode($string) {
11351132
global $global;
11361133

@@ -1172,7 +1169,7 @@ function _sys_get_temp_dir() {
11721169
return $dir;
11731170
}
11741171

1175-
function _get_temp_file($prefix='') {
1172+
function _get_temp_file($prefix = '') {
11761173
return tempnam(_sys_get_temp_dir(), $prefix);
11771174
}
11781175

@@ -1195,7 +1192,6 @@ function convertDates() {
11951192
}
11961193
}
11971194

1198-
11991195
function convertToServerDate($originalDateTime, $fromTimezone) {
12001196
$serverTimezone = date_default_timezone_get();
12011197
$dateTime = new DateTime($originalDateTime, new DateTimeZone($fromTimezone));
@@ -1206,3 +1202,19 @@ function convertToServerDate($originalDateTime, $fromTimezone) {
12061202
// Print the converted datetime
12071203
return $dateTime->format('Y-m-d H:i:s');
12081204
}
1205+
1206+
function getCategoriesSelect($id) {
1207+
?>
1208+
<select class="form-control categories_id" id="<?php echo $id; ?>" name="<?php echo $id; ?>">
1209+
1210+
<option value="0"><?php echo __('Category - Use site default'); ?></option>
1211+
<?php
1212+
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
1213+
foreach ($_SESSION['login']->categories as $key => $value) {
1214+
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
1215+
}
1216+
?>
1217+
</select>
1218+
<?php
1219+
}
1220+

view/index_shareVideos.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,9 @@
6262
?>
6363
<div class="form-group">
6464
<div style="display: flex;">
65-
<select class="form-control categories_id" id="download_categories_id" name="download_categories_id">
66-
67-
<option value="0"><?php echo __('Category - Use site default'); ?></option>
68-
<?php
69-
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
70-
foreach ($_SESSION['login']->categories as $key => $value) {
71-
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
72-
}
73-
?>
74-
</select>
65+
<?php
66+
echo getCategoriesSelect('download_categories_id');
67+
?>
7568
<?php
7669
if (Login::canCreateCategory()) {
7770
?>
@@ -148,16 +141,9 @@ function reloadIfIsNotEditingCategory() {
148141
?>
149142
<div class="form-group">
150143
<div style="display: flex;">
151-
<select class="form-control categories_id" id="bulk_categories_id" name="bulk_categories_id">
152-
153-
<option value="0"><?php echo __('Category - Use site default'); ?></option>
154-
<?php
155-
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
156-
foreach ($_SESSION['login']->categories as $key => $value) {
157-
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
158-
}
159-
?>
160-
</select>
144+
<?php
145+
echo getCategoriesSelect('bulk_categories_id');
146+
?>
161147
<?php
162148
if (Login::canCreateCategory()) {
163149
?>

view/jquery-file-upload/form.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,9 @@
1616
?>
1717
<div class="form-group">
1818
<div style="display: flex;">
19-
<select class="form-control categories_id" id="categories_id" name="categories_id">
20-
21-
<option value="0"><?php echo __('Category - Use site default'); ?></option>
22-
<?php
23-
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
24-
foreach ($_SESSION['login']->categories as $key => $value) {
25-
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
26-
}
27-
?>
28-
</select>
19+
<?php
20+
echo getCategoriesSelect('categories_id_upload');
21+
?>
2922
<?php
3023
if (Login::canCreateCategory()) {
3124
?>

view/jquery-file-upload/js/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ $(function () {
152152
"inputAutoAudio": $('#inputAutoAudio').is(":checked"),
153153
"title": $('#title').val(),
154154
"description": $('#description').val(),
155-
"categories_id": $('#categories_id').val(),
155+
"categories_id": $('#categories_id_upload').val(),
156156
"callback": $('#callback').val(),
157157
"usergroups_id": $(".usergroups_id:checked").map(function () {
158158
return $(this).val();
@@ -183,7 +183,7 @@ $(function () {
183183
"inputAutoAudio": $('#inputAutoAudio').is(":checked"),
184184
"title": $('#title').val(),
185185
"description": $('#description').val(),
186-
"categories_id": $('#categories_id').val(),
186+
"categories_id": $('#categories_id_upload').val(),
187187
"releaseDate": $('#releaseDate').val(),
188188
"callback": $('#callback').val(),
189189
"timezone": timezone,

view/mini-upload-form/assets/js/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $(function () {
5151
"inputHD": $('#inputHD').is(":checked"),
5252
"title": $('#title').val(),
5353
"description": $('#description').val(),
54-
"categories_id": $('#categories_id').val(),
54+
"categories_id": $('#categories_id_upload').val(),
5555
"releaseDate": $('#releaseDate').val(),
5656
"callback": $('#callback').val(),
5757
"timezone": timezone,

view/mini-upload-form/form.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- not used -->
12
<link href="view/mini-upload-form/assets/css/style.css" rel="stylesheet" />
23
<form id="upload" method="post" action="<?= $global['webSiteRootURL'] ?>upload" enctype="multipart/form-data">
34
<div class="form-group">
@@ -11,16 +12,9 @@
1112
?>
1213
<div class="form-group">
1314
<div style="display: flex;">
14-
<select class="form-control categories_id" id="categories_id" name="categories_id">
15-
16-
<option value="0"><?php echo __('Category - Use site default'); ?></option>
17-
<?php
18-
array_multisort(array_column($_SESSION['login']->categories, 'hierarchyAndName'), SORT_ASC, $_SESSION['login']->categories);
19-
foreach ($_SESSION['login']->categories as $key => $value) {
20-
echo '<option value="' . $value->id . '">' . $value->hierarchyAndName . '</option>';
21-
}
22-
?>
23-
</select>
15+
<?php
16+
echo getCategoriesSelect('categories_id_miniupload');
17+
?>
2418
<?php
2519
if (Login::canCreateCategory()) {
2620
?>

0 commit comments

Comments
 (0)