Log in

View Full Version : MySQL queries for posting a new thread


Darth Cow
07-19-2002, 08:07 PM
Hello! I'm interested in what direct MySQL queries would be necesary to add a new thread in the preset forum of my choice, without worrying about any verification, ect. It can be just like a thread made by a Guest, however, it would need to be put into a forum with access for only mods/admins. We (at MTGnews.com) are trying to update our news submissions forms to make new threads for reported news in a special forum. We can format everything into whatever format. I've been trying to edit the newthread.php and what not to do some, but there are several files that need to be edited to allow posting as such and it's a pain largely because we don't want to have to log users out of our forums or cause any other difficulties. Unfortunately, it's not exactly clear what the necessary info is for the queries to insert a new thread/post with a guest acount is, nor how to how to execute them. Maybe someone more experienced with vB knows how to do this? Thanks!

SaintDog
07-19-2002, 09:13 PM
Darth Cow, please go to this (http://www.vbulletin.com/members/vbulletin.org.php) page and enter your username, to show you are licensed. (you will need to use your customer number and password to access that page)
Thank you.

Darth Cow
07-19-2002, 09:40 PM
Ok, well here's the issue then. I know that we're liscensed, however only the webmaster has the liscense stuff. Before I ask for it, is it possible to have multiple users on these forums on the same liscense? Wouldn't want to lock him out or something... :)

SaintDog
07-20-2002, 12:29 AM
Yes, have him goto: this (http://www.vbulletin.com/members/vbulletin.org.php) page and enter your username in the form.

- SaintDog

Darth Cow
07-21-2002, 06:16 PM
There! I finally got my lazy webmaster to give me licensed access. Now, does anyone know how to help me? :D

Logician
07-22-2002, 08:21 AM
<a href="https://vborg.vbsupport.ru/showthread.php?s=&threadid=37446" target="_blank">https://vborg.vbsupport.ru/showt...threadid=37446</a>

Darth Cow
07-22-2002, 09:45 PM
Originally posted by Logician
https://vborg.vbsupport.ru/showthread.php?s=&threadid=37446

Thanks, but there's a couple of issues - I want to make a new thread, not reply to an old one and the redirection needs to take you elsewhere, since the news submissions will be going to a hidden form (for non-mods). That's why I was looking for the specific MySQL queries, because I figured that just might be easier then editing newthread.php :).

Admin
07-23-2002, 06:32 AM
You basically need two things, INSERT INTO thread and INSERT INTO post. Then you need to updateforumcount() for the forum, and if you are posting as a user, you need to update that user's information (lastpost, total posts, etc.).

Most of the things in newthread.php are NOT expendable.

Darth Cow
07-23-2002, 07:00 PM
Originally posted by FireFly
You basically need two things, INSERT INTO thread and INSERT INTO post. Then you need to updateforumcount() for the forum, and if you are posting as a user, you need to update that user's information (lastpost, total posts, etc.).

Most of the things in newthread.php are NOT expendable.

Thanks! I seem to have gotten it down to what I figure is the minimum. However, I have one other concern - how do I allow the echoing or leaving of PHP when I'm requiring global.php? Is there anyway to turn off template processing for a page, so that I can just load database/functions/config features that you need to get it basically functioning? I want to be able to do non-vBulletin template powered echoing of information and includes. Thanks :)

Admin
07-23-2002, 07:02 PM
You don't need to use the templates, just echo directly as you would with any other PHP file.

Darth Cow
07-23-2002, 07:11 PM
Hmm... the file I have it outside of the forums directory - could that be an issue? Because nothing is being displayed, unlike when I put it in the forums directory.

EDIT: Ok, so will this take care of connecting to the database, database function and other vB functions? I have no need for sessions or any of that, just the *basic* things that will allow me to insert new threads.

require('./admin/config.php');

$dbservertype = strtolower($dbservertype);
$dbclassname="./admin/db_$dbservertype.php";
require($dbclassname);

$DB_site=new DB_Sql_vb;

$DB_site->appname='vBulletin';
$DB_site->appshortname='vBulletin (forum)';
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;

$DB_site->connect();

$dbpassword="";
$DB_site->password="";

require('./admin/functions.php');

nabeel
07-23-2002, 07:14 PM
yeah it could be outside of the forum directory

do you have the paths etc correct?

Darth Cow
07-23-2002, 07:18 PM
Originally posted by nabeel
yeah it could be outside of the forum directory

do you have the paths etc correct?

Yes, I'm certain that I was - I was getting no error messages.

See my edit above for how I hope to solve this for the sake of simplicity.

EDIT: $foruminfo[parentlist] - how can I load this up (needed in DB query for updating a forum)?

nabeel
07-23-2002, 08:15 PM
whats the

$dbpassword="";
$DB_site->password="";

for after the connect?

what are the queries you use?

I think they use $DB_site->query() etc, i just use the normal mysql_query


this is how i have mine setup

include_once("/home/vhosts/fragblast.com/httpdocs/forums/admin/db_mysql.php");
$DB_site=new DB_Sql_vb;
$DB_site->appname='vBulletin';
$DB_site->appshortname='vBulletin (forum)';
$DB_site->database="fragblast";
$DB_site->server="localhost";
$DB_site->user="myusername";
$DB_site->password="mypass";
$DB_site->connect();

include("/home/vhosts/fragblast.com/httpdocs/forums/admin/functions.php");
include("/home/vhosts/fragblast.com/httpdocs/forums/admin/sessions.php");

i didnt bother with the config.php


and the query isnt showing anything?

try doing
echo mysql_error(); to see if something did go wrong

Darth Cow
07-23-2002, 09:21 PM
$dbpassword="";
$DB_site->password="";

I think it's so you don't give out your db password accidently through a template or something :p.

Well, just FYI everyone, I finally got my thing working :). I first created a file vbbasics.php that I put in the folder with the submissions forum, which had what I posted above. I then figured out the basic queries to do to get it working in the submit form. The final code was kinda complex ;) and included some site specific stuff, so I doubt it would work as a hack I could submit to the hack database, though I will attach most of it :).

nabeel
07-23-2002, 09:41 PM
heh cool