ks_work |
11-23-2006 12:37 PM |
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']) ? 0 : 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', $vbulletin, ERRTYPE_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'], true, false);
}
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', $vbulletin, ERRTYPE_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]";
}
}
?>
|