Log in

View Full Version : Manually add threads and posts


stalk
06-22-2004, 12:36 AM
One possible use is having a user enter in the url of a news story and then a generic user "newsman" or something will automatically create a new thread with that news story for people to comment on. Since I am just dealing with 1 user and no moderation (in my case), then I believe all I have to do is add-to/modify the following tables:

forum
user (optional because it's a fake user, but I'll do it anyway)
thread
post
posthash

Does that seem right? Does postindex come into play at all? I realize that I'll still have to do the dupecheck before posting.

Any comments, suggestions, and ideas are welcome. Thank you.

Velocd
06-22-2004, 01:24 AM
Hmm.. an automated concept might be more useful.

If I had time, I'd code it. An "articlebot", like Sitepoint.com has for their forums when new articles are added.

Although, your method of fetching articles is somewhat broad and unclear, if you plan if you intend to grab the content from a news article by a user-submitted URL.

A better idea is to read a news feed XML from an XML parser. Not sure if you're familar with PHP's PEAR, but there is a great package by Stephan Schmidt known as XML_Serializer (http://pear.php.net/package/XML_Serializer) that easily parses XML data to arrays. Another of course is XML_Parser (http://pear.php.net/package/XML_Parser).

Then you just find XML news feeds (http://www.google.com/search?hl=en&ie=UTF-8&q=xml+news+feed), e.g.

http://www.securityfocus.com/rss/news.xml
http://www.computerworld.com/news/xml/50/0,5009,,00.xml
http://rss.news.yahoo.com/rss/tech

And have the "ArticleBot" display the URL and description inside the post.

Something to think about. ;)

This would be a most useful hack though.

stalk
06-22-2004, 01:33 AM
Velocd,

Thank you for the information. I was just using news articles as an example, but I have no problem parsing information.. in fact, I already wrote the parser for what I need, now I need to stick it in the forum.

Is what I said about manually adding threads/posts correct?

Thank you in advance. :up:

Velocd
06-22-2004, 02:13 AM
You would need to assign a forum for where ever the bot is to post, and also a "bot user", and then have a human user upload the file. What ever you're using to do the parsing (I just remembered XML_RSS (http://pear.php.net/manual/en/package.xml.xml-rss.php)) will run through the file and then insert a new row into the `thread` table, associated with `forum` and its "bot user", and also insert a `post` associated with `thread` and its "bot user".

stalk
06-22-2004, 02:47 AM
Velocd,

Thank you for your reply. Now to ask you 2 questions that I'm almost sure about but just want to make sure...

1) It would also be necessary to fill out the posthash table (and check it) to make sure I don't get duplicate submissions, correct?

2) To make the post searchable, all I have to do is call build_post_index from functions_databuild.php with the correct args, correct?

Velocd
06-22-2004, 03:36 AM
Stalk,

I'm assuming you are stepping through the build_new_post() function that is in newthread.php and newpost.php.

If not, it's located in /includes/functions_newpost.php, and should have all the necessary steps to completing a thread. ;)

I'll check back tomorrow if you still need help.

stalk
06-22-2004, 09:16 AM
I'm assuming you are stepping through the build_new_post() function that is in newthread.php and newpost.php.

Actually, yes. I just always liked reassurance. Since my board is still not in use, I guess it wouldn't hurt to play around with the threads/posts tables. I'll let you know how it all turns out. Thanks for your help.

ethank
06-25-2004, 04:03 AM
Can you post your code when its through? I have to bulk load 8 years of news articles as posts for my interim website... :)

stalk
06-29-2004, 03:40 AM
It's actually really simple if you are just going to create a new thread and add a post.

You can just call the build_new_post function from includes/functions_newpost.php like this:

build_new_post('thread', $foruminfo, array(), 0, $newpost, $errors);

If you look in the source of the functions_newpost.php file, you'll see what you need to fill in for the $newpost array. $foruminfo you'd just do something like:

$foruminfo = fetch_foruminfo(10)

Replace 10 with the forumid you want to insert it in.
Pick a user to be a bot, get their id, and do:
[PHP]$bbuserinfo = fetch_userinfo(2)[/PHP

You use that to build the posthash.

look in newthread.php for an example of how to call build_new_post. Let me know if you need more info.

Hm... I'm not sure what you are trying to do, but I had to modify some of the vb files because the forums I want the bot to post to are moderated and a regular user won't have permissions to post.. build_new_post will grab YOUR permissions (I believe).

So yeah.. just let me know if you have any questions/problems.

Andreas
06-29-2004, 04:11 AM
build_new_post will grab YOUR permissions (I believe).

I think you're wrong ;)


// ###################### Start newpost #######################
function build_new_post($type = 'thread', $foruminfo, $threadinfo, $parentid, &$post, &$errors)
{
//NOTE: permissions are not checked in this function

This is quite useful if you use this function for automated purposes where there actuallyy is no "user".

stalk
06-30-2004, 04:22 PM
:speechless:

My bad. I was just assuming. What happened was that I set the bot user as a moderator, but the post was still being marked for moderation when I called that function.