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

Reply
 
Thread Tools
Details »»

Version: , by (Guest)
Developer Last Online: Jan 1970 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

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-20-2001, 11: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, 11: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, 02: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, 04: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, 07: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, 09: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, 09: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, 10: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, 01: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 10:30 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04184 seconds
  • Memory Usage 2,318KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_imicons
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete