forked from .cyb/cyberman
Domain registration (excluding communication with nsd)
Domains are registered in the sqlite database but the information is not sent to nsd; nothing will really happen.
This commit is contained in:
parent
5024363f22
commit
e3d00d0683
|
@ -20,4 +20,55 @@ get '/domains' => sub {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
post '/domains/new' => sub {
|
||||||
|
my %errs;
|
||||||
|
|
||||||
|
if (!param("name")) {
|
||||||
|
$errs{"e_no_name"} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $name = lc param("name");
|
||||||
|
|
||||||
|
if (scalar(keys(%errs)) == 0) {
|
||||||
|
if (param("name") !~ m/^[a-z0-9]([a-z0-9\-_]*[a-z0-9])?$/) {
|
||||||
|
$errs{"e_chars"} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scalar(keys(%errs)) == 0) {
|
||||||
|
my $result = database->quick_select(
|
||||||
|
"domain",
|
||||||
|
{
|
||||||
|
"name" => param("name"),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$errs{"e_exists"} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scalar(keys(%errs)) != 0) {
|
||||||
|
return template 'domains/new' => {
|
||||||
|
params,
|
||||||
|
%errs,
|
||||||
|
error => 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO: send domains to nsd
|
||||||
|
|
||||||
|
database->quick_insert(
|
||||||
|
"domain",
|
||||||
|
{
|
||||||
|
"name" => $name,
|
||||||
|
"ownerid" => vars->{"auth"},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
template 'redir' => {
|
||||||
|
"redir" => "../domains",
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
true;
|
true;
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
<div class="body">
|
<div class="body">
|
||||||
|
<center>
|
||||||
|
[ <a class="bracketButton" href="domains/new">Register a domain</a> ]
|
||||||
|
</center>
|
||||||
|
|
||||||
<% IF domains.size > 0 %>
|
<% IF domains.size > 0 %>
|
||||||
<em>
|
<em>
|
||||||
<% domains.size %>
|
<% domains.size %>
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<center>
|
||||||
|
<br />
|
||||||
|
<h1>Register a domain</h1>
|
||||||
|
<br />
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<% IF error %>
|
||||||
|
<center>
|
||||||
|
<div class="msgBox">
|
||||||
|
<% IF e_no_name %>
|
||||||
|
You did not specify a domain to register.
|
||||||
|
<% END %>
|
||||||
|
<% IF e_exists %>
|
||||||
|
The domain '<% name | html_entity %>.cyb' has already been registered. Please choose a different domain name.
|
||||||
|
<% END %>
|
||||||
|
<% IF e_chars %>
|
||||||
|
The domain '<% name | html_entity %>.cyb' contains invalid characters. Domains must match the regular expression `^[a-z0-9]([a-z0-9\-_]*[a-z0-9])?$`.
|
||||||
|
<% END %>
|
||||||
|
</div>
|
||||||
|
<br /><br />
|
||||||
|
</center>
|
||||||
|
<% END %>
|
||||||
|
|
||||||
|
<%# TODO: a nice AJAX availability checker %>
|
||||||
|
|
||||||
|
<div class="body">
|
||||||
|
Please choose a domain to register:
|
||||||
|
<br /><br />
|
||||||
|
|
||||||
|
<form method="POST" class="login">
|
||||||
|
<input type="text" name="name">.cyb
|
||||||
|
<button action="submit" style="margin-left:20px">Register domain</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
Loading…
Reference in New Issue