diff --git a/install/checkConfiguration.php b/install/checkConfiguration.php index 384ce2f46c..d8e2fd892e 100644 --- a/install/checkConfiguration.php +++ b/install/checkConfiguration.php @@ -5,7 +5,7 @@ if (file_exists("../videos/configuration.php")) { } -$installationVersion = "14.1"; +$installationVersion = "14.2"; require_once '../objects/functionSecurity.php'; diff --git a/install/database.sql b/install/database.sql index 5120d1028d..b2b0bc6860 100644 --- a/install/database.sql +++ b/install/database.sql @@ -41,6 +41,7 @@ CREATE TABLE IF NOT EXISTS `users` ( `extra_info` TEXT NULL DEFAULT NULL, `phone` VARCHAR(255) NULL DEFAULT NULL, `is_company` TINYINT(4) NULL DEFAULT NULL, + `birth_date` DATE NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE INDEX `user_UNIQUE` (`user` ASC)) ENGINE = InnoDB; diff --git a/objects/login.json.php b/objects/login.json.php index b6dbd534df..5c90d14c1d 100644 --- a/objects/login.json.php +++ b/objects/login.json.php @@ -250,6 +250,7 @@ $object->canStream = User::canStream(); $object->redirectUri = @$_POST['redirectUri']; $object->embedChatUrl = ''; $object->embedChatUrlMobile = ''; +$object->age = User::getAge(); //_error_log("login.json.php check chat2"); if (AVideoPlugin::isEnabledByName('Chat2') && method_exists('Chat2', 'getChatRoomLink')) { diff --git a/objects/user.php b/objects/user.php index 989e0df017..a161bc4bc3 100644 --- a/objects/user.php +++ b/objects/user.php @@ -58,6 +58,7 @@ class User private $extra_info; private $phone; private $is_company; + private $birth_date; public static $DOCUMENT_IMAGE_TYPE = "Document Image"; public static $channel_artTV = 'tv'; public static $channel_artDesktopMax = 'desktop_max'; @@ -123,6 +124,17 @@ class User $this->phone = $phone; } + function getBirth_date() + { + return $this->birth_date; + } + + function setBirth_date($birth_date): void + { + $time = strtotime($birth_date); + $this->birth_date = date('Y/m/d', $time); + } + public function getEmail() { return $this->email; @@ -629,7 +641,7 @@ if (typeof gtag !== \"function\") { global $global; $photo = self::_getPhoto($users_id); if ($photo == ImagesPlaceHolders::getUserIcon()) { - return $global['systemRootPath'].($photo); + return $global['systemRootPath'] . ($photo); } if (empty($photo)) { return false; @@ -727,7 +739,7 @@ if (typeof gtag !== \"function\") { //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 to register '.json_encode(debug_backtrace())); + _error_log('Error : 1 You need a user to register ' . json_encode(debug_backtrace())); return false; } if (empty($this->password)) { @@ -799,6 +811,11 @@ if (typeof gtag !== \"function\") { $values[] = $this->canViewChart; $sql .= "canViewChart = ?, "; } + if (!empty($this->birth_date)) { + $formats .= "s"; + $values[] = $this->birth_date; + $sql .= "birth_date = ?, "; + } $formats .= "ssssssisssssssssssi"; $values[] = $this->status; $values[] = $this->photoURL; @@ -1050,7 +1067,7 @@ if (typeof gtag !== \"function\") { WHERE users_id = ? )"; sqlDAL::writeSql($sql, "i", [$this->id]); - + $arrayTables = [ //'live_transmition_history_log', 'live_transmitions', @@ -1075,7 +1092,7 @@ if (typeof gtag !== \"function\") { _error_log("Delete usertable not found {$value}"); $tableExists = false; } - + if ($tableExists) { $sql = "DELETE FROM {$value} WHERE users_id = ?"; try { @@ -1109,7 +1126,7 @@ if (typeof gtag !== \"function\") { return self::USER_LOGGED; } global $global, $advancedCustom, $advancedCustomUser, $config; - if(class_exists('AVideoPlugin')){ + if (class_exists('AVideoPlugin')) { if (empty($advancedCustomUser)) { $advancedCustomUser = AVideoPlugin::getObjectData("CustomizeUser"); } @@ -1340,6 +1357,39 @@ if (typeof gtag !== \"function\") { return !empty($_SESSION['user']['isAdmin']); } + public static function getBirthIfIsSet($users_id = 0) + { + $birth_date = ''; + if (!empty($users_id)) { + $user = new User($users_id); + $birth_date = $user->getBirth_date(); + } else { + self::recreateLoginFromCookie(); + $birth_date = $_SESSION['user']['birth_date']; + } + return $birth_date; + } + + public static function getAge($users_id = 0) + { + $birth_date = self::getBirthIfIsSet($users_id); + if (empty($birth_date)) { + return 0; + } + $birth_date = new DateTime($birth_date); + $current_date = new DateTime('now'); + $age = $current_date->diff($birth_date)->y; + if($age<0){ + return 0; + } + return $age; + } + + public static function isOver18($users_id = 0): bool + { + return self::getAge($users_id) > 18; + } + public static function isACompany($users_id = 0) { global $_is_a_company; @@ -1977,12 +2027,12 @@ if (typeof gtag !== \"function\") { //current=1&rowCount=10&sort[sender]=asc&searchPhrase= global $global; $sql = "SELECT * "; - - if(!empty($_REQUEST['getUsage'])){ - $sql .=", (SELECT sum(filesize) as total FROM videos WHERE filesize > 0 AND (users_id = u.id)) as usageInBytes"; + + if (!empty($_REQUEST['getUsage'])) { + $sql .= ", (SELECT sum(filesize) as total FROM videos WHERE filesize > 0 AND (users_id = u.id)) as usageInBytes"; } - $sql .=" FROM users u WHERE 1=1 "; + $sql .= " FROM users u WHERE 1=1 "; if (!empty($status)) { if (strtolower($status) === 'i') { $sql .= " AND status = 'i' "; @@ -2303,17 +2353,17 @@ if (typeof gtag !== \"function\") { global $global, $config, $advancedCustomUser; $reason = []; if (empty($doNotCheckPlugins) && !AVideoPlugin::userCanUpload(User::getId())) { - $reason[] = 'A plugin said users_id=['.User::getId().'] cannot upload'; + $reason[] = 'A plugin said users_id=[' . User::getId() . '] cannot upload'; } if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && !User::isVerified())) { $reason[] = 'The email is not verified'; } - if ($config->getAuthCanUploadVideos() && !self::isLogged()) { + if ($config->getAuthCanUploadVideos() && !self::isLogged()) { $reason[] = 'The user is not logged'; } - if (self::isLogged() && !empty($_SESSION['user']['canUpload'])) { + if (self::isLogged() && !empty($_SESSION['user']['canUpload'])) { $reason[] = 'You do not have upload rights'; } return $reason; @@ -2677,7 +2727,7 @@ if (typeof gtag !== \"function\") { $msg .= "

" . __($advancedCustomUser->verificationMailTextLine4); $msg .= "

" . " " . __("Verify") . ""; - $resp = sendSiteEmail($user->getEmail(), __('Please Verify Your E-mail '). ' ' . $webSiteTitle, $msg); + $resp = sendSiteEmail($user->getEmail(), __('Please Verify Your E-mail ') . ' ' . $webSiteTitle, $msg); if (!$resp) { _error_log("sendVerificationLink Error Info: {$mail->ErrorInfo}"); diff --git a/objects/userAddNew.json.php b/objects/userAddNew.json.php index 6a9901e94d..e47c19a8a0 100644 --- a/objects/userAddNew.json.php +++ b/objects/userAddNew.json.php @@ -51,6 +51,7 @@ $user->setStatus($_POST['status']); $user->setEmailVerified($_POST['isEmailVerified']); $user->setAnalyticsCode($_POST['analyticsCode']); $user->setPhone($_POST['phone']); +$user->setBirth_date($_POST['birth']); _error_log("userAddNew.json.php: set channel name = ({$_POST['channelName']})"); diff --git a/objects/userUpdate.json.php b/objects/userUpdate.json.php index 4d8028e320..c17e59cd09 100644 --- a/objects/userUpdate.json.php +++ b/objects/userUpdate.json.php @@ -29,6 +29,7 @@ $user->setAbout($_POST['about']); $user->setAnalyticsCode($_POST['analyticsCode']); $user->setDonationLink($_POST['donationLink']); $user->setPhone($_POST['phone']); +$user->setBirth_date($_POST['birth_date']); $unique = $user->setChannelName($_POST['channelName']); if (!$unique) { $obj->msg = __("Channel name already exists"); diff --git a/objects/video.php b/objects/video.php index 9b4e723987..056378badf 100644 --- a/objects/video.php +++ b/objects/video.php @@ -1841,7 +1841,6 @@ if (!class_exists('Video')) { _error_log("Video::updateLikesDislikes: id={$row['id']}"); $row['dislikes'] = self::updateLikesDislikes($row['id'], 'dislikes'); } - if (empty($row['duration_in_seconds']) && in_array($row['type'], $allowedDurationTypes)) { _error_log("Video::duration_in_seconds: id={$row['id']} {$row['duration']} {$row['type']}"); $row['duration_in_seconds'] = self::updateDurationInSeconds($row['id'], $row['duration']); @@ -1996,6 +1995,7 @@ if (!class_exists('Video')) { $row['views_count_short'] = number_format_short($row['views_count']); TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit); $row['identification'] = User::getNameIdentificationById(!empty($row['users_id_company']) ? $row['users_id_company'] : $row['users_id']); + $row['age'] = User::getAge($row['users_id']); if (empty($row['externalOptions'])) { $row['externalOptions'] = json_encode(['videoStartSeconds' => '00:00:00']); diff --git a/plugin/CustomizeAdvanced/confirmRating.php b/plugin/CustomizeAdvanced/confirmRating.php index a2e38be11f..149e2d0e1d 100644 --- a/plugin/CustomizeAdvanced/confirmRating.php +++ b/plugin/CustomizeAdvanced/confirmRating.php @@ -1,6 +1,6 @@ poster; @@ -11,82 +11,108 @@ $imgw = 1280; $imgh = 720; $metaDescription = $title = getSEOTitle($video['title']); $ogURL = Video::getLinkToVideo($video['id'], $video['clean_title'], false, false); + +$_page = new Page(array('Confirm Rating')); ?> - - - - <?php echo __("Confirm Rating") . $config->getPageTitleSeparator() . $title; ?> - - - - - -
- - -