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
  #12  
Old 06-28-2001, 07:07 AM
stroppytart
Guest
 
Posts: n/a
Default

Ok, I imstalled both the .cgi and .php versions on a test page, but neither worked. Here's the gist of the page:

PHP Code:
<HTML>
<
HEAD>
   <
BASEFONT face="Verdana, Arial, helvetica" size="2">
   <
content="4; URL=http://www.lilymud.com/forum/">
   <
META name="Author" CONTENT="Lilymud">
   <
META name="Description" content="">
   <
META name="Keywords" content="">   
<
TITLE>Test</TITLE>
<
STYLE TYPE="text/css">
<!--
BODY {
    
SCROLLBAR-BASE-COLOR000080;
    
SCROLLBAR-ARROW-COLORffffff;
}
SELECT {
    
FONT-FAMILYVerdana,Arial,Helvetica;
    
FONT-SIZE9px;
    
COLORblack;
    
BACKGROUND-COLOR#CFCFCF
}
TEXTAREA, .bginput {
    
FONT-SIZE10px;
    
FONT-FAMILYVerdana,Arial,Helvetica;
    
COLORblack;
    
BACKGROUND-COLOR#CFCFCF
}
A:linkA:visitedA:active {
    
COLORFFFFFF;
TEXT-DECORATIONunderline;
}
A:hover {
    
COLORffffcc;
TEXT-DECORATIONnone;
}
    -->
</
STYLE>
</
script>
</
head>

<
body bgcolor="#666696">

<
p>&nbsp;</p>
<
blockquote>
  <
blockquote>
    <
blockquote>
      <
blockquote>
 <
p align="center"><font face="Arial">Text/article here.</font></p>

        <
p align="center"><font face="Arial"></font></p>
       [
b]<!--#include virtual=/discussion_link.php?topic=Topic+Title+Here&forum=13 -->[/b]

    
      
</blockquote>
    </
blockquote>
  </
blockquote>
</
blockquote>
</
body>
</
html
What am I doing wrong? I'm not extremely familiar with the #include option.

For reference, here's my discussion_link.php page (password/username starred out for security reasons..duh):

PHP Code:
<?
############################################################################
#  Per-Site Variable Settings
############################################################################

   $username = "*******";
   $password = "*******";
   $database = "lilymud";
   $forumpath = "http://www.lilymud.com/forum"; # no trailing /

############################################################################
   
   $link = db_connect() or exit();
   $query = "SELECT title FROM forum WHERE forumid = $forum";

   $result = mysql_query("$query") or exit();

   if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_array($result)) {
         $forum_name = $row["title"];
      }
   }

   $quoted_title = addslashes($topic);
   $query = "SELECT threadid FROM thread WHERE forumid = $forum AND title = \"$quoted_title\"";
   $result = mysql_query("$query") or exit();
   if (mysql_num_rows($result)) {
      while ($row = mysql_fetch_array($result)) {
         $threadid = $row["threadid"];
      }
   }
   $topic = str_replace(" ", "+", $topic);
  
   if ($threadid <= 0) {
      print "<A HREF=\"$forumpath/newthread.php?s=&action=newthread&forumid=$forum&subject=$topic\">Start a Conversation!</A>";
   } else {
     print ("<A HREF=\"$forumpath/showthread.php?s=&threadid=$threadid\">Join the Conversation!</A>");
   }

function db_connect ()
{
    global $username, $password, $database;
    $link = @mysql_pconnect("localhost", $username, $password);
    if ($link && mysql_select_db($database)) return($link);
    return(FALSE);
}

?>
Reply With Quote
  #13  
Old 06-30-2001, 01:57 PM
stroppytart
Guest
 
Posts: n/a
Default

Can anyone help..?
Reply With Quote
  #14  
Old 06-30-2001, 06:35 PM
unixman
Guest
 
Posts: n/a
Default

The #include will only work if your Apache web server supports server-side includes (SSI). With regard to the PHP version that akiy posted - you just have to include it in using PHPs include syntax:

PHP Code:
<? include "/path/to/your/script/whatever.php"; ?>
Cheers.
Reply With Quote
  #15  
Old 07-01-2001, 10:46 PM
Juan Juan is offline
 
Join Date: Nov 2001
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This looks like a nice hack!

I am testing it with the php version. I have named it discussion.php and uploaded it to the forums directory.

What is exactly what I need to include below to make sure it starts or joins in a conversation?

<? include "/path/to/my/forums/discussion.php"; ?>

The way it is, it just displays a blank page.
Reply With Quote
  #16  
Old 07-02-2001, 06:51 AM
stroppytart
Guest
 
Posts: n/a
Default

OK, that worked, but now I recieve this error where the link should be.

Warning: open_basedir restriction in effect. File is in wrong directory in /home/sites/site207/web/browse.php on line 306

Warning: Failed opening '/discussion_link.php' for inclusion (include_path='.:..:/usr/local/lib/php') in /home/sites/site207/web/browse.php on line 306

The usr/local/lib/php would be necessary? I wasn't aware php required a bin.. but I'm a novice, so eh.. is there any quick fix to this?
Reply With Quote
  #17  
Old 07-04-2001, 12:46 PM
stroppytart
Guest
 
Posts: n/a
Default

Reply With Quote
  #18  
Old 07-04-2001, 03:20 PM
chilliboy
Guest
 
Posts: n/a
Default

I would guess your include path is not the full path - if your on a shared server this is likely to be the case - you may need to add sometheing like www/public_html/ infront of your path. You cant set a .htaccess to stop you having to do this repetitively (which I have done) - but don't ask me how off my head. - do a search.
Reply With Quote
  #19  
Old 07-04-2001, 06:11 PM
stroppytart
Guest
 
Posts: n/a
Default

this is the full, absolute location.

<? include "/home/sites/site207/web/discussion_link.php"; ?>

I insert that text, on .php pages, .cgi pages, .html pages.. no luck. its blank on all of them. Not so much as an error anymore.
Reply With Quote
  #20  
Old 07-05-2001, 07:09 AM
chilliboy
Guest
 
Posts: n/a
Default

Have you tried it without the starting / ie <? include ("home/sites/site207/web/discussion_link.php"); ?> ??

I doubt this would be the prob though as you would get 'file not found error' - unless you have turned off error reporting.

PS. I haven't tried this hack yet, so I may be missing something.
Reply With Quote
  #21  
Old 07-05-2001, 07:34 PM
stroppytart
Guest
 
Posts: n/a
Default

Warning: open_basedir restriction in effect. File is in wrong directory in /home/sites/site207/web/get.php on line 144

Warning: Failed opening 'home/sites/site207/web/discussion_link.php' for inclusion (include_path='.:..:/usr/local/lib/php') in /home/sites/site207/web/get.php on line 144


Got this again. Do you think the first "open_basedir" is a setting, perhaps a permissions setting that needs to be configured? I did a google search for this error text, and it appears to be VERY common.
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 11:27 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.08672 seconds
  • Memory Usage 2,314KB
  • 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
  • (2)bbcode_code
  • (3)bbcode_php
  • (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
  • (1)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