Indentation cleanup (switch to tabs)

This commit is contained in:
Al Beano 2017-08-19 23:45:25 +01:00
parent f3632b24ca
commit f97a931d13
29 changed files with 1211 additions and 1211 deletions

View File

@ -9,8 +9,8 @@ use cyberman;
use Plack::Builder; use Plack::Builder;
builder { builder {
enable "Deflater"; enable "Deflater";
enable "Session"; enable "Session";
enable "CSRFBlock"; enable "CSRFBlock";
cyberman->to_app; cyberman->to_app;
} }

View File

@ -37,12 +37,12 @@ say $out <<'END';
END END
if ($conf->{"include"}->{"enabled"}) { if ($conf->{"include"}->{"enabled"}) {
say $out "\$INCLUDE $conf->{include}->{file}"; say $out "\$INCLUDE $conf->{include}->{file}";
} }
# Time to get the records # Time to get the records
die "Unsupported database!" die "Unsupported database!"
unless $yml->[0]->{"plugins"}->{"Database"}->{"driver"} eq "SQLite"; unless $yml->[0]->{"plugins"}->{"Database"}->{"driver"} eq "SQLite";
my $dbfile = "$Bin/../$yml->[0]->{plugins}->{Database}->{dbname}"; my $dbfile = "$Bin/../$yml->[0]->{plugins}->{Database}->{dbname}";
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", ""); my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", "");
@ -50,24 +50,24 @@ my $sth = $dbh->prepare("SELECT * FROM record");
$sth->execute; $sth->execute;
while (my $r = $sth->fetchrow_hashref) { while (my $r = $sth->fetchrow_hashref) {
# Look up domain # Look up domain
my $dsth = $dbh->prepare("select * from domain where id=?"); my $dsth = $dbh->prepare("select * from domain where id=?");
$dsth->bind_param(1, $r->{"domainid"}); $dsth->bind_param(1, $r->{"domainid"});
$dsth->execute; $dsth->execute;
my $d = $dsth->fetchrow_hashref; my $d = $dsth->fetchrow_hashref;
# domain name # domain name
if ($r->{"name"} eq '@') { if ($r->{"name"} eq '@') {
print $out $d->{"name"}, " "; print $out $d->{"name"}, " ";
} else { } else {
print $out $r->{"name"}, ".", $d->{"name"}, " "; print $out $r->{"name"}, ".", $d->{"name"}, " ";
} }
# record type # record type
print $out "IN $r->{type} "; print $out "IN $r->{type} ";
# value # value
say $out $r->{value}; say $out $r->{value};
} }
close $out; close $out;

View File

@ -21,6 +21,6 @@ requires "Plack::Middleware::Session" => "0";
requires "Plack::Middleware::CSRFBlock" => "0"; requires "Plack::Middleware::CSRFBlock" => "0";
on "test" => sub { on "test" => sub {
requires "Test::More" => "0"; requires "Test::More" => "0";
requires "HTTP::Request::Common" => "0"; requires "HTTP::Request::Common" => "0";
}; };

View File

@ -1,6 +1,6 @@
create table cyberman ( create table cyberman (
id integer primary key, id integer primary key,
dbrev integer not null dbrev integer not null
); );
insert into cyberman (dbrev) values (2); insert into cyberman (dbrev) values (2);

View File

@ -14,57 +14,57 @@ use cyberman::Forgot;
# Index route, hook and helper functions for authentication # Index route, hook and helper functions for authentication
sub get_auth { sub get_auth {
my $uid = shift; my $uid = shift;
my $token = shift; my $token = shift;
my $result = database->quick_select("session", {"uid" => $uid, "token" => $token}); my $result = database->quick_select("session", {"uid" => $uid, "token" => $token});
if ($result) { if ($result) {
return $uid; return $uid;
} else { } else {
return 0; return 0;
} }
} }
hook 'before' => sub { hook 'before' => sub {
sub cookieval { sub cookieval {
my $name = shift; my $name = shift;
my $cookie = cookie($name); my $cookie = cookie($name);
if ($cookie) { if ($cookie) {
return $cookie->value; return $cookie->value;
} else { } else {
return undef; return undef;
} }
} }
my $uid = cookieval("id");
my $token = cookieval("token");
my $auth = 0;
my $email;
if ($uid && $token) {
$auth = get_auth($uid, $token);
$email = database->quick_lookup(
"user",
{
"id" => $uid,
},
"email",
);
}
var auth => $auth; my $uid = cookieval("id");
var email => $email; my $token = cookieval("token");
var config => config(); my $auth = 0;
my $email;
if ($uid && $token) {
$auth = get_auth($uid, $token);
$email = database->quick_lookup(
"user",
{
"id" => $uid,
},
"email",
);
}
var auth => $auth;
var email => $email;
var config => config();
}; };
get qr{^/(index)?$} => sub { get qr{^/(index)?$} => sub {
if (!vars->{auth}) { if (!vars->{auth}) {
return template 'index'; return template 'index';
} }
template 'redir' => { template 'redir' => {
"redir" => "domains", "redir" => "domains",
}; };
}; };
true; true;

View File

@ -5,29 +5,29 @@ use Dancer2::Plugin::Database;
use cyberman::Helper; use cyberman::Helper;
get '/api/check_availability' => sub { get '/api/check_availability' => sub {
# No auth req'd # No auth req'd
# returns 'y' or 'n' # returns 'y' or 'n'
if (!param("name")) { if (!param("name")) {
return "n"; return "n";
} }
if (!check_name(param "name")) { if (!check_name(param "name")) {
return "n"; return "n";
} }
my $result = database->quick_select( my $result = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
} }
); );
if ($result) { if ($result) {
return "n"; return "n";
} else { } else {
return "y"; return "y";
} }
}; };
true; true;

View File

