mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
parent
d0988b5a8c
commit
9b56290692
6 changed files with 110 additions and 13 deletions
62
install/restartNginxIfNeed.php
Normal file
62
install/restartNginxIfNeed.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
if(php_sapi_name() !== 'cli'){
|
||||
die('command line only');
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects if an SSL certificate is valid for the given hostname and port.
|
||||
*
|
||||
* @param string $hostname The hostname to connect to.
|
||||
* @param int $port The port number to connect to.
|
||||
* @param int $timeout The timeout value in seconds (default: 30).
|
||||
* @return bool Returns true if the SSL certificate is valid, false otherwise.
|
||||
*/
|
||||
function is_ssl_certificate_valid($hostname, $port = 8443, $timeout = 30) {
|
||||
$errno = '';
|
||||
$errstr = '';
|
||||
$context = stream_context_create(array("ssl" =>
|
||||
array(
|
||||
"capture_peer_cert" => true,
|
||||
'verify_peer'=>false,
|
||||
'verify_peer_name'=>false,
|
||||
'allow_self_signed'=>true
|
||||
)
|
||||
));
|
||||
$stream = @stream_socket_client("ssl://{$hostname}:{$port}", $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context);
|
||||
if(!empty($stream)){
|
||||
$cert_data = openssl_x509_parse(stream_context_get_params($stream)["options"]["ssl"]["peer_certificate"]);
|
||||
|
||||
$validFrom = DateTime::createFromFormat('ymdHisT', $cert_data["validFrom"]);
|
||||
$validTo = DateTime::createFromFormat('ymdHisT', $cert_data["validTo"]);
|
||||
$now = new DateTime();
|
||||
|
||||
if ($now >= $validFrom && $now <= $validTo) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Error connecting to the SSL endpoint
|
||||
error_log("Failed to connect to SSL endpoint: {$errstr} ({$errno})");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isDocker(){
|
||||
return file_exists('/var/www/docker_vars.json');
|
||||
}
|
||||
|
||||
$hostname = 'live';
|
||||
if(!isDocker()){
|
||||
$hostname = 'localhost';
|
||||
}
|
||||
|
||||
if (!is_ssl_certificate_valid($hostname)) {
|
||||
// Restart Nginx
|
||||
echo 'Restart Nginx';
|
||||
exec('/usr/local/nginx/sbin/nginx -s stop');
|
||||
sleep(3);
|
||||
exec('/usr/local/nginx/sbin/nginx');
|
||||
}else{
|
||||
echo 'No need to restart';
|
||||
}
|
|
@ -393,25 +393,36 @@ function cleanString($text) {
|
|||
return preg_replace(array_keys($utf8), array_values($utf8), $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes a string by removing HTML tags and special characters.
|
||||
*
|
||||
* @param string $text The text to sanitize.
|
||||
* @param bool $strict (optional) Whether to apply strict sanitization. Defaults to false.
|
||||
* @return string The sanitized string.
|
||||
*/
|
||||
function safeString($text, $strict = false, $try = 0) {
|
||||
if (empty($text)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$originalText = $text;
|
||||
$text = strip_tags($text);
|
||||
$text = str_replace(['&', '<', '>'], ['', '', ''], $text);
|
||||
$text = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '', $text);
|
||||
$text = preg_replace('/(&#x*[0-9A-F]+);*/iu', '', $text);
|
||||
$text = html_entity_decode($text, ENT_COMPAT, 'UTF-8');
|
||||
|
||||
if ($strict) {
|
||||
$text = filter_var($text, FILTER_SANITIZE_STRING);
|
||||
$text = filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_ENCODE_LOW | FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_ENCODE_AMP);
|
||||
//$text = cleanURLName($text);
|
||||
}
|
||||
|
||||
$text = trim($text);
|
||||
|
||||
if(empty($try) && empty($text)){
|
||||
return safeString(utf8_encode($originalText), $strict, 1);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
@ -490,21 +501,35 @@ function getMinutesTotalVideosLength() {
|
|||
return floor($seconds / 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a duration in seconds to a formatted time string (hh:mm:ss).
|
||||
*
|
||||
* @param int|float|string $seconds The duration in seconds to convert.
|
||||
* @return string The formatted time string.
|
||||
*/
|
||||
function secondsToVideoTime($seconds) {
|
||||
if (!is_numeric($seconds)) {
|
||||
return $seconds;
|
||||
return (string) $seconds;
|
||||
}
|
||||
|
||||
$seconds = round($seconds);
|
||||
$hours = floor($seconds / 3600);
|
||||
$mins = floor(intval($seconds / 60) % 60);
|
||||
$secs = floor($seconds % 60);
|
||||
return sprintf('%02d:%02d:%02d', $hours, $mins, $secs);
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$seconds = $seconds % 60;
|
||||
|
||||
return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
|
||||
}
|
||||
|
||||
function parseSecondsToDuration($seconds) {
|
||||
return secondsToVideoTime($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a duration string to the corresponding number of seconds.
|
||||
*
|
||||
* @param int|string $str The duration string to parse, in the format "HH:MM:SS".
|
||||
* @return int The duration in seconds.
|
||||
*/
|
||||
function parseDurationToSeconds($str) {
|
||||
if ($str == "00:00:00") {
|
||||
return 0;
|
||||
|
@ -582,10 +607,17 @@ function setSiteSendMessage(\PHPMailer\PHPMailer\PHPMailer &$mail) {
|
|||
session_write_close();
|
||||
}
|
||||
|
||||
function array_iunique($array) {
|
||||
return array_intersect_key($array, array_unique(array_map("mb_strtolower", $array)));
|
||||
/**
|
||||
* Returns an array with the unique values from the input array, ignoring case differences.
|
||||
*
|
||||
* @param array $array The input array.
|
||||
* @return array The array with unique values.
|
||||
*/
|
||||
function array_iunique(array $array): array {
|
||||
return array_intersect_key($array, array_unique(array_map('mb_strtolower', $array)));
|
||||
}
|
||||
|
||||
|
||||
function partition(array $list, $totalItens) {
|
||||
$listlen = count($list);
|
||||
_error_log("partition: listlen={$listlen} totalItens={$totalItens}");
|
||||
|
|
|
@ -24,7 +24,9 @@ set_time_limit(0);
|
|||
ini_set('max_execution_time', 0);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
/**
|
||||
* @var mixed[] $global
|
||||
*/
|
||||
$global['rowCount'] = $global['limitForUnlimitedVideos'] = 999999;
|
||||
$path = getVideosDir();
|
||||
$total = Video::getTotalVideos("", false, true, true, false, false);
|
||||
|
|
|
@ -317,7 +317,9 @@ class CustomizeAdvanced extends PluginAbstract {
|
|||
$obj->doNotDisplayPluginsTags = false;
|
||||
$obj->showNotRatedLabel = false;
|
||||
$obj->showShareMenuOpenByDefault = false;
|
||||
|
||||
/**
|
||||
* @var mixed[] $global
|
||||
*/
|
||||
foreach ($global['social_medias'] as $key => $value) {
|
||||
eval("\$obj->showShareButton_{$key} = true;");
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ if ((!empty($videos)) || (!empty($obj) && $obj->SubCategorys)) {
|
|||
$backURL = $_REQUEST['getBackURL'];
|
||||
}
|
||||
?>
|
||||
<div class="col-lg-2 col-md-4 col-sm-4 col-xs-6 galleryVideo galleryVideo<?php echo $value['id']; ?> fixPadding">
|
||||
<div class="col-lg-2 col-md-4 col-sm-4 col-xs-6 galleryVideo galleryVideo<?php echo $cat['id']; ?> fixPadding">
|
||||
<a href="<?php echo $global['webSiteRootURL']; ?>cat/<?php echo $cat['clean_name']; ?>?getBackURL=<?php echo urlencode($backURL);?>" title="<?php $cat['name']; ?>">
|
||||
<div class="aspectRatio16_9">
|
||||
<?php
|
||||
|
|
|
@ -7,8 +7,7 @@ $percent = 90;
|
|||
background: -webkit-linear-gradient(bottom, rgba(<?php echo $obj->backgroundRGB; ?>,1) <?php echo $percent; ?>%, rgba(<?php echo $obj->backgroundRGB; ?>,0) 100%);
|
||||
background: -o-linear-gradient(top, rgba(<?php echo $obj->backgroundRGB; ?>,1) <?php echo $percent; ?>%, rgba(<?php echo $obj->backgroundRGB; ?>,0) 100%);
|
||||
background: linear-gradient(top, rgba(<?php echo $obj->backgroundRGB; ?>,1) <?php echo $percent; ?>%, rgba(<?php echo $obj->backgroundRGB; ?>,0) 100%);
|
||||
background: -moz-linear-gradient(to top, rgba(<?php echo $obj->backgroundRGB; ?>,1) <?php echo $percent; ?>%, rgba(<?php echo $obj->backgroundRGB; ?>,0) 100%);
|
||||
">
|
||||
background: -moz-linear-gradient(to top, rgba(<?php echo $obj->backgroundRGB; ?>,1) <?php echo $percent; ?>%, rgba(<?php echo $obj->backgroundRGB; ?>,0) 100%);">
|
||||
<?php
|
||||
$_REQUEST['current'] = 1;
|
||||
$_REQUEST['rowCount'] = $obj->maxVideos;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue