View Single Post
  #1  
Old 06-02-2006, 02:27 PM
MoFish MoFish is offline
 
Join Date: May 2006
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help With Creating A Thread Please

hello, im wondering if anyone can point me in the right direction. im trying to create a page with a form. Once the user clicks the submit button on the form I want it to create a new thread in a specified area of my forum. I am running into trouble creating this script using some code I found lieing about the forum.

Is this the correct way to do things? because im getting an error "Parse error: parse error, unexpected $end"

here is the code im trying go get working.

Code:
<?php
// ############################## NOTES #################################
/**
* NOTE: user permissions are not checked in this example script and guest 
* posting is allowed by default. Set the full path to your main forum 
* directory, FTP to wherever, and call this script from your browser to 
* test it out. Read the code for further details.
*/

// ########################### CONFIGURATION #############################
// set the full path to your main forum directory
define('FWD','H:\wamp\www\Forum');

// #################### PRE-CACHE TEMPLATES AND DATA #####################
$phrasegroups = array('cpglobal');

// ######################### REQUIRE BACK-END ############################
define('BWD', (($getcwd = getcwd()) ? $getcwd : '.'));
chdir(FWD);
require_once('./global.php');
chdir(BWD);

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

// use the default function parameters
//create_new_thread();

if (!isset($_POST['submit'])){
?>
<form name="form1" method="post" action="create_new_thread.php">
  <input type="submit" name="submit" value="submit">
</form>
<?
}else{

// alternatively set the function parameters
$title = 'Hello There';
$message = 'Alternative Message';
$id = 4;
$guest = true;
create_new_thread($title, $message, $id, $guest);

}
// ###################### Start create_new_thread ########################
/**
* Creates new thread or gives error and then redirects user
*
* @param	string	Title of thread
* @param	string	Message of post
* @param	integer	ForumID for thread
* @param	boolean	Allow guest posts
*/
function create_new_thread($title = 'Default Title', $message = 'Default Message', $id = 2, $guest = true)
{
	// set some globals

	global $forumperms, $vbulletin, $vbphrase;

	// init some variables

	$fail = 0;
	$errors = array();
	$newpost = array();

	// init post information

	if ($guest AND $vbulletin->userinfo['userid'] == 0)
	{
		$newpost['username'] = $vbphrase['guest'];
	}
	$newpost['title'] = $title;
	$newpost['message'] = $message;
	$newpost['signature'] = '0';
	if ($vbulletin->userinfo['signature'] != '')
	{
		$newpost['signature'] = '1';
	}
	$newpost['parseurl'] = '1';
	$newpost['emailupdate'] = '9999';

	// attempt thread create

	$foruminfo = verify_id('forum', $id, 0, 1);
	if (!$foruminfo['forumid'])
	{
		$fail = 1;
	}
	$forumperms = fetch_permissions($foruminfo['forumid']);
	if (!function_exists('build_new_post'))
	{
		require_once(DIR . '/includes/functions_newpost.php');
	}
	build_new_post('thread', $foruminfo, array(), array(), $newpost, $errors);
	if (sizeof($errors) > 0)
	{
		$fail = 1;
	}

	// do redirection

	if (!$fail)
	{
		$vbulletin->url = $vbulletin->options['bburl'] . '/showthread.php?' . $vbulletin->session->vars['sessionurl'] . "p=".$newpost['postid']."#post".$newpost['postid'];
		eval(print_standard_redirect('redirect_postthanks'));
	}
	else
	{
		$vbulletin->url = $vbulletin->options['bburl'];
		eval(print_standard_redirect($vbphrase['error'].': '.$vbphrase['redirecting'],0,1));
	}
}
?>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01629 seconds
  • Memory Usage 1,781KB
  • 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_code
  • (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