View Issue Details

IDProjectCategoryView StatusLast Update
0014108phpList 3 applicationMessage Managementpublic10-05-11 22:04
Reporterelectrawn 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
Product VersionSVN 
Target VersionFuture developmentsFixed in Version 
Summary0014108: Store Attachments in Database
DescriptionExtends database and phplist libraries to store attachments in database. Useful if your frontend and backend are on different servers. Did not change dl.php, will need to alter that to fully support the feature.
TagsNo tags attached.

Activities

14-04-08 17:16

 

attachmentsindb.patch (4,238 bytes)
# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: phplist/public_html/lists/admin/send_core.php
--- phplist/public_html/lists/admin/send_core.php Base (1.45)
+++ phplist/public_html/lists/admin/send_core.php Locally Modified (Based On 1.45)
@@ -554,10 +554,18 @@
           $fd = fopen($GLOBALS["attachment_repository"]."/".$newfile, "w" );
           fwrite( $fd, $contents );
           fclose( $fd );
+          if (ATTACHMENTS_IN_DB){
+            $filecontent = addslashes($contents);
+            Sql_query(sprintf('insert into %s (filename,remotefile,mimetype,description,size,filedata) values("%s","%s","%s","%s",%d, "%s")',
+              $tables["attachment"],
+              basename($newfile),$remotename,$type,$description,$file_size,$filecontent)    
+              );
+          } else {
           Sql_query(sprintf('insert into %s (filename,remotefile,mimetype,description,size) values("%s","%s","%s","%s",%d)',
           $tables["attachment"],
           basename($newfile),$remotename,$type,$description,$file_size)
           );
+          }
           $attachmentid = Sql_Insert_Id($tables['attachement'], 'id');
           Sql_query(sprintf('insert into %s (messageid,attachmentid) values(%d,%d)',
           $tables["message_attachment"],$messageid,$attachmentid));
Index: phplist/public_html/lists/admin/sendemaillib.php
--- phplist/public_html/lists/admin/sendemaillib.php Base (1.41)
+++ phplist/public_html/lists/admin/sendemaillib.php Locally Modified (Based On 1.41)
@@ -914,7 +937,12 @@
     while ($att = Sql_Fetch_array($req)) {
       switch ($type) {
         case "HTML":
-          if (is_file($GLOBALS["attachment_repository"]."/".$att["filename"]) && filesize($GLOBALS["attachment_repository"]."/".$att["filename"])) {
+          if (ATTACHMENT_IN_DB) {
+             $mail->AddStringAttachment($att["filedata"],
+              basename($att["remotefile"]),"base64",
+              $att["mimetype"]);
+          }
+          elseif (is_file($GLOBALS["attachment_repository"]."/".$att["filename"]) && filesize($GLOBALS["attachment_repository"]."/".$att["filename"])) {
             $fp = fopen($GLOBALS["attachment_repository"]."/".$att["filename"],"r");
             if ($fp) {
               $contents = fread($fp,filesize($GLOBALS["attachment_repository"]."/".$att["filename"]));
Index: phplist/public_html/lists/admin/structure.php
--- phplist/public_html/lists/admin/structure.php Base (1.18)
+++ phplist/public_html/lists/admin/structure.php Locally Modified (Based On 1.18)
@@ -164,11 +164,12 @@
       ),
       "attachment" => array (
         "id" => array("integer not null primary key auto_increment","ID"),
-        "filename" => array("varchar(255)","file"),
+        "filename" => array("varchar(255)","Local File Name"),
         "remotefile" => array("varchar(255)","The original location on the uploader machine"),
         "mimetype" => array("varchar(255)","The type of attachment"),
         "description" => array("text","Description"),
-        "size" => array("integer","Size of the file")
+        "size" => array("integer","Size of the file"), 
+        "filedata" => array("mediumblob", "File Data")
       ),
       "usermessage" => array ( # linking messages to a user
           #"id" => array("integer not null primary key auto_increment","ID"),
Index: phplist/public_html/lists/admin/upgrade.php
--- phplist/public_html/lists/admin/upgrade.php Base (1.23)
+++ phplist/public_html/lists/admin/upgrade.php Locally Modified (Based On 1.23)
@@ -269,6 +269,8 @@
     case "2.8.1": case "2.8.2": case "2.8.3":
     case "2.8.4": case "2.8.5": case "2.8.6":
       Sql_Query("alter table {$tables["user"]} add index index_uniqid (uniqid)");
+    case "2.10.5":
+      Sql_Query("alter table {$tables["attachment"]} add column filedata mediumblob");
\ No newline at end of file
     case "whatever versions we will get later":
       #Sql_Query("alter table table that altered");
       break;
attachmentsindb.patch (4,238 bytes)