Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 01 Feb 2004, 08:43
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Auto-creation of threads?

Hey guys, I'm working on a site where I will have certain admins enter in data into a form, which slaps the data into a couple of tables. What I'd like it to do is to create a new thread in a specific forum based upon certain pre-existing criteria. It will only create a new thread when new data is entered. It would be great if I could have it also create the sub-forums, but I can handle that myself for the time being.

In one of the tables will be a column for the forum ID that the new thread will be created in. I've been looking through the functions_newpost.php and newthread.php, but I'm not quite sure how to set it up so that it will create the thread for me. Yes, I do intend for it to create a first post with relevant info.

Uniquely formatting the first post of these auto-created threads will be my next venture. The problem I'm having is the actual vB stuff, how to get it to make a new thread, the integration stuff. If I'm right, I should just be able to pass values to the title and message variables into the newthread.php file, along with the value of f, which is the forumID, and it will do the rest, but I'm not quite sure.

So, has anyone else done something like this before? Can anyone point me in the right direction? Thanks!

BTW, I've taken a quick look at the talker bot code, and some of it points towards how new posts can be created, but not new threads. Hope that helps anyone else that's interested in a snippet like this.
Reply With Quote
  #2  
Old 01 Feb 2004, 18:21
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
in functions_newpost.php there is the build_newpost function, you just have to submit an array to this functions containing all info like forumid, authorid, message.... and type = 'thread' and it will insert the new thread for ya
Reply With Quote
  #3  
Old 02 Feb 2004, 04:38
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Well, that certainly seems easier than submitting info directly to multiple tables like it was seeming I was going to have to do.

I've been thinking of the message portion. For example, in my first post in this thread, I spaced out the paragrahs, but when I check out the table entry for a similar post, it appears as if the paragrahs just run together. In otherwords, is there any secret to get the formatting right?

Also, if I wanted to place an image within the message in a certain place if the pic flag is marked in a table, would it be easier to just have an if statement within the postbit template for this, or is there a way to easily set up the formatting in the afforementioned functions? I already have an if stmt in the postbit to make any post by the bot formatted in a non-default way.
Reply With Quote
  #4  
Old 02 Feb 2004, 16:05
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
it's safer to use if statements, especially if you already did something like that already.

i don't get what you mean by getting the formatting right.
When you enter a post directly to the db, it's not different than posting it manually, it will be parsed when you go to showthread, and there it will convert all new lines(\n) into <br /> tags
Reply With Quote
  #5  
Old 03 Feb 2004, 00:05
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Hrm... I'm using the Webmin sw that's on my server (RedHat IIRC) and looking into the post table, I don't see the HTML formatting (i.e. \n, etc.) and the test just runs together... Wait... if I go in to edit an entry, the formatting isn't there (\n) but it looks normal, yippee!

Ok, this is making much more sense now, eheh. Thanks Xenon. I'll report back if everything goes well or not, and if it does, it'll be quite an interesting site!
Reply With Quote
  #6  
Old 05 Feb 2004, 01:25
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Ok, I found it and I've been looking into the arguments, i.e. $foruminfo. It looks like it's an array. However, I can't find an easy list on all of the values that I need to pass to it. Same goes for $threadinfo. &$post I think I've got down as the description of the function details it. Somewhat worried about
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

but I'll leave them for later.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I did find this snippet pertaining to $foruminfo, but I've seen other array cells referenced throughout the code.
Reply With Quote
  #7  
Old 05 Feb 2004, 01:26
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
just look into the forum / thread /post table.

every field you have in these tables can be within the $...info array.
but you don't have to use every entry
Reply With Quote
  #8  
Old 05 Feb 2004, 05:09
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Gotcha. They really need better commenting in their code Is there a code comment manual I missed or something?
Reply With Quote
  #9  
Old 05 Feb 2004, 19:03
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
not right now, but iirc something like that is planned

you have to remember vb3 is not yet released final
Reply With Quote
  #10  
