mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-02-03 10:35:32 +00:00
switch remote file_get_contents to curl
This commit is contained in:
parent
034a8c540a
commit
d2cad4833e
@ -52,10 +52,19 @@ try
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manifest
|
// Get node manifest
|
||||||
if ($manifest = @json_decode(@file_get_contents($node->manifest)))
|
$curl = new Curl($node->manifest, API_USER_AGENT);
|
||||||
|
|
||||||
|
if (200 != $curl->getCode())
|
||||||
{
|
{
|
||||||
// Feed channel exists
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$manifest = $curl->getResponse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($manifest->export))
|
if (empty($manifest->export))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -64,7 +73,20 @@ try
|
|||||||
// Users
|
// Users
|
||||||
if (API_IMPORT_USERS_ENABLED)
|
if (API_IMPORT_USERS_ENABLED)
|
||||||
{
|
{
|
||||||
if (empty($manifest->export->users))
|
if (Valid::url($manifest->export->users))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call feed
|
||||||
|
$curl = new Curl($manifest->export->users, API_USER_AGENT);
|
||||||
|
|
||||||
|
if (200 != $curl->getCode())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$remoteUsers = $curl->getResponse())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -72,7 +94,7 @@ try
|
|||||||
// Init alias registry for this host
|
// Init alias registry for this host
|
||||||
$aliasUserId = [];
|
$aliasUserId = [];
|
||||||
|
|
||||||
foreach (@json_decode(@file_get_contents($manifest->export->users)) as $remoteUser)
|
foreach ((object) $remoteUsers as $remoteUser)
|
||||||
{
|
{
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if (!Valid::user($remoteUser))
|
if (!Valid::user($remoteUser))
|
||||||
@ -95,9 +117,6 @@ try
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remember user ID for this host
|
|
||||||
$aliasUserId[$remoteUser->userId] = $localUser->userId;
|
|
||||||
|
|
||||||
// Update time added if newer
|
// Update time added if newer
|
||||||
if ($localUser->timeAdded < $remoteUser->timeAdded)
|
if ($localUser->timeAdded < $remoteUser->timeAdded)
|
||||||
{
|
{
|
||||||
@ -136,12 +155,28 @@ try
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register userId alias
|
||||||
|
$aliasUserId[$remoteUser->userId] = $localUser->userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Magnets
|
// Magnets
|
||||||
if (API_IMPORT_MAGNETS_ENABLED)
|
if (API_IMPORT_MAGNETS_ENABLED)
|
||||||
{
|
{
|
||||||
if (empty($manifest->export->magnets))
|
if (Valid::url($manifest->export->magnets))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call feed
|
||||||
|
$curl = new Curl($manifest->export->magnets, API_USER_AGENT);
|
||||||
|
|
||||||
|
if (200 != $curl->getCode())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$remoteMagnets = $curl->getResponse())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -149,7 +184,7 @@ try
|
|||||||
// Init alias registry for this host
|
// Init alias registry for this host
|
||||||
$aliasMagnetId = [];
|
$aliasMagnetId = [];
|
||||||
|
|
||||||
foreach (@json_decode(@file_get_contents($manifest->export->magnets)) as $remoteMagnet)
|
foreach ((object) $remoteMagnets as $remoteMagnet)
|
||||||
{
|
{
|
||||||
// Validate required fields by protocol
|
// Validate required fields by protocol
|
||||||
if (!Valid::magnet($remoteMagnet))
|
if (!Valid::magnet($remoteMagnet))
|
||||||
@ -187,9 +222,6 @@ try
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add magnet alias for this host
|
|
||||||
$aliasMagnetId[$remoteMagnet->magnetId] = $localMagnet->magnetId;
|
|
||||||
|
|
||||||
// Update time added if newer
|
// Update time added if newer
|
||||||
if ($localMagnet->timeAdded < $remoteMagnet->timeAdded)
|
if ($localMagnet->timeAdded < $remoteMagnet->timeAdded)
|
||||||
{
|
{
|
||||||
@ -334,17 +366,33 @@ try
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add magnet alias for this host
|
||||||
|
$aliasMagnetId[$remoteMagnet->magnetId] = $localMagnet->magnetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Magnet comments
|
// Magnet comments
|
||||||
if (API_IMPORT_MAGNET_COMMENTS_ENABLED)
|
if (API_IMPORT_MAGNET_COMMENTS_ENABLED)
|
||||||
{
|
{
|
||||||
if (empty($manifest->export->magnetComments))
|
if (Valid::url($manifest->export->magnetComments))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetComments)) as $remoteMagnetComment)
|
// Call feed
|
||||||
|
$curl = new Curl($manifest->export->magnetComments, API_USER_AGENT);
|
||||||
|
|
||||||
|
if (200 != $curl->getCode())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$remoteMagnetComments = $curl->getResponse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((object) $remoteMagnetComments as $remoteMagnetComment)
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!Valid::magnetComment($remoteMagnetComment))
|
if (!Valid::magnetComment($remoteMagnetComment))
|
||||||
@ -396,12 +444,25 @@ try
|
|||||||
// Magnet downloads
|
// Magnet downloads
|
||||||
if (API_IMPORT_MAGNET_DOWNLOADS_ENABLED)
|
if (API_IMPORT_MAGNET_DOWNLOADS_ENABLED)
|
||||||
{
|
{
|
||||||
if (empty($manifest->export->magnetDownloads))
|
if (Valid::url($manifest->export->magnetDownloads))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetDownloads)) as $remoteMagnetDownload)
|
// Call feed
|
||||||
|
$curl = new Curl($manifest->export->magnetDownloads, API_USER_AGENT);
|
||||||
|
|
||||||
|
if (200 != $curl->getCode())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$remoteMagnetDownloads = $curl->getResponse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((object) $remoteMagnetDownloads as $remoteMagnetDownload)
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!Valid::magnetDownload($remoteMagnetDownload))
|
if (!Valid::magnetDownload($remoteMagnetDownload))
|
||||||
@ -432,12 +493,25 @@ try
|
|||||||
// Magnet views
|
// Magnet views
|
||||||
if (API_IMPORT_MAGNET_VIEWS_ENABLED)
|
if (API_IMPORT_MAGNET_VIEWS_ENABLED)
|
||||||
{
|
{
|
||||||
if (empty($manifest->export->magnetViews))
|
if (Valid::url($manifest->export->magnetViews))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetViews)) as $remoteMagnetView)
|
// Call feed
|
||||||
|
$curl = new Curl($manifest->export->magnetViews, API_USER_AGENT);
|
||||||
|
|
||||||
|
if (200 != $curl->getCode())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$remoteMagnetViews = $curl->getResponse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((object) $remoteMagnetViews as $remoteMagnetView)
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!Valid::magnetView($remoteMagnetView))
|
if (!Valid::magnetView($remoteMagnetView))
|
||||||
@ -468,12 +542,25 @@ try
|
|||||||
// Magnet stars
|
// Magnet stars
|
||||||
if (API_IMPORT_MAGNET_STARS_ENABLED)
|
if (API_IMPORT_MAGNET_STARS_ENABLED)
|
||||||
{
|
{
|
||||||
if (empty($manifest->export->magnetStars))
|
if (Valid::url($manifest->export->magnetStars))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (@json_decode(@file_get_contents($manifest->export->magnetStars)) as $remoteMagnetStar)
|
// Call feed
|
||||||
|
$curl = new Curl($manifest->export->magnetStars, API_USER_AGENT);
|
||||||
|
|
||||||
|
if (200 != $curl->getCode())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$remoteMagnetStars = $curl->getResponse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((object) $remoteMagnetStars as $remoteMagnetStar)
|
||||||
{
|
{
|
||||||
// Validate
|
// Validate
|
||||||
if (!Valid::magnetStar($remoteMagnetStar))
|
if (!Valid::magnetStar($remoteMagnetStar))
|
||||||
@ -504,7 +591,6 @@ try
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user