341 lines
9.7 KiB
PHP
341 lines
9.7 KiB
PHP
<?php
|
|
namespace Site\Controller;
|
|
|
|
use Site\Controller\Mods;
|
|
use Std\Lib\Auth;
|
|
use Std\Lib\Template;
|
|
|
|
use Std\Lib\Openprovider;
|
|
|
|
class Op {
|
|
use Mods;
|
|
|
|
public function index(array $params): void {
|
|
try {
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = 'OpenProvider管理 - ホーム';
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', false);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$tmpl->addCss('table');
|
|
$tmpl->render('index');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opSearchCustomers(array $params): void {
|
|
try {
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = 'OpenProvider管理 - 顧客様検索';
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', true);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
$data = $op->searchCustomers();
|
|
$tmpl->assign('data', $data);
|
|
|
|
$tmpl->addCss('table');
|
|
$tmpl->render('searchcustomer');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opListTlds(array $params): void {
|
|
try {
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = 'OpenProvider管理 - TLD一覧';
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', false);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
$data = $op->listTlds();
|
|
$tmpl->assign('data', $data);
|
|
|
|
$tmpl->addCss('table');
|
|
$tmpl->render('listtlds');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opGetTld(array $params): void {
|
|
try {
|
|
$tld = '';
|
|
if (isset($params['tld'])) $tld = $params['tld'];
|
|
if ($tld === '') {
|
|
header('Location: /');
|
|
exit();
|
|
}
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = "OpenProvider管理 - .{$tld}の表示";
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', false);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
$data = $op->getTld($tld);
|
|
$tmpl->assign('data', $data);
|
|
|
|
$tmpl->addCss('table');
|
|
$tmpl->render('gettld');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opListDomains(array $params): void {
|
|
try {
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = 'OpenProvider管理 - ドメイン確認';
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', false);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
$data = $op->listDomains($domains, true);
|
|
$tmpl->assign('data', $data);
|
|
|
|
$tmpl->assign('saved', $saved);
|
|
|
|
$tmpl->addCss('table');
|
|
$tmpl->addCss('openprovider');
|
|
$tmpl->render('checkdomain');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opCheckDomainAvailable(array $params): void {
|
|
try {
|
|
$domains = isset($_GET['domains']) ? explode("\n", $_GET['domains']) : [];
|
|
$saved = '';
|
|
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = 'OpenProvider管理 - ドメイン確認';
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', false);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
if (!empty($domains)) {
|
|
$data = $op->checkDomainAvailable($domains, true);
|
|
$tmpl->assign('data', $data);
|
|
$saved = $_GET['domains'];
|
|
}
|
|
|
|
$tmpl->assign('saved', $saved);
|
|
|
|
$tmpl->addCss('table');
|
|
$tmpl->addCss('openprovider');
|
|
$tmpl->render('checkdomain');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opGetDomainPrices(array $params): void {
|
|
try {
|
|
$domainname = $_GET['domain_name'] ?? '';
|
|
$domainext = $_GET['domain_extension'] ?? '';
|
|
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = 'OpenProvider管理 - ドメイン値段一覧';
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', false);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
$data = $op->getDomainPrices(['domain.name' => $domainname, 'domain.extension' => $domainext]);
|
|
$tmpl->assign('data', $data);
|
|
|
|
$tmpl->addCss('table');
|
|
$tmpl->render('getdomainprices');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opListDns(array $params): void {
|
|
try {
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = "OpenProvider管理 - DNS一覧";
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', true);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
$data = $op->listDnsZones();
|
|
$tmpl->assign('data', $data);
|
|
|
|
$tmpl->addCss('table');
|
|
if ($user && $user->role & (\Roles::ADMIN)) $tmpl->render('listdnszones');
|
|
else goto noaccess;
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function opGetDns(array $params): void {
|
|
try {
|
|
$domain = '';
|
|
if (isset($params['domain'])) $domain = $params['domain'];
|
|
if ($domain === '') {
|
|
header('Location: /');
|
|
exit();
|
|
}
|
|
$tmpl = new Template('/openprovider/');
|
|
$pagetit = "OpenProvider管理 - {$domain}のDNS管理";
|
|
$description = '';
|
|
|
|
// ユーザー
|
|
$auth = new Auth();
|
|
$user = $auth->getLoggedInUser();
|
|
$tmpl->assign('user', $user);
|
|
|
|
$tmpl->assign('pagetit', $pagetit);
|
|
$tmpl->assign('curPage', 'openprovider');
|
|
$tmpl->assign('custCss', false);
|
|
$tmpl->assign('menu', $this->getMenu());
|
|
$tmpl->assign('description', $description);
|
|
|
|
if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
|
|
$op = new Openprovider();
|
|
$op->login();
|
|
$data = ['rec' => $op->listZoneRecords($domain), 'zone' => $op->getDnsZone($domain)];
|
|
$tmpl->assign('data', $data);
|
|
|
|
$tmpl->addCss('table');
|
|
$tmpl->render('getdns');
|
|
exit();
|
|
|
|
noaccess:
|
|
$tmpl->render('nopermission');
|
|
} catch (\Exception $e) {
|
|
throw new \Exception($e->getMessage());
|
|
}
|
|
}
|
|
} |