switch remote file_get_contents to curl

This commit is contained in:
ghost 2023-09-15 23:43:00 +03:00
parent 034a8c540a
commit d2cad4833e

View File

@ -52,453 +52,539 @@ 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 (empty($manifest->export)) }
if (!$manifest = $curl->getResponse())
{
continue;
}
if (empty($manifest->export))
{
continue;
}
// Users
if (API_IMPORT_USERS_ENABLED)
{
if (Valid::url($manifest->export->users))
{ {
continue; continue;
} }
// Users // Call feed
if (API_IMPORT_USERS_ENABLED) $curl = new Curl($manifest->export->users, API_USER_AGENT);
if (200 != $curl->getCode())
{ {
if (empty($manifest->export->users)) continue;
}
if (!$remoteUsers = $curl->getResponse())
{
continue;
}
// Init alias registry for this host
$aliasUserId = [];
foreach ((object) $remoteUsers as $remoteUser)
{
// Validate required fields
if (!Valid::user($remoteUser))
{
continue;
}
// Skip import on user approved required
if (API_IMPORT_USERS_APPROVED_ONLY && !$remoteUser->approved)
{
continue;
}
// Init session
else if (!$localUser = $db->getUser(
$db->initUserId($remoteUser->address,
USER_AUTO_APPROVE_ON_IMPORT_APPROVED ? $remoteUser->approved : USER_DEFAULT_APPROVED,
$remoteUser->timeAdded)))
{
continue;
}
// Update time added if newer
if ($localUser->timeAdded < $remoteUser->timeAdded)
{
$db->updateUserTimeAdded(
$localUser->userId,
$remoteUser->timeAdded
);
}
// Update user info if newer
if ($localUser->timeUpdated < $remoteUser->timeUpdated)
{
// Update time updated
$db->updateUserTimeUpdated(
$localUser->userId,
$remoteUser->timeUpdated
);
// Update approved for existing user
if (USER_AUTO_APPROVE_ON_IMPORT_APPROVED && $localUser->approved !== $remoteUser->approved && $remoteUser->approved)
{
$db->updateUserApproved(
$localUser->userId,
$remoteUser->approved,
$remoteUser->timeUpdated
);
}
// Set public as received remotely
if (!$localUser->public)
{
$db->updateUserPublic(
$localUser->userId,
true,
$remoteUser->timeUpdated
);
}
}
// Register userId alias
$aliasUserId[$remoteUser->userId] = $localUser->userId;
}
// Magnets
if (API_IMPORT_MAGNETS_ENABLED)
{
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;
} }
// Init alias registry for this host // Init alias registry for this host
$aliasUserId = []; $aliasMagnetId = [];
foreach (@json_decode(@file_get_contents($manifest->export->users)) as $remoteUser) foreach ((object) $remoteMagnets as $remoteMagnet)
{ {
// Validate required fields // Validate required fields by protocol
if (!Valid::user($remoteUser)) if (!Valid::magnet($remoteMagnet))
{ {
continue; continue;
} }
// Skip import on user approved required // Aliases check
if (API_IMPORT_USERS_APPROVED_ONLY && !$remoteUser->approved) if (!isset($aliasUserId[$remoteMagnet->userId]))
{ {
continue; continue;
} }
// Init session // Skip import on magnet approved required
else if (!$localUser = $db->getUser( if (API_IMPORT_MAGNETS_APPROVED_ONLY && !$remoteMagnet->approved)
$db->initUserId($remoteUser->address,
USER_AUTO_APPROVE_ON_IMPORT_APPROVED ? $remoteUser->approved : USER_DEFAULT_APPROVED,
$remoteUser->timeAdded)))
{ {
continue; continue;
} }
// Remember user ID for this host // Add new magnet if not exist by timestamp added for this user
$aliasUserId[$remoteUser->userId] = $localUser->userId; if (!$localMagnet = $db->findMagnet($aliasUserId[$remoteMagnet->userId], $remoteMagnet->timeAdded))
{
$localMagnet = $db->getMagnet(
$db->addMagnet(
$aliasUserId[$remoteMagnet->userId],
$remoteMagnet->xl,
$remoteMagnet->dn,
'', // @TODO linkSource used for debug only, will be deleted later
true,
$remoteMagnet->comments,
$remoteMagnet->sensitive,
MAGNET_AUTO_APPROVE_ON_IMPORT_APPROVED ? $remoteMagnet->approved : MAGNET_DEFAULT_APPROVED,
$remoteMagnet->timeAdded
)
);
}
// Update time added if newer // Update time added if newer
if ($localUser->timeAdded < $remoteUser->timeAdded) if ($localMagnet->timeAdded < $remoteMagnet->timeAdded)
{ {
$db->updateUserTimeAdded( $db->updateMagnetTimeAdded(
$localUser->userId, $localMagnet->magnetId,
$remoteUser->timeAdded $remoteMagnet->timeAdded
); );
} }
// Update user info if newer // Update info if remote newer
if ($localUser->timeUpdated < $remoteUser->timeUpdated) if ($localMagnet->timeUpdated < $remoteMagnet->timeUpdated)
{ {
// Update time updated // Magnet fields
$db->updateUserTimeUpdated( $db->updateMagnetXl($localMagnet->magnetId, $remoteMagnet->xl, $remoteMagnet->timeUpdated);
$localUser->userId, $db->updateMagnetDn($localMagnet->magnetId, $remoteMagnet->dn, $remoteMagnet->timeUpdated);
$remoteUser->timeUpdated $db->updateMagnetTitle($localMagnet->magnetId, $remoteMagnet->title, $remoteMagnet->timeUpdated);
); $db->updateMagnetPreview($localMagnet->magnetId, $remoteMagnet->preview, $remoteMagnet->timeUpdated);
$db->updateMagnetDescription($localMagnet->magnetId, $remoteMagnet->description, $remoteMagnet->timeUpdated);
$db->updateMagnetComments($localMagnet->magnetId, $remoteMagnet->comments, $remoteMagnet->timeUpdated);
$db->updateMagnetSensitive($localMagnet->magnetId, $remoteMagnet->sensitive, $remoteMagnet->timeUpdated);
// Update approved for existing user if (MAGNET_AUTO_APPROVE_ON_IMPORT_APPROVED && $localMagnet->approved !== $remoteMagnet->approved && $remoteMagnet->approved)
if (USER_AUTO_APPROVE_ON_IMPORT_APPROVED && $localUser->approved !== $remoteUser->approved && $remoteUser->approved)
{ {
$db->updateUserApproved( $db->updateMagnetApproved($localMagnet->magnetId, $remoteMagnet->approved, $remoteMagnet->timeUpdated);
$localUser->userId, }
$remoteUser->approved,
$remoteUser->timeUpdated // xt
foreach ((array) $remoteMagnet->xt as $xt)
{
switch ($xt->version)
{
case 1:
if (Yggverse\Parser\Magnet::isXTv1($xt->value))
{
$exist = false;
foreach ($db->findMagnetToInfoHashByMagnetId($localMagnet->magnetId) as $result)
{
if ($infoHash = $db->getInfoHash($result->infoHashId))
{
if ($infoHash->version == 1)
{
$exist = true;
}
}
}
if (!$exist)
{
$db->addMagnetToInfoHash(
$localMagnet->magnetId,
$db->initInfoHashId(
Yggverse\Parser\Magnet::filterInfoHash($xt->value), 1
)
);
}
}
break;
case 2:
if (Yggverse\Parser\Magnet::isXTv2($xt->value))
{
$exist = false;
foreach ($db->findMagnetToInfoHashByMagnetId($localMagnet->magnetId) as $result)
{
if ($infoHash = $db->getInfoHash($result->infoHashId))
{
if ($infoHash->version == 2)
{
$exist = true;
}
}
}
if (!$exist)
{
$db->addMagnetToInfoHash(
$localMagnet->magnetId,
$db->initInfoHashId(
Yggverse\Parser\Magnet::filterInfoHash($xt->value), 2
)
);
}
}
break;
}
}
// kt
foreach ($remoteMagnet->kt as $kt)
{
$db->initMagnetToKeywordTopicId(
$localMagnet->magnetId,
$db->initKeywordTopicId(trim(mb_strtolower(strip_tags(html_entity_decode($kt)))))
); );
} }
// Set public as received remotely // tr
if (!$localUser->public) foreach ($remoteMagnet->tr as $tr)
{ {
$db->updateUserPublic( $db->initMagnetToAddressTrackerId(
$localUser->userId, $localMagnet->magnetId,
true, $db->initAddressTrackerId(
$remoteUser->timeUpdated $db->initSchemeId($url->host->scheme),
$db->initHostId($url->host->name),
$db->initPortId($url->host->port),
$db->initUriId($url->page->uri)
)
);
}
// as
foreach ($remoteMagnet->as as $as)
{
$db->initMagnetToAcceptableSourceId(
$localMagnet->magnetId,
$db->initAcceptableSourceId(
$db->initSchemeId($url->host->scheme),
$db->initHostId($url->host->name),
$db->initPortId($url->host->port),
$db->initUriId($url->page->uri)
)
);
}
// xs
foreach ($remoteMagnet->xs as $xs)
{
$db->initMagnetToExactSourceId(
$localMagnet->magnetId,
$db->initExactSourceId(
$db->initSchemeId($url->host->scheme),
$db->initHostId($url->host->name),
$db->initPortId($url->host->port),
$db->initUriId($url->page->uri)
)
); );
} }
} }
// Add magnet alias for this host
$aliasMagnetId[$remoteMagnet->magnetId] = $localMagnet->magnetId;
} }
// Magnets // Magnet comments
if (API_IMPORT_MAGNETS_ENABLED) if (API_IMPORT_MAGNET_COMMENTS_ENABLED)
{ {
if (empty($manifest->export->magnets)) if (Valid::url($manifest->export->magnetComments))
{ {
continue; continue;
} }
// Init alias registry for this host // Call feed
$aliasMagnetId = []; $curl = new Curl($manifest->export->magnetComments, API_USER_AGENT);
foreach (@json_decode(@file_get_contents($manifest->export->magnets)) as $remoteMagnet) if (200 != $curl->getCode())
{ {
// Validate required fields by protocol continue;
if (!Valid::magnet($remoteMagnet)) }
if (!$remoteMagnetComments = $curl->getResponse())
{
continue;
}
foreach ((object) $remoteMagnetComments as $remoteMagnetComment)
{
// Validate
if (!Valid::magnetComment($remoteMagnetComment))
{ {
continue; continue;
} }
// Aliases check // Aliases check
if (!isset($aliasUserId[$remoteMagnet->userId])) if (!isset($aliasMagnetId[$remoteMagnetComment->magnetId]) || !isset($aliasUserId[$remoteMagnetComment->userId]))
{ {
continue; continue;
} }
// Skip import on magnet approved required // Skip import on magnet comment approved required
if (API_IMPORT_MAGNETS_APPROVED_ONLY && !$remoteMagnet->approved) if (API_IMPORT_MAGNET_COMMENTS_APPROVED_ONLY && !$remoteMagnetComment->approved)
{ {
continue; continue;
} }
// Add new magnet if not exist by timestamp added for this user // Add new magnet comment if not exist by timestamp added for this user
if (!$localMagnet = $db->findMagnet($aliasUserId[$remoteMagnet->userId], $remoteMagnet->timeAdded)) if (!$db->findMagnetComment($aliasMagnetId[$remoteMagnetComment->magnetId],
$aliasUserId[$remoteMagnetComment->userId],
$remoteMagnetComment->timeAdded))
{ {
$localMagnet = $db->getMagnet( // Parent comment provided
$db->addMagnet( if (is_int($remoteMagnetComment->magnetCommentIdParent))
$aliasUserId[$remoteMagnet->userId], {
$remoteMagnet->xl, $localMagnetCommentIdParent = null; // @TODO feature not in use yet
$remoteMagnet->dn, }
'', // @TODO linkSource used for debug only, will be deleted later
true, else
$remoteMagnet->comments, {
$remoteMagnet->sensitive, $localMagnetCommentIdParent = null;
MAGNET_AUTO_APPROVE_ON_IMPORT_APPROVED ? $remoteMagnet->approved : MAGNET_DEFAULT_APPROVED, }
$remoteMagnet->timeAdded
) $db->addMagnetComment(
$aliasMagnetId[$remoteMagnetComment->magnetId],
$aliasUserId[$remoteMagnetComment->userId],
$localMagnetCommentIdParent,
$remoteMagnetComment->value,
$remoteMagnetComment->approved,
true,
$remoteMagnetComment->timeAdded
); );
} }
}
}
// Add magnet alias for this host // Magnet downloads
$aliasMagnetId[$remoteMagnet->magnetId] = $localMagnet->magnetId; if (API_IMPORT_MAGNET_DOWNLOADS_ENABLED)
{
if (Valid::url($manifest->export->magnetDownloads))
{
continue;
}
// Update time added if newer // Call feed
if ($localMagnet->timeAdded < $remoteMagnet->timeAdded) $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
if (!Valid::magnetDownload($remoteMagnetDownload))
{ {
$db->updateMagnetTimeAdded( continue;
$localMagnet->magnetId, }
$remoteMagnet->timeAdded
// Aliases check
if (!isset($aliasMagnetId[$remoteMagnetDownload->magnetId]) || !isset($aliasUserId[$remoteMagnetDownload->userId]))
{
continue;
}
// Add new magnet download if not exist by timestamp added for this user
if (!$db->findMagnetDownload($aliasMagnetId[$remoteMagnetDownload->magnetId],
$aliasUserId[$remoteMagnetDownload->userId],
$remoteMagnetDownload->timeAdded))
{
$db->addMagnetDownload(
$aliasMagnetId[$remoteMagnetDownload->magnetId],
$aliasUserId[$remoteMagnetDownload->userId],
$remoteMagnetDownload->timeAdded
); );
} }
}
}
// Update info if remote newer // Magnet views
if ($localMagnet->timeUpdated < $remoteMagnet->timeUpdated) if (API_IMPORT_MAGNET_VIEWS_ENABLED)
{ {
// Magnet fields if (Valid::url($manifest->export->magnetViews))
$db->updateMagnetXl($localMagnet->magnetId, $remoteMagnet->xl, $remoteMagnet->timeUpdated); {
$db->updateMagnetDn($localMagnet->magnetId, $remoteMagnet->dn, $remoteMagnet->timeUpdated); continue;
$db->updateMagnetTitle($localMagnet->magnetId, $remoteMagnet->title, $remoteMagnet->timeUpdated);
$db->updateMagnetPreview($localMagnet->magnetId, $remoteMagnet->preview, $remoteMagnet->timeUpdated);
$db->updateMagnetDescription($localMagnet->magnetId, $remoteMagnet->description, $remoteMagnet->timeUpdated);
$db->updateMagnetComments($localMagnet->magnetId, $remoteMagnet->comments, $remoteMagnet->timeUpdated);
$db->updateMagnetSensitive($localMagnet->magnetId, $remoteMagnet->sensitive, $remoteMagnet->timeUpdated);
if (MAGNET_AUTO_APPROVE_ON_IMPORT_APPROVED && $localMagnet->approved !== $remoteMagnet->approved && $remoteMagnet->approved)
{
$db->updateMagnetApproved($localMagnet->magnetId, $remoteMagnet->approved, $remoteMagnet->timeUpdated);
}
// xt
foreach ((array) $remoteMagnet->xt as $xt)
{
switch ($xt->version)
{
case 1:
if (Yggverse\Parser\Magnet::isXTv1($xt->value))
{
$exist = false;
foreach ($db->findMagnetToInfoHashByMagnetId($localMagnet->magnetId) as $result)
{
if ($infoHash = $db->getInfoHash($result->infoHashId))
{
if ($infoHash->version == 1)
{
$exist = true;
}
}
}
if (!$exist)
{
$db->addMagnetToInfoHash(
$localMagnet->magnetId,
$db->initInfoHashId(
Yggverse\Parser\Magnet::filterInfoHash($xt->value), 1
)
);
}
}
break;
case 2:
if (Yggverse\Parser\Magnet::isXTv2($xt->value))
{
$exist = false;
foreach ($db->findMagnetToInfoHashByMagnetId($localMagnet->magnetId) as $result)
{
if ($infoHash = $db->getInfoHash($result->infoHashId))
{
if ($infoHash->version == 2)
{
$exist = true;
}
}
}
if (!$exist)
{
$db->addMagnetToInfoHash(
$localMagnet->magnetId,
$db->initInfoHashId(
Yggverse\Parser\Magnet::filterInfoHash($xt->value), 2
)
);
}
}
break;
}
}
// kt
foreach ($remoteMagnet->kt as $kt)
{
$db->initMagnetToKeywordTopicId(
$localMagnet->magnetId,
$db->initKeywordTopicId(trim(mb_strtolower(strip_tags(html_entity_decode($kt)))))
);
}
// tr
foreach ($remoteMagnet->tr as $tr)
{
$db->initMagnetToAddressTrackerId(
$localMagnet->magnetId,
$db->initAddressTrackerId(
$db->initSchemeId($url->host->scheme),
$db->initHostId($url->host->name),
$db->initPortId($url->host->port),
$db->initUriId($url->page->uri)
)
);
}
// as
foreach ($remoteMagnet->as as $as)
{
$db->initMagnetToAcceptableSourceId(
$localMagnet->magnetId,
$db->initAcceptableSourceId(
$db->initSchemeId($url->host->scheme),
$db->initHostId($url->host->name),
$db->initPortId($url->host->port),
$db->initUriId($url->page->uri)
)
);
}
// xs
foreach ($remoteMagnet->xs as $xs)
{
$db->initMagnetToExactSourceId(
$localMagnet->magnetId,
$db->initExactSourceId(
$db->initSchemeId($url->host->scheme),
$db->initHostId($url->host->name),
$db->initPortId($url->host->port),
$db->initUriId($url->page->uri)
)
);
}
}
} }
// Magnet comments // Call feed
if (API_IMPORT_MAGNET_COMMENTS_ENABLED) $curl = new Curl($manifest->export->magnetViews, API_USER_AGENT);
if (200 != $curl->getCode())
{ {
if (empty($manifest->export->magnetComments)) continue;
}
if (!$remoteMagnetViews = $curl->getResponse())
{
continue;
}
foreach ((object) $remoteMagnetViews as $remoteMagnetView)
{
// Validate
if (!Valid::magnetView($remoteMagnetView))
{ {
continue; continue;
} }
foreach (@json_decode(@file_get_contents($manifest->export->magnetComments)) as $remoteMagnetComment) // Aliases check
{ if (!isset($aliasMagnetId[$remoteMagnetView->magnetId]) || !isset($aliasUserId[$remoteMagnetView->userId]))
// Validate
if (!Valid::magnetComment($remoteMagnetComment))
{
continue;
}
// Aliases check
if (!isset($aliasMagnetId[$remoteMagnetComment->magnetId]) || !isset($aliasUserId[$remoteMagnetComment->userId]))
{
continue;
}
// Skip import on magnet comment approved required
if (API_IMPORT_MAGNET_COMMENTS_APPROVED_ONLY && !$remoteMagnetComment->approved)
{
continue;
}
// Add new magnet comment if not exist by timestamp added for this user
if (!$db->findMagnetComment($aliasMagnetId[$remoteMagnetComment->magnetId],
$aliasUserId[$remoteMagnetComment->userId],
$remoteMagnetComment->timeAdded))
{
// Parent comment provided
if (is_int($remoteMagnetComment->magnetCommentIdParent))
{
$localMagnetCommentIdParent = null; // @TODO feature not in use yet
}
else
{
$localMagnetCommentIdParent = null;
}
$db->addMagnetComment(
$aliasMagnetId[$remoteMagnetComment->magnetId],
$aliasUserId[$remoteMagnetComment->userId],
$localMagnetCommentIdParent,
$remoteMagnetComment->value,
$remoteMagnetComment->approved,
true,
$remoteMagnetComment->timeAdded
);
}
}
}
// Magnet downloads
if (API_IMPORT_MAGNET_DOWNLOADS_ENABLED)
{
if (empty($manifest->export->magnetDownloads))
{ {
continue; continue;
} }
foreach (@json_decode(@file_get_contents($manifest->export->magnetDownloads)) as $remoteMagnetDownload) // Add new magnet view if not exist by timestamp added for this user
if (!$db->findMagnetView($aliasMagnetId[$remoteMagnetView->magnetId],
$aliasUserId[$remoteMagnetView->userId],
$remoteMagnetView->timeAdded))
{ {
// Validate $db->addMagnetView(
if (!Valid::magnetDownload($remoteMagnetDownload)) $aliasMagnetId[$remoteMagnetView->magnetId],
{ $aliasUserId[$remoteMagnetView->userId],
continue; $remoteMagnetView->timeAdded
} );
// Aliases check
if (!isset($aliasMagnetId[$remoteMagnetDownload->magnetId]) || !isset($aliasUserId[$remoteMagnetDownload->userId]))
{
continue;
}
// Add new magnet download if not exist by timestamp added for this user
if (!$db->findMagnetDownload($aliasMagnetId[$remoteMagnetDownload->magnetId],
$aliasUserId[$remoteMagnetDownload->userId],
$remoteMagnetDownload->timeAdded))
{
$db->addMagnetDownload(
$aliasMagnetId[$remoteMagnetDownload->magnetId],
$aliasUserId[$remoteMagnetDownload->userId],
$remoteMagnetDownload->timeAdded
);
}
} }
} }
}
// Magnet views // Magnet stars
if (API_IMPORT_MAGNET_VIEWS_ENABLED) if (API_IMPORT_MAGNET_STARS_ENABLED)
{
if (Valid::url($manifest->export->magnetStars))
{ {
if (empty($manifest->export->magnetViews)) continue;
}
// 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
if (!Valid::magnetStar($remoteMagnetStar))
{ {
continue; continue;
} }
foreach (@json_decode(@file_get_contents($manifest->export->magnetViews)) as $remoteMagnetView) // Aliases check
{ if (!isset($aliasMagnetId[$remoteMagnetStar->magnetId]) || !isset($aliasUserId[$remoteMagnetStar->userId]))
// Validate
if (!Valid::magnetView($remoteMagnetView))
{
continue;
}
// Aliases check
if (!isset($aliasMagnetId[$remoteMagnetView->magnetId]) || !isset($aliasUserId[$remoteMagnetView->userId]))
{
continue;
}
// Add new magnet view if not exist by timestamp added for this user
if (!$db->findMagnetView($aliasMagnetId[$remoteMagnetView->magnetId],
$aliasUserId[$remoteMagnetView->userId],
$remoteMagnetView->timeAdded))
{
$db->addMagnetView(
$aliasMagnetId[$remoteMagnetView->magnetId],
$aliasUserId[$remoteMagnetView->userId],
$remoteMagnetView->timeAdded
);
}
}
}
// Magnet stars
if (API_IMPORT_MAGNET_STARS_ENABLED)
{
if (empty($manifest->export->magnetStars))
{ {
continue; continue;
} }
foreach (@json_decode(@file_get_contents($manifest->export->magnetStars)) as $remoteMagnetStar) // Add new magnet star if not exist by timestamp added for this user
if (!$db->findMagnetStar($aliasMagnetId[$remoteMagnetStar->magnetId],
$aliasUserId[$remoteMagnetStar->userId],
$remoteMagnetStar->timeAdded))
{ {
// Validate $db->addMagnetStar(
if (!Valid::magnetStar($remoteMagnetStar)) $aliasMagnetId[$remoteMagnetStar->magnetId],
{ $aliasUserId[$remoteMagnetStar->userId],
continue; $remoteMagnetStar->value,
} $remoteMagnetStar->timeAdded
);
// Aliases check
if (!isset($aliasMagnetId[$remoteMagnetStar->magnetId]) || !isset($aliasUserId[$remoteMagnetStar->userId]))
{
continue;
}
// Add new magnet star if not exist by timestamp added for this user
if (!$db->findMagnetStar($aliasMagnetId[$remoteMagnetStar->magnetId],
$aliasUserId[$remoteMagnetStar->userId],
$remoteMagnetStar->timeAdded))
{
$db->addMagnetStar(
$aliasMagnetId[$remoteMagnetStar->magnetId],
$aliasUserId[$remoteMagnetStar->userId],
$remoteMagnetStar->value,
$remoteMagnetStar->timeAdded
);
}
} }
} }
} }