News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Archiving to a textfile

Started by vizion, September 16, 2005, 02:39:59 PM

Previous topic - Next topic

vizion

How can I output the following to text files:

1. Lists of Categories, Boards and descriptions
2. Ordered Archives of postings by thread within Board?


Does anyone know how this can be done?

Thanks

David

Oldiesmann

1. Put the following in a file and upload it to your SMF directory. Make sure that directory is chmodded to 777, then run the file... (this will get you a list of each category and each board in that category listed in the correct order, but ignoring positioning and locations for child boards as this is more difficult to accomplish).

<?php
include_once('SSI.php');
// Get the categories first...
$query db_query("SELECT * FROM smf_categories ORDER BY ID_CAT ASC"__FILE____LINE__);
$handle fopen('Categories.txt''x+');
fwrite($handle'ID_CAT\t Name\r\n');
while(
$categories mysql_fetch_assoc($query))
{
    
fwrite($handle$categories['ID_CAT'] . '\t' $categories['name'] . '\r\n');
    
$query2 db_query("SELECT ID_BOARD, name, description, numTopics, numPosts FROM smf_boards WHERE ID_CAT ='$categories['ID_CAT']' ORDER BY boardOrder ASC"__FILE____LINE__);
   
fwrite($handle'\n\n\tID_BOARD\tName\tdescription\t\r\n');
    while(
$boards mysql_fetch_assoc($query2))
    {
        
// Output the info with a tab between each item
        
fwrite($handle'\t' $boards['ID_BOARD']  . '\t' $boards['name'] . '\t' $boards['description'] . '\r\n');
    }
// Two blank lines after each category...
fwrite($handle'\n\n');
}
fclose($handle);
?>


2. Attempting to do this would probably result in the script timing out because it would take a really long time and result in some rather large (and ugly) text files (if you did it by topic, it might not time out, but then you'd end up with hundreds of text files).
Michael Eshom
Christian Metal Fans

Anguz

1. You could also load the forum's home and save as text file with your browser. :P

2. Same as 1 but with the board's pages, and then put together all the files with your text editor. :P
Cristián Lávaque http://cristianlavaque.com

vizion

Thanks very much guys

How about adding postings to a text files as the postings are made?

I may need to send postings to a mail list =- hence archiving the postings to a text file for archive search purposes. ASs the Board I need to do this on is new - I could start with tailing posts to a file and piping the posts to the mail list.

Has anyone done that - or do not want to re-invent the wheel!!

Oldiesmann

Archiving posts to a text file will quickly eat up your disk space. Why can't you just pull them from the database whenever you need to email one?
Michael Eshom
Christian Metal Fans

vizion

Several reasons

1. Using internet search engines to create an index (That is one reason for creating unique posting numbers (by category, Board, thread & post) to appear in each thread as the initial part of the subject line. There are some advertising revenue apportunities here..but I will not bore you with the details atm

2. Preparing mail list digests

3. Apart from access by search engines and for digest creation there would be negligable additional load on the system especially if the files were on a separate server.

There are some other minor benefits
david

vizion

Quote from: Oldiesmann on September 17, 2005, 08:50:24 PM
1. Put the following in a file and upload it to your SMF directory. Make sure that directory is chmodded to 777, then run the file... (this will get you a list of each category and each board in that category listed in the correct order, but ignoring positioning and locations for child boards as this is more difficult to accomplish).

<snip code>

2. Attempting to do this would probably result in the script timing out because it would take a really long time and result in some rather large (and ugly) text files (if you did it by topic, it might not time out, but then you'd end up with hundreds of text files).


Thanks that was a great start.. I can fine tune that.

david

Advertisement: