Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #21  
Old 02-08-2004, 12:45 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Basic code to post a new thread (as any user you want):

PHP Code:
chdir('/path/to/forum/root');

// Load vB-Backend
require('./global.php');
require(./
includes/functions_newpost.php');

$userid = 1234; // The user creating the thread
$forumid = 12; // The forum where the thread should be posted

// Get forum & user info
$foruminfo = fetch_foruminfo($forumid);
$bbuserinfo = fetch_userinfo($userid);

// Setup the thread
$post[title] = '
Some foobar title';
$post[message] = '
Some foobar message text';
$post[poststarttime] = TIMENOW;
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['
userid'] . $bbuserinfo['salt']);

// build the thread
build_new_post('
thread', $foruminfo, array(), 0, $post, $errors);

// Errors?
if (sizeof($errors) > 0)) {
  // error processing

Reply With Quote
  #22  
Old 02-08-2004, 12:47 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by version2
All right. I am done talking to myself. Hopefully this will help someone in the future. I got around the cookie problem by declaring the username and then grabbing the bbuserinfo using that username. I am also using init.php and not global.php. Everything seems to be working. All counts are being update, etc.
Mind sharing that bit of code? That'll save tons of work for me, eheh.

As for the rest, Finally no errors! Wait.... yep, found one! This one's minor though, can be taken care of with the bot account. For some reason, it auto subscribes me to the threads created with that script, yet not when I make one normally. Are you being auto subscribed to your threads?

Then again, not sure I want massive amounts of subscriptions in the bot's acct. Yes, auto subscribe for the acct is turned off.

Next thing to tackle is an if stmt in the postbit that if picture is part of data, pic will be displayed in the thread. That's cake, but I've been experimenting with pics and text in a post. Only way I can figure out a way to wrap the text around the pic is with table cells. Crude, but should work just fine.

Next thing I'm going to be working on is how to grab the newly created threadID (maybe even post ID) after the thread/post is made.

I'm also looking into how to auto create a forum/sub forum, but for security reasons, I think I might not let the bot have this access, and find out how to do it with normal mySQL statements. Any suggestions/tips?
Reply With Quote
  #23  
Old 02-08-2004, 12:50 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Wired1
Next thing I'm going to be working on is how to grab the newly created threadID (maybe even post ID) after the thread/post is made.
If you are manually dealing with the database:
$DB_site->insert_id();
Reply With Quote
  #24  
Old 02-08-2004, 12:52 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kirby, thanks! That's solved the posterid prob, but it also auto-subscribes the account to the thread.

$DB_site->insert_id();

hhmm.... not quite sure how that's supposed to be used. Mind giving me an example, or a place in the vB code (or a thread here) that explains that?
Reply With Quote
  #25  
Old 02-08-2004, 12:53 AM
version2's Avatar
version2 version2 is offline
 
Join Date: Feb 2003
Location: Philly
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Wired1
Mind sharing that bit of code? That'll save tons of work for me, eheh.?
Dont mind at all! But, I think I have been beaten to the punch. Kirby already posted it:

PHP Code:
$userid 2;
$bbuserinfo fetch_userinfo($userid); 
Kirby's code is about what I ended up with.
Reply With Quote
  #26  
Old 02-08-2004, 12:54 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks as well version2! BTW, I'm grabbing the threadID after it is created automatically so that I can place it into another table I created, so that another page will auto-create links to certain threads based on other criteria.
Reply With Quote
  #27  
Old 02-08-2004, 12:55 AM
version2's Avatar
version2 version2 is offline
 
Join Date: Feb 2003
Location: Philly
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Wired1
Kirby, thanks! That's solved the posterid prob, but it also auto-subscribes the account to the thread.
PHP Code:
$post['emailupdate'] = 9999
That'll fix the subscribe.
Reply With Quote
  #28  
Old 02-08-2004, 12:57 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@Wired1:

PHP Code:
$post['emailupdate'] = 9999
before calling build_new_post() should avoid subscribing the thread.

If you use this function to create the thread you can use
$post['threadid'] and $post['postid'] afterwards - the ID's will be there.
Reply With Quote
  #29  
Old 02-08-2004, 12:58 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wahooo!!!!! Now to understand $DB_site->insert_id();
Reply With Quote
  #30  
Old 02-08-2004, 01:00 AM
Wired1's Avatar
Wired1 Wired1 is offline
 
Join Date: Nov 2003
Location: Orlando, FL, USA
Posts: 1,361
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

But I can only use $post['threadid'] and $post['postid'] after the build_new_post is hit in the code, correct? I think that'll save me 1 query

This look right?
PHP Code:
// Load vB-Backend 
require('./global.php'); 
require(
'./includes/functions_newpost.php'); 

$userid 5// The user creating the thread 
$forumid 10// The forum where the thread should be posted 

// Get forum & user info 
$foruminfo fetch_foruminfo($forumid); 
$bbuserinfo fetch_userinfo($userid); 

// Setup the thread 
$post[title] = 'Some foobar sssstitle'
$post[message] = 'Some foobar message text'
$post[poststarttime] = TIMENOW
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']); 
$post['emailupdate'] = 9999

// build the thread 
build_new_post('thread'$foruminfo, array(), 0$post$errors); 

// Errors? 
if (sizeof($errors) > 0) { 
  
// error processing 
}
ThreadID $post['threadid']; 
PostID $post['postid']; 
ThreadID and PostID are columns in a table I have created.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 01:19 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04666 seconds
  • Memory Usage 2,286KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete