vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Manually add threads and posts (https://vborg.vbsupport.ru/showthread.php?t=66381)

stalk 06-22-2004 01:36 AM

Manually add threads and posts
 
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 02: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 that easily parses XML data to arrays. Another of course is XML_Parser.

Then you just find XML news feeds, 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 02: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 03: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) 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 03: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 04: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 10:16 AM

Quote:

Originally Posted by Velocd
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 05: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 04: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:

PHP Code:

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:

PHP Code:

$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 05:11 AM

Quote:

Originally Posted by stalk
build_new_post will grab YOUR permissions (I believe).

I think you're wrong ;)

PHP Code:

// ###################### 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".


All times are GMT. The time now is 05:04 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01091 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete