Browse Source

add API version check #13, #14

main
ghost 1 year ago
parent
commit
fe2a7a575f
  1. 2
      example/environment/env.example.php
  2. 4
      src/config/bootstrap.php
  3. 4
      src/crontab/export/feed.php
  4. 13
      src/crontab/import/feed.php

2
example/environment/env.example.php

@ -165,8 +165,6 @@ define('NODE_RULE_SUBJECT', 'Common'); @@ -165,8 +165,6 @@ define('NODE_RULE_SUBJECT', 'Common');
define('NODE_RULE_LANGUAGES', 'All');
// API
define('API_VERSION', '1.0.0');
define('API_USER_AGENT', WEBSITE_NAME);
/// Export

4
src/config/bootstrap.php

@ -3,6 +3,10 @@ @@ -3,6 +3,10 @@
// PHP
declare(strict_types=1);
// Application
define('APP_VERSION', '2.0.0');
define('API_VERSION', APP_VERSION);
// Init environment
if (!file_exists(__DIR__ . '/.env'))
{

4
src/crontab/export/feed.php

@ -58,7 +58,8 @@ try @@ -58,7 +58,8 @@ try
// Manifest
$manifest =
[
'updated' => time(),
'updated' => time(),
'version' => (string) API_VERSION,
'settings' => (object)
[
@ -119,7 +120,6 @@ try @@ -119,7 +120,6 @@ try
'MAGNET_STOP_WORDS_SIMILAR' => (object) MAGNET_STOP_WORDS_SIMILAR,
'API_VERSION' => (string) API_VERSION,
'API_USER_AGENT' => (string) API_USER_AGENT,
'API_EXPORT_ENABLED' => (bool) API_EXPORT_ENABLED,

13
src/crontab/import/feed.php

@ -135,6 +135,19 @@ try @@ -135,6 +135,19 @@ try
continue;
}
if (empty($manifest->version) || $manifest->version !== API_VERSION)
{
array_push(
$debug['dump'],
sprintf(
_('Manifest API not compatible with local version "%s"'),
API_VERSION
)
);
continue;
}
if (empty($manifest->export))
{
array_push(

Loading…
Cancel
Save