Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles

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
  #22  
Old 11-22-2006, 02:24 PM
ks_work ks_work is offline
 
Join Date: Jul 2006
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i'm with 3.6.3 now.
How do I update existing post ?

thanks
Reply With Quote
  #23  
Old 11-23-2006, 03:52 AM
amcd amcd is offline
 
Join Date: Oct 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ks_work View Post
i'm with 3.6.3 now.
How do I update existing post ?

thanks
this is how we do it on 3.6.1 . i think the same is valid for 3.6.3 as well
Code:
$vbulletin->db->query_write("UPDATE post SET pagetext = '$message' WHERE postid=$postid");
$vbulletin->db->query_write("DELETE FROM postparsed WHERE postid=$postid");
Reply With Quote
  #24  
Old 11-23-2006, 12:37 PM
ks_work ks_work is offline
 
Join Date: Jul 2006
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks a lot !
I'll try it.
Meanwhile this code did the job for me (i apologize for it's messiness):
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
//define('GET_EDIT_TEMPLATES', true);

    
define('SKIP_SESSIONCREATE'1);
    
define('DIE_QUIETLY'1);    
define('THIS_SCRIPT''editpost');

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR '/includes/functions_newpost.php');
require_once(
DIR '/includes/functions_bigthree.php');
require_once(
DIR '/includes/functions_editor.php');
require_once(
DIR '/includes/functions_log_error.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

// ### STANDARD INITIALIZATIONS ###
$checked = array();
$edit = array();
$postattach = array();



############################ start  input from tt_news

$k_postid=$_REQUEST["k_postid"];
$k_threadid=$_REQUEST['k_threadid'];
$k_title=$_REQUEST['k_title'];
$k_pagetext=$_REQUEST['k_pagetext'];
$k_hidden_visible=$_REQUEST['k_hidden_visible'];

############################  end input from tt_news



$threadinfo['forumid']=55;
$threadinfo['threadid']=$k_threadid;
$threadinfo['firstpostid']= $k_postid;

$foruminfo fetch_foruminfo($threadinfo['forumid'], false);
//print"<P>forum: <pre>".print_r($foruminfo,1);print"<P>thread :<pre>".print_r($threadinfo,1);
    
$postinfo['postid'] = $k_postid;
    
$postinfo['threadid'] =$threadinfo['threadid'];
    
$postinfo['parentid'] = $k_postid;
    
$postinfo['username'] = 'administrator';
    
$postinfo['userid'] = 1;
    
$postinfo['title'] = $k_title;
    
$postinfo['dateline'] = '';
    
$postinfo['pagetext'] =$k_pagetext;
    
$postinfo['allowsmilie'] = 1;
    
$postinfo['showsignature'] = 0;
    
$postinfo['ipaddress'] = '206.223.168.166';
    
$postinfo['iconid'] = 0;

        if( isset(
$_REQUEST["k_hidden_visible"]))//
        
{
                if(
$_REQUEST["k_hidden_visible"]==0)// hidden
                
{
                
$visible_val=0;
                }
                else 
//
                
{
                
$visible_val=1;
                }        
        }
        else 
//
        
{
            
$visible_val=0;
        
        }

    
$postinfo['visible'] = $visible_val;
    
$postinfo['attach'] = 0;
    
$postinfo['infraction'] = 0;
    
$postinfo['reportthreadid'] = 0;
    
$postinfo['isdeleted'] = 0;
    
$postinfo['edit_userid'] = '';
    
$postinfo['edit_dateline'] = '';
    
$postinfo['edit_reason'] ='' ;


    
$threadinfo['visible']=$visible_val;
///print"<P>post <pre>".print_r($postinfo,1);
$aaa=1;

// need to get last post-type information
cache_ordered_forums(1);

// ############################### start update post ###############################
if ($aaa ==1)
{
    
// Variables reused in templates
    
$posthash $vbulletin->input->clean_gpc('p''posthash'TYPE_NOHTML);
    
$poststarttime $vbulletin->input->clean_gpc('p''poststarttime'TYPE_UINT);

    
$vbulletin->input->clean_array_gpc('p', array(
        
'stickunstick'   => TYPE_BOOL,
        
'openclose'      => TYPE_BOOL,
        
'wysiwyg'        => TYPE_BOOL,
        
'message'        => TYPE_STR,
        
'title'          => TYPE_STR,
        
'iconid'         => TYPE_UINT,
        
'parseurl'       => TYPE_BOOL,
        
'signature'         => TYPE_BOOL,
        
'disablesmilies' => TYPE_BOOL,
        
'reason'         => TYPE_NOHTML,
        
'preview'        => TYPE_STR,
        
'folderid'       => TYPE_UINT,
        
'emailupdate'    => TYPE_UINT,
        
'ajax'           => TYPE_BOOL,
        
'advanced'       => TYPE_BOOL,
        
'postcount'      => TYPE_UINT,
        
'podcasturl'     => TYPE_STR,
        
'podcastsize'    => TYPE_UINT,
        
'podcastexplicit' => TYPE_BOOL,
        
'podcastkeywords' => TYPE_STR,
        
'podcastsubtitle' => TYPE_STR,
        
'podcastauthor'   => TYPE_STR,
    ));
    
    
// ### PREP INPUT ###
    
        
$edit['message'] =$k_pagetext;
        
$edit['iconid'] =& $vbulletin->GPC['iconid'];
        
$edit['title'] =$k_title;
        
$edit['podcasturl'] =& $vbulletin->GPC['podcasturl'];
        
$edit['podcastsize'] =& $vbulletin->GPC['podcastsize'];
        
$edit['podcastexplicit'] =& $vbulletin->GPC['podcastexplicit'];
        
$edit['podcastkeywords'] =& $vbulletin->GPC['podcastkeywords'];
        
$edit['podcastsubtitle'] =& $vbulletin->GPC['podcastsubtitle'];
        
$edit['podcastauthor'] =& $vbulletin->GPC['podcastauthor'];        
        
$edit['signature'] =& $vbulletin->GPC['signature'];
        
$edit['disablesmilies'] =& $vbulletin->GPC['disablesmilies'];
        
$edit['enablesmilies'] = $edit['allowsmilie'] = ($edit['disablesmilies']) ? 1;
        
$edit['stickunstick'] =& $vbulletin->GPC['stickunstick'];
        
$edit['openclose'] =& $vbulletin->GPC['openclose'];
        
$edit['visible'] = $visible_val;

        
$edit['reason'] = fetch_censored_text($vbulletin->GPC['reason']);
        
$edit['preview'] =& $vbulletin->GPC['preview'];
        
$edit['folderid'] =& $vbulletin->GPC['folderid'];    

    
$dataman =& datamanager_init('Post'$vbulletinERRTYPE_ARRAY'threadpost');
    
$dataman->set_existing($postinfo);
//print"<P>edit:<pre>".print_r($edit,1);
    // set info
    
$dataman->set_info('parseurl', ($foruminfo['allowbbcode'] AND $edit['parseurl']));
    
$dataman->set_info('posthash'$posthash);
    
$dataman->set_info('forum'$foruminfo);
    
$dataman->set_info('visible'$visible_val);
    
$dataman->set_info('thread'$threadinfo);
    
$dataman->set_info('show_title_error'true);
    
$dataman->set_info('podcasturl'$edit['podcasturl']);
    
$dataman->set_info('podcastsize'$edit['podcastsize']);
    
$dataman->set_info('podcastexplicit'$edit['podcastexplicit']);
    
$dataman->set_info('podcastkeywords'$edit['podcastkeywords']);
    
$dataman->set_info('podcastsubtitle'$edit['podcastsubtitle']);
    
$dataman->set_info('podcastauthor'$edit['podcastauthor']);
    if (
$postinfo['userid'] == $vbulletin->userinfo['userid'])
    {
        
$dataman->set_info('user'$vbulletin->userinfo);
    }
//print"<P>userinfo:<pre>".print_r($vbulletin->userinfo,1);


    // set options
    
$dataman->setr('showsignature'$edit['signature']);
    
$dataman->setr('allowsmilie'$edit['enablesmilies']);

    
// set data
    /*$dataman->setr('userid', $vbulletin->userinfo['userid']);
    if ($vbulletin->userinfo['userid'] == 0)
    {
        $dataman->setr('username', $post['username']);
    }*/
    
$dataman->setr('title'$edit['title']);
    
$dataman->setr('visible'$edit['visible']);
    
$dataman->setr('pagetext'$edit['message']);
    if (
$postinfo['userid'] != $vbulletin->userinfo['userid'])
    {
        
$dataman->setr('iconid'$edit['iconid'], truefalse);
    }
    else
    {
        
$dataman->setr('iconid'$edit['iconid']);
    }
    
    
$dataman->pre_save();
    if (
$dataman->errors)
    {
        
$errors $dataman->errors;
    }
    
    if (
sizeof($errors) > 0)
    {
        
// ### POST HAS ERRORS ###
        
print"<P>ERRORS:<pre>".print_r($errors,1);
            
    }    
    else
    {
        
// ### POST HAS NO ERRORS ###

        
print"<P>No errors so far !";
        print
"<P>edit:<pre>".print_r($edit,1);

        print 
"<P>result is :".$dataman->save();    

        
$date vbdate($vbulletin->options['dateformat'], TIMENOW);
        
$time vbdate($vbulletin->options['timeformat'], TIMENOW);

        
// initialize thread / forum update clauses
        
$forumupdate false;

        
$threadman =& datamanager_init('Thread'$vbulletinERRTYPE_SILENT'threadpost');
        
$threadman->set_existing($threadinfo);

    if (
$edit['title'] != '' )
        {
            
// need to update thread title and iconid            
            
$threadman->set_info('skip_first_post_update'false);
            
$threadman->set('title'unhtmlspecialchars($edit['title']));
            
$threadman->set('visible'$edit['visible']);
            
$threadman->set('iconid'$edit['iconid']);

            
// do we need to update the forum counters?
            
$forumupdate = ($foruminfo['lastthreadid'] == $threadinfo['threadid']) ? true false;
        }
        else{
        print 
"<P> line 237 not update thread";
        }
                
        
$threadman->save();
        
        require_once(
DIR '/includes/functions_databuild.php');

        
// do forum update if necessary
        
if ($forumupdate)
        {
            
build_forum_counters($threadinfo['forumid']);
        }

        
$cansubscribe true;
        
        
//    $vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "p=$postinfo[postid]#post$postinfo[postid]";                
    
}
}
?>
Reply With Quote
  #25  
Old 12-03-2006, 11:23 PM
Derschizo Derschizo is offline
 
Join Date: Jul 2005
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That looks interesting can you show me how to implement and make it fully work completely. I'm not sure exactly where you put the code and what each section completely means. I'm assuming it goes to the function_newpost .
Reply With Quote
  #26  
Old 12-04-2006, 03:18 AM
amcd amcd is offline
 
Join Date: Oct 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That depends on what you want to achieve. In vbulletin 3.5 or higher, editing the original php files is discouraged and its better to add plugins.
Reply With Quote
  #27  
Old 12-09-2006, 03:10 PM
jj's Avatar
jj jj is offline
 
Join Date: Sep 2005
Location: Viernheim, Germany
Posts: 188
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi guys, I'm creating/posting/modifying posts/thread out of some custom software I wrote. Now is there a way of bypassing the post-time limit with the datamanager-method when doing it?
Reply With Quote
  #28  
Old 12-21-2006, 03:38 PM
BOLT BOLT is offline
 
Join Date: Dec 2006
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I dont understand. Where do you enter this code? And how do you make the post, time, thread, etc. be what exactly you want?
Reply With Quote
  #29  
Old 05-27-2007, 03:36 AM
liquidx liquidx is offline
 
Join Date: Nov 2002
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can someone help here?

I'm trying to create new posts, I've tried both the dataman and build_new_post methods, here's my problems:

Dataman method:
How do I handle errors? When I get an error (like posting anonymously with a user name that is already in use) it directly echos out a full error page! I don't want this, I want just the error message..

build_new_post method:
When posting anonymous, the new posts are moderated, even though the forum allows anonymous posting and is not moderated.. I can't figure out how to stop this from happening.

I've searched all over the forums for both these issues but came up empty, anyone?
Reply With Quote
  #30  
Old 07-04-2007, 10:26 PM
quitsmoking quitsmoking is offline
 
Join Date: Mar 2006
Location: Egypt
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And what if I want to add a new thread (not a post in an existing thread)?
Reply With Quote
  #31  
Old 07-05-2007, 11:49 AM
fly fly is offline
 
Join Date: Oct 2003
Posts: 1,215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Then you'd find the thread about HowTo Create Threads.
Reply With Quote
Reply

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

Forum Jump


All times are GMT. The time now is 01:22 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.04558 seconds
  • Memory Usage 2,442KB
  • 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
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)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
  • (4)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