@ -6,159 +6,159 @@ use URI::Escape;
use cyberman::Helper; use cyberman::Helper;
get '/account' => sub { get '/account' => sub {
return auth_test() if auth_test(); return auth_test() if auth_test();
my $user = database->quick_select( my $user = database->quick_select(
"user", "user",
{ {
"id" => vars->{"auth"}, "id" => vars->{"auth"},
}, },
); );
template 'account' => { template 'account' => {
"user" => $user, "user" => $user,
}; };
}; };
post '/account' => sub { post '/account' => sub {
return auth_test() if auth_test(); return auth_test() if auth_test();
my %errs; my %errs;
my $new_pass = 0; my $new_pass = 0;
my $user = database->quick_select ( my $user = database->quick_select (
"user", "user",
{ {
"id" => vars->{"auth"}, "id" => vars->{"auth"},
} }
); );
if (!param("email")) { if (!param("email")) {
$errs{"e_no_email"} = 1; $errs{"e_no_email"} = 1;
} }
if (param("email") ne $user->{"email"}) { if (param("email") ne $user->{"email"}) {
my $result = database->quick_select ( my $result = database->quick_select (
"user", "user",
{ {
"email" => param("email"), "email" => param("email"),
}, },
); );
if ($result) {
$errs{"e_email_exists"} = 1;
}
}
if (param("password") || param("npassword") || param("npassword2")) { if ($result) {
$new_pass = 1; $errs{"e_email_exists"} = 1;
}
}
my ($o_hash, $o_salt) = hash_password(param("password"), $user->{"salt"}); if (param("password") || param("npassword") || param("npassword2")) {
if ($o_hash ne $user->{"password"}) { $new_pass = 1;
$errs{"e_wrong_pass"} = 1;
}
if (param "npassword" ne param "npassword2") { my ($o_hash, $o_salt) = hash_password(param("password"), $user->{"salt"});
$errs{"e_pass_mismatch"} = 1; if ($o_hash ne $user->{"password"}) {
} elsif (length(param "npassword") < 8) { $errs{"e_wrong_pass"} = 1;
$errs{"e_pass_len"} = 1; }
}
}
if (scalar(keys %errs) != 0) { if (param "npassword" ne param "npassword2") {
return template 'account' => { $errs{"e_pass_mismatch"} = 1;
"user" => $user, } elsif (length(param "npassword") < 8) {
error => 1, $errs{"e_pass_len"} = 1;
%errs, }
}; }
}
if (param("email") ne $user->{"email"}) { if (scalar(keys %errs) != 0) {
my $conftoken = randstring(16); return template 'account' => {
"user" => $user,
error => 1,
%errs,
};
}
database->quick_update ( if (param("email") ne $user->{"email"}) {
"user", my $conftoken = randstring(16);
{
"id" => vars->{"auth"},
},
{
"newemail" => param("email"),
"conftoken" => $conftoken,
},
);
my $email = template 'email/update' => { database->quick_update (
"link" => config->{"mail"}->{"baseurl"} . "/confirm_update?o=" . uri_escape($user->{"email"}) . "&n=" . uri_escape(param "email") . "&t=$conftoken", "user",
}, {
{ "id" => vars->{"auth"},
"layout" => undef, },
}; {
send_email(param("email"), $email); "newemail" => param("email"),
} "conftoken" => $conftoken,
},
);
if ($new_pass) { my $email = template 'email/update' => {
my ($hash, $salt) = hash_password(param "npassword"); "link" => config->{"mail"}->{"baseurl"} . "/confirm_update?o=" . uri_escape($user->{"email"}) . "&n=" . uri_escape(param "email") . "&t=$conftoken",
database->quick_update ( },
"user", {
{ "layout" => undef,
"id" => vars->{"auth"}, };
}, send_email(param("email"), $email);
{ }
"password" => $hash,
"salt" => $salt,
},
);
database->quick_delete ( if ($new_pass) {
"session", my ($hash, $salt) = hash_password(param "npassword");
{ database->quick_update (
"uid" => vars->{"auth"}, "user",
}, {
); "id" => vars->{"auth"},
},
{
"password" => $hash,
"salt" => $salt,
},
);
return template 'redir' => { database->quick_delete (
"redir" => "login?pwchange=1", "session",
}; {
} "uid" => vars->{"auth"},
},
);
$user = database->quick_select ( return template 'redir' => {
"user", "redir" => "login?pwchange=1",
{ };
"id" => vars->{"auth"}, }
},
);
template 'account' => { $user = database->quick_select (
updated => 1, "user",
user => $user, {
}; "id" => vars->{"auth"},
},
);
template 'account' => {
updated => 1,
user => $user,
};
}; };
get '/confirm_update' => sub { get '/confirm_update' => sub {
my $user = database->quick_select( my $user = database->quick_select(
"user", "user",
{ {
"email" => param("o"), "email" => param("o"),
"newemail" => param("n"), "newemail" => param("n"),
"conftoken" => param("t"), "conftoken" => param("t"),
}, },
); );
if (!$user) { if (!$user) {
return "No such user/token!"; return "No such user/token!";
} }
database->quick_update( database->quick_update(
"user", "user",
{ {
"id" => $user->{"id"}, "id" => $user->{"id"},
}, },
{ {
"email" => param("n"), "email" => param("n"),
}, },
); );
template 'confirmed'; template 'confirmed';
}; };
true; true;

View File

@ -10,153 +10,153 @@ use cyberman::Helper;
# Hooks and helper functions for authentication are in cyberman.pm # Hooks and helper functions for authentication are in cyberman.pm
post '/register' => sub { post '/register' => sub {
my %errs; my %errs;
for my $param ("password", "password2", "email") { for my $param ("password", "password2", "email") {
if (!param($param)) { if (!param($param)) {
$errs{"e_no_$param"} = 1; $errs{"e_no_$param"} = 1;
} }
} }
my $result = database->quick_select( my $result = database->quick_select(
"user", "user",
{ {
"email" => param("email"), "email" => param("email"),
}, },
); );
if ($result) { if ($result) {
$errs{"e_email_exists"} = 1; $errs{"e_email_exists"} = 1;
} }
if (!exists $errs{"e_no_password"} || !exists $errs{"e_no_password2"}) { if (!exists $errs{"e_no_password"} || !exists $errs{"e_no_password2"}) {
if (param("password") ne param("password2")) { if (param("password") ne param("password2")) {
$errs{"e_pass_match"} = 1; $errs{"e_pass_match"} = 1;
} }
if (length param("password") < 8) { if (length param("password") < 8) {
$errs{"e_pass_len"} = 1; $errs{"e_pass_len"} = 1;
} }
} }
if (scalar(keys(%errs)) != 0) { if (scalar(keys(%errs)) != 0) {
return template 'register' => { return template 'register' => {
error => 1, error => 1,
%errs, %errs,
}; };
} }
my ($hash, $salt) = hash_password(param("password")); my ($hash, $salt) = hash_password(param("password"));
my $conftoken = randstring(16); my $conftoken = randstring(16);
# Create the account in the database # Create the account in the database
database->quick_insert( database->quick_insert(
"user", "user",
{ {
"email" => param("email"), "email" => param("email"),
"password" => $hash, "password" => $hash,
"salt" => $salt, "salt" => $salt,
"conftoken" => $conftoken, "conftoken" => $conftoken,
}, },
); );
# Send email # Send email
my $email = template 'email/registration' => { my $email = template 'email/registration' => {
"link" => config->{"mail"}->{"baseurl"} . "/confirm_new?e=" . uri_escape(param "email") . "&t=$conftoken", "link" => config->{"mail"}->{"baseurl"} . "/confirm_new?e=" . uri_escape(param "email") . "&t=$conftoken",
}, },
{ {
"layout" => undef, "layout" => undef,
}; };
send_email(param("email"), $email); send_email(param("email"), $email);
template 'login' => { template 'login' => {
account_created => 1, account_created => 1,
}; };
}; };
post '/login' => sub { post '/login' => sub {
my %errs; my %errs;
my $user = database->quick_select( my $user = database->quick_select(
"user", "user",
{ {
"email" => param("email"), "email" => param("email"),
}, },
); );
if (!$user) { if (!$user) {
$errs{"e_no_user"} = 1; $errs{"e_no_user"} = 1;
} }
if (scalar(keys(%errs)) == 0) { if (scalar(keys(%errs)) == 0) {
my ($hash, $salt) = hash_password(param("password"), $user->{"salt"}); my ($hash, $salt) = hash_password(param("password"), $user->{"salt"});
$errs{"e_pass"} = 1 unless $hash eq $user->{"password"}; $errs{"e_pass"} = 1 unless $hash eq $user->{"password"};
} }
if (scalar(keys(%errs)) == 0) { if (scalar(keys(%errs)) == 0) {
$errs{"e_not_confirmed"} = 1 unless $user->{"active"}; $errs{"e_not_confirmed"} = 1 unless $user->{"active"};
} }
if (scalar(keys(%errs)) != 0) { if (scalar(keys(%errs)) != 0) {
return template 'login' => { return template 'login' => {
error => 1, error => 1,
%errs, %errs,
}; };
} }
# checks finished, we can create a session now # checks finished, we can create a session now
my $token = randstring(32); my $token = randstring(32);
database->quick_insert( database->quick_insert(
"session", "session",
{ {
"token" => $token, "token" => $token,
"uid" => $user->{"id"}, "uid" => $user->{"id"},
"since" => time, "since" => time,
}, },
); );
cookie id => $user->{"id"}, http_only => 1; cookie id => $user->{"id"}, http_only => 1;
cookie token => $token, http_only => 1; cookie token => $token, http_only => 1;
template 'redir' => { template 'redir' => {
"redir" => "domains", "redir" => "domains",
}; };
}; };
get '/confirm_new' => sub { get '/confirm_new' => sub {
my $user = database->quick_select( my $user = database->quick_select(
"user", "user",
{ {
"email" => param("e"), "email" => param("e"),
"conftoken" => param("t"), "conftoken" => param("t"),
}, },
); );
if (!$user) { if (!$user) {
return "No such user/token!"; return "No such user/token!";
} }
database->quick_update( database->quick_update(
"user", "user",
{ {
"id" => $user->{"id"}, "id" => $user->{"id"},
}, },
{ {
"active" => 1, "active" => 1,
}, },
); );
template 'confirmed'; template 'confirmed';
}; };
post '/logout' => sub { post '/logout' => sub {
cookie 'id' => undef; cookie 'id' => undef;
cookie 'token' => undef; cookie 'token' => undef;
template 'redir' => { template 'redir' => {
"redir" => "index", "redir" => "index",
}; };
}; };
true; true;

View File

@ -6,118 +6,118 @@ use Dancer2::Plugin::Database;
use cyberman::Helper; use cyberman::Helper;
get '/domains' => sub { get '/domains' => sub {
return auth_test() if auth_test(); return auth_test() if auth_test();
my @domains = database->quick_select( my @domains = database->quick_select(
"domain", "domain",
{ {
"ownerid" => vars->{"auth"}, "ownerid" => vars->{"auth"},
}, },
); );
template 'domains' => { template 'domains' => {
"domains" => \@domains, "domains" => \@domains,
} }
}; };
post '/domains/new' => sub { post '/domains/new' => sub {
return auth_test() if auth_test(); return auth_test() if auth_test();
my %errs; my %errs;
if (!param("name")) { if (!param("name")) {
$errs{"e_no_name"} = 1; $errs{"e_no_name"} = 1;
} }
my $name = lc param("name"); my $name = lc param("name");
if (scalar(keys(%errs)) == 0) { if (scalar(keys(%errs)) == 0) {
if (!check_name(param "name")) { if (!check_name(param "name")) {
$errs{"e_chars"} = 1; $errs{"e_chars"} = 1;
} }
} }
if (scalar(keys(%errs)) == 0) { if (scalar(keys(%errs)) == 0) {
my $result = database->quick_select( my $result = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
if ($result) { if ($result) {
$errs{"e_exists"} = 1; $errs{"e_exists"} = 1;
} }
} }
if (scalar(keys(%errs)) == 0) { if (scalar(keys(%errs)) == 0) {
foreach my $disallowed (@{ config->{"reserved_domains"} }) { foreach my $disallowed (@{ config->{"reserved_domains"} }) {
if ($name eq $disallowed) { if ($name eq $disallowed) {
$errs{"e_reserved"} = 1; $errs{"e_reserved"} = 1;
} }
} }
} }
if (scalar(keys(%errs)) != 0) { if (scalar(keys(%errs)) != 0) {
return template 'domains/new' => { return template 'domains/new' => {
%errs, %errs,
error => 1, error => 1,
}; };
} }
database->quick_insert( database->quick_insert(
"domain", "domain",
{ {
"name" => $name, "name" => $name,
"ownerid" => vars->{"auth"}, "ownerid" => vars->{"auth"},
}, },
); );
template 'redir' => { template 'redir' => {
"redir" => "../domains?new=$name", "redir" => "../domains?new=$name",
}; };
}; };
get '/domains/:name/remove' => sub { get '/domains/:name/remove' => sub {
my $domain = database->quick_select( my $domain = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"}); return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"});
template 'domains/remove.tt' => { template 'domains/remove.tt' => {
"domain" => $domain, "domain" => $domain,
}; };
}; };
post '/domains/:name/remove' => sub { post '/domains/:name/remove' => sub {
my $domain = database->quick_select( my $domain = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
if (!$domain) { if (!$domain) {
# quick and dirty error that shouldn't really appear # quick and dirty error that shouldn't really appear
return "No such domain!"; return "No such domain!";
} }
return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"}); return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"});
database->quick_delete( database->quick_delete(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
template redir => { template redir => {
redir => "../../domains?removed=$domain->{name}", redir => "../../domains?removed=$domain->{name}",
}; };
}; };
true; true;

View File

@ -7,111 +7,111 @@ use URI::Escape;
use cyberman::Helper; use cyberman::Helper;
post '/forgot' => sub { post '/forgot' => sub {
my $user = database->quick_select( my $user = database->quick_select(
"user", "user",
{ {
"email" => param("email"), "email" => param("email"),
}, },
); );
if (!$user) { if (!$user) {
return template 'forgot' => { return template 'forgot' => {
err => 1, err => 1,
e_no_user => 1, e_no_user => 1,
}; };
} }
my $token = randstring(32); my $token = randstring(32);
database->quick_update( database->quick_update(
"user", "user",
{ {
"id" => $user->{"id"}, "id" => $user->{"id"},
}, },
{ {
"recoverytoken" => $token, "recoverytoken" => $token,
}, },
); );
my $email = template 'email/forgot' => { my $email = template 'email/forgot' => {
"link" => config->{"mail"}->{"baseurl"} . "/confirm_forgot?e=" . uri_escape(param("email")) . "&t=$token", "link" => config->{"mail"}->{"baseurl"} . "/confirm_forgot?e=" . uri_escape(param("email")) . "&t=$token",
}, },
{ {
"layout" => undef, "layout" => undef,
}; };
send_email(param("email"), $email); send_email(param("email"), $email);
template 'forgot' => { template 'forgot' => {
success => 1, success => 1,
}; };
}; };
post '/confirm_forgot' => sub { post '/confirm_forgot' => sub {
my %errs; my %errs;
if (!param("e") || !param("t")) { if (!param("e") || !param("t")) {
$errs{"e_bad_link"} = 1; $errs{"e_bad_link"} = 1;
} elsif (!param("password")) { } elsif (!param("password")) {
$errs{"e_no_pass"} = 1; $errs{"e_no_pass"} = 1;
} elsif (length(param("password")) < 8) { } elsif (length(param("password")) < 8) {
$errs{"e_pass_len"} = 1; $errs{"e_pass_len"} = 1;
} elsif (param("password") ne param("password2")) { } elsif (param("password") ne param("password2")) {
$errs{"e_pass_mismatch"} = 1; $errs{"e_pass_mismatch"} = 1;
} }
if (scalar(keys(%errs)) == 0) { if (scalar(keys(%errs)) == 0) {
my $user = database->quick_select( my $user = database->quick_select(
"user", "user",
{ {
"email" => param("e"), "email" => param("e"),
"recoverytoken" => param("t"), "recoverytoken" => param("t"),
}, },
); );
if (!$user) { if (!$user) {
$errs{"e_bad_link"} = 1; $errs{"e_bad_link"} = 1;
} else { } else {
# Update the password # Update the password
my ($hash, $salt) = hash_password(param "password"); my ($hash, $salt) = hash_password(param "password");
database->quick_update( database->quick_update(
"user", "user",
{ {
"id" => $user->{"id"}, "id" => $user->{"id"},
}, },
{ {
"password" => $hash, "password" => $hash,
"salt" => $salt, "salt" => $salt,
}, },
); );
database->quick_delete( database->quick_delete(
"session", "session",
{ {
"uid" => $user->{"id"}, "uid" => $user->{"id"},
}, },
); );
database->quick_update( database->quick_update(
"user", "user",
{ {
"id" => $user->{"id"}, "id" => $user->{"id"},
}, },
{ {
"recoverytoken" => "", "recoverytoken" => "",
}, },
); );
} }
} }
if (scalar(keys(%errs)) != 0) { if (scalar(keys(%errs)) != 0) {
return template 'confirm_forgot' => { return template 'confirm_forgot' => {
"err" => 1, "err" => 1,
%errs, %errs,
}; };
} }
template 'redir' => { template 'redir' => {
"redir" => "login?pwchange=1", "redir" => "login?pwchange=1",
}; };
}; };
true; true;

View File

@ -15,80 +15,80 @@ our @EXPORT = qw(auth_test randstring hash_password check_name send_email);
# Helper functions # Helper functions
sub auth_test { sub auth_test {
my $id = undef; my $id = undef;
if (@_) { if (@_) {
$id = shift; $id = shift;
} }
if (!vars->{"auth"}) { if (!vars->{"auth"}) {
return template 'redir' => { return template 'redir' => {
"redir" => "/index", "redir" => "/index",
}; };
} elsif ($id && vars->{"auth"} != $id) { } elsif ($id && vars->{"auth"} != $id) {
return template 'redir' => { return template 'redir' => {
"redir" => "/index", "redir" => "/index",
}; };
} else { } else {
return 0; # nothing to be returned, route can continue return 0; # nothing to be returned, route can continue
} }
} }
sub randstring { sub randstring {
my $len = shift; my $len = shift;
my @chars = (0..9, "a".."z", "A".."Z"); my @chars = (0..9, "a".."z", "A".."Z");
my $ret; my $ret;
for (1..$len) { for (1..$len) {
$ret .= $chars[irand(scalar(@chars))]; $ret .= $chars[irand(scalar(@chars))];
} }
return $ret; return $ret;
} }
sub hash_password { sub hash_password {
my $plaintext = shift; my $plaintext = shift;
my $salt; my $salt;
if (scalar(@_) > 0) { if (scalar(@_) > 0) {
$salt = shift; $salt = shift;
} else { } else {
$salt = randstring(16); $salt = randstring(16);
} }
my $b = new Digest::Bcrypt; my $b = new Digest::Bcrypt;
$b->cost(8); $b->cost(8);
$b->salt($salt); $b->salt($salt);
$b->add($plaintext); $b->add($plaintext);
return ($b->bcrypt_b64digest, $salt); return ($b->bcrypt_b64digest, $salt);
} }
sub check_name { sub check_name {
my $name = shift; my $name = shift;
if ($name =~ m/^[a-z0-9]([a-z0-9\-_]*[a-z0-9])?$/) { if ($name =~ m/^[a-z0-9]([a-z0-9\-_]*[a-z0-9])?$/) {
return 1; return 1;
} else { } else {
return 0; return 0;
} }
} }
sub send_email { sub send_email {
my $addy = shift; my $addy = shift;
my $body = shift; my $body = shift;
# TODO: this function is quick and dirty to get this # TODO: this function is quick and dirty to get this
# online - it needs to be rewritten so it doesn't block the thread!! # online - it needs to be rewritten so it doesn't block the thread!!
my $email = Email::Simple->create( my $email = Email::Simple->create(
header => [ header => [
To => $addy, To => $addy,
From => config->{"mail"}->{"from"}, From => config->{"mail"}->{"from"},
Subject => "Confirm your email address", Subject => "Confirm your email address",
], ],
body => $body, body => $body,
); );
sendmail($email) if config->{"mail"}->{"enabled"}; sendmail($email) if config->{"mail"}->{"enabled"};
} }
1; 1;

View File

@ -7,168 +7,168 @@ use Switch;
use cyberman::Helper; use cyberman::Helper;
get '/domains/:name/records' => sub { get '/domains/:name/records' => sub {
my $domain = database->quick_select( my $domain = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
if (!$domain) { if (!$domain) {
return "No such domain!"; return "No such domain!";
} }
return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"}); return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"});
my @records = database->quick_select( my @records = database->quick_select(
"record", "record",
{ {
"domainid" => $domain->{"id"}, "domainid" => $domain->{"id"},
}, },
); );
template 'records' => { template 'records' => {
domain => $domain, domain => $domain,
records => \@records, records => \@records,
}; };
}; };
get '/domains/:name/records/add' => sub { get '/domains/:name/records/add' => sub {
my $domain = database->quick_select( my $domain = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
if (!$domain) { if (!$domain) {
return "No such domain!"; return "No such domain!";
} }
return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"}); return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"});
template 'records/add' => { template 'records/add' => {
domain => $domain, domain => $domain,
}; };
}; };
post '/domains/:name/records/add' => sub { post '/domains/:name/records/add' => sub {
my $domain = database->quick_select( my $domain = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
if (!$domain) { if (!$domain) {
return "No such domain!"; return "No such domain!";
} }
return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"}); return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"});
my %errs; my %errs;
# tw overuse of regex # tw overuse of regex
switch (param("type")) { switch (param("type")) {
case "A" { case "A" {
if (param("value") !~ m/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}$/) { if (param("value") !~ m/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}$/) {
# here we go... # here we go...
$errs{"e_bad_value"} = 1; $errs{"e_bad_value"} = 1;
} }
} }
case "AAAA" { case "AAAA" {
if (param("value") !~ m/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/) { if (param("value") !~ m/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/) {
# I am sorry # I am sorry
$errs{"e_bad_value"} = 1; $errs{"e_bad_value"} = 1;
} }
} }
case "NS" { case "NS" {
if (param("value") !~ m/^([a-zA-Z0-9]([a-zA-Z0-9-_]*[a-zA-Z0-9])?\.)+$/) { if (param("value") !~ m/^([a-zA-Z0-9]([a-zA-Z0-9-_]*[a-zA-Z0-9])?\.)+$/) {
$errs{"e_bad_value"} = 1; $errs{"e_bad_value"} = 1;
} }
} }
else { else {
$errs{"e_bad_type"} = 1; $errs{"e_bad_type"} = 1;
} }
} }
if (param("rname") !~ m/^(@|([a-zA-Z0-9]([a-zA-Z0-9-_]*[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9-_]*[a-zA-Z0-9])?)$/) { if (param("rname") !~ m/^(@|([a-zA-Z0-9]([a-zA-Z0-9-_]*[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9-_]*[a-zA-Z0-9])?)$/) {
$errs{"e_bad_name"} = 1; $errs{"e_bad_name"} = 1;
} }
if (scalar(keys(%errs)) != 0) { if (scalar(keys(%errs)) != 0) {
return template 'records/add' => { return template 'records/add' => {
domain => $domain, domain => $domain,
%errs, %errs,
error => 1, error => 1,
}; };
} }
my $sid = $domain->{"lastsid"} + 1; my $sid = $domain->{"lastsid"} + 1;
database->quick_update( database->quick_update(
"domain", "domain",
{ {
"id" => $domain->{"id"}, "id" => $domain->{"id"},
}, },
{ {
"lastsid" => $sid, "lastsid" => $sid,
}, },
); );
database->quick_insert( database->quick_insert(
"record", "record",
{ {
"sid" => $sid, "sid" => $sid,
"domainid" => $domain->{"id"}, "domainid" => $domain->{"id"},
"type" => param("type"), "type" => param("type"),
"name" => param("rname"), "name" => param("rname"),
"value" => param("value"), "value" => param("value"),
}, },
); );
template 'redir' => { template 'redir' => {
"redir" => "../records?added=1", "redir" => "../records?added=1",
}; };
}; };
post '/domains/:name/records/:sid/remove' => sub { post '/domains/:name/records/:sid/remove' => sub {
my $domain = database->quick_select( my $domain = database->quick_select(
"domain", "domain",
{ {
"name" => param("name"), "name" => param("name"),
}, },
); );
if (!$domain) { if (!$domain) {
return "No such domain!"; return "No such domain!";
} }
return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"}); return auth_test($domain->{"ownerid"}) if auth_test($domain->{"ownerid"});
my $record = database->quick_select( my $record = database->quick_select(
"record", "record",
{ {
"domainid" => $domain->{"id"}, "domainid" => $domain->{"id"},
"sid" => param("sid"), "sid" => param("sid"),
}, },
); );
if (!$record) { if (!$record) {
return "No such record!"; return "No such record!";
} }
database->quick_delete( database->quick_delete(
"record", "record",
{ {
"domainid" => $domain->{"id"}, "domainid" => $domain->{"id"},
"sid" => param("sid"), "sid" => param("sid"),
}, },
); );
template 'redir' => { template 'redir' => {
"redir" => "../../records?removed=1", "redir" => "../../records?removed=1",
}; };
}; };
true; true;

View File

@ -1,55 +1,55 @@
* { * {
margin: 0; margin: 0;
} }
body, a { body, a {
background-color: black; background-color: black;
font-family: monospace; font-family: monospace;
color: white; color: white;
font-size: 14px; font-size: 14px;
line-height: 1.6em; line-height: 1.6em;
} }
p { p {
margin-bottom: 0.8em; margin-bottom: 0.8em;
} }
.body { .body {
max-width: 700px; max-width: 700px;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
} }
.toolbar { .toolbar {
border: 1px solid white; border: 1px solid white;
} }
a.bracketButton { a.bracketButton {
text-decoration: none; text-decoration: none;
} }
a.bracketButton:hover { a.bracketButton:hover {
text-decoration: underline; text-decoration: underline;
} }
button.textButton { button.textButton {
background: none !important; background: none !important;
color: inherit; color: inherit;
border: none; border: none;
padding: 0 !important; padding: 0 !important;
font: inherit; font: inherit;
cursor: pointer; cursor: pointer;
} }
button.textButton:hover { button.textButton:hover {
text-decoration: underline; text-decoration: underline;
} }
form.login>table>tbody>tr>td>label { form.login>table>tbody>tr>td>label {
margin-right: 10px; margin-right: 10px;
} }
table.domains { table.domains {
width: 100%; width: 100%;
} }
table.domains td:first-child { table.domains td:first-child {
width: 50%; width: 50%;
} }
.msgBox { .msgBox {
border: 1px solid white; border: 1px solid white;
display: inline-block; display: inline-block;
padding: 10px; padding: 10px;
} }

View File

@ -1,23 +1,23 @@
function updateAvailability() { function updateAvailability() {
if (this.responseText === "y") { if (this.responseText === "y") {
document.getElementById("avail").innerHTML = "Available!"; document.getElementById("avail").innerHTML = "Available!";
} else { } else {
document.getElementById("avail").innerHTML = "Not available"; document.getElementById("avail").innerHTML = "Not available";
} }
} }
function checkAvailability() { function checkAvailability() {
var name = document.getElementById("name").value; var name = document.getElementById("name").value;
if (name === "") { if (name === "") {
document.getElementById("avail").innerHTML = ""; document.getElementById("avail").innerHTML = "";
return return
} }
document.getElementById("avail").innerHTML = "Checking availability..."; document.getElementById("avail").innerHTML = "Checking availability...";
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.addEventListener("load", updateAvailability); req.addEventListener("load", updateAvailability);
req.open("GET", "/api/check_availability?name="+encodeURIComponent(name)); req.open("GET", "/api/check_availability?name="+encodeURIComponent(name));
req.send(); req.send();
} }

View File

@ -1,44 +1,44 @@
drop table if exists cyberman; drop table if exists cyberman;
create table cyberman ( create table cyberman (
id integer primary key, id integer primary key,
dbrev integer not null dbrev integer not null
); );
insert into cyberman (dbrev) values (3); insert into cyberman (dbrev) values (3);
drop table if exists user; drop table if exists user;
create table user ( create table user (
id integer primary key, id integer primary key,
email text not null, email text not null,
password text not null, password text not null,
salt text not null, salt text not null,
active integer not null default 0, active integer not null default 0,
conftoken text not null, conftoken text not null,
newemail text, newemail text,
recoverytoken text recoverytoken text
); );
drop table if exists session; drop table if exists session;
create table session ( create table session (
id integer primary key, id integer primary key,
uid integer not null, uid integer not null,
since integer not null, since integer not null,
token text not null token text not null
); );
drop table if exists domain; drop table if exists domain;
create table domain ( create table domain (
id integer primary key, id integer primary key,
name string not null, name string not null,
ownerid integer not null, ownerid integer not null,
lastsid integer not null default 0 lastsid integer not null default 0
); );
drop table if exists record; drop table if exists record;
create table record ( create table record (
id integer primary key, id integer primary key,
sid integer not null, sid integer not null,
domainid integer not null, domainid integer not null,
type string not null, type string not null,
name string not null, name string not null,
value string not null value string not null
); );

View File

@ -1,79 +1,79 @@
<center> <center>
<br /> <br />
<h1>Your Account</h1> <h1>Your Account</h1>
<br /> <br />
<% IF updated %> <% IF updated %>
<div class="msgBox"> <div class="msgBox">
Your account details were updated successfully. If you updated your email address, you need to click the link sent to you before the changes can be applied. Your account details were updated successfully. If you updated your email address, you need to click the link sent to you before the changes can be applied.
</div> </div>
<br /><br /> <br /><br />
<% END %> <% END %>
</center> </center>
<% IF error %> <% IF error %>
<div style="text-align:center"> <div style="text-align:center">
<div class="msgBox" style="text-align:left"> <div class="msgBox" style="text-align:left">
There were some problems with your submission: There were some problems with your submission:
<br /> <br />
<ul> <ul>
<% IF e_no_email %> <% IF e_no_email %>
<li>You need too enter a valid email address.</li> <li>You need too enter a valid email address.</li>
<% END %> <% END %>
<% IF e_wrong_pass %> <% IF e_wrong_pass %>
<li>The password you entered is incorrect.</li> <li>The password you entered is incorrect.</li>
<% END %> <% END %>
<% IF e_pass_mismatch %> <% IF e_pass_mismatch %>
<li>The two passwords you entered do not match.</li> <li>The two passwords you entered do not match.</li>
<% END %> <% END %>
<% IF e_pass_len %> <% IF e_pass_len %>
<li>Your password must be at least 8 characters long.</li> <li>Your password must be at least 8 characters long.</li>
<% END %> <% END %>
<% IF e_email_exists %> <% IF e_email_exists %>
<li>There is already an account with that email address.</li> <li>There is already an account with that email address.</li>
<% END %> <% END %>
</ul> </ul>
</div> </div>
</div> </div>
<br /> <br />
<% END %> <% END %>
<div class="body"> <div class="body">
<form method="POST"> <form method="POST">
<table class="domains"> <table class="domains">
<tr> <tr>
<td> <td>
<label for="email">Email address:</label> <label for="email">Email address:</label>
</td> </td>
<td> <td>
<input type="email" name="email" id="email" value="<% user.email | html_entity %>" /> <input type="email" name="email" id="email" value="<% user.email | html_entity %>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="password">Old password:</label> <label for="password">Old password:</label>
</td> </td>
<td> <td>
<input type="password" name="password" id="password" /> <input type="password" name="password" id="password" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="npassword">New password:</label> <label for="npassword">New password:</label>
</td> </td>
<td> <td>
<input type="password" name="npassword" id="npassword" /> <input type="password" name="npassword" id="npassword" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="npassword2">New password (confirm):</label> <label for="npassword2">New password (confirm):</label>
</td> </td>
<td> <td>
<input type="password" name="npassword2" id="npassword2" /> <input type="password" name="npassword2" id="npassword2" />
</td> </td>
</tr> </tr>
</table> </table>
<br /> <br />
[&nbsp;<button class="textButton" action="submit">update</button>&nbsp;] [&nbsp;<button class="textButton" action="submit">update</button>&nbsp;]
</form> </form>
</div> </div>

View File

@ -1,11 +1,11 @@
<center> <center>
<br /> <br />
<h1>.cyb charter</h1> <h1>.cyb charter</h1>
<br /> <br />
</center> </center>
<div class="body"> <div class="body">
<pre style="white-space:pre-wrap;word-wrap:break-word"> <pre style="white-space:pre-wrap;word-wrap:break-word">
Description Description
- - - - - - - - - - - -
@ -48,5 +48,5 @@ Contacts
* DNS master - hostmaster@opennic.cyb * DNS master - hostmaster@opennic.cyb
* Abuse - abuse@opennic.cyb * Abuse - abuse@opennic.cyb
* Webmaster - webmaster@opennic.cyb * Webmaster - webmaster@opennic.cyb
</pre> </pre>
</div> </div>

View File

@ -1,49 +1,49 @@
<center> <center>
<br /> <br />
<h1>Update your password</h1> <h1>Update your password</h1>
<br /> <br />
<% IF err %> <% IF err %>
<div class="msgBox"> <div class="msgBox">
Error: Error:
<% IF e_bad_link %> <% IF e_bad_link %>
The link you clicked on is invalid! The link you clicked on is invalid!
<% ELSIF e_no_pass %> <% ELSIF e_no_pass %>
You must enter a password. You must enter a password.
<% ELSIF e_pass_len %> <% ELSIF e_pass_len %>
Your password must be at least 8 characters long. Your password must be at least 8 characters long.
<% ELSIF e_pass_mismatch %> <% ELSIF e_pass_mismatch %>
The two passwords you entered do not match. The two passwords you entered do not match.
<% END%> <% END%>
</div> </div>
<br /><br /> <br /><br />
<% END %> <% END %>
</center> </center>
<div class="body"> <div class="body">
Enter a new password and click update. Enter a new password and click update.
<br /> <br />
<form method="POST" class="login" action="confirm_forgot"> <form method="POST" class="login" action="confirm_forgot">
<input type="hidden" name="e" value="<% params.e | html_entity %>" /> <input type="hidden" name="e" value="<% params.e | html_entity %>" />
<input type="hidden" name="t" value="<% params.t | html_entity %>" /> <input type="hidden" name="t" value="<% params.t | html_entity %>" />
<table> <table>
<tr> <tr>
<td> <td>
<label for="password">New password:</label> <label for="password">New password:</label>
</td> </td>
<td> <td>
<input type="password" name="password" id="password" /> <input type="password" name="password" id="password" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="password2">New password (confirm):</label> <label for="password2">New password (confirm):</label>
</td> </td>
<td> <td>
<input type="password" name="password2" id="password2" /> <input type="password" name="password2" id="password2" />
</td> </td>
</tr> </tr>
</table> </table>
<br /> <br />
[&nbsp;<button class="textButton" action="submit">update</button>&nbsp;] [&nbsp;<button class="textButton" action="submit">update</button>&nbsp;]
</form> </form>
</div> </div>

View File

@ -1,9 +1,9 @@
<center> <center>
<br /> <br />
<h1>Success</h1> <h1>Success</h1>
<br /> <br />
</center> </center>
<div class="body"> <div class="body">
Your email address was confirmed successfully. Your email address was confirmed successfully.
</div> </div>

View File

@ -1,62 +1,62 @@
<center> <center>
<br /> <br />
<h1>Your Domains</h1> <h1>Your Domains</h1>
<br /> <br />
<% IF params.new %> <% IF params.new %>
<div class="msgBox"> <div class="msgBox">
The domain '<% params.new | html_entity %>.<% vars.config.tld %>' was registered successfully! The domain '<% params.new | html_entity %>.<% vars.config.tld %>' was registered successfully!
</div> </div>
<br /><br /> <br /><br />
<% END %> <% END %>
<% IF params.removed %> <% IF params.removed %>
<div class="msgBox"> <div class="msgBox">
The domain '<% params.removed | html_entity %>.<% vars.config.tld %>' was removed successfully. The domain '<% params.removed | html_entity %>.<% vars.config.tld %>' was removed successfully.
</div> </div>
<br /><br /> <br /><br />
<% END %> <% END %>
</center> </center>
<div class="body"> <div class="body">
<center> <center>
[&nbsp;<a class="bracketButton" href="domains/new">register a domain</a>&nbsp;] [&nbsp;<a class="bracketButton" href="domains/new">register a domain</a>&nbsp;]
</center> </center>
<% IF domains.size > 0 %> <% IF domains.size > 0 %>
<em> <em>
<% domains.size %> <% domains.size %>
<% IF domains.size == 1 %> <% IF domains.size == 1 %>
domain domain
<% ELSE %> <% ELSE %>
domains domains
<% END %> <% END %>
</em> </em>
<br /> <br />
<table class="domains"> <table class="domains">
<tr> <tr>
<td> <td>
<strong>Domain name</strong> <strong>Domain name</strong>
</td> </td>
<td> <td>
<strong>Actions</strong> <strong>Actions</strong>
</td> </td>
</tr> </tr>
<% FOREACH d IN domains %> <% FOREACH d IN domains %>
<tr> <tr>
<td> <td>
<% d.name | html_entity %>.<% vars.config.tld %> <% d.name | html_entity %>.<% vars.config.tld %>
</td> </td>
<td> <td>
[&nbsp;<a class="bracketButton" href="domains/<% d.name %>/records">edit</a>&nbsp;] [&nbsp;<a class="bracketButton" href="domains/<% d.name %>/records">edit</a>&nbsp;]
[&nbsp;<a class="bracketButton" href="domains/<% d.name %>/remove">remove</a>&nbsp;] [&nbsp;<a class="bracketButton" href="domains/<% d.name %>/remove">remove</a>&nbsp;]
</td> </td>
</tr> </tr>
<% END %> <% END %>
</table> </table>
<% ELSE %> <% ELSE %>
You don't have any domains registered. You don't have any domains registered.
<% END %> <% END %>
</div> </div>

View File

@ -1,40 +1,40 @@
<center> <center>
<br /> <br />
<h1>Register a domain</h1> <h1>Register a domain</h1>
<br /> <br />
</center> </center>
<% IF error %> <% IF error %>
<center> <center>
<div class="msgBox"> <div class="msgBox">
<% IF e_no_name %> <% IF e_no_name %>
You did not specify a domain to register. You did not specify a domain to register.
<% END %> <% END %>
<% IF e_exists %> <% IF e_exists %>
The domain '<% params.name | html_entity %>.<% vars.config.tld %>' has already been registered. Please choose a different domain name. The domain '<% params.name | html_entity %>.<% vars.config.tld %>' has already been registered. Please choose a different domain name.
<% END %> <% END %>
<% IF e_chars %> <% IF e_chars %>
The domain '<% params.name | html_entity %>.<% vars.config.tld %>' contains invalid characters. The domain '<% params.name | html_entity %>.<% vars.config.tld %>' contains invalid characters.
<% END %> <% END %>
<% IF e_reserved %> <% IF e_reserved %>
The domain '<% params.name | html_entity %>.<% vars.config.tld %>' is reserved for use by the registry. The domain '<% params.name | html_entity %>.<% vars.config.tld %>' is reserved for use by the registry.
<% END %> <% END %>
</div> </div>
<br /><br /> <br /><br />
</center> </center>
<% END %> <% END %>
<div class="body"> <div class="body">
Please choose a domain to register: Please choose a domain to register:
<br /><br /> <br /><br />
<form method="POST" class="login"> <form method="POST" class="login">
<input type="text" name="name" id="name" onkeyup="checkAvailability()">.<% vars.config.tld %> <input type="text" name="name" id="name" onkeyup="checkAvailability()">.<% vars.config.tld %>
<br /><br /> <br /><br />
[&nbsp;<button action="submit" class="textButton">register&nbsp;domain</button>&nbsp;] [&nbsp;<button action="submit" class="textButton">register&nbsp;domain</button>&nbsp;]
[&nbsp;<a href="../domains" class="bracketButton">go&nbsp;back</a>&nbsp;] [&nbsp;<a href="../domains" class="bracketButton">go&nbsp;back</a>&nbsp;]
</form> </form>
<span id="avail"></span> <span id="avail"></span>
</div> </div>
<script type="text/javascript" src="/js/domain_check.js"></script> <script type="text/javascript" src="/js/domain_check.js"></script>

View File

@ -1,32 +1,32 @@
<% IF domain %> <% IF domain %>
<center> <center>
<br /> <br />
<h1>Removal of <% domain.name %>.<% vars.config.tld %></h1> <h1>Removal of <% domain.name %>.<% vars.config.tld %></h1>
<br /> <br />
</center> </center>
<div class="body"> <div class="body">
<p> <p>
You are about to permanently remove <% domain.name %>.<% vars.config.tld %> and all its records. You are about to permanently remove <% domain.name %>.<% vars.config.tld %> and all its records.
</p> </p>
<p style="font-size:1.6em"> <p style="font-size:1.6em">
YOU ARE ABOUT TO PERMANENTLY REMOVE <% domain.name %>.<% vars.config.tld %> AND ALL ITS RECORDS! YOU ARE ABOUT TO PERMANENTLY REMOVE <% domain.name %>.<% vars.config.tld %> AND ALL ITS RECORDS!
</p> </p>
<p> <p>
There is <strong>no</strong> guarantee that you will be able to re-register this domain at a later date. There is <strong>no</strong> guarantee that you will be able to re-register this domain at a later date.
</p> </p>
<p> <p>
<center> <center>
<form method="POST"> <form method="POST">
[&nbsp;<button class="textButton" action="submit">yes,&nbsp;destroy&nbsp;the&nbsp;domain</button>&nbsp;] [&nbsp;<button class="textButton" action="submit">yes,&nbsp;destroy&nbsp;the&nbsp;domain</button>&nbsp;]
</form> </form>
</center> </center>
</p> </p>
</div> </div>
<% ELSE %> <% ELSE %>
<center> <center>
No such domain! No such domain!
<br /> <br />
[&nbsp;<a href="../../domains" class="bracketButton">go&nbsp;back</a>&nbsp;] [&nbsp;<a href="../../domains" class="bracketButton">go&nbsp;back</a>&nbsp;]
</center> </center>
<% END %> <% END %>

View File

@ -1,27 +1,27 @@
<center> <center>
<br /> <br />
<h1 >Forgotten password</h1> <h1 >Forgotten password</h1>
<br /> <br />
<% IF err || success %> <% IF err || success %>
<div class="msgBox"> <div class="msgBox">
<% IF e_no_user %> <% IF e_no_user %>
Error: There is no user account associated with that email address. Error: There is no user account associated with that email address.
<% END %> <% END %>
<% IF success %> <% IF success %>
An email has been sent to <% params.email | html_entity %>. Please click the link to reset your password. An email has been sent to <% params.email | html_entity %>. Please click the link to reset your password.
<% END %> <% END %>
</div> </div>
<br /><br /> <br /><br />
<% END %> <% END %>
</center> </center>
<div class="body"> <div class="body">
Enter your email into the field below and we'll send an email with a link to reset your password. Enter your email into the field below and we'll send an email with a link to reset your password.
<br /> <br />
<form method="POST"> <form method="POST">
<label for="email">Email address:</label> <label for="email">Email address:</label>
<input type="email" name="email" id="email" value="<% params.email | html_entity %>"/> <input type="email" name="email" id="email" value="<% params.email | html_entity %>"/>
<br /> <br />
[&nbsp;<button action="submit" class="textButton">submit</button>&nbsp;] [&nbsp;<button action="submit" class="textButton">submit</button>&nbsp;]
</form> </form>
</div> </div>

View File

@ -1,15 +1,15 @@
<center> <center>
<br /><br /><br /> <br /><br /><br />
<h1>Welcome to cybNIC</h1> <h1>Welcome to cybNIC</h1>
</center> </center>
<br /> <br />
<div class="body"> <div class="body">
<p>.cyb is a new TLD (top level domain) for anything and everything cyberpunk-related, on the OpenNIC network. To get started, change your computer's DNS settings to use OpenNIC's servers - <a href="https://www.moderntld.com/get-started/">here's how</a>. Registering a .cyb domain is free for everyone.</p> <p>.cyb is a new TLD (top level domain) for anything and everything cyberpunk-related, on the OpenNIC network. To get started, change your computer's DNS settings to use OpenNIC's servers - <a href="https://www.moderntld.com/get-started/">here's how</a>. Registering a .cyb domain is free for everyone.</p>
<p>You can <a href="charter">read our charter</a> for more information and details on how to report abuse of cybNIC services.</p> <p>You can <a href="charter">read our charter</a> for more information and details on how to report abuse of cybNIC services.</p>
<p>Create or log in to an account in order to register or update .cyb domains.</p> <p>Create or log in to an account in order to register or update .cyb domains.</p>
<center> <center>
<p>[&nbsp;<a class="bracketButton" href="login">log&nbsp;in</a>&nbsp;]&nbsp;&nbsp;[&nbsp;<a class="bracketButton" href="register">register</a>&nbsp;]</p> <p>[&nbsp;<a class="bracketButton" href="login">log&nbsp;in</a>&nbsp;]&nbsp;&nbsp;[&nbsp;<a class="bracketButton" href="register">register</a>&nbsp;]</p>
</center> </center>
</div> </div>

View File

@ -1,31 +1,31 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html lang=en> <html lang=en>
<head> <head>
<meta charset="utf8" /> <meta charset="utf8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<% IF redir %> <% IF redir %>
<meta http-equiv="refresh" content="0;<% redir %>" /> <meta http-equiv="refresh" content="0;<% redir %>" />
<% END %> <% END %>
<title>cybNIC</title> <title>cybNIC</title>
<link rel="stylesheet" type="text/css" href="/css/style.css" /> <link rel="stylesheet" type="text/css" href="/css/style.css" />
</head> </head>
<body> <body>
<% IF vars.auth %> <% IF vars.auth %>
<div class="toolbar"> <div class="toolbar">
<div class="body"> <div class="body">
<span> <span>
Logged in as <% vars.email | html_entity %> Logged in as <% vars.email | html_entity %>
</span> </span>
<span style="float:right;"> <span style="float:right;">
<form action="/logout" method="POST"> <form action="/logout" method="POST">
[&nbsp;<a href="/domains" class="bracketButton">domains</a>&nbsp;] [&nbsp;<a href="/domains" class="bracketButton">domains</a>&nbsp;]
[&nbsp;<a href="/account" class="bracketButton">account</a>&nbsp;] [&nbsp;<a href="/account" class="bracketButton">account</a>&nbsp;]
[&nbsp;<button class="textButton" action="submit">log&nbsp;out</button>&nbsp;] [&nbsp;<button class="textButton" action="submit">log&nbsp;out</button>&nbsp;]
</form> </form>
</span> </span>
</div> </div>
</div> </div>
<% END %> <% END %>
<% content %> <% content %>
</body> </body>
</html> </html>

View File

@ -1,63 +1,63 @@
<center> <center>
<br /> <br />
<h1>Log in</h1> <h1>Log in</h1>
<br /> <br />
<% IF account_created %> <% IF account_created %>
<div class="msgBox"> <div class="msgBox">
Your account has been created and a confirmation email sent to <% params.email | html_entity %>. Please confirm your email address, then log in here. Your account has been created and a confirmation email sent to <% params.email | html_entity %>. Please confirm your email address, then log in here.
</div> </div>
<br /><br /> <br /><br />
<% END %> <% END %>
<% IF params.pwchange %>
<div class="msgBox">
Your password has been changed and all browsers logged out. Please log in again here.
</div>
<br /><br />
<% END %>
<% IF error %> <% IF params.pwchange %>
<div class="msgBox"> <div class="msgBox">
<% IF e_no_user %> Your password has been changed and all browsers logged out. Please log in again here.
The email address <% params.email | html_entity %> is not registered. </div>
<% END %> <br /><br />
<% IF e_pass %> <% END %>
Your password was incorrect, sorry.
<% END %> <% IF error %>
<% IF e_not_confirmed %> <div class="msgBox">
Please confirm your email address using the link sent to <% params.email | html_entity %>. <% IF e_no_user %>
<% END %> The email address <% params.email | html_entity %> is not registered.
</div> <% END %>
<br /><br /> <% IF e_pass %>
<% END %> Your password was incorrect, sorry.
<% END %>
<% IF e_not_confirmed %>
Please confirm your email address using the link sent to <% params.email | html_entity %>.
<% END %>
</div>
<br /><br />
<% END %>
</center> </center>
<div class="body"> <div class="body">
<form method=POST class="login" action="login"> <form method=POST class="login" action="login">
<table> <table>
<tr> <tr>
<td> <td>
<label for="email">Email address:</label> <label for="email">Email address:</label>
</td> </td>
<td> <td>
<input type="email" name="email" id="email" /> <input type="email" name="email" id="email" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="password">Password:</label> <label for="password">Password:</label>
</td> </td>
<td> <td>
<input type="password" name="password" id="password" /> <input type="password" name="password" id="password" />
</td> </td>
</tr> </tr>
</table> </table>
<br /> <br />
[&nbsp;<button action="submit" class="textButton">log&nbsp;in</button>&nbsp;] [&nbsp;<button action="submit" class="textButton">log&nbsp;in</button>&nbsp;]
[&nbsp;<a href="index" class="bracketButton">go&nbsp;back</a>&nbsp;] [&nbsp;<a href="index" class="bracketButton">go&nbsp;back</a>&nbsp;]
<br /><br /> <br /><br />
[&nbsp;<a href="forgot" class="bracketButton">recover forgotten password</a>&nbsp;] [&nbsp;<a href="forgot" class="bracketButton">recover forgotten password</a>&nbsp;]
</form> </form>
</div> </div>

View File

@ -1,75 +1,75 @@
<center> <center>
<br /> <br />
<h1>Add a record</h1> <h1>Add a record</h1>
<br /> <br />
</center> </center>
<% IF error %> <% IF error %>
<div style="text-align:center"> <div style="text-align:center">
<div class="msgBox" style="text-align:left"> <div class="msgBox" style="text-align:left">
There were some problems with your submission: There were some problems with your submission:
<br /> <br />
<ul> <ul>
<% IF e_bad_value %> <% IF e_bad_value %>
<li>The value you entered was invalid. <li>The value you entered was invalid.
<% IF params.type == 'NS' %>(Did you forget the trailing '.'?)<% END %></li> <% IF params.type == 'NS' %>(Did you forget the trailing '.'?)<% END %></li>
<% END %> <% END %>
<% IF e_bad_type %> <% IF e_bad_type %>
<li>You must choose a type for the record.</li> <li>You must choose a type for the record.</li>
<% END %> <% END %>
<% IF e_bad_name %> <% IF e_bad_name %>
<li>The name of the record is invalid.</li> <li>The name of the record is invalid.</li>
<% END %> <% END %>
</ul> </ul>
</div> </div>
</div> </div>
<br /> <br />
<% END %> <% END %>
<div class="body"> <div class="body">
<em>Adding a record for <% domain.name | html_entity %>.<% vars.config.tld %></em> <em>Adding a record for <% domain.name | html_entity %>.<% vars.config.tld %></em>
<form method="POST" class="login"> <form method="POST" class="login">
<table class="domains"> <table class="domains">
<tr> <tr>
<td> <td>
<strong> <strong>
<label for="name">Record name:</label> <label for="name">Record name:</label>
</strong> </strong>
</td> </td>
<td> <td>
<input type="text" style="width: 100px" name="rname" id="rname" placeholder="Use @ for root" <input type="text" style="width: 100px" name="rname" id="rname" placeholder="Use @ for root"
value="<% params.rname | html_entity %>" />.<% domain.name | html_entity %>.<% vars.config.tld %> value="<% params.rname | html_entity %>" />.<% domain.name | html_entity %>.<% vars.config.tld %>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<strong> <strong>
<label for="type">Record type:</label> <label for="type">Record type:</label>
</strong> </strong>
</td> </td>
<td> <td>
<select name="type" id="type"> <select name="type" id="type">
<option value="">- Select -</option> <option value="">- Select -</option>
<option value="A">A</option> <option value="A">A</option>
<option value="AAAA">AAAA</option> <option value="AAAA">AAAA</option>
<option value="NS">NS</option> <option value="NS">NS</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<strong> <strong>
<label for="value">Value:</label> <label for="value">Value:</label>
</strong> </strong>
</td> </td>
<td> <td>
<input type="text" name="value" id="value" value="<% params.value | html_entity %>" /> <input type="text" name="value" id="value" value="<% params.value | html_entity %>" />
</td> </td>
</tr> </tr>
</table> </table>
<br /> <br />
[&nbsp;<button action="submit" class="textButton">create&nbsp;record</button>&nbsp;] [&nbsp;<button action="submit" class="textButton">create&nbsp;record</button>&nbsp;]
[&nbsp;<a class="bracketButton" href="../records">go&nbsp;back</a>&nbsp;] [&nbsp;<a class="bracketButton" href="../records">go&nbsp;back</a>&nbsp;]
</form> </form>
</div> </div>

View File

@ -1,3 +1,3 @@
<div class="body"> <div class="body">
Redirecting, please wait. Redirecting, please wait.
</div> </div>

View File

@ -1,71 +1,71 @@
<center> <center>
<br /> <br />
<h1>Register</h1> <h1>Register</h1>
<br /> <br />
</center> </center>
<% IF error %> <% IF error %>
<div style="text-align:center"> <div style="text-align:center">
<div class="msgBox" style="text-align:left"> <div class="msgBox" style="text-align:left">
There were some problems with your registration: There were some problems with your registration:
<br /> <br />
<ul> <ul>
<% IF e_no_email %> <% IF e_no_email %>
<li>You need to enter a valid email address.</li> <li>You need to enter a valid email address.</li>
<% END %> <% END %>
<% IF e_no_password %> <% IF e_no_password %>
<li>You need to enter a password.</li> <li>You need to enter a password.</li>
<% END %> <% END %>
<% IF e_pass_len %> <% IF e_pass_len %>
<li>Your password must be at least 8 characters!</li> <li>Your password must be at least 8 characters!</li>
<% END %> <% END %>
<% IF e_no_password2 %> <% IF e_no_password2 %>
<li>You need to enter a password confirmation.</li> <li>You need to enter a password confirmation.</li>
<% END %> <% END %>
<% IF e_pass_match %> <% IF e_pass_match %>
<li>The two passwords you entered do not match!</li> <li>The two passwords you entered do not match!</li>
<% END %> <% END %>
<% IF e_email_exists %> <% IF e_email_exists %>
<li>There is already an account with that email address.</li> <li>There is already an account with that email address.</li>
<% END %> <% END %>
</ul> </ul>
</div> </div>
</div> </div>
<br /> <br />
<% END %> <% END %>
<div class="body"> <div class="body">
<form class="login" method="POST" action="register"> <form class="login" method="POST" action="register">
<table> <table>
<tr> <tr>
<td> <td>
<label for="email">Email address:</label> <label for="email">Email address:</label>
</td> </td>
<td> <td>
<input type="email" name="email" id="email" value="<% params.email | html_entity %>" /> <input type="email" name="email" id="email" value="<% params.email | html_entity %>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="password">Password:</label> <label for="password">Password:</label>
</td> </td>
<td> <td>
<input type="password" name="password" id="password" value="<% params.password | html_entity %>" /> <input type="password" name="password" id="password" value="<% params.password | html_entity %>" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="password2">Confirm password:</label> <label for="password2">Confirm password:</label>
</td> </td>
<td> <td>
<input type="password" name="password2" id="password2" value="<% params.password2 | html_entity %>" /> <input type="password" name="password2" id="password2" value="<% params.password2 | html_entity %>" />
</td> </td>
</tr> </tr>
</table> </table>
<br /> <br />
[&nbsp;<button action="submit" class="textButton">register</button>&nbsp;] [&nbsp;<button action="submit" class="textButton">register</button>&nbsp;]
[&nbsp;<a href="index" class="bracketButton">go&nbsp;back</a>&nbsp;] [&nbsp;<a href="index" class="bracketButton">go&nbsp;back</a>&nbsp;]
<br /><br /> <br /><br />
<em>By registering, you agree to be bound by the policies set forward in our <a href="charter">charter</a>.</em> <em>By registering, you agree to be bound by the policies set forward in our <a href="charter">charter</a>.</em>
</form> </form>
</div> </div>