Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Create Posts
fly
Join Date: Oct 2003
Posts: 1,215

 

Show Printable Version Email this Page Subscription
fly fly is offline 12-06-2005, 10:00 PM

PHP Code:
require_once('./global.php');
require_once(
'./includes/class_dm.php');
require_once(
'./includes/class_dm_threadpost.php');

$postdm = new vB_DataManager_Post($vbulletinERRTYPE_STANDARD);

$postthreadid '4473';
$postusername 'admin';
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postuserid = '1';
$postpagetext 'Hi mom!';

$threadinfo fetch_threadinfo($postthreadid);
$foruminfo fetch_foruminfo($threadinfo['forumid']);

$postdm->set_info('forum'$foruminfo);
$postdm->set_info('thread'$threadinfo);  
$postdm->set('threadid'$postthreadid);
$postdm->set('username'$postusername);
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postdm->set('userid', $postuserid);
$postdm->set('pagetext'$postpagetext);
$postdm->set('allowsmilie'1);
$postdm->set('visible'1);
$postdm->set('dateline'TIMENOW);
$postdm->save();
unset(
$postdm); 
Reply With Quote
  #12  
Old 04-24-2006, 02:47 PM
Wild-Wing Wild-Wing is offline
 
Join Date: Dec 2005
Posts: 86
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how can this be used to edit a post already posted?
Reply With Quote
  #13  
Old 04-25-2006, 11:43 AM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

afaik, it can't.
Reply With Quote
  #14  
Old 04-26-2006, 09:53 AM
Evercraft Evercraft is offline
 
Join Date: Jan 2005
Location: United Kingdom
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to add the following code, after the post has been created, to update forum counters and last post index etc.

PHP Code:
require_once(DIR '/includes/functions_databuild.php');
build_forum_counters($threadinfo['forumid']); 
Quote:
Originally Posted by laddil
I have a quick question about using this method to put in a post...

Does it take into account user preferances (i.e., emoticons, smilies, etc.) and forum security settings (vBcode, raw HTML, etc.)?

The modification I'm writing needs to add posts to a specific forum, but I have consern about the potential of this bypassing security and causing mischief.
It doesn't check permissions.
Reply With Quote
  #15  
Old 07-22-2006, 07:28 PM
nj_vb nj_vb is offline
 
Join Date: Jul 2006
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This doesn't work with 3.5.x for me...

It's saying "the user is already logged in, if you have lost your pw click here" or something to that effect. Any ideas?
Reply With Quote
  #16  
Old 07-24-2006, 04:52 AM
Atakan KOC's Avatar
Atakan KOC Atakan KOC is offline
 
Join Date: Feb 2006
Location: Istanbul
Posts: 710
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

3.5.x

PHP Code:
$rforuminfo fetch_foruminfo($Feed['forumid']);
$newpost = array(
    
'emailupdate' => 9999,
    
'userid' => 'Userid',
    
'username' => 'Username',
    
'title' => 'Title',
  
'message' =>  'Message',
  
'thread=> 'threadid'
);
$threadinfo['threadid'] = 'threadid';
build_new_post('Post'$rforuminfo$threadinfo, array(), $newpost$errors); 
Reply With Quote
  #17  
Old 07-24-2006, 11:32 AM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nj_vb
This doesn't work with 3.5.x for me...

It's saying "the user is already logged in, if you have lost your pw click here" or something to that effect. Any ideas?
I remember that happening to me as well. iirc, you populated BOTH the username and userid. Only fill in one.
Reply With Quote
  #18  
Old 08-25-2006, 05:24 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i've created a hook :
PHP Code:
if ($forumid==7)
{
$newpost = array(
    
'emailupdate' => 9999,
    
'userid' => '120',
    
'username' => 'Informationsminister',
    
'title' => 'Info',
  
'message' =>  '[SHOWTOGROUPS="10"]folge dem wei?n wolf
:P oder w?hle folgende nummer[/SHOWTOGROUPS]'
,
  
'thread=> '$threadid'
);
$threadinfo['threadid'] = 'threadid';
build_new_post('Post''7'$threadinfo, array(), $newpost$errors);} 
the start is newpost_complete
i want to make a automatic answer on every thread that someone creates in forum=7 but it doesn do that
Reply With Quote
  #19  
Old 08-29-2006, 01:35 AM
FreekBoy FreekBoy is offline
 
Join Date: Dec 2004
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a way like this to create forums?
Reply With Quote
  #20  
Old 10-04-2006, 01:53 PM
Derschizo Derschizo is offline
 
Join Date: Jul 2005
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What if you put it in the function_new reply and you want it to be a auto second post, what would you put for the threadid?
b/c
$threadinfo['threadid'] = 'threadid'; doesn't seem to work.

I want it in the same thread.
Reply With Quote
  #21  
Old 10-07-2006, 03:03 AM
ruinernix ruinernix is offline
 
Join Date: Oct 2005
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Atakan KOC
3.5.x

PHP Code:
$rforuminfo fetch_foruminfo($Feed['forumid']);
$newpost = array(
    
'emailupdate' => 9999,
    
'userid' => 'Userid',
    
'username' => 'Username',
    
'title' => 'Title',
  
'message' =>  'Message',
  
'thread=> 'threadid'
);
$threadinfo['threadid'] = 'threadid';
build_new_post('Post'$rforuminfo$threadinfo, array(), $newpost$errors); 
This works, but all messages created end up in a moderation queue even though the forum is not set to moderate posts/threads. I tried adding 'visible'=>'1' but it doesn't make a difference. Any clues? I suppose it's because I'm running this from an outside script, that isn't really logged into VB. I made a modification to functions_newpost.php
PHP Code:
Replaced:
    
// see if post has to be moderated or if poster in a mod
    
if ( 
        ((
With:
    
// see if post has to be moderated or if poster in a mod
    
if ( ($post['visible'] == 0) AND
        (( 
It does the job, but I'd like to understand why it's not working properly..

I also added build_forum_counters($forumid); after posting, otherwise the lastthread info doesn't get updated in the forum list.

Quote:
Originally Posted by Derschizo
What if you put it in the function_new reply and you want it to be a auto second post, what would you put for the threadid?
b/c
$threadinfo['threadid'] = 'threadid'; doesn't seem to work.

I want it in the same thread.
You should be using

$threadinfo['threadid'] = 3310; (ie: 3310 is the thread id)
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 12:57 PM.


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.05053 seconds
  • Memory Usage 2,351KB
  • Queries Executed 26 (?)
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
  • (6)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • 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