mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Update installation version to 16.0 and enhance videos_statistics table by adding user_agent and app fields with default values. Modify VideoStatistic class to include new properties and methods for user agent and app handling.
This commit is contained in:
parent
1a0db7cd54
commit
fc1cfbd1cb
4 changed files with 49 additions and 6 deletions
|
@ -5,7 +5,7 @@ if (file_exists("../videos/configuration.php")) {
|
|||
}
|
||||
|
||||
|
||||
$installationVersion = "15.1";
|
||||
$installationVersion = "16.0";
|
||||
|
||||
require_once '../objects/functionsSecurity.php';
|
||||
|
||||
|
|
|
@ -369,11 +369,13 @@ CREATE TABLE IF NOT EXISTS `videos_statistics` (
|
|||
`modified` DATETIME NULL DEFAULT NULL,
|
||||
`lastVideoTime` INT(11) NULL DEFAULT NULL,
|
||||
`session_id` VARCHAR(45) NOT NULL,
|
||||
`seconds_watching_video` INT NULL,
|
||||
`json` TEXT NULL,
|
||||
`timezone` VARCHAR(255) NULL,
|
||||
`created_php_time` INT(11) NULL,
|
||||
`seconds_watching_video` INT(11) NULL DEFAULT NULL,
|
||||
`json` TEXT NULL DEFAULT NULL,
|
||||
`timezone` VARCHAR(255) NULL DEFAULT NULL,
|
||||
`created_php_time` INT(11) NULL DEFAULT NULL,
|
||||
`rewarded` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`user_agent` VARCHAR(255) NULL,
|
||||
`app` VARCHAR(45) NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fk_videos_statistics_users1_idx` (`users_id` ASC),
|
||||
INDEX `fk_videos_statistics_videos1_idx` (`videos_id` ASC),
|
||||
|
@ -382,6 +384,8 @@ CREATE TABLE IF NOT EXISTS `videos_statistics` (
|
|||
INDEX `sec_watchin_videos` (`seconds_watching_video` ASC),
|
||||
INDEX `videos_statistics_php_time` (`created_php_time` ASC),
|
||||
INDEX `videos_statistics_rewarded` (`rewarded` ASC),
|
||||
INDEX `video_statistics_ua` (`user_agent` ASC),
|
||||
INDEX `video_statistics_app` (`app` ASC),
|
||||
CONSTRAINT `fk_videos_statistics_users1`
|
||||
FOREIGN KEY (`users_id`)
|
||||
REFERENCES `users` (`id`)
|
||||
|
@ -392,7 +396,9 @@ CREATE TABLE IF NOT EXISTS `videos_statistics` (
|
|||
REFERENCES `videos` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE CASCADE)
|
||||
ENGINE = InnoDB;
|
||||
ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 199
|
||||
DEFAULT CHARACTER SET = latin1;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
|
|
|
@ -24,6 +24,29 @@ class VideoStatistic extends ObjectYPT
|
|||
protected $json;
|
||||
protected $rewarded;
|
||||
protected $created_php_time;
|
||||
protected $user_agent;
|
||||
protected $app;
|
||||
|
||||
public function getUser_agent()
|
||||
{
|
||||
return $this->user_agent;
|
||||
}
|
||||
|
||||
public function setUser_agent($user_agent)
|
||||
{
|
||||
$this->user_agent = $user_agent;
|
||||
}
|
||||
|
||||
public function getApp()
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
public function setApp($app)
|
||||
{
|
||||
$app = preg_replace('/[^a-zA-Z0-9]/', '', $app);
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public static function getSearchFieldsNames()
|
||||
{
|
||||
|
@ -115,6 +138,8 @@ class VideoStatistic extends ObjectYPT
|
|||
$vs->setUsers_id($users_id);
|
||||
$vs->setVideos_id($videos_id);
|
||||
$vs->setWhen(date("Y-m-d h:i:s"));
|
||||
$vs->setUser_agent($_SERVER['HTTP_USER_AGENT']);
|
||||
$vs->setApp(@$_REQUEST['platform']);
|
||||
} else {
|
||||
//error_log("updateStatistic: videos_id=$videos_id lastVideoTime=$lastVideoTime, seconds_watching_video=$seconds_watching_video line=" . __LINE__);
|
||||
$vs = new VideoStatistic($lastStatistic['id']);
|
||||
|
|
12
updatedb/updateDb.v16.0.sql
Normal file
12
updatedb/updateDb.v16.0.sql
Normal file
|
@ -0,0 +1,12 @@
|
|||
ALTER TABLE `videos_statistics`
|
||||
ADD COLUMN `rewarded` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
|
||||
ADD INDEX `videos_statistics_rewarded` (`rewarded` ASC);
|
||||
UPDATE configurations SET version = '12.7', modified = now() WHERE id = 1;
|
||||
|
||||
|
||||
ALTER TABLE `videos_statistics`
|
||||
ADD COLUMN `user_agent` VARCHAR(255) NULL,
|
||||
ADD COLUMN `app` VARCHAR(45) NULL,
|
||||
ADD INDEX `video_statistics_ua` (`user_agent` ASC),
|
||||
ADD INDEX `video_statistics_app` (`app` ASC);
|
||||
UPDATE configurations SET version = '16.0', modified = now() WHERE id = 1;
|
Loading…
Add table
Add a link
Reference in a new issue