pdns-web/app/Http/Controllers/PagesController.php
2018-03-30 11:40:59 -04:00

75 lines
1.7 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use View;
Use App\helpers;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
class PagesController extends Controller
{
public function home()
{
return view('home');
}
public function createzone(Request $createzone_req)
{
if(!$createzone_req->zonename){
return view('createzone');
}
$zone_name = $createzone_req->zonename;
$zone_ttl = $createzone_req->zonettl;
$zone_primary_ip = $createzone_req->primaryip;
$headers = [
'Accept: application/json',
'X-API-Key: '. 'JgTtTq6EFVeo7X71wOVCYQk3rOie2G1k',
];
dd($headers);
$client = new Client(); //GuzzleHttp\Client
$result = $client->post('http://127.0.0.1:8081/api/v1/servers/localhost/zones', [
'form_params' => [
'headers' => $headers,
'kind' => 'Native',
'name' => $zone_name,
'nameservers' => 'pdnstest.tfmm.co',
'records' => [
'0' => [
'content' => 'pdnstest.tfmm.co. hostmaster.tfmm.co. 1 1800 900 604800 86400',
'disabled' => 'false',
'ttl' => '86400',
'type' => 'SOA'
],
'1' => [
'content' => $zone_primary_ip,
'disabled' => 'false',
'name' => $zone_name,
'ttl' => '3600',
'type' => 'A'
]
]
]
]);
return redirect('createzone');
}
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');
}
}