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: 06-18-2001 Last Update: Never Installs: 3
 
No support by the author.

Another quick, but kick-arse hack. We have a home-made content management system (actually, a beta tool see incursio.com for more info - product is called Editio). At any rate, it allows staff or community members to create online articles. Once articles are published, I wanted a way to automatically link them into our forums, so people could start a discussion, or join a discussion already in progress about that particular article. Yahoo! does this with news events as well.

At any rate, perl script. chmod 755, I call it discuss_link.cgi. It should be invoked via SSI. Under Apache:

Code:
  <!--#include virtual=/cgi-bin/discuss_link.cgi?topic=Downhill+Skiing+Basics&forum=5 -->
In the link above, plug in your forum number (forumid column in VB), and the title of the article. The title will be used as the title of the post. If a post exists in the passed forum with that title, a link to "Join the conversation" will be emitted. Otherwise, you get a link called "Start a conversation". You get the picture.

Our content management system (through its plugin concept) allows us to have stuff like this embedded within each article - you could cobble up something similar in your own system with a little effort.

Code:
#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

use DBI;

#Require the cgi library
require '/opt/web/cgi-bin/cgi-lib.pl';

&ReadParse(*input);

# Grab fields
$topic =  $input{'topic'};
$forum =  $input{'forum'};

# Does the forum/topic combo exist?

# Connect to mySQL

$dbh = DBI->connect( "DBI:mysql:vbulletin", "id", "password");

if ( !defined $dbh ) {
  print "<LI>Cannot connect to mySQL server: $DBI::errstr\n";
}

# Grab the forum name

$q = "SELECT title FROM forum WHERE forum = $forum";

$sth = $dbh->prepare($q);
$sth->execute;
@result = $sth->fetchrow_array;
$forum_name = $result[0];
$sth->finish;

$quoted_title = $dbh->quote($topic);
$q = "SELECT threadid FROM thread WHERE forumid = $forum AND title = $quoted_title";
$sth = $dbh->prepare($q);
$sth->execute;
@result = $sth->fetchrow_array;
$threadid = $result[0];
$sth->finish;

# Prep for linking
$topic =~ tr/ /+/;

if( $threadid <= 0 ) {
  print "<A HREF=http://www.mysite.com/forums/newthread.php?s=&action=newthread&forumid=$forum&subject=$topic>Start a Conversation!</A>";
  exit(1);
}

print ("<A HREF=http://www.mysite.com/forums/showthread.php?s=&threadid=$threadid>Join the Conversation!</A>");

exit;
Cheers.

Show Your Support

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

Comments
  #22  
Old 07-12-2001, 12:22 PM
chilliboy
Guest
 
Posts: n/a
Default

Sorry its lost me - maybe its a host thing - contact them.
Reply With Quote
  #23  
Old 07-24-2001, 03:34 PM
Deacon Frost
Guest
 
Posts: n/a
Default

I've a Question to the cgi-version (php works fine *g*)... When my DB is not stored on localhost, what have I to add?
Reply With Quote
  #24  
Old 07-24-2001, 04:24 PM
unixman
Guest
 
Posts: n/a
Default

Quote:
Originally posted by Deacon Frost
I've a Question to the cgi-version (php works fine *g*)... When my DB is not stored on localhost, what have I to add?
Change:

Code:
# Connect to mySQL

$dbh = DBI->connect( "DBI:mysql:vbulletin", "id", "password");
to:

Code:
# Connect to mySQL

$dbh = DBI->connect( "DBI:mysql:vbulletin:xyz.mydomain.com", "id", "password");
Cheers.
Reply With Quote
  #25  
Old 07-24-2001, 11:30 PM
Juan Juan is offline
 
Join Date: Nov 2001
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can someone please explain this hack better, I cannot get it to work. Instructions are not that clear to me.
Reply With Quote
  #26  
Old 07-25-2001, 01:37 AM
unixman
Guest
 
Posts: n/a
Default

This isn't a "hack", but a simple add-on script. What problems are you having specifically? "I can't get it to work" doesn't tell us a whole lot.
Reply With Quote
  #27  
Old 07-25-2001, 03:16 AM
Juan Juan is offline
 
Join Date: Nov 2001
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for your reply.

I don't undertand/know what code I need to add in the comment/join converstation to make it work.
Reply With Quote
  #28  
Old 07-27-2001, 05:29 PM
tamarian tamarian is offline
 
Join Date: Oct 2001
Location: Canada
Posts: 1,205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is a great script.

I just added it (the PHP version) and it works.

Just one problem when the title of the page contains '#' it halts.

I tried htmlspecial chars, and stripslashes but they didn't change the behaviour. Any tricks to make it work with '#"?
Reply With Quote
  #29  
Old 07-29-2001, 06:00 PM
tamarian tamarian is offline
 
Join Date: Oct 2001
Location: Canada
Posts: 1,205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Another observation. If the page title ($topic) had an '&' it will trim it to just before the '&'

My guess is that the php parser expects a variable following &.

Example:

$topic = "Sweet & Sour" will create a thread titled "Sweet"

htnlspecialchars won't help, it will replace & with &amp; !!

Any ideas?
Reply With Quote
  #30  
Old 07-30-2001, 04:01 PM
unixman
Guest
 
Posts: n/a
Default

With the PHP version of this script, you'll need to use urlencode() to encode the title before passing it along. There are similar solutions for Perl scripts out there as well.
Reply With Quote
  #31  
Old 07-30-2001, 07:41 PM
tamarian tamarian is offline
 
Join Date: Oct 2001
Location: Canada
Posts: 1,205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, this fixed both of my problems, the & and #.

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:18 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.04475 seconds
  • Memory Usage 2,290KB
  • Queries Executed 25 (?)
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
  • (4)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (5)postbit_onlinestatus
  • (11)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete