Thread: Create Posts
View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01252 seconds
  • Memory Usage 1,959KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete