Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Topic started by: aegersz on September 20, 2016, 10:02:24 PM

Title: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: aegersz on September 20, 2016, 10:02:24 PM
I thought it might be handy for members to take Topics or Posts offsite for whatever reason.

Like who really owns their posts ?

The last forum I was on before I built mine left 1000's of people feeling that their data was stolen.

I'd like to give people a special option of preserving their posts or entire topics.

How hard would this be to code and would anybody be willing to do it ?

I'm willing to download the unloaded post or topic to people manually and then send via email if that makes them love my forum but my php / sql is still too poor to code it myself.
Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: nend on September 21, 2016, 07:38:16 AM
It depends, how would you like to save the post?

The simplest way would be to have the user use the print topic option and have them print to file using their PC. If you want to waste CPU cycles you can do this server side.

If you want to do only the users post and have something more automated it shouldn't be to hard to code. However depending on certain factors this may be a slow query depending on how many post and how far you'd like to go back.
Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: aegersz on September 21, 2016, 08:04:31 PM
Thank you, user's own posts would be the way to go.

My system never gets enough load to slow down.

I'm usually the guy that writes his own software but as an older guy now, I haven't got the patience to do much beyond listing all members etc. with php and sql.

Incorporating it into SMF may be too much work but I'd even settle for a batch php job if anyone has the time.

I could then redirect the output to a file but it should have post headers like Topic and date/time.
Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: aegersz on September 26, 2016, 04:03:19 PM
i wrote this and it works  :):

Code: [Select]
<?php
$servername 
"localhost";
$username "root";
$password "root"// <- modify
$dbname "smf209";

// Create connection
$conn = new mysqli($servername$username$password$dbname);
// Check connection
if ($conn->connect_error) {
    die(
"Connection failed: " $conn->connect_error);
}

//$sql = "SELECT FROM_UNIXTIME( poster_time )
$sql "SELECT *
        FROM  `smf209_messages` WHERE poster_name =  'andrew' ORDER BY id_topic, poster_time"
// <-modify poster_name
$result $conn->query($sql);

if (
$result->num_rows 0) {
    
// output data of each row
    
while($row $result->fetch_assoc()) {
        print 
"<strong>".$row['subject']."</strong> by "$row['poster_name']. "<br/>";
        echo 
"Dated: "date("d/m/Y H:i:s"$row['poster_time']);
        echo 
" "PHP_EOL"<br/>";
        echo 
$row['body']. PHP_EOL"<br/>";
        echo 
" "PHP_EOL"<br/>";
    }
} else {
        echo 
"0 results";
}
$conn->close();
?>

Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: aegersz on September 26, 2016, 06:32:18 PM
... it may run from the web directory, then cut and pasted into a file on your client OS/desktop then finally emailed to the member.

it may be cumbersome and fiddly as it requires command line access to your host but it does the job of saving someone's posts, should they want to leave the site - yes, i'm such a nice guy, i'll even help you pack your bags as you're walking out the door ...  ???

example of the basic output:

Bedroom DJ Here. by andrew
Dated: 16/12/2014 09:25:21
latest re-re-mix is in the reply post.

Re: Bedroom DJ Here. by andrew
Dated: 27/09/2016 04:01:43
second post by andrew

Legalise Phenethylamines ? by andrew
Dated: 16/12/2014 09:40:14
again, the least of all evils.

there are many people who would benefit from tracking their usage because it would shock sense into some of them !

Re: Legalise Phenethylamines ? by andrew
Dated: 24/03/2015 02:49:58
take the money out of it and rethink ...

etc.
Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: devilkin on October 07, 2018, 11:39:22 AM
I've created a script that dumps the entire forum: https://github.com/jdeluyck/scripts/tree/master/smf_forums
Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: aegersz on October 07, 2018, 08:36:40 PM
thank you, i saved that away if i need it.
Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: GigaWatt on October 07, 2018, 09:06:47 PM
Me too, will definitely test it out ;).
Title: Re: Any way to Download a Topic or Post to the host or to the user's Download area ?
Post by: Shambles on October 08, 2018, 03:03:22 AM
^ yeah good work devilkin ;)