|
|
@ -136,7 +136,7 @@ try |
|
|
|
'nodes' => (object) json_decode(file_get_contents(__DIR__ . '/../../config/nodes.json')), |
|
|
|
'nodes' => (object) json_decode(file_get_contents(__DIR__ . '/../../config/nodes.json')), |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
/// Dump manifest manifest |
|
|
|
/// Dump feed |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/manifest.json', 'w+')) |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/manifest.json', 'w+')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fwrite($handle, json_encode($manifest)); |
|
|
|
fwrite($handle, json_encode($manifest)); |
|
|
@ -322,121 +322,122 @@ try |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Downloads |
|
|
|
// Magnet downloads |
|
|
|
if (API_EXPORT_MAGNET_DOWNLOADS_ENABLED) |
|
|
|
if (API_EXPORT_MAGNET_DOWNLOADS_ENABLED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$downloads = []; |
|
|
|
$magnetDownloads = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($db->getMagnetDownloads() as $download) |
|
|
|
foreach ($db->getMagnetDownloads() as $magnetDownload) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Dump public data only |
|
|
|
// Dump public data only |
|
|
|
if (isset($public['magnet'][$download->magnetId]) && $public['magnet'][$download->magnetId] === '1' && |
|
|
|
if (isset($public['magnet'][$magnetDownload->magnetId]) && $public['magnet'][$magnetDownload->magnetId] === '1' && |
|
|
|
isset($public['user'][$download->userId]) && $public['user'][$download->userId] === '1') |
|
|
|
isset($public['user'][$magnetDownload->userId]) && $public['user'][$magnetDownload->userId] === '1') |
|
|
|
{ |
|
|
|
{ |
|
|
|
$downloads[] = (object) |
|
|
|
$magnetDownloads[] = (object) |
|
|
|
[ |
|
|
|
[ |
|
|
|
'magnetDownloadId' => $download->magnetDownloadId, |
|
|
|
'magnetDownloadId' => $magnetDownload->magnetDownloadId, |
|
|
|
'userId' => $download->userId, |
|
|
|
'userId' => $magnetDownload->userId, |
|
|
|
'magnetId' => $download->magnetId, |
|
|
|
'magnetId' => $magnetDownload->magnetId, |
|
|
|
'timeAdded' => $download->timeAdded, |
|
|
|
'timeAdded' => $magnetDownload->timeAdded, |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Dump downloads feed |
|
|
|
/// Dump feed |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetDownloads.json', 'w+')) |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetDownloads.json', 'w+')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fwrite($handle, json_encode($downloads)); |
|
|
|
fwrite($handle, json_encode($magnetDownloads)); |
|
|
|
fclose($handle); |
|
|
|
fclose($handle); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Comments |
|
|
|
// Magnet comments |
|
|
|
if (API_EXPORT_MAGNET_COMMENTS_ENABLED) |
|
|
|
if (API_EXPORT_MAGNET_COMMENTS_ENABLED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$comments = []; |
|
|
|
$magnetComments = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($db->getMagnetComments() as $comment) |
|
|
|
foreach ($db->getMagnetComments() as $magnetComment) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Dump public data only |
|
|
|
// Dump public data only |
|
|
|
if (isset($public['magnet'][$comment->magnetId]) && $public['magnet'][$comment->magnetId] === '1' && |
|
|
|
if (isset($public['magnet'][$magnetComment->magnetId]) && $public['magnet'][$magnetComment->magnetId] === '1' && |
|
|
|
isset($public['user'][$comment->userId]) && $public['user'][$comment->userId] === '1') |
|
|
|
isset($public['user'][$magnetComment->userId]) && $public['user'][$magnetComment->userId] === '1') |
|
|
|
{ |
|
|
|
{ |
|
|
|
$comments[] = (object) |
|
|
|
$magnetComments[] = (object) |
|
|
|
[ |
|
|
|
[ |
|
|
|
'magnetCommentId' => $comment->magnetCommentId, |
|
|
|
'magnetCommentId' => $magnetComment->magnetCommentId, |
|
|
|
'magnetCommentIdParent' => $comment->magnetCommentIdParent, |
|
|
|
'magnetCommentIdParent' => $magnetComment->magnetCommentIdParent, |
|
|
|
'userId' => $comment->userId, |
|
|
|
'userId' => $magnetComment->userId, |
|
|
|
'magnetId' => $comment->magnetId, |
|
|
|
'magnetId' => $magnetComment->magnetId, |
|
|
|
'timeAdded' => $comment->timeAdded, |
|
|
|
'timeAdded' => $magnetComment->timeAdded, |
|
|
|
'approved' => (bool) $comment->approved, |
|
|
|
'approved' => (bool) $magnetComment->approved, |
|
|
|
'value' => $comment->value |
|
|
|
'value' => $magnetComment->value |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Dump comments feed |
|
|
|
/// Dump feed |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetComments.json', 'w+')) |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetComments.json', 'w+')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fwrite($handle, json_encode($comments)); |
|
|
|
fwrite($handle, json_encode($magnetComments)); |
|
|
|
fclose($handle); |
|
|
|
fclose($handle); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Stars |
|
|
|
// Magnet stars |
|
|
|
if (API_EXPORT_MAGNET_STARS_ENABLED) |
|
|
|
if (API_EXPORT_MAGNET_STARS_ENABLED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$stars = []; |
|
|
|
$magnetStars = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($db->getMagnetStars() as $star) |
|
|
|
foreach ($db->getMagnetStars() as $magnetStar) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Dump public data only |
|
|
|
// Dump public data only |
|
|
|
if (isset($public['magnet'][$star->magnetId]) && $public['magnet'][$star->magnetId] === '1' && |
|
|
|
if (isset($public['magnet'][$magnetStar->magnetId]) && $public['magnet'][$magnetStar->magnetId] === '1' && |
|
|
|
isset($public['user'][$star->userId]) && $public['user'][$star->userId] === '1') |
|
|
|
isset($public['user'][$magnetStar->userId]) && $public['user'][$magnetStar->userId] === '1') |
|
|
|
{ |
|
|
|
{ |
|
|
|
$stars[] = (object) |
|
|
|
$magnetStars[] = (object) |
|
|
|
[ |
|
|
|
[ |
|
|
|
'magnetStarId' => $star->magnetStarId, |
|
|
|
'magnetStarId' => $magnetStar->magnetStarId, |
|
|
|
'userId' => $star->userId, |
|
|
|
'userId' => $magnetStar->userId, |
|
|
|
'magnetId' => $star->magnetId, |
|
|
|
'magnetId' => $magnetStar->magnetId, |
|
|
|
'value' => (bool) $star->value, |
|
|
|
'value' => (bool) $magnetStar->value, |
|
|
|
'timeAdded' => $star->timeAdded, |
|
|
|
'timeAdded' => $magnetStar->timeAdded, |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Dump stars feed |
|
|
|
/// Dump feed |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetStars.json', 'w+')) |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetStars.json', 'w+')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fwrite($handle, json_encode($stars)); |
|
|
|
fwrite($handle, json_encode($magnetStars)); |
|
|
|
fclose($handle); |
|
|
|
fclose($handle); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Views |
|
|
|
|
|
|
|
|
|
|
|
// Magnet views |
|
|
|
if (API_EXPORT_MAGNET_VIEWS_ENABLED) |
|
|
|
if (API_EXPORT_MAGNET_VIEWS_ENABLED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$views = []; |
|
|
|
$magnetViews = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($db->getMagnetViews() as $view) |
|
|
|
foreach ($db->getMagnetViews() as $magnetView) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Dump public data only |
|
|
|
// Dump public data only |
|
|
|
if (isset($public['magnet'][$view->magnetId]) && $public['magnet'][$view->magnetId] === '1' && |
|
|
|
if (isset($public['magnet'][$magnetView->magnetId]) && $public['magnet'][$magnetView->magnetId] === '1' && |
|
|
|
isset($public['user'][$view->userId]) && $public['user'][$view->userId] === '1') |
|
|
|
isset($public['user'][$magnetView->userId] ) && $public['user'][$magnetView->userId] === '1') |
|
|
|
{ |
|
|
|
{ |
|
|
|
$views[] = (object) |
|
|
|
$magnetViews[] = (object) |
|
|
|
[ |
|
|
|
[ |
|
|
|
'magnetViewId' => $view->magnetViewId, |
|
|
|
'magnetViewId' => $magnetView->magnetViewId, |
|
|
|
'userId' => $view->userId, |
|
|
|
'userId' => $magnetView->userId, |
|
|
|
'magnetId' => $view->magnetId, |
|
|
|
'magnetId' => $magnetView->magnetId, |
|
|
|
'timeAdded' => $view->timeAdded, |
|
|
|
'timeAdded' => $magnetView->timeAdded, |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Dump views feed |
|
|
|
/// Dump feed |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetViews.json', 'w+')) |
|
|
|
if ($handle = fopen(__DIR__ . '/../../public/api/magnetViews.json', 'w+')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fwrite($handle, json_encode($views)); |
|
|
|
fwrite($handle, json_encode($magnetViews)); |
|
|
|
fclose($handle); |
|
|
|
fclose($handle); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|