1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 10:49:36 +02:00
This commit is contained in:
Daniel Neto 2023-03-28 13:08:27 -03:00
parent 8483867cb1
commit 49f5694d2c
2 changed files with 22 additions and 3 deletions

View file

@ -2892,6 +2892,17 @@ function try_get_contents_from_local($url) {
return false; return false;
} }
function url_get_contents_with_cache($url, $lifeTime = 60, $ctx = "", $timeout = 0, $debug = false, $mantainSession = false) {
$cache = ObjectYPT::getCache($url, $lifeTime); // 24 hours
if(!empty($cache)){
return $cache;
}
$return = url_get_contents($url, $ctx, $timeout, $debug, $mantainSession);
ObjectYPT::setCache($url, $return);
return $return;
}
function url_get_contents($url, $ctx = "", $timeout = 0, $debug = false, $mantainSession = false) { function url_get_contents($url, $ctx = "", $timeout = 0, $debug = false, $mantainSession = false) {
global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort; global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort;
if (!isValidURLOrPath($url)) { if (!isValidURLOrPath($url)) {

View file

@ -2210,14 +2210,22 @@ class SectionFirstPage
//$endpointURL = addQueryStringParameter($endpointURL, 'PHPSESSID', session_id()); //$endpointURL = addQueryStringParameter($endpointURL, 'PHPSESSID', session_id());
} }
$response = json_decode(url_get_contents($endpointURL, '', 2, false, true));
$endPointResponse = url_get_contents_with_cache($endpointURL, 300, '', 5, false, true);
$response = json_decode($endPointResponse);
/* /*
if(User::isLogged()){ if(User::isLogged()){
session_id($response->session_id); session_id($response->session_id);
} }
*/ */
$this->endpointResponse = $response->response; if(!empty($response)){
$this->totalRows = $this->endpointResponse->totalRows; $this->endpointResponse = $response->response;
$this->totalRows = $this->endpointResponse->totalRows;
}else{
$this->endpointResponse = new stdClass();
$this->totalRows = 0;
}
$this->childs = $childs; $this->childs = $childs;
} }
} }