1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00
This commit is contained in:
Daniel Neto 2023-02-23 18:18:26 -03:00
parent a1f5544788
commit 3dbdce673b
15 changed files with 275 additions and 171 deletions

View file

@ -1,8 +1,8 @@
FROM ubuntu/apache2:2.4-22.10_edge
FROM ubuntu:latest
LABEL maintainer="TRW <trw@acoby.de>" \
org.label-schema.schema-version="1.0" \
org.label-schema.version="1.1.0" \
LABEL maintainer="Daniel Neto <developer@youphptube.com>" \
org.label-schema.schema-version="2.0" \
org.label-schema.version="2.0.0" \
org.label-schema.name="avideo-platform" \
org.label-schema.description="Audio Video Platform" \
org.label-schema.url="https://github.com/WWBN/AVideo" \
@ -29,33 +29,104 @@ ARG CONTACT_EMAIL
ARG SYSTEM_ADMIN_PASSWORD
ARG WEBSITE_TITLE
ARG MAIN_LANGUAGE
ARG NGINX_RTMP_PORT
ARG NGINX_HTTP_PORT
ARG NGINX_HTTPS_PORT
# Retrieve package list
RUN apt update
# Update package list and upgrade installed packages
RUN apt-get update && apt-get upgrade -y
# Install dependencies
RUN apt-get update -y && apt-get upgrade -y \
&& apt install -y --no-install-recommends dos2unix bash-completion lsof rsyslog cron rsync ca-certificates apt-transport-https software-properties-common curl \
&& curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp \
&& chmod a+rx /usr/local/bin/yt-dlp \
&& apt install -y --no-install-recommends sshpass nano net-tools curl apache2 php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-sqlite3 php8.1-curl php8.1-gd php8.1-intl \
php-zip mysql-client ffmpeg git libimage-exiftool-perl libapache2-mod-xsendfile python3-certbot-apache -y && a2enmod xsendfile && cd /var/www/html \
&& apt install -y --no-install-recommends && curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl \
&& chmod a+rx /usr/local/bin/youtube-dl && apt install -y --no-install-recommends build-essential libpcre3 libpcre3-dev libssl-dev php8.1-xml -y \
&& a2enmod rewrite \
&& apt install -y --no-install-recommends unzip -y && apt install -y --no-install-recommends htop python3-pip \
&& pip3 install youtube-dl && pip3 install --upgrade youtube-dl && a2enmod expires \
&& a2enmod headers
# Install basic utilities
RUN apt-get install -y --no-install-recommends \
apt-transport-https \
bash-completion \
ca-certificates \
cron \
curl \
dos2unix \
git \
htop \
iputils-ping \
lsof \
nano \
net-tools \
rsyslog \
rsync \
software-properties-common \
unzip \
sshpass
# Install Apache and Apache modules
RUN apt-get install -y --no-install-recommends \
apache2 \
libapache2-mod-xsendfile \
libapache2-mod-php \
libimage-exiftool-perl
# Install PHP and PHP extensions
RUN apt-get install -y --no-install-recommends \
libapache2-mod-php \
#libzip-dev \
libssl-dev \
#libicu-dev \
#libpq-dev \
#libpng-dev \
#libjpeg-dev \
#libfreetype6-dev \
#libonig-dev \
#libxml2-dev \
zlib1g-dev \
php \
php-curl \
php-gd \
php-intl \
php-mysql \
php-sqlite3 \
php-xml \
#php-dev \
php-zip \
php-pear
# Install multimedia tools
RUN apt-get install -y --no-install-recommends \
ffmpeg
# Install Python packages
RUN apt-get install -y --no-install-recommends \
python3-certbot-apache \
python3-pip
# Download and install yt-dlp
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && \
chmod a+rx /usr/local/bin/yt-dlp
# Download and install youtube-dl
RUN cd /var/www/html && \
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl && \
chmod a+rx /usr/local/bin/youtube-dl
# Install ssh2 and openssl
#RUN pecl install ssh2 && \
# docker-php-ext-enable ssh2 && \
# docker-php-ext-install openssl && \
# echo "extension=ssh2.so" >> /usr/local/etc/php/conf.d/ssh2.ini
# Enable necessary Apache modules
RUN a2enmod xsendfile rewrite expires headers ssl
# Install and upgrade youtube-dl using pip
RUN pip3 install youtube-dl --upgrade youtube-dl
# Copy configuration files
COPY deploy/apache/avideo.conf /etc/apache2/sites-enabled/000-default.conf
COPY deploy/apache/docker-entrypoint /usr/local/bin/docker-entrypoint
COPY deploy/apache/wait-for-db.php /usr/local/bin/wait-for-db.php
#COPY deploy/apache/phpmyadmin.conf /etc/apache2/conf-available/phpmyadmin.conf
COPY deploy/apache/crontab /etc/cron.d/crontab
RUN dos2unix /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN chmod +x /etc/cron.d/crontab
# Set permissions for crontab
RUN dos2unix /etc/cron.d/crontab && \
chmod 0644 /etc/cron.d/crontab && \
chmod +x /etc/cron.d/crontab
# Configure AVideo
RUN dos2unix /usr/local/bin/docker-entrypoint && \
@ -71,11 +142,14 @@ RUN dos2unix /usr/local/bin/docker-entrypoint && \
# Add Apache configuration
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Create directory and set permissions
VOLUME /var/www/tmp
RUN mkdir -p /var/www/tmp && \
chown www-data:www-data /var/www/tmp && \
chmod 777 /var/www/tmp
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /var/www/html/AVideo/
EXPOSE $SOCKET_PORT

View file

@ -10,7 +10,10 @@ ARG CREATE_TLS_CERTIFICATE
ARG TLS_CERTIFICATE_FILE
ARG TLS_CERTIFICATE_KEY
# Update and upgrade packages
RUN apt-get update -y && apt-get upgrade -y
# Install basic packages
RUN apt-get install -y --no-install-recommends \
dos2unix \
bash-completion \
@ -24,17 +27,28 @@ RUN apt-get install -y --no-install-recommends \
curl \
build-essential \
libssl-dev \
php-fpm \
php-cli \
php-curl \
libpcre3 \
libpcre3-dev \
git \
python3-certbot-nginx \
ffmpeg \
zlib1g-dev \
wget
RUN mkdir ~/build && \
# Install PHP packages
RUN apt-get install -y --no-install-recommends \
php-fpm \
php-cli \
php-curl
# Install NGINX dependencies
RUN apt-get install -y --no-install-recommends \
libpcre3 \
libpcre3-dev
# Install Git and Certbot
RUN apt-get install -y --no-install-recommends \
git \
python3-certbot-nginx
# Build NGINX with RTMP module
RUN mkdir ~/build && \
cd ~/build && \
git clone https://github.com/arut/nginx-rtmp-module.git && \
git clone https://github.com/nginx/nginx.git && \
@ -42,7 +56,9 @@ RUN apt-get install -y --no-install-recommends \
./auto/configure --with-http_ssl_module --with-http_stub_status_module --add-module=../nginx-rtmp-module --with-cc-opt="-Wimplicit-fallthrough=0" && \
make && \
make install
RUN cd /usr/local/nginx/html && \
# Download and configure NGINX
RUN cd /usr/local/nginx/html && \
wget https://youphp.tube/docs/stat.xsl --no-check-certificate && \
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old && \
cd /usr/local/nginx/conf/ && \
@ -53,30 +69,34 @@ RUN apt-get install -y --no-install-recommends \
mkdir /var/www/tmp/ && \
chmod 777 /var/www/tmp
# Copy configuration files
COPY deploy/nginx/docker-entrypoint-live /usr/local/bin/docker-entrypoint-live
COPY deploy/nginx/nginx.conf /usr/local/nginx/conf/nginx.conf
COPY deploy/nginx/crontab /etc/cron.d/crontab
RUN dos2unix /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN chmod +x /etc/cron.d/crontab
RUN service cron start
RUN crontab /etc/cron.d/crontab
# Set permissions for crontab
RUN dos2unix /etc/cron.d/crontab && \
chmod 0644 /etc/cron.d/crontab && \
chmod +x /etc/cron.d/crontab && \
service cron start && \
crontab /etc/cron.d/crontab
# Set permissions for docker-entrypoint-live
RUN dos2unix /usr/local/bin/docker-entrypoint-live && \
chmod 755 /usr/local/bin/docker-entrypoint-live && \
chmod +x /usr/local/bin/docker-entrypoint-live
# Create directory and set permissions
VOLUME /var/www/tmp
RUN mkdir -p /var/www/tmp && \
chmod 777 /var/www/tmp
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Expose ports
EXPOSE $NGINX_RTMP_PORT
EXPOSE $NGINX_HTTP_PORT
EXPOSE $NGINX_HTTPS_PORT
# Set the entrypoint and command
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-live"]
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]
#CMD ["bash"]

View file

@ -1,20 +1,17 @@
php_flag log_errors on
php_value error_log /dev/stderr
ErrorLog /dev/stderr
CustomLog ${APACHE_LOG_DIR}/access.log combined
TransferLog /dev/stdout
<VirtualHost localhost:80>
ServerName localhost
ServerAdmin CONTACT_EMAIL
DocumentRoot "/var/www/html/AVideo"
ErrorLog /dev/stderr
CustomLog ${APACHE_LOG_DIR}/access.log combined
TransferLog /dev/stdout
</VirtualHost>
<VirtualHost localhost:443>
ServerName localhost
ServerAdmin CONTACT_EMAIL
DocumentRoot "/var/www/html/AVideo"
ErrorLog /dev/stderr
CustomLog ${APACHE_LOG_DIR}/access.log combined
TransferLog /dev/stdout
SSLEngine on
SSLCertificateFile TLS_CERTIFICATE_FILE
SSLCertificateKeyFile TLS_CERTIFICATE_KEY
@ -23,17 +20,11 @@
ServerName SERVER_NAME
ServerAdmin CONTACT_EMAIL
DocumentRoot "/var/www/html/AVideo"
ErrorLog /dev/stderr
CustomLog ${APACHE_LOG_DIR}/access.log combined
TransferLog /dev/stdout
</VirtualHost>
<VirtualHost *:443>
ServerName SERVER_NAME
ServerAdmin CONTACT_EMAIL
DocumentRoot "/var/www/html/AVideo"
ErrorLog /dev/stderr
CustomLog ${APACHE_LOG_DIR}/access.log combined
TransferLog /dev/stdout
</VirtualHost>
<Directory /var/www/html/AVideo/>
Options Indexes FollowSymLinks

View file

@ -1,12 +1,12 @@
#!/bin/bash
echo "Starting AVideo Platform..."
echo "entrypoint -- Starting AVideo Platform..."
CONFIG_FILE=/etc/apache2/sites-enabled/000-default.conf
if [ "_${CREATE_TLS_CERTIFICATE}_" == "_yes_" ]; then
echo "Generate Certificate..."
echo "Certificate file: ${TLS_CERTIFICATE_FILE}"
echo "Certificate key: ${TLS_CERTIFICATE_KEY}"
echo "entrypoint -- Generate Certificate..."
echo "entrypoint -- Certificate file: ${TLS_CERTIFICATE_FILE}"
echo "entrypoint -- Certificate key: ${TLS_CERTIFICATE_KEY}"
mkdir -p `dirname ${TLS_CERTIFICATE_FILE}`
mkdir -p `dirname ${TLS_CERTIFICATE_KEY}`
@ -38,14 +38,14 @@ if [ "_${CREATE_TLS_CERTIFICATE}_" == "_yes_" ]; then
-extensions EXT -config <( \
printf "${CONFIG}")
echo "New Certificate config..."
echo "entrypoint -- New Certificate config..."
openssl x509 -in ${TLS_CERTIFICATE_FILE} -noout -text || true
fi
sed -i 's#SERVER_NAME#'${SERVER_NAME}'#' ${CONFIG_FILE}
sed -i 's#CONTACT_EMAIL#'${CONTACT_EMAIL}'#' ${CONFIG_FILE}
echo "Configure Apache..."
echo "entrypoint -- Configure Apache..."
sed -i 's#TLS_CERTIFICATE_FILE#'${TLS_CERTIFICATE_FILE}'#' ${CONFIG_FILE}
sed -i 's#TLS_CERTIFICATE_KEY#'${TLS_CERTIFICATE_KEY}'#' ${CONFIG_FILE}
@ -54,17 +54,17 @@ mkdir -p /etc/letsencrypt/live/localhost/
cp ${TLS_CERTIFICATE_FILE} /etc/letsencrypt/live/localhost/fullchain.pem
cp ${TLS_CERTIFICATE_KEY} /etc/letsencrypt/live/localhost/privkey.pem
echo "Waiting for database ${DB_MYSQL_HOST} to be up and running"
echo "entrypoint -- Waiting for database ${DB_MYSQL_HOST} to be up and running"
php /usr/local/bin/wait-for-db.php
if [ $? -ne 0 ]; then
echo "Stopping container"
echo "entrypoint -- Stopping container"
exit 1
fi
if [ -f /var/www/html/AVideo/plugin/User_Location/install/install.sql ]; then
echo "Using existing location tables..."
echo "entrypoint -- Using existing location tables..."
else
echo "Create new locations tables..."
echo "entrypoint -- Create new locations tables..."
cd /var/www/html/AVideo/plugin/User_Location/install && unzip install.zip
# Configure AVideo Encoder
cd /var/www/html/AVideo && git config --global advice.detachedHead false && git clone https://github.com/WWBN/AVideo-Encoder.git Encoder
@ -73,51 +73,50 @@ else
fi
if [ -f /var/www/html/AVideo/Encoder/index.php ]; then
echo "Using existing Encoder configuration..."
echo "entrypoint -- Using existing Encoder configuration..."
else
echo "Create new Encoder configuration..."
echo "entrypoint -- Create new Encoder configuration..."
# Configure AVideo Encoder
cd /var/www/html/AVideo && git config --global advice.detachedHead false && git clone https://github.com/WWBN/AVideo-Encoder.git Encoder
fi
if [ -d /var/www/html/AVideo/Encoder/videos ]; then
echo "Using existing Encoder videos..."
echo "entrypoint -- Using existing Encoder videos..."
else
echo "Create new Encoder videos..."
echo "entrypoint -- Create new Encoder videos..."
# Configure AVideo Encoder
mkdir -p /var/www/html/AVideo/Encoder/videos && chown www-data:www-data /var/www/html/AVideo/Encoder/videos && chmod 777 /var/www/html/AVideo/Encoder/videos
fi
echo "Checking configuration..."
echo "entrypoint -- Checking configuration..."
cd /var/www/html/AVideo/install/
php ./cli.php
cd /var/www/html/AVideo/
#if [ "_${ENABLE_PHPMYADMIN}_" = "_yes_" ]; then
# echo "Enabling local PHPMyAdmin on https://${SERVER_NAME}/phpmyadmin"
# cp /etc/apache2/conf-available/phpmyadmin.conf /etc/apache2/conf-enabled/phpmyadmin.conf
# a2enmod proxy
# a2enmod proxy_http
#fi
echo "lets encrypt apache ${SERVER_NAME}"
echo "entrypoint -- Running certbot..."
certbot --apache --non-interactive --agree-tos --register-unsafely-without-email --redirect --keep-until-expiring -d ${SERVER_NAME}
/etc/init.d/apache2 stop
echo "Start socket"
echo "entrypoint -- Writing /var/www/docker_vars.json"
echo "{\"SOCKET_PORT\":${SOCKET_PORT}, \"HTTP_PORT\":${HTTP_PORT}, \"HTTPS_PORT\":${HTTPS_PORT}, \"SERVER_NAME\":\"${SERVER_NAME}\", \"NGINX_RTMP_PORT\":${NGINX_RTMP_PORT}, \"NGINX_HTTP_PORT\":${NGINX_HTTP_PORT}, \"NGINX_HTTPS_PORT\":${NGINX_HTTPS_PORT}}" > /var/www/docker_vars.json
echo "entrypoint -- Starting socket server..."
nohup php /var/www/html/AVideo/plugin/YPTSocket/server.php &
echo "Reset log"
echo "entrypoint -- Reset log"
echo '' > /var/www/html/AVideo/videos/avideo.log
chmod 777 /var/www/html/AVideo/videos/avideo.log
echo "deny access to .compose"
echo "entrypoint -- Deny access to .compose"
echo "Deny from all" > /var/www/html/AVideo/.compose/.htaccess
echo "entrypoint -- Running updatedb script..."
cd /var/www/html/AVideo/install && php updatedb.php
echo "entrypoint -- Running reencodeAllVideos script..."
cd /var/www/html/AVideo/Encoder/install && php reencodeAllVideos.php
echo "crontab starting"
echo "entrypoint -- Starting cron service..."
cron
service cron start
crontab /etc/cron.d/crontab
@ -125,9 +124,9 @@ crontab /etc/cron.d/crontab
bash
source /etc/bash_completion
echo "apache2-foreground start"
apache2-foreground
echo "apache2-foreground done"
echo "entrypoint -- service apache2 start"
#apache2-foreground
apachectl -DFOREGROUND
echo "entrypoint -- service apache2 done"
#eof

View file

@ -45,6 +45,9 @@ services:
SYSTEM_ADMIN_PASSWORD: "${SYSTEM_ADMIN_PASSWORD:-password}"
WEBSITE_TITLE: "${WEBSITE_TITLE:-AVideo}"
MAIN_LANGUAGE: "${MAIN_LANGUAGE:-en_US}"
NGINX_RTMP_PORT: "${NGINX_RTMP_PORT:-1935}"
NGINX_HTTP_PORT: "${NGINX_HTTP_PORT:-8080}"
NGINX_HTTPS_PORT: "${NGINX_HTTPS_PORT:-8443}"
env_file:
- .env
ports:
@ -85,6 +88,9 @@ services:
CREATE_TLS_CERTIFICATE: "${CREATE_TLS_CERTIFICATE:-yes}"
TLS_CERTIFICATE_FILE: "${TLS_CERTIFICATE_FILE:-/etc/apache2/ssl/localhost.crt}"
TLS_CERTIFICATE_KEY: "${TLS_CERTIFICATE_KEY:-/etc/apache2/ssl/localhost.key}"
NGINX_RTMP_PORT: "${NGINX_RTMP_PORT:-1935}"
NGINX_HTTP_PORT: "${NGINX_HTTP_PORT:-8080}"
NGINX_HTTPS_PORT: "${NGINX_HTTPS_PORT:-8443}"
env_file:
- .env
ports:

View file

@ -700,7 +700,7 @@ abstract class ObjectYPT implements ObjectInterface
rrmdirCommandLine($newtmpDir, true);
}
self::setLastDeleteALLCacheTime();
unlink($lockFile);
@unlink($lockFile);
$end = microtime(true) - $start;
_error_log("deleteALLCache end in {$end} seconds");
return true;

View file

@ -3765,7 +3765,8 @@ function rrmdir($dir) {
rrmdirCommandLine($dir);
if (is_dir($dir)) {
//_error_log('rrmdir: The Directory was not deleted, trying again ' . $dir);
$objects = scandir($dir);
$objects = @scandir($dir);
if(!empty($objects)){
//_error_log('rrmdir: scandir ' . $dir . ' '. json_encode($objects));
foreach ($objects as $object) {
if ($object !== '.' && $object !== '..') {
@ -3776,17 +3777,20 @@ function rrmdir($dir) {
}
}
}
}
if (preg_match('/(\/|^)videos(\/cache)?\/?$/i', $dir)) {
_error_log('rrmdir: do not delete videos or cache folder ' . $dir);
// do not delete videos or cache folder
return false;
}
if (rmdir($dir)) {
if(is_dir($dir)){
if (@rmdir($dir)) {
return true;
} else if (is_dir($dir)) {
_error_log('rrmdir: could not delete folder ' . $dir);
return false;
}
}
} else {
//_error_log('rrmdir: The Directory does not exists '.$dir);
return true;
@ -5648,10 +5652,12 @@ function isValidURLOrPath($str, $insideCacheOrTmpDirOnly = true) {
}
function hasLastSlash($word) {
$word = trim($word);
return substr($word, -1) === '/';
}
function addLastSlash($word) {
$word = trim($word);
return $word . (hasLastSlash($word) ? "" : "/");
}
@ -10134,3 +10140,8 @@ function isConfirmationPage() {
global $_isConfirmationPage;
return !empty($_isConfirmationPage);
}
function getDockerVars(){
$content = file_get_contents('/var/www/docker_vars.json');
return json_decode($content);
}

View file

@ -3963,13 +3963,17 @@ class LiveStreamObject {
public function getM3U8($doNotProtect = false, $allowOnlineIndex = false, $ignoreCDN = false) {
global $global;
$o = AVideoPlugin::getObjectData("Live");
$uuid = $this->getKeyWithIndex($allowOnlineIndex, $allowOnlineIndex);
//_error_log("Live:getM3U8($doNotProtect , $allowOnlineIndex e, $ignoreCDN) $uuid ($allowOnlineIndex");
if (empty($o->server_type->value)) {
$row = LiveTransmitionHistory::getLatest($this->key, $this->live_servers_id);
if (!empty($row['domain'])) {
return "{$row['domain']}live/{$uuid}.m3u8";
if($row['domain'] == 'http://avideo:8080/'){
$row['domain'] = $o->playerServer;
}
$url = "{$row['domain']}live/{$uuid}.m3u8";
//_error_log("getM3U8($doNotProtect, $allowOnlineIndex, $ignoreCDN) ".__LINE__." {$url}");
return $url;
}
}
@ -3983,13 +3987,22 @@ class LiveStreamObject {
}
$playerServer = addLastSlash($playerServer);
if ($o->protectLive && empty($doNotProtect)) {
return "{$global['webSiteRootURL']}plugin/Live/m3u8.php?live_servers_id={$this->live_servers_id}&uuid=" . encryptString($uuid);
} elseif ($o->useAadaptiveMode) {
return $playerServer . "{$uuid}.m3u8";
} else {
return $playerServer . "{$uuid}/index.m3u8";
if($playerServer == 'http://avideo:8080/live/'){
$dockerVars = getDockerVars();
$playerServer = "https://{$dockerVars->SERVER_NAME}:{$dockerVars->NGINX_HTTPS_PORT}/live/";
//_error_log("getM3U8($doNotProtect, $allowOnlineIndex, $ignoreCDN) {$playerServer} ".__LINE__);
}
if ($o->protectLive && empty($doNotProtect)) {
$url = "{$global['webSiteRootURL']}plugin/Live/m3u8.php?live_servers_id={$this->live_servers_id}&uuid=" . encryptString($uuid);
//_error_log("getM3U8($doNotProtect, $allowOnlineIndex, $ignoreCDN) ".__LINE__." {$url}");
} elseif ($o->useAadaptiveMode) {
$url = $playerServer . "{$uuid}.m3u8";
//_error_log("getM3U8($doNotProtect, $allowOnlineIndex, $ignoreCDN) ".__LINE__." {$url}");
} else {
$url = $playerServer . "{$uuid}/index.m3u8";
//_error_log("getM3U8($doNotProtect, $allowOnlineIndex, $ignoreCDN) {$playerServer} ".__LINE__." {$url}");
}
return $url;
}
public function getOnlineM3U8($users_id, $doNotProtect = false) {

View file

@ -139,7 +139,7 @@ class LiveTransmition extends ObjectYPT
return true;
}
public static function getFromDbByUser($user_id)
public static function getFromDbByUser($user_id, $refreshCache = false)
{
global $global;
if (!self::isTableInstalled(static::getTableName())) {
@ -148,10 +148,11 @@ class LiveTransmition extends ObjectYPT
}
$user_id = intval($user_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "i", [$user_id]);
$res = sqlDAL::readSql($sql, "i", [$user_id], $refreshCache);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res != false) {
if (!empty($data)) {
$data['live_servers_id'] = Live::getLiveServersIdRequest();
$liveStreamObject = new LiveStreamObject($data['key'], $data['live_servers_id']);
$data['key_with_index'] = $liveStreamObject->getKeyWithIndex(true);
$data['live_index'] = $liveStreamObject->getIndex();
@ -291,13 +292,17 @@ class LiveTransmition extends ObjectYPT
if (!empty($row)) {
$row['live_schedule_id'] = 0;
$row['scheduled'] = 0;
$row['users_id'] = 0;
}
if (!empty($row)) {
$p = $row['live_password'];
$row = cleanUpRowFromDatabase($row);
$row['live_password'] = $p;
}
if (empty($row['users_id'])) {
$row['users_id'] = 0;
}
} else {
$row = false;
}
@ -313,8 +318,15 @@ class LiveTransmition extends ObjectYPT
return $row;
}
public function save()
{
public function save(){
if(empty($this->users_id)){
return false;
}
$row = self::getFromDbByUser($this->users_id, true);
if(!empty($row)){
$this->id = $row['id'];
}
$this->public = intval($this->public);
$this->saveTransmition = intval($this->saveTransmition);
$this->showOnTV = intval($this->showOnTV);
@ -413,7 +425,6 @@ class LiveTransmition extends ObjectYPT
}
public static function getFromKey($key, $checkSchedule = true){
global $global;
return self::keyExists($key, $checkSchedule);
}

View file

@ -276,34 +276,6 @@ $global['doNotLoadPlayer'] = 1;
var params = {};
var attributes = {};
function amIOnline() {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/Live/stats.json.php?checkIfYouOnline',
data: {
"name": "<?php echo $streamName; ?>"
},
type: 'post',
success: function(response) {
offLine = true;
if (response.applications) {
for (i = 0; i < response.applications.length; i++) {
if (response.applications[i].key === "<?php echo $trasnmition['key']; ?>") {
offLine = false;
break;
}
}
}
// you online do not show webcam
if (!offLine) {
$('#webcam').find('.alert').text("<?php echo __("You are online now, web cam is disabled"); ?>");
} else {
$('#webcam').find('.alert').text("<?php echo __("You are not online, loading webcam..."); ?>");
swfobject.embedSWF("<?php echo $global['webSiteRootURL']; ?>plugin/Live/view/webcam.swf", "webcam", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}
}
});
}
function saveStream() {
modal.showPleaseWait();
@ -351,9 +323,6 @@ $global['doNotLoadPlayer'] = 1;
$('.btnSaveStream').click(function() {
saveStream();
});
$('#enableWebCam').click(function() {
amIOnline();
});
<?php
echo PlayerSkins::getStartPlayerJS("", "", true);

View file

@ -57,7 +57,7 @@ if (empty($_GET['p'])) {
$lt = LiveTransmition::getFromKey($name);
if(!empty($lt)){
if(!empty($lt) && !empty($lt['users_id'])){
$name = Live::cleanUpKey($_POST['name']);
if($name == $lt['key']){
$user = new User($lt['users_id']);
@ -67,7 +67,7 @@ if (empty($_GET['p'])) {
_error_log("NGINX ON Publish encryption token keys doe not matchd: {$name} == {$lt['key']}");
}
}else{
_error_log("NGINX ON Publish encryption token error livetransmition error: [{$name}]");
_error_log("NGINX ON Publish encryption token error livetransmition error: [{$name}] ".json_encode($lt));
}
}
}
@ -97,7 +97,7 @@ if (empty($_POST['name']) && !empty($_GET['name'])) {
if (empty($_POST['name']) && !empty($_GET['key'])) {
$_POST['name'] = $_GET['key'];
}
if (strpos($_GET['p'], '/') !== false) {
if (!empty($_GET['p']) && strpos($_GET['p'], '/') !== false) {
$parts = explode("/", $_GET['p']);
if (!empty($parts[1])) {
$_GET['p'] = $parts[0];
@ -177,7 +177,7 @@ if (!empty($obj) && empty($obj->error)) {
_error_log("NGINX Live::on_publish end");
if (AVideoPlugin::isEnabledByName('YPTSocket')) {
$array = setLiveKey($lth->getKey(), $lth->getLive_servers_id());
ob_end_flush();
@ob_clean();
_ob_start();
$lth = new LiveTransmitionHistory($obj->liveTransmitionHistory_id);
$m3u8 = Live::getM3U8File($lth->getKey(), false,true);
@ -187,7 +187,6 @@ if (!empty($obj) && empty($obj->error)) {
include "{$global['systemRootPath']}plugin/Live/on_publish_socket_notification.php";
} else {
$command = get_php(). " {$global['systemRootPath']}plugin/Live/on_publish_socket_notification.php '$users_id' '$m3u8' '{$obj->liveTransmitionHistory_id}'";
_error_log("NGINX Live::on_publish YPTSocket start ($command)");
$pid = execAsync($command);
_error_log("NGINX Live::on_publish YPTSocket end {$pid}");

View file

@ -58,7 +58,8 @@ if (strpos($_GET['p'], '/') !== false) {
}
Live::deleteStatsCache(true);
$row = LiveTransmitionHistory::getLatest($_POST['name'], $row['live_servers_id'], true);
$live_servers_id = Live::getLiveServersIdRequest();
$row = LiveTransmitionHistory::getLatest($_POST['name'], $live_servers_id, true);
$insert_row = LiveTransmitionHistory::finishFromTransmitionHistoryId($row['id']);
_error_log("NGINX ON Publish Done finishFromTransmitionHistoryId {$_POST['name']} id={$row['id']} key={$row['key']} live_servers_id={$row['live_servers_id']} insert_row={$insert_row}");
Live::killIfIsRunning($row['key']);
@ -67,4 +68,8 @@ $parameters = Live::getLiveParametersFromKey($array['key']);
$array['cleanKey'] = $parameters['cleanKey'];
$array['stats'] = LiveTransmitionHistory::getStatsAndRemoveApplication($row['id']);
$socketObj = Live::notifySocketStats("socketLiveOFFCallback", $array);
AVideoPlugin::on_publish_done($row['id'], $row['users_id'], $row['key'], $row['live_servers_id']);
if(empty($row)){
_error_log("NGINX ON Publish Done error LiveTransmitionHistory::getLatest({$_POST['name']}, $live_servers_id, true);");
}else{
AVideoPlugin::on_publish_done($row['id'], $row['users_id'], $row['key'], $row['live_servers_id']);
}

View file

@ -239,15 +239,24 @@ class Message implements MessageComponentInterface {
}
private function shouldPropagateInfo($row) {
global $_shouldPropagateInfoLastMessage;
if (!empty($row['yptDeviceId']) && preg_match('/^unknowDevice.*/', $row['yptDeviceId'])) {
$_shouldPropagateInfoLastMessage = 'unknowDevice';
return false;
}
if (!empty($row['isCommandLine'])) {
$_shouldPropagateInfoLastMessage = 'isCommandLine';
return false;
}
return true;
}
private function getShouldPropagateInfoLastMessage() {
global $_shouldPropagateInfoLastMessage;
return $_shouldPropagateInfoLastMessage;
}
public function msgToResourceId($msg, $resourceId, $type = "", $totals = array()) {
global $onMessageSentTo, $SocketDataObj;
if (empty($resourceId)) {
@ -261,7 +270,7 @@ class Message implements MessageComponentInterface {
}
if (!$this->shouldPropagateInfo($row)) {
_log_message("msgToResourceId: we wil NOT send the message to resourceId=({$resourceId}) {$type}");
_log_message("msgToResourceId: we wil NOT send the message to resourceId=({$resourceId}) [{$type}] ".$this->getShouldPropagateInfoLastMessage());
}
if (!is_array($msg)) {
@ -437,17 +446,10 @@ class Message implements MessageComponentInterface {
}
$rows = dbGetAllResourcesIdFromLive($live_key, $live_servers_id);
$return = $this->getTotals();
$totals = $this->getTotals();
$info = array(
'webSocketServerVersion' => $SocketDataObj->serverVersion,
'socket_users_id' => $users_id,
'socket_resourceId' => $resourceId,
);
$autoUpdateOnHTML = array_merge($info, $return);
foreach ($rows as $value) {
$this->msgToResourceId($msg, $value['resourceId'], \SocketMessageType::ON_LIVE_MSG);
$this->msgToResourceId($msg, $value['resourceId'], \SocketMessageType::ON_LIVE_MSG, $totals);
}
}

View file

@ -196,7 +196,11 @@ class YPTSocket extends PluginAbstract {
$port = $socketobj->port;
$protocol = "ws";
$scheme = parse_url($global['webSiteRootURL'], PHP_URL_SCHEME);
if (strtolower($scheme) === 'https') {
if($address == 'avideo'){
$protocol = "wss";
$dockerVars = getDockerVars();
$address = $dockerVars->SERVER_NAME;
}else if (strtolower($scheme) === 'https') {
$protocol = "wss";
}
if (empty($webSocketToken)) {