mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 22:41:59 +01:00
added an option to limit message downloads
This commit is contained in:
parent
19b9340868
commit
39468c3877
@ -158,6 +158,7 @@ $config['RESTRICTED_AUDITOR'] = 0;
|
||||
|
||||
$config['SHOW_ENVELOPE_JOURNAL'] = 0;
|
||||
$config['BULK_DOWNLOAD_FOR_USERS'] = 1;
|
||||
$config['MAX_DOWNLOAD_PER_HOUR'] = 0;
|
||||
|
||||
$config['MAX_CGI_FROM_SUBJ_LEN'] = 34;
|
||||
$config['PAGE_LEN'] = 20;
|
||||
|
@ -14,11 +14,14 @@ class ControllerMessageDownload extends Controller {
|
||||
|
||||
$this->load->model('search/search');
|
||||
$this->load->model('search/message');
|
||||
$this->load->model('audit/audit');
|
||||
|
||||
$this->document->title = $this->data['text_message'];
|
||||
|
||||
$this->data['id'] = @$this->request->get['id'];
|
||||
|
||||
if(!$this->model_audit_audit->can_download()) { die("you cannot download at the moment"); }
|
||||
|
||||
if(!verify_piler_id($this->data['id'])) {
|
||||
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
|
||||
die("invalid id: " . $this->data['id']);
|
||||
|
@ -14,7 +14,7 @@ class ControllerMessageHeaders extends Controller {
|
||||
|
||||
$this->load->model('search/search');
|
||||
$this->load->model('search/message');
|
||||
|
||||
$this->load->model('audit/audit');
|
||||
$this->load->model('user/user');
|
||||
|
||||
$this->document->title = $this->data['text_message'];
|
||||
@ -39,6 +39,8 @@ 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->render();
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@ 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->render();
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,8 @@ class ControllerMessageView extends Controller {
|
||||
|
||||
$this->data['images'] = array();
|
||||
|
||||
$this->data['can_download'] = $this->model_audit_audit->can_download();
|
||||
|
||||
foreach($this->data['attachments'] as $a) {
|
||||
if(preg_match("/image/", $a['type'])) {
|
||||
$attachment = $this->model_search_message->get_attachment_by_id($a['id']);
|
||||
|
@ -155,6 +155,22 @@ class ModelAuditAudit extends Model {
|
||||
}
|
||||
|
||||
|
||||
public function can_download() {
|
||||
|
||||
if(MAX_DOWNLOAD_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_DOWNLOAD_MESSAGE));
|
||||
|
||||
if($query->row['num'] <= MAX_DOWNLOAD_PER_HOUR) { return 1; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -13,7 +13,9 @@
|
||||
<div class="messageheader">
|
||||
|
||||
<p>
|
||||
<?php if($can_download == 1) { ?>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><i class="icon-cloud-download"></i> <?php print $text_download_message; ?></a> |
|
||||
<?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 { ?>
|
||||
|
@ -13,7 +13,9 @@
|
||||
<div class="messageheader">
|
||||
|
||||
<p>
|
||||
<?php if($can_download == 1) { ?>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><i class="icon-cloud-download"></i> <?php print $text_download_message; ?></a> |
|
||||
<?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 { ?>
|
||||
|
@ -13,7 +13,9 @@
|
||||
<div class="messageheader">
|
||||
|
||||
<p>
|
||||
<?php if($can_download == 1) { ?>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><i class="icon-cloud-download"></i> <?php print $text_download_message; ?></a> |
|
||||
<?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 { ?>
|
||||
|
@ -11,7 +11,9 @@
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<?php if($can_download == 1) { ?>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><i class="icon-download"></i> <?php print $text_download_message; ?></a> |
|
||||
<?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 { ?>
|
||||
|
@ -11,7 +11,9 @@
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<?php if($can_download == 1) { ?>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><i class="icon-download"></i> <?php print $text_download_message; ?></a> |
|
||||
<?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 { ?>
|
||||
|
@ -13,7 +13,9 @@
|
||||
<div class="messageheader">
|
||||
|
||||
<p>
|
||||
<?php if($can_download == 1) { ?>
|
||||
<a class="messagelink" href="index.php?route=message/download&id=<?php print $id; ?>"><i class="icon-download"></i> <?php print $text_download_message; ?></a> |
|
||||
<?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 { ?>
|
||||
|
Loading…
Reference in New Issue
Block a user