Here is my entire script - the variables in $_GET are all form variables being sent via AJAX to a page processing the form and creating a new thread:
PHP Code:
<?php
// Get Required Includes
require_once('global.php');
require_once('includes/class_dm.php');
require_once('includes/class_dm_threadpost.php');
require_once('includes/functions_databuild.php');
// Retrieve data from Query String
$name = $_GET['name'];
$lat = $_GET['lat'];
$lon = $_GET['lon'];
$uid = $_GET['uid'];
$uname = $_GET['uname'];
$gid = $_GET['gid'];
$desc = $_GET['desc'];
$phone = $_GET['phone'];
$addr = $_GET['addr'];
$addr2 = $_GET['addr2'];
$city = $_GET['city'];
$state = $_GET['state'];
$zip = $_GET['zip'];
$cat = $_GET['cat'];
// Escape User Input to help prevent SQL Injection
$name = mysql_real_escape_string($name);
$lat = mysql_real_escape_string($lat);
$lon = mysql_real_escape_string($lon);
$uid = mysql_real_escape_string($uid);
$uname = mysql_real_escape_string($uname);
$gid = mysql_real_escape_string($gid);
$desc = mysql_real_escape_string($desc);
$phone = mysql_real_escape_string($phone);
$addr = mysql_real_escape_string($addr);
$addr2 = mysql_real_escape_string($addr2);
$city = mysql_real_escape_string($city);
$state = mysql_real_escape_string($state);
$zip = mysql_real_escape_string($zip);
$cat = mysql_real_escape_string($cat);
// Thread_FirstPost DataManager to add thread
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$threadinfo = array();
// unsure about these two
$threaddm->set_info('forum', $foruminfo);
$threaddm->set_info('thread', $threadinfo);
// set to correct forum to use
$forumtouse = 57;
$threaddm->setr('forumid', $forumtouse);
// user information - uid and username come from submitted form
$threaddm->setr('userid', $uid);
$threaddm->setr('username', $uname);
$threadtitle = "Some title text";
$threaddm->setr('title', $threadtitle);
// Set thread contents
$pagetext = $desc;
$threaddm->setr('pagetext', $pagetext);
// allow replies
$threaddm->set('open', $open);
// allow smilies
$threaddm->set('allowsmilie', $allowsmilie);
// make visible
$threaddm->set('visible', $visible);
// pre-save
$threaddm->pre_save();
$threadid = $threaddm->save();
unset($threaddm);
build_thread_counters($threaddm);
build_forum_counters($foruminfo['forumid']);
There exists more code below this but none of it deals with inserting a new thread.