vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Help With Creating A Thread Please (https://vborg.vbsupport.ru/showthread.php?t=117436)

MoFish 06-02-2006 03:27 PM

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));
        }
}
?>



All times are GMT. The time now is 05:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00941 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete