[re-release vb2.0] Download PMs to file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bira
    Senior Member
    • May 2000
    • 1498

    [re-release vb2.0] Download PMs to file

    Since I was asked to make this available, here's my hack for downloading Private Messages (as many as you select) at once into a local txt file.

    This is helpful if you need to clear out your PM folder(s) due to quota limitation, but don't want to lose those messages.

    In effect, it works like an e-mail RFC archive.

    Installation Instructions:

    1. Open private.php.

    Find:

    Code:
      if ($delete!="") {
        $what="delete";
      }
    Immediately AFTER it put:

    PHP Code:
      if ($download!="") {
        
    $what="download";
      } 
    Find:

    Code:
        eval("standardredirect(\"".gettemplate("redirect_pmdelete")."\",\"private.php?s=$session[sessionhash]&folderid=$thisfolder\");");
      }
    Immediately AFTER it put:

    PHP Code:
      if ($what=="download") {
          
        if (
    is_array($privatemessage)) {
            
    header("Content-disposition: filename=messages.txt");
            
    header("Content-type: application/octetstream");
            
    header("Pragma: no-cache");
            
    header("Expires: 0");

              while(list(
    $key,$val)=each($privatemessage)) {
                
    $downloads=$DB_site->query_first("SELECT touserid,fromuserid,dateline,title,message FROM privatemessage WHERE privatemessageid='$key' AND userid=$bbuserinfo[userid]");
                
    $tousername=$DB_site->query_first("SELECT username FROM user WHERE userid='$downloads[touserid]'");
                
    $fromusername=$DB_site->query_first("SELECT username FROM user WHERE userid='$downloads[fromuserid]'");
                
    $msgdt vbdate($dateformat,$downloads[dateline]);
                
    $msgtm vbdate($timeformat,$downloads[dateline]);
                
    $wordwrap wordwrap($downloads[message],75,"\r\n");
                
                print(
    "Date/Time Sent: $msgdt$msgtm\r\n");
                print(
    "From: $fromusername[username]\r\n");
                print(
    "To: $tousername[username]\r\n");
                print(
    "Subject: $downloads[title]\r\n\r\n");
                print(
    "$wordwrap\r\n");
                print(
    "==========================================================================\r\n\r\n\r\n");

            } 
    //end while
        
        
    } else {
          eval(
    "standarderror(\"".gettemplate("error_pmnoselected")."\");");
          exit;
          }
      } 
    Note for Foreign Users: replace the words 'Date/Time Sent', 'From', 'To', 'Subject' in the above code with whatever wording in your language that suits you.

    Save file and upload.

    2. Edit template privfolder.

    Find:

    Code:
    $massforwardlink
    Immediately after OR before it (it does not matter), put:

    Code:
    or <input type="submit" name="download" value="Download">
    Note for Foreign Users: replace the word "or" and the value "Download" with whatever wording in your language that suits you.


    That's it!

    Usage: select one or more messages in one of your Private Messages folder and click on "Download". You will be prompted to save messages.txt on your hard drive (a Windows filename & folder selection dialogue will pop up).

    Cheers,

    Bira

  • bokhalifa
    Member
    • Feb 2001
    • 99

    #2
    good hack min

    Comment

    • conan
      Senior Member
      • Sep 2000
      • 389

      #3
      Thanks a lot for the great hack!

      Comment

      • poil11
        Member
        • Aug 2000
        • 54

        #4
        Thanks for this great hack. i hope that you don't mind but i hacked it to work with wwwthreads. and i am going to use this in many many other things! good deal!

        instead of it being message.txt i made that the subject of the post....
        Last edited by poil11; Thu 3 May '01, 10:33am.

        Comment

        • The_Sisko
          Senior Member
          • Jun 2000
          • 384

          #5
          This is what a lot of my Users asked for!!!
          THANKS A LOT!
          The Sisko
          SciFi-Forum.de

          Comment

          • bira
            Senior Member
            • May 2000
            • 1498

            #6
            thanks

            Comment

            • Streicher
              Senior Member
              • Jan 2001
              • 373
              • 3.7.x

              #7
              Very good hack. No problems to hack in vB.
              Streicher

              Comment

              • smelialichu
                New Member
                • May 2001
                • 21

                #8
                This is a great hack, just one problem though. When i click on download it displays the pm's in my browser and doesn't download it. i use IE 5.01 none of the other people on the board have reported the problem, ideas? I realise the problem is most likely at my end.

                Comment

                • bira
                  Senior Member
                  • May 2000
                  • 1498

                  #9
                  Originally posted by smelialichu
                  This is a great hack, just one problem though. When i click on download it displays the pm's in my browser and doesn't download it. i use IE 5.01 none of the other people on the board have reported the problem, ideas? I realise the problem is most likely at my end.
                  smelialichu, I'm not sure where to point you to, but it has to do with your system/browser setting. Instead of prompting you to choose between save file or open it, it goes right ahead and opens it without asking. I'm not sure how you solve that as I am not familiar with win32 registry stuff.

                  You might want to check in your security settings (Tool -> Internet Options) that Download is enabled (general download, that is). Not sure about anything else.

                  In any case, I'd recommend upgrading to IE 5.5, which is a much better, faster and less buggy browser.

                  Cheers,

                  bira

                  Comment

                  • veedee
                    Senior Member
                    • Sep 2000
                    • 324
                    • 1.1.x

                    #10
                    Great looking hack.

                    I run about 7 styles on my website, does this mean i have to hack the templates 7 times ?

                    ~veedee
                    Talking loud but aint saying nothing.

                    Comment

                    • bira
                      Senior Member
                      • May 2000
                      • 1498

                      #11
                      Originally posted by veedee
                      Great looking hack.

                      I run about 7 styles on my website, does this mean i have to hack the templates 7 times ?

                      ~veedee
                      Do you actually have a different templateset for every style though?!?

                      Run a search in the Control Panel -> Templates for $massforwardlink. If you have more than one template with it, you can do a search/replace of

                      Code:
                      Search for: $massforwardlink
                      Replace with: $massforwardlinkor <input type="submit" name="download" value="Download">
                      At your peril though
                      Last edited by bira; Mon 14 May '01, 10:51am.

                      Comment

                      • veedee
                        Senior Member
                        • Sep 2000
                        • 324
                        • 1.1.x

                        #12
                        yeah different templates

                        will do what you told me, cheers me dear
                        Talking loud but aint saying nothing.

                        Comment

                        • smelialichu
                          New Member
                          • May 2001
                          • 21

                          #13
                          Abyone got any ideas on how to solve my prob? i got it so the filename includes the date. i can tell you how if anyone's interested, iy's fairly simple. In fact very simple

                          Comment

                          • bira
                            Senior Member
                            • May 2000
                            • 1498

                            #14
                            Actually, wordwrap() is a built-in function in PHP.

                            Perhaps, though, it's only in PHP4 or something.

                            Comment

                            • slip
                              Member
                              • Jan 2001
                              • 66

                              #15
                              i installed everything exactly as it should be done, yet when i try to download some pm's, i just get a blank page (completely blank, no errors)

                              any help?

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...