diff --git a/.gitignore b/.gitignore
index 5e6e38280a..6f5b141e2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,78 +1,78 @@
-/.scannerwork/
-/YouPHPTube.code-workspace
-/git.php
-/iptvsource_one_one.csv
-/nbproject/
-/nbproject/private/
-/plugin/AD_Server_Promote_Videos/
-/plugin/AWS_S3/
-/plugin/AudioTrackSwitcher/
-/plugin/AudioVisualizer/
-/plugin/AutoShare/
-/plugin/Backup/
-/plugin/Blackblaze_B2/
-/plugin/Bookmark/
-/plugin/Chat2/
-/plugin/CountryRedirect/
-/plugin/CreateUserManager/
-/plugin/Customize/
-/plugin/DIY/
-/plugin/DiskUploadQuota/
-/plugin/FTPAutoImport/
-/plugin/FTP_Storage/
-/plugin/FlixHouse/
-/plugin/GoogleAds_IMA/
-/plugin/IPDirectConnect/
-/plugin/IPTV/
-/plugin/ImportFromOtherVideoPlatform/
-/plugin/Layout/hamburguerMenu.php
-/plugin/Layout/navBarLateral.php
-/plugin/Layout/navbar.php
-/plugin/Layout/timer.php
-/plugin/LifeStreamLayout/
-/plugin/LiveCountdownEvent/
-/plugin/LiveOnlineUsers/
-/plugin/LiveUsers/
-/plugin/Livesearch/
-/plugin/LoginLDAP/
-/plugin/LoginLDAP_DYNA/
-/plugin/MP4ThumbsAndGif/
-/plugin/MP4ThumbsAndGifLocal/
-/plugin/Notifications/
-/plugin/PayPalToWatch/
-/plugin/PayPerView/
-/plugin/PayPerViewLive/
-/plugin/PointsSystem/
-/plugin/PromoteVideos/
-/plugin/ReturnToLastPosition/
-/plugin/SecondLife/
-/plugin/SecondWatch/
-/plugin/SecureVideosDirectory/
-/plugin/SendRecordedToEncoder/
-/plugin/SignUpAgreement/
-/plugin/Subscription/
-/plugin/SubtitleSwitcher/
-/plugin/SupportAuthor/
-/plugin/Tecorio/
-/plugin/User_Controll/
-/plugin/VideoDocuments/
-/plugin/VideoHLS/
-/plugin/VideoResolutionSwitcher/
-/plugin/VideoSpeed/
-/plugin/VideoThumbnails/
-/plugin/Video_Location_Block/
-/plugin/YPTStorage/
-/plugin/YouPHPTV/
-/plugin/ZoomMeetingRecorder/
-/plugin/oncologytube/
-/plugin/predefinedCategory/
-/plugin/FansSubscriptions/
-/videos/
-*.zip
-sitemap.xml
-/plugin/WebRTCLiveCam/
-/plugin/Wix/
-/plugin/Live/standAloneFiles/WebRTCServer/configuration.php
-/plugin/Fishr/
-/plugin/JoshWho/
-.DS_Store
+/.scannerwork/
+/YouPHPTube.code-workspace
+/git.php
+/iptvsource_one_one.csv
+/nbproject/
+/nbproject/private/
+/plugin/AD_Server_Promote_Videos/
+/plugin/AWS_S3/
+/plugin/AudioTrackSwitcher/
+/plugin/AudioVisualizer/
+/plugin/AutoShare/
+/plugin/Backup/
+/plugin/Blackblaze_B2/
+/plugin/Bookmark/
+/plugin/Chat2/
+/plugin/CountryRedirect/
+/plugin/CreateUserManager/
+/plugin/Customize/
+/plugin/DIY/
+/plugin/DiskUploadQuota/
+/plugin/FTPAutoImport/
+/plugin/FTP_Storage/
+/plugin/FlixHouse/
+/plugin/GoogleAds_IMA/
+/plugin/IPDirectConnect/
+/plugin/IPTV/
+/plugin/ImportFromOtherVideoPlatform/
+/plugin/Layout/hamburguerMenu.php
+/plugin/Layout/navBarLateral.php
+/plugin/Layout/navbar.php
+/plugin/Layout/timer.php
+/plugin/LifeStreamLayout/
+/plugin/LiveCountdownEvent/
+/plugin/LiveOnlineUsers/
+/plugin/LiveUsers/
+/plugin/Livesearch/
+/plugin/LoginLDAP/
+/plugin/LoginLDAP_DYNA/
+/plugin/MP4ThumbsAndGif/
+/plugin/MP4ThumbsAndGifLocal/
+/plugin/Notifications/
+/plugin/PayPalToWatch/
+/plugin/PayPerView/
+/plugin/PayPerViewLive/
+/plugin/PointsSystem/
+/plugin/PromoteVideos/
+/plugin/ReturnToLastPosition/
+/plugin/SecondLife/
+/plugin/SecondWatch/
+/plugin/SecureVideosDirectory/
+/plugin/SendRecordedToEncoder/
+/plugin/SignUpAgreement/
+/plugin/Subscription/
+/plugin/SubtitleSwitcher/
+/plugin/SupportAuthor/
+/plugin/Tecorio/
+/plugin/User_Controll/
+/plugin/VideoDocuments/
+/plugin/VideoHLS/
+/plugin/VideoResolutionSwitcher/
+/plugin/VideoSpeed/
+/plugin/VideoThumbnails/
+/plugin/Video_Location_Block/
+/plugin/YPTStorage/
+/plugin/YouPHPTV/
+/plugin/ZoomMeetingRecorder/
+/plugin/oncologytube/
+/plugin/predefinedCategory/
+/plugin/FansSubscriptions/
+/videos/
+*.zip
+sitemap.xml
+/plugin/WebRTCLiveCam/
+/plugin/Wix/
+/plugin/Live/standAloneFiles/WebRTCServer/configuration.php
+/plugin/Fishr/
+/plugin/JoshWho/
+.DS_Store
diff --git a/README.md b/README.md
index 111502c408..6904fe0bbd 100644
--- a/README.md
+++ b/README.md
@@ -1,173 +1,173 @@
-
-
-[](https://php.net/)
-[](https://github.com/WWBN/AVideo/releases)
-
-## Audio Video Platform
-AVideo is a term that means absolutely nothing, or anything video. Since it doesn't mean anything the brand simply is identifiable with audio video. AVideo Platform is an Audio and Video Platform or simply "A Video Platform".
-
-* AVideo - Audio Video
-* AVideo Platform - Audio Video Platform
-* OAVP - Online Audio Video Platform
-* OVP - Online Video Platform
-
-AVideo Platform is distributed as SaaS at AVideo.com, as an Enterprise Version, and as an Open-Source Project.
-
-## AN AVideo Platform Instance
-
-When we say a clone or copy of AVideo we mean an instance of AVideo Platform Enterprise or Open-Source and every instance of the AVideo Platform can be indexed as a network in the World Wide Broadcast Network Platform System.
-
-### AVideo trademark is FREE to use
-AVideo is a registered trademark owned by WWBN/PeachWiz (World Wide Broadcast Network) the media division of PeachWiz, Inc. and is freely distributable with any Enterprise or Open-Source AVideo Platform products provided by WWBN, and its permitted use is granted with GNU-GPL, CDDL open source licenses. Open-Source License can be viewed in this link.
-* Word Mark: AVIDEO
-* Translations: "AVideo" has no meaning in any foreign language.
-* Description: "AVideo" constitutes Audio Video.
-* Goods and Services: IC 009. US 021 023 026 036 038. G & S: Computer search engine software for searching online video content. FIRST USE: 20030602. FIRST USE IN COMMERCE: 20040112
-* Standard Characters: Claimed
-* Mark Drawing Code: (4) STANDARD CHARACTER MARK
-* Trademark Search Facility Classification Code: LETS-1 A A single letter, multiples of a single letter or in combination with a design
-* Serial Number: 77450549
-* Registration Number: 3625659
-
-#### About the project re-brand.
- Originally the open-source version was offered as YouPHPTube, and marketed as a YouTube Clone (after the popular video sharing site), we decided to rebrand our open-source audio video platform project from YouPHPTube to AVideo Platform which constitutes Audio Video Platform. In some plugins, forks, versions, modules, APIs, documentation, file names, there may be or have been reference to youphptube, youphp.tube, youtube clone, clone script, searchtube, adtube, showtube, searchmercials. WWBN owns Searchmercials, SearchTube, AdTube, ShowTube, AVideo, WWBN among other trademarks. All other trademarks and similarity to any referred to in any files, documents, wikis, plugins, code, modules, apis, integrations, technologies, links belong to their respective owners. Follow us on Facebook
-#
-# AVideo Platform Open-Source Project
-## AVideo Platform Open-Source Consist of THREE main Areas:
-
-
-#### (Management/Encoding/Storage)
-1. Management Project(s): AVideo Platform
-1. Encoding Project(s): AVideo Encoder & AVideo Encoder Network (Optional)
-1. Storage Project(s): AVideo Storage
-
-Management life cycle is as follows; media is managed at the platform at 1, media is then uploaded to a temporary storage to be encoded at 2, then stored for broadcast at 3, then distributed to devices at 1 to be consumed.
-
-#### About AVideo Platform Open-Source
-Some of the largest brands in the world use the AVideo Platform to manage and distribute their media assets. AVideo Platform open-source project has over 900 developers, and over 4000 AVideo Platform instances throughout the world. Because of the remarkable flexibility of the platform, each of our customers uses our platform in a slightly different way, to address their particular needs and deliver solid targeted value to their organization.
-
-The AVideo Platform Plugin Design allows you to get exactly the solution that addresses your needs today, while ensuring that your Broadcast Network implementation can grow and expand with you as your needs evolve.
-
-
-
-# Create Your Own Broadcast Network With AVideo Platform
-
-## AVideo Platform Open-Source Solution enables you to create your own video sharing site. Join the AVideo Developer Community and get platform innovation details, bug fixes, and contribute the continued evolution of AVideo Platform.
-
-## Along with this re-brand come a slew of value added benefits for all AVideo Platform instances.
-* Each AVideo Platform clone is considered a broadcast network
-* Each broadcast network is indexed in our World Wide Broadcast Network Platform System
-* Each broadcast network can use our ad network
-* Each broadcast network can use our Open Systems TV platform (Coming Soon)
-* Each broadcast network has channels and each channel has programs Learn more
-
-And more to come in 2020. Our mission is to take your video sharing site to "The Next Level" Internet TV.
-
-WWBN offers relevant and practical solutions, as well as valuable innovative technology, designed to increase the efficiency of advertising and broadcasting operations and maximize revenue opportunities for our customers and partners.
-
-### WHERE WE DELIVER
-PROFITABLE STRATEGIES - We provide companies with new business models that evolve around the delivery of video and other digital assets complementing their existing business offerings and adding to their revenues. These new ways of doing business include Turnkey application-integration with capabilities for managing, auditing, and disseminating digital content.
-
-### To learn more about AVideo Platform visit the AVideo Platform Official Site.
-### To learn more about the history of the AVideo Paroject WWBN Project Page
-
-### To see a demo select one below.
-* AVideo Platform Flix Demo
- - We provide you a AVideo Flix Style site sample. On this site you can subscribe (with real money on PayPal). this subscription will allow you to watch our private videos. There is an user that you can use to see how it works. user: test and pass: test.
-* AVideo Platform Gallery Demo
- - We've provided a sample Video Gallery site, which is also our tutorials site. On this sample you can login, subscribe, like, dislike and comment. but you can not upload videos.
-* AVideo Platform Full-Access Demo
- - We provide you a Demo site sample with full access to the admin account. You will need an admin password to upload and manage videos, it is by default. user: admin and pass: 123. Also there is a non admin user and password (Only for comments). user: test and pass: test.
-
-
-
-# Notice:
-### We highly recommend you keep your instance of AVideo Platform updated to the latest release. If you have updated your instance to version 8.0, your old plugins will not work, just download them again and you should be fine.
-
-# First thing...
-I would humbly like to thank God for giving me the necessary knowledge, motivation, resources and idea to be able to execute this project. Without God's permission this would never be possible.
-
-**For of Him, and through Him, and to Him, are all things: to whom be glory for ever. Amen.**
-`Apostle Paul in Romans 11:36`
-
-## This Software must be used for Good, never Evil. It is expressly forbidden to use AVideo Platform Open-Source to build porn sites, violence, racism, terrorism, or anything else that affects human integrity or denigrates the image of anyone.
-
-## Now you can read the rest...
-
-## Important Information
-
-> Streamer can be installed on any Server, including Windows, but the encoder and Livestream should work fine on any Linux distribution. However we recommend Ubuntu 20.04 without any kind of control panel.
-> The problem with cPanel, Plesk, Webmin, VestaCP, etc. It's because we need full root access to install some libs, and maybe compile them. Another important point is that to make Livestream work, we need to compile Nginx and the control panels often prevent us from running the commands forcing the installation available only on your panel.
-
-I don´t want to read I just want you to show me how to install!!
-
-Ok, check this out!
-
-For text-based tutorials and the manual, look here.
-
-There, you can find some hints for troubleshooting as well.
-
-### AVideo Platform Mobile APP
-Android
-
-## AVideo Platform Certified
-#### Need Help With Installation or Plugins? Feel free to ask us for help from the AVideo Platform Certified developers.
-
-Daniel Neto
-
-# AVideo - Streamer
-AVideo! is an video-sharing website, It is an open source solution that is freely available to everyone. With AVideo you can create your own video sharing site, AVideo will help you import and encode videos from other sites like Youtube, Vimeo, etc. and you can share directly on your website. In addition, you can use Facebook or Google login to register users on your site. The service was created in march 2017.
-
-
-
-# Why do I need the Encoder?
-You may want to install the encoder for a few reasons, such as, if you have a faster server than the public encoder server (which is likely to be the case), or if you'd like a private way of encoding your videos.
-
-But, the installation is mandatory if you are using a private network. The public encoder will not have access to send the videos to your streamer site.
-
-If your server does not have a public IP or uses an IP on some of these bands:
-- 10.0.0.0/8
-- 127.0.0.0/8 (Localhost)
-- 172.16.0.0/12
-- 192.168.0.0/16
-
-Surely you need to install an encoder
-
-# Server Requirements
-
-In order for you to be able to run AVideo Platform, there are certain tools that need to be installed on your server. Don't worry, they are all FREE. To have a look at complete list of required tools, click the link below. https://github.com/WWBN/AVideo/wiki/AVideo-Platform-Hardware-Requirements
-
-- PHP 7.3+
-- MySQL 5.0+
-- Apache web server 2.x (with mod_rewrite enabled)
-
-## Docker local development
-
-```bash
-docker-compose up --build -d
-```
-
-# Roadmap
-
-## Version 8.9
-
-## Version 8.10
-
-## Version 8.11
-
-## git clone
-
-After a git clone command run this
-
-composer update --prefer-dist --ignore-platform-reqs
+
+
+[](https://php.net/)
+[](https://github.com/WWBN/AVideo/releases)
+
+## Audio Video Platform
+AVideo is a term that means absolutely nothing, or anything video. Since it doesn't mean anything the brand simply is identifiable with audio video. AVideo Platform is an Audio and Video Platform or simply "A Video Platform".
+
+* AVideo - Audio Video
+* AVideo Platform - Audio Video Platform
+* OAVP - Online Audio Video Platform
+* OVP - Online Video Platform
+
+AVideo Platform is distributed as SaaS at AVideo.com, as an Enterprise Version, and as an Open-Source Project.
+
+## AN AVideo Platform Instance
+
+When we say a clone or copy of AVideo we mean an instance of AVideo Platform Enterprise or Open-Source and every instance of the AVideo Platform can be indexed as a network in the World Wide Broadcast Network Platform System.
+
+### AVideo trademark is FREE to use
+AVideo is a registered trademark owned by WWBN/PeachWiz (World Wide Broadcast Network) the media division of PeachWiz, Inc. and is freely distributable with any Enterprise or Open-Source AVideo Platform products provided by WWBN, and its permitted use is granted with GNU-GPL, CDDL open source licenses. Open-Source License can be viewed in this link.
+* Word Mark: AVIDEO
+* Translations: "AVideo" has no meaning in any foreign language.
+* Description: "AVideo" constitutes Audio Video.
+* Goods and Services: IC 009. US 021 023 026 036 038. G & S: Computer search engine software for searching online video content. FIRST USE: 20030602. FIRST USE IN COMMERCE: 20040112
+* Standard Characters: Claimed
+* Mark Drawing Code: (4) STANDARD CHARACTER MARK
+* Trademark Search Facility Classification Code: LETS-1 A A single letter, multiples of a single letter or in combination with a design
+* Serial Number: 77450549
+* Registration Number: 3625659
+
+#### About the project re-brand.
+ Originally the open-source version was offered as YouPHPTube, and marketed as a YouTube Clone (after the popular video sharing site), we decided to rebrand our open-source audio video platform project from YouPHPTube to AVideo Platform which constitutes Audio Video Platform. In some plugins, forks, versions, modules, APIs, documentation, file names, there may be or have been reference to youphptube, youphp.tube, youtube clone, clone script, searchtube, adtube, showtube, searchmercials. WWBN owns Searchmercials, SearchTube, AdTube, ShowTube, AVideo, WWBN among other trademarks. All other trademarks and similarity to any referred to in any files, documents, wikis, plugins, code, modules, apis, integrations, technologies, links belong to their respective owners. Follow us on Facebook
+#
+# AVideo Platform Open-Source Project
+## AVideo Platform Open-Source Consist of THREE main Areas:
+
+
+#### (Management/Encoding/Storage)
+1. Management Project(s): AVideo Platform
+1. Encoding Project(s): AVideo Encoder & AVideo Encoder Network (Optional)
+1. Storage Project(s): AVideo Storage
+
+Management life cycle is as follows; media is managed at the platform at 1, media is then uploaded to a temporary storage to be encoded at 2, then stored for broadcast at 3, then distributed to devices at 1 to be consumed.
+
+#### About AVideo Platform Open-Source
+Some of the largest brands in the world use the AVideo Platform to manage and distribute their media assets. AVideo Platform open-source project has over 900 developers, and over 4000 AVideo Platform instances throughout the world. Because of the remarkable flexibility of the platform, each of our customers uses our platform in a slightly different way, to address their particular needs and deliver solid targeted value to their organization.
+
+The AVideo Platform Plugin Design allows you to get exactly the solution that addresses your needs today, while ensuring that your Broadcast Network implementation can grow and expand with you as your needs evolve.
+
+
+
+# Create Your Own Broadcast Network With AVideo Platform
+
+## AVideo Platform Open-Source Solution enables you to create your own video sharing site. Join the AVideo Developer Community and get platform innovation details, bug fixes, and contribute the continued evolution of AVideo Platform.
+
+## Along with this re-brand come a slew of value added benefits for all AVideo Platform instances.
+* Each AVideo Platform clone is considered a broadcast network
+* Each broadcast network is indexed in our World Wide Broadcast Network Platform System
+* Each broadcast network can use our ad network
+* Each broadcast network can use our Open Systems TV platform (Coming Soon)
+* Each broadcast network has channels and each channel has programs Learn more
+
+And more to come in 2020. Our mission is to take your video sharing site to "The Next Level" Internet TV.
+
+WWBN offers relevant and practical solutions, as well as valuable innovative technology, designed to increase the efficiency of advertising and broadcasting operations and maximize revenue opportunities for our customers and partners.
+
+### WHERE WE DELIVER
+PROFITABLE STRATEGIES - We provide companies with new business models that evolve around the delivery of video and other digital assets complementing their existing business offerings and adding to their revenues. These new ways of doing business include Turnkey application-integration with capabilities for managing, auditing, and disseminating digital content.
+
+### To learn more about AVideo Platform visit the AVideo Platform Official Site.
+### To learn more about the history of the AVideo Paroject WWBN Project Page
+
+### To see a demo select one below.
+* AVideo Platform Flix Demo
+ - We provide you a AVideo Flix Style site sample. On this site you can subscribe (with real money on PayPal). this subscription will allow you to watch our private videos. There is an user that you can use to see how it works. user: test and pass: test.
+* AVideo Platform Gallery Demo
+ - We've provided a sample Video Gallery site, which is also our tutorials site. On this sample you can login, subscribe, like, dislike and comment. but you can not upload videos.
+* AVideo Platform Full-Access Demo
+ - We provide you a Demo site sample with full access to the admin account. You will need an admin password to upload and manage videos, it is by default. user: admin and pass: 123. Also there is a non admin user and password (Only for comments). user: test and pass: test.
+
+
+
+# Notice:
+### We highly recommend you keep your instance of AVideo Platform updated to the latest release. If you have updated your instance to version 8.0, your old plugins will not work, just download them again and you should be fine.
+
+# First thing...
+I would humbly like to thank God for giving me the necessary knowledge, motivation, resources and idea to be able to execute this project. Without God's permission this would never be possible.
+
+**For of Him, and through Him, and to Him, are all things: to whom be glory for ever. Amen.**
+`Apostle Paul in Romans 11:36`
+
+## This Software must be used for Good, never Evil. It is expressly forbidden to use AVideo Platform Open-Source to build porn sites, violence, racism, terrorism, or anything else that affects human integrity or denigrates the image of anyone.
+
+## Now you can read the rest...
+
+## Important Information
+
+> Streamer can be installed on any Server, including Windows, but the encoder and Livestream should work fine on any Linux distribution. However we recommend Ubuntu 20.04 without any kind of control panel.
+> The problem with cPanel, Plesk, Webmin, VestaCP, etc. It's because we need full root access to install some libs, and maybe compile them. Another important point is that to make Livestream work, we need to compile Nginx and the control panels often prevent us from running the commands forcing the installation available only on your panel.
+
+I don´t want to read I just want you to show me how to install!!
+
+Ok, check this out!
+
+For text-based tutorials and the manual, look here.
+
+There, you can find some hints for troubleshooting as well.
+
+### AVideo Platform Mobile APP
+Android
+
+## AVideo Platform Certified
+#### Need Help With Installation or Plugins? Feel free to ask us for help from the AVideo Platform Certified developers.
+
+Daniel Neto
+
+# AVideo - Streamer
+AVideo! is an video-sharing website, It is an open source solution that is freely available to everyone. With AVideo you can create your own video sharing site, AVideo will help you import and encode videos from other sites like Youtube, Vimeo, etc. and you can share directly on your website. In addition, you can use Facebook or Google login to register users on your site. The service was created in march 2017.
+
+
+
+# Why do I need the Encoder?
+You may want to install the encoder for a few reasons, such as, if you have a faster server than the public encoder server (which is likely to be the case), or if you'd like a private way of encoding your videos.
+
+But, the installation is mandatory if you are using a private network. The public encoder will not have access to send the videos to your streamer site.
+
+If your server does not have a public IP or uses an IP on some of these bands:
+- 10.0.0.0/8
+- 127.0.0.0/8 (Localhost)
+- 172.16.0.0/12
+- 192.168.0.0/16
+
+Surely you need to install an encoder
+
+# Server Requirements
+
+In order for you to be able to run AVideo Platform, there are certain tools that need to be installed on your server. Don't worry, they are all FREE. To have a look at complete list of required tools, click the link below. https://github.com/WWBN/AVideo/wiki/AVideo-Platform-Hardware-Requirements
+
+- PHP 7.3+
+- MySQL 5.0+
+- Apache web server 2.x (with mod_rewrite enabled)
+
+## Docker local development
+
+```bash
+docker-compose up --build -d
+```
+
+# Roadmap
+
+## Version 8.9
+
+## Version 8.10
+
+## Version 8.11
+
+## git clone
+
+After a git clone command run this
+
+composer update --prefer-dist --ignore-platform-reqs
diff --git a/admin/backup.php b/admin/backup.php
index 4ffef6b1ba..71527a524c 100644
--- a/admin/backup.php
+++ b/admin/backup.php
@@ -1,48 +1,47 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Clone Site
-
-
-
-
-
- __('Place here the URL of the site you want to clone'));
- echo createTable("CloneSite", $filter);
- include $global['systemRootPath'] . 'plugin/CloneSite/pluginMenu.html';
- ?>
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Clone Site
+
+
+
+
+
+ __('Place here the URL of the site you want to clone'), ];
+ echo createTable("CloneSite", $filter);
+ include $global['systemRootPath'] . 'plugin/CloneSite/pluginMenu.html';
+ ?>
+
diff --git a/admin/general_settings_encoder.php b/admin/general_settings_encoder.php
index 7858ef4bfc..377f3038f5 100644
--- a/admin/general_settings_encoder.php
+++ b/admin/general_settings_encoder.php
@@ -1,11 +1,11 @@
- __('Let the encoder network (If configured) choose what is the best encoder to use'),
- 'doNotShowEncoderResolutionLow' => __('Do not allow encode in Low resolution'),
- 'doNotShowEncoderResolutionSD' => __('Do not allow encode in SD resolution'),
- 'doNotShowEncoderResolutionHD' => __('Do not allow encode in HD resolution'),
- 'makeVideosInactiveAfterEncode' => __('Maybe you need to approve or check something on your video before make it public'),
- 'makeVideosUnlistedAfterEncode' => __('Maybe you need to approve or check something on your video before make it public')
-);
-
-createTable("CustomizeAdvanced", $filter);
+ __('Let the encoder network (If configured) choose what is the best encoder to use'),
+ 'doNotShowEncoderResolutionLow' => __('Do not allow encode in Low resolution'),
+ 'doNotShowEncoderResolutionSD' => __('Do not allow encode in SD resolution'),
+ 'doNotShowEncoderResolutionHD' => __('Do not allow encode in HD resolution'),
+ 'makeVideosInactiveAfterEncode' => __('Maybe you need to approve or check something on your video before make it public'),
+ 'makeVideosUnlistedAfterEncode' => __('Maybe you need to approve or check something on your video before make it public'),
+];
+
+createTable("CustomizeAdvanced", $filter);
diff --git a/admin/general_settings_upload.php b/admin/general_settings_upload.php
index e773f604d2..094a193e9a 100644
--- a/admin/general_settings_upload.php
+++ b/admin/general_settings_upload.php
@@ -1,10 +1,10 @@
-'The Encoder Network URL ',
- 'useEncoderNetworkRecomendation'=>__('Let the encoder network (if configured) choose what is the best encoder to use'),
- 'doNotShowUploadMP4Button'=>__('Users will not be able to directly upload, only use the encoder'),
- 'doNotShowImportMP4Button'=>__('Disable the option to import MP4 videos from your local (Server) storage'),
- 'doNotShowEncoderButton'=>__('Do not show the button to the encoder'),
- 'doNotShowEmbedButton'=>__('Check this if you will not use embed videos on your site')
-);
-createTable("CustomizeAdvanced", $filter);
+ 'The Encoder Network URL ',
+ 'useEncoderNetworkRecomendation' => __('Let the encoder network (if configured) choose what is the best encoder to use'),
+ 'doNotShowUploadMP4Button' => __('Users will not be able to directly upload, only use the encoder'),
+ 'doNotShowImportMP4Button' => __('Disable the option to import MP4 videos from your local (Server) storage'),
+ 'doNotShowEncoderButton' => __('Do not show the button to the encoder'),
+ 'doNotShowEmbedButton' => __('Check this if you will not use embed videos on your site'),
+];
+createTable("CustomizeAdvanced", $filter);
diff --git a/admin/general_settings_user.php b/admin/general_settings_user.php
index 4eb24dbbfa..706c6c7ec3 100644
--- a/admin/general_settings_user.php
+++ b/admin/general_settings_user.php
@@ -1,15 +1,15 @@
-__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'),
- 'disableNativeSignIn'=>__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'),
- 'disablePersonalInfo'=>__('Disable the My Account personal info like: First and Last Name and address'),
- 'newUsersCanStream'=>__('Automatic allow new users to use your Livestream Platform'),
- 'doNotIndentifyByEmail'=>__('Do not show user\'s email on the site'),
- 'doNotIndentifyByName'=>__('Do not show user\'s name on the site'),
- 'doNotIndentifyByUserName'=>__('Do not show user\'s username on the site'),
- 'unverifiedEmailsCanNOTLogin'=>__('Users must verify their emails before login'),
- 'onlyVerifiedEmailCanUpload'=>__('Users must verify their emails before upload/submit videos'),
- 'sendVerificationMailAutomatic'=>__('After sign up we will automatic send a verification email'),
- 'userMustBeLoggedIn'=>__('Hide the website to non logged users')
-);
-createTable("CustomizeUser", $filter);
+__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'),
+ 'disableNativeSignIn'=>__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'),
+ 'disablePersonalInfo'=>__('Disable the My Account personal info like: First and Last Name and address'),
+ 'newUsersCanStream'=>__('Automatic allow new users to use your Livestream Platform'),
+ 'doNotIndentifyByEmail'=>__('Do not show user\'s email on the site'),
+ 'doNotIndentifyByName'=>__('Do not show user\'s name on the site'),
+ 'doNotIndentifyByUserName'=>__('Do not show user\'s username on the site'),
+ 'unverifiedEmailsCanNOTLogin'=>__('Users must verify their emails before login'),
+ 'onlyVerifiedEmailCanUpload'=>__('Users must verify their emails before upload/submit videos'),
+ 'sendVerificationMailAutomatic'=>__('After sign up we will automatic send a verification email'),
+ 'userMustBeLoggedIn'=>__('Hide the website to non logged users'),
+];
+createTable("CustomizeUser", $filter);
diff --git a/admin/health_check.php b/admin/health_check.php
index 20c92b920e..d2dd2717f5 100644
--- a/admin/health_check.php
+++ b/admin/health_check.php
@@ -1,37 +1,37 @@
array(), 'PHP' => array(), 'Apache' => array());
+$messages = ['Server' => [], 'PHP' => [], 'Apache' => []];
$version = phpversion();
$phpMinVersion = '7.3.0';
if (strnatcmp($version, $phpMinVersion) >= 0) {
@@ -46,7 +46,7 @@ foreach ($phpExtensions as $value) {
if (in_array($value[0], $extensions)) {
$messages['PHP'][] = $value[0];
} else {
- $messages['PHP'][] = array($value[0], 'sudo apt-get install php-' . str_replace('_', '-', $value[0]) . ' -y && sudo /etc/init.d/apache2 restart');
+ $messages['PHP'][] = [$value[0], 'sudo apt-get install php-' . str_replace('_', '-', $value[0]) . ' -y && sudo /etc/init.d/apache2 restart'];
}
}
@@ -54,10 +54,10 @@ foreach ($phpExtensions as $value) {
if (isset($_SERVER["HTTPS"])) {
$messages['Apache'][] = "HTTPS is enabled";
} else {
- $messages['Apache'][] = array("HTTPS is not enabled", 'https://github.com/WWBN/AVideo/wiki/Why-use-HTTPS');
+ $messages['Apache'][] = ["HTTPS is not enabled", 'https://github.com/WWBN/AVideo/wiki/Why-use-HTTPS'];
}
-if(function_exists('apache_get_modules')){
+if (function_exists('apache_get_modules')) {
$mods = array_map('strtolower', apache_get_modules());
//var_dump($mods);
foreach ($apacheModules as $value) {
@@ -74,13 +74,13 @@ if(function_exists('apache_get_modules')){
if ($found) {
$messages['Apache'][] = $found;
} else {
- $messages['Apache'][] = array($value[0], @$value[1]);
+ $messages['Apache'][] = [$value[0], @$value[1]];
}
}
}
-}else{
+} else {
foreach ($apacheModules as $value) {
- $messages['Apache'][] = array($value[0], 'We could not check your installed modules. We recommend you to use apache as a module NOT as a FPM');
+ $messages['Apache'][] = [$value[0], 'We could not check your installed modules. We recommend you to use apache as a module NOT as a FPM'];
}
}
@@ -89,27 +89,27 @@ foreach ($linuxApps as $value) {
if (!empty($response)) {
$messages['Server'][] = "{$value[0]} is installed here {$response}";
} else {
- $messages['Server'][] = array("{$value[0]} is NOT installed", @$value[1]);
+ $messages['Server'][] = ["{$value[0]} is NOT installed", @$value[1]];
}
}
$videosDir = getVideosDir();
if (is_writable($videosDir)) {
$messages['Server'][] = "{$videosDir} is writable";
} else {
- $messages['Server'][] = array("{$videosDir} is NOT writable", 'sudo chmod -R 777 ' . $videosDir);
+ $messages['Server'][] = ["{$videosDir} is NOT writable", 'sudo chmod -R 777 ' . $videosDir];
}
if (is_writable($global['logfile'])) {
$messages['Server'][] = "Log file is writable";
} else {
- $messages['Server'][] = array("{$global['logfile']} is NOT writable", 'sudo chmod -R 777 ' . $global['logfile']);
+ $messages['Server'][] = ["{$global['logfile']} is NOT writable", 'sudo chmod -R 777 ' . $global['logfile']];
}
$cacheDir = "{$videosDir}cache/";
if (is_writable($cacheDir)) {
$messages['Server'][] = "Cache is writable";
} else {
- $messages['Server'][] = array("{$cacheDir} is NOT writable", 'sudo chmod -R 777 ' . $cacheDir);
+ $messages['Server'][] = ["{$cacheDir} is NOT writable", 'sudo chmod -R 777 ' . $cacheDir];
}
$_50GB = 53687091200;
@@ -118,14 +118,14 @@ $df = disk_free_space("/");
if ($df > $_50GB) {
$messages['Server'][] = "You have enough free disk space " . humanFileSize($df);
} else {
- $messages['Server'][] = array("Your disk is almost full, you have only " . humanFileSize($df) . ' free');
+ $messages['Server'][] = ["Your disk is almost full, you have only " . humanFileSize($df) . ' free'];
}
$dfVideos = disk_free_space($videosDir);
if ($dfVideos > $_50GB) {
$messages['Server'][] = "You have enough free disk space for the videos directory " . humanFileSize($dfVideos);
} else {
- $messages['Server'][] = array("Your videos directory is almost full, you have only " . humanFileSize($dfVideos) . ' free');
+ $messages['Server'][] = ["Your videos directory is almost full, you have only " . humanFileSize($dfVideos) . ' free'];
}
@@ -135,19 +135,19 @@ $verifyURL = addQueryStringParameter($verifyURL, 'screenshot', 1);
$result = url_get_contents($verifyURL, '', 5);
if (empty($result)) {
- $messages['Server'][] = array("We could not verify your server from outside {$global['webSiteRootURL']}");
+ $messages['Server'][] = ["We could not verify your server from outside {$global['webSiteRootURL']}"];
} else {
$verified = json_decode($result);
if (!empty($verified->verified)) {
$messages['Server'][] = "Server Checked from outside: " . implode(' ', $verified->msg);
} else {
- $messages['Server'][] = array("Something is wrong: ", implode(' ', $verified->msg));
+ $messages['Server'][] = ["Something is wrong: ", implode(' ', $verified->msg)];
}
/*
if(!empty($verified->screenshot)){
$messages['Server'][] = "";
}
- *
+ *
*/
}
?>
@@ -181,18 +181,17 @@ if (empty($result)) {
- 'It will collect usage info but will not display the counter on the live video');
-
- createTable("LiveUsers",$filter);
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'It will collect usage info but will not display the counter on the live video', ];
+
+ createTable("LiveUsers", $filter);
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/mail_all_users.php b/admin/mail_all_users.php
index ba207f2874..e1f7143376 100644
--- a/admin/mail_all_users.php
+++ b/admin/mail_all_users.php
@@ -1,78 +1,78 @@
-
-
- 'Show a button on the top to subscribe',
- 'displayLeftMenuSubscribeButton' => 'Show a button on the the left menu to subscribe',
- 'textSubscribe' => 'The button text label');
- createTable("Subscription", $filter);
- ?>
-
-
-
-
\ No newline at end of file
+
+
+
+
Subscription Configuration
+
+ 'Show a button on the top to subscribe',
+ 'displayLeftMenuSubscribeButton' => 'Show a button on the the left menu to subscribe',
+ 'textSubscribe' => 'The button text label', ];
+ createTable("Subscription", $filter);
+ ?>
+
- 'How much will your users receive per each video view',
- 'rewardOnlyLoggedUsersView' => 'Check this to allow only count rewards from logged users');
-
- createTable("MonetizeUsers",$filter);
- ?>
-
-
-
-
-
-
-
-
- 'Usually for USD we use 2, for cryptocurrencies we use more the 2',
- 'currency' => 'Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc',
- 'currency_symbol' => '$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)',
- 'manualAddFundsTransferFromUserId' => 'When some one buy something on your web site, the wallet balance will be transferred to this user ID',
- 'enablePlugin_YPTWalletPayPal' => 'You need to enable it to be able to use PayPal to add funds on your wallet',
- 'enableManualWithdrawFundsPage' => 'Let users request withdraws from his wallet. the withdraw mus be done manually');
- createTable("YPTWallet", $filter);
- ?>
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+ 'How much will your users receive per each video view',
+ 'rewardOnlyLoggedUsersView' => 'Check this to allow only count rewards from logged users', ];
+
+ createTable("MonetizeUsers", $filter);
+ ?>
+
+
+
+
+
+
+
+
+ 'Usually for USD we use 2, for cryptocurrencies we use more the 2',
+ 'currency' => 'Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc',
+ 'currency_symbol' => '$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)',
+ 'manualAddFundsTransferFromUserId' => 'When some one buy something on your web site, the wallet balance will be transferred to this user ID',
+ 'enablePlugin_YPTWalletPayPal' => 'You need to enable it to be able to use PayPal to add funds on your wallet',
+ 'enableManualWithdrawFundsPage' => 'Let users request withdraws from his wallet. the withdraw mus be done manually', ];
+ createTable("YPTWallet", $filter);
+ ?>
+
- __('Usually for USD we use 2, for cryptocurrencies we use more the 2'),
- 'currency' => __('Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc'),
- 'currency_symbol' => __('$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)'),
- 'manualAddFundsTransferFromUserId' => __('When some one buy something on your web site, the wallet balance will be transferred to this user ID'),
- 'enablePlugin_YPTWalletPayPal' => __('You need to enable it to be able to use PayPal to add funds on your wallet'),
- 'enableManualWithdrawFundsPage' => __('Let users request withdraws from his wallet. the withdraw mus be done manually'));
- createTable("YPTWallet", $filter);
- ?>
-
-
-
-
-
-
PayPal
-
-
-
-
-
-
+
+
+
+
+
+ __('Usually for USD we use 2, for cryptocurrencies we use more the 2'),
+ 'currency' => __('Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc'),
+ 'currency_symbol' => __('$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)'),
+ 'manualAddFundsTransferFromUserId' => __('When some one buy something on your web site, the wallet balance will be transferred to this user ID'),
+ 'enablePlugin_YPTWalletPayPal' => __('You need to enable it to be able to use PayPal to add funds on your wallet'),
+ 'enableManualWithdrawFundsPage' => __('Let users request withdraws from his wallet. the withdraw mus be done manually'), ];
+ createTable("YPTWallet", $filter);
+ ?>
+
- __('The form to signup will not exists'),
- 'disableNativeSignIn' => __('The regular form to signin will not exist, if you check this will only have social login or LDAP option'),
- 'userMustBeLoggedIn' => __('The site will display only a login form to un authenticated users'));
- createTable("CustomizeUser", $filter);
- ?>
-
+ __('The form to signup will not exists'),
+ 'disableNativeSignIn' => __('The regular form to signin will not exist, if you check this will only have social login or LDAP option'),
+ 'userMustBeLoggedIn' => __('The site will display only a login form to un authenticated users'), ];
+ createTable("CustomizeUser", $filter);
+ ?>
+
- "); echo htmlentities(""); echo __(" and change AllowOverride None to AllowOverride All"); ?>
-
-
sudo nano /etc/apache2/apache2.conf
-
-
-
-
-
- Options Indexes FollowSymLinks
- AllowOverride All
- Require all granted
- "); ?>
-
-
"); ?>
-
sudo a2enmod rewrite
-
-
-
-
sudo /etc/init.d/apache2 restart
-
-
-
-
sudo service apache2 restart
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "); echo htmlentities(""); echo __(" and change AllowOverride None to AllowOverride All"); ?>
+
+
sudo nano /etc/apache2/apache2.conf
+
+
+
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride All
+ Require all granted
+ "); ?>
+
+
"); ?>
+
sudo a2enmod rewrite
+
+
+
+
sudo /etc/init.d/apache2 restart
+
+
+
+
sudo service apache2 restart
+
+
+
+
+
+post = $_POST;
-
-if (!file_exists($_POST['systemRootPath'] . "index.php")) {
- $obj->error = "Your system path to application ({$_POST['systemRootPath']}) is wrong";
- echo json_encode($obj);
- exit;
-}
-error_log("Installation: ".__LINE__);
-
-$mysqli = @new mysqli($_POST['databaseHost'], $_POST['databaseUser'], $_POST['databasePass'], "", $_POST['databasePort']);
-
-/*
- * This is the "official" OO way to do it,
- * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
- */
-if ($mysqli->connect_error) {
- $obj->error = ('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
- echo json_encode($obj);
- exit;
-}
-error_log("Installation: ".__LINE__);
-
-if ($_POST['createTables'] == 2) {
- $sql = "CREATE DATABASE IF NOT EXISTS {$_POST['databaseName']}";
- if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error creating database: " . $mysqli->error;
- echo json_encode($obj);
- exit;
- }
-}
-$mysqli->select_db($_POST['databaseName']);
-
-error_log("Installation: ".__LINE__);
-/*
- $cmd = "mysql -h {$_POST['databaseHost']} -u {$_POST['databaseUser']} -p {$_POST['databasePass']} {$_POST['databaseName']} < {$_POST['systemRootPath']}install/database.sql";
- exec("{$cmd} 2>&1", $output, $return_val);
- if ($return_val !== 0) {
- $obj->error = "Error on command: {$cmd}";
- echo json_encode($obj);
- exit;
- }
- */
-error_log("Installation: ".__LINE__);
-if ($_POST['createTables'] > 0) {
- error_log("Installation: ".__LINE__);
-// Temporary variable, used to store current query
- $templine = '';
- $installFile = "{$_POST['systemRootPath']}install/database.sql";
- if(!file_exists($installFile)){
- $obj->error = "File Not found {$installFile}";
- echo json_encode($obj);
- exit;
- }
- error_log("Installation: ".__LINE__);
-// Read in entire file
- $lines = file($installFile);
- if(empty($lines)){
- $obj->error = "File is empty {$installFile}";
- echo json_encode($obj);
- exit;
- }
- error_log("Installation: ".__LINE__);
-// Loop through each line
- $obj->error = "";
- foreach ($lines as $line) {
-// Skip it if it's a comment
- if (substr($line, 0, 2) == '--' || $line == '')
- continue;
-
-// Add this line to the current segment
- $templine .= $line;
-// If it has a semicolon at the end, it's the end of the query
- if (substr(trim($line), -1, 1) == ';') {
- // Perform the query
- //error_log("Installation: ".$templine);
- if (!$mysqli->query($templine)) {
- error_log("Installation: SQL ERROR ".$mysqli->error);
- $obj->error = ('Error performing query \'' . $templine . '\': ' . $mysqli->error . '
');
- }
- // Reset temp variable to empty
- $templine = '';
- }
- }
- error_log("Installation: ".__LINE__);
-}
-
-error_log("Installation: ".__LINE__);
-
-$sql = "DELETE FROM users WHERE id = 1 ";
-if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error deleting user: " . $mysqli->error;
- echo json_encode($obj);
- exit;
-}
-
-
-error_log("Installation: ".__LINE__);
-$sql = "INSERT INTO users (id, user, email, password, created, modified, isAdmin) VALUES (1, 'admin', '" . $_POST['contactEmail'] . "', '" . md5($_POST['systemAdminPass']) . "', now(), now(), true)";
-if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error creating admin user: " . $mysqli->error;
- echo json_encode($obj);
- exit;
-}
-
-error_log("Installation: ".__LINE__);
-$sql = "DELETE FROM categories WHERE id = 1 ";
-if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error deleting category: " . $mysqli->error;
- echo json_encode($obj);
- exit;
-}
-
-error_log("Installation: ".__LINE__);
-$sql = "INSERT INTO categories (id, name, clean_name, description, created, modified) VALUES (1, 'Default', 'default','', now(), now())";
-if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error creating category: " . $mysqli->error;
- echo json_encode($obj);
- exit;
-}
-
-error_log("Installation: ".__LINE__);
-$sql = "DELETE FROM configurations WHERE id = 1 ";
-if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error deleting configuration: " . $mysqli->error;
- echo json_encode($obj);
- exit;
-}
-
-error_log("Installation: ".__LINE__);
-
-$encoder = 'https://encoder1.avideo.com/';
-if(is_dir("{$_POST['systemRootPath']}Encoder")){
- $encoder = "{$_POST['webSiteRootURL']}Encoder/";
-}
-
-$sql = "INSERT INTO configurations (id, video_resolution, users_id, version, webSiteTitle, language, contactEmail, encoderURL, created, modified) "
- . " VALUES "
- . " (1, '858:480', 1,'{$installationVersion}', '{$_POST['webSiteTitle']}', '{$_POST['mainLanguage']}', '{$_POST['contactEmail']}', '{$encoder}', now(), now())";
-if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error creating configuration: " . $mysqli->error;
- echo json_encode($obj);
- exit;
-}
-
-error_log("Installation: ".__LINE__);
-$sql = "INSERT INTO `plugins` VALUES (NULL, 'a06505bf-3570-4b1f-977a-fd0e5cab205d', 'active', now(), now(), '', 'Gallery', 'Gallery', '1.0');";
-if ($mysqli->query($sql) !== TRUE) {
- $obj->error = "Error enabling Gallery Plugin: " . $mysqli->error;
- echo json_encode($obj);
- exit;
-}
-
-
-error_log("Installation: ".__LINE__);
-$mysqli->close();
-
-if(empty($_POST['salt'])){
- $_POST['salt'] = uniqid();
-}
-$content = "error = "Error copying the encoding progress sample files. Check whether the directory {$_POST['systemRootPath']}videos/ exists and the process have permission";
- echo json_encode($obj);
- exit;
-}
-*/
-error_log("Installation: ".__LINE__);
-$obj->success = true;
-echo json_encode($obj);
-
-error_log("Installation: ".__LINE__);
\ No newline at end of file
+post = $_POST;
+
+if (!file_exists($_POST['systemRootPath'] . "index.php")) {
+ $obj->error = "Your system path to application ({$_POST['systemRootPath']}) is wrong";
+ echo json_encode($obj);
+ exit;
+}
+error_log("Installation: ".__LINE__);
+
+$mysqli = @new mysqli($_POST['databaseHost'], $_POST['databaseUser'], $_POST['databasePass'], "", $_POST['databasePort']);
+
+/*
+ * This is the "official" OO way to do it,
+ * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
+ */
+if ($mysqli->connect_error) {
+ $obj->error = ('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
+ echo json_encode($obj);
+ exit;
+}
+error_log("Installation: ".__LINE__);
+
+if ($_POST['createTables'] == 2) {
+ $sql = "CREATE DATABASE IF NOT EXISTS {$_POST['databaseName']}";
+ if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error creating database: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+ }
+}
+$mysqli->select_db($_POST['databaseName']);
+
+error_log("Installation: ".__LINE__);
+/*
+ $cmd = "mysql -h {$_POST['databaseHost']} -u {$_POST['databaseUser']} -p {$_POST['databasePass']} {$_POST['databaseName']} < {$_POST['systemRootPath']}install/database.sql";
+ exec("{$cmd} 2>&1", $output, $return_val);
+ if ($return_val !== 0) {
+ $obj->error = "Error on command: {$cmd}";
+ echo json_encode($obj);
+ exit;
+ }
+ */
+error_log("Installation: ".__LINE__);
+if ($_POST['createTables'] > 0) {
+ error_log("Installation: ".__LINE__);
+ // Temporary variable, used to store current query
+ $templine = '';
+ $installFile = "{$_POST['systemRootPath']}install/database.sql";
+ if (!file_exists($installFile)) {
+ $obj->error = "File Not found {$installFile}";
+ echo json_encode($obj);
+ exit;
+ }
+ error_log("Installation: ".__LINE__);
+ // Read in entire file
+ $lines = file($installFile);
+ if (empty($lines)) {
+ $obj->error = "File is empty {$installFile}";
+ echo json_encode($obj);
+ exit;
+ }
+ error_log("Installation: ".__LINE__);
+ // Loop through each line
+ $obj->error = '';
+ foreach ($lines as $line) {
+ // Skip it if it's a comment
+ if (substr($line, 0, 2) == '--' || $line == '') {
+ continue;
+ }
+
+ // Add this line to the current segment
+ $templine .= $line;
+ // If it has a semicolon at the end, it's the end of the query
+ if (substr(trim($line), -1, 1) == ';') {
+ // Perform the query
+ //error_log("Installation: ".$templine);
+ if (!$mysqli->query($templine)) {
+ error_log("Installation: SQL ERROR ".$mysqli->error);
+ $obj->error = ('Error performing query \'' . $templine . '\': ' . $mysqli->error . '
');
+ }
+ // Reset temp variable to empty
+ $templine = '';
+ }
+ }
+ error_log("Installation: ".__LINE__);
+}
+
+error_log("Installation: ".__LINE__);
+
+$sql = "DELETE FROM users WHERE id = 1 ";
+if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error deleting user: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+}
+
+
+error_log("Installation: ".__LINE__);
+$sql = "INSERT INTO users (id, user, email, password, created, modified, isAdmin) VALUES (1, 'admin', '" . $_POST['contactEmail'] . "', '" . md5($_POST['systemAdminPass']) . "', now(), now(), true)";
+if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error creating admin user: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+}
+
+error_log("Installation: ".__LINE__);
+$sql = "DELETE FROM categories WHERE id = 1 ";
+if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error deleting category: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+}
+
+error_log("Installation: ".__LINE__);
+$sql = "INSERT INTO categories (id, name, clean_name, description, created, modified) VALUES (1, 'Default', 'default','', now(), now())";
+if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error creating category: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+}
+
+error_log("Installation: ".__LINE__);
+$sql = "DELETE FROM configurations WHERE id = 1 ";
+if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error deleting configuration: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+}
+
+error_log("Installation: ".__LINE__);
+
+$encoder = 'https://encoder1.avideo.com/';
+if (is_dir("{$_POST['systemRootPath']}Encoder")) {
+ $encoder = "{$_POST['webSiteRootURL']}Encoder/";
+}
+
+$sql = "INSERT INTO configurations (id, video_resolution, users_id, version, webSiteTitle, language, contactEmail, encoderURL, created, modified) "
+ . " VALUES "
+ . " (1, '858:480', 1,'{$installationVersion}', '{$_POST['webSiteTitle']}', '{$_POST['mainLanguage']}', '{$_POST['contactEmail']}', '{$encoder}', now(), now())";
+if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error creating configuration: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+}
+
+error_log("Installation: ".__LINE__);
+$sql = "INSERT INTO `plugins` VALUES (NULL, 'a06505bf-3570-4b1f-977a-fd0e5cab205d', 'active', now(), now(), '', 'Gallery', 'Gallery', '1.0');";
+if ($mysqli->query($sql) !== true) {
+ $obj->error = "Error enabling Gallery Plugin: " . $mysqli->error;
+ echo json_encode($obj);
+ exit;
+}
+
+
+error_log("Installation: ".__LINE__);
+$mysqli->close();
+
+if (empty($_POST['salt'])) {
+ $_POST['salt'] = uniqid();
+}
+$content = "error = "Error copying the encoding progress sample files. Check whether the directory {$_POST['systemRootPath']}videos/ exists and the process have permission";
+ echo json_encode($obj);
+ exit;
+}
+*/
+error_log("Installation: ".__LINE__);
+$obj->success = true;
+echo json_encode($obj);
+
+error_log("Installation: ".__LINE__);
diff --git a/install/database.sql b/install/database.sql
index b1870bd17f..da6fe2a4eb 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -1,600 +1,600 @@
--- MySQL Workbench Forward Engineering
-
-SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
-SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
-SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-
--- -----------------------------------------------------
--- Table `users`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `users` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `user` VARCHAR(45) NOT NULL,
- `name` VARCHAR(45) NULL,
- `email` VARCHAR(254) NULL,
- `password` VARCHAR(145) NOT NULL,
- `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `modified` DATETIME NOT NULL,
- `isAdmin` TINYINT(1) NOT NULL DEFAULT 0,
- `status` ENUM('a', 'i') NOT NULL DEFAULT 'a',
- `photoURL` VARCHAR(255) NULL,
- `lastLogin` DATETIME NULL,
- `recoverPass` VARCHAR(255) NULL,
- `backgroundURL` VARCHAR(255) NULL,
- `canStream` TINYINT(1) NULL,
- `canUpload` TINYINT(1) NULL,
- `canCreateMeet` TINYINT(1) NULL,
- `canViewChart` TINYINT(1) NOT NULL DEFAULT 0,
- `about` TEXT NULL,
- `channelName` VARCHAR(45) NULL,
- `emailVerified` TINYINT(1) NOT NULL DEFAULT 0,
- `analyticsCode` VARCHAR(45) NULL DEFAULT NULL,
- `externalOptions` TEXT NULL,
- `first_name` VARCHAR(255) NULL DEFAULT NULL,
- `last_name` VARCHAR(255) NULL DEFAULT NULL,
- `address` VARCHAR(255) NULL DEFAULT NULL,
- `zip_code` VARCHAR(45) NULL DEFAULT NULL,
- `country` VARCHAR(100) NULL DEFAULT NULL,
- `region` VARCHAR(100) NULL DEFAULT NULL,
- `city` VARCHAR(100) NULL DEFAULT NULL,
- `donationLink` VARCHAR(225) NULL DEFAULT NULL,
- `extra_info` TEXT NULL DEFAULT NULL,
- PRIMARY KEY (`id`),
- UNIQUE INDEX `user_UNIQUE` (`user` ASC))
-ENGINE = InnoDB;
-
-
-CREATE TABLE IF NOT EXISTS `users_blob` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `blob` LONGBLOB NULL,
- `users_id` INT NOT NULL,
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- `type` VARCHAR(45) NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_users_document_image_users1_idx` (`users_id` ASC),
- CONSTRAINT `fk_users_document_image_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
--- -----------------------------------------------------
--- Table `categories`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `categories` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `name` VARCHAR(45) NOT NULL,
- `clean_name` VARCHAR(45) NOT NULL,
- `description` TEXT NULL,
- `nextVideoOrder` INT(2) NOT NULL DEFAULT '0',
- `parentId` INT NOT NULL DEFAULT '0',
- `created` DATETIME NOT NULL,
- `modified` DATETIME NOT NULL,
- `iconClass` VARCHAR(45) NOT NULL DEFAULT 'fa fa-folder',
- `users_id` INT(11) NOT NULL DEFAULT 1,
- `private` TINYINT(1) NULL DEFAULT 0,
- `allow_download` TINYINT(1) NULL DEFAULT 1,
- `order` INT(11) NULL DEFAULT NULL,
- `suggested` TINYINT(1) NULL DEFAULT NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_categories_users1_idx` (`users_id` ASC),
- INDEX `clean_name_INDEX2` (`clean_name` ASC),
- INDEX `sortcategoryOrderIndex` (`order` ASC),
- INDEX `category_name_idx` (`name` ASC),
- INDEX `categoriesindex9suggested` (`suggested` ASC),
- FULLTEXT INDEX `index7cname` (`name`),
- FULLTEXT INDEX `index8cdescr` (`description`),
- UNIQUE INDEX `clean_name_UNIQUE` (`clean_name` ASC),
- CONSTRAINT `fk_categories_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-CREATE TABLE IF NOT EXISTS `sites` (
- `id` INT(11) NOT NULL AUTO_INCREMENT,
- `name` VARCHAR(255) NULL DEFAULT NULL,
- `url` VARCHAR(255) NOT NULL,
- `created` DATETIME NULL DEFAULT NULL,
- `modified` DATETIME NULL DEFAULT NULL,
- `status` CHAR(1) NULL DEFAULT NULL,
- `secret` VARCHAR(255) NOT NULL,
- PRIMARY KEY (`id`))
-ENGINE = InnoDB;
-
--- -----------------------------------------------------
--- Table `videos`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `videos` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `title` VARCHAR(190) NOT NULL,
- `clean_title` VARCHAR(190) NOT NULL,
- `description` TEXT NULL,
- `views_count` INT NOT NULL DEFAULT 0,
- `views_count_25` INT(11) NULL DEFAULT 0,
- `views_count_50` INT(11) NULL DEFAULT 0,
- `views_count_75` INT(11) NULL DEFAULT 0,
- `views_count_100` INT(11) NULL DEFAULT 0,
- `status` VARCHAR(16) NOT NULL DEFAULT 'e' ,
- `created` DATETIME NOT NULL,
- `modified` DATETIME NOT NULL,
- `users_id` INT NOT NULL,
- `categories_id` INT NOT NULL,
- `filename` VARCHAR(255) NOT NULL,
- `duration` VARCHAR(15) NOT NULL,
- `type` ENUM('audio', 'video', 'embed', 'linkVideo', 'linkAudio', 'torrent', 'pdf', 'image', 'gallery', 'article', 'serie', 'zip') NOT NULL DEFAULT 'video',
- `videoDownloadedLink` VARCHAR(255) NULL,
- `order` INT UNSIGNED NOT NULL DEFAULT 1,
- `rotation` SMALLINT NULL DEFAULT 0,
- `zoom` FLOAT NULL DEFAULT 1,
- `youtubeId` VARCHAR(45) NULL,
- `videoLink` VARCHAR(255) NULL,
- `next_videos_id` INT NULL,
- `isSuggested` INT(1) NOT NULL DEFAULT 0,
- `trailer1` VARCHAR(255) NULL DEFAULT NULL,
- `trailer2` VARCHAR(255) NULL DEFAULT NULL,
- `trailer3` VARCHAR(255) NULL DEFAULT NULL,
- `rate` FLOAT(4,2) NULL DEFAULT NULL,
- `can_download` TINYINT(1) NULL DEFAULT NULL,
- `can_share` TINYINT(1) NULL DEFAULT NULL,
- `rrating` VARCHAR(45) NULL DEFAULT NULL,
- `externalOptions` TEXT NULL DEFAULT NULL,
- `only_for_paid` TINYINT(1) NULL DEFAULT NULL,
- `serie_playlists_id` INT(11) NULL DEFAULT NULL,
- `sites_id` INT(11) NULL,
- `video_password` VARCHAR(45) NULL DEFAULT NULL,
- `encoderURL` VARCHAR(255) NULL DEFAULT NULL,
- `filepath` VARCHAR(255) NULL DEFAULT NULL,
- `filesize` BIGINT(19) UNSIGNED NULL DEFAULT 0,
- `live_transmitions_history_id` INT(11) NULL DEFAULT NULL,
- `total_seconds_watching` INT(11) NULL DEFAULT 0,
- `duration_in_seconds` INT NULL DEFAULT NULL,
- `likes` INT(11) NULL DEFAULT NULL,
- `dislikes` INT(11) NULL DEFAULT NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_videos_users_idx` (`users_id` ASC),
- INDEX `fk_videos_categories1_idx` (`categories_id` ASC),
- UNIQUE INDEX `clean_title_UNIQUE` (`clean_title` ASC),
- INDEX `index5` (`order` ASC),
- INDEX `fk_videos_videos1_idx` (`next_videos_id` ASC),
- INDEX `fk_videos_sites1_idx` (`sites_id` ASC),
- INDEX `clean_title_INDEX` (`clean_title` ASC),
- INDEX `video_filename_INDEX` (`filename` ASC),
- INDEX `video_status_idx` (`status` ASC),
- INDEX `video_type_idx` (`type` ASC) ,
- INDEX `videos_likes_index` (`likes` ASC),
- INDEX `videos_dislikes_index` (`dislikes` ASC),
- INDEX `fk_videos_live_transmitions_history1_idx` (`live_transmitions_history_id` ASC),
- INDEX `total_sec_watchinindex` (`total_seconds_watching` ASC),
- FULLTEXT INDEX `index17vname` (`title`),
- FULLTEXT INDEX `index18vdesc` (`description`),
- CONSTRAINT `fk_videos_sites1`
- FOREIGN KEY (`sites_id`)
- REFERENCES `sites` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
- CONSTRAINT `fk_videos_users`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
- CONSTRAINT `fk_videos_categories1`
- FOREIGN KEY (`categories_id`)
- REFERENCES `categories` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
- CONSTRAINT `fk_videos_videos1`
- FOREIGN KEY (`next_videos_id`)
- REFERENCES `videos` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
-CONSTRAINT `fk_videos_playlists1`
- FOREIGN KEY (`serie_playlists_id`)
- REFERENCES `playlists` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-CREATE TABLE IF NOT EXISTS `videos_metadata` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `videos_id` INT NOT NULL,
- `resolution` VARCHAR(12) NOT NULL,
- `format` VARCHAR(12) NOT NULL,
- `stream_id` INT NOT NULL,
- `name` VARCHAR(128) NOT NULL,
- `value` VARCHAR(255) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE (`videos_id`, `resolution`, `format`, `stream_id`, `name`),
- INDEX `fk_videos_metadata_videos1_idx` (`videos_id` ASC),
- CONSTRAINT `fk_videos_metadata_videos1`
- FOREIGN KEY (`videos_id`)
- REFERENCES `videos` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE
-) ENGINE = InnoDB;
-
--- -----------------------------------------------------
--- Table `comments`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `comments` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `comment` TEXT NOT NULL,
- `videos_id` INT NOT NULL,
- `users_id` INT NOT NULL,
- `created` DATETIME NOT NULL,
- `modified` DATETIME NOT NULL,
- `comments_id_pai` INT NULL,
- `pin` INT(1) NOT NULL DEFAULT 0 COMMENT 'If = 1 will be on the top',
- PRIMARY KEY (`id`),
- INDEX `fk_comments_videos1_idx` (`videos_id` ASC),
- INDEX `fk_comments_users1_idx` (`users_id` ASC),
- INDEX `fk_comments_comments1_idx` (`comments_id_pai` ASC),
- CONSTRAINT `fk_comments_videos1`
- FOREIGN KEY (`videos_id`)
- REFERENCES `videos` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_comments_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_comments_comments1`
- FOREIGN KEY (`comments_id_pai`)
- REFERENCES `comments` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `configurations`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `configurations` (
- `id` INT NOT NULL,
- `video_resolution` VARCHAR(12) NOT NULL,
- `users_id` INT NOT NULL,
- `version` VARCHAR(10) NOT NULL,
- `webSiteTitle` VARCHAR(45) NOT NULL DEFAULT 'AVideo',
- `language` VARCHAR(6) NOT NULL DEFAULT 'en',
- `contactEmail` VARCHAR(254) NOT NULL,
- `modified` DATETIME NOT NULL,
- `created` DATETIME NOT NULL,
- `authGoogle_id` VARCHAR(255) NULL,
- `authGoogle_key` VARCHAR(255) NULL,
- `authGoogle_enabled` TINYINT(1) NOT NULL DEFAULT 0,
- `authFacebook_id` VARCHAR(255) NULL,
- `authFacebook_key` VARCHAR(255) NULL,
- `authFacebook_enabled` TINYINT(1) NOT NULL DEFAULT 0,
- `authCanUploadVideos` TINYINT(1) NOT NULL DEFAULT 0,
- `authCanViewChart` TINYINT(2) NOT NULL DEFAULT 0,
- `authCanComment` TINYINT(1) NOT NULL DEFAULT 1,
- `head` TEXT NULL,
- `logo` VARCHAR(255) NULL,
- `logo_small` VARCHAR(255) NULL,
- `adsense` TEXT NULL,
- `mode` ENUM('Youtube', 'Gallery') NULL DEFAULT 'Youtube',
- `disable_analytics` TINYINT(1) NULL DEFAULT 0,
- `disable_youtubeupload` TINYINT(1) NULL DEFAULT 0,
- `allow_download` TINYINT(1) NULL DEFAULT 0,
- `session_timeout` INT NULL DEFAULT 3600,
- `autoplay` TINYINT(1) NULL,
- `theme` VARCHAR(45) NULL DEFAULT 'default',
- `smtp` TINYINT(1) NULL,
- `smtpAuth` TINYINT(1) NULL,
- `smtpSecure` VARCHAR(255) NULL COMMENT '\'ssl\'; // secure transfer enabled REQUIRED for Gmail',
- `smtpHost` VARCHAR(255) NULL COMMENT '\"smtp.gmail.com\"',
- `smtpUsername` VARCHAR(255) NULL COMMENT '\"email@gmail.com\"',
- `smtpPassword` VARCHAR(255) NULL,
- `smtpPort` INT NULL,
- `encoderURL` VARCHAR(255) NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_configurations_users1_idx` (`users_id` ASC),
- CONSTRAINT `fk_configurations_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION)
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `videos_statistics`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `videos_statistics` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `when` DATETIME NOT NULL,
- `ip` VARCHAR(45) NULL,
- `users_id` INT NULL,
- `videos_id` INT NOT NULL,
- `created` DATETIME NULL DEFAULT NULL,
- `modified` DATETIME NULL DEFAULT NULL,
- `lastVideoTime` INT(11) NULL DEFAULT NULL,
- `session_id` VARCHAR(45) NOT NULL,
- `seconds_watching_video` INT(11) NULL DEFAULT NULL,
- `json` TEXT NULL DEFAULT NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_videos_statistics_users1_idx` (`users_id` ASC),
- INDEX `fk_videos_statistics_videos1_idx` (`videos_id` ASC),
- INDEX `when_statisci` (`when` ASC),
- INDEX `session_id_statistics` (`session_id` ASC),
- INDEX `sec_watchin_videos` (`seconds_watching_video` ASC),
- CONSTRAINT `fk_videos_statistics_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_videos_statistics_videos1`
- FOREIGN KEY (`videos_id`)
- REFERENCES `videos` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `likes`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `likes` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `like` INT(1) NOT NULL DEFAULT 0 COMMENT '1 = Like\n0 = Does not metter\n-1 = Dislike',
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- `videos_id` INT NOT NULL,
- `users_id` INT NOT NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_likes_videos1_idx` (`videos_id` ASC),
- INDEX `fk_likes_users1_idx` (`users_id` ASC),
- INDEX `likes_likes_idx` (`like` ASC),
- CONSTRAINT `fk_likes_videos1`
- FOREIGN KEY (`videos_id`)
- REFERENCES `videos` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_likes_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `users_groups`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `users_groups` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `group_name` VARCHAR(255) NULL,
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- PRIMARY KEY (`id`))
-ENGINE = InnoDB;
-
--- -----------------------------------------------------
--- Table `users_has_users_groups`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `users_has_users_groups` (
- `users_id` INT NOT NULL,
- `users_groups_id` INT NOT NULL,
- PRIMARY KEY (`users_id`, `users_groups_id`),
- INDEX `fk_users_has_users_groups_users_groups1_idx` (`users_groups_id` ASC),
- INDEX `fk_users_has_users_groups_users1_idx` (`users_id` ASC),
- UNIQUE INDEX `index_user_groups_unique` (`users_groups_id` ASC, `users_id` ASC),
- CONSTRAINT `fk_users_has_users_groups_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_users_has_users_groups_users_groups1`
- FOREIGN KEY (`users_groups_id`)
- REFERENCES `users_groups` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `videos_group_view`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `videos_group_view` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `users_groups_id` INT NOT NULL,
- `videos_id` INT NOT NULL,
- INDEX `fk_videos_group_view_users_groups1_idx` (`users_groups_id` ASC),
- INDEX `fk_videos_group_view_videos1_idx` (`videos_id` ASC),
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_videos_group_view_users_groups1`
- FOREIGN KEY (`users_groups_id`)
- REFERENCES `users_groups` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_videos_group_view_videos1`
- FOREIGN KEY (`videos_id`)
- REFERENCES `videos` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
--- -----------------------------------------------------
--- Table `subscribes`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `subscribes` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `email` VARCHAR(100) NOT NULL,
- `status` ENUM('a', 'i') NOT NULL DEFAULT 'a',
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- `ip` VARCHAR(45) NULL,
- `users_id` INT NOT NULL DEFAULT 1 COMMENT 'subscribes to user channel',
- `notify` TINYINT(1) NOT NULL DEFAULT 1,
- `subscriber_users_id` INT(11) NOT NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_subscribes_users1_idx` (`users_id` ASC),
- INDEX `fk_subscribes_users2_idx` (`subscriber_users_id` ASC),
- CONSTRAINT `fk_subscribes_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_subscribes_users2`
- FOREIGN KEY (`subscriber_users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `playlists`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `playlists` (
- `id` INT(11) NOT NULL AUTO_INCREMENT,
- `name` VARCHAR(45) NOT NULL,
- `created` DATETIME NULL DEFAULT NULL,
- `modified` DATETIME NULL DEFAULT NULL,
- `users_id` INT(11) NOT NULL,
- `status` ENUM('public', 'private', 'unlisted', 'favorite', 'watch_later') NOT NULL DEFAULT 'public',
- `showOnTV` TINYINT NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_playlists_users1_idx` (`users_id` ASC),
- INDEX `showOnTVindex3` (`showOnTV` ASC),
- CONSTRAINT `fk_playlists_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
--- -----------------------------------------------------
--- Table `playlists_has_videos`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `playlists_has_videos` (
- `playlists_id` INT NOT NULL,
- `videos_id` INT NOT NULL,
- `order` INT NULL,
- PRIMARY KEY (`playlists_id`, `videos_id`),
- INDEX `fk_playlists_has_videos_videos1_idx` (`videos_id` ASC),
- INDEX `fk_playlists_has_videos_playlists1_idx` (`playlists_id` ASC),
- CONSTRAINT `fk_playlists_has_videos_playlists1`
- FOREIGN KEY (`playlists_id`)
- REFERENCES `playlists` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_playlists_has_videos_videos1`
- FOREIGN KEY (`videos_id`)
- REFERENCES `videos` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `plugins`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `plugins` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `uuid` VARCHAR(45) NOT NULL,
- `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active',
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- `object_data` TEXT NULL,
- `name` VARCHAR(255) NOT NULL,
- `dirName` VARCHAR(255) NOT NULL,
- `pluginversion` VARCHAR(6) NULL,
- PRIMARY KEY (`id`),
- UNIQUE INDEX `uuid_UNIQUE` (`uuid` ASC))
-ENGINE = InnoDB;
-
-
--- -----------------------------------------------------
--- Table `comments_likes`
--- -----------------------------------------------------
-CREATE TABLE IF NOT EXISTS `comments_likes` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `like` INT(1) NOT NULL,
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- `users_id` INT NOT NULL,
- `comments_id` INT NOT NULL,
- PRIMARY KEY (`id`),
- INDEX `fk_comments_likes_users1_idx` (`users_id` ASC),
- INDEX `fk_comments_likes_comments1_idx` (`comments_id` ASC),
- CONSTRAINT `fk_comments_likes_users1`
- FOREIGN KEY (`users_id`)
- REFERENCES `users` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_comments_likes_comments1`
- FOREIGN KEY (`comments_id`)
- REFERENCES `comments` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
--- -----------------------------------------------------
--- Table `category_type_cache`
--- -----------------------------------------------------
-CREATE TABLE `category_type_cache` (
- `categoryId` int(11) NOT NULL,
- `type` int(2) NOT NULL COMMENT '0=both, 1=audio, 2=video' DEFAULT 0,
- `manualSet` int(1) NOT NULL COMMENT '0=auto, 1=manual' DEFAULT 0
-
-) ENGINE=InnoDB;
-
-CREATE TABLE IF NOT EXISTS `categories_has_users_groups` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `categories_id` INT(11) NOT NULL,
- `users_groups_id` INT(11) NOT NULL,
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- `status` CHAR(1) NOT NULL DEFAULT 'a',
- PRIMARY KEY (`id`),
- INDEX `fk_categories_has_users_groups_users_groups1_idx` (`users_groups_id` ASC),
- INDEX `fk_categories_has_users_groups_categories1_idx` (`categories_id` ASC),
- CONSTRAINT `fk_categories_has_users_groups_categories1`
- FOREIGN KEY (`categories_id`)
- REFERENCES `categories` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `fk_categories_has_users_groups_users_groups1`
- FOREIGN KEY (`users_groups_id`)
- REFERENCES `users_groups` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
-ENGINE = InnoDB;
-
-CREATE TABLE IF NOT EXISTS `users_extra_info` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `field_name` VARCHAR(45) NOT NULL,
- `field_type` VARCHAR(45) NOT NULL,
- `field_options` TEXT NULL,
- `field_default_value` VARCHAR(45) NULL,
- `parameters` TEXT NULL,
- `created` DATETIME NULL,
- `modified` DATETIME NULL,
- `status` CHAR(1) NOT NULL DEFAULT 'a',
- `order` INT NOT NULL DEFAULT 0,
- PRIMARY KEY (`id`),
- INDEX `ordersortusers_extra_info` USING BTREE (`order`))
-ENGINE = InnoDB;
-
-ALTER TABLE `category_type_cache`
- ADD UNIQUE KEY `categoryId` (`categoryId`);
-
-ALTER TABLE `plugins`
-ADD INDEX `plugin_status` (`status` ASC);
-
-ALTER TABLE `videos`
-ADD INDEX `videos_status_index` (`status` ASC),
-ADD INDEX `is_suggested_index` (`isSuggested` ASC),
-ADD INDEX `views_count_index` (`views_count` ASC),
-ADD INDEX `filename_index` (`filename` ASC);
-
-COMMIT;
-
-SET SQL_MODE=@OLD_SQL_MODE;
-SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
-SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
+-- MySQL Workbench Forward Engineering
+
+SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
+SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
+SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
+
+-- -----------------------------------------------------
+-- Table `users`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `users` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `user` VARCHAR(45) NOT NULL,
+ `name` VARCHAR(45) NULL,
+ `email` VARCHAR(254) NULL,
+ `password` VARCHAR(145) NOT NULL,
+ `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `modified` DATETIME NOT NULL,
+ `isAdmin` TINYINT(1) NOT NULL DEFAULT 0,
+ `status` ENUM('a', 'i') NOT NULL DEFAULT 'a',
+ `photoURL` VARCHAR(255) NULL,
+ `lastLogin` DATETIME NULL,
+ `recoverPass` VARCHAR(255) NULL,
+ `backgroundURL` VARCHAR(255) NULL,
+ `canStream` TINYINT(1) NULL,
+ `canUpload` TINYINT(1) NULL,
+ `canCreateMeet` TINYINT(1) NULL,
+ `canViewChart` TINYINT(1) NOT NULL DEFAULT 0,
+ `about` TEXT NULL,
+ `channelName` VARCHAR(45) NULL,
+ `emailVerified` TINYINT(1) NOT NULL DEFAULT 0,
+ `analyticsCode` VARCHAR(45) NULL DEFAULT NULL,
+ `externalOptions` TEXT NULL,
+ `first_name` VARCHAR(255) NULL DEFAULT NULL,
+ `last_name` VARCHAR(255) NULL DEFAULT NULL,
+ `address` VARCHAR(255) NULL DEFAULT NULL,
+ `zip_code` VARCHAR(45) NULL DEFAULT NULL,
+ `country` VARCHAR(100) NULL DEFAULT NULL,
+ `region` VARCHAR(100) NULL DEFAULT NULL,
+ `city` VARCHAR(100) NULL DEFAULT NULL,
+ `donationLink` VARCHAR(225) NULL DEFAULT NULL,
+ `extra_info` TEXT NULL DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE INDEX `user_UNIQUE` (`user` ASC))
+ENGINE = InnoDB;
+
+
+CREATE TABLE IF NOT EXISTS `users_blob` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `blob` LONGBLOB NULL,
+ `users_id` INT NOT NULL,
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ `type` VARCHAR(45) NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_users_document_image_users1_idx` (`users_id` ASC),
+ CONSTRAINT `fk_users_document_image_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `categories`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `categories` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `name` VARCHAR(45) NOT NULL,
+ `clean_name` VARCHAR(45) NOT NULL,
+ `description` TEXT NULL,
+ `nextVideoOrder` INT(2) NOT NULL DEFAULT '0',
+ `parentId` INT NOT NULL DEFAULT '0',
+ `created` DATETIME NOT NULL,
+ `modified` DATETIME NOT NULL,
+ `iconClass` VARCHAR(45) NOT NULL DEFAULT 'fa fa-folder',
+ `users_id` INT(11) NOT NULL DEFAULT 1,
+ `private` TINYINT(1) NULL DEFAULT 0,
+ `allow_download` TINYINT(1) NULL DEFAULT 1,
+ `order` INT(11) NULL DEFAULT NULL,
+ `suggested` TINYINT(1) NULL DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_categories_users1_idx` (`users_id` ASC),
+ INDEX `clean_name_INDEX2` (`clean_name` ASC),
+ INDEX `sortcategoryOrderIndex` (`order` ASC),
+ INDEX `category_name_idx` (`name` ASC),
+ INDEX `categoriesindex9suggested` (`suggested` ASC),
+ FULLTEXT INDEX `index7cname` (`name`),
+ FULLTEXT INDEX `index8cdescr` (`description`),
+ UNIQUE INDEX `clean_name_UNIQUE` (`clean_name` ASC),
+ CONSTRAINT `fk_categories_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+CREATE TABLE IF NOT EXISTS `sites` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
+ `name` VARCHAR(255) NULL DEFAULT NULL,
+ `url` VARCHAR(255) NOT NULL,
+ `created` DATETIME NULL DEFAULT NULL,
+ `modified` DATETIME NULL DEFAULT NULL,
+ `status` CHAR(1) NULL DEFAULT NULL,
+ `secret` VARCHAR(255) NOT NULL,
+ PRIMARY KEY (`id`))
+ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `videos`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `videos` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `title` VARCHAR(190) NOT NULL,
+ `clean_title` VARCHAR(190) NOT NULL,
+ `description` TEXT NULL,
+ `views_count` INT NOT NULL DEFAULT 0,
+ `views_count_25` INT(11) NULL DEFAULT 0,
+ `views_count_50` INT(11) NULL DEFAULT 0,
+ `views_count_75` INT(11) NULL DEFAULT 0,
+ `views_count_100` INT(11) NULL DEFAULT 0,
+ `status` VARCHAR(16) NOT NULL DEFAULT 'e' ,
+ `created` DATETIME NOT NULL,
+ `modified` DATETIME NOT NULL,
+ `users_id` INT NOT NULL,
+ `categories_id` INT NOT NULL,
+ `filename` VARCHAR(255) NOT NULL,
+ `duration` VARCHAR(15) NOT NULL,
+ `type` ENUM('audio', 'video', 'embed', 'linkVideo', 'linkAudio', 'torrent', 'pdf', 'image', 'gallery', 'article', 'serie', 'zip') NOT NULL DEFAULT 'video',
+ `videoDownloadedLink` VARCHAR(255) NULL,
+ `order` INT UNSIGNED NOT NULL DEFAULT 1,
+ `rotation` SMALLINT NULL DEFAULT 0,
+ `zoom` FLOAT NULL DEFAULT 1,
+ `youtubeId` VARCHAR(45) NULL,
+ `videoLink` VARCHAR(255) NULL,
+ `next_videos_id` INT NULL,
+ `isSuggested` INT(1) NOT NULL DEFAULT 0,
+ `trailer1` VARCHAR(255) NULL DEFAULT NULL,
+ `trailer2` VARCHAR(255) NULL DEFAULT NULL,
+ `trailer3` VARCHAR(255) NULL DEFAULT NULL,
+ `rate` FLOAT(4,2) NULL DEFAULT NULL,
+ `can_download` TINYINT(1) NULL DEFAULT NULL,
+ `can_share` TINYINT(1) NULL DEFAULT NULL,
+ `rrating` VARCHAR(45) NULL DEFAULT NULL,
+ `externalOptions` TEXT NULL DEFAULT NULL,
+ `only_for_paid` TINYINT(1) NULL DEFAULT NULL,
+ `serie_playlists_id` INT(11) NULL DEFAULT NULL,
+ `sites_id` INT(11) NULL,
+ `video_password` VARCHAR(45) NULL DEFAULT NULL,
+ `encoderURL` VARCHAR(255) NULL DEFAULT NULL,
+ `filepath` VARCHAR(255) NULL DEFAULT NULL,
+ `filesize` BIGINT(19) UNSIGNED NULL DEFAULT 0,
+ `live_transmitions_history_id` INT(11) NULL DEFAULT NULL,
+ `total_seconds_watching` INT(11) NULL DEFAULT 0,
+ `duration_in_seconds` INT NULL DEFAULT NULL,
+ `likes` INT(11) NULL DEFAULT NULL,
+ `dislikes` INT(11) NULL DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_videos_users_idx` (`users_id` ASC),
+ INDEX `fk_videos_categories1_idx` (`categories_id` ASC),
+ UNIQUE INDEX `clean_title_UNIQUE` (`clean_title` ASC),
+ INDEX `index5` (`order` ASC),
+ INDEX `fk_videos_videos1_idx` (`next_videos_id` ASC),
+ INDEX `fk_videos_sites1_idx` (`sites_id` ASC),
+ INDEX `clean_title_INDEX` (`clean_title` ASC),
+ INDEX `video_filename_INDEX` (`filename` ASC),
+ INDEX `video_status_idx` (`status` ASC),
+ INDEX `video_type_idx` (`type` ASC) ,
+ INDEX `videos_likes_index` (`likes` ASC),
+ INDEX `videos_dislikes_index` (`dislikes` ASC),
+ INDEX `fk_videos_live_transmitions_history1_idx` (`live_transmitions_history_id` ASC),
+ INDEX `total_sec_watchinindex` (`total_seconds_watching` ASC),
+ FULLTEXT INDEX `index17vname` (`title`),
+ FULLTEXT INDEX `index18vdesc` (`description`),
+ CONSTRAINT `fk_videos_sites1`
+ FOREIGN KEY (`sites_id`)
+ REFERENCES `sites` (`id`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_videos_users`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_videos_categories1`
+ FOREIGN KEY (`categories_id`)
+ REFERENCES `categories` (`id`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_videos_videos1`
+ FOREIGN KEY (`next_videos_id`)
+ REFERENCES `videos` (`id`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+CONSTRAINT `fk_videos_playlists1`
+ FOREIGN KEY (`serie_playlists_id`)
+ REFERENCES `playlists` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+CREATE TABLE IF NOT EXISTS `videos_metadata` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `videos_id` INT NOT NULL,
+ `resolution` VARCHAR(12) NOT NULL,
+ `format` VARCHAR(12) NOT NULL,
+ `stream_id` INT NOT NULL,
+ `name` VARCHAR(128) NOT NULL,
+ `value` VARCHAR(255) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE (`videos_id`, `resolution`, `format`, `stream_id`, `name`),
+ INDEX `fk_videos_metadata_videos1_idx` (`videos_id` ASC),
+ CONSTRAINT `fk_videos_metadata_videos1`
+ FOREIGN KEY (`videos_id`)
+ REFERENCES `videos` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE
+) ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `comments`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `comments` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `comment` TEXT NOT NULL,
+ `videos_id` INT NOT NULL,
+ `users_id` INT NOT NULL,
+ `created` DATETIME NOT NULL,
+ `modified` DATETIME NOT NULL,
+ `comments_id_pai` INT NULL,
+ `pin` INT(1) NOT NULL DEFAULT 0 COMMENT 'If = 1 will be on the top',
+ PRIMARY KEY (`id`),
+ INDEX `fk_comments_videos1_idx` (`videos_id` ASC),
+ INDEX `fk_comments_users1_idx` (`users_id` ASC),
+ INDEX `fk_comments_comments1_idx` (`comments_id_pai` ASC),
+ CONSTRAINT `fk_comments_videos1`
+ FOREIGN KEY (`videos_id`)
+ REFERENCES `videos` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_comments_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_comments_comments1`
+ FOREIGN KEY (`comments_id_pai`)
+ REFERENCES `comments` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `configurations`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `configurations` (
+ `id` INT NOT NULL,
+ `video_resolution` VARCHAR(12) NOT NULL,
+ `users_id` INT NOT NULL,
+ `version` VARCHAR(10) NOT NULL,
+ `webSiteTitle` VARCHAR(45) NOT NULL DEFAULT 'AVideo',
+ `language` VARCHAR(6) NOT NULL DEFAULT 'en',
+ `contactEmail` VARCHAR(254) NOT NULL,
+ `modified` DATETIME NOT NULL,
+ `created` DATETIME NOT NULL,
+ `authGoogle_id` VARCHAR(255) NULL,
+ `authGoogle_key` VARCHAR(255) NULL,
+ `authGoogle_enabled` TINYINT(1) NOT NULL DEFAULT 0,
+ `authFacebook_id` VARCHAR(255) NULL,
+ `authFacebook_key` VARCHAR(255) NULL,
+ `authFacebook_enabled` TINYINT(1) NOT NULL DEFAULT 0,
+ `authCanUploadVideos` TINYINT(1) NOT NULL DEFAULT 0,
+ `authCanViewChart` TINYINT(2) NOT NULL DEFAULT 0,
+ `authCanComment` TINYINT(1) NOT NULL DEFAULT 1,
+ `head` TEXT NULL,
+ `logo` VARCHAR(255) NULL,
+ `logo_small` VARCHAR(255) NULL,
+ `adsense` TEXT NULL,
+ `mode` ENUM('Youtube', 'Gallery') NULL DEFAULT 'Youtube',
+ `disable_analytics` TINYINT(1) NULL DEFAULT 0,
+ `disable_youtubeupload` TINYINT(1) NULL DEFAULT 0,
+ `allow_download` TINYINT(1) NULL DEFAULT 0,
+ `session_timeout` INT NULL DEFAULT 3600,
+ `autoplay` TINYINT(1) NULL,
+ `theme` VARCHAR(45) NULL DEFAULT 'default',
+ `smtp` TINYINT(1) NULL,
+ `smtpAuth` TINYINT(1) NULL,
+ `smtpSecure` VARCHAR(255) NULL COMMENT '\'ssl\'; // secure transfer enabled REQUIRED for Gmail',
+ `smtpHost` VARCHAR(255) NULL COMMENT '\"smtp.gmail.com\"',
+ `smtpUsername` VARCHAR(255) NULL COMMENT '\"email@gmail.com\"',
+ `smtpPassword` VARCHAR(255) NULL,
+ `smtpPort` INT NULL,
+ `encoderURL` VARCHAR(255) NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_configurations_users1_idx` (`users_id` ASC),
+ CONSTRAINT `fk_configurations_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `videos_statistics`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `videos_statistics` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `when` DATETIME NOT NULL,
+ `ip` VARCHAR(45) NULL,
+ `users_id` INT NULL,
+ `videos_id` INT NOT NULL,
+ `created` DATETIME NULL DEFAULT NULL,
+ `modified` DATETIME NULL DEFAULT NULL,
+ `lastVideoTime` INT(11) NULL DEFAULT NULL,
+ `session_id` VARCHAR(45) NOT NULL,
+ `seconds_watching_video` INT(11) NULL DEFAULT NULL,
+ `json` TEXT NULL DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_videos_statistics_users1_idx` (`users_id` ASC),
+ INDEX `fk_videos_statistics_videos1_idx` (`videos_id` ASC),
+ INDEX `when_statisci` (`when` ASC),
+ INDEX `session_id_statistics` (`session_id` ASC),
+ INDEX `sec_watchin_videos` (`seconds_watching_video` ASC),
+ CONSTRAINT `fk_videos_statistics_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_videos_statistics_videos1`
+ FOREIGN KEY (`videos_id`)
+ REFERENCES `videos` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `likes`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `likes` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `like` INT(1) NOT NULL DEFAULT 0 COMMENT '1 = Like\n0 = Does not metter\n-1 = Dislike',
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ `videos_id` INT NOT NULL,
+ `users_id` INT NOT NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_likes_videos1_idx` (`videos_id` ASC),
+ INDEX `fk_likes_users1_idx` (`users_id` ASC),
+ INDEX `likes_likes_idx` (`like` ASC),
+ CONSTRAINT `fk_likes_videos1`
+ FOREIGN KEY (`videos_id`)
+ REFERENCES `videos` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_likes_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `users_groups`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `users_groups` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `group_name` VARCHAR(255) NULL,
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ PRIMARY KEY (`id`))
+ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `users_has_users_groups`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `users_has_users_groups` (
+ `users_id` INT NOT NULL,
+ `users_groups_id` INT NOT NULL,
+ PRIMARY KEY (`users_id`, `users_groups_id`),
+ INDEX `fk_users_has_users_groups_users_groups1_idx` (`users_groups_id` ASC),
+ INDEX `fk_users_has_users_groups_users1_idx` (`users_id` ASC),
+ UNIQUE INDEX `index_user_groups_unique` (`users_groups_id` ASC, `users_id` ASC),
+ CONSTRAINT `fk_users_has_users_groups_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_users_has_users_groups_users_groups1`
+ FOREIGN KEY (`users_groups_id`)
+ REFERENCES `users_groups` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `videos_group_view`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `videos_group_view` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `users_groups_id` INT NOT NULL,
+ `videos_id` INT NOT NULL,
+ INDEX `fk_videos_group_view_users_groups1_idx` (`users_groups_id` ASC),
+ INDEX `fk_videos_group_view_videos1_idx` (`videos_id` ASC),
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_videos_group_view_users_groups1`
+ FOREIGN KEY (`users_groups_id`)
+ REFERENCES `users_groups` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_videos_group_view_videos1`
+ FOREIGN KEY (`videos_id`)
+ REFERENCES `videos` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `subscribes`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `subscribes` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `email` VARCHAR(100) NOT NULL,
+ `status` ENUM('a', 'i') NOT NULL DEFAULT 'a',
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ `ip` VARCHAR(45) NULL,
+ `users_id` INT NOT NULL DEFAULT 1 COMMENT 'subscribes to user channel',
+ `notify` TINYINT(1) NOT NULL DEFAULT 1,
+ `subscriber_users_id` INT(11) NOT NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_subscribes_users1_idx` (`users_id` ASC),
+ INDEX `fk_subscribes_users2_idx` (`subscriber_users_id` ASC),
+ CONSTRAINT `fk_subscribes_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_subscribes_users2`
+ FOREIGN KEY (`subscriber_users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `playlists`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `playlists` (
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
+ `name` VARCHAR(45) NOT NULL,
+ `created` DATETIME NULL DEFAULT NULL,
+ `modified` DATETIME NULL DEFAULT NULL,
+ `users_id` INT(11) NOT NULL,
+ `status` ENUM('public', 'private', 'unlisted', 'favorite', 'watch_later') NOT NULL DEFAULT 'public',
+ `showOnTV` TINYINT NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_playlists_users1_idx` (`users_id` ASC),
+ INDEX `showOnTVindex3` (`showOnTV` ASC),
+ CONSTRAINT `fk_playlists_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `playlists_has_videos`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `playlists_has_videos` (
+ `playlists_id` INT NOT NULL,
+ `videos_id` INT NOT NULL,
+ `order` INT NULL,
+ PRIMARY KEY (`playlists_id`, `videos_id`),
+ INDEX `fk_playlists_has_videos_videos1_idx` (`videos_id` ASC),
+ INDEX `fk_playlists_has_videos_playlists1_idx` (`playlists_id` ASC),
+ CONSTRAINT `fk_playlists_has_videos_playlists1`
+ FOREIGN KEY (`playlists_id`)
+ REFERENCES `playlists` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_playlists_has_videos_videos1`
+ FOREIGN KEY (`videos_id`)
+ REFERENCES `videos` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `plugins`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `plugins` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `uuid` VARCHAR(45) NOT NULL,
+ `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active',
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ `object_data` TEXT NULL,
+ `name` VARCHAR(255) NOT NULL,
+ `dirName` VARCHAR(255) NOT NULL,
+ `pluginversion` VARCHAR(6) NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE INDEX `uuid_UNIQUE` (`uuid` ASC))
+ENGINE = InnoDB;
+
+
+-- -----------------------------------------------------
+-- Table `comments_likes`
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS `comments_likes` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `like` INT(1) NOT NULL,
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ `users_id` INT NOT NULL,
+ `comments_id` INT NOT NULL,
+ PRIMARY KEY (`id`),
+ INDEX `fk_comments_likes_users1_idx` (`users_id` ASC),
+ INDEX `fk_comments_likes_comments1_idx` (`comments_id` ASC),
+ CONSTRAINT `fk_comments_likes_users1`
+ FOREIGN KEY (`users_id`)
+ REFERENCES `users` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_comments_likes_comments1`
+ FOREIGN KEY (`comments_id`)
+ REFERENCES `comments` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+-- -----------------------------------------------------
+-- Table `category_type_cache`
+-- -----------------------------------------------------
+CREATE TABLE `category_type_cache` (
+ `categoryId` int(11) NOT NULL,
+ `type` int(2) NOT NULL COMMENT '0=both, 1=audio, 2=video' DEFAULT 0,
+ `manualSet` int(1) NOT NULL COMMENT '0=auto, 1=manual' DEFAULT 0
+
+) ENGINE=InnoDB;
+
+CREATE TABLE IF NOT EXISTS `categories_has_users_groups` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `categories_id` INT(11) NOT NULL,
+ `users_groups_id` INT(11) NOT NULL,
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ `status` CHAR(1) NOT NULL DEFAULT 'a',
+ PRIMARY KEY (`id`),
+ INDEX `fk_categories_has_users_groups_users_groups1_idx` (`users_groups_id` ASC),
+ INDEX `fk_categories_has_users_groups_categories1_idx` (`categories_id` ASC),
+ CONSTRAINT `fk_categories_has_users_groups_categories1`
+ FOREIGN KEY (`categories_id`)
+ REFERENCES `categories` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE,
+ CONSTRAINT `fk_categories_has_users_groups_users_groups1`
+ FOREIGN KEY (`users_groups_id`)
+ REFERENCES `users_groups` (`id`)
+ ON DELETE CASCADE
+ ON UPDATE CASCADE)
+ENGINE = InnoDB;
+
+CREATE TABLE IF NOT EXISTS `users_extra_info` (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `field_name` VARCHAR(45) NOT NULL,
+ `field_type` VARCHAR(45) NOT NULL,
+ `field_options` TEXT NULL,
+ `field_default_value` VARCHAR(45) NULL,
+ `parameters` TEXT NULL,
+ `created` DATETIME NULL,
+ `modified` DATETIME NULL,
+ `status` CHAR(1) NOT NULL DEFAULT 'a',
+ `order` INT NOT NULL DEFAULT 0,
+ PRIMARY KEY (`id`),
+ INDEX `ordersortusers_extra_info` USING BTREE (`order`))
+ENGINE = InnoDB;
+
+ALTER TABLE `category_type_cache`
+ ADD UNIQUE KEY `categoryId` (`categoryId`);
+
+ALTER TABLE `plugins`
+ADD INDEX `plugin_status` (`status` ASC);
+
+ALTER TABLE `videos`
+ADD INDEX `videos_status_index` (`status` ASC),
+ADD INDEX `is_suggested_index` (`isSuggested` ASC),
+ADD INDEX `views_count_index` (`views_count` ASC),
+ADD INDEX `filename_index` (`filename` ASC);
+
+COMMIT;
+
+SET SQL_MODE=@OLD_SQL_MODE;
+SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
+SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
diff --git a/install/deleteOrphanFiles.php b/install/deleteOrphanFiles.php
index 288c6a19f8..10d71ff45f 100644
--- a/install/deleteOrphanFiles.php
+++ b/install/deleteOrphanFiles.php
@@ -1,85 +1,83 @@
- $value) {
- $dir = "{$path}{$value}";
- if (!is_dir($dir)) {
- $bname = basename($dir);
- if (in_array($bname, $doNotDeleteFilesList) || preg_match('/configuration\./i', $bname)) {
- unset($files[$key]);
- } else {
- $filename = Video::getCleanFilenameFromFile($dir);
- $video = Video::getVideoFromFileName($filename, true);
- if (!empty($video)) {
- //echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
- unset($files[$key]);
- } else {
- $files[$key] = array($value, $dir);
- //echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
- }
- }
- continue;
- }
- $file = "{$dir}" . DIRECTORY_SEPARATOR . "{$lockFilename}";
- if (file_exists($file)) {
- $filename = Video::getCleanFilenameFromFile($dir);
- $video = Video::getVideoFromFileName($filename, true);
- if (!empty($video)) {
- //echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
- unset($files[$key]);
- } else {
- $files[$key] = array($value, $dir);
- //echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
- }
- } else {
- //echo "*** Lock file does not exists {$file} ".PHP_EOL;
- unset($files[$key]);
- }
-}
-
-$total = count($files);
-echo "*** Total filenames " . $total . " Will be deleted\n";
-
-if (empty($total)) {
- exit;
-}
-
-$totalSize = 0;
-foreach ($files as $key => $value) {
- $size = getDirSize($value[1]);
- $totalSize += $size;
- echo "{$value[0]} => $value[1] " . (humanFileSize($size)) . " \n";
-}
-echo "*** Confirm Delete Them (" . humanFileSize($totalSize) . ")? y/n: ";
-
-ob_flush();
-$confirm = trim(readline(""));
-if (!empty($confirm) && strtolower($confirm) === 'y') {
- foreach ($files as $key => $value) {
- if (is_dir($value[1])) {
- rrmdir($value[1]);
- if (is_dir($value[1])) {
- echo "$value[1] Directory Deleted \n";
- } else {
- echo "$value[1] Directory Could Not be Deleted \n";
- }
- } else
- if (unlink($value[1])) {
- echo "$value[1] Deleted \n";
- } else {
- echo "$value[1] Could Not be Deleted \n";
- }
- }
-}
+ $value) {
+ $dir = "{$path}{$value}";
+ if (!is_dir($dir)) {
+ $bname = basename($dir);
+ if (in_array($bname, $doNotDeleteFilesList) || preg_match('/configuration\./i', $bname)) {
+ unset($files[$key]);
+ } else {
+ $filename = Video::getCleanFilenameFromFile($dir);
+ $video = Video::getVideoFromFileName($filename, true);
+ if (!empty($video)) {
+ //echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
+ unset($files[$key]);
+ } else {
+ $files[$key] = [$value, $dir];
+ //echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
+ }
+ }
+ continue;
+ }
+ $file = "{$dir}" . DIRECTORY_SEPARATOR . "{$lockFilename}";
+ if (file_exists($file)) {
+ $filename = Video::getCleanFilenameFromFile($dir);
+ $video = Video::getVideoFromFileName($filename, true);
+ if (!empty($video)) {
+ //echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
+ unset($files[$key]);
+ } else {
+ $files[$key] = [$value, $dir];
+ //echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
+ }
+ } else {
+ //echo "*** Lock file does not exists {$file} ".PHP_EOL;
+ unset($files[$key]);
+ }
+}
+
+$total = count($files);
+echo "*** Total filenames " . $total . " Will be deleted\n";
+
+if (empty($total)) {
+ exit;
+}
+
+$totalSize = 0;
+foreach ($files as $key => $value) {
+ $size = getDirSize($value[1]);
+ $totalSize += $size;
+ echo "{$value[0]} => $value[1] " . (humanFileSize($size)) . " \n";
+}
+echo "*** Confirm Delete Them (" . humanFileSize($totalSize) . ")? y/n: ";
+
+ob_flush();
+$confirm = trim(readline(""));
+if (!empty($confirm) && strtolower($confirm) === 'y') {
+ foreach ($files as $key => $value) {
+ if (is_dir($value[1])) {
+ rrmdir($value[1]);
+ if (is_dir($value[1])) {
+ echo "$value[1] Directory Deleted \n";
+ } else {
+ echo "$value[1] Directory Could Not be Deleted \n";
+ }
+ } elseif (unlink($value[1])) {
+ echo "$value[1] Deleted \n";
+ } else {
+ echo "$value[1] Could Not be Deleted \n";
+ }
+ }
+}
diff --git a/install/deleteStorageFiles.php b/install/deleteStorageFiles.php
index 2e9cb8d8f3..e916f5d141 100644
--- a/install/deleteStorageFiles.php
+++ b/install/deleteStorageFiles.php
@@ -1,112 +1,110 @@
- $value) {
- if (!empty($checkedFiles[$value[0]])) {
- continue;
- }
- $checkedFiles[$value[0]] = array(true);
- $getUsageFromFilename = YPTStorage::getUsageFromFilename($value[0]);
- $checkedFiles[$value[0]][] = $getUsageFromFilename;
-
- if ($getUsageFromFilename < 200000) {
- //echo "Local file is too small, probably transfered already or is a directory (HLS) \n";
- continue;
- }
- $video = Video::getVideoFromFileName($value[0], true);
- if (!empty($video)) {
- $sites_id = $video['sites_id'];
- if ($sites_id > 0) {
- $count++;
- if ($count > $max) {
- exit;
- }
- echo "{$count}: Local file videos_id = {$video['id']} {$video['title']}=> $getUsageFromFilename " . humanFileSize($getUsageFromFilename) . "\n";
- $source_size = YPTStorage::getFileSize($video['id'], -1);
- $destination_size = YPTStorage::getFileSize($video['id'], $sites_id);
- if (!empty($destination_size) && $destination_size > 5000000 && $source_size <= $destination_size) {
- $countExecuted++;
- if ($countExecuted > $max) {
- exit;
- }
- YPTStorage::createDummy($video['id']);
- $tgzFile = $global['systemRootPath'] . "videos/{$video['filename']}.tgz";
- if(file_exists($tgzFile)){
- unlink($tgzFile);
- }
- echo "****** File size is the same videos_id = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
- //exit;
- } else if($source_sizee > 5000000){
- echo "----- ERROR File size is NOT the same videos_id and it's supposed to be on the storage = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
- } else if($source_sizee > 5000000){
- echo "+++++ All seems fine with video {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
- }
- } else {
- //echo "The video_id {$video['id']} ({$video['title']}) is not hosted on the storage\n";
- }
- }
-}
\ No newline at end of file
+ $value) {
+ if (!empty($checkedFiles[$value[0]])) {
+ continue;
+ }
+ $checkedFiles[$value[0]] = [true];
+ $getUsageFromFilename = YPTStorage::getUsageFromFilename($value[0]);
+ $checkedFiles[$value[0]][] = $getUsageFromFilename;
+
+ if ($getUsageFromFilename < 200000) {
+ //echo "Local file is too small, probably transfered already or is a directory (HLS) \n";
+ continue;
+ }
+ $video = Video::getVideoFromFileName($value[0], true);
+ if (!empty($video)) {
+ $sites_id = $video['sites_id'];
+ if ($sites_id > 0) {
+ $count++;
+ if ($count > $max) {
+ exit;
+ }
+ echo "{$count}: Local file videos_id = {$video['id']} {$video['title']}=> $getUsageFromFilename " . humanFileSize($getUsageFromFilename) . "\n";
+ $source_size = YPTStorage::getFileSize($video['id'], -1);
+ $destination_size = YPTStorage::getFileSize($video['id'], $sites_id);
+ if (!empty($destination_size) && $destination_size > 5000000 && $source_size <= $destination_size) {
+ $countExecuted++;
+ if ($countExecuted > $max) {
+ exit;
+ }
+ YPTStorage::createDummy($video['id']);
+ $tgzFile = $global['systemRootPath'] . "videos/{$video['filename']}.tgz";
+ if (file_exists($tgzFile)) {
+ unlink($tgzFile);
+ }
+ echo "****** File size is the same videos_id = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
+ //exit;
+ } elseif ($source_sizee > 5000000) {
+ echo "----- ERROR File size is NOT the same videos_id and it's supposed to be on the storage = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
+ } elseif ($source_sizee > 5000000) {
+ echo "+++++ All seems fine with video {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
+ }
+ } else {
+ //echo "The video_id {$video['id']} ({$video['title']}) is not hosted on the storage\n";
+ }
+ }
+}
diff --git a/install/deleteTGZFiles.php b/install/deleteTGZFiles.php
index 4961d4bab4..44967c4da1 100644
--- a/install/deleteTGZFiles.php
+++ b/install/deleteTGZFiles.php
@@ -1,26 +1,25 @@
- $row) {
- $count++;
- $filename = $row['filename'];
- $totalDeleted = Video::deleteThumbs($filename, true, $checkIfIsCorrupted);
- if($totalDeleted){
- echo "{$total}/{$count} Thumbs deleted ($totalDeleted) from {$row['title']}".PHP_EOL;
- }else{
- echo "{$total}/{$count} Thumbs NOT deleted from {$row['title']}".PHP_EOL;
- }
- }
-} else {
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
-}
\ No newline at end of file
+ $row) {
+ $count++;
+ $filename = $row['filename'];
+ $totalDeleted = Video::deleteThumbs($filename, true, $checkIfIsCorrupted);
+ if ($totalDeleted) {
+ echo "{$total}/{$count} Thumbs deleted ($totalDeleted) from {$row['title']}".PHP_EOL;
+ } else {
+ echo "{$total}/{$count} Thumbs NOT deleted from {$row['title']}".PHP_EOL;
+ }
+ }
+} else {
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+}
diff --git a/install/fixDynamicUsergroups.php b/install/fixDynamicUsergroups.php
index 029fc68254..b5d0b0a563 100644
--- a/install/fixDynamicUsergroups.php
+++ b/install/fixDynamicUsergroups.php
@@ -1,43 +1,42 @@
-0, 'NoDynamic'=>0, 'Deleted'=>0);
-if ($res != false) {
- foreach ($fullData as $key => $row) {
- $rowsUser = UserGroups::getUserGroups($row['id']);
- if(empty($rowsUser)){
- //echo "This user has no permanent usergroups".PHP_EOL;
- $count['NoPermanent']++;
- }else{
- $user = new User($row['id'], $row['user'], $row['password']);
- $user->login(true, false, true);
- $user_groups_id = AVideoPlugin::getDynamicUserGroupsId($row['id']);
- if(empty($user_groups_id)){
- //echo "This user has no dynamic usergroups".PHP_EOL;
- $count['NoDynamic']++;
- }else{
- echo "found dynamic usergroups from users_id={$row['id']} user={$row['user']} usergroups=". implode(',', $user_groups_id).PHP_EOL;
- $sqlUG = "DELETE FROM users_has_users_groups WHERE users_id = ? AND users_groups_id IN (". implode(',', $user_groups_id).")";
- sqlDAL::writeSql($sqlUG, "i", array($row['id']));
- $count['Deleted']++;
- }
- }
- }
-} else {
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
-}
-echo "Finish, ". json_encode($count);
\ No newline at end of file
+0, 'NoDynamic'=>0, 'Deleted'=>0];
+if ($res != false) {
+ foreach ($fullData as $key => $row) {
+ $rowsUser = UserGroups::getUserGroups($row['id']);
+ if (empty($rowsUser)) {
+ //echo "This user has no permanent usergroups".PHP_EOL;
+ $count['NoPermanent']++;
+ } else {
+ $user = new User($row['id'], $row['user'], $row['password']);
+ $user->login(true, false, true);
+ $user_groups_id = AVideoPlugin::getDynamicUserGroupsId($row['id']);
+ if (empty($user_groups_id)) {
+ //echo "This user has no dynamic usergroups".PHP_EOL;
+ $count['NoDynamic']++;
+ } else {
+ echo "found dynamic usergroups from users_id={$row['id']} user={$row['user']} usergroups=". implode(',', $user_groups_id).PHP_EOL;
+ $sqlUG = "DELETE FROM users_has_users_groups WHERE users_id = ? AND users_groups_id IN (". implode(',', $user_groups_id).")";
+ sqlDAL::writeSql($sqlUG, "i", [$row['id']]);
+ $count['Deleted']++;
+ }
+ }
+ }
+} else {
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+}
+echo "Finish, ". json_encode($count);
diff --git a/install/getAllWebp.php b/install/getAllWebp.php
index ec6ab2c12b..93696498ba 100644
--- a/install/getAllWebp.php
+++ b/install/getAllWebp.php
@@ -1,97 +1,98 @@
- [
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- ],
- ]);
-
- $file_headers = @get_headers($url, 0, $context);
- if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') {
- echo "\nGet webp not found {$url}";
- ob_flush();
- continue;
- } else {
- $url = $config->getEncoderURL() . "getImageMP4/" . base64_encode($url) . "/webp/{$duration}";
- $image = url_get_contents($url);
- file_put_contents($destination, $image);
- }
- } else {
- echo "\nVideo URL empty";
- ob_flush();
- }
-
- echo "\nGet done";
- ob_flush();
- } else {
- echo "\nFile exists: " . $value['title'] . " {$destination}";
- ob_flush();
- }
-
- echo "\nFinish: " . $value['title'];
- echo "\n******\n";
- ob_flush();
-}
-
-function getFirstVideoURL($videoFileName) {
- $types = array('', '_Low', '_SD', '_HD');
- $videosList = getVideosURL($videoFileName);
- if (!empty($videosList['m3u8']["url"])) {
- return $videosList['m3u8']["url"];
- }
- foreach ($types as $value) {
- if (!empty($videosList['mp4' . $value]["url"])) {
- return $videosList['mp4' . $value]["url"];
- } else if (!empty($videosList['webm' . $value]["url"])) {
- return $videosList['webm' . $value]["url"];
- }
- }
- return false;
-}
-
-function getFirstVideoPath($videoFileName) {
- $types = array('', '_Low', '_SD', '_HD');
- $videosList = getVideosURL($videoFileName);
- if (!empty($videosList['m3u8']["path"])) {
- return $videosList['m3u8']["path"];
- }
- foreach ($types as $value) {
- if (!empty($videosList['mp4' . $value]["path"])) {
- return $videosList['mp4' . $value]["path"];
- } else if (!empty($videosList['webm' . $value]["path"])) {
- return $videosList['webm' . $value]["path"];
- }
- }
- return false;
-}
+ [
+ 'verify_peer' => false,
+ 'verify_peer_name' => false,
+ ],
+ ]);
+
+ $file_headers = @get_headers($url, 0, $context);
+ if (!$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found') {
+ echo "\nGet webp not found {$url}";
+ ob_flush();
+ continue;
+ } else {
+ $url = $config->getEncoderURL() . "getImageMP4/" . base64_encode($url) . "/webp/{$duration}";
+ $image = url_get_contents($url);
+ file_put_contents($destination, $image);
+ }
+ } else {
+ echo "\nVideo URL empty";
+ ob_flush();
+ }
+
+ echo "\nGet done";
+ ob_flush();
+ } else {
+ echo "\nFile exists: " . $value['title'] . " {$destination}";
+ ob_flush();
+ }
+
+ echo "\nFinish: " . $value['title'];
+ echo "\n******\n";
+ ob_flush();
+}
+
+function getFirstVideoURL($videoFileName)
+{
+ $types = ['', '_Low', '_SD', '_HD'];
+ $videosList = getVideosURL($videoFileName);
+ if (!empty($videosList['m3u8']["url"])) {
+ return $videosList['m3u8']["url"];
+ }
+ foreach ($types as $value) {
+ if (!empty($videosList['mp4' . $value]["url"])) {
+ return $videosList['mp4' . $value]["url"];
+ } elseif (!empty($videosList['webm' . $value]["url"])) {
+ return $videosList['webm' . $value]["url"];
+ }
+ }
+ return false;
+}
+
+function getFirstVideoPath($videoFileName)
+{
+ $types = ['', '_Low', '_SD', '_HD'];
+ $videosList = getVideosURL($videoFileName);
+ if (!empty($videosList['m3u8']["path"])) {
+ return $videosList['m3u8']["path"];
+ }
+ foreach ($types as $value) {
+ if (!empty($videosList['mp4' . $value]["path"])) {
+ return $videosList['mp4' . $value]["path"];
+ } elseif (!empty($videosList['webm' . $value]["path"])) {
+ return $videosList['webm' . $value]["path"];
+ }
+ }
+ return false;
+}
diff --git a/install/index.php b/install/index.php
index 5ca44029b6..efb6904f83 100644
--- a/install/index.php
+++ b/install/index.php
@@ -1,363 +1,350 @@
-
-
-
-
- Install AVideo
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Your system is installed, remove the install directory to continue
-
- Go to the main page
-
-
-
-
-
-
-
-
-
Check list
-
-
-
-
- is Present
-
-
-
-
- Your server is , you must install Apache
-
-
-
-
-
- PHP is present.
-
-
-
-
- Your PHP version is . PHP 7.3 or newer is required.
-
-
-
-
-
-
- Your videos directory is writable
-
-
-
-
- Your videos directory must be writable
-
-
- The video directory does not exists, AVideo had no permition to create it, you must create it manualy!
-
-
sudo mkdir
-
-
- Then you can set the permissions (www-data means apache user).
-
-
sudo chown www-data:www-data && sudo chmod 755
-
-
-
-
-
-
-
- Your post_max_size is
-
-
-
-
- Your post_max_size is , it must be at least 100M
-
-
- Edit the php.ini file
-
-
sudo nano
-
-
-
-
-
-
-
- Your upload_max_filesize is
-
-
-
-
- Your upload_max_filesize is , it must be at least 100M
-
-
- Edit the php.ini file
-
-
+
+ Your system is installed, remove the install directory to continue
+
+ Go to the main page
+
+
+
+
+
+
+
+
+
Check list
+
+
+
+
+ is Present
+
+
+
+
+ Your server is , you must install Apache
+
+
+
+
+
+ PHP is present.
+
+
+
+
+ Your PHP version is . PHP 7.3 or newer is required.
+
+
+
+
+
+
+ Your videos directory is writable
+
+
+
+
+ Your videos directory must be writable
+
+
+ The video directory does not exists, AVideo had no permition to create it, you must create it manualy!
+
+
sudo mkdir
+
+
+ Then you can set the permissions (www-data means apache user).
+
+
sudo chown www-data:www-data && sudo chmod 755
+
+
+
+
+
+
+
+ Your post_max_size is
+
+
+
+
+ Your post_max_size is , it must be at least 100M
+
+
+ Edit the php.ini file
+
+
sudo nano
+
+
+
+
+
+
+
+ Your upload_max_filesize is
+
+
+
+
+ Your upload_max_filesize is , it must be at least 100M
+
+
+ Edit the php.ini file
+
+
{$_POST['comment']}";
- //Create a new PHPMailer instance
- $mail = new \PHPMailer\PHPMailer\PHPMailer;
- setSiteSendMessage($mail);
- //$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
- //var_dump($mail->SMTPAuth, $mail);
- //Set who the message is to be sent from
-
- $replyTo = User::getEmail_();
- if (empty($replyTo)) {
- $replyTo = $config->getContactEmail();
- }
-
- $sendTo = $_POST['email'];
-
- // if it is from contact form send the message to the siteowner and the sender is the email on the form field
- if (!empty($_POST['contactForm'])) {
- $replyTo = $_POST['email'];
- $sendTo = $config->getContactEmail();
- }
-
- if (filter_var($sendTo, FILTER_VALIDATE_EMAIL)) {
- $mail->AddReplyTo($replyTo);
- $mail->setFrom($replyTo);
- //Set who the message is to be sent to
- $mail->addAddress($sendTo);
- //Set the subject line
- $mail->Subject = 'Message From Site ' . $config->getWebSiteTitle() . " ({$_POST['first_name']})";
- $mail->msgHTML($msg);
-
- //send the message, check for errors
- if (!$mail->send()) {
- $obj->error = __("Message could not be sent") . " (" . $mail->ErrorInfo.")";
- } else {
- $obj->success = __("Message sent");
- }
- } else {
- $obj->error = __("The email is invalid");
- }
-} else {
- $obj->error = __("Your code is not valid");
-}
-_error_log("sendEmail: ".$obj->error);
-header('Content-Type: application/json');
-echo json_encode($obj);
+error = '';
+if ($valid) {
+ $msg = "Email: {$_POST['email']}
{$_POST['comment']}";
+ //Create a new PHPMailer instance
+ $mail = new \PHPMailer\PHPMailer\PHPMailer();
+ setSiteSendMessage($mail);
+ //$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
+ //var_dump($mail->SMTPAuth, $mail);
+ //Set who the message is to be sent from
+
+ $replyTo = User::getEmail_();
+ if (empty($replyTo)) {
+ $replyTo = $config->getContactEmail();
+ }
+
+ $sendTo = $_POST['email'];
+
+ // if it is from contact form send the message to the siteowner and the sender is the email on the form field
+ if (!empty($_POST['contactForm'])) {
+ $replyTo = $_POST['email'];
+ $sendTo = $config->getContactEmail();
+ }
+
+ if (filter_var($sendTo, FILTER_VALIDATE_EMAIL)) {
+ $mail->AddReplyTo($replyTo);
+ $mail->setFrom($replyTo);
+ //Set who the message is to be sent to
+ $mail->addAddress($sendTo);
+ //Set the subject line
+ $mail->Subject = 'Message From Site ' . $config->getWebSiteTitle() . " ({$_POST['first_name']})";
+ $mail->msgHTML($msg);
+
+ //send the message, check for errors
+ if (!$mail->send()) {
+ $obj->error = __("Message could not be sent") . " (" . $mail->ErrorInfo.")";
+ } else {
+ $obj->success = __("Message sent");
+ }
+ } else {
+ $obj->error = __("The email is invalid");
+ }
+} else {
+ $obj->error = __("Your code is not valid");
+}
+_error_log("sendEmail: ".$obj->error);
+header('Content-Type: application/json');
+echo json_encode($obj);
diff --git a/objects/sendSiteEmailAsync.php b/objects/sendSiteEmailAsync.php
index ad8cd7b740..ac996e72a5 100644
--- a/objects/sendSiteEmailAsync.php
+++ b/objects/sendSiteEmailAsync.php
@@ -1,32 +1,31 @@
-to);
-$subject = ($json->subject);
-$message = ($json->message);
-
-sendSiteEmail($to, $subject, $message);
-_error_log('sendSiteEmailAsync: Complete');
+to);
+$subject = ($json->subject);
+$message = ($json->message);
+
+sendSiteEmail($to, $subject, $message);
+_error_log('sendSiteEmailAsync: Complete');
diff --git a/objects/sites.php b/objects/sites.php
index 49ef0309ca..b470e571bb 100644
--- a/objects/sites.php
+++ b/objects/sites.php
@@ -1,97 +1,113 @@
-name;
- }
-
- function getUrl() {
- return $this->url;
- }
-
- function getStatus() {
- return $this->status;
- }
-
- function setName($name) {
- $this->name = $name;
- }
-
- function setUrl($url) {
- $this->url = $url;
- }
-
- function setStatus($status) {
- $this->status = $status;
- }
-
- function getSecret() {
- return $this->secret;
- }
-
- function setSecret($secret) {
- $this->secret = $secret;
- }
-
- function save() {
- if(empty($this->getSecret())){
- $this->setSecret(md5(uniqid()));
- }
-
- $siteURL = $this->getUrl();
- if (substr($siteURL, -1) !== '/') {
- $siteURL .= "/";
- }
- $this->setUrl($siteURL);
- return parent::save();
- }
-
- static function getFromFileName($fileName){
- $obj = new stdClass();
- $obj->url = "";
- $obj->secret = "";
- $obj->filename = $fileName;
- $video = Video::getVideoFromFileNameLight($fileName);
- if(!empty($video['sites_id'])){
- $site = new Sites($video['sites_id']);
- $obj->url = $site->getUrl();
- $obj->secret = $site->getSecret();
- }
- return $obj;
- }
-
- static function getFromStatus($status) {
- global $global;
- if (!static::isTableInstalled()) {
- return false;
- }
- $sql = "SELECT * FROM " . static::getTableName() . " WHERE status = ? ";
-
- $res = sqlDAL::readSql($sql, 's', array($status));
- $fullData = sqlDAL::fetchAllAssoc($res);
- sqlDAL::close($res);
- $rows = array();
- if ($res != false) {
- foreach ($fullData as $row) {
- $rows[] = $row;
- }
- } else {
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
- }
- return $rows;
- }
-
-}
+name;
+ }
+
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ public function setUrl($url)
+ {
+ $this->url = $url;
+ }
+
+ public function setStatus($status)
+ {
+ $this->status = $status;
+ }
+
+ public function getSecret()
+ {
+ return $this->secret;
+ }
+
+ public function setSecret($secret)
+ {
+ $this->secret = $secret;
+ }
+
+ public function save()
+ {
+ if (empty($this->getSecret())) {
+ $this->setSecret(md5(uniqid()));
+ }
+
+ $siteURL = $this->getUrl();
+ if (substr($siteURL, -1) !== '/') {
+ $siteURL .= "/";
+ }
+ $this->setUrl($siteURL);
+ return parent::save();
+ }
+
+ public static function getFromFileName($fileName)
+ {
+ $obj = new stdClass();
+ $obj->url = '';
+ $obj->secret = '';
+ $obj->filename = $fileName;
+ $video = Video::getVideoFromFileNameLight($fileName);
+ if (!empty($video['sites_id'])) {
+ $site = new Sites($video['sites_id']);
+ $obj->url = $site->getUrl();
+ $obj->secret = $site->getSecret();
+ }
+ return $obj;
+ }
+
+ public static function getFromStatus($status)
+ {
+ global $global;
+ if (!static::isTableInstalled()) {
+ return false;
+ }
+ $sql = "SELECT * FROM " . static::getTableName() . " WHERE status = ? ";
+
+ $res = sqlDAL::readSql($sql, 's', [$status]);
+ $fullData = sqlDAL::fetchAllAssoc($res);
+ sqlDAL::close($res);
+ $rows = [];
+ if ($res != false) {
+ foreach ($fullData as $row) {
+ $rows[] = $row;
+ }
+ } else {
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ }
+ return $rows;
+ }
+}
diff --git a/objects/status.json.php b/objects/status.json.php
index 7be718826d..a616c37553 100644
--- a/objects/status.json.php
+++ b/objects/status.json.php
@@ -1,40 +1,40 @@
-max_file_size = get_max_file_size();
-$obj->file_upload_max_size = file_upload_max_size();
-$obj->videoStorageLimitMinutes = $global['videoStorageLimitMinutes'];
-$obj->currentStorageUsage = getSecondsTotalVideosLength();
-$obj->webSiteLogo = $config->getLogo(true);
-$obj->webSiteTitle = $config->getWebSiteTitle();
-$obj->PHPSESSID = session_id();
-$obj->version = $config->getVersion();
-$obj->mobileSreamerVersion = MobileManager::getVersion();
-$obj->reportVideoPluginEnabled = AVideoPlugin::isEnabledByName("ReportVideo");
-$obj->oauthLogin = array();
-$obj->oauthLogin[] = array('type'=>'Facebook', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginFacebook')));
-$obj->oauthLogin[] = array('type'=>'Google', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginGoogle')));
-$obj->oauthLogin[] = array('type'=>'Twitter', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginTwitter')));
-$obj->oauthLogin[] = array('type'=>'LinkedIn', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginLinkedin')));
-$obj->oauthLogin[] = array('type'=>'Apple', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginApple')));
-
-$obj->plugins = array();
-$plugins = Plugin::getAllEnabled();
-foreach ($plugins as $value) {
- $p = AVideoPlugin::loadPlugin($value['dirName']);
- if (is_object($p)) {
- $info = $p->getMobileInfo();
- if(!empty($info)){
- $obj->plugins[$value['dirName']] = $info;
- }
- }
-}
-
-echo json_encode($obj);
+max_file_size = get_max_file_size();
+$obj->file_upload_max_size = file_upload_max_size();
+$obj->videoStorageLimitMinutes = $global['videoStorageLimitMinutes'];
+$obj->currentStorageUsage = getSecondsTotalVideosLength();
+$obj->webSiteLogo = $config->getLogo(true);
+$obj->webSiteTitle = $config->getWebSiteTitle();
+$obj->PHPSESSID = session_id();
+$obj->version = $config->getVersion();
+$obj->mobileSreamerVersion = MobileManager::getVersion();
+$obj->reportVideoPluginEnabled = AVideoPlugin::isEnabledByName("ReportVideo");
+$obj->oauthLogin = [];
+$obj->oauthLogin[] = ['type' => 'Facebook', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginFacebook'))];
+$obj->oauthLogin[] = ['type' => 'Google', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginGoogle'))];
+$obj->oauthLogin[] = ['type' => 'Twitter', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginTwitter'))];
+$obj->oauthLogin[] = ['type' => 'LinkedIn', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginLinkedin'))];
+$obj->oauthLogin[] = ['type' => 'Apple', 'status'=> !empty(AVideoPlugin::loadPluginIfEnabled('LoginApple'))];
+
+$obj->plugins = [];
+$plugins = Plugin::getAllEnabled();
+foreach ($plugins as $value) {
+ $p = AVideoPlugin::loadPlugin($value['dirName']);
+ if (is_object($p)) {
+ $info = $p->getMobileInfo();
+ if (!empty($info)) {
+ $obj->plugins[$value['dirName']] = $info;
+ }
+ }
+}
+
+echo json_encode($obj);
diff --git a/objects/subscribe.json.php b/objects/subscribe.json.php
index b1bc2a5604..a4e61c6b0e 100644
--- a/objects/subscribe.json.php
+++ b/objects/subscribe.json.php
@@ -1,44 +1,43 @@
-error = "";
-$obj->subscribe = "";
-
-// gettig the mobile submited value
-$inputJSON = url_get_contents('php://input');
-$input = _json_decode($inputJSON, TRUE); //convert JSON into array
-unset($_POST["redirectUri"]);
-if(!empty($input) && empty($_POST)){
- foreach ($input as $key => $value) {
- $_POST[$key]=$value;
- }
-}
-
-// gettig the mobile submited value
-if(empty($_POST) && !empty($_GET)){
- foreach ($_GET as $key => $value) {
- $_POST[$key]=$value;
- }
-}
-
-if(!empty($_POST['user']) && !empty($_POST['pass'])){
- $user = new User(0, $_POST['user'], $_POST['pass']);
- $user->login(false, true);
-}
-
-if (!User::isLogged()) {
- $obj->error = "Must be logged";
- die(json_encode($obj));
-}
-
-$_POST['email'] = User::getEmail_();
-if (empty($_POST['user_id'])) {
- $obj->error = __("User can not be blank");
- die(json_encode($obj));
-}
-$subscribe = new Subscribe(0, $_POST['email'], $_POST['user_id'], User::getId());
-$subscribe->toggle();
-$obj->subscribe = $subscribe->getStatus();
-die(json_encode($obj));
+error = '';
+$obj->subscribe = '';
+
+// gettig the mobile submited value
+$inputJSON = url_get_contents('php://input');
+$input = _json_decode($inputJSON, true); //convert JSON into array
+unset($_POST["redirectUri"]);
+if (!empty($input) && empty($_POST)) {
+ foreach ($input as $key => $value) {
+ $_POST[$key]=$value;
+ }
+}
+
+// gettig the mobile submited value
+if (empty($_POST) && !empty($_GET)) {
+ foreach ($_GET as $key => $value) {
+ $_POST[$key]=$value;
+ }
+}
+
+if (!empty($_POST['user']) && !empty($_POST['pass'])) {
+ $user = new User(0, $_POST['user'], $_POST['pass']);
+ $user->login(false, true);
+}
+
+if (!User::isLogged()) {
+ $obj->error = "Must be logged";
+ die(json_encode($obj));
+}
+
+$_POST['email'] = User::getEmail_();
+if (empty($_POST['user_id'])) {
+ $obj->error = __("User can not be blank");
+ die(json_encode($obj));
+}
+$subscribe = new Subscribe(0, $_POST['email'], $_POST['user_id'], User::getId());
+$subscribe->toggle();
+$obj->subscribe = $subscribe->getStatus();
+die(json_encode($obj));
diff --git a/objects/subscribe.php b/objects/subscribe.php
index c27965f55e..3b422cfdb9 100644
--- a/objects/subscribe.php
+++ b/objects/subscribe.php
@@ -1,404 +1,428 @@
-load($id);
- }
- if (!empty($subscriber_users_id)) {
- $this->email = $email;
- $this->users_id = $user_id;
- $this->subscriber_users_id = $subscriber_users_id;
- if (empty($this->id)) {
- $this->loadFromId($this->subscriber_users_id, $user_id, "");
- }
- }
- }
-
- private function load($id) {
- $obj = self::getSubscribe($id);
- if (empty($obj))
- return false;
- foreach ($obj as $key => $value) {
- $this->$key = $value;
- }
- return true;
- }
-
- private function loadFromEmail($email, $user_id, $status = "a") {
- $obj = self::getSubscribeFromEmail($email, $user_id, $status);
- if (empty($obj))
- return false;
- foreach ($obj as $key => $value) {
- $this->$key = $value;
- }
- return true;
- }
-
- private function loadFromId($subscriber_users_id, $user_id, $status = "a") {
- $obj = self::getSubscribeFromID($subscriber_users_id, $user_id, $status);
- if (empty($obj))
- return false;
- foreach ($obj as $key => $value) {
- $this->$key = $value;
- }
- return true;
- }
-
- function save() {
- global $global;
- if (!empty($this->id)) {
- $sql = "UPDATE subscribes SET status = '{$this->status}', notify = '{$this->notify}',ip = '" . getRealIpAddr() . "', modified = now() WHERE id = {$this->id}";
- } else {
- $sql = "INSERT INTO subscribes ( users_id, email,status,ip, created, modified, subscriber_users_id) VALUES ('{$this->users_id}','{$this->email}', 'a', '" . getRealIpAddr() . "',now(), now(), '$this->subscriber_users_id')";
- }
- return sqlDAL::writeSql($sql);
- }
-
- static function getSubscribe($id) {
- global $global;
- $id = intval($id);
- $sql = "SELECT * FROM subscribes WHERE id = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "i", array($id));
- $data = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- $subscribe = $data;
- } else {
- $subscribe = false;
- }
- return $subscribe;
- }
-
- static function getSubscribeFromEmail($email, $user_id, $status = "a") {
- global $global;
- $status = str_replace("'", "", $status);
- $sql = "SELECT * FROM subscribes WHERE email = '$email' AND users_id = {$user_id} ";
- if (!empty($status)) {
- $sql .= " AND status = '{$status}' ";
- }
- $sql .= " LIMIT 1";
- $res = sqlDAL::readSql($sql);
- $data = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- $subscribe = $data;
- } else {
- $subscribe = false;
- }
- return $subscribe;
- }
-
- static function getSubscribeFromID($subscriber_users_id, $user_id, $status = "a") {
- global $global;
- $status = str_replace("'", "", $status);
- $sql = "SELECT * FROM subscribes WHERE subscriber_users_id = '$subscriber_users_id' AND users_id = {$user_id} ";
- if (!empty($status)) {
- $sql .= " AND status = '{$status}' ";
- }
- $sql .= " LIMIT 1";
- $res = sqlDAL::readSql($sql, "", array(), true);
- $data = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- $subscribe = $data;
- } else {
- $subscribe = false;
- }
- return $subscribe;
- }
-
- static function isSubscribed($subscribed_to_user_id, $user_id = 0) {
- if (empty($user_id)) {
- if (User::isLogged()) {
- $user_id = User::getId();
- } else {
- return false;
- }
- }
- $s = self::getSubscribeFromID($subscribed_to_user_id, $user_id);
- return !empty($s['users_id']);
- }
-
- /**
- * return all subscribers that has subscribe to an user channel
- * @global type $global
- * @param type $user_id
- * @return boolean
- */
- static function getAllSubscribes($user_id = "", $status = "a", $verifiedOnly = false) {
- global $global;
- $cacheName = "getAllSubscribes_{$user_id}_{$status}_" . getCurrentPage() . "_" . getRowCount();
- $subscribe = ObjectYPT::getCache($cacheName, 300); // 5 minutes
- if (empty($subscribe)) {
- $status = str_replace("'", "", $status);
- $sql = "SELECT subscriber_users_id as subscriber_id, s.id, s.status, s.ip, s.users_id, s.notify, "
- . " s.subscriber_users_id , s.created , s.modified, suId.email as email, suId.emailVerified as emailVerified FROM subscribes as s "
- //. " LEFT JOIN users as su ON s.email = su.email "
- . " LEFT JOIN users as suId ON suId.id = s.subscriber_users_id "
- . " LEFT JOIN users as u ON users_id = u.id WHERE 1=1 AND subscriber_users_id > 0 ";
- if (!empty($user_id)) {
- $sql .= " AND users_id = {$user_id} ";
- }
- if (!empty($status)) {
- $sql .= " AND u.status = '{$status}' ";
- $sql .= " AND suId.status = '{$status}' ";
- //$sql .= " AND su.status = '{$status}' ";
- }
- if (!empty($verifiedOnly)) {
- $sql .= " AND suId.emailVerified = 1 ";
- }
-
- //$sql .= " GROUP BY subscriber_id ";
-
- $sql .= BootGrid::getSqlFromPost(array('email'));
-
-
- $res = sqlDAL::readSql($sql);
- $fullData = sqlDAL::fetchAllAssoc($res);
- sqlDAL::close($res);
- $subscribe = array();
- if ($res != false) {
- $emails = array();
- foreach ($fullData as $row) {
- $row = cleanUpRowFromDatabase($row);
- if (in_array($row['email'], $emails)) {
- //continue;
- }
- $emails[] = $row['email'];
- $row['identification'] = User::getNameIdentificationById($row['subscriber_id']);
- if ($row['identification'] === __("Unknown User")) {
- $row['identification'] = $row['email'];
- }
- $row['backgroundURL'] = User::getBackground($row['subscriber_id']);
- $row['photoURL'] = User::getPhoto($row['subscriber_id']);
-
- $subscribe[] = $row;
- }
- //$subscribe = $res->fetch_all(MYSQLI_ASSOC);
- } else {
- $subscribe = false;
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
- }
- ObjectYPT::setCache($cacheName, $subscribe);
- } else {
- $subscribe = object_to_array($subscribe);
- }
- return $subscribe;
- }
-
- /**
- * return all channels that a user has subscribed
- * @global type $global
- * @param type $user_id
- * @return boolean
- */
- static function getSubscribedChannels($user_id, $limit = 0, $page = 0) {
- global $global;
- $limit = intval($limit);
- $page = intval($page) - 1;
- if ($page < 0) {
- $page = 0;
- }
- $offset = $limit * $page;
- $sql = "SELECT s.*, (SELECT MAX(v.created) FROM videos v WHERE v.users_id = s.users_id) as newestvideo "
- . " FROM subscribes as s WHERE status = 'a' AND subscriber_users_id = ? "
- . " ORDER BY newestvideo DESC ";
-
- if (!empty($limit)) {
- $sql .= " LIMIT {$offset},{$limit} ";
- }
- //var_dump($sql, $user_id);exit;
- $res = sqlDAL::readSql($sql, "i", array($user_id));
- $fullData = sqlDAL::fetchAllAssoc($res);
- sqlDAL::close($res);
- $subscribe = array();
- if ($res != false) {
- foreach ($fullData as $row) {
- $row['identification'] = User::getNameIdentificationById($row['users_id']);
- if ($row['identification'] === __("Unknown User")) {
- $row['identification'] = $row['email'];
- }
- $row['channelName'] = User::_getChannelName($row['users_id']);
- $row['backgroundURL'] = User::getBackground($row['users_id']);
- $row['photoURL'] = User::getPhoto($row['users_id']);
-
- $current = getCurrentPage();
- $rowCount = getRowCount();
- $sort = @$_POST['sort'];
-
- $_POST['current'] = 1;
- $_REQUEST['rowCount'] = 6;
- $_POST['sort']['created'] = "DESC";
- $row['latestVideos'] = Video::getAllVideos("viewable", $row['users_id']);
- foreach ($row['latestVideos'] as $key => $video) {
- $images = Video::getImageFromFilename($video['filename'], $video['type']);
- $row['latestVideos'][$key]['Thumbnail'] = $images->thumbsJpg;
- $row['latestVideos'][$key]['createdHumanTiming'] = humanTiming(strtotime($video['created']));
- $row['latestVideos'][$key]['pageUrl'] = Video::getLink($video['id'], $video['clean_title'], false);
- $row['latestVideos'][$key]['embedUrl'] = Video::getLink($video['id'], $video['clean_title'], true);
- $row['latestVideos'][$key]['UserPhoto'] = User::getPhoto($video['users_id']);
- }
- $_POST['current'] = $current;
- $_REQUEST['rowCount'] = $rowCount;
- $_POST['sort'] = $sort;
-
- $row['totalViewsIn30Days'] = VideoStatistic::getChannelsTotalViews($row['users_id']);
-
- $subscribe[] = $row;
- }
- //$subscribe = $res->fetch_all(MYSQLI_ASSOC);
- } else {
- $subscribe = false;
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
- }
- return $subscribe;
- }
-
- static function getTotalSubscribes($user_id = 0) {
- global $global;
- $sql = "SELECT id FROM subscribes WHERE status = 'a' AND subscriber_users_id > 0 ";
- if (!empty($user_id)) {
- $sql .= " AND users_id = '{$user_id}' ";
- }
-
- $sql .= BootGrid::getSqlSearchFromPost(array('email'));
- $res = sqlDAL::readSql($sql);
- $numRows = sqlDAL::num_rows($res);
- sqlDAL::close($res);
-
- $extra = User::getExtraSubscribers($user_id);
- return $numRows+$extra;
- }
-
- static function getTotalSubscribedChannels($user_id = "") {
- global $global;
- $sql = "SELECT id FROM subscribes WHERE status = 'a' AND subscriber_users_id = ? ";
-
- //$sql .= BootGrid::getSqlSearchFromPost(array('email'));
- $res = sqlDAL::readSql($sql, "i", array($user_id));
- $numRows = sqlDAL::num_rows($res);
- sqlDAL::close($res);
-
-
- return $numRows;
- }
-
- function toggle() {
- if (empty($this->status) || $this->status == "i") {
- $this->status = 'a';
- } else {
- $this->status = 'i';
- }
- $this->save();
- }
-
- function notifyToggle() {
- if (empty($this->notify)) {
- $this->notify = 1;
- } else {
- $this->notify = 0;
- }
- $this->save();
- }
-
- function getStatus() {
- return $this->status;
- }
-
- function getNotify() {
- return $this->notify;
- }
-
- function setNotify($notify) {
- $this->notify = $notify;
- }
-
- static function getButton($user_id) {
- global $global, $advancedCustom;
-
- if (!empty($advancedCustom->removeSubscribeButton)) {
- return "";
- }
-
- $total = static::getTotalSubscribes($user_id);
- $btnFile = $global['systemRootPath'] . 'view/subscribeBtnOffline.html';
-
- $notify = '';
- $email = '';
- $subscribed = '';
- $subscribeText = __("Subscribe");
- $subscribedText = __("Subscribed");
- if (User::isLogged()) {
- $btnFile = $global['systemRootPath'] . 'view/subscribeBtn.html';
- $email = User::getMail();
- $subs = Subscribe::getSubscribeFromID(User::getId(), $user_id);
- if (!empty($subs['notify'])) {
- $notify = 'notify';
- }
-
- if (!empty($subs) && $subs['status'] === 'a') {
- $subscribed = 'subscribed';
- }
- }
- $content = local_get_contents($btnFile);
-
- $signInBTN = ("".__("Sign in to subscribe to this channel")."");
-
- $search = array(
- '_user_id_',
- '{notify}',
- '{tooltipStop}',
- '{tooltip}',
- '{titleOffline}',
- '{tooltipOffline}',
- '{email}', '{total}',
- '{subscribed}', '{subscribeText}', '{subscribedText}');
-
- $replace = array(
- $user_id,
- $notify,
- __("Stop getting notified for every new video"),
- __("Click to get notified for every new video"),
- __("Want to subscribe to this channel?"),
- $signInBTN,
- $email, $total,
- $subscribed, $subscribeText, $subscribedText);
-
- $btnHTML = str_replace($search, $replace, $content);
- return $btnHTML;
- }
-
- function getSubscriber_users_id() {
- return $this->subscriber_users_id;
- }
-
- function setSubscriber_users_id($subscriber_users_id) {
- $this->subscriber_users_id = $subscriber_users_id;
- }
-
- function getUsers_id() {
- return $this->users_id;
- }
-
- function setUsers_id($users_id) {
- $this->users_id = $users_id;
- }
-
-}
+load($id);
+ }
+ if (!empty($subscriber_users_id)) {
+ $this->email = $email;
+ $this->users_id = $user_id;
+ $this->subscriber_users_id = $subscriber_users_id;
+ if (empty($this->id)) {
+ $this->loadFromId($this->subscriber_users_id, $user_id, "");
+ }
+ }
+ }
+
+ private function load($id)
+ {
+ $obj = self::getSubscribe($id);
+ if (empty($obj)) {
+ return false;
+ }
+ foreach ($obj as $key => $value) {
+ $this->$key = $value;
+ }
+ return true;
+ }
+
+ private function loadFromEmail($email, $user_id, $status = "a")
+ {
+ $obj = self::getSubscribeFromEmail($email, $user_id, $status);
+ if (empty($obj)) {
+ return false;
+ }
+ foreach ($obj as $key => $value) {
+ $this->$key = $value;
+ }
+ return true;
+ }
+
+ private function loadFromId($subscriber_users_id, $user_id, $status = "a")
+ {
+ $obj = self::getSubscribeFromID($subscriber_users_id, $user_id, $status);
+ if (empty($obj)) {
+ return false;
+ }
+ foreach ($obj as $key => $value) {
+ $this->$key = $value;
+ }
+ return true;
+ }
+
+ public function save()
+ {
+ global $global;
+ if (!empty($this->id)) {
+ $sql = "UPDATE subscribes SET status = '{$this->status}', notify = '{$this->notify}',ip = '" . getRealIpAddr() . "', modified = now() WHERE id = {$this->id}";
+ } else {
+ $sql = "INSERT INTO subscribes ( users_id, email,status,ip, created, modified, subscriber_users_id) VALUES ('{$this->users_id}','{$this->email}', 'a', '" . getRealIpAddr() . "',now(), now(), '$this->subscriber_users_id')";
+ }
+ return sqlDAL::writeSql($sql);
+ }
+
+ public static function getSubscribe($id)
+ {
+ global $global;
+ $id = intval($id);
+ $sql = "SELECT * FROM subscribes WHERE id = ? LIMIT 1";
+ $res = sqlDAL::readSql($sql, "i", [$id]);
+ $data = sqlDAL::fetchAssoc($res);
+ sqlDAL::close($res);
+ if ($res != false) {
+ $subscribe = $data;
+ } else {
+ $subscribe = false;
+ }
+ return $subscribe;
+ }
+
+ public static function getSubscribeFromEmail($email, $user_id, $status = "a")
+ {
+ global $global;
+ $status = str_replace("'", "", $status);
+ $sql = "SELECT * FROM subscribes WHERE email = '$email' AND users_id = {$user_id} ";
+ if (!empty($status)) {
+ $sql .= " AND status = '{$status}' ";
+ }
+ $sql .= " LIMIT 1";
+ $res = sqlDAL::readSql($sql);
+ $data = sqlDAL::fetchAssoc($res);
+ sqlDAL::close($res);
+ if ($res != false) {
+ $subscribe = $data;
+ } else {
+ $subscribe = false;
+ }
+ return $subscribe;
+ }
+
+ public static function getSubscribeFromID($subscriber_users_id, $user_id, $status = "a")
+ {
+ global $global;
+ $status = str_replace("'", "", $status);
+ $sql = "SELECT * FROM subscribes WHERE subscriber_users_id = '$subscriber_users_id' AND users_id = {$user_id} ";
+ if (!empty($status)) {
+ $sql .= " AND status = '{$status}' ";
+ }
+ $sql .= " LIMIT 1";
+ $res = sqlDAL::readSql($sql, "", [], true);
+ $data = sqlDAL::fetchAssoc($res);
+ sqlDAL::close($res);
+ if ($res != false) {
+ $subscribe = $data;
+ } else {
+ $subscribe = false;
+ }
+ return $subscribe;
+ }
+
+ public static function isSubscribed($subscribed_to_user_id, $user_id = 0)
+ {
+ if (empty($user_id)) {
+ if (User::isLogged()) {
+ $user_id = User::getId();
+ } else {
+ return false;
+ }
+ }
+ $s = self::getSubscribeFromID($subscribed_to_user_id, $user_id);
+ return !empty($s['users_id']);
+ }
+
+ /**
+ * return all subscribers that has subscribe to an user channel
+ * @global type $global
+ * @param type $user_id
+ * @return boolean
+ */
+ public static function getAllSubscribes($user_id = "", $status = "a", $verifiedOnly = false)
+ {
+ global $global;
+ $cacheName = "getAllSubscribes_{$user_id}_{$status}_" . getCurrentPage() . "_" . getRowCount();
+ $subscribe = ObjectYPT::getCache($cacheName, 300); // 5 minutes
+ if (empty($subscribe)) {
+ $status = str_replace("'", "", $status);
+ $sql = "SELECT subscriber_users_id as subscriber_id, s.id, s.status, s.ip, s.users_id, s.notify, "
+ . " s.subscriber_users_id , s.created , s.modified, suId.email as email, suId.emailVerified as emailVerified FROM subscribes as s "
+ //. " LEFT JOIN users as su ON s.email = su.email "
+ . " LEFT JOIN users as suId ON suId.id = s.subscriber_users_id "
+ . " LEFT JOIN users as u ON users_id = u.id WHERE 1=1 AND subscriber_users_id > 0 ";
+ if (!empty($user_id)) {
+ $sql .= " AND users_id = {$user_id} ";
+ }
+ if (!empty($status)) {
+ $sql .= " AND u.status = '{$status}' ";
+ $sql .= " AND suId.status = '{$status}' ";
+ //$sql .= " AND su.status = '{$status}' ";
+ }
+ if (!empty($verifiedOnly)) {
+ $sql .= " AND suId.emailVerified = 1 ";
+ }
+
+ //$sql .= " GROUP BY subscriber_id ";
+
+ $sql .= BootGrid::getSqlFromPost(['email']);
+
+
+ $res = sqlDAL::readSql($sql);
+ $fullData = sqlDAL::fetchAllAssoc($res);
+ sqlDAL::close($res);
+ $subscribe = [];
+ if ($res != false) {
+ $emails = [];
+ foreach ($fullData as $row) {
+ $row = cleanUpRowFromDatabase($row);
+ if (in_array($row['email'], $emails)) {
+ //continue;
+ }
+ $emails[] = $row['email'];
+ $row['identification'] = User::getNameIdentificationById($row['subscriber_id']);
+ if ($row['identification'] === __("Unknown User")) {
+ $row['identification'] = $row['email'];
+ }
+ $row['backgroundURL'] = User::getBackground($row['subscriber_id']);
+ $row['photoURL'] = User::getPhoto($row['subscriber_id']);
+
+ $subscribe[] = $row;
+ }
+ //$subscribe = $res->fetch_all(MYSQLI_ASSOC);
+ } else {
+ $subscribe = false;
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ }
+ ObjectYPT::setCache($cacheName, $subscribe);
+ } else {
+ $subscribe = object_to_array($subscribe);
+ }
+ return $subscribe;
+ }
+
+ /**
+ * return all channels that a user has subscribed
+ * @global type $global
+ * @param type $user_id
+ * @return boolean
+ */
+ public static function getSubscribedChannels($user_id, $limit = 0, $page = 0)
+ {
+ global $global;
+ $limit = intval($limit);
+ $page = intval($page) - 1;
+ if ($page < 0) {
+ $page = 0;
+ }
+ $offset = $limit * $page;
+ $sql = "SELECT s.*, (SELECT MAX(v.created) FROM videos v WHERE v.users_id = s.users_id) as newestvideo "
+ . " FROM subscribes as s WHERE status = 'a' AND subscriber_users_id = ? "
+ . " ORDER BY newestvideo DESC ";
+
+ if (!empty($limit)) {
+ $sql .= " LIMIT {$offset},{$limit} ";
+ }
+ //var_dump($sql, $user_id);exit;
+ $res = sqlDAL::readSql($sql, "i", [$user_id]);
+ $fullData = sqlDAL::fetchAllAssoc($res);
+ sqlDAL::close($res);
+ $subscribe = [];
+ if ($res != false) {
+ foreach ($fullData as $row) {
+ $row['identification'] = User::getNameIdentificationById($row['users_id']);
+ if ($row['identification'] === __("Unknown User")) {
+ $row['identification'] = $row['email'];
+ }
+ $row['channelName'] = User::_getChannelName($row['users_id']);
+ $row['backgroundURL'] = User::getBackground($row['users_id']);
+ $row['photoURL'] = User::getPhoto($row['users_id']);
+
+ $current = getCurrentPage();
+ $rowCount = getRowCount();
+ $sort = @$_POST['sort'];
+
+ $_POST['current'] = 1;
+ $_REQUEST['rowCount'] = 6;
+ $_POST['sort']['created'] = "DESC";
+ $row['latestVideos'] = Video::getAllVideos("viewable", $row['users_id']);
+ foreach ($row['latestVideos'] as $key => $video) {
+ $images = Video::getImageFromFilename($video['filename'], $video['type']);
+ $row['latestVideos'][$key]['Thumbnail'] = $images->thumbsJpg;
+ $row['latestVideos'][$key]['createdHumanTiming'] = humanTiming(strtotime($video['created']));
+ $row['latestVideos'][$key]['pageUrl'] = Video::getLink($video['id'], $video['clean_title'], false);
+ $row['latestVideos'][$key]['embedUrl'] = Video::getLink($video['id'], $video['clean_title'], true);
+ $row['latestVideos'][$key]['UserPhoto'] = User::getPhoto($video['users_id']);
+ }
+ $_POST['current'] = $current;
+ $_REQUEST['rowCount'] = $rowCount;
+ $_POST['sort'] = $sort;
+
+ $row['totalViewsIn30Days'] = VideoStatistic::getChannelsTotalViews($row['users_id']);
+
+ $subscribe[] = $row;
+ }
+ //$subscribe = $res->fetch_all(MYSQLI_ASSOC);
+ } else {
+ $subscribe = false;
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ }
+ return $subscribe;
+ }
+
+ public static function getTotalSubscribes($user_id = 0)
+ {
+ global $global;
+ $sql = "SELECT id FROM subscribes WHERE status = 'a' AND subscriber_users_id > 0 ";
+ if (!empty($user_id)) {
+ $sql .= " AND users_id = '{$user_id}' ";
+ }
+
+ $sql .= BootGrid::getSqlSearchFromPost(['email']);
+ $res = sqlDAL::readSql($sql);
+ $numRows = sqlDAL::num_rows($res);
+ sqlDAL::close($res);
+
+ $extra = User::getExtraSubscribers($user_id);
+ return $numRows+$extra;
+ }
+
+ public static function getTotalSubscribedChannels($user_id = "")
+ {
+ global $global;
+ $sql = "SELECT id FROM subscribes WHERE status = 'a' AND subscriber_users_id = ? ";
+
+ //$sql .= BootGrid::getSqlSearchFromPost(array('email'));
+ $res = sqlDAL::readSql($sql, "i", [$user_id]);
+ $numRows = sqlDAL::num_rows($res);
+ sqlDAL::close($res);
+
+
+ return $numRows;
+ }
+
+ public function toggle()
+ {
+ if (empty($this->status) || $this->status == "i") {
+ $this->status = 'a';
+ } else {
+ $this->status = 'i';
+ }
+ $this->save();
+ }
+
+ public function notifyToggle()
+ {
+ if (empty($this->notify)) {
+ $this->notify = 1;
+ } else {
+ $this->notify = 0;
+ }
+ $this->save();
+ }
+
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ public function getNotify()
+ {
+ return $this->notify;
+ }
+
+ public function setNotify($notify)
+ {
+ $this->notify = $notify;
+ }
+
+ public static function getButton($user_id)
+ {
+ global $global, $advancedCustom;
+
+ if (!empty($advancedCustom->removeSubscribeButton)) {
+ return "";
+ }
+
+ $total = static::getTotalSubscribes($user_id);
+ $btnFile = $global['systemRootPath'] . 'view/subscribeBtnOffline.html';
+
+ $notify = '';
+ $email = '';
+ $subscribed = '';
+ $subscribeText = __("Subscribe");
+ $subscribedText = __("Subscribed");
+ if (User::isLogged()) {
+ $btnFile = $global['systemRootPath'] . 'view/subscribeBtn.html';
+ $email = User::getMail();
+ $subs = Subscribe::getSubscribeFromID(User::getId(), $user_id);
+ if (!empty($subs['notify'])) {
+ $notify = 'notify';
+ }
+
+ if (!empty($subs) && $subs['status'] === 'a') {
+ $subscribed = 'subscribed';
+ }
+ }
+ $content = local_get_contents($btnFile);
+
+ $signInBTN = ("".__("Sign in to subscribe to this channel")."");
+
+ $search = [
+ '_user_id_',
+ '{notify}',
+ '{tooltipStop}',
+ '{tooltip}',
+ '{titleOffline}',
+ '{tooltipOffline}',
+ '{email}', '{total}',
+ '{subscribed}', '{subscribeText}', '{subscribedText}', ];
+
+ $replace = [
+ $user_id,
+ $notify,
+ __("Stop getting notified for every new video"),
+ __("Click to get notified for every new video"),
+ __("Want to subscribe to this channel?"),
+ $signInBTN,
+ $email, $total,
+ $subscribed, $subscribeText, $subscribedText, ];
+
+ $btnHTML = str_replace($search, $replace, $content);
+ return $btnHTML;
+ }
+
+ public function getSubscriber_users_id()
+ {
+ return $this->subscriber_users_id;
+ }
+
+ public function setSubscriber_users_id($subscriber_users_id)
+ {
+ $this->subscriber_users_id = $subscriber_users_id;
+ }
+
+ public function getUsers_id()
+ {
+ return $this->users_id;
+ }
+
+ public function setUsers_id($users_id)
+ {
+ $this->users_id = $users_id;
+ }
+}
diff --git a/objects/subscribeNotify.json.php b/objects/subscribeNotify.json.php
index 68263903c8..ea8fa67af9 100644
--- a/objects/subscribeNotify.json.php
+++ b/objects/subscribeNotify.json.php
@@ -1,26 +1,26 @@
- $value) {
- $_POST[$key]=$value;
- }
-}
-require_once 'subscribe.php';
-header('Content-Type: application/json');
-$obj = new stdClass();
-$obj->error = "";
-$obj->subscribe = "";
-if (!User::isLogged()) {
- $obj->error = "Must be logged";
- die(json_encode($obj));
-}
-
-$_POST['email'] = User::getEmail_();
-if (empty($_POST['user_id'])) {
- $obj->error = __("User can not be blank");
- die(json_encode($obj));
-}
-$subscribe = new Subscribe(0, $_POST['email'], $_POST['user_id'], User::getId());
-$subscribe->notifyToggle();
-$obj->notify = $subscribe->getNotify();
-die(json_encode($obj));
+ $value) {
+ $_POST[$key]=$value;
+ }
+}
+require_once 'subscribe.php';
+header('Content-Type: application/json');
+$obj = new stdClass();
+$obj->error = '';
+$obj->subscribe = '';
+if (!User::isLogged()) {
+ $obj->error = "Must be logged";
+ die(json_encode($obj));
+}
+
+$_POST['email'] = User::getEmail_();
+if (empty($_POST['user_id'])) {
+ $obj->error = __("User can not be blank");
+ die(json_encode($obj));
+}
+$subscribe = new Subscribe(0, $_POST['email'], $_POST['user_id'], User::getId());
+$subscribe->notifyToggle();
+$obj->notify = $subscribe->getNotify();
+die(json_encode($obj));
diff --git a/objects/subscribed.json.php b/objects/subscribed.json.php
index 8b5adda245..7aec14f670 100644
--- a/objects/subscribed.json.php
+++ b/objects/subscribed.json.php
@@ -1,20 +1,20 @@
-login(false, true);
-}
-if (!User::isLogged()) {
- return false;
-}
-header('Content-Type: application/json');
-
-$user_id = User::getId();
-
-$Subscribes = Subscribe::getSubscribedChannels($user_id);
-$total = Subscribe::getTotalSubscribedChannels($user_id);
-echo '{ "current": '. getCurrentPage().',"rowCount": '.getRowCount().', "total": '.$total.', "rows":'. json_encode($Subscribes).'}';
+login(false, true);
+}
+if (!User::isLogged()) {
+ return false;
+}
+header('Content-Type: application/json');
+
+$user_id = User::getId();
+
+$Subscribes = Subscribe::getSubscribedChannels($user_id);
+$total = Subscribe::getTotalSubscribedChannels($user_id);
+echo '{ "current": '. getCurrentPage().',"rowCount": '.getRowCount().', "total": '.$total.', "rows":'. json_encode($Subscribes).'}';
diff --git a/objects/subscribes.json.php b/objects/subscribes.json.php
index 0c658393df..96f2593b26 100644
--- a/objects/subscribes.json.php
+++ b/objects/subscribes.json.php
@@ -1,23 +1,23 @@
-login(false, true);
-}
-if (!User::isLogged()) {
- return false;
-}
-header('Content-Type: application/json');
-
-$user_id = User::getId();
-// if admin bring all subscribers
-if (User::isAdmin()) {
- $user_id = "";
-}
-$Subscribes = Subscribe::getAllSubscribes($user_id);
-$total = Subscribe::getTotalSubscribes($user_id);
-echo '{ "current": '. getCurrentPage().',"rowCount": '.getRowCount().', "total": '.$total.', "rows":'. json_encode($Subscribes).'}';
+login(false, true);
+}
+if (!User::isLogged()) {
+ return false;
+}
+header('Content-Type: application/json');
+
+$user_id = User::getId();
+// if admin bring all subscribers
+if (User::isAdmin()) {
+ $user_id = '';
+}
+$Subscribes = Subscribe::getAllSubscribes($user_id);
+$total = Subscribe::getTotalSubscribes($user_id);
+echo '{ "current": '. getCurrentPage().',"rowCount": '.getRowCount().', "total": '.$total.', "rows":'. json_encode($Subscribes).'}';
diff --git a/objects/uploadArticleImage.php b/objects/uploadArticleImage.php
index 72053486a6..42f1a6bc70 100644
--- a/objects/uploadArticleImage.php
+++ b/objects/uploadArticleImage.php
@@ -1,51 +1,50 @@
-error = true;
-if (!Video::canEdit($_GET['video_id'])) {
- $obj->msg = 'You can\'t edit this file';
- die(json_encode($obj));
-}
-header('Content-Type: application/json');
-// A list of permitted file extensions
-$allowed = array('jpg', 'gif', 'png');
-if (isset($_FILES['file_data']) && $_FILES['file_data']['error'] == 0) {
- $extension = pathinfo($_FILES['file_data']['name'], PATHINFO_EXTENSION);
- if (!in_array(strtolower($extension), $allowed)) {
- $obj->msg = "File extension error [{$_FILES['file_data']['name']}], we allow only (" . implode(",", $allowed) . ")";
- die(json_encode($obj));
- }
- //var_dump($extension, $type);exit;
- $video = new Video("", "", $_GET['video_id']);
- if (!empty($video)) {
- $dir = Video::getStoragePath()."articleImages/" . $video->getFilename()."/";
- $name = uniqid();
- if(!is_dir($dir)){
- mkdir($dir, 0777, true);
- }
- $destination = $dir . $name.".".strtolower($extension);
- _error_log("Try to move " . $destination . " \n " . print_r($video, true));
- if (!move_uploaded_file($_FILES['file_data']['tmp_name'], $destination)) {
- $obj->msg = "Error on move_file_uploaded_file(" . $_FILES['file_data']['tmp_name'] . ", " . $destination;
- die(json_encode($obj));
- }
- $obj->url = "{$global['webSiteRootURL']}videos/articleImages/" . $video->getFilename()."/{$name}.".strtolower($extension);
- $obj->error = false;
- } else {
- $obj->msg = "Video Not found";
- die(json_encode($obj));
- }
-}
-$obj->msg = "\$_FILES Error";
-$obj->FILES = $_FILES;
-die(json_encode($obj));
+error = true;
+if (!Video::canEdit($_GET['video_id'])) {
+ $obj->msg = 'You can\'t edit this file';
+ die(json_encode($obj));
+}
+header('Content-Type: application/json');
+// A list of permitted file extensions
+$allowed = ['jpg', 'gif', 'png'];
+if (isset($_FILES['file_data']) && $_FILES['file_data']['error'] == 0) {
+ $extension = pathinfo($_FILES['file_data']['name'], PATHINFO_EXTENSION);
+ if (!in_array(strtolower($extension), $allowed)) {
+ $obj->msg = "File extension error [{$_FILES['file_data']['name']}], we allow only (" . implode(",", $allowed) . ")";
+ die(json_encode($obj));
+ }
+ //var_dump($extension, $type);exit;
+ $video = new Video("", "", $_GET['video_id']);
+ if (!empty($video)) {
+ $dir = Video::getStoragePath()."articleImages/" . $video->getFilename()."/";
+ $name = uniqid();
+ if (!is_dir($dir)) {
+ mkdir($dir, 0777, true);
+ }
+ $destination = $dir . $name.".".strtolower($extension);
+ _error_log("Try to move " . $destination . " \n " . print_r($video, true));
+ if (!move_uploaded_file($_FILES['file_data']['tmp_name'], $destination)) {
+ $obj->msg = "Error on move_file_uploaded_file(" . $_FILES['file_data']['tmp_name'] . ", " . $destination;
+ die(json_encode($obj));
+ }
+ $obj->url = "{$global['webSiteRootURL']}videos/articleImages/" . $video->getFilename()."/{$name}.".strtolower($extension);
+ $obj->error = false;
+ } else {
+ $obj->msg = "Video Not found";
+ die(json_encode($obj));
+ }
+}
+$obj->msg = "\$_FILES Error";
+$obj->FILES = $_FILES;
+die(json_encode($obj));
diff --git a/objects/uploadChannelArt.php b/objects/uploadChannelArt.php
index 7310084afa..f666570c98 100644
--- a/objects/uploadChannelArt.php
+++ b/objects/uploadChannelArt.php
@@ -1,48 +1,47 @@
-error = true;
-if (!User::isLogged()) {
- $obj->msg = 'You can\'t edit this file';
- die(json_encode($obj));
-}
-header('Content-Type: application/json');
-// A list of permitted file extensions
-$allowed = array('jpg', 'jpeg', 'gif', 'png');
-if (isset($_FILES['file_data']) && $_FILES['file_data']['error'] == 0) {
- $extension = pathinfo($_FILES['file_data']['name'], PATHINFO_EXTENSION);
- if (!in_array(strtolower($extension), $allowed)) {
- $obj->msg = "File extension error [{$_FILES['file_data']['name']}], we allow only (" . implode(",", $allowed) . ")";
- die(json_encode($obj));
- }
-
- $tmpDestination = Video::getStoragePath()."userPhoto/tmp_background".User::getId().".". $extension;
- $obj->file = "videos/userPhoto/background".User::getId().".jpg";
- $oldfile = Video::getStoragePath()."userPhoto/background".User::getId().".png";
-
- if (!move_uploaded_file($_FILES['file_data']['tmp_name'], $tmpDestination)) {
- $obj->msg = "Error on move_file_uploaded_file(" . $_FILES['file_data']['tmp_name'] . ", " . Video::getStoragePath()."" . $filename . $ext;
- die(json_encode($obj));
- }
- convertImage($tmpDestination, $global['systemRootPath'].$obj->file, 70);
- unlink($tmpDestination);
- if(file_exists($oldfile)){
- unlink($oldfile);
- }
-
- echo "{}";
- exit;
-}
-$obj->msg = "\$_FILES Error";
-$obj->FILES = $_FILES;
-die(json_encode($obj));
+error = true;
+if (!User::isLogged()) {
+ $obj->msg = 'You can\'t edit this file';
+ die(json_encode($obj));
+}
+header('Content-Type: application/json');
+// A list of permitted file extensions
+$allowed = ['jpg', 'jpeg', 'gif', 'png'];
+if (isset($_FILES['file_data']) && $_FILES['file_data']['error'] == 0) {
+ $extension = pathinfo($_FILES['file_data']['name'], PATHINFO_EXTENSION);
+ if (!in_array(strtolower($extension), $allowed)) {
+ $obj->msg = "File extension error [{$_FILES['file_data']['name']}], we allow only (" . implode(",", $allowed) . ")";
+ die(json_encode($obj));
+ }
+
+ $tmpDestination = Video::getStoragePath()."userPhoto/tmp_background".User::getId().".". $extension;
+ $obj->file = "videos/userPhoto/background".User::getId().".jpg";
+ $oldfile = Video::getStoragePath()."userPhoto/background".User::getId().".png";
+
+ if (!move_uploaded_file($_FILES['file_data']['tmp_name'], $tmpDestination)) {
+ $obj->msg = "Error on move_file_uploaded_file(" . $_FILES['file_data']['tmp_name'] . ", " . Video::getStoragePath()."" . $filename . $ext;
+ die(json_encode($obj));
+ }
+ convertImage($tmpDestination, $global['systemRootPath'].$obj->file, 70);
+ unlink($tmpDestination);
+ if (file_exists($oldfile)) {
+ unlink($oldfile);
+ }
+
+ echo "{}";
+ exit;
+}
+$obj->msg = "\$_FILES Error";
+$obj->FILES = $_FILES;
+die(json_encode($obj));
diff --git a/objects/uploadPoster.php b/objects/uploadPoster.php
index 7e3e372513..3cb58371bd 100644
--- a/objects/uploadPoster.php
+++ b/objects/uploadPoster.php
@@ -1,93 +1,92 @@
-error = true;
-if (!Video::canEdit($_GET['video_id'])) {
- $obj->msg = 'You can\'t edit this file';
- die(json_encode($obj));
-}
-$obj->videos_id = intval($_GET['video_id']);
-
-header('Content-Type: application/json');
-// A list of permitted file extensions
-$allowed = array('jpg', 'jpeg', 'gif', 'pjpg', 'pgif', 'webp', 'png', 'bmp');
-if (!in_array(strtolower($_GET['type']), $allowed)) {
- $obj->msg = "UploadPoster FIle extension not allowed";
- _error_log($obj->msg );
- die(json_encode($obj));
-}
-if (isset($_FILES['file_data']) && $_FILES['file_data']['error'] == 0) {
- $extension = pathinfo($_FILES['file_data']['name'], PATHINFO_EXTENSION);
- if (!in_array(strtolower($extension), $allowed)) {
- $obj->msg = "File extension error [{$_FILES['file_data']['name']}], we allow only (" . implode(",", $allowed) . ")";
- die(json_encode($obj));
- }
- //var_dump($extension, $type);exit;
- $video = new Video("", "", $_GET['video_id']);
- if (!empty($video)) {
- $ext = ".jpg";
- switch ($_GET['type']) {
- case "jpg":
- case "jpeg":
- $ext = ".jpg";
- if($extension == 'png' || $extension == 'bmp'){
- $ext = "_convertToJPG.{$extension}";
- }
- break;
- case "pjpg":
- $ext = "_portrait.jpg";
- if($extension == 'png' || $extension == 'bmp'){
- $ext = "_portrait_convertToJPG.{$extension}";
- }
- break;
- case "gif":
- $ext = ".gif";
- break;
- case "webp":
- $ext = ".webp";
- break;
- case "pgif":
- $ext = "_portrait.gif";
- break;
- }
- /**
- * This is when is using in a non file_dataoaded movie
- */
- $paths = Video::getPaths($video->getFilename());
- $destination = $paths['path'] . $video->getFilename() . $ext;
- _error_log("Try to move " . $destination . " \n " . print_r($video, true));
- if (!move_uploaded_file($_FILES['file_data']['tmp_name'], $destination)) {
- $obj->msg = "Error on move_file_uploaded_file(" . $_FILES['file_data']['tmp_name'] . ", " . $destination;
- die(json_encode($obj));
- } else {
- if(preg_match('/_convertToJPG/', $ext)){
- $new_destination = str_replace('_convertToJPG.'.$extension, '.jpg', $destination);
- if(convertImage($destination, $new_destination, 100)){
- unlink($destination);
- }
- }
- // delete thumbs from poster
- Video::deleteThumbs($video->getFilename());
- }
- $obj->clearFirstPageCache = clearFirstPageCache();
- $obj->error = false;
- echo "{}";
- exit;
- } else {
- $obj->msg = "Video Not found";
- die(json_encode($obj));
- }
-}
-$obj->msg = "\$_FILES Error";
-$obj->FILES = $_FILES;
-die(json_encode($obj));
+error = true;
+if (!Video::canEdit($_GET['video_id'])) {
+ $obj->msg = 'You can\'t edit this file';
+ die(json_encode($obj));
+}
+$obj->videos_id = intval($_GET['video_id']);
+
+header('Content-Type: application/json');
+// A list of permitted file extensions
+$allowed = ['jpg', 'jpeg', 'gif', 'pjpg', 'pgif', 'webp', 'png', 'bmp'];
+if (!in_array(strtolower($_GET['type']), $allowed)) {
+ $obj->msg = "UploadPoster FIle extension not allowed";
+ _error_log($obj->msg);
+ die(json_encode($obj));
+}
+if (isset($_FILES['file_data']) && $_FILES['file_data']['error'] == 0) {
+ $extension = pathinfo($_FILES['file_data']['name'], PATHINFO_EXTENSION);
+ if (!in_array(strtolower($extension), $allowed)) {
+ $obj->msg = "File extension error [{$_FILES['file_data']['name']}], we allow only (" . implode(",", $allowed) . ")";
+ die(json_encode($obj));
+ }
+ //var_dump($extension, $type);exit;
+ $video = new Video("", "", $_GET['video_id']);
+ if (!empty($video)) {
+ $ext = ".jpg";
+ switch ($_GET['type']) {
+ case "jpg":
+ case "jpeg":
+ $ext = ".jpg";
+ if ($extension == 'png' || $extension == 'bmp') {
+ $ext = "_convertToJPG.{$extension}";
+ }
+ break;
+ case "pjpg":
+ $ext = "_portrait.jpg";
+ if ($extension == 'png' || $extension == 'bmp') {
+ $ext = "_portrait_convertToJPG.{$extension}";
+ }
+ break;
+ case "gif":
+ $ext = ".gif";
+ break;
+ case "webp":
+ $ext = ".webp";
+ break;
+ case "pgif":
+ $ext = "_portrait.gif";
+ break;
+ }
+ /**
+ * This is when is using in a non file_dataoaded movie
+ */
+ $paths = Video::getPaths($video->getFilename());
+ $destination = $paths['path'] . $video->getFilename() . $ext;
+ _error_log("Try to move " . $destination . " \n " . print_r($video, true));
+ if (!move_uploaded_file($_FILES['file_data']['tmp_name'], $destination)) {
+ $obj->msg = "Error on move_file_uploaded_file(" . $_FILES['file_data']['tmp_name'] . ", " . $destination;
+ die(json_encode($obj));
+ } else {
+ if (preg_match('/_convertToJPG/', $ext)) {
+ $new_destination = str_replace('_convertToJPG.'.$extension, '.jpg', $destination);
+ if (convertImage($destination, $new_destination, 100)) {
+ unlink($destination);
+ }
+ }
+ // delete thumbs from poster
+ Video::deleteThumbs($video->getFilename());
+ }
+ $obj->clearFirstPageCache = clearFirstPageCache();
+ $obj->error = false;
+ echo "{}";
+ exit;
+ } else {
+ $obj->msg = "Video Not found";
+ die(json_encode($obj));
+ }
+}
+$obj->msg = "\$_FILES Error";
+$obj->FILES = $_FILES;
+die(json_encode($obj));
diff --git a/objects/user.php b/objects/user.php
index 67a94d0173..abb32967d8 100644
--- a/objects/user.php
+++ b/objects/user.php
@@ -1,2550 +1,2714 @@
-user = $user;
- if ($password !== false) {
- $this->password = $password;
- } else {
- $this->loadFromUser($user);
- }
- } else {
- // get data from id
- $this->load($id);
- }
- }
-
- public function getEmail() {
- return $this->email;
- }
-
- public function getUser() {
- return $this->user;
- }
-
- public function getAbout() {
- return str_replace(array('\\\\\\\n'), array("\n"), $this->about);
- }
-
- public function setAbout($about) {
- $this->about = strip_specific_tags(xss_esc($about));
- }
-
- public function getPassword() {
- return $this->password;
- }
-
- public function getCanStream() {
- return $this->canStream;
- }
-
- public function setCanStream($canStream) {
- $this->canStream = (empty($canStream) || strtolower($canStream) === 'false') ? 0 : 1;
- }
-
- public function getCanViewChart() {
- return $this->canViewChart;
- }
-
- public function setCanViewChart($canViewChart) {
- $this->canViewChart = (empty($canViewChart) || strtolower($canViewChart) === 'false') ? 0 : 1;
- }
-
- public function getCanCreateMeet() {
- return $this->canCreateMeet;
- }
-
- public function setCanCreateMeet($canCreateMeet) {
- $this->canCreateMeet = (empty($canCreateMeet) || strtolower($canCreateMeet) === 'false') ? 0 : 1;
- ;
- }
-
- public function getCanUpload() {
- return $this->canUpload;
- }
-
- public function setCanUpload($canUpload) {
- $this->canUpload = (empty($canUpload) || strtolower($canUpload) === 'false') ? 0 : 1;
- }
-
- public function getAnalyticsCode() {
- return $this->analyticsCode;
- }
-
- public function setAnalyticsCode($analyticsCode) {
- preg_match("/(ua-\d{4,9}-\d{1,4})/i", $analyticsCode, $matches);
- if (!empty($matches[1])) {
- $this->analyticsCode = $matches[1];
- } else {
- $this->analyticsCode = "";
- }
- }
-
- public function getAnalytics() {
- $id = $this->getId();
- $aCode = $this->getAnalyticsCode();
- if (!empty($id) && !empty($aCode)) {
- $code = "
-
-
-";
- } else {
- $code = "";
- }
- return $code;
- }
-
- public function addExternalOptions($id, $value) {
- $eo = unserialize(base64_decode($this->externalOptions));
- if (!is_array($eo)) {
- $eo = array();
- }
- $eo[$id] = $value;
- $this->setExternalOptions($eo);
- return $this->save();
- }
-
- public function removeExternalOptions($id) {
- $eo = unserialize(base64_decode($this->externalOptions));
- unset($eo[$id]);
- $this->setExternalOptions($eo);
- return $this->save();
- }
-
- public function setExternalOptions($options) {
- //we convert it to base64 to sanitize the input since we do not validate input from externalOptions
- $this->externalOptions = base64_encode(serialize($options));
- //var_dump($this->externalOptions, $options);
- }
-
- public function getExternalOption($id) {
- $eo = unserialize(base64_decode($this->externalOptions));
- if (empty($eo[$id])) {
- return null;
- }
- return $eo[$id];
- }
-
- private function load($id) {
- $id = intval($id);
- if (empty($id)) {
- return false;
- }
- $user = self::getUserDb($id);
- if (empty($user)) {
- return false;
- }
- foreach ($user as $key => $value) {
- $this->$key = $value;
- }
- return true;
- }
-
- private function loadFromUser($user) {
- $userLoaded = self::getUserDbFromUser($user);
- if (empty($userLoaded)) {
- return false;
- }
- //_error_log("User::loadFromUser($user) ");
- //_error_log("User::loadFromUser json " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
- foreach ($userLoaded as $key => $value) {
- $this->$key = $value;
- }
- return true;
- }
-
- public function loadSelfUser() {
- $this->load($this->getId());
- }
-
- public static function getId() {
- if (self::isLogged()) {
- return $_SESSION['user']['id'];
- } else {
- return false;
- }
- }
-
- public static function getEmail_() {
- if (self::isLogged()) {
- return $_SESSION['user']['email'];
- } else {
- return false;
- }
- }
-
- public function getBdId() {
- return $this->id;
- }
-
- public static function updateSessionInfo() {
- if (self::isLogged()) {
- $user = self::getUserDb($_SESSION['user']['id']);
- $_SESSION['user'] = $user;
- }
- }
-
- public static function getName() {
- if (self::isLogged()) {
- return $_SESSION['user']['name'];
- } else {
- return false;
- }
- }
-
- public static function getUserName() {
- if (self::isLogged()) {
- return $_SESSION['user']['user'];
- } else {
- return false;
- }
- }
-
- public static function getUserChannelName() {
- if (self::isLogged()) {
- if (empty($_SESSION['user']['channelName'])) {
- $_SESSION['user']['channelName'] = self::_recommendChannelName();
- $user = new User(User::getId());
- $user->setChannelName($_SESSION['user']['channelName']);
- $user->save();
- }
-
- return $_SESSION['user']['channelName'];
- } else {
- return false;
- }
- }
-
- public static function _recommendChannelName($name = "", $try = 0, $unknown = "", $users_id = 0) {
- if (empty($users_id)) {
- if (!empty(User::getId())) {
- $users_id = User::getId();
- }
- }
- if (empty($users_id)) {
- $newChannelName = $name . "_" . uniqid();
- if (strlen($newChannelName) > 40) {
- $newChannelName = uniqid();
- }
- return $newChannelName;
- }
- if ($try > 10) {
- _error_log("User:_recommendChannelName too many tries ({$name}) (" . User::getId() . ") ", AVideoLog::$ERROR);
- return uniqid();
- }
- if (empty($name)) {
- $name = self::getNameIdentification();
- if ($name == __("Unknown User") && !empty($unknown)) {
- $name = $unknown;
- }
- $name = cleanString($name);
- }
- // in case is a email get only the username
- $parts = explode("@", $name);
- $name = $parts[0];
- // do not exceed 36 chars to leave some room for the unique id;
- $name = substr($name, 0, 36);
- if (!Permissions::canAdminUsers()) {
- $user = self::getUserFromChannelName($name);
- if ($user && $user['id'] !== $users_id) {
- return self::_recommendChannelName($name . "_" . uniqid(), $try + 1);
- }
- }
- return $name;
- }
-
- public static function getUserFromChannelName($channelName) {
- $channelName = cleanString($channelName);
- global $global;
- $channelName = ($channelName);
- $sql = "SELECT * FROM users WHERE channelName = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($channelName));
- $user = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
-
- if ($user != false) {
- $user = cleanUpRowFromDatabase($user);
- return $user;
- } else {
- return false;
- }
- }
-
- /**
- * return an name to identify the user
- * @return String
- */
- public static function getNameIdentification() {
- global $advancedCustomUser;
- if (self::isLogged()) {
- if (!empty(self::getName()) && empty($advancedCustomUser->doNotIndentifyByName)) {
- return self::getName();
- }
- if (!empty(self::getMail()) && empty($advancedCustomUser->doNotIndentifyByEmail)) {
- return self::getMail();
- }
- if (!empty(self::getUserName()) && empty($advancedCustomUser->doNotIndentifyByUserName)) {
- return self::getUserName();
- }
- if (!empty(self::getUserChannelName())) {
- return self::getUserChannelName();
- }
- }
- return __("Unknown User");
- }
-
- /**
- * return an name to identify the user from database
- * @return String
- */
- public function getNameIdentificationBd() {
- global $advancedCustomUser;
- if (!empty($this->name) && empty($advancedCustomUser->doNotIndentifyByName)) {
- return $this->name;
- }
- if (!empty($this->email) && empty($advancedCustomUser->doNotIndentifyByEmail)) {
- return $this->email;
- }
- if (!empty($this->user) && empty($advancedCustomUser->doNotIndentifyByUserName)) {
- return $this->user;
- }
- if (!empty($this->channelName)) {
- return $this->channelName;
- }
- return __("Unknown User");
- }
-
- public static function getNameIdentificationById($id = "") {
- if (!empty($id)) {
- $user = new User($id);
- return $user->getNameIdentificationBd();
- }
- return __("Unknown User");
- }
-
- public static function getUserPass() {
- if (self::isLogged()) {
- return $_SESSION['user']['password'];
- } else {
- return false;
- }
- }
-
- public function _getName() {
- return $this->name;
- }
-
- public function getBdName() {
- return $this->_getName();
- }
-
- public static function _getPhoto($id = "") {
- global $global;
- if (!empty($id)) {
- $user = self::findById($id);
- if (!empty($user)) {
- $photo = $user['photoURL'];
- }
- } elseif (self::isLogged()) {
- $photo = $_SESSION['user']['photoURL'];
- }
- if (!empty($photo)) {
- if (preg_match("/videos\/userPhoto\/.*/", $photo) && file_exists($global['systemRootPath'] . $photo)) {
- return $photo;
- } else {
- $photoPath = "/videos/userPhoto/photo{$id}.png";
- $content = url_get_contents($photo);
- file_put_contents($global['systemRootPath'] . $photoPath, $content);
- $photo = $photoPath;
- }
- }
- if (empty($photo)) {
- $photo = "view/img/userSilhouette.jpg";
- }
- return $photo;
- }
-
- public static function getPhoto($id = "") {
- global $global;
- if (!empty($id)) {
- $user = self::findById($id);
- if (!empty($user)) {
- $photo = $user['photoURL'];
- }
- } elseif (self::isLogged()) {
- $photo = $_SESSION['user']['photoURL'];
- }
- if (!empty($photo) && preg_match("/videos\/userPhoto\/.*/", $photo)) {
- if (file_exists($global['systemRootPath'] . $photo)) {
- $photo = getURL($photo);
- } else {
- $photo = "";
- }
- }
- if (empty($photo)) {
- $photo = getURL("view/img/userSilhouette.jpg");
- }
- return $photo;
- }
-
- public static function _getOGImage($users_id) {
- return "/videos/userPhoto/photo{$users_id}_og_200X200.jpg";
- }
-
- public static function deleteOGImage($users_id) {
- global $global;
- $photo = $global['systemRootPath'] . self::_getOGImage($users_id);
- @unlink($photo);
- }
-
- public static function getOGImage($users_id = "") {
- global $global;
- $photo = self::_getPhoto($users_id);
- if ($photo == "view/img/userSilhouette.jpg") {
- return getCDN() . "view/img/userSilhouette.jpg";
- }
- if (empty($photo)) {
- return false;
- }
- $source = $global['systemRootPath'] . $photo;
- $destination = $global['systemRootPath'] . self::_getOGImage($users_id);
-
- convertImageToOG($source, $destination);
-
- return getCDN() . self::_getOGImage($users_id);
- }
-
- public static function getEmailVerifiedIcon($id = "") {
- global $advancedCustomUser;
- $mark = "";
- if (!empty($advancedCustomUser->showEmailVerifiedMark)) {
- if (!empty($id)) {
- $user = self::findById($id);
- if (!empty($user)) {
- $verified = $user['emailVerified'];
- }
- } elseif (self::isLogged()) {
- $verified = $_SESSION['user']['emailVerified'];
- }
- if (!empty($verified)) {
- $mark .= ' ';
- } else {
- //return '';
- $mark .= '';
- }
- }
- if ($advancedCustomUser->Checkmark1Enabled) {
- if (User::externalOptionsFromUserID($id, "checkmark1")) {
- $mark .= " " . $advancedCustomUser->Checkmark1HTML;
- }
- }
- if ($advancedCustomUser->Checkmark2Enabled) {
- if (User::externalOptionsFromUserID($id, "checkmark2")) {
- $mark .= " " . $advancedCustomUser->Checkmark2HTML;
- }
- }
- if ($advancedCustomUser->Checkmark3Enabled) {
- if (User::externalOptionsFromUserID($id, "checkmark3")) {
- $mark .= " " . $advancedCustomUser->Checkmark3HTML;
- }
- }
- return $mark;
- }
-
- public function getPhotoDB() {
- global $global;
- $photo = self::getPhoto($this->id);
- return $photo;
- }
-
- public static function getBackground($id = "") {
- global $global;
- if (!empty($id)) {
- $user = self::findById($id);
- if (!empty($user)) {
- $photo = $user['backgroundURL'];
- }
- } elseif (self::isLogged()) {
- $photo = $_SESSION['user']['backgroundURL'];
- }
- if (!empty($photo) && preg_match("/videos\/userPhoto\/.*/", $photo)) {
- if (file_exists($global['systemRootPath'] . $photo)) {
- $photo = getCDN() . $photo;
- } else {
- $photo = "";
- }
- }
- if (empty($photo)) {
- $photo = getCDN() . "view/img/background.png";
- }
- return $photo;
- }
-
- public static function getMail() {
- if (self::isLogged()) {
- return $_SESSION['user']['email'];
- } else {
- return false;
- }
- }
-
- public function save($updateUserGroups = false) {
- global $global, $config, $advancedCustom, $advancedCustomUser;
- if (is_object($config) && $config->currentVersionLowerThen('5.6')) {
- // they don't have analytics code
- return false;
- }
- if (empty($this->user) || empty($this->password)) {
- //echo "u:" . $this->user . "|p:" . strlen($this->password);
- if (empty($this->user)) {
- //echo "u:" . $this->user . "|p:" . strlen($this->password);
- _error_log('Error : 1 ' . __("You need a user and passsword to register"));
- return false;
- }
- if (empty($this->password)) {
- //echo "u:" . $this->user . "|p:" . strlen($this->password);
- _error_log('Error : 2 ' . __("You need a user and passsword to register"));
- return false;
- }
-
- return false;
- }
- if (empty($this->isAdmin)) {
- $this->isAdmin = "false";
- }
- if (empty($this->canStream)) {
- if (empty($this->id)) { // it is a new user
- if (empty($advancedCustomUser->newUsersCanStream)) {
- $this->canStream = "0";
- } else {
- $this->canStream = "1";
- }
- } else {
- $this->canStream = "0";
- }
- }
- if (empty($this->canUpload)) {
- $this->canUpload = "0";
- }
- if (empty($this->status)) {
- $this->status = 'a';
- }
- if (empty($this->emailVerified)) {
- $this->emailVerified = "false";
- }
-
- $user = ($this->user);
- $password = ($this->password);
- $name = ($this->name);
- $status = ($this->status);
- $this->about = preg_replace("/(\\\)+n/", "\n", $this->about);
- $this->channelName = self::_recommendChannelName($this->channelName, 0, $this->user, $this->id);
- $channelName = ($this->channelName);
- if (filter_var($this->donationLink, FILTER_VALIDATE_URL) === false) {
- $this->donationLink = "";
- }
- if (!empty($this->id)) {
- $formats = "ssssiiii";
- $values = array($user, $password, $this->email, $name, $this->isAdmin, $this->canStream, $this->canUpload, $this->canCreateMeet);
- $sql = "UPDATE users SET user = ?, password = ?, "
- . "email = ?, name = ?, isAdmin = ?,"
- . "canStream = ?,canUpload = ?,canCreateMeet = ?,";
- if (isset($this->canViewChart)) {
- $formats .= "i";
- $values[] = $this->canViewChart;
- $sql .= "canViewChart = ?, ";
- }
- $formats .= "ssssssissssssssssi";
- $values[] = $this->status;
- $values[] = $this->photoURL;
- $values[] = $this->backgroundURL;
- $values[] = $this->recoverPass;
- $values[] = $this->about;
- $values[] = $this->channelName;
- $values[] = $this->emailVerified;
- $values[] = $this->analyticsCode;
- $values[] = $this->externalOptions;
- $values[] = $this->first_name;
- $values[] = $this->last_name;
- $values[] = $this->address;
- $values[] = $this->zip_code;
- $values[] = $this->country;
- $values[] = $this->region;
- $values[] = $this->city;
- $values[] = $this->donationLink;
- $values[] = $this->id;
-
- $sql .= "status = ?, "
- . "photoURL = ?, backgroundURL = ?, "
- . "recoverPass = ?, about = ?, "
- . " channelName = ?, emailVerified = ? , analyticsCode = ?, externalOptions = ? , "
- . " first_name = ? , last_name = ? , address = ? , zip_code = ? , country = ? , region = ? , city = ? , donationLink = ? , "
- . " modified = now() WHERE id = ?";
- } else {
- $formats = "ssssiiiissssss";
- $values = array($user, $password, $this->email, $name, $this->isAdmin, $this->canStream, $this->canUpload, $this->canCreateMeet,
- $status, $this->photoURL, $this->recoverPass, $channelName, $this->analyticsCode, $this->externalOptions);
- $sql = "INSERT INTO users (user, password, email, name, isAdmin, canStream, canUpload, canCreateMeet, canViewChart, status,photoURL,recoverPass, created, modified, channelName, analyticsCode, externalOptions) "
- . " VALUES (?,?,?,?,?,?,?,?, false, "
- . "?,?,?, now(), now(),?,?,?)";
- }
- $insert_row = sqlDAL::writeSql($sql, $formats, $values);
- if ($insert_row) {
- if (empty($this->id)) {
- $id = $global['mysqli']->insert_id;
- if (!empty($advancedCustomUser->unverifiedEmailsCanNOTLogin)) {
- self::sendVerificationLink($id);
- }
- } else {
- $id = $this->id;
- }
- if ($updateUserGroups) {
- require_once $global['systemRootPath'] . 'objects/userGroups.php';
- // update the user groups
- UserGroups::updateUserGroups($id, $this->userGroups);
- }
- return $id;
- } else {
- _error_log(' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error . " $sql");
- return false;
- }
- }
-
- public static function getChannelOwner($channelName) {
- global $global;
- $channelName = ($channelName);
- $sql = "SELECT * FROM users WHERE channelName = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($channelName));
- $result = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($res) {
- $result = cleanUpRowFromDatabase($result);
- $user = $result;
- } else {
- $user = false;
- }
- return $user;
- }
-
- public static function getFromUsername($user) {
- global $global;
- $user = ($user);
- $sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($user));
- $result = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($res) {
- $result = cleanUpRowFromDatabase($result);
- $user = $result;
- } else {
- $user = false;
- }
- return $user;
- }
-
- private static function setCacheWatchVideo($cacheName, $value) {
- if (!User::isLogged()) {
- ObjectYPT::setCache($cacheName, $value);
- ;
- } else {
- ObjectYPT::setSessionCache($cacheName, $value);
- }
- }
-
- public static function canWatchVideo($videos_id) {
- $cacheName = "canWatchVideo$videos_id";
- if (!User::isLogged()) {
- $cacheName = "canWatchVideoNOTLOGED$videos_id";
- $cache = ObjectYPT::getCache($cacheName, 60);
- }
- if (empty($cache)) {
- $cache = ObjectYPT::getSessionCache($cacheName, 600);
- }
- if (isset($cache)) {
- if ($cache === 'false') {
- $cache = false;
- }
- return $cache;
- }
- if (empty($videos_id)) {
- _error_log("User::canWatchVideo Video is empty ({$videos_id})");
- return false;
- }
-
- if (User::isAdmin()) {
- return true;
- }
-
- $video = new Video("", "", $videos_id);
- if ($video->getStatus() === 'i') {
- _error_log("User::canWatchVideo Video is inactive ({$videos_id})");
- self::setCacheWatchVideo($cacheName, false);
- return false;
- }
- $user = new User($video->getUsers_id());
- if ($user->getStatus() === 'i') {
- _error_log("User::canWatchVideo User is inactive ({$videos_id})");
- self::setCacheWatchVideo($cacheName, false);
- return false;
- }
-
- if (AVideoPlugin::userCanWatchVideo(User::getId(), $videos_id)) {
- self::setCacheWatchVideo($cacheName, true);
- return true;
- }
-
- // check if the video is not public
- $rows = UserGroups::getVideoGroups($videos_id);
-
- if (empty($rows)) {
- // check if any plugin restrict access to this video
- $pluginCanWatch = AVideoPlugin::userCanWatchVideo(User::getId(), $videos_id);
- if (!$pluginCanWatch) {
- if (User::isLogged()) {
- _error_log("User::canWatchVideo there is no usergorup set for this video but A plugin said user [" . User::getId() . "] can not see ({$videos_id})");
- } else {
- //_error_log("User::canWatchVideo there is no usergorup set for this video but A plugin said user [not logged] can not see ({$videos_id})");
- }
- self::setCacheWatchVideo($cacheName, false);
- return false;
- } else {
- self::setCacheWatchVideo($cacheName, true);
- return true; // the video is public
- }
- }
-
- if (!User::isLogged()) {
- //_error_log("User::canWatchVideo You are not logged so can not see ({$videos_id}) session_id=" . session_id() . " SCRIPT_NAME=" . $_SERVER["SCRIPT_NAME"] . " IP = " . getRealIpAddr());
-
- self::setCacheWatchVideo($cacheName, false);
- return false;
- }
- // if is not public check if the user is on one of its groups
- $rowsUser = UserGroups::getUserGroups(User::getId());
-
- foreach ($rows as $value) {
- foreach ($rowsUser as $value2) {
- if ($value['id'] === $value2['id']) {
- self::setCacheWatchVideo($cacheName, true);
- return true;
- }
- }
- }
-
- _error_log("User::canWatchVideo The user " . User::getId() . " is not on any of the user groups ({$videos_id}) " . json_encode($rows));
- self::setCacheWatchVideo($cacheName, false);
- return false;
- }
-
- public static function canWatchVideoWithAds($videos_id) {
- if (empty($videos_id)) {
- _error_log("User::canWatchVideo (videos_id is empty) " . $videos_id);
- return false;
- }
- if (User::isAdmin()) {
- return true;
- }
-
- if (AVideoPlugin::userCanWatchVideoWithAds(User::getId(), $videos_id)) {
- //_error_log("User::userCanWatchVideoWithAds (can) " . User::getId() . " " . $videos_id);
- return true;
- }
- _error_log("User::userCanWatchVideoWithAds (No can not) " . User::getId() . " " . $videos_id);
-
- if (self::canWatchVideo($videos_id)) {
- //_error_log("User::canWatchVideo (can) " . $videos_id);
- return true;
- }
- _error_log("User::canWatchVideo (No can not) " . $videos_id);
-
- return false;
- }
-
- public function delete() {
- if (!self::isAdmin()) {
- return false;
- }
- // cannot delete yourself
- if (self::getId() === $this->id) {
- return false;
- }
-
- global $global;
- if (!empty($this->id)) {
- $sql = "DELETE FROM users WHERE id = ?";
- } else {
- return false;
- }
- return sqlDAL::writeSql($sql, "i", array($this->id));
- }
-
- const USER_LOGGED = 0;
- const USER_NOT_VERIFIED = 1;
- const USER_NOT_FOUND = 2;
- const CAPTCHA_ERROR = 3;
- const REQUIRE2FA = 4;
-
- public function login($noPass = false, $encodedPass = false, $ignoreEmailVerification = false) {
- if (User::isLogged()) {
- return false;
- }
- global $global, $advancedCustom, $advancedCustomUser, $config;
-
- if (empty($advancedCustom)) {
- $advancedCustomUser = AVideoPlugin::getObjectData("CustomizeUser");
- }
- if (empty($advancedCustom)) {
- $advancedCustom = AVideoPlugin::getObjectData("CustomizeAdvanced");
- }
-
- if (strtolower($encodedPass) === 'false') {
- $encodedPass = false;
- }
- //_error_log("user::login: noPass = $noPass, encodedPass = $encodedPass, this->user, $this->user " . getRealIpAddr());
- if ($noPass) {
- $user = $this->find($this->user, false, true);
- } else {
- $user = $this->find($this->user, $this->password, true, $encodedPass);
- }
-
- if (!self::checkLoginAttempts()) {
- return self::CAPTCHA_ERROR;
- }
- ObjectYPT::clearSessionCache();
- _session_start();
-
- // check for multiple logins attempts to prevent hacking end
- // if user is not verified
- if (empty($ignoreEmailVerification) && !empty($user) && empty($user['isAdmin']) && empty($user['emailVerified']) && !empty($advancedCustomUser->unverifiedEmailsCanNOTLogin)) {
- unset($_SESSION['user']);
- self::sendVerificationLink($user['id']);
- return self::USER_NOT_VERIFIED;
- } elseif ($user) {
- $_SESSION['user'] = $user;
- $this->setLastLogin($_SESSION['user']['id']);
- $rememberme = 0;
- if ((!empty($_POST['rememberme']) && $_POST['rememberme'] == "true") || !empty($_COOKIE['rememberme'])) {
- $expires = strtotime("+ 1 year");
- $rememberme = 1;
- } else {
- $expires = 0;
- }
- _setcookie("rememberme", $rememberme, $expires);
- _setcookie("user", $user['user'], $expires);
- _setcookie("pass", $user['password'], $expires);
-
- AVideoPlugin::onUserSignIn($_SESSION['user']['id']);
- $_SESSION['loginAttempts'] = 0;
- session_write_close();
- return self::USER_LOGGED;
- } else {
- unset($_SESSION['user']);
- return self::USER_NOT_FOUND;
- }
- }
-
- public static function isCaptchaNeed() {
- global $advancedCustomUser;
- // check for multiple logins attempts to prevent hacking
- if (!empty($_SESSION['loginAttempts']) && !empty($advancedCustomUser->requestCaptchaAfterLoginsAttempts)) {
- if (isMobile()) {
- $advancedCustomUser->requestCaptchaAfterLoginsAttempts += 10;
- }
- if ($_SESSION['loginAttempts'] > $advancedCustomUser->requestCaptchaAfterLoginsAttempts) {
- return true;
- }
- }
- return false;
- }
-
- public static function checkLoginAttempts() {
- global $advancedCustomUser, $global;
- // check for multiple logins attempts to prevent hacking
- if (empty($_SESSION['loginAttempts'])) {
- _session_start();
- $_SESSION['loginAttempts'] = 0;
- }
- if (!empty($advancedCustomUser->requestCaptchaAfterLoginsAttempts)) {
- _session_start();
- $_SESSION['loginAttempts']++;
- if ($_SESSION['loginAttempts'] > $advancedCustomUser->requestCaptchaAfterLoginsAttempts) {
- if (empty($_POST['captcha'])) {
- return false;
- }
- require_once $global['systemRootPath'] . 'objects/captcha.php';
- if (!Captcha::validation($_POST['captcha'])) {
- return false;
- }
- }
- }
- return true;
- }
-
- public static function getCaptchaFormIfNeed() {
- // check for multiple logins attempts to prevent hacking
- if (self::isCaptchaNeed()) {
- return self::getCaptchaForm();
- }
- return "";
- }
-
- public static function getCaptchaForm($uid = "") {
- global $global;
- return '
'
- . '
-
-
-
- ';
- }
-
- private function setLastLogin($user_id) {
- global $global;
- if (empty($user_id)) {
- die('Error : setLastLogin ');
- }
- $sql = "UPDATE users SET lastLogin = now(), modified = now() WHERE id = ?";
- return sqlDAL::writeSql($sql, "i", array($user_id));
- }
-
- public static function logoff() {
- global $global, $justLogoff;
- $justLogoff = true;
- _session_start();
- ObjectYPT::deleteAllSessionCache();
- _unsetcookie('rememberme');
- _unsetcookie('user');
- _unsetcookie('pass');
- unset($_SESSION['user']);
- }
-
- private static function recreateLoginFromCookie() {
- global $justLogoff, $justTryToRecreateLoginFromCookie;
-
- if (empty($justTryToRecreateLoginFromCookie) && empty($justLogoff) && empty($_SESSION['user']['id'])) {
- $justTryToRecreateLoginFromCookie = 1;
-
- // first check if the LoginControl::singleDeviceLogin is enabled, if it is only recreate login if the device is the last device
- if ($obj = AVideoPlugin::getDataObjectIfEnabled("LoginControl")) {
- if (!empty($obj->singleDeviceLogin)) {
- if (!LoginControl::isLoggedFromSameDevice()) {
- _error_log("user::recreateLoginFromCookie: LoginControl and the last logged device is different: " . $_COOKIE['user'] . "");
- self::logoff();
- return false;
- }
- }
- }
- if ((!empty($_COOKIE['user'])) && (!empty($_COOKIE['pass'])) && (!empty($_COOKIE['rememberme']))) {
- $user = new User(0, $_COOKIE['user'], false);
- $user->setPassword($_COOKIE['pass'], true);
- // $dbuser = self::getUserDbFromUser($_COOKIE['user']);
- $resp = $user->login(false, true);
-
- _error_log("user::recreateLoginFromCookie: do cookie-login: " . $_COOKIE['user'] . " result: " . $resp);
- if (0 == $resp) {
- _error_log("success " . $_SESSION['user']['id']);
- } else {
- _error_log("user::recreateLoginFromCookie: do logoff: " . $_COOKIE['user'] . " result: " . $resp);
- self::logoff();
- }
- }
- }
- }
-
- public static function isLogged($checkForRequestLogin=false) {
- self::recreateLoginFromCookie();
- $isLogged = !empty($_SESSION['user']['id']);
- if(empty($isLogged) && $checkForRequestLogin){
- self::loginFromRequest();
- return !empty($_SESSION['user']['id']);
- }else{
- return $isLogged;
- }
- }
-
- public static function isVerified() {
- self::recreateLoginFromCookie();
- return !empty($_SESSION['user']['emailVerified']);
- }
-
- public static function isAdmin($users_id = 0) {
- if (!empty($users_id)) {
- $user = new User($users_id);
- return !empty($user->getIsAdmin());
- }
-
- self::recreateLoginFromCookie();
- return !empty($_SESSION['user']['isAdmin']);
- }
-
- public static function canStream() {
- self::recreateLoginFromCookie();
- return !empty($_SESSION['user']['isAdmin']) || !empty($_SESSION['user']['canStream']);
- }
-
- public static function externalOptions($id) {
- if (!empty($_SESSION['user']['externalOptions'])) {
- $externalOptions = unserialize(base64_decode($_SESSION['user']['externalOptions']));
- if (isset($externalOptions[$id])) {
- if ($externalOptions[$id] == "true") {
- $externalOptions[$id] = true;
- } elseif ($externalOptions[$id] == "false") {
- $externalOptions[$id] = false;
- }
-
- return $externalOptions[$id];
- }
- }
- return false;
- }
-
- public function getExternalOptions($id) {
- if (empty($this->id)) {
- return null;
- }
- return self::externalOptionsFromUserID($this->id, $id);
- }
-
- public static function externalOptionsFromUserID($users_id, $id) {
- $user = self::findById($users_id);
- if ($user) {
- if (!is_null($user['externalOptions'])) {
- $externalOptions = unserialize(base64_decode($user['externalOptions']));
- if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
- //var_dump($externalOptions);
- foreach ($externalOptions as $k => $v) {
- if ($id != $k) {
- continue;
- }
- if ($v == "true") {
- $v = 1;
- } elseif ($v == "false") {
- $v = 0;
- }
- return $v;
- }
- }
- }
- }
- return false;
- }
-
- public function thisUserCanStream() {
- if ($this->status === 'i') {
- return false;
- }
- return !empty($this->isAdmin) || !empty($this->canStream);
- }
-
- private function find($user, $pass, $mustBeactive = false, $encodedPass = false) {
- global $global, $advancedCustom;
- $formats = "";
- $values = array();
- $sql = "SELECT * FROM users WHERE user = ? ";
-
- $formats .= "s";
- $values[] = $user;
-
- if (trim($user) !== $user) {
- $formats .= "s";
- $values[] = trim($user);
- $sql .= " OR user = ? ";
- }
-
- if ($mustBeactive) {
- $sql .= " AND status = 'a' ";
- }
-
- $sql .= " LIMIT 1";
- $res = sqlDAL::readSql($sql, $formats, $values, true);
- $result = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if (!empty($result)) {
- if ($pass !== false) {
- if (!encryptPasswordVerify($pass, $result['password'], $encodedPass)) {
- if (!empty($advancedCustom) && $advancedCustom->enableOldPassHashCheck) {
- _error_log("Password check new hash pass does not match, trying MD5");
- return $this->find_Old($user, $pass, $mustBeactive, $encodedPass);
- } else {
- return false;
- }
- }
- }
- $user = $result;
- } else {
- _error_log("Password check new hash user not found");
- //check if is the old password style
- $user = false;
- //$user = false;
- }
- return $user;
- }
-
- /**
- * this is the deprecated function, with week password
- * @global type $global
- * @param type $user
- * @param type $pass
- * @param type $mustBeactive
- * @param type $encodedPass
- * @return boolean
- */
- private function find_Old($user, $pass, $mustBeactive = false, $encodedPass = false) {
- global $global;
- $formats = "";
- $values = array();
- $sql = "SELECT * FROM users WHERE user = ? ";
-
- $formats .= "s";
- $values[] = $user;
-
- if ($mustBeactive) {
- $sql .= " AND status = 'a' ";
- }
- if ($pass !== false) {
- if (!$encodedPass || $encodedPass === 'false') {
- _error_log("Password check Old not encoded pass");
- $passEncoded = md5($pass);
- } else {
- _error_log("Password check Old encoded pass");
- $passEncoded = $pass;
- }
- $sql .= " AND password = ? ";
- $formats .= "s";
- $values[] = $passEncoded;
- }
- $sql .= " LIMIT 1";
- $res = sqlDAL::readSql($sql, $formats, $values, true);
- $result = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if (!empty($result)) {
- if (!$encodedPass || $encodedPass === 'false') {
- //update the password
- $u = new User($result['id']);
- $u->setPassword($pass);
- $u->save();
- $result['password'] = $u->getPassword();
- }
- $user = $result;
- } else {
- $user = false;
- }
- if (empty($user)) {
- _error_log("Password check Old not found");
- } else {
- _error_log("Password check Old found");
- }
- return $user;
- }
-
- private static function findById($id) {
- global $global;
- $id = intval($id);
- if (empty($id)) {
- return false;
- }
- $sql = "SELECT * FROM users WHERE id = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "i", array($id));
- $result = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($res) {
- $user = $result;
- } else {
- $user = false;
- }
- return $user;
- }
-
- public static function findByEmail($email) {
- global $global;
- $email = trim($email);
- if (empty($email)) {
- return false;
- }
- $sql = "SELECT * FROM users WHERE email = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($email));
- $result = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- $user = $result;
- } else {
- $user = false;
- }
- return $user;
- }
-
- private static function getUserDb($id) {
- global $global;
- $id = intval($id);
- if (empty($id)) {
- return false;
- }
- $sql = "SELECT * FROM users WHERE id = ? LIMIT 1;";
- $res = sqlDAL::readSql($sql, "i", array($id));
- $user = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($user != false) {
- return $user;
- }
- return false;
- }
-
- private static function getUserDbFromUser($user) {
- global $global;
- if (empty($user)) {
- return false;
- }
- $sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($user));
- $user = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($user != false) {
- return $user;
- }
- return false;
- }
-
- public static function getUserFromID($users_id) {
- global $global;
- if (empty($users_id)) {
- return false;
- }
- $sql = "SELECT * FROM users WHERE id = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($users_id));
- $user = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($user != false) {
- $user['groups'] = UserGroups::getUserGroups($user['id']);
- $user['identification'] = self::getNameIdentificationById($user['id']);
- $user['photo'] = self::getPhoto($user['id']);
- $user['background'] = self::getBackground($user['id']);
- $user['tags'] = self::getTags($user['id']);
- $user['name'] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $user['name']);
- $user['isEmailVerified'] = $user['emailVerified'];
- if (!is_null($user['externalOptions'])) {
- $externalOptions = unserialize(base64_decode($user['externalOptions']));
- if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
- foreach ($externalOptions as $k => $v) {
- if ($v == "true") {
- $v = 1;
- } elseif ($v == "false") {
- $v = 0;
- }
- $user[$k] = $v;
- }
- }
- }
- unset($user['password'], $user['recoverPass']);
- if (!Permissions::canAdminUsers() && $user['id'] !== User::getId()) {
- unset(
- $user['first_name'],
- $user['last_name'],
- $user['address'],
- $user['zip_code'],
- $user['country'],
- $user['region'],
- $user['city']
- );
- }
- return $user;
- }
- return false;
- }
-
- public static function getUserFromEmail($email) {
- $email = trim($email);
- $sql = "SELECT * FROM users WHERE email = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($email), true);
- $user = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($user != false) {
- return $user;
- }
- return false;
- }
-
- public function setUser($user) {
- global $advancedCustomUser;
- if (empty($advancedCustomUser->userCanChangeUsername)) {
- if (!empty($this->user)) {
- return false;
- }
- }
- $this->user = strip_tags($user);
- }
-
- public function setName($name) {
- $this->name = strip_tags($name);
- }
-
- public function setEmail($email) {
- global $advancedCustomUser;
- $email = strip_tags($email);
- if (!empty($advancedCustomUser->emailMustBeUnique)) {
- if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
- return false;
- }
- $userFromEmail = User::getUserFromEmail($email);
- if (!empty($userFromEmail)) {
- return false;
- }
- }
- $this->email = $email;
- return true;
- }
-
- public function setPassword($password, $doNotEncrypt = false) {
- if (!empty($password)) {
- if ($doNotEncrypt) {
- $this->password = ($password);
- } else {
- $this->password = encryptPassword($password);
- }
- }
- }
-
- public function setIsAdmin($isAdmin) {
- if (empty($isAdmin) || $isAdmin === "false" || !User::isAdmin()) {
- $isAdmin = "0";
- } else {
- $isAdmin = "1";
- }
- $this->isAdmin = $isAdmin;
- }
-
- public function setStatus($status) {
- $this->status = strip_tags($status);
- }
-
- public function getPhotoURL() {
- return $this->photoURL;
- }
-
- public function setPhotoURL($photoURL) {
- $this->photoURL = strip_tags($photoURL);
- }
-
- public static function getAllUsersFromUsergroup($users_groups_id, $ignoreAdmin = false, $searchFields = array('name', 'email', 'user', 'channelName', 'about'), $status = "") {
- if (!Permissions::canAdminUsers() && !$ignoreAdmin) {
- return false;
- }
- $users_groups_id = intval($users_groups_id);
- if (empty($users_groups_id)) {
- return false;
- }
- //will receive
- //current=1&rowCount=10&sort[sender]=asc&searchPhrase=
- global $global;
- $sql = "SELECT * FROM users u WHERE 1=1 ";
-
- $queryIds = array();
- if (empty($_REQUEST['userGroupShowOnly']) || $_REQUEST['userGroupShowOnly'] == 'permanent') {
- $queryIds[] = " id IN (SELECT users_id FROM users_has_users_groups ug WHERE ug.users_groups_id = {$users_groups_id}) ";
- }
- if (empty($_REQUEST['userGroupShowOnly']) || $_REQUEST['userGroupShowOnly'] == 'dynamic') {
- $ids = AVideoPlugin::getDynamicUsersId($users_groups_id);
- if (!empty($ids) && is_array($ids)) {
- $ids = array_unique($ids);
- $queryIds[] = " id IN ('" . implode("','", $ids) . "') ";
- }
- }
- if (!empty($queryIds)) {
- $sql .= " AND ( ";
- $sql .= implode(' OR ', $queryIds);
- $sql .= " ) ";
- }else{
- // do not return nothing
- $sql .= " AND u.id < 0 ";
- }
-
- if (!empty($status)) {
- if (strtolower($status) === 'i') {
- $sql .= " AND u.status = 'i' ";
- } else {
- $sql .= " AND u.status = 'a' ";
- }
- }
-
- $sql .= BootGrid::getSqlFromPost($searchFields);
-
- $user = array();
- require_once $global['systemRootPath'] . 'objects/userGroups.php';
- //echo $sql;exit;
- $res = sqlDAL::readSql($sql . ";");
- $downloadedArray = sqlDAL::fetchAllAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- foreach ($downloadedArray as $row) {
- $row['creator'] = Video::getCreatorHTML($row['id'], '', true, true);
- $row = cleanUpRowFromDatabase($row);
- $user[] = self::getUserInfoFromRow($row);
- }
- } else {
- $user = false;
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
- }
-
- return $user;
- }
-
- public static function getTotalUsersFromUsergroup($users_groups_id, $ignoreAdmin = false, $status = "") {
- if (!Permissions::canAdminUsers() && !$ignoreAdmin) {
- return false;
- }
- $users_groups_id = intval($users_groups_id);
- if (empty($users_groups_id)) {
- return false;
- }
- //will receive
- //current=1&rowCount=10&sort[sender]=asc&searchPhrase=
- global $global;
- $sql = "SELECT id FROM users WHERE 1=1 ";
-
- $queryIds = array();
- if (empty($_REQUEST['userGroupShowOnly']) || $_REQUEST['userGroupShowOnly'] == 'permanent') {
- $queryIds[] = " id IN (SELECT users_id FROM users_has_users_groups ug WHERE ug.users_groups_id = {$users_groups_id}) ";
- }
- if (empty($_REQUEST['userGroupShowOnly']) || $_REQUEST['userGroupShowOnly'] == 'dynamic') {
- $ids = AVideoPlugin::getDynamicUsersId($users_groups_id);
- if (!empty($ids) && is_array($ids)) {
- $ids = array_unique($ids);
- $queryIds[] = " id IN ('" . implode("','", $ids) . "') ";
- }
- }
- if (!empty($queryIds)) {
- $sql .= " AND ( ";
- $sql .= implode(' OR ', $queryIds);
- $sql .= " ) ";
- }else{
- // do not return nothing
- $sql .= " AND u.id < 0 ";
- }
-
- if (!empty($status)) {
- if (strtolower($status) === 'i') {
- $sql .= " AND status = 'i' ";
- } else {
- $sql .= " AND status = 'a' ";
- }
- }
- $sql .= BootGrid::getSqlSearchFromPost(array('name', 'email', 'user'));
-
- $res = sqlDAL::readSql($sql);
- $result = sqlDal::num_rows($res);
- sqlDAL::close($res);
-
-
- return $result;
- }
-
- public static function getAllUsers($ignoreAdmin = false, $searchFields = array('name', 'email', 'user', 'channelName', 'about'), $status = "", $isAdmin = null) {
- if (!Permissions::canAdminUsers() && !$ignoreAdmin) {
- return false;
- }
- //will receive
- //current=1&rowCount=10&sort[sender]=asc&searchPhrase=
- global $global;
- $sql = "SELECT * FROM users WHERE 1=1 ";
- if (!empty($status)) {
- if (strtolower($status) === 'i') {
- $sql .= " AND status = 'i' ";
- } else {
- $sql .= " AND status = 'a' ";
- }
- }
- if (isset($isAdmin)) {
- if (empty($isAdmin)) {
- $sql .= " AND isAdmin = 0 ";
- } else {
- $sql .= " AND isAdmin = 1 ";
- }
- }
- $sql .= BootGrid::getSqlFromPost($searchFields);
-
- $user = array();
- require_once $global['systemRootPath'] . 'objects/userGroups.php';
- $res = sqlDAL::readSql($sql . ";");
- $downloadedArray = sqlDAL::fetchAllAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- foreach ($downloadedArray as $row) {
- $row['creator'] = Video::getCreatorHTML($row['id'], '', true, true);
- $row = self::getUserInfoFromRow($row);
- $row = cleanUpRowFromDatabase($row);
- $user[] = $row;
- }
- } else {
- $user = false;
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
- }
-
- return $user;
- }
-
- public static function getAllActiveUsersThatCanUpload() {
- if (!Permissions::canAdminUsers()) {
- return false;
- }
- //will receive
- //current=1&rowCount=10&sort[sender]=asc&searchPhrase=
- global $global;
- $sql = "SELECT * FROM users WHERE 1=1 AND status = 'a' AND (canUpload = 1 OR isAdmin = 1) ";
-
- $user = array();
- $res = sqlDAL::readSql($sql . ";");
- $downloadedArray = sqlDAL::fetchAllAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- foreach ($downloadedArray as $row) {
- $row = cleanUpRowFromDatabase($row);
- $user[] = $row;
- }
- } else {
- $user = false;
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
- }
-
- return $user;
- }
-
- private static function getUserInfoFromRow($row) {
- $row['groups'] = UserGroups::getUserGroups($row['id']);
- $row['identification'] = self::getNameIdentificationById($row['id']);
- $row['photo'] = self::getPhoto($row['id']);
- $row['background'] = self::getBackground($row['id']);
- $row['tags'] = self::getTags($row['id']);
- $row['name'] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $row['name']);
- $row['isEmailVerified'] = $row['emailVerified'];
- if (!is_null($row['externalOptions'])) {
- $externalOptions = unserialize(base64_decode($row['externalOptions']));
- if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
- foreach ($externalOptions as $k => $v) {
- if ($v == "true") {
- $v = 1;
- } elseif ($v == "false") {
- $v = 0;
- }
- $row[$k] = $v;
- }
- }
- }
- unset($row['password'], $row['recoverPass']);
- if (!Permissions::canAdminUsers() && $row['id'] !== User::getId()) {
- unset(
- $row['first_name'],
- $row['last_name'],
- $row['address'],
- $row['zip_code'],
- $row['country'],
- $row['region'],
- $row['city']
- );
- }
- return $row;
- }
-
- public static function getAllUsersThatHasVideos($ignoreAdmin = false) {
- if (!self::isAdmin() && !$ignoreAdmin) {
- return false;
- }
- global $global;
- $sql = "SELECT * FROM users u WHERE status = 'a' AND (canUpload = 1 || isAdmin = 1) AND "
- . " (SELECT count(id) FROM videos where users_id = u.id )>0 ";
-
- $user = array();
- $res = sqlDAL::readSql($sql . ";");
- $downloadedArray = sqlDAL::fetchAllAssoc($res);
- sqlDAL::close($res);
- if ($res != false) {
- foreach ($downloadedArray as $row) {
- $row = cleanUpRowFromDatabase($row);
- $user[] = $row;
- }
- } else {
- $user = false;
- die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
- }
-
- return $user;
- }
-
- public static function getTotalUsers($ignoreAdmin = false, $status = "", $isAdmin = null) {
- if (!Permissions::canAdminUsers() && !$ignoreAdmin) {
- return false;
- }
- //will receive
- //current=1&rowCount=10&sort[sender]=asc&searchPhrase=
- global $global;
- $sql = "SELECT id FROM users WHERE 1=1 ";
-
- if (!empty($status)) {
- if (strtolower($status) === 'i') {
- $sql .= " AND status = 'i' ";
- } else {
- $sql .= " AND status = 'a' ";
- }
- }
- if (isset($isAdmin)) {
- if (empty($isAdmin)) {
- $sql .= " AND isAdmin = 0 ";
- } else {
- $sql .= " AND isAdmin = 1 ";
- }
- }
- $sql .= BootGrid::getSqlSearchFromPost(array('name', 'email', 'user'));
-
- $res = sqlDAL::readSql($sql);
- $result = sqlDal::num_rows($res);
- sqlDAL::close($res);
-
-
- return $result;
- }
-
- public static function userExists($user) {
- global $global;
- $user = ($user);
- $sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "s", array($user));
- $user = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
-
- if ($user != false) {
- return $user['id'];
- } else {
- return false;
- }
- }
-
- public static function idExists($users_id) {
- global $global;
- $users_id = intval($users_id);
- $sql = "SELECT * FROM users WHERE id = ? LIMIT 1";
- $res = sqlDAL::readSql($sql, "i", array($users_id));
- $user = sqlDAL::fetchAssoc($res);
- sqlDAL::close($res);
- if ($user != false) {
- return $user['id'];
- } else {
- return false;
- }
- }
-
- public static function createUserIfNotExists($user, $pass, $name, $email, $photoURL, $isAdmin = false, $emailVerified = false) {
- global $global, $advancedCustomUser;
- $userId = 0;
- if (!$userId = self::userExists($user)) {
- if (empty($pass)) {
- $pass = uniqid();
- }
- $pass = encryptPassword($pass);
- $userObject = new User(0, $user, $pass);
- $userObject->setEmail($email);
- $userObject->setName($name);
- $userObject->setIsAdmin($isAdmin);
- $userObject->setPhotoURL($photoURL);
- $userObject->setEmailVerified($emailVerified);
- $userId = $userObject->save();
- if (!empty($userId)) {
- if (!empty($advancedCustomUser->userDefaultUserGroup->value)) { // for new users use the default usergroup
- UserGroups::updateUserGroups($userId, array($advancedCustomUser->userDefaultUserGroup->value), true);
- }
- }
- return $userId;
- } else {
- if ($emailVerified) {
- $userObj = new User($userId);
- if (!$userObj->getEmailVerified()) {
- $userObj->setEmailVerified(1);
- $userObj->save();
- }
- }
- }
- return $userId;
- }
-
- public function getRecoverPass() {
- return $this->recoverPass;
- }
-
- public function setRecoverPass($forceChange = false) {
- // let the same recover pass if it was 10 minutes ago
- if (!$this->isRecoverPassExpired($this->recoverPass) && empty($forceChange) && !empty($this->recoverPass) && !empty($recoverPass) && !empty($this->modified) && strtotime($this->modified) > strtotime("-10 minutes")) {
- return $this->recoverPass;
- }
- $this->recoverPass = $this->createRecoverPass();
- return $this->recoverPass;
- }
-
- private function createRecoverPass($secondsValid = 600) {
- $json = new stdClass();
- $json->valid = strtotime("+{$secondsValid} seconds");
- return encryptString(json_encode($json));
- }
-
- function checkRecoverPass($recoverPass) {
- if ($this->recoverPass === $recoverPass) {
- if (!$this->isRecoverPassExpired($recoverPass)) {
- _error_log('checkRecoverPass success: ' . $this->user . ' ' . getRealIpAddr());
- return true;
- }
- }
- return false;
- }
-
- function isRecoverPassExpired($recoverPass) {
- $string = decryptString($recoverPass);
- if ($string) {
- $json = _json_decode($string);
- if (is_object($json)) {
- if (time() < $json->valid) {
- return false;
- }
- }
- }
- return true;
- }
-
- public static function canUpload($doNotCheckPlugins = false) {
- global $global, $config, $advancedCustomUser;
- if (Permissions::canModerateVideos()) {
- return true;
- }
- if (User::isAdmin()) {
- return true;
- }
- if (empty($doNotCheckPlugins) && !AVideoPlugin::userCanUpload(User::getId())) {
- return false;
- }
-
- if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && !User::isVerified())) {
- return false;
- }
-
- if ($config->getAuthCanUploadVideos()) {
- return self::isLogged();
- }
- if (self::isLogged() && !empty($_SESSION['user']['canUpload'])) {
- return true;
- }
- return self::isAdmin();
- }
-
- public static function canViewChart() {
- global $global, $config;
- if (self::isLogged() && !empty($_SESSION['user']['canViewChart'])) {
- return true;
- }
- return self::isAdmin();
- }
-
- public static function canCreateMeet() {
- global $global, $config;
- if (self::isLogged() && !empty($_SESSION['user']['canCreateMeet'])) {
- return true;
- }
- return self::isAdmin();
- }
-
- public static function canComment() {
- global $global, $config, $advancedCustomUser;
- if (self::isAdmin()) {
- return true;
- }
-
- if (Permissions::canAdminComment()) {
- return true;
- }
-
- if ($config->getAuthCanComment()) {
- if (empty($advancedCustomUser->unverifiedEmailsCanNOTComment)) {
- return self::isLogged();
- } else {
- return self::isVerified();
- }
- }
- return false;
- }
-
- public static function canSeeCommentTextarea() {
- global $global, $config;
- if (!$config->getAuthCanComment()) {
- if (!self::isAdmin()) {
- return false;
- }
- }
- return true;
- }
-
- public function getUserGroups() {
- return $this->userGroups;
- }
-
- public function setUserGroups($userGroups) {
- if (is_array($userGroups)) {
- $this->userGroups = $userGroups;
- }
- }
-
- public function getIsAdmin() {
- return $this->isAdmin;
- }
-
- public function getStatus() {
- return $this->status;
- }
-
- /**
- *
- * @param type $user_id
- * text
- * label Default Primary Success Info Warning Danger
- */
- public static function getTags($user_id) {
- $user = new User($user_id);
- $tags = array();
- if ($user->getIsAdmin()) {
- $obj = new stdClass();
- $obj->type = "info";
- $obj->text = __("Admin");
- $tags[] = $obj;
- } else {
- $obj = new stdClass();
- $obj->type = "default";
- $obj->text = __("Regular User");
- $tags[] = $obj;
- }
-
- if ($user->getStatus() == "a") {
- $obj = new stdClass();
- $obj->type = "success";
- $obj->text = __("Active");
- $tags[] = $obj;
- } else {
- $obj = new stdClass();
- $obj->type = "danger";
- $obj->text = __("Inactive");
- $tags[] = $obj;
- }
- if ($user->getEmailVerified()) {
- $obj = new stdClass();
- $obj->type = "success";
- $obj->text = __("E-mail Verified");
- $tags[] = $obj;
- } else {
- $obj = new stdClass();
- $obj->type = "warning";
- $obj->text = __("E-mail Not Verified");
- $tags[] = $obj;
- }
- global $global;
- if (!empty($global['systemRootPath'])) {
- require_once $global['systemRootPath'] . 'objects/userGroups.php';
- } else {
- require_once 'userGroups.php';
- }
- $groups = UserGroups::getUserGroups($user_id);
- foreach ($groups as $value) {
- $obj = new stdClass();
- $obj->type = "warning";
- $obj->text = (!empty($value['isDynamic']) ? '' : '') . ' ' . $value['group_name'];
- $tags[] = $obj;
- }
-
- return $tags;
- }
-
- public function getBackgroundURL() {
- global $global;
- $this->backgroundURL = self::getBackgroundURLFromUserID($this->id);
- return $this->backgroundURL;
- }
-
- public static function getBackgroundURLFromUserID($users_id = 0) {
- if (empty($users_id)) {
- $users_id = User::getId();
- }
- global $global;
- $backgroundURL = "videos/userPhoto/background{$users_id}.jpg";
- if (!file_exists($global['systemRootPath'] . $backgroundURL)) {
- $backgroundURL = "videos/userPhoto/background{$users_id}.png";
- }
- if (!file_exists($global['systemRootPath'] . $backgroundURL)) {
- $backgroundURL = "view/img/background.jpg";
- }
- return $backgroundURL;
- }
-
- public function setBackgroundURL($backgroundURL) {
- $this->backgroundURL = strip_tags($backgroundURL);
- }
-
- public function getChannelName() {
- if (empty($this->channelName)) {
- $this->channelName = self::_recommendChannelName($this->channelName);
- $this->save();
- }
- return $this->channelName;
- }
-
- public static function _getUserChannelName($users_id = 0) {
- global $global, $config;
- if (empty($users_id)) {
- $users_id = self::getId();
- }
- $user = new User($users_id);
- if (empty($user)) {
- return false;
- }
-
- return $user->getChannelName();
- }
-
- public function getEmailVerified() {
- return intval($this->emailVerified);
- }
-
- public static function validateChannelName($channelName) {
- return trim(preg_replace("/[^0-9A-Z_]/i", "", ucwords($channelName)));
- }
-
- /**
- *
- * @param type $channelName
- * @return boolean return true is is unique
- */
- public function setChannelName($channelName) {
- $channelName = self::validateChannelName($channelName);
- $user = static::getChannelOwner($channelName);
- if (!empty($user)) { // if the channel name exists and it is not from this user, rename the channel name
- if (empty($this->id) || $user['id'] != $this->id) {
- return false;
- }
- }
- $this->channelName = xss_esc($channelName);
- return true;
- }
-
- public function setEmailVerified($emailVerified) {
- $this->emailVerified = (empty($emailVerified) || strtolower($emailVerified) === 'false') ? 0 : 1;
- }
-
- public static function getChannelLink($users_id = 0) {
- global $global;
- $name = self::_getChannelName($users_id);
- if (empty($name)) {
- return false;
- }
- $link = "{$global['webSiteRootURL']}channel/" . urlencode($name);
- return $link;
- }
-
- public static function getChannelLinkFromChannelName($channelName) {
- global $global;
- $link = "{$global['webSiteRootURL']}channel/" . urlencode($channelName);
- return $link;
- }
-
- public static function _getChannelName($users_id = 0) {
- global $global, $config;
- if (empty($users_id)) {
- $users_id = self::getId();
- }
- $user = new User($users_id);
- if (empty($user)) {
- return false;
- }
- if (empty($user->getChannelName())) {
- $name = $user->getBdId();
- } else {
- $name = $user->getChannelName();
- }
- return $name;
- }
-
- public static function sendVerificationLink($users_id) {
- global $global, $advancedCustomUser;
- //Only send the verification email each 30 minutes
- if (!empty($_SESSION["sendVerificationLink"][$users_id]) && time() - $_SESSION["sendVerificationLink"][$users_id] > 1800) {
- _error_log("sendVerificationLink: Email already sent, we will wait 30 min {$users_id}");
- return true;
- }
- $config = new Configuration();
- $user = new User($users_id);
- $code = urlencode(static::createVerificationCode($users_id));
- //Create a new PHPMailer instance
- if (!is_object($config)) {
- _error_log("sendVerificationLink: config is not a object " . json_encode($config));
- return false;
- }
- $contactEmail = $config->getContactEmail();
- $webSiteTitle = $config->getWebSiteTitle();
- $email = $user->getEmail();
- try {
- $mail = new \PHPMailer\PHPMailer\PHPMailer;
- setSiteSendMessage($mail);
- //$mail->SMTPDebug = 4;
- //Set who the message is to be sent from
- $mail->setFrom($contactEmail, $webSiteTitle);
- //Set who the message is to be sent to
- $mail->addAddress($email);
- //Set the subject line
- $mail->Subject = __('Please Verify Your E-mail ') . $webSiteTitle;
-
- $msg = sprintf(__("Hi %s"), $user->getName());
- $msg .= "
";
- }
-}
-
-echo json_encode($obj);
+success = false;
+require_once $global['systemRootPath'] . 'objects/functions.php';
+header('Content-Type: application/json');
+
+$obj = AVideoPlugin::getObjectData("LoginGoogle");
+$OAUTH2_CLIENT_ID = $obj->id;
+$OAUTH2_CLIENT_SECRET = $obj->key;
+/*
+ * You can acquire an OAuth 2.0 client ID and client secret from the
+ * {{ Google Cloud Console }} <{{ https://cloud.google.com/console }}>
+ * For more information about using OAuth 2.0 to access Google APIs, please see:
+ *
+ * Please ensure that you have enabled the YouTube Data API for your project.
+ */
+$client = new Google_Client();
+$client->setClientId($OAUTH2_CLIENT_ID);
+$client->setClientSecret($OAUTH2_CLIENT_SECRET);
+$client->setScopes('https://www.googleapis.com/auth/youtube');
+//$redirectUri = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'],FILTER_SANITIZE_URL);
+$redirectUri = "{$global['webSiteRootURL']}objects/youtubeUpload.json.php";
+$redirect = "{$global['webSiteRootURL']}mvideos";
+$client->setRedirectUri($redirectUri);
+// Define an object that will be used to make all API requests.
+$youtube = new Google_Service_YouTube($client);
+// Check if an auth token exists for the required scopes
+$tokenSessionKey = 'token-' . $client->prepareScopes();
+if (isset($_GET['code'])) {
+ if (strval($_SESSION['state']) !== strval($_GET['state'])) {
+ die('The session state did not match.');
+ }
+ $client->authenticate($_GET['code']);
+ $_SESSION[$tokenSessionKey] = $client->getAccessToken();
+ header('Location: ' . $redirect);
+}
+if (!is_array($_POST['id'])) {
+ $_POST['id'] = [$_POST['id']];
+}
+foreach ($_POST['id'] as $value) {
+ $v = new Video("", "", $value);
+ if (!$v->userCanManageVideo()) {
+ $obj->msg = __("You can not Manage This Video");
+ die(json_encode($obj));
+ }
+ if (isset($_SESSION[$tokenSessionKey])) {
+ $client->setAccessToken($_SESSION[$tokenSessionKey]);
+ }
+ // Check to ensure that the access token was successfully acquired.
+ if ($client->getAccessToken()) {
+ try {
+ // REPLACE this value with the path to the file you are uploading.
+ $videoPath = $v->getExistingVideoFile();
+ // Create a snippet with title, description, tags and category ID
+ // Create an asset resource and set its snippet metadata and type.
+ // This example sets the video's title, description, keyword tags, and
+ // video category.
+ $snippet = new Google_Service_YouTube_VideoSnippet();
+ $snippet->setTitle($v->getTitle());
+ $snippet->setDescription($v->getDescription());
+ $snippet->setTags(["AVideo", $config->getWebSiteTitle()]);
+ // Numeric video category. See
+ // https://developers.google.com/youtube/v3/docs/videoCategories/list
+ // $snippet->setCategoryId("22");
+ // Set the video's status to "public". Valid statuses are "public",
+ // "private" and "unlisted".
+ $status = new Google_Service_YouTube_VideoStatus();
+ $status->privacyStatus = "public";
+ // Associate the snippet and status objects with a new video resource.
+ $video = new Google_Service_YouTube_Video();
+ $video->setSnippet($snippet);
+ $video->setStatus($status);
+ // Specify the size of each chunk of data, in bytes. Set a higher value for
+ // reliable connection as fewer chunks lead to faster uploads. Set a lower
+ // value for better recovery on less reliable connections.
+ $chunkSizeBytes = 1 * 1024 * 1024;
+ // Setting the defer flag to true tells the client to return a request which can be called
+ // with ->execute(); instead of making the API call immediately.
+ $client->setDefer(true);
+ // Create a request for the API's videos.insert method to create and upload the video.
+ $insertRequest = $youtube->videos->insert("status,snippet", $video);
+ // Create a MediaFileUpload object for resumable uploads.
+
+ _error_log("youtubeUpload: videoPath:: ". json_encode($videoPath));
+ _error_log("youtubeUpload: title:: ".$v->getTitle());
+ _error_log("youtubeUpload: videoPath:: {$videoPath}");
+
+ $media = new Google_Http_MediaFileUpload(
+ $client,
+ $insertRequest,
+ 'video/*',
+ null,
+ true,
+ $chunkSizeBytes
+ );
+ $media->setFileSize(filesize($videoPath));
+ // Read the media file and upload it chunk by chunk.
+ $status = false;
+ $handle = fopen($videoPath, "rb");
+ while (!$status && !feof($handle)) {
+ $chunk = fread($handle, $chunkSizeBytes);
+ $status = $media->nextChunk($chunk);
+ }
+ fclose($handle);
+ // If you want to make other calls after the file upload, set setDefer back to false
+ $client->setDefer(false);
+ $obj->success = true;
+ $obj->title = $status['snippet']['title'];
+ $obj->id = $status['id'];
+ $obj->status = $status;
+ $obj->msg = sprintf(__("Your video %s was uploaded to your YouTube Account "), $obj->id, $obj->title);
+ $v->setYoutubeId($obj->id);
+ $v->save();
+ } catch (Google_Service_Exception $e) {
+ $obj->msg = sprintf(__("A service error occurred [1]: %s"), $e->getMessage());
+ } catch (Google_Exception $e) {
+ $obj->msg = sprintf(__("An client error occurred [2]: %s"), $e->getMessage());
+ }
+ $_SESSION[$tokenSessionKey] = $client->getAccessToken();
+ } elseif ($OAUTH2_CLIENT_ID == 'REPLACE_ME') {
+ $obj->msg = "
Client Credentials Required
+
+ You need to set \$OAUTH2_CLIENT_ID and
+ \$OAUTH2_CLIENT_ID before proceeding.
+
";
+ } else {
+ // If the user hasn't authorized the app, initiate the OAuth flow
+ $state = mt_rand();
+ $client->setState($state);
+ $_SESSION['state'] = $state;
+ $authUrl = $client->createAuthUrl();
+ $obj->msg = "
+
\ No newline at end of file
diff --git a/view/channelHead.php b/view/channelHead.php
index 3211d77696..bbc83e6592 100644
--- a/view/channelHead.php
+++ b/view/channelHead.php
@@ -1,32 +1,32 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/view/channelPlaylist.php b/view/channelPlaylist.php
index 73c0c5e1d5..2887203755 100644
--- a/view/channelPlaylist.php
+++ b/view/channelPlaylist.php
@@ -1,91 +1,91 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/view/channelPlaylistItems.php b/view/channelPlaylistItems.php
index 1dccbd4d60..679d4bc705 100644
--- a/view/channelPlaylistItems.php
+++ b/view/channelPlaylistItems.php
@@ -1,601 +1,573 @@
-
-
- " . __('Sorry you do not have anything available') . "
-
-
-
+
+
\ No newline at end of file
diff --git a/view/charts_head.php b/view/charts_head.php
index 861988aff0..46cca7d969 100644
--- a/view/charts_head.php
+++ b/view/charts_head.php
@@ -1,76 +1,76 @@
-getAuthCanViewChart() == 0 && !User::canUpload()) {
- forbiddenPage("Only video uploaders can see charts");
- }
- if ($config->getAuthCanViewChart() == 1) {
- // mode 1 means selected users see admin-charts.
- if (empty($_SESSION['user']['canViewChart'])) {
- forbiddenPage("Admin did not give you right to see the chart");
- }
- }
-}
-
-?>
-
-
-
\ No newline at end of file
diff --git a/view/configurations.php b/view/configurations.php
index 2b4b8480f6..e7e698403e 100644
--- a/view/configurations.php
+++ b/view/configurations.php
@@ -1,40 +1,40 @@
-
-
-
-
- getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
-
-
-
-
-
-
- getAllow_download())) {
- echo getChecked(__("Your Site Configurations is set to NOT Allow Download"), false, $help);
- } else {
- echo getChecked(__("Your Site Configurations is set to Allow Download"), true, $help);
- }
- if (User::isAdmin()) {
- $help = array();
- $help[] = "Plugins menu / CustomizeUser / nonAdminCannotDownload";
- }
- if ($obj->nonAdminCannotDownload) {
- echo getChecked(__("Non admin users can download videos"), true, $help);
- } else {
- echo getChecked(__("Non admin users can NOT download videos"), false, $help);
- }
- }else{
- echo getChecked(__("This site configuration allow download"), true, $help);
-
- if ($obj->nonAdminCannotDownload) {
- $help[] = "Plugins menu / CustomizeUser / nonAdminCannotDownload";
- echo getChecked(__("But only admin can download"), true, $help);
- }
- }
- ?>
-
-
-
-getUsers_id();
- $user = new User($users_id);
- ?>
-
-
- User Download Configuration ()
-
-
-
- getType();
- if(!in_array($type, $canDownload)){
- echo getChecked(__("You cannot download video type")." {$type}", false, $help);
- }
- if (User::isAdmin()) {
- $help = array();
- $help[] = "Plugins menu / CustomizeUser / userCanAllowFilesDownload";
- }else{
- $help = array();
- }
- if (!empty($obj->userCanAllowFilesDownload)) {
- $help[] = "My Videos menu / Allow Download My Videos";
- if (!empty($user->getExternalOption('userCanAllowFilesDownload'))) {
- if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) {
- echo getChecked(__("This user do allow download selected videos"), true, $help);
- } else {
- echo getChecked(__("This user do allow download all his files"), true, $help);
- }
- } else {
- echo getChecked(__("This user do NOT allow download his files"), false, $help);
- }
- } else {
- echo getChecked(__("The download is controlled by the system, there is nothing to check on the user"), true, $help);
- }
- ?>
-
-
-
-
-
-
- Video Download Configuration (getTitle(); ?>)
-
-
-
- getId());
- if ($canDownloadVideoFromVideo) {
- echo getChecked(__("This video can be downloaded"), true);
- } else {
- $category = new Category($video->getCategories_id());
- $help = array();
- $help[] = "Categories menu / Edit a category / Meta Data / Allow Download";
- if (is_object($category) && !$category->getAllow_download()) {
- echo getChecked(__("This category do not allow download"), false, $help);
- } else {
- echo getChecked(__("This category allow download"), true, $help);
- }
- if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) {
- $help = array();
- $help[] = "My Videos menu / Edit a video / Allow Download This media";
- if (empty($video->getCan_download())) {
- echo getChecked(__("User must allow each video individually, but this video is not marked for download"), false, $help);
- } else {
- echo getChecked(__("This video checked for download"), true, $help);
- }
- } else {
- echo getChecked(__("The download permission is site wide, so there is nothing to check on the video"), true);
- }
- }
- ?>
-
+ getAllow_download())) {
+ echo getChecked(__("Your Site Configurations is set to NOT Allow Download"), false, $help);
+ } else {
+ echo getChecked(__("Your Site Configurations is set to Allow Download"), true, $help);
+ }
+ if (User::isAdmin()) {
+ $help = [];
+ $help[] = "Plugins menu / CustomizeUser / nonAdminCannotDownload";
+ }
+ if ($obj->nonAdminCannotDownload) {
+ echo getChecked(__("Non admin users can download videos"), true, $help);
+ } else {
+ echo getChecked(__("Non admin users can NOT download videos"), false, $help);
+ }
+ } else {
+ echo getChecked(__("This site configuration allow download"), true, $help);
+
+ if ($obj->nonAdminCannotDownload) {
+ $help[] = "Plugins menu / CustomizeUser / nonAdminCannotDownload";
+ echo getChecked(__("But only admin can download"), true, $help);
+ }
+ }
+ ?>
+
+
+
+getUsers_id();
+ $user = new User($users_id); ?>
+
+
+ User Download Configuration ()
+
+
+
+ getType();
+ if (!in_array($type, $canDownload)) {
+ echo getChecked(__("You cannot download video type")." {$type}", false, $help);
+ }
+ if (User::isAdmin()) {
+ $help = [];
+ $help[] = "Plugins menu / CustomizeUser / userCanAllowFilesDownload";
+ } else {
+ $help = [];
+ }
+ if (!empty($obj->userCanAllowFilesDownload)) {
+ $help[] = "My Videos menu / Allow Download My Videos";
+ if (!empty($user->getExternalOption('userCanAllowFilesDownload'))) {
+ if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) {
+ echo getChecked(__("This user do allow download selected videos"), true, $help);
+ } else {
+ echo getChecked(__("This user do allow download all his files"), true, $help);
+ }
+ } else {
+ echo getChecked(__("This user do NOT allow download his files"), false, $help);
+ }
+ } else {
+ echo getChecked(__("The download is controlled by the system, there is nothing to check on the user"), true, $help);
+ } ?>
+
+
+
+
+
+
+ Video Download Configuration (getTitle(); ?>)
+
+
+
+ getId());
+ if ($canDownloadVideoFromVideo) {
+ echo getChecked(__("This video can be downloaded"), true);
+ } else {
+ $category = new Category($video->getCategories_id());
+ $help = [];
+ $help[] = "Categories menu / Edit a category / Meta Data / Allow Download";
+ if (is_object($category) && !$category->getAllow_download()) {
+ echo getChecked(__("This category do not allow download"), false, $help);
+ } else {
+ echo getChecked(__("This category allow download"), true, $help);
+ }
+ if (!empty($obj->userCanAllowFilesDownloadSelectPerVideo)) {
+ $help = [];
+ $help[] = "My Videos menu / Edit a video / Allow Download This media";
+ if (empty($video->getCan_download())) {
+ echo getChecked(__("User must allow each video individually, but this video is not marked for download"), false, $help);
+ } else {
+ echo getChecked(__("This video checked for download"), true, $help);
+ }
+ } else {
+ echo getChecked(__("The download permission is site wide, so there is nothing to check on the video"), true);
+ }
+ } ?>
+
+
+
+
+
\ No newline at end of file
diff --git a/view/downloadExternalVideo.php b/view/downloadExternalVideo.php
index 421b043c2b..51c196d4c3 100644
--- a/view/downloadExternalVideo.php
+++ b/view/downloadExternalVideo.php
@@ -1,197 +1,198 @@
-
-
-
-
- getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
-
-
-
-
-
-
-
-
- Here you can direct import multiple videos stored on your hard drive.
- If there is a file (html or htm or txt) we will import it's content as a description, and the first
- characteres will be the file title. (choose 0 to use the file name as the title)
-
+
+ Here you can direct import multiple videos stored on your hard drive.
+ If there is a file (html or htm or txt) we will import it's content as a description, and the first
+ characteres will be the file title. (choose 0 to use the file name as the title)
+
" . PHP_EOL;
- return true;
-}
-
-if (empty($global['logfile'])) {
- die("Log variable does not exists");
-}
-
-if (!file_exists($global['logfile'])) {
- die("you may have problems on the write permission for the log file");
-}
-
-$lines = tail($global['logfile'], 5000, true, true);
-$lines = array_reverse($lines);
-foreach ($lines as $key => $line) {
- if (empty($line[0])) {
- unset($line[$key]);
- } else {
- break;
- }
-}
-$outputText .= $collapsibleOpen;
-foreach ($lines as $line) {
- e($line[0]);
-}
-$outputText .= $collapsibleClose;
-?>
-
-
-
- getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
-
-
-
-
-
-
-
-
-
-
- Log Date log size file
-
-
-
- If you have a problem with your installation, feel free to share this log information on GitHub.
- In this log, we hide all the sensitive information from your log, but it still very helpful for finding issues.
-
-
-
" . PHP_EOL;
+ return true;
+}
+
+if (empty($global['logfile'])) {
+ die("Log variable does not exists");
+}
+
+if (!file_exists($global['logfile'])) {
+ die("you may have problems on the write permission for the log file");
+}
+
+$lines = tail($global['logfile'], 5000, true, true);
+$lines = array_reverse($lines);
+foreach ($lines as $key => $line) {
+ if (empty($line[0])) {
+ unset($line[$key]);
+ } else {
+ break;
+ }
+}
+$outputText .= $collapsibleOpen;
+foreach ($lines as $line) {
+ e($line[0]);
+}
+$outputText .= $collapsibleClose;
+?>
+
+
+
+ getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
+
+
+
+
+
+
+
+
+
+
+ Log Date log size file
+
+
+
+ If you have a problem with your installation, feel free to share this log information on GitHub.
+ In this log, we hide all the sensitive information from your log, but it still very helpful for finding issues.
+
+
+
+
+
+
+
+
+
+ #{$count} - {$value[2]}"; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ #{$count} - {$value[2]}";
+ } ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/view/maintanance.html b/view/maintanance.html
index 0c6ac119d1..9d7742a92c 100644
--- a/view/maintanance.html
+++ b/view/maintanance.html
@@ -1,73 +1,73 @@
-
-
-
- Under Maintanance
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/view/managerVideosLight_meta.php b/view/managerVideosLight_meta.php
index 233ca5a5b5..fc281e56d9 100644
--- a/view/managerVideosLight_meta.php
+++ b/view/managerVideosLight_meta.php
@@ -1,54 +1,54 @@
-
-
+
+
+
+
\ No newline at end of file
diff --git a/view/modeYoutubeBundle.php b/view/modeYoutubeBundle.php
index 5aa61fcf6b..d62ab4af64 100644
--- a/view/modeYoutubeBundle.php
+++ b/view/modeYoutubeBundle.php
@@ -1,105 +1,92 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/view/modeYoutubeTop.php b/view/modeYoutubeTop.php
index 49ff73cda7..ce372ff9d9 100644
--- a/view/modeYoutubeTop.php
+++ b/view/modeYoutubeTop.php
@@ -1,36 +1,36 @@
-
\ No newline at end of file
diff --git a/view/subscribeBtnOffline.html b/view/subscribeBtnOffline.html
index 0dfcdb1b6f..d70105dc7e 100644
--- a/view/subscribeBtnOffline.html
+++ b/view/subscribeBtnOffline.html
@@ -1,10 +1,10 @@
-
-
+
+
\ No newline at end of file
diff --git a/view/theme.css.php b/view/theme.css.php
index 8ed641a17a..4b6ac1c785 100644
--- a/view/theme.css.php
+++ b/view/theme.css.php
@@ -1,18 +1,18 @@
-
-
-
-
- getPageTitleSeparator() . $config->getWebSiteTitle(); ?>
-
-
-
-
-
-
-
-
{html}
\ No newline at end of file
diff --git a/view/videoCreatorSmall.html b/view/videoCreatorSmall.html
index 3c43fb82b4..b64dae35f1 100644
--- a/view/videoCreatorSmall.html
+++ b/view/videoCreatorSmall.html
@@ -1,9 +1,9 @@
-
+
+
+
\ No newline at end of file
diff --git a/view/xsendfile.php b/view/xsendfile.php
index 732712be67..fd37a31101 100644
--- a/view/xsendfile.php
+++ b/view/xsendfile.php
@@ -38,7 +38,7 @@ if ($file == "configuration.php") {
$path = Video::getPathToFile($file);
if (file_exists($path)) {
if (!empty($_GET['download'])) {
- if(!CustomizeUser::canDownloadVideos()){
+ if (!CustomizeUser::canDownloadVideos()) {
_error_log("downloadHLS: CustomizeUser::canDownloadVideos said NO");
forbiddenPage("Can't download this");
}
@@ -62,7 +62,7 @@ if (file_exists($path)) {
if (empty($advancedCustom->doNotUseXsendFile)) {
//_error_log("X-Sendfile: {$path}");
header("X-Sendfile: {$path}");
- }else{
+ } else {
_error_log("Careful, we recommend you to use the X-Sendfile and it is disabled on AdvancedCustom plugin -> doNotUseXsendFile. You may have an error 'Allowed Memory Size Exhausted' if your video file is too big", AVideoLog::$WARNING);
}
} else {