PHP Code:
<?php
/*****************************\
* Name: GRPS: Groups Commune
* Written By: Paul "sabret00the" Walker-Daley
* Concept: 30 October 2003
* Spawned: 26 March 2005
* Copyright Since: 23 April 2004
* Gold: 19 October 2006
* Modified: 21 December 2006
* Contact: sabe@ebslive.com
\*****************************/
// ################ SET SCRIPT LOCATION ENVIRONMENT ######################
require_once('./includes/config_grps.php');
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('GET_EDIT_TEMPLATES', true);
define('THIS_SCRIPT', 'groupsreply');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('grps', 'threadmanage', 'posting');
// get special data templates from the datastore
$specialtemplates = array(
'smiliecache',
'bbcodecache'
);
// pre-cache templates used by specific actions
$actiontemplates = array();
$globaltemplates = array(
'groups_newreply'
);
// ### STANDARD INITIALIZATIONS ###
$checked = array();
$newpost = array();
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/functions_newpost.php');
require_once('./includes/functions_editor.php');
require_once('./includes/functions_bigthree.php');
require_once(DIR . '/includes/class_postbit.php');
require_once('./includes/class_grps.php');
require_once('./includes/functions_grps.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (empty($vbulletin->userinfo['userid']))
{
print_no_permission();
}
($hook = vBulletinHook::fetch_hook('grps_global_start')) ? eval($hook) : false;
// get decent textarea size for user's browser
$textareacols = fetch_textarea_width();
$vbulletin->input->clean_array_gpc('r', array(
'noquote' => TYPE_BOOL,
'p' => TYPE_INT,
));
// ### GET QUOTE FEATURES ###
// check for valid thread or post
if (!empty($vbulletin->GPC['p']))
{
$getquotedetails = $db->query_first("
SELECT username, pagetext, dateline, groupid, threadid
FROM grps_post
WHERE postid = " . intval($vbulletin->GPC['p'])
);
$originalposter = $getquotedetails['username'];
$postdate = vbdate($vbulletin->options['dateformat'], $getquotedetails['dateline']);
$posttime = vbdate($vbulletin->options['timeformat'], $getquotedetails['dateline']);
$pagetext = htmlspecialchars_uni($getquotedetails['pagetext']);
$pagetext = trim(strip_quotes($pagetext));
$groupid = $getquotedetails['groupid'];
$threadid = $getquotedetails['threadid'];
eval('$newpost[\'message\'] = "' . fetch_template('newpost_quote', 1, 0) . '";');
// fetch the quoted post title
$newpost['title'] = htmlspecialchars_uni(fetch_quote_title($postinfo['title'], $threadinfo['title']));
}
// ############################### start post reply ###############################
if (isset($_POST['do']) AND $_POST['do'] == 'postreply')
{
$vbulletin->input->clean_array_gpc('p', array(
'g' => TYPE_INT,
'p' => TYPE_INT,
'parentid' => TYPE_INT,
'userid' => TYPE_INT,
'ipaddress' => TYPE_STR,
'wysiwyg' => TYPE_BOOL,
'message' => TYPE_STR,
'quickreply' => TYPE_BOOL,
'fromquickreply' => TYPE_BOOL,
'folderid' => TYPE_UINT,
'emailupdate' => TYPE_UINT,
'title' => TYPE_STR,
'iconid' => TYPE_UINT,
'parseurl' => TYPE_BOOL,
'signature' => TYPE_BOOL,
'preview' => TYPE_STR,
'disablesmilies' => TYPE_BOOL,
'username' => TYPE_STR,
'rating' => TYPE_UINT,
'stickunstick' => TYPE_BOOL,
'openclose' => TYPE_BOOL,
'ajax' => TYPE_BOOL,
'ajax_lastpost' => TYPE_INT
));
$threadinfo = grps_getthreadinfo($_POST['t']);
$grps_ids = explode(' ', trim($vbulletin->userinfo['grps']));
if (!in_array($vbulletin->GPC['g'], $grps_ids))
{
print_no_permission();
}
if (sizeof($errors) > 0)
{
// ### POST HAS ERRORS ###
$postpreview = construct_errors($errors); // this will take the preview's place
construct_checkboxes($newpost);
$_GET['do'] = 'newreply';
$newpost['message'] = htmlspecialchars_uni($newpost['message']);
}
else if ($vbulletin->GPC['preview'])
{
// ### PREVIEW POST ###
$newpost['message'] = htmlspecialchars_uni($newpost['message']);
$postpreview = grps_datamanager::build_post_preview($newpost, $vbulletin->userinfo['userid']);
$previewpost = true;
$_GET['do'] = 'newreply';
}
else
{
grps_datamanager::build_group_post($_POST);
($hook = vBulletinHook::fetch_hook('grps_newreply_successful')) ? eval($hook) : false;
// ### NOT PREVIEW - ACTUAL POST ###
if (!$vbulletin->options['grpsmoderateposts'])
{
$grps_numberofposts = $db->query_first("
SELECT COUNT(*) AS posttotal, MAX(postid) AS postid
FROM grps_post
WHERE groupid = " . intval($threadinfo['groupid']) . " AND threadid = " . intval($threadinfo['threadid']) . "
");
$whatpage = ceil($grps_numberofposts['posttotal'] / $vbulletin->options['grpspostsperpage']);
if ($whatpage > 1)
{
$gotopage = '&page=' . $whatpage;
}
else
{
$gotopage = FALSE;
}
$vbulletin->url = 'viewthread.php?' . $vbulletin->session->vars['sessionurl'] . 'g=' . $threadinfo['groupid'] . '&t=' . $threadinfo['threadid'] . $gotopage . '#post' . $grps_numberofposts['postid'];
}
else
{
$vbulletin->url = 'viewthread.php?' . $vbulletin->session->vars['sessionurl'] . 'g=' . $threadinfo['groupid'] . '&t=' . $threadinfo['threadid'];
}
eval(print_standard_redirect('Redirecting...', FALSE));
} // end if
}
// ############################### start new reply ###############################
if (isset($_GET['do']) AND $_GET['do'] == 'newreply')
{
$vbulletin->input->clean_array_gpc('r', array(
't' => TYPE_INT
));
// echo $threadid;
$threadid = (empty($threadid)) ? $vbulletin->GPC['t'] : $threadid;
$threadinfo = grps_getthreadinfo($threadid);
$foruminfo = grps_getgroupinfo($threadinfo['groupid']);
$newpost = array('title' => NULL, 'iconid' => NULL, 'message' => htmlspecialchars_uni($newpost['message']));
$foruminfo = @array_merge($foruminfo, array('allowbbcode' => TRUE, 'allowimages' => TRUE, 'allowhtml' => FALSE, 'allowsmilies' => TRUE, 'forumid' => NULL));
$grps_ids = explode(' ', trim($vbulletin->userinfo['grps']));
if (!in_array($threadinfo['groupid'], $grps_ids))
{
print_no_permission();
}
// falls down from preview post and has already been sent through htmlspecialchars() in build_new_post()
$title = ($newpost['title']) ? construct_phrase($vbphrase['grps_re_x'], $newpost['title']) : '';
// *********************************************************************
// get options checks
$posticons = construct_icons($newpost['iconid'], 1);
$editorid = construct_edit_toolbar(
$newpost['message'],
0,
$foruminfo['forumid'],
1,
1,
($forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] AND $vbulletin->userinfo['userid'])
);
$messagearea = str_replace(
array(
'="clientscript',
'src="images/smilies/'
),
array(
'="' . $vbulletin->options['bburl'] . '/clientscript',
'src="' . $vbulletin->options['bburl'] . '/images/smilies/'
),
$messagearea);
$posticons = str_replace('src="images/icons/', 'src="' . $vbulletin->options['bburl'] . '/images/icons/', $posticons);
// auto-parse URL
if (!isset($checked['parseurl']))
{
$checked['parseurl'] = 'checked="checked"';
}
if ($vbulletin->userinfo['userid'] AND !$postpreview)
{
// signature
$checked['signature'] = ($vbulletin->userinfo['signature'] != '') ? 'checked="checked"' : '';
}
eval('$usernamecode = "' . fetch_template('newpost_usernamecode') . '";');
$usernamecode = grps_rewrite_links($usernamecode);
// *********************************************************************
// finish the page
construct_forum_rules($foruminfo, $forumperms);
// draw nav bar
$navbits = array();
$navbits['browse.php?' . $vbulletin->session->vars['sessionurl'] . 'c=' . $foruminfo['catid']] = $foruminfo['catname'];
$navbits['groups.php?' . $vbulletin->session->vars['sessionurl'] . 'g=' . $foruminfo['groupid']] = $foruminfo['title'];
$navbits['viewthread.php?' . $vbulletin->session->vars['sessionurl'] . 'g=' . $foruminfo['groupid'] . '&t=' . $threadinfo['threadid']] = $threadinfo['title'];
$navbits[''] = $vbphrase['reply_to_thread'];
$navbits = construct_navbits($navbits);
eval('$headinclude = "' . fetch_template('headinclude') . '";');
$headinclude = grps_rewrite_links($headinclude);
eval('$navbar = "' . fetch_template('navbar') . '";');
$navbar = grps_rewrite_links($navbar);
eval('$footer = "' . fetch_template('footer') . '";');
$footer = grps_rewrite_links($footer);
($hook = vBulletinHook::fetch_hook('grps_global_complete')) ? eval($hook) : false;
// complete
eval('print_output("' . fetch_template('groups_newreply') . '");');
}
?>