From 78f76feaf0c662d79450afa526bdb9c248313ecf Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Tue, 18 Jul 2023 12:08:10 -0300 Subject: [PATCH] update --- objects/functions.php | 2 +- plugin/MonetizeUsers/MonetizeUsers.php | 15 ++++++++++++++- .../Objects/Monetize_user_reward_log.php | 5 +++-- plugin/MonetizeUsers/install/install.sql | 2 ++ plugin/MonetizeUsers/install/updateV2.0.sql | 3 +++ plugin/PlayerSkins/PlayerSkins.php | 7 ++++++- 6 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 plugin/MonetizeUsers/install/updateV2.0.sql diff --git a/objects/functions.php b/objects/functions.php index 480b21e1e7..5c322e2188 100644 --- a/objects/functions.php +++ b/objects/functions.php @@ -5521,7 +5521,7 @@ function isHLS() { global $video, $global; if (isLive()) { return true; - } elseif (!empty($video) && $video['type'] == 'video' && file_exists(Video::getPathToFile("{$video['filename']}/index.m3u8"))) { + } elseif (!empty($video) && is_array($video) && $video['type'] == 'video' && file_exists(Video::getPathToFile("{$video['filename']}/index.m3u8"))) { return true; } return false; diff --git a/plugin/MonetizeUsers/MonetizeUsers.php b/plugin/MonetizeUsers/MonetizeUsers.php index 3c43911af4..bcc5f10a39 100644 --- a/plugin/MonetizeUsers/MonetizeUsers.php +++ b/plugin/MonetizeUsers/MonetizeUsers.php @@ -28,7 +28,7 @@ class MonetizeUsers extends PluginAbstract { } public function getPluginVersion() { - return "1.0"; + return "2.0"; } public function getEmptyDataObject() { @@ -86,6 +86,7 @@ class MonetizeUsers extends PluginAbstract { $percentage_watched = $obj->rewardMinimumViewPercentage->value; $now = date('Y-m-d H:i:s'); $when_from = date('Y-m-d H:i:s', Monetize_user_reward_log::getLastRewardTime()); + _error_log("MonetizeUsers getLastRewardTime {$when_from}"); //$when_from = date('Y-m-d H:i:s', strtotime('-1 year')); $only_logged_users = $obj->rewardOnlyLoggedUsersView; $users_id = 0; @@ -219,4 +220,16 @@ class MonetizeUsers extends PluginAbstract { return $fullData; } + public function updateScript() { + global $global; + + if (AVideoPlugin::compareVersion($this->getName(), "2.0") < 0) { + $sqls = file_get_contents($global['systemRootPath'] . 'plugin/MonetizeUsers/install/updateV2.0.sql'); + $sqlParts = explode(";", $sqls); + foreach ($sqlParts as $value) { + sqlDal::writeSql(trim($value)); + } + } + return true; + } } diff --git a/plugin/MonetizeUsers/Objects/Monetize_user_reward_log.php b/plugin/MonetizeUsers/Objects/Monetize_user_reward_log.php index d0ffc15d11..eba4652cb2 100644 --- a/plugin/MonetizeUsers/Objects/Monetize_user_reward_log.php +++ b/plugin/MonetizeUsers/Objects/Monetize_user_reward_log.php @@ -81,12 +81,13 @@ class Monetize_user_reward_log extends ObjectYPT { static function getLastRewardTime(){ global $global; - $sql = "SELECT MAX(created) as created FROM monetize_user_reward_log"; + $sql = "SELECT MAX(created_php_time) as created_php_time FROM monetize_user_reward_log"; $res = sqlDAL::readSql($sql, '', [], true); $data = sqlDAL::fetchAssoc($res); sqlDAL::close($res); if ($res && !empty($data['created'])) { - return strtotime($data['created']); + _error_log("MonetizeUsers getLastRewardTime {$when_from}"); + return $data['created_php_time']; } else { return strtotime('-24 hours'); } diff --git a/plugin/MonetizeUsers/install/install.sql b/plugin/MonetizeUsers/install/install.sql index 4d48913f7b..c3ea58d11f 100644 --- a/plugin/MonetizeUsers/install/install.sql +++ b/plugin/MonetizeUsers/install/install.sql @@ -10,10 +10,12 @@ CREATE TABLE IF NOT EXISTS `monetize_user_reward_log` ( `created` DATETIME NULL, `modified` DATETIME NULL, `timezone` VARCHAR(255) NULL, + `created_php_time` INT(11) NULL, PRIMARY KEY (`id`), INDEX `fk_monetize_user_reward_log_videos1_idx` (`videos_id` ASC) , INDEX `monetize_user_reward_log_idx1` (`video_owner_users_id` ASC) , INDEX `monetize_user_reward_log_idx2` (`when_watched` ASC) , + INDEX `monetize_user_reward_log_created_php_time` (`created_php_time` ASC), CONSTRAINT `fk_monetize_user_reward_log_videos1` FOREIGN KEY (`videos_id`) REFERENCES `videos` (`id`) diff --git a/plugin/MonetizeUsers/install/updateV2.0.sql b/plugin/MonetizeUsers/install/updateV2.0.sql new file mode 100644 index 0000000000..65321d91f1 --- /dev/null +++ b/plugin/MonetizeUsers/install/updateV2.0.sql @@ -0,0 +1,3 @@ +ALTER TABLE `monetize_user_reward_log` +ADD COLUMN `created_php_time` INT(11) NULL, +ADD INDEX `monetize_user_reward_log_created_php_time` (`created_php_time` ASC); \ No newline at end of file diff --git a/plugin/PlayerSkins/PlayerSkins.php b/plugin/PlayerSkins/PlayerSkins.php index 4ff0e5e983..e04eef11c1 100644 --- a/plugin/PlayerSkins/PlayerSkins.php +++ b/plugin/PlayerSkins/PlayerSkins.php @@ -308,7 +308,12 @@ class PlayerSkins extends PluginAbstract { global $global, $config, $getStartPlayerJSWasRequested, $video, $url, $title; $js = ""; $obj = $this->getDataObject(); - if (!empty($_GET['videoName']) || !empty($_GET['u']) || !empty($_GET['evideo']) || !empty($_GET['playlists_id']) || !empty($video['id'])) { + if ( + !empty($_GET['videoName']) || + !empty($_GET['u']) || + !empty($_GET['evideo']) || + !empty($_GET['playlists_id']) || + (is_array($video) && !empty($video['id']))) { if (empty($obj->showLoopButton) && empty($obj->contextMenuLoop)) { $js .= ""; }