From 25623dda1c96c92f1315cf537f34df4eee2dc4a6 Mon Sep 17 00:00:00 2001
From: SJ
Date: Wed, 30 Oct 2013 23:40:34 +0100
Subject: [PATCH] smarter verification check in the gui
---
webui/model/search/message.php | 15 +++++++++------
webui/model/search/search.php | 4 +++-
.../view/theme/default/templates/message/view.tpl | 5 +++++
.../view/theme/mobile/templates/message/view.tpl | 3 +++
4 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/webui/model/search/message.php b/webui/model/search/message.php
index c232cdc7..79962557 100644
--- a/webui/model/search/message.php
+++ b/webui/model/search/message.php
@@ -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
);
}
diff --git a/webui/model/search/search.php b/webui/model/search/search.php
index 22b1e6bc..a4b0c813 100644
--- a/webui/model/search/search.php
+++ b/webui/model/search/search.php
@@ -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'] = ''; }
diff --git a/webui/view/theme/default/templates/message/view.tpl b/webui/view/theme/default/templates/message/view.tpl
index 28cd0ba1..ec54a66e 100644
--- a/webui/view/theme/default/templates/message/view.tpl
+++ b/webui/view/theme/default/templates/message/view.tpl
@@ -23,6 +23,11 @@
|
+
+
+
diff --git a/webui/view/theme/mobile/templates/message/view.tpl b/webui/view/theme/mobile/templates/message/view.tpl
index 0d07e058..49b8d528 100644
--- a/webui/view/theme/mobile/templates/message/view.tpl
+++ b/webui/view/theme/mobile/templates/message/view.tpl
@@ -22,6 +22,9 @@
|
+