Announcement

Collapse
No announcement yet.

Creating a new thread using an external program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a new thread using an external program

    I'm looking for the PHP code to create a new thread in a specific forum.

    Julie
    http://www.the-gadgeteer.com

  • #2
    Originally posted by The Gadgeteer
    I'm looking for the PHP code to create a new thread in a specific forum.

    Julie
    http://www.the-gadgeteer.com
    All you have to do is insert a row in the thread and post tables along with some housekeeping (counters and whatnot).
    --filburt1, vBulletin.org/vBulletinTemplates.com moderator
    Web Design Forums.net: vB Board of the Month
    vBulletin Mail System (vBMS): webmail for your forum users

    Comment


    • #3
      Originally posted by filburt1
      All you have to do is insert a row in the thread and post tables along with some housekeeping (counters and whatnot).
      Can you give me a little more detail please? Or tell me where I can find more info.

      Thanks,
      Julie

      Comment


      • #4
        Originally posted by The Gadgeteer
        Can you give me a little more detail please? Or tell me where I can find more info.

        Thanks,
        Julie
        here is my vb2 forum class from my backend

        PHP Code:
        <?php

        error_reporting
        (E_ALL & ~E_NOTICE);

        class 
        forum
        {

            function 
        checkauth ($username$userid$password$ismd5)
            {
                if (!
        $ismd5)
                {
                    
        $password md5($password);    
                }
                
                if (
        $userid)
                {
                    
        $user mysql_query("SELECT * FROM user WHERE userid=$userid");    
                }
                else
                {
                    
        $user mysql_query("SELECT * FROM user WHERE username='" addslashes($username) . "'");    
                }

                
        $userinfo mysql_fetch_array($user);
                if (
        $userinfo['password'] == $password)
                {
                    return 
        true;    
                }
                else
                {
                    return 
        false;    
                }
            }

            function 
        getforumlist ()
            {

                
        $forumcache = array('0' => 'No Forum');
                
        $forums mysql_query("SELECT * FROM forum WHERE cancontainthreads=1");
                while (
        $forum mysql_fetch_array($forums))
                {
                    
        $forumcache["$forum[forumid]"] = $forum['title'];
                }
                return 
        $forumcache;

            }

            function 
        newthread ($forumid$userid$username$ip$title$post)
            {
                
        mysql_query("INSERT INTO thread (threadid,title,lastpost,forumid,open,replycount,postusername,postuserid,lastposter,dateline,iconid,visible,attach) VALUES (NULL,'".addslashes(htmlspecialchars($title))."','".time()."','$forumid','1','0','".addslashes($username)."','$userid','".addslashes($username)."','".time()."','0','1','0')");
                
        $threadid mysql_insert_id();
                
        mysql_query("INSERT INTO post (postid,threadid,title,username,userid,dateline,attachmentid,pagetext,allowsmilie,showsignature,ipaddress,iconid,visible) VALUES (NULL, $threadid,'" addslashes(htmlspecialchars($title)) . "','" addslashes($username) . "', '$userid', '".time()."', 0, '" addslashes($post) . "', 0, '', '$ip', 0, 1)");
                
        mysql_query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1,lastpost='".time()."',lastposter='".addslashes($username)."' WHERE forumid=$forumid");
                return 
        $threadid;

            }

            function 
        updatethread ($threadid$title$post)
            {

                
        $postid mysql_query_first("SELECT MIN(postid) AS postid FROM post WHERE threadid=$threadid");
                
        mysql_query("UPDATE thread SET title='" addslashes(htmlspecialchars($title)) . "' WHERE threadid=$threadid");
                
        mysql_query("UPDATE post SET title='" addslashes(htmlspecialchars($title)) . "', pagetext='" addslashes($post) . "' WHERE postid=$postid[postid]");

            }

            function 
        deletethread ($threadid)
            {
                
        $posts mysql_query("SELECT userid,attachmentid,postid FROM post WHERE threadid=$threadid");
                    while (
        $post mysql_fetch_array($posts))
                {
                    if (
        $post['attachmentid'])
                    {
                        
        $attachmentids .= $post['attachmentid'].",";
                    }
                }

                if (!empty(
        $attachmentids))
                {
                    
        $checkattachments mysql_query("SELECT DISTINCT attachmentid FROM post WHERE attachmentid IN ($attachmentids"."0) AND threadid<>$threadid");
                    unset(
        $omitattachmentids);
                    while (
        $omitattach mysql_fetch_array($checkattachments))
                    {
                        
        $omitattachmentids .= $omitattach['attachmentid'] . ',';
                    }
                    
        mysql_query("DELETE FROM attachment WHERE attachmentid IN ($attachmentids"."0) AND attachmentid NOT IN ($omitattachmentids"."0)");
                }
                
        mysql_query("DELETE FROM post WHERE threadid=$threadid");
                
        mysql_query("DELETE FROM thread WHERE threadid=$threadid");
                
        mysql_query("DELETE FROM thread WHERE open=10 AND pollid=$threadid");
                
        mysql_query("DELETE FROM threadrate WHERE threadid=$threadid");
                
        mysql_query("DELETE FROM subscribethread WHERE threadid=$threadid");
            }

        }

        ?>
        though i haven't fully tested it, it presumes you have a connection to your database though.
        Scott MacVicar

        My Blog | Twitter

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X