From eccfeed034824cd659a5a175ba4246718f3ba03c Mon Sep 17 00:00:00 2001 From: alec Date: Sat, 2 Jul 2011 12:15:20 +0000 Subject: - Add file_get_contents() result check (#1487932) git-svn-id: https://svn.roundcube.net/trunk@4900 208e9e7b-5314-0410-a742-e7e81cd9613c --- .../database_attachments/database_attachments.php | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'plugins/database_attachments/database_attachments.php') diff --git a/plugins/database_attachments/database_attachments.php b/plugins/database_attachments/database_attachments.php index 970a36754..32461cff6 100644 --- a/plugins/database_attachments/database_attachments.php +++ b/plugins/database_attachments/database_attachments.php @@ -36,7 +36,13 @@ class database_attachments extends filesystem_attachments $args['status'] = false; $rcmail = rcmail::get_instance(); $key = $this->_key($args); - $data = base64_encode(file_get_contents($args['path'])); + + $data = file_get_contents($args['path']); + + if ($data === false) + return $args; + + $data = base64_encode($data); $status = $rcmail->db->query( "INSERT INTO ".get_table_name('cache')." @@ -45,13 +51,13 @@ class database_attachments extends filesystem_attachments $_SESSION['user_id'], $key, $data); - + if ($status) { $args['id'] = $key; $args['status'] = true; unset($args['path']); } - + return $args; } @@ -65,8 +71,12 @@ class database_attachments extends filesystem_attachments $key = $this->_key($args); - if ($args['path']) - $args['data'] = file_get_contents($args['path']); + if ($args['path']) { + $args['data'] = file_get_contents($args['path']); + + if ($args['data'] === false) + return $args; + } $data = base64_encode($args['data']); @@ -77,7 +87,7 @@ class database_attachments extends filesystem_attachments $_SESSION['user_id'], $key, $data); - + if ($status) { $args['id'] = $key; $args['status'] = true; @@ -100,11 +110,11 @@ class database_attachments extends filesystem_attachments AND cache_key=?", $_SESSION['user_id'], $args['id']); - + if ($status) { $args['status'] = true; } - + return $args; } @@ -125,7 +135,7 @@ class database_attachments extends filesystem_attachments function get($args) { $rcmail = rcmail::get_instance(); - + $sql_result = $rcmail->db->query( "SELECT cache_id, data FROM ".get_table_name('cache')." @@ -138,10 +148,10 @@ class database_attachments extends filesystem_attachments $args['data'] = base64_decode($sql_arr['data']); $args['status'] = true; } - + return $args; } - + /** * Delete all temp files associated with this user */ -- cgit v1.2.3