Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Aug 16, 2023
1 parent c7c1252 commit 00f383e
Show file tree
Hide file tree
Showing 16 changed files with 535 additions and 158 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ test.php
/plugin/PedagoFlix/
/plugin/YPTWebRTC/
plugin/CustomizeUser/getMyAccount.php
*.rnd
*.rnd
/plugin/Gift/
1 change: 1 addition & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Options All -Indexes
RewriteEngine on
#VideoHLS for DRM

RewriteRule ^buy/? plugin/Layout/buy.php [NC,L,QSA]
RewriteRule ^id/? view/id.php [NC,L,QSA]
RewriteRule ^logo.png view/logo.png.php [NC,L,QSA]

Expand Down
39 changes: 39 additions & 0 deletions locale/function.js.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

if (empty($_GET['lang'])) {
return '';
}

$lang = preg_replace('/[^a-z0-9_]/i', '', $_GET['lang']);

$langFile = "./{$lang}.php";
if(!file_exists($langFile)){
return '';
}

include_once $langFile;
header('Content-Type: application/javascript');
?>
var translations = <?php echo json_encode($t); ?>;

function __(str, allowHTML = false) {
let returnStr = str;

// Check if translation exists for exact string
if (translations.hasOwnProperty(str)) {
returnStr = translations[str];
} else {
// Case insensitive check
let lowerCaseKey = Object.keys(translations).find(key => key.toLowerCase() === str.toLowerCase());
if (lowerCaseKey) {
returnStr = translations[lowerCaseKey];
}
}

if (allowHTML) {
return returnStr;
}

// Escape certain characters for security
return returnStr.replace(/'/g, "&apos;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
74 changes: 37 additions & 37 deletions objects/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4461,42 +4461,42 @@ function getLdJson($videos_id)
if ($duration == "PT0H0M0S") {
$duration = "PT0H0M1S";
}
$output = '
<script type="application/ld+json" id="application_ld_json">
{
"@context": "http://schema.org/",
"@type": "VideoObject",
"name": "' . getSEOTitle($video['title']) . '",
"description": "' . $description . '",
"thumbnailUrl": [
"' . $img . '"
],
"uploadDate": "' . date("Y-m-d\Th:i:s", strtotime($video['created'])) . '",
"duration": "' . $duration . '",
"contentUrl": "' . Video::getLinkToVideo($videos_id, '', false, false) . '",
"embedUrl": "' . Video::getLinkToVideo($videos_id, '', true, false) . '",
"interactionCount": "' . $video['views_count'] . '",
"@id": "' . Video::getPermaLink($videos_id) . '",
"datePublished": "' . date("Y-m-d", strtotime($video['created'])) . '",
"interactionStatistic": [
{
"@type": "InteractionCounter",
"interactionService": {
"@type": "WebSite",
"name": "' . str_replace('"', '', $config->getWebSiteTitle()) . '",
"@id": "' . $global['webSiteRootURL'] . '"
},
"interactionType": "http://schema.org/LikeAction",
"userInteractionCount": "' . $video['views_count'] . '"
},
{
"@type": "InteractionCounter",
"interactionType": "http://schema.org/WatchAction",
"userInteractionCount": "' . $video['views_count'] . '"
}
]
}
</script>';
$data = array(
"@context" => "http://schema.org/",
"@type" => "VideoObject",
"name" => getSEOTitle($video['title']),
"description" => $description,
"thumbnailUrl" => array($img),
"uploadDate" => date("Y-m-d\Th:i:s", strtotime($video['created'])),
"duration" => $duration,
"contentUrl" => Video::getLinkToVideo($videos_id, '', false, false),
"embedUrl" => Video::getLinkToVideo($videos_id, '', true, false),
"interactionCount" => $video['views_count'],
"@id" => Video::getPermaLink($videos_id),
"datePublished" => date("Y-m-d", strtotime($video['created'])),
"interactionStatistic" => array(
array(
"@type" => "InteractionCounter",
"interactionService" => array(
"@type" => "WebSite",
"name" => str_replace('"', '', $config->getWebSiteTitle()),
"@id" => $global['webSiteRootURL']
),
"interactionType" => "http://schema.org/LikeAction",
"userInteractionCount" => $video['views_count']
),
array(
"@type" => "InteractionCounter",
"interactionType" => "http://schema.org/WatchAction",
"userInteractionCount" => $video['views_count']
)
)
);

$output = '<script type="application/ld+json" id="application_ld_json">';
$output .= json_encode($data, JSON_UNESCAPED_SLASHES);
$output .= '</script>';

ObjectYPT::setCacheGlobal("getLdJson{$videos_id}", $output);
echo $output;
}
Expand Down Expand Up @@ -10847,7 +10847,7 @@ function getMP3ANDMP4DownloadLinksFromHLS($videos_id, $video_type)
if (!empty($videoHLSObj) && method_exists('VideoHLS', 'getMP3ANDMP4DownloadLinks')) {
$downloadOptions = VideoHLS::getMP3ANDMP4DownloadLinks($videos_id);
} else {
_error_log("getMP3ANDMP4DownloadLinksFromHLS($videos_id, $video_type): invalid plugin");
//_error_log("getMP3ANDMP4DownloadLinksFromHLS($videos_id, $video_type): invalid plugin");
}
} else {
_error_log("getMP3ANDMP4DownloadLinksFromHLS($videos_id, $video_type): invalid vidreo type");
Expand Down
6 changes: 2 additions & 4 deletions objects/video.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ public function save($updateVideoGroups = false, $allowOfflineUser = false)
if (empty($this->duration_in_seconds)) {
$this->duration_in_seconds = durationToSeconds($this->duration);
}

//var_dump($this->clean_title);exit;
if (!empty($this->id)) {
if (!$this->userCanManageVideo() && !$allowOfflineUser && !Permissions::canModerateVideos()) {
forbiddenPage('Permission denied');
Expand Down Expand Up @@ -1428,7 +1428,6 @@ public static function getRelatedMovies($videos_id, $limit = 10)
$sql .= AVideoPlugin::getVideoWhereClause();

$sql .= "ORDER BY RAND() LIMIT {$limit}";

$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);

Expand Down Expand Up @@ -2881,7 +2880,6 @@ private static function rrmdir($dir)
public function setDescription($description)
{
global $global, $advancedCustom;

if (empty($advancedCustom)) {
$advancedCustom = AVideoPlugin::getDataObject('CustomizeAdvanced');
}
Expand Down Expand Up @@ -5185,7 +5183,7 @@ public static function get_clean_title($videos_id)
sqlDAL::close($res);

if ($res !== false) {
if ($videoRow !== false) {
if (is_array($videoRow)) {
return $videoRow['clean_title'];
}
} else {
Expand Down
1 change: 1 addition & 0 deletions objects/videoAddNew.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
$obj->setCreated($_REQUEST['created']);
}
}

TimeLogEnd(__FILE__, __LINE__);
$resp = $obj->save(true);
// if is a new embed video
Expand Down
1 change: 0 additions & 1 deletion objects/video_statistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ public static function deleteOldStatistics($days) {
//_error_log("Delete Query: ".$sql);
return sqlDAL::writeSql($sql, "i", [$days]);
}
_error_log("Id for table " . static::getTableName() . " not defined for deletion", AVideoLog::$ERROR);
return false;
}

Expand Down
19 changes: 19 additions & 0 deletions plugin/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,25 @@ public static function deleteFirstPageCache() {
return CachesInDB::_deleteCacheStartingWith('firstPage');
}

public static function deleteOldCache($days, $limit = 5000) {
global $global;
$days = intval($days);
if (!empty($days)) {
$sql = "DELETE FROM CachesInDB ";
$sql .= " WHERE created < DATE_SUB(NOW(), INTERVAL ? DAY) ";
$sql .= " LIMIT $limit";
$global['lastQuery'] = $sql;

return sqlDAL::writeSql($sql, "i", [$days]);
}
return false;
}
function executeEveryMinute() {
global $global;
$global['systemRootPath'] . 'plugin/Cache/deleteStatistics.json.php';
self::deleteOldCache(1);
}

}

function sanitize_output($buffer) {
Expand Down
Loading

0 comments on commit 00f383e

Please sign in to comment.