soselo/api/v1/config/instances/add/index.php

19 lines
677 B
PHP

<?php chdir('../../../../../') ?>
<?php require 'base.php' ?>
<?php
if (!in_array(trim($_GET['software']), $GLOBALS['supported_ap_software']))
apiresult(['error' => '<software> given is not supported yet']);
$_GET['hostname'] = $_GET['instance'];
$data = mod_php('api/v1/network/resolve-instance');
if (isset($data['error']))
apiresult(['error' => '<instance> could not be resolved. Make sure you\'ve entered it correctly']);
$software = trim($_GET['software']);
$instance = trim($_GET['instance']);
filedb_put("instances/$software/$instance", 'config');
$uri = preg_replace('#api/v1/config/instances.*#', '', $_SERVER['REQUEST_URI']);
header('Location: '.$uri.'#home');