Added quota form/handlers for domain and user
This commit is contained in:
@@ -67,6 +67,8 @@ nobase_dist_pkgdata_DATA = \
|
|||||||
templs/domain-add-handler.html.ep \
|
templs/domain-add-handler.html.ep \
|
||||||
templs/domain-update-form.html.ep \
|
templs/domain-update-form.html.ep \
|
||||||
templs/domain-update-handler.html.ep \
|
templs/domain-update-handler.html.ep \
|
||||||
|
templs/domain-rename-form.html.ep \
|
||||||
|
templs/domain-rename-handler.html.ep \
|
||||||
templs/domain-delete-form.html.ep \
|
templs/domain-delete-form.html.ep \
|
||||||
templs/domain-delete-handler.html.ep \
|
templs/domain-delete-handler.html.ep \
|
||||||
\
|
\
|
||||||
|
|||||||
@@ -330,6 +330,8 @@ nobase_dist_pkgdata_DATA = \
|
|||||||
templs/domain-add-handler.html.ep \
|
templs/domain-add-handler.html.ep \
|
||||||
templs/domain-update-form.html.ep \
|
templs/domain-update-form.html.ep \
|
||||||
templs/domain-update-handler.html.ep \
|
templs/domain-update-handler.html.ep \
|
||||||
|
templs/domain-rename-form.html.ep \
|
||||||
|
templs/domain-rename-handler.html.ep \
|
||||||
templs/domain-delete-form.html.ep \
|
templs/domain-delete-form.html.ep \
|
||||||
templs/domain-delete-handler.html.ep \
|
templs/domain-delete-handler.html.ep \
|
||||||
\
|
\
|
||||||
|
|||||||
20
configure
vendored
20
configure
vendored
@@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.69 for maacom.pl 0.02.
|
# Generated by GNU Autoconf 2.69 for maacom.pl 0.03.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||||
@@ -576,8 +576,8 @@ MAKEFLAGS=
|
|||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='maacom.pl'
|
PACKAGE_NAME='maacom.pl'
|
||||||
PACKAGE_TARNAME='maacom-pl'
|
PACKAGE_TARNAME='maacom-pl'
|
||||||
PACKAGE_VERSION='0.02'
|
PACKAGE_VERSION='0.03'
|
||||||
PACKAGE_STRING='maacom.pl 0.02'
|
PACKAGE_STRING='maacom.pl 0.03'
|
||||||
PACKAGE_BUGREPORT=''
|
PACKAGE_BUGREPORT=''
|
||||||
PACKAGE_URL=''
|
PACKAGE_URL=''
|
||||||
|
|
||||||
@@ -1234,7 +1234,7 @@ if test "$ac_init_help" = "long"; then
|
|||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# Omit some internal or obsolete options to make the list less imposing.
|
||||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures maacom.pl 0.02 to adapt to many kinds of systems.
|
\`configure' configures maacom.pl 0.03 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
@@ -1304,7 +1304,7 @@ fi
|
|||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of maacom.pl 0.02:";;
|
short | recursive ) echo "Configuration of maacom.pl 0.03:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
@@ -1392,7 +1392,7 @@ fi
|
|||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
maacom.pl configure 0.02
|
maacom.pl configure 0.03
|
||||||
generated by GNU Autoconf 2.69
|
generated by GNU Autoconf 2.69
|
||||||
|
|
||||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||||
@@ -1409,7 +1409,7 @@ cat >config.log <<_ACEOF
|
|||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by maacom.pl $as_me 0.02, which was
|
It was created by maacom.pl $as_me 0.03, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
@@ -2272,7 +2272,7 @@ fi
|
|||||||
|
|
||||||
# Define the identity of the package.
|
# Define the identity of the package.
|
||||||
PACKAGE='maacom-pl'
|
PACKAGE='maacom-pl'
|
||||||
VERSION='0.02'
|
VERSION='0.03'
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
@@ -3455,7 +3455,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
ac_log="
|
||||||
This file was extended by maacom.pl $as_me 0.02, which was
|
This file was extended by maacom.pl $as_me 0.03, which was
|
||||||
generated by GNU Autoconf 2.69. Invocation command line was
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
@@ -3508,7 +3508,7 @@ _ACEOF
|
|||||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
maacom.pl config.status 0.02
|
maacom.pl config.status 0.03
|
||||||
configured by $0, generated by GNU Autoconf 2.69,
|
configured by $0, generated by GNU Autoconf 2.69,
|
||||||
with options \\"\$ac_cs_config\\"
|
with options \\"\$ac_cs_config\\"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT(maacom.pl,0.02)
|
AC_INIT(maacom.pl,0.03)
|
||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
AC_PREFIX_DEFAULT(/usr/local)
|
AC_PREFIX_DEFAULT(/usr/local)
|
||||||
|
|
||||||
|
|||||||
30
maacom.pl
30
maacom.pl
@@ -284,11 +284,13 @@ sub domain_nextid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub domain_add {
|
sub domain_add {
|
||||||
my ($self, $name) = @_;
|
my ($self, $name, $quota) = @_;
|
||||||
return undef unless $name;
|
return undef unless $name;
|
||||||
return undef if $self->domain_exist($name);
|
return undef if $self->domain_exist($name);
|
||||||
|
$quota ||= 1024*1024;
|
||||||
my $next_id = $self->domain_nextid;
|
my $next_id = $self->domain_nextid;
|
||||||
$self->db->do("insert into domains (id, name) values ($next_id, '$name')");
|
|
||||||
|
$self->db->do("insert into domains (id, name, quota) values ($next_id, '$name', $quota)");
|
||||||
$self->domain_exist($name);
|
$self->domain_exist($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,8 +306,10 @@ sub domain_update {
|
|||||||
return undef unless $prof;
|
return undef unless $prof;
|
||||||
|
|
||||||
my $name = $args{name} || $prof->{name};
|
my $name = $args{name} || $prof->{name};
|
||||||
my $quota = $args{quota} || $prof->{quota};
|
my $quota = $args{quota}*1;
|
||||||
|
$quota ||= $prof->{quota};
|
||||||
my $size = $prof->{size};
|
my $size = $prof->{size};
|
||||||
|
$args{size} ||= -1;
|
||||||
$size = $args{size} if $args{size} >= 0;
|
$size = $args{size} if $args{size} >= 0;
|
||||||
|
|
||||||
$self->db->do("update domains set name = '$name', size = $size, quota = $quota where id = $id");
|
$self->db->do("update domains set name = '$name', size = $size, quota = $quota where id = $id");
|
||||||
@@ -471,7 +475,7 @@ sub user_add {
|
|||||||
return undef unless $name;
|
return undef unless $name;
|
||||||
return undef unless $password;
|
return undef unless $password;
|
||||||
return undef unless $domain_id;
|
return undef unless $domain_id;
|
||||||
$quota ||= 1024*1024*1024*10;
|
$quota ||= 1024*10;
|
||||||
|
|
||||||
return undef if $self->user_exist($name, $domain_id);
|
return undef if $self->user_exist($name, $domain_id);
|
||||||
return undef unless $self->domain_profile($domain_id);
|
return undef unless $self->domain_profile($domain_id);
|
||||||
@@ -479,7 +483,7 @@ sub user_add {
|
|||||||
my $salt = substr(sha512_base64(sprintf("%X", rand(2**31-1))), 4, 16);
|
my $salt = substr(sha512_base64(sprintf("%X", rand(2**31-1))), 4, 16);
|
||||||
my $hash = crypt($password,'$6$'.$salt.'$');
|
my $hash = crypt($password,'$6$'.$salt.'$');
|
||||||
|
|
||||||
$self->db->do("insert into users (id, name, password, domain_id, hash, $quota)
|
$self->db->do("insert into users (id, name, password, domain_id, hash, quota)
|
||||||
values ($next_id, '$name', '$password', $domain_id, '$hash', $quota)");
|
values ($next_id, '$name', '$password', $domain_id, '$hash', $quota)");
|
||||||
$self->user_exist($name, $domain_id);
|
$self->user_exist($name, $domain_id);
|
||||||
}
|
}
|
||||||
@@ -908,6 +912,16 @@ sub domain_update_handler {
|
|||||||
$self->render(template => 'domain-update-handler');
|
$self->render(template => 'domain-update-handler');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub domain_rename_form {
|
||||||
|
my $self = shift;
|
||||||
|
$self->render(template => 'domain-rename-form');
|
||||||
|
}
|
||||||
|
|
||||||
|
sub domain_rename_handler {
|
||||||
|
my $self = shift;
|
||||||
|
$self->render(template => 'domain-rename-handler');
|
||||||
|
}
|
||||||
|
|
||||||
sub domain_delete_form {
|
sub domain_delete_form {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->render(template => 'domain-delete-form');
|
$self->render(template => 'domain-delete-form');
|
||||||
@@ -1248,6 +1262,8 @@ $r->any('/domain/add/form')->over('auth')->to('controller#domain_add_form' );
|
|||||||
$r->any('/domain/add/handler')->over('auth')->to('controller#domain_add_handler' );
|
$r->any('/domain/add/handler')->over('auth')->to('controller#domain_add_handler' );
|
||||||
$r->any('/domain/update/form')->over('auth')->to('controller#domain_update_form' );
|
$r->any('/domain/update/form')->over('auth')->to('controller#domain_update_form' );
|
||||||
$r->any('/domain/update/handler')->over('auth')->to('controller#domain_update_handler' );
|
$r->any('/domain/update/handler')->over('auth')->to('controller#domain_update_handler' );
|
||||||
|
$r->any('/domain/rename/form')->over('auth')->to('controller#domain_rename_form' );
|
||||||
|
$r->any('/domain/rename/handler')->over('auth')->to('controller#domain_rename_handler' );
|
||||||
$r->any('/domain/delete/form')->over('auth')->to('controller#domain_delete_form' );
|
$r->any('/domain/delete/form')->over('auth')->to('controller#domain_delete_form' );
|
||||||
$r->any('/domain/delete/handler')->over('auth')->to('controller#domain_delete_handler' );
|
$r->any('/domain/delete/handler')->over('auth')->to('controller#domain_delete_handler' );
|
||||||
|
|
||||||
@@ -1341,7 +1357,7 @@ $app->log(Mojo::Log->new(
|
|||||||
my $user = $app->config('user');
|
my $user = $app->config('user');
|
||||||
my $group = $app->config('group');
|
my $group = $app->config('group');
|
||||||
my $d = Daemon->new($user, $group);
|
my $d = Daemon->new($user, $group);
|
||||||
#$d->fork;
|
$d->fork;
|
||||||
|
|
||||||
$app->hook(before_dispatch => sub {
|
$app->hook(before_dispatch => sub {
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
@@ -1381,7 +1397,7 @@ sub du {
|
|||||||
$maxdeep ||= 10;
|
$maxdeep ||= 10;
|
||||||
$deep ||= 0;
|
$deep ||= 0;
|
||||||
my $stat = stat($subj);
|
my $stat = stat($subj);
|
||||||
return int($stat->size/1024) if -f $subj;
|
return int($stat->size/(1024*1024)+0.5) if -f $subj;
|
||||||
|
|
||||||
$deep += 1;
|
$deep += 1;
|
||||||
return 0 if $deep > $maxdeep;
|
return 0 if $deep > $maxdeep;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ CREATE TABLE domains (
|
|||||||
id int unique NOT NULL PRIMARY KEY,
|
id int unique NOT NULL PRIMARY KEY,
|
||||||
name text unique,
|
name text unique,
|
||||||
size int DEFAULT 0,
|
size int DEFAULT 0,
|
||||||
quota int DEFAULT 0
|
quota int DEFAULT 1048576
|
||||||
);
|
);
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
id int unique NOT NULL PRIMARY KEY,
|
id int unique NOT NULL PRIMARY KEY,
|
||||||
@@ -12,7 +12,7 @@ CREATE TABLE users (
|
|||||||
password text,
|
password text,
|
||||||
hash text,
|
hash text,
|
||||||
size int DEFAULT 0,
|
size int DEFAULT 0,
|
||||||
quota int DEFAULT 10737418240
|
quota int DEFAULT 10240
|
||||||
);
|
);
|
||||||
CREATE TABLE aliases (
|
CREATE TABLE aliases (
|
||||||
id int unique NOT NULL PRIMARY KEY,
|
id int unique NOT NULL PRIMARY KEY,
|
||||||
|
|||||||
Reference in New Issue
Block a user