Skip to content

Commit 1d258ee

Browse files
author
Marius Cramer
committed
Merge branch 'ftp-autoexpire' into 'master'
Ftp Autoexpire at specific date
2 parents 9b15585 + 666853a commit 1d258ee

File tree

9 files changed

+28
-10
lines changed

9 files changed

+28
-10
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `ftp_user` ADD `expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `dl_bandwidth` ;

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ CREATE TABLE `ftp_user` (
598598
`dl_ratio` int(11) NOT NULL default '-1',
599599
`ul_bandwidth` int(11) NOT NULL default '-1',
600600
`dl_bandwidth` int(11) NOT NULL default '-1',
601+
`expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
601602
PRIMARY KEY (`ftp_user_id`),
602603
KEY `active` (`active`),
603604
KEY `server_id` (`server_id`),

install/tpl/pureftpd_mysql.conf.master

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ MYSQLCrypt crypt
5959

6060
# Query to execute in order to fetch the password
6161

62-
MYSQLGetPW SELECT password FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L"
62+
MYSQLGetPW SELECT password FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
6363

6464

6565
# Query to execute in order to fetch the system user name or uid
6666

67-
MYSQLGetUID SELECT uid FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L"
67+
MYSQLGetUID SELECT uid FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
6868

6969

7070
# Optional : default UID - if set this overrides MYSQLGetUID
@@ -74,7 +74,7 @@ MYSQLGetUID SELECT uid FROM ftp_user WHERE active = 'y' AND server_id = '{se
7474

7575
# Query to execute in order to fetch the system user group or gid
7676

77-
MYSQLGetGID SELECT gid FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L"
77+
MYSQLGetGID SELECT gid FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
7878

7979

8080
# Optional : default GID - if set this overrides MYSQLGetGID
@@ -84,34 +84,34 @@ MYSQLGetGID SELECT gid FROM ftp_user WHERE active = 'y' AND server_id = '{se
8484

8585
# Query to execute in order to fetch the home directory
8686

87-
MYSQLGetDir SELECT dir FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L"
87+
MYSQLGetDir SELECT dir FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
8888

8989

9090
# Optional : query to get the maximal number of files
9191
# Pure-FTPd must have been compiled with virtual quotas support.
9292

93-
MySQLGetQTAFS SELECT quota_files FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND quota_files != '-1' AND username="\L"
93+
MySQLGetQTAFS SELECT quota_files FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND quota_files != '-1' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
9494

9595

9696
# Optional : query to get the maximal disk usage (virtual quotas)
9797
# The number should be in Megabytes.
9898
# Pure-FTPd must have been compiled with virtual quotas support.
9999

100-
MySQLGetQTASZ SELECT quota_size FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND quota_size != '-1' AND username="\L"
100+
MySQLGetQTASZ SELECT quota_size FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND quota_size != '-1' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
101101

102102

103103
# Optional : ratios. The server has to be compiled with ratio support.
104104

105-
MySQLGetRatioUL SELECT ul_ratio FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND ul_ratio != '-1' AND username="\L"
106-
MySQLGetRatioDL SELECT dl_ratio FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND dl_ratio != '-1' AND username="\L"
105+
MySQLGetRatioUL SELECT ul_ratio FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND ul_ratio != '-1' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
106+
MySQLGetRatioDL SELECT dl_ratio FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND dl_ratio != '-1' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
107107

108108

109109
# Optional : bandwidth throttling.
110110
# The server has to be compiled with throttling support.
111111
# Values are in KB/s .
112112

113-
MySQLGetBandwidthUL SELECT ul_bandwidth FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND ul_bandwidth != '-1' AND username="\L"
114-
MySQLGetBandwidthDL SELECT dl_bandwidth FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND dl_bandwidth != '-1' AND username="\L"
113+
MySQLGetBandwidthUL SELECT ul_bandwidth FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND ul_bandwidth != '-1' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
114+
MySQLGetBandwidthDL SELECT dl_bandwidth FROM ftp_user WHERE active = 'y' AND server_id = '{server_id}' AND dl_bandwidth != '-1' AND username="\L" AND (expires = "0000-00-00 00:00:00" OR expires > NOW())
115115

116116
# Enable ~ expansion. NEVER ENABLE THIS BLINDLY UNLESS :
117117
# 1) You know what you are doing.

interface/lib/classes/tform_actions.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function onUpdate() {
106106
global $app, $conf;
107107

108108
$this->onBeforeUpdate();
109+
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_before_update', $this);
109110

110111
$ext_where = '';
111112
$sql = $app->tform->getSQL($this->dataRecord, $app->tform->getCurrentTab(), 'UPDATE', $this->id, $ext_where);
@@ -192,6 +193,7 @@ function onInsert() {
192193
global $app, $conf;
193194

194195
$this->onBeforeInsert();
196+
$app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_before_insert', $this);
195197

196198
$ext_where = '';
197199
$sql = $app->tform->getSQL($this->dataRecord, $app->tform->getCurrentTab(), 'INSERT', $this->id, $ext_where);

interface/web/sites/form/ftp_user.tform.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@
273273

274274
}
275275

276+
$form['tabs']['advanced']['fields']['expires'] = array(
277+
'datatype' => 'DATETIME',
278+
'formtype' => 'DATETIME'
279+
);
276280

277281

278282
?>

interface/web/sites/lib/lang/de_ftp_user.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ $wb['generate_password_txt'] = 'Passwort erzeugen';
3131
$wb['repeat_password_txt'] = 'Passwort wiederholen';
3232
$wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.';
3333
$wb['password_match_txt'] = 'Die Passwörter stimmen überein.';
34+
$wb['expires_txt'] = 'Zugang läuft ab';
3435
?>

interface/web/sites/lib/lang/en_ftp_user.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ $wb['generate_password_txt'] = 'Generate Password';
3232
$wb['repeat_password_txt'] = 'Repeat Password';
3333
$wb['password_mismatch_txt'] = 'The passwords do not match.';
3434
$wb['password_match_txt'] = 'The passwords do match.';
35+
$wb['expires_txt'] = 'Expire at';
3536
?>

interface/web/sites/templates/ftp_user_advanced.htm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
3737
<label for="dl_bandwidth">{tmpl_var name='dl_bandwidth_txt'}</label>
3838
<input name="dl_bandwidth" id="dl_bandwidth" value="{tmpl_var name='dl_bandwidth'}" size="7" maxlength="7" type="text" class="textInput formLengthLimit" /><p class="label">kb/s</p>
3939
</div>
40+
<div class="ctrlHolder">
41+
<label for="expires">{tmpl_var name='expires_txt'}</label>
42+
{tmpl_var name='expires'}
43+
</div>
4044
</fieldset>
4145

4246
<input type="hidden" name="id" value="{tmpl_var name='id'}">

interface/web/sites/templates/ftp_user_advanced_client.htm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
99
<label for="dir">{tmpl_var name='dir_txt'}</label>
1010
<input name="dir" id="dir" value="{tmpl_var name='dir'}" size="30" maxlength="255" type="text" class="textInput" />
1111
</div>
12+
<div class="ctrlHolder">
13+
<label for="expires">{tmpl_var name='expires_txt'}</label>
14+
{tmpl_var name='expires'}
15+
</div>
1216
</fieldset>
1317

1418
<input type="hidden" name="id" value="{tmpl_var name='id'}">

0 commit comments

Comments
 (0)