36 lines
769 B
PHP
Executable File
36 lines
769 B
PHP
Executable File
#!/usr/bin/php
|
|
<?php
|
|
|
|
class Custom extends Plugin
|
|
{
|
|
public function onSync($remote_config)
|
|
{
|
|
if (!isset($remote_config["custom"])) {
|
|
return;
|
|
}
|
|
$this->config = $remote_config["custom"];
|
|
$this->saveConfig();
|
|
|
|
$this->updateConfigFile();
|
|
}
|
|
|
|
public function updateConfigFile()
|
|
{
|
|
$path = dirname(__DIR__, 2) . "/networks/custom.json";
|
|
$current_config = @file_get_contents($path);
|
|
$new_config = json_encode($this->config);
|
|
if($current_config !== $new_config) {
|
|
file_put_contents($path, $new_config);
|
|
}
|
|
}
|
|
|
|
public function onInit(PluginContext $context): void
|
|
{
|
|
parent::onInit($context);
|
|
$this->updateConfigFile();
|
|
}
|
|
|
|
|
|
}
|
|
|