mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:11:59 +01:00
added an option to limit message restores
This commit is contained in:
parent
8bde6d145a
commit
c95e1b23e7
@ -159,6 +159,7 @@ $config['RESTRICTED_AUDITOR'] = 0;
|
||||
$config['SHOW_ENVELOPE_JOURNAL'] = 0;
|
||||
$config['BULK_DOWNLOAD_FOR_USERS'] = 1;
|
||||
$config['MAX_DOWNLOAD_PER_HOUR'] = 0;
|
||||
$config['MAX_RESTORE_PER_HOUR'] = 0;
|
||||
|
||||
$config['MAX_CGI_FROM_SUBJ_LEN'] = 34;
|
||||
$config['PAGE_LEN'] = 20;
|
||||
|
@ -40,6 +40,7 @@ class ControllerMessageHeaders extends Controller {
|
||||
$this->data['message'] = $this->model_search_message->get_message_headers($this->data['piler_id']);
|
||||
|
||||
$this->data['can_download'] = $this->model_audit_audit->can_download();
|
||||
$this->data['can_restore'] = $this->model_audit_audit->can_restore();
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class ControllerMessageJournal extends Controller {
|
||||
$this->data['data'] = $this->model_search_message->get_message_journal($this->data['piler_id']);
|
||||
|
||||
$this->data['can_download'] = $this->model_audit_audit->can_download();
|
||||
$this->data['can_restore'] = $this->model_audit_audit->can_restore();
|
||||
|
||||
$this->render();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class ControllerMessageRestore extends Controller {
|
||||
|
||||
$this->load->model('search/search');
|
||||
$this->load->model('search/message');
|
||||
|
||||
$this->load->model('audit/audit');
|
||||
$this->load->model('user/user');
|
||||
$this->load->model('mail/mail');
|
||||
|
||||
@ -38,6 +38,10 @@ class ControllerMessageRestore extends Controller {
|
||||
}
|
||||
|
||||
|
||||
if(!$this->model_audit_audit->can_restore()) {
|
||||
die("cannot restore at the moment");
|
||||
}
|
||||
|
||||
if(!verify_piler_id($this->data['id'])) {
|
||||
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown piler id: ' . $this->data['id']);
|
||||
die("invalid id: " . $this->data['id']);
|
||||
|
@ -81,6 +81,7 @@ class ControllerMessageView extends Controller {
|
||||
$this->data['images'] = array();
|
||||
|
||||
$this->data['can_download'] = $this->model_audit_audit->can_download();
|
||||
$this->data['can_restore'] = $this->model_audit_audit->can_restore();
|
||||
|
||||
foreach($this->data['attachments'] as $a) {
|
||||
if(preg_match("/image/", $a['type'])) {
|
||||
|
@ -171,6 +171,21 @@ class ModelAuditAudit extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function can_restore() {
|
||||
|
||||
if(MAX_RESTORE_PER_HOUR <= 0 || Registry::get('auditor_user') == 1) { return 1; }
|
||||
|
||||
$session = Registry::get('session');
|
||||
|
||||
$email = $session->get("email");
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS num FROM " . TABLE_AUDIT . " WHERE email=? AND ts > ? AND action=?", array($email, NOW-3600, ACTION_RESTORE_MESSAGE));
|
||||
|
||||
if($query->row['num'] <= MAX_RESTORE_PER_HOUR) { return 1; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<?php } ?>
|
||||
<?php if(SMARTHOST || ENABLE_IMAP_AUTH == 1) { if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="$('#restorebox').show();"><i class="icon-reply"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<?php } else if($can_restore == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.restore_message(<?php print $id; ?>);"><i class="icon-reply"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } } ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.view_message(<?php print $id; ?>);"><i class="icon-envelope-alt"></i> <?php print $text_view_message; ?></a>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<?php } ?>
|
||||
<?php if(SMARTHOST || ENABLE_IMAP_AUTH == 1) { if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="$('#restorebox').show();"><i class="icon-reply"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<?php } else if($can_restore == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.restore_message(<?php print $id; ?>);"><i class="icon-reply"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } } ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.view_headers(<?php print $id; ?>);"><i class="icon-envelope-alt"></i> <?php print $text_view_headers; ?></a>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<?php } ?>
|
||||
<?php if(SMARTHOST || ENABLE_IMAP_AUTH == 1) { if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="$('#restorebox').show();"><i class="icon-reply"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<?php } else if($can_restore == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.restore_message(<?php print $id; ?>);"><i class="icon-reply"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } } ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.view_headers(<?php print $id; ?>);"><i class="icon-envelope-alt"></i> <?php print $text_view_headers; ?></a>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<?php } ?>
|
||||
<?php if(SMARTHOST || ENABLE_IMAP_AUTH == 1) { if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="$('#restorebox').show();"><i class="icon-gift"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<?php } else if($can_restore == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.restore_message(<?php print $id; ?>);"><i class="icon-gift"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } } ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.view_message(<?php print $id; ?>);"><i class="icon-envelope"></i> <?php print $text_view_message; ?></a>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<?php } ?>
|
||||
<?php if(SMARTHOST || ENABLE_IMAP_AUTH == 1) { if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="$('#restorebox').show();"><i class="icon-gift"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<?php } else if($can_restore == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.restore_message(<?php print $id; ?>);"><i class="icon-gift"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } } ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.view_headers(<?php print $id; ?>);"><i class="icon-envelope"></i> <?php print $text_view_headers; ?></a> |
|
||||
|
@ -18,7 +18,7 @@
|
||||
<?php } ?>
|
||||
<?php if(SMARTHOST || ENABLE_IMAP_AUTH == 1) { if(Registry::get('auditor_user') == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="$('#restorebox').show();"><i class="icon-gift"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } else { ?>
|
||||
<?php } else if($can_restore == 1) { ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.restore_message(<?php print $id; ?>);"><i class="icon-gift"></i> <?php print $text_restore_to_mailbox; ?></a> |
|
||||
<?php } } ?>
|
||||
<a class="messagelink" href="#" onclick="Piler.view_headers(<?php print $id; ?>);"><i class="icon-envelope"></i> <?php print $text_view_headers; ?></a>
|
||||
|
Loading…
Reference in New Issue
Block a user