Old 06 Feb 2004, 04:11
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Hehe, I know, but when I was checking out vb2 code, I don't recall seeing any decent amount of comments either. Starting a bit of coding right now, I'll update this with the results.

Update: Grrrr........

Here's my code so far:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I'm getting this error:
Warning: build_new_post(./includes/functions_login.php): failed to open stream: No such file or directory in .../includes/functions_newpost.php on line 212

Fatal error: build_new_post(): Failed opening required './includes/functions_login.php' (include_path='.:/usr/share/pear') in .../includes/functions_newpost.php on line 212
Line 211-213:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

After I got that error, I added the require into the page, but with no effect. Any suggestions?

BTW, after this darn thing gets functional, I think I'll slap the good stuff from this thread and post a basic tutorial about this so it can help others. That ok with you? If so, what sub-forum would you recommend it be placed in?

Last edited by Wired1; 06 Feb 2004 at 06:48.
Reply With Quote
  #11  
Old 06 Feb 2004, 15:01
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
the subforum would be modification hints and tips

as for your problem: hmm, wierd, it seems like you are calling the function files out of the wrong directory.

isn't your script located within the forum directory?

you may want to add a chdir('..'); before the first require once of your script above.
Reply With Quote
  #12  
Old 06 Feb 2004, 21:53
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Yes, the test file was outside the directory. Moving it inside did get rid of that, but more have come

Fatal error: Call to a member function on a non-object in ...forums/includes/functions.php on line 259

That line is within the function fetch_phrase, which is used in function verify_post_errors, which is used in this snippet within functions_new_post.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Tracing code use is fun kids! lol
Ok, so $post['preview'] has already been set to 0 in the code I listed in the test file a couple of posts back. Not real sure how to set $_REQUEST['fromquickreply'] to the correct value though. Tracing it back, I think that's a default setting. I'm starting to get the feeling that a manual INSERT might work better, but I'm not giving up yet!
Reply With Quote
  #13  
Old 07 Feb 2004, 01:19
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
wierd, i haven't had any problems, i added the build_newpost to a script of mine myself and it worked flawless (ok not creating a new thread, just post...)

the errormessage you have sounds like you have to add a global $DB_site; at the correct part of your script

or better said, does your script include the global.php so the connection to the DB is set up already?
Reply With Quote
  #14  
Old 07 Feb 2004, 03:00
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
... ... ... nope... LMAO! It was there at one point, must've deleted it accidentally! Added that, then re-ran it, got an odd vB error, refreshed, and it went in! Getting an odd error though:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now the data is getting into the thread in the right place. Also just found out that every time that happens, I get a DB error email lol! 2 odd things though, which I'll cover after this code, which is the latest incarnation of the test code:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

the threadinfo['title'] doesn't do diddly, even when the post['title'] is commented out. Also, I'd like the post specific title to be nothing, but I can always remove it in the postbit.

I've also found out that it uses the cookie's session to use my username/id, not the one in the test file. I was wondering if there's a way to have it log out the user, log in with the Bot's Username/PW, then after it's done, log out. Would probably be easier for the poster to just log out of their user name and login to the bot's acct.

BTW, I take it back about what I said about their code comments, was looking around the vb.com site, and found the pdf with the ERD for the database... WOAH! I'll wait to see vB3 final to see what code comments they say...

Last edited by Wired1; 07 Feb 2004 at 08:11.
Reply With Quote
  #15  
Old 08 Feb 2004, 00:35
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Real name: Stefan Kaeser
replace the code

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

with that:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

that should avoid the db error i think.

as for your second question.
if you just use the init.php instead of global.php i think it doesn't use your account, but does create the thread as well. (but i don't give guarantee for that )
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Administrative and Maintenance Tools Mass User Creation and Auto Posting alexgeek vBulletin 3.6 Add-ons 102 10 Mar 2015 07:34



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 10:37.

Layout Options | Width: Wide Color: