diff --git a/.gitignore b/.gitignore index e91c62c4ac..fd99267b49 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,5 @@ view/videoComments_bkp.php /.compose/ test.php /plugin/JosephZ/ +/Encoder/ +/.env diff --git a/Dockerfile b/Dockerfile index 6a5edee48f..0fe3b6e8aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,94 +10,94 @@ LABEL maintainer="TRW " \ ARG DEBIAN_FRONTEND=noninteractive -ENV DB_MYSQL_HOST database -ENV DB_MYSQL_PORT 3306 -ENV DB_MYSQL_NAME avideo -ENV DB_MYSQL_USER avideo -ENV DB_MYSQL_PASSWORD avideo - -ENV SERVER_NAME localhost -ENV ENABLE_PHPMYADMIN yes -ENV CREATE_TLS_CERTIFICATE yes -ENV TLS_CERTIFICATE_FILE /etc/apache2/ssl/localhost.crt -ENV TLS_CERTIFICATE_KEY /etc/apache2/ssl/localhost.key -ENV CONTACT_EMAIL admin@localhost -ENV SYSTEM_ADMIN_PASSWORD password -ENV WEBSITE_TITLE AVideo -ENV MAIN_LANGUAGE en_US - -ENV HTTPS_PORT $HTTPS_PORT +ARG SOCKET_PORT +ARG HTTP_PORT +ARG HTTPS_PORT +ARG NGINX_RTMP_PORT +ARG NGINX_HTTP_PORT +ARG NGINX_HTTPS_PORT +ARG DB_MYSQL_HOST +ARG DB_MYSQL_PORT +ARG DB_MYSQL_NAME +ARG DB_MYSQL_USER +ARG DB_MYSQL_PASSWORD +ARG SERVER_NAME +ARG CREATE_TLS_CERTIFICATE +ARG TLS_CERTIFICATE_FILE +ARG TLS_CERTIFICATE_KEY +ARG CONTACT_EMAIL +ARG SYSTEM_ADMIN_PASSWORD +ARG WEBSITE_TITLE +ARG MAIN_LANGUAGE # Retrieve package list RUN apt update # Install dependencies RUN apt-get update -y && apt-get upgrade -y \ - && apt install -y --no-install-recommends ca-certificates apt-transport-https software-properties-common curl \ + && apt install -y --no-install-recommends dos2unix bash-completion lsof 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-curl php8.1-gd php8.1-intl \ - php-zip mysql-client ffmpeg git libimage-exiftool-perl libapache2-mod-xsendfile -y && a2enmod xsendfile && cd /var/www/html \ - && git clone https://github.com/WWBN/AVideo.git \ + && 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 && chown www-data:www-data /var/www/html/AVideo/plugin && chmod 755 /var/www/html/AVideo/plugin \ + && 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 COPY deploy/apache/avideo.conf /etc/apache2/sites-enabled/000-default.conf -COPY deploy/apache/phpmyadmin.conf /etc/apache2/conf-available/phpmyadmin.conf COPY deploy/docker-entrypoint /usr/local/bin/docker-entrypoint COPY deploy/wait-for-db.php /usr/local/bin/wait-for-db.php -COPY admin /var/www/html/AVideo/admin -COPY feed /var/www/html/AVideo/feed -COPY install /var/www/html/AVideo/install -COPY locale /var/www/html/AVideo/locale -COPY node_modules /var/www/html/AVideo/node_modules -COPY objects /var/www/html/AVideo/objects -COPY plugin /var/www/html/AVideo/plugin -COPY storage /var/www/html/AVideo/storage -COPY updatedb /var/www/html/AVideo/updatedb -COPY vendor /var/www/html/AVideo/vendor -COPY view /var/www/html/AVideo/view -COPY _config.yml /var/www/html/AVideo -COPY .htaccess /var/www/html/AVideo -COPY CNAME /var/www/html/AVideo -COPY LICENSE /var/www/html/AVideo -COPY README.md /var/www/html/AVideo -COPY web.config /var/www/html/AVideo -COPY index.php /var/www/html/AVideo -COPY git.json.php /var/www/html/AVideo -COPY sw.js /var/www/html/AVideo/ +# Install nginx +RUN apt-get install build-essential libssl-dev libpcre3 libpcre3-dev wget -y \ + && apt-get install --reinstall zlib1g zlib1g-dev -y \ + && mkdir /var/www/tmp && chmod -R 777 /var/www/tmp \ + && mkdir /HLS && mkdir /HLS/live && chmod -R 777 /HLS + +RUN mkdir ~/build \ + && cd ~/build \ + && git clone https://github.com/arut/nginx-rtmp-module.git \ + && git clone https://github.com/nginx/nginx.git \ + && cd nginx \ + && ./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\ + && cd /usr/local/nginx/html && wget https://youphp.tube/docs/stat.xsl + +COPY deploy/nginx/nginx.conf /usr/local/nginx/conf/nginx.conf + +COPY deploy/crontab /etc/cron.d/crontab +RUN chmod 0644 /etc/cron.d/crontab # Configure AVideo -RUN chmod 755 /usr/local/bin/docker-entrypoint && \ +RUN dos2unix /usr/local/bin/docker-entrypoint && \ + chmod 755 /usr/local/bin/docker-entrypoint && \ + chmod +x /usr/local/bin/docker-entrypoint && \ pip3 install youtube-dl && \ - cd /var/www/html/AVideo && \ - git config --global advice.detachedHead false && \ - git clone https://github.com/WWBN/AVideo-Encoder.git Encoder && \ - chown -R www-data:www-data /var/www/html/AVideo && \ - cd /var/www/html/AVideo/plugin/User_Location/install && \ - unzip install.zip && \ sed -i 's/^post_max_size.*$/post_max_size = 10G/' /etc/php/8.1/apache2/php.ini && \ sed -i 's/^upload_max_filesize.*$/upload_max_filesize = 10G/' /etc/php/8.1/apache2/php.ini && \ + sed -i 's/^max_execution_time.*$/max_execution_time = 7200/' /etc/php/8.1/apache2/php.ini && \ + sed -i 's/^memory_limit.*$/memory_limit = 512M/' /etc/php/8.1/apache2/php.ini && \ a2enmod rewrite expires headers ssl xsendfile +# Add Apache configuration +RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf + VOLUME /var/www/tmp RUN mkdir -p /var/www/tmp && \ chown www-data:www-data /var/www/tmp && \ chmod 777 /var/www/tmp -VOLUME /var/www/html/AVideo/videos -RUN mkdir -p /var/www/html/AVideo/videos && \ - chown www-data:www-data /var/www/html/AVideo/videos && \ - chmod 777 /var/www/html/AVideo/videos - WORKDIR /var/www/html/AVideo/ +EXPOSE $SOCKET_PORT +EXPOSE $HTTP_PORT EXPOSE $HTTPS_PORT +EXPOSE $NGINX_RTMP_PORT +EXPOSE $NGINX_HTTPS_PORT ENTRYPOINT ["/usr/local/bin/docker-entrypoint"] CMD ["apache2-foreground"] diff --git a/deploy/apache/avideo.conf b/deploy/apache/avideo.conf index 097f159caa..567b254b53 100644 --- a/deploy/apache/avideo.conf +++ b/deploy/apache/avideo.conf @@ -1,29 +1,40 @@ - - ServerName SERVER_NAME + + ServerName localhost ServerAdmin CONTACT_EMAIL DocumentRoot "/var/www/html/AVideo" - ErrorLog /dev/stderr + CustomLog ${APACHE_LOG_DIR}/access.log combined TransferLog /dev/stdout - - RewriteEngine On - RewriteCond %{HTTPS} off - RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} - - - ServerName SERVER_NAME + + 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 - + + ServerName SERVER_NAME + ServerAdmin CONTACT_EMAIL + DocumentRoot "/var/www/html/AVideo" + ErrorLog /dev/stderr + CustomLog ${APACHE_LOG_DIR}/access.log combined + TransferLog /dev/stdout + + + ServerName SERVER_NAME + ServerAdmin CONTACT_EMAIL + DocumentRoot "/var/www/html/AVideo" + ErrorLog /dev/stderr + CustomLog ${APACHE_LOG_DIR}/access.log combined + TransferLog /dev/stdout + Options Indexes FollowSymLinks XSendFile on diff --git a/deploy/apache/localhost.conf b/deploy/apache/localhost.conf new file mode 100644 index 0000000000..d66c35ef74 --- /dev/null +++ b/deploy/apache/localhost.conf @@ -0,0 +1,33 @@ + + ServerName SERVER_NAME + ServerAlias localhost + ServerAdmin CONTACT_EMAIL + DocumentRoot "/var/www/html/AVideo" + + ErrorLog /dev/stderr + CustomLog ${APACHE_LOG_DIR}/access.log combined + TransferLog /dev/stdout + + + ServerName SERVER_NAME + ServerAlias 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 + + + Options Indexes FollowSymLinks + XSendFile on + XSendFilePath /var/www/html/AVideo/ + AllowOverride All + Require all granted + Order Allow,Deny + Allow from All + diff --git a/deploy/crontab b/deploy/crontab new file mode 100644 index 0000000000..44d7e235e8 --- /dev/null +++ b/deploy/crontab @@ -0,0 +1,4 @@ +# m h dom mon dow command +1 1 * * * pip3 install --upgrade youtube-dl +* * * * * php /var/www/html/AVideo/plugin/Scheduler/run.php +#2 1 * * * php /var/www/html/AVideo/plugin/CDN/tools/moveMissingFiles.php \ No newline at end of file diff --git a/deploy/docker-entrypoint b/deploy/docker-entrypoint index 30de80e8fa..6e019debf8 100644 --- a/deploy/docker-entrypoint +++ b/deploy/docker-entrypoint @@ -2,6 +2,7 @@ echo "Starting AVideo Platform..." CONFIG_FILE=/etc/apache2/sites-enabled/000-default.conf +CONFIG_NGINX_FILE=/usr/local/nginx/conf/nginx.conf if [ "_${CREATE_TLS_CERTIFICATE}_" == "_yes_" ]; then echo "Generate Certificate..." @@ -42,18 +43,25 @@ if [ "_${CREATE_TLS_CERTIFICATE}_" == "_yes_" ]; then openssl x509 -in ${TLS_CERTIFICATE_FILE} -noout -text || true fi -echo "Configure Apache..." sed -i 's#SERVER_NAME#'${SERVER_NAME}'#' ${CONFIG_FILE} +sed -i 's#CONTACT_EMAIL#'${CONTACT_EMAIL}'#' ${CONFIG_FILE} +sed -i 's#server_name localhost _#server_name localhost _ '${SERVER_NAME}'#' ${CONFIG_NGINX_FILE} + +echo "Configure Apache..." sed -i 's#TLS_CERTIFICATE_FILE#'${TLS_CERTIFICATE_FILE}'#' ${CONFIG_FILE} sed -i 's#TLS_CERTIFICATE_KEY#'${TLS_CERTIFICATE_KEY}'#' ${CONFIG_FILE} -sed -i 's#CONTACT_EMAIL#'${CONTACT_EMAIL}'#' ${CONFIG_FILE} -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 "Configure Nginx..." +sed -i 's#ssl_certificate /etc/apache2/ssl/localhost.crt#ssl_certificate '${TLS_CERTIFICATE_FILE}'#' ${CONFIG_NGINX_FILE} +sed -i 's#ssl_certificate_key /etc/apache2/ssl/localhost.key#ssl_certificate_key '${TLS_CERTIFICATE_KEY}'#' ${CONFIG_NGINX_FILE} +sed -i 's#listen 1935#listen '${NGINX_RTMP_PORT}'#' ${CONFIG_NGINX_FILE} +sed -i 's#listen 8080#listen '${NGINX_HTTP_PORT}'#' ${CONFIG_NGINX_FILE} +sed -i 's#listen 8443#listen '${NGINX_HTTPS_PORT}'#' ${CONFIG_NGINX_FILE} + +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" php /usr/local/bin/wait-for-db.php @@ -62,14 +70,69 @@ if [ $? -ne 0 ]; then exit 1 fi -if [ -f /var/www/html/AVideo/videos/configuration.php ]; then - echo "Using existing configuration..." +if [ -f /var/www/html/AVideo/plugin/User_Location/install/install.sql ]; then + echo "Using existing location tables..." else - echo "Create new configuration..." - cd /var/www/html/AVideo/install/ - php ./cli.php - cd /var/www/html/AVideo/ + echo "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 + # Configure AVideo permissions + chown -R www-data:www-data /var/www/html/AVideo fi +if [ -f /var/www/html/AVideo/Encoder/index.php ]; then + echo "Using existing Encoder configuration..." +else + echo "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..." +else + echo "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..." +cd /var/www/html/AVideo/install/ +php ./cli.php +cd /var/www/html/AVideo/ + +echo "lets encrypt apache ${SERVER_NAME}" +certbot --apache --non-interactive --agree-tos --register-unsafely-without-email --redirect --keep-until-expiring -d ${SERVER_NAME} + +/etc/init.d/apache2 stop + +if [ -f /usr/local/nginx/sbin/nginx ]; then + /usr/local/nginx/sbin/nginx -s stop + echo "lets encrypt nginx ${SERVER_NAME}" + apt-get install -y --no-install-recommends python3-certbot-nginx + mv /usr/sbin/nginx /usr/sbin/nginx.old && cp /usr/local/nginx/sbin/nginx /usr/sbin/nginx + mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old && cp /usr/local/nginx/conf/nginx.conf /etc/nginx/nginx.conf + certbot --nginx --non-interactive --agree-tos --nginx-server-root /usr/local/nginx/conf --no-redirect --register-unsafely-without-email --keep-until-expiring -d $SERVER_NAME + sed -i 's/listen 443 ssl/listen 8443 ssl/g' /usr/local/nginx/conf/nginx.conf + echo "nginx start" + /usr/local/nginx/sbin/nginx -s stop && sleep 3 && /usr/local/nginx/sbin/nginx +fi + +nohup php /var/www/html/AVideo/plugin/YPTSocket/server.php & +echo "socket done" + +echo "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 "Deny from all" > /var/www/html/AVideo/.compose/.htaccess + apache2-foreground +echo "apache2-foreground done" + +cd /var/www/html/AVideo/install && php updatedb.php && installPluginsTables.php 4 +cd /var/www/html/AVideo/Encoder/install && php reencodeAllVideos.php + #eof \ No newline at end of file diff --git a/deploy/nginx/nginx.conf b/deploy/nginx/nginx.conf new file mode 100644 index 0000000000..de39b50f52 --- /dev/null +++ b/deploy/nginx/nginx.conf @@ -0,0 +1,142 @@ +user www-data; +worker_processes 1; +error_log logs/error.log debug; +events { + worker_connections 1024; +} +rtmp { + server { + listen 1935; + buflen 1000ms; + chunk_size 4096; + ping_timeout 30s; + ### Use case option (max_streams; default is 32 ) + #max_streams 10; + allow play all; + #creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments + application live { + allow play all; + live on; + hls on; + hls_nested on; + hls_path /HLS/live; + hls_playlist_length 60m; + hls_fragment 4s; + drop_idle_publisher 30s; + sync 500ms; + #Experimental. Force dropped stream, or ended stream from being watched. (idle_streams) + #idle_streams off; + on_publish http://127.0.0.1/plugin/Live/on_publish.php; + on_publish_done http://127.0.0.1/plugin/Live/on_publish_done.php; + on_play http://127.0.0.1/plugin/Live/on_play.php; + on_record_done http://127.0.0.1/plugin/Live/on_record_done.php; + + #exec ffmpeg -re -i rtmp://localhost/live/$name -c:v libx264 -preset veryfast -c:a copy -f hls -hls_time 5 -hls_list_size 0 -f flv rtmp://localhost/adaptive/$name_hi; + #exec ffmpeg -re -i rtmp://localhost/live/$name + # -c:v libx264 -vf scale=-2:240 -r 20 -g 40 -keyint_min 40 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 400k -maxrate 700k -bufsize 1400k -c:a aac -strict -2 -b:a 96k -f flv rtmp://localhost/adaptive/$name_low + # -c:v libx264 -vf scale=-2:480 -r 30 -g 60 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 1200k -maxrate 2100k -bufsize 4200k -c:a aac -strict -2 -b:a 128k -f flv rtmp://localhost/adaptive/$name_mid + # -c:v libx264 -vf scale=-2:720 -r 30 -g 60 -keyint_min 48 -sc_threshold 0 -bf 3 -b_strategy 2 -b:v 2400k -maxrate 3000k -bufsize 6000k -c:a aac -strict -2 -b:a 128k -f flv rtmp://localhost/adaptive/$name_hi; + + recorder video { + record all manual; + record_path /var/www/tmp; + record_notify on; + record_max_size 2048M; + record_suffix -%d-%b-%y-%T.flv; + } + + ### Record Audio Separately ( For podcast ) + #recorder audio { + # record audio; + # record_path /var/www/tmp; + # record_max_size 1024M; + # record_suffix -%d-%b-%y-%T.mp3; + #} + } + + #application adaptive { + # live on; + # hls on; + + # hls_path /HLS/live; + # hls_nested on; + # hls_playlist_length 10m; + # allow play all; + # allow publish 127.0.0.1; + # deny publish all; + # hls_variant _hi BANDWIDTH=264000,RESOLUTION=1280x720; # this is for line 34 only, do not uncomment it + # hls_variant _low BANDWIDTH=900000; + # hls_variant _mid BANDWIDTH=2400000; + # hls_variant _hi BANDWIDTH=3500000; + #} + } +} +http { + include mime.types; + default_type application/octet-stream; + server { + listen 8080; + server_name localhost _; + #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/live/my-stream-key/index.m3u8" + location /live { + expires 60; + add_header 'Cache-Control' 'public'; + location ~ \.m3u8$ { + expires -1; + # Disable cache + add_header 'Cache-Control' 'no-cache'; + # CORS setup + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length'; + } + + # CORS setup + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length'; + + # allow CORS preflight requests + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + types { + application/vnd.apple.mpegurl m3u8; + } + alias /HLS/live; + } + #allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats" + #location /stats { + # stub_status; + #} + location /stat { + rtmp_stat all; + rtmp_stat_stylesheet stat.xsl; + } + location /stat.xsl { + root html; + } + location /control { + # replace this with the IP of your AVideo site + allow 127.0.0.1; + deny all; + rtmp_control all; + } + #allows us to host some webpages which can show our videos: "http://my-ip/my-page.html" + location / { + root html; + index index.html index.htm; + } + + #location ~ \.php$ { + # include /etc/nginx/snippets/fastcgi-php.conf; + # fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + #} + listen 8443 ssl; + ssl_certificate /etc/apache2/ssl/localhost.crt; + ssl_certificate_key /etc/apache2/ssl/localhost.key; + + } +} diff --git a/deploy/wait-for-db.php b/deploy/wait-for-db.php index 97e2eb8f1d..508b6e5958 100644 --- a/deploy/wait-for-db.php +++ b/deploy/wait-for-db.php @@ -11,7 +11,7 @@ $db_user = getenv("DB_MYSQL_USER"); $db_pass = getenv("DB_MYSQL_PASSWORD"); while (!$connected) { - echo "Checking database connection...."; + echo "Checking database connection.... $db_host, $db_user"; $mysqli = @new mysqli($db_host, $db_user, $db_pass, $db_name, $db_port); if ($mysqli !== false) { echo "OK\n"; diff --git a/docker-compose.yml b/docker-compose.yml index 878fcdb82f..57a02fdb47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,50 +1,67 @@ version: '3' services: - web: - build: . + avideo: + build: + context: . + args: + SOCKET_PORT: ${SOCKET_PORT} + HTTP_PORT: ${HTTP_PORT} + HTTPS_PORT: ${HTTPS_PORT} + NGINX_RTMP_PORT: ${NGINX_RTMP_PORT} + NGINX_HTTP_PORT: ${NGINX_HTTP_PORT} + NGINX_HTTPS_PORT: ${NGINX_HTTPS_PORT} + DB_MYSQL_HOST: ${DB_MYSQL_HOST} + DB_MYSQL_PORT: ${DB_MYSQL_PORT} + DB_MYSQL_NAME: ${DB_MYSQL_NAME} + DB_MYSQL_USER: ${DB_MYSQL_USER} + DB_MYSQL_PASSWORD: ${DB_MYSQL_PASSWORD} + SERVER_NAME: ${SERVER_NAME} + CREATE_TLS_CERTIFICATE: ${CREATE_TLS_CERTIFICATE} + TLS_CERTIFICATE_FILE: ${TLS_CERTIFICATE_FILE} + TLS_CERTIFICATE_KEY: ${TLS_CERTIFICATE_KEY} + CONTACT_EMAIL: ${CONTACT_EMAIL} + SYSTEM_ADMIN_PASSWORD: ${SYSTEM_ADMIN_PASSWORD} + WEBSITE_TITLE: ${WEBSITE_TITLE} + MAIN_LANGUAGE: ${MAIN_LANGUAGE} restart: "unless-stopped" environment: + SOCKET_PORT: ${SOCKET_PORT:-2053} HTTP_PORT: ${HTTP_PORT:-80} - HTTPS_PORT: ${HTTPS_PORT:-443} - DB_MYSQL_HOST: "database" + HTTPS_PORT: ${HTTP_PORT:-443} + NGINX_RTMP_PORT: ${NGINX_RTMP_PORT:-1935} + NGINX_HTTP_PORT: ${NGINX_HTTP_PORT:-8080} + NGINX_HTTPS_PORT: ${NGINX_HTTPS_PORT:-8443} + DB_MYSQL_HOST: "${DB_MYSQL_HOST:-database}" DB_MYSQL_PORT: ${DB_MYSQL_PORT:-3306} - DB_MYSQL_NAME: "avideo" - DB_MYSQL_USER: "avideo" - DB_MYSQL_PASSWORD: "avideo" - SERVER_NAME: "localhost" - ENABLE_PHPMYADMIN: "yes" - CREATE_TLS_CERTIFICATE: "yes" - TLS_CERTIFICATE_FILE: "/etc/apache2/ssl/localhost.crt" - TLS_CERTIFICATE_KEY: "/etc/apache2/ssl/localhost.key" - CONTACT_EMAIL: "admin@localhost" - SYSTEM_ADMIN_PASSWORD: "password" - WEBSITE_TITLE: "AVideo" - MAIN_LANGUAGE: "en_US" + DB_MYSQL_NAME: "${DB_MYSQL_NAME:-avideo}" + DB_MYSQL_USER: "${DB_MYSQL_USER:-avideo}" + DB_MYSQL_PASSWORD: "${DB_MYSQL_PASSWORD:-avideo}" + SERVER_NAME: "${SERVER_NAME:-localhost}" + 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}" + CONTACT_EMAIL: "${CONTACT_EMAIL:-admin@localhost}" + SYSTEM_ADMIN_PASSWORD: "${SYSTEM_ADMIN_PASSWORD:-password}" + WEBSITE_TITLE: "${WEBSITE_TITLE:-AVideo}" + MAIN_LANGUAGE: "${MAIN_LANGUAGE:-en_US}" + env_file: + - .env ports: - - '${HTTP_PORT}:80' - - '${HTTPS_PORT}:443' + - "${SOCKET_PORT:-2053}:2053" + - "${HTTP_PORT:-80}:80" + - "${HTTPS_PORT:-443}:443" + - "${NGINX_RTMP_PORT:-1935}:1935" + - "${NGINX_HTTP_PORT:-8080}:8080" + - "${NGINX_HTTPS_PORT:-8443}:8443" volumes: - - "./var/www/avideo:/var/www/avideo" - depends_on: - - database - - phpmyadmin - networks: - - app_net - - phpmyadmin: - image: "phpmyadmin/phpmyadmin" - restart: "unless-stopped" - environment: - PMA_ABSOLUTE_URI: "https://localhost/phpmyadmin" - PMA_HOST: "database" - PMA_PORT: 3306 - PMA_CONTROLUSER: "avideo" - PMA_CONTROLPASS: "avideo" - PMA_PMADB: "avideo" - HIDE_PHP_VERSION: "true" + - "./:/var/www/html/AVideo" + - "./.compose/videos:/var/www/html/AVideo/videos" + - "./.compose/encoder:/var/www/html/AVideo/Encoder" + - "./.compose/letsencrypt:/etc/letsencrypt/" depends_on: - database + - database_encoder networks: - app_net @@ -62,6 +79,20 @@ services: networks: - app_net + database_encoder: + image: "mariadb:latest" + restart: "unless-stopped" + environment: + MYSQL_RANDOM_ROOT_PASSWORD: "yes" + MYSQL_INITDB_SKIP_TZINFO: 1 + MYSQL_DATABASE: "avideo_encoder" + MYSQL_USER: "avideo" + MYSQL_PASSWORD: "avideo" + volumes: + - ./.compose/db_encoder:/var/lib/mysql + networks: + - app_net + networks: app_net: - driver: bridge + driver: bridge \ No newline at end of file diff --git a/env.example b/env.example index e8ca8518f9..33a14fc3cb 100644 --- a/env.example +++ b/env.example @@ -1,5 +1,13 @@ -webSiteRootURL={webSiteRootURL} -# Exposed HTTP port -HTTP_PORT={HTTP_PORT} -HTTPS_PORT={HTTPS_PORT} -Socket_PORT={Socket_PORT} \ No newline at end of file +SERVER_NAME=localhost + +SOCKET_PORT=2053 +HTTP_PORT=80 +HTTPS_PORT=443 +NGINX_RTMP_PORT=1935 +NGINX_HTTP_PORT=8080 +NGINX_HTTPS_PORT=8443 +DB_MYSQL_HOST=database +DB_MYSQL_PORT=3306 +DB_MYSQL_NAME=avideo +DB_MYSQL_USER=avideo +DB_MYSQL_PASSWORD=avideo \ No newline at end of file diff --git a/install/cli.php b/install/cli.php index bfe2938599..bb0854afdd 100644 --- a/install/cli.php +++ b/install/cli.php @@ -1,5 +1,7 @@ $value) { + if($value['videos_id']==$videos_id){ + return $key; + } + } + } + return 0; + } public static function getVideosIDFromPlaylistLight($playlists_id) { global $global, $getVideosIDFromPlaylistLight; diff --git a/plugin/AVideoPlugin.php b/plugin/AVideoPlugin.php index bf75cdb572..a530a27c51 100644 --- a/plugin/AVideoPlugin.php +++ b/plugin/AVideoPlugin.php @@ -300,7 +300,7 @@ class AVideoPlugin // need to add dechex because some times it return an negative value and make it fails on javascript playlists if (!isset($pluginIsLoaded[$name]) && empty($forceReload)) { $pluginIsLoaded[$name] = false; - if (file_exists($loadPluginFile)) { + if (file_exists($loadPluginFile) && !class_exists($name)) { require_once $loadPluginFile; if (class_exists($name)) { $code = "\$p = new {$name}();"; diff --git a/plugin/Gallery/view/mainAreaTags.php b/plugin/Gallery/view/mainAreaTags.php index 6784e4283c..a8ba7f5289 100644 --- a/plugin/Gallery/view/mainAreaTags.php +++ b/plugin/Gallery/view/mainAreaTags.php @@ -43,7 +43,7 @@ if ($totalPages < $page) {

diff --git a/plugin/PlayLists/PlayLists.php b/plugin/PlayLists/PlayLists.php index 9697cd02ed..5dffbe9968 100644 --- a/plugin/PlayLists/PlayLists.php +++ b/plugin/PlayLists/PlayLists.php @@ -406,8 +406,6 @@ class PlayLists extends PluginAbstract { foreach ($fullData as $row) { $rows[] = $row; } - } else { - die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $rows; } diff --git a/plugin/Scheduler/Scheduler.php b/plugin/Scheduler/Scheduler.php index aec81f9595..83be1b155d 100644 --- a/plugin/Scheduler/Scheduler.php +++ b/plugin/Scheduler/Scheduler.php @@ -30,7 +30,7 @@ class Scheduler extends PluginAbstract { } public function getPluginVersion() { - return "4.1"; + return "4.2"; } public function updateScript() { @@ -56,6 +56,13 @@ class Scheduler extends PluginAbstract { sqlDal::writeSql(trim($value)); } } + if (AVideoPlugin::compareVersion($this->getName(), "4.2") < 0) { + $sqls = file_get_contents($global['systemRootPath'] . 'plugin/Scheduler/install/updateV4.2.sql'); + $sqlParts = explode(";", $sqls); + foreach ($sqlParts as $value) { + sqlDal::writeSql(trim($value)); + } + } return true; } diff --git a/plugin/Scheduler/install/install.sql b/plugin/Scheduler/install/install.sql index a8f93a2762..a757b7189a 100644 --- a/plugin/Scheduler/install/install.sql +++ b/plugin/Scheduler/install/install.sql @@ -13,6 +13,7 @@ CREATE TABLE IF NOT EXISTS `scheduler_commands` ( `repeat_hour` INT NULL, `repeat_day_of_month` INT NULL, `repeat_month` INT NULL, + `repeat_day_of_week` INT NULL, `day_of_week` INT NULL, `videos_id` INT(11) NULL, PRIMARY KEY (`id`), diff --git a/plugin/Scheduler/install/updateV4.2.sql b/plugin/Scheduler/install/updateV4.2.sql new file mode 100644 index 0000000000..c8a0cca3b2 --- /dev/null +++ b/plugin/Scheduler/install/updateV4.2.sql @@ -0,0 +1,2 @@ +ALTER TABLE `scheduler_commands` +ADD COLUMN `repeat_day_of_week` INT(11) NULL DEFAULT NULL; \ No newline at end of file diff --git a/plugin/VideoTags/VideoTags.php b/plugin/VideoTags/VideoTags.php index 96a6484417..c75e642bb4 100644 --- a/plugin/VideoTags/VideoTags.php +++ b/plugin/VideoTags/VideoTags.php @@ -116,6 +116,18 @@ class VideoTags extends PluginAbstract { static function getAllVideosIdFromTagsId($tags_id) { return TagsHasVideos::getAllVideosIdFromTagsId($tags_id); } + + static function getVideoIndexFromTagsId($tags_id, $videos_id) { + if(!empty($videos_id)){ + $pl = self::getAllVideosFromTagsId($tags_id); + foreach ($pl as $key => $value) { + if($value['videos_id']==$videos_id){ + return $key; + } + } + } + return 0; + } static function getAllVideosFromTagsId($tags_id) { return TagsHasVideos::getAllVideosFromTagsId($tags_id); @@ -216,7 +228,7 @@ $(\'#inputTags' . $tagTypesId . '\').tagsinput({ return $_isUserSubscribedTags[$users_id][$tags_id]; } - public static function getButton($tags_id, $btnClass = 'btn-xs', $btnClassPrimary = 'btn-primary', $btnClassSuccess = 'btn-success', $btnClassDefault = 'btn-default'){ + public static function getButton($tags_id, $videos_id = 0, $btnClass = 'btn-xs', $btnClassPrimary = 'btn-primary', $btnClassSuccess = 'btn-success', $btnClassDefault = 'btn-default'){ if(empty($tags_id)){ return ''; } @@ -235,7 +247,9 @@ $(\'#inputTags' . $tagTypesId . '\').tagsinput({ $playAllLink = '#'; $playAllClass = 'hidden'; if(AVideoPlugin::isEnabledByName('PlayLists')){ - $playAllLink = PlayLists::getTagLink($tags_id, $embed = false, $playlist_index = null); + $playlist_index = self::getVideoIndexFromTagsId($tags_id, $videos_id); + //var_dump($videos_id,getVideos_id(), $playlist_index);exit; + $playAllLink = PlayLists::getTagLink($tags_id, false, $playlist_index); $playAllClass = ''; } @@ -248,7 +262,6 @@ $(\'#inputTags' . $tagTypesId . '\').tagsinput({ $btnFile = $global['systemRootPath'] . 'plugin/VideoTags/subscribeBtn.html'; $email = User::getMail(); $subs = self::isUserSubscribed($users_id, $tags_id); - if (!empty($subs)) { if (!empty($subs['notify'])) { $notify = 'notify'; @@ -378,7 +391,7 @@ $(\'#inputTags' . $tagTypesId . '\').tagsinput({ if($obj->disableTagsSubscriptions){ $strT .= self::getTagHTMLLink($value['tags_id'], $value['total']); }else{ - $strT .= self::getButton($value['tags_id']); + $strT .= self::getButton($value['tags_id'], $videos_id); } } if (!empty($strT)) { diff --git a/plugin/VideoTags/pluginMenu.html b/plugin/VideoTags/pluginMenu.html index f612e06272..7ee7f456ca 100644 --- a/plugin/VideoTags/pluginMenu.html +++ b/plugin/VideoTags/pluginMenu.html @@ -1,2 +1,4 @@ - \ No newline at end of file + diff --git a/plugin/YPTSocket/server.php b/plugin/YPTSocket/server.php index 5a79b396ac..e7d594b4e9 100644 --- a/plugin/YPTSocket/server.php +++ b/plugin/YPTSocket/server.php @@ -56,7 +56,9 @@ _error_log("Starting Socket server at port {$SocketDataObj->port}"); $scheme = parse_url($global['webSiteRootURL'], PHP_URL_SCHEME); echo "Starting AVideo Socket server version {$SocketDataObj->serverVersion} on port {$SocketDataObj->port}" . PHP_EOL; -if (strtolower($scheme) !== 'https' || !empty($SocketDataObj->forceNonSecure)) { +$sslFound = file_exists($SocketDataObj->server_crt_file) && is_readable($SocketDataObj->server_crt_file) && file_exists($SocketDataObj->server_key_file) && is_readable($SocketDataObj->server_key_file); + +if ((strtolower($scheme) !== 'https' || !empty($SocketDataObj->forceNonSecure)) && !$sslFound) { echo "Your socket server does NOT use a secure connection" . PHP_EOL; $server = IoServer::factory( new HttpServer( diff --git a/view/img/audio_wave_jpg.webp b/view/img/audio_wave_jpg.webp new file mode 100644 index 0000000000..a198ae0eb5 Binary files /dev/null and b/view/img/audio_wave_jpg.webp differ diff --git a/view/managerVideos_form.php b/view/managerVideos_form.php index 24cc2457bb..0365392e7d 100644 --- a/view/managerVideos_form.php +++ b/view/managerVideos_form.php @@ -109,6 +109,7 @@