pdns-web/app/Http/Controllers/PagesController.php

75 lines
1.8 KiB
PHP
Raw Normal View History

2018-03-30 07:55:34 -04:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
2018-03-30 08:04:18 -04:00
use Illuminate\Support\Facades\DB;
use View;
Use App\helpers;
2018-03-30 09:52:08 -04:00
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
2018-03-30 07:55:34 -04:00
class PagesController extends Controller
{
2018-03-30 08:04:18 -04:00
public function home()
{
return view('home');
}
2018-03-30 09:16:28 -04:00
public function createzone(Request $createzone_req)
{
2018-03-30 09:52:08 -04:00
if(!$createzone_req->zonename){
return view('createzone');
}
$zone_name = $createzone_req->zonename;
$zone_ttl = $createzone_req->zonettl;
$zone_primary_ip = $createzone_req->primaryip;
$client = new Client(); //GuzzleHttp\Client
2018-03-30 09:55:50 -04:00
$result = $client->post('http://127.0.0.1:8081/api/v1/servers/localhost/zones', [
2018-03-30 13:07:30 -04:00
\GuzzleHttp\RequestOptions::JSON => [
'kind' => 'Native',
'masters' => [],
2018-03-30 13:10:07 -04:00
'name' => $zone_name . '.',
2018-03-30 13:07:30 -04:00
'nameservers' => [
2018-03-30 13:10:38 -04:00
'0' => 'pdnstest.tfmm.co.'
2018-03-30 13:07:30 -04:00
],
'records' => [
2018-03-30 13:28:13 -04:00
[
2018-03-30 13:07:30 -04:00
'content' => 'pdnstest.tfmm.co. hostmaster.tfmm.co. 1 1800 900 604800 86400',
'disabled' => 'false',
'ttl' => '86400',
'type' => 'SOA'
],
2018-03-30 13:28:13 -04:00
[
2018-03-30 13:07:30 -04:00
'content' => $zone_primary_ip,
'disabled' => 'false',
'name' => $zone_name,
'ttl' => '3600',
'type' => 'A'
]
2018-03-30 13:28:13 -04:00
]
2018-03-30 13:07:30 -04:00
],
2018-03-30 12:11:14 -04:00
'headers' => [
'X-API-Key' => 'JgTtTq6EFVeo7X71wOVCYQk3rOie2G1k'
2018-03-30 12:12:00 -04:00
]
2018-03-30 09:54:06 -04:00
]);
2018-03-30 09:52:08 -04:00
return redirect('createzone');
2018-03-30 09:16:28 -04:00
}
2018-03-30 08:04:18 -04:00
public function domains(Request $domain_req)
{
return view('domains');
}
public function newrecord(Request $newrec_req)
{
return view('newrecord');
}
public function updaterecord(Request $updaterec_req)
{
return view('updaterecord');
}
2018-03-30 07:55:34 -04:00
}