smarter verification check in the gui

This commit is contained in:
SJ 2013-10-30 23:40:34 +01:00
parent b8d10ea9e5
commit 25623dda1c
4 changed files with 20 additions and 7 deletions

View File

@ -3,7 +3,7 @@
class ModelSearchMessage extends Model {
public function verify_message($id = '') {
public function verify_message($id = '', $data = '') {
if($id == '') { return 0; }
$q = $this->db->query("SELECT `size`, `hlen`, `digest`, `bodydigest`,`attachments` FROM " . TABLE_META . " WHERE piler_id=?", array($id));
@ -14,13 +14,9 @@ class ModelSearchMessage extends Model {
$hlen = $q->row['hlen'];
$attachments = $q->row['attachments'];
$data = $this->get_raw_message($id);
$_digest = openssl_digest($data, "SHA256");
$_bodydigest = openssl_digest(substr($data, $hlen), "SHA256");
$data = '';
if($_digest == $digest && $_bodydigest == $bodydigest) { return 1; }
return 0;
@ -299,11 +295,17 @@ class ModelSearchMessage extends Model {
$has_text_plain = 0;
$rfc822 = 0;
$_1st_header = 1;
$verification = 1;
$from = $to = $subject = $date = $message = "";
$this->connect_to_pilergetd();
$msg = $this->get_raw_message($id);
if(ENABLE_ON_THE_FLY_VERIFICATION == 0) {
$verification = $this->verify_message($id, $msg);
}
$this->disconnect_from_pilergetd();
$has_journal = $this->remove_journal($msg);
@ -422,7 +424,8 @@ class ModelSearchMessage extends Model {
'subject' => $this->highlight_search_terms($this->decode_my_str($subject), $terms),
'date' => $this->decode_my_str($date),
'message' => $this->highlight_search_terms($message, $terms),
'has_journal' => $has_journal
'has_journal' => $has_journal,
'verification' => $verification
);
}

View File

@ -420,7 +420,9 @@ class ModelSearchSearch extends Model {
*/
if(ENABLE_ON_THE_FLY_VERIFICATION == 1) {
$m['verification'] = $this->model_search_message->verify_message($m['piler_id']);
$data = $this->model_search_message->get_raw_message($m['piler_id']);
$m['verification'] = $this->model_search_message->verify_message($m['piler_id'], $data);
$data = '';
}
if(isset($tag[$m['id']])) { $m['tag'] = $tag[$m['id']]; } else { $m['tag'] = ''; }

View File

@ -23,6 +23,11 @@
<?php if($message['has_journal'] == 1 && Registry::get('auditor_user') == 1 && SHOW_ENVELOPE_JOURNAL == 1) { ?>
| <a class="messagelink" href="#" onclick="Piler.view_journal(<?php print $id; ?>);"><i class="icon-envelope-alt"></i>&nbsp;<?php print $text_view_journal_envelope; ?></a>
<?php } ?>
<?php if(ENABLE_ON_THE_FLY_VERIFICATION == 0) {
if ($message['verification'] == 1) { ?><?php print $text_verified_flag; ?> <i class="verified icon-ok-sign icon-large" title="<?php print $text_verified_flag; ?>"></i><?php } else { ?><?php print $text_unverified_flag; ?> <i class="unverified icon-remove-sign icon-large" title="<?php print $text_unverified_flag; ?>"></i><?php }
} ?>
</p>
<strong><?php if($message['subject'] == "" || $message['subject'] == "Subject:") { print "&lt;" . $text_no_subject . "&gt;"; } else { print $message['subject']; } ?></strong><br />

View File

@ -22,6 +22,9 @@
| <a class="messagelink" href="#" onclick="Piler.view_journal(<?php print $id; ?>);"><i class="icon-envelope"></i>&nbsp;<?php print $text_view_journal_envelope; ?></a>
<?php } ?>
<?php if(ENABLE_ON_THE_FLY_VERIFICATION == 0) {
if ($message['verification'] == 1) { ?><?php print $text_verified_flag; ?> <i class="icon-ok-sign sleek" title="<?php print $text_verified_flag; ?>"></i><?php } else { ?><?php print $text_unverified_flag; ?> <i class="unverified icon-remove-sign sleek" title="<?php print $text_unverified_flag; ?>"></i><?php }
} ?>
</p>