Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by (Guest)
Developer Last Online: Show Printable Version Email this Page

Version: Unknown Rating:
Released: 07-19-2001 Last Update: Never Installs: 0
 
No support by the author.

Hy there,

we have a self-written newssystem and wanted to use our forum as archive and discussion place for news. So I wrote a little php script which creates a new thread for every newsitem. It's not a big deal:

PHP Code:
  function createPosting ($headline, $newstext, $newstime, $author, $authorid, $forumid) {

    // Create thread

    mysql_query("INSERT INTO thread (threadid, title, lastpost, forumid, pollid, open, replycount, postusername,
                                     postuserid, lastposter, dateline, views, iconid, notes, visible, sticky,
                                     votenum, votetotal, attach)
                        VALUES ('', '". addslashes($headline)."', '$newstime', '$forumid', '0', '1', '0', '$author',
                               'authorid', '$author', '$newstime', '1', '1', '', '1', '0',
                               '0', '0', '0');", $GLOBALS[dblink]);

    if(mysql_errno($GLOBALS[dblink]) != '0') {
      echo '<p>Error creating thread.</p>';
    }
    else {
      $threadid = mysql_insert_id($GLOBALS[dblink]);

      $postingtext = html2vb($newstext);

      // Create posting
      mysql_query("INSERT INTO post (postid, threadid, username, userid, title, dateline, attachmentid, pagetext,
                                   allowsmilie, showsignature, ipaddress, iconid, visible, edituserid, editdate)
                        VALUES ('', '$threadid', '$author', '$authorid', '" . addslashes($headline) ."',
                               '$newstime', '0', '" . addslashes($postingtext) ."', '1', '0', '127.0.0.1', '1', '1', '0', '0');", $GLOBALS[dblink]);

      if (mysql_errno($GLOBALS[dblink]) != '0') {
        echo '<p>Error creating posting.</p>';
      }
      else {

        // Update newsinfo
        // I write the threadid into my newsdb to link the thread later

        // Update foruminfo
        mysql_query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1,lastpost='$newstime',lastposter='".addslashes($author)."'
                     WHERE forumid = '$forumid';", $GLOBALS[dblink]);
        echo mysql_error();
      }
   }
} 
And we need a php function html2vb which converts the html to vbCode:

PHP Code:
  function html2vb ($strHTML) {
    $strVB = '';

    $strVB = trim($strHTML);  // Remove unnecessary whitespaces

    $strVB = str_replace(chr(13), '', $strVB); // Remove ascii-char 13
    $strVB = str_replace(chr(10), '', $strVB); // Remove ascii-char 10
    $strVB = str_replace('<p>', "\n\n", $strVB);  // Replace new-paragraph
    $strVB = str_replace('<br>', "\n", $strVB);   // Replace br's

    // vbCodes for bold Text
    $strVB = str_replace('<b>', '[b]', $strVB);
    $strVB = str_replace('</b>', '[/b]', $strVB);
    $strVB = str_replace('<strong>', '[b]', $strVB);
    $strVB = str_replace('</strong>', '[/b]', $strVB);

    // vbCodes for italic Text
    $strVB = str_replace('<i>', '[i]', $strVB);
    $strVB = str_replace('</i>', '[/i]', $strVB);
    $strVB = str_replace('<em>', '[i]', $strVB);
    $strVB = str_replace('</em>', '[/i]', $strVB);

    // Remove all other tags
    $strVB = ereg_replace('[<][^>]*[>]', '', $strVB);

    return $strVB;
  } 
Of course you need to add str_replace for all of your vbCodes.

Hope someone is helped with that . The best is that you don't need to modify your vBulletin source.

See it in action: http://lionsource.com

Show Your Support

  • If you like to thanks you by the author -> Click Thanks to the Author
  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-20-2001, 10:33 AM
NORRITT NORRITT is offline
 
Join Date: Nov 2001
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well done!
Reply With Quote
  #3  
Old 07-20-2001, 10:34 AM
NORRITT NORRITT is offline
 
Join Date: Nov 2001
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

damn sorry for this double posting ... IE 6 beta, I hate it
Reply With Quote
  #4  
Old 07-20-2001, 01:05 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

tststs, einer von Gamigo sieht gut aus

for all: well done
Reply With Quote
  #5  
Old 07-21-2001, 03:30 PM
Shane's Avatar
Shane Shane is offline
 
Join Date: Nov 2001
Posts: 108
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did exactlly the correct thing, and it didn't work. :-/
Reply With Quote
  #6  
Old 07-21-2001, 06:41 PM
jarvis jarvis is offline
 
Join Date: Nov 2001
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I've really been wanting to get something like this. I'm not so interested in the thread creation part of this hack, but I am really wanting to link to my threads from my home page and be able to display information like the following:

"News article here"

20 comment(s) Last post by Jarvis

I would think that there is a line of code from this hack that I should be able to use and just manually put in the forumid and thread strings, but my question is, where would I have my MySQL user information to pull this data. My main page is HTML-based, but PHP-parsed. I'm a bit nervous about embedding my user information in my homepage. Can this or any other hack do what I am asking?

Newbie questions I'm sure, but any help is greatly appreciated!!!

Thanks!!

Reply With Quote
  #7  
Old 07-21-2001, 08:22 PM
NORRITT NORRITT is offline
 
Join Date: Nov 2001
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

pernaps there is a better hack to realise that.

look here: http://www.vbulletin.com/forum/showt...threadid=12324
Reply With Quote
  #8  
Old 07-21-2001, 08:54 PM
jarvis jarvis is offline
 
Join Date: Nov 2001
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks NORRITT,

I do use that LastXX hack but not in that way. If you go to my site at www.mhogaming.com and see where I have "Discuss this Post" after each news story, I would like to replace it with the above mentioned references to vB itself.

Thanks again, hopefully there is an easy way to do this.

-Jarv
Reply With Quote
  #9  
Old 07-21-2001, 09:31 PM
Dark_Wizard Dark_Wizard is offline
 
Join Date: Nov 2001
Location: North Carolina
Posts: 1,251
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this...
http://www.vbulletin.com/forum/showt...threadid=21875
Reply With Quote
  #10  
Old 07-22-2001, 12:59 AM
jarvis jarvis is offline
 
Join Date: Nov 2001
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm... I'll ask again on that thread, but didn't get any reply to it a week ago.

Thanks...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:39 AM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.