Version: , by dubucm (Guest)
Developer Last Online: Jan 1970
Version: Unknown
Rating:
Released: 03-26-2001
Last Update: Never
Installs: 0
No support by the author.
Hi everyone,
First I apologize for my "frenchie" english .
Vbulletin is a great forum software.... but many of us are webmaster from website with articles, tutorials, contribution and more .
We are all using PHP/MySQL to have "automated" website.
As far as i am concern, my website deals with Flash. And i needed to have comments/questions forums for all of my tutorials and contributions.
My website is "automatic" and a user can add a script/tutorial so i was obliged to found a way to automatically create this comments forum. ( and with VBulletin on my website i did not want to create a comments table .... )
So here is a script with some usefull function to do that.
It creates a thread and insert a message in it. ( you should create a forum not visible from the users and use it's forum id ).
You can easilly understand how it works i think. .
Do not h?sitate for questions... i'll help you.
( Just wanna thanx TubeDog for his helps ).
I'll improve the script adding those features :
- Functions to retreive number of comments/questions for an article.
- E Mail sending to the articles author for each new responses.
- and more ... jsut ask away .
here it is :
PLEASE TAKE CARE OF CHANGING i conid by iconid ( the same for ipad dress by ipaddress etc.. ( see the post from tubedogg bellow ) due to a "bug" i cannot fix it manullay in my post sorry.
PHP Code:
<?
function InsertThread($THREADTITLE)
{
global $mysql_link_forum,$mysql_link_corpo,$db_forum,$db_corpo;
mysql_db_query($db_forum,"INSERT INTO thread(threadid,title,lastpost,forumid,open,replycount,postusername,postuserid,lastposter,dateline,iconid,visible,attach) VALUES (NULL,'".addslashes("$THREADTITLE")."','".time()."','38','1','0','martin','2','martin','".time()."','1','1','0')",$mysql_link_forum) or die ("REQUETE PB1.");
// give the thread id
$threadidresult = mysql_db_query($db_forum, "SELECT threadid FROM thread WHERE title='".addslashes("$THREADTITLE")."'" , $mysql_link_forum) or die ("REQUETE PB.");
$threadid = mysql_result($threadidresult,0,0) or die ("REQUETE PB.");
return $threadid;
}
function InsertPost($THREADID,$MESSAGE)
{
global $mysql_link_forum,$mysql_link_corpo,$db_forum,$db_corpo;
mysql_db_query($db_forum,"INSERT INTO post (postid,threadid,title,username,userid,dateline,attachmentid,pagetext,allowsmilie,showsignature,ipaddress,iconid,visible) VALUES (NULL,'$THREADID','','martin','2','".time()."','','".addslashes("$MESSAGE")."','1','1','127.0.0.1','1','1')",$mysql_link_forum) or die ("REQUETE PB2.");
}
function UpdateTutTable($THREADID,$TUTID)
{
global $mysql_link_forum,$mysql_link_corpo,$db_forum,$db_corpo;
mysql_db_query($db_corpo,"update TUTORIALTABLE set threadid='$THREADID' where artid='$TUTID'",$mysql_link_corpo) or die ("REQUETE PB3.");
}
function AddTutForum($TUTID)
{
global $mysql_link_forum,$mysql_link_corpo,$db_forum,$db_corpo;
$result_tut = mysql_db_query($db_corpo,"SELECT title,description FROM TUTORIALTABLE WHERE artid='$TUTID'",$mysql_link_corpo) or die ("REQUETE PB4.");
list($THREADTITLE,$MESSAGE) = mysql_fetch_row($result_tut);
$MESSAGE.="<br>Use this thread to post all your comments / questions on this article.";
$THREADID=InsertThread($THREADTITLE);
InsertPost($THREADID,$MESSAGE);
UpdateTutTable($THREADID,$TUTID);
echo "DONE";
// jsut to see if everythin as well worked. :)
}
// MAIN PROGRAM
$dbhost='';
$dbname_forum='';
$dbname_corpo='';
$dbpass_forum='';
$dbpass_corpo='';
$dbuser_forum='';
$dbuser_corpo='';
$db_forum = '';
$db_corpo = '';
$mysql_link_forum = mysql_connect($dbhost,$dbuser_forum,$dbpass_forum) or DIE ("Impossible de trouver la serveur de donn?e1");
$mysql_link_corpo = mysql_connect($dbhost,$dbuser_corpo,$dbpass_corpo) or DIE ("Impossible de trouver la serveur de donn?e2");
AddTutForum($TUTID);
?>
it's really a little contribution but it's my first one... and i know vbulletin since only 1 week ...
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
This is my fault, cause I gave you the code (but I think it's really vB's fault, because I double-checked the code!!), but in the insert thread function, you need to change
Yes it's already done in the script I gave.. I had some mysql error ... but it was so strange to have i conid... so a little "phpmyadmin trip" and it was corrected.
Tommorrow i'll add some functions .
But do you know how i can have an e mail automaticcaly send to the author of the article when a message is posted in the thread ?