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 Projektil Projektil is offline
Developer Last Online: Nov 2001 Show Printable Version Email this Page

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

hi, i'v got a small hack for you. the script reads the content of a forum directly from the database and displays the threads and replys. the hack is based on (i forgot that) a old hack.
you can enter the length of the message after it is shortent.

sorry, no demo, we use it in out extranet.

the code:

PHP Code:

<? 
error_reporting(0);

$DBhost = "db.host"; 
$DBuser = "db.user"; 
$DBpass = "db.password"; 
$DBName = "db.name"; 
$RipNumber = "10"; // rip of comments after...
$path = "http://path.to.server/forum"; 

$DBTable = "thread"; // db_table (standard)
$DBForum = 2; // nr. of forum

$newsPath = "http://path.to.server/forum";

$cutLength = 300; // cut comments and message after $cutLength chars

function sstr($str){
    $u = 300;
     if ( strlen($str)<$u ){
          return $str;
     } else {
         do {$u++;} while(substr("$str",$u,1)==" ");
        return trim(substr($str, 0, $u).$u);    
        $u = 300;
    }
}

mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable toconnect to database"); 
mysql_select_db("$DBName") or die("Unable to access the News"); 
$sqlquery = "SELECT * FROM $DBTable WHERE forumid = $DBForum AND visible !=0 ORDER by dateline DESC LIMIT 0,$RipNumber"; 
$result = mysql_query($sqlquery); 
$number = mysql_numrows($result); 

$i = 0; 
$daycheck = niltz;

if ($number < 1) { 
print "<CENTER><P>There Is NO News!</CENTER>"; 

else { 
print "
        <head>
        <title>News</title>
        </head>
        <link rel=STYLESHEET type=text/css href=ns_format_02.css disabled>
        <script language=JavaScript type=text/javascript> if (document.all) document.createStyleSheet(\"ie_format_02.css\");</script>
        <body bgcolor=#CEDFFF>
        <table width=300 cellspacing=2 cellpadding=0 align=LEFT valign=TOP>";
while ($number > $i) { 
$title = mysql_result($result,$i,"title"); 
$theid = mysql_result($result,$i,"threadid"); 
$name = mysql_result($result,$i,"postusername"); 
$time = mysql_result($result,$i,"dateline"); 
$time2 = date("d-m-Y",$time); 
$time3 = date("H:i",$time);

$story = mysql_result(mysql_query("SELECT pagetext FROM post where threadid = $theid order by dateline limit 0,1"),"pagetext"); 

$post = mysql_result(mysql_query("SELECT postid FROM post where threadid = $theid order by dateline limit 0,1"),"postid"); 

$userid = mysql_result(mysql_query("SELECT userid FROM post where threadid = $theid order by dateline limit 0,1"),"userid");

$numcheck = mysql_result($result,$i,"replycount");
$numie = ($numcheck);

// replace vbul-coding
$search = array ("/(\[URL=http:\/\/)(.*)(\])(.*)(\[\/URL\])/U",
                 "/(\[EMAIL=mailto:)(.*)(\])(.*)(\[\/EMAIL\])/U",
                 "/(\[SIZE=)(.*)(\])(.*)(\[\/SIZE\])/U",
                 "/(\[FONT=)(.*)(\])(.*)(\[\/FONT\])/U",
                 "/(\[COLOR=)(.*)(\])(.*)(\[\/COLOR\])/U",
                 "'\[list]'",
                 "'\[list=1]'",
                 "'\[list=a]'",
                 "'\[/list]'",
                 "'\[/list=1]'",
                 "'\[/list=a]'",
                 "'\[\*\]'",
                 "'\[B\]'",
                 "'\[/B\]'",
                 "'\[I\]'",
                 "'\[/I\]'",
                 "'\[U\]'",
                 "'\[/U\]'");                  
                 
$replace = array ("<a href=http:\/\\2>\\4</a>",
                  "<a href=mailto:\\2>\\2</a>",
                  "<font size=\\2 >\\2</font>",
                  "<font face=\\2 >\\2</font>",
                  "<font color=\\2 >\\2</font>",
                  "<ul>",
                  "<ol type=1>",
                  "<ol type=a>",
                  "</ul>",
                  "</ol>",
                  "</ol>",
                  "<li>",
                  "<b>",
                  "</b>",
                  "<i>",
                  "</i>",
                  "<u>",
                  "</u>");

$tmpStory = preg_replace ($search, $replace, $story);


$firstReply = mysql_result(mysql_query("SELECT pagetext FROM post where threadid = $theid order by dateline limit 1, $numcheck"),"pagetext"); 

if (!$firstReply) {
    $enterReply = "";
} else {
    $enterReply = "<tr><td bgcolor=$txtbgcolor>Antworten: $firstReply</td></tr>";
}
    
$br = '<BR>';
$p='<P>'; 
$chr = "\n"; 


 if ( strlen($tmpStory)<$cutLength ){
      $newstoryShort = $tmpStory;
 } else {
     $u = 300;
     do {$u++;} while(substr($tmpStory,$u,1)==" ");
    $newstoryShort = trim(substr($tmpStory, 0, $u)." ... ");    
}


if (strlen($newstoryShort) > $cutLength) {
    $showMore = "<A href=$newsPath/news.php?action=detail&message=$i&subID=0 class=content-bold-orange>[weiter]</a>";
} else {
    $showMore = "";
}

    if ($action=="detail") {
        
        if ($message==$i){
                print "
                <tr><td><font class=content-bold-black>[ $title ]</font></td></tr>
                    <tr><td><hr noshade size=1 color=black></td></tr>
                    <tr><td><font class=content-regular-black>";
                
                if ($subID!=0){
                    print $newstoryShort;
                    print $showMore;
                } else {
                    print $tmpStory;
                }
                
                print "
                    <tr><td><hr noshade size=1 color=black></td></tr>
                    <tr><td><font class=content-regular-black>$name, $time2, $time3.";
                // reply
                if ($numie!=0) {
                    $maxReply = $numie+1;
                    for ( $i = 1 ; $i < $maxReply ; $i++){
                        print "<tr><td><hr noshade size=1 color=black></td></tr>";
                        $thisThread =  mysql_result(mysql_query("SELECT postid FROM post where threadid = $theid order by dateline limit $i, 1"),"reply"); 
                        print "<tr><td><font class=content-regular-black>-->  ";
                        print mysql_result(mysql_query("SELECT username FROM post where threadid = $theid order by dateline limit $i, 1"),"reply");
                        print ": <A href=$newsPath/news.php?action=detail&message=$message&subID=$thisThread class=content-bold-orange>";
                        print mysql_result(mysql_query("SELECT title FROM post where threadid = $theid order by dateline limit $i, 1"),"reply"); 
                        print "</a></td></tr>";
                        if ($subID == $thisThread){
                            print "<tr><td><font class=content-regular-black><br>";
                            print preg_replace ($search, $replace, mysql_result(mysql_query("SELECT pagetext FROM post where threadid = $theid order by dateline limit $i, 1"),"reply") );
                            print "</font></td></tr>";
                        } 
                    }    
                } 
                // reply
                    
                print "<tr><td><hr noshade size=1 color=black></td></tr>";
                print "
                <tr><td><a href=$newsPath/news.php class=content-bold-orange>[ Back ]</a></td></tr>
                </table><p>
                "; 
                break;
            } 
    } else {
        print "        
            <tr><td><font class=content-bold-black>[ $title ]</font></td></tr>
            <tr><td><hr noshade size=1 color=black></td></tr>
            <tr><td><font class=content-regular-black>$newstoryShort</font>$showMore</td></tr>
            <tr><td><hr noshade size=1 color=black></td></tr>
            <tr><td><font class=content-regular-black>$name, $time2, $time3.";
            
            
        if ($numie!=0) {
        print "        
             Comments: $numie</font></td></tr>
            <tr><td><hr noshade size=1 color=black></td></tr>
            <tr><td><font class=content-bold-black>Comments:</font></td></tr>";
            $maxReply = $numie+1;
            for ( $j = 1 ; $j < $maxReply ; $j++){
                $thisThread =  mysql_result(mysql_query("SELECT postid FROM post where threadid = $theid order by dateline limit $j, 1"),"reply"); 
                print "<tr><td><font class=content-regular-black>--> ";
                print mysql_result(mysql_query("SELECT username FROM post where threadid = $theid order by dateline limit $j, 1"),"reply");
                print ": <A href=$newsPath/news.php?action=detail&message=$i&subID=$thisThread class=content-bold-orange>";
                print mysql_result(mysql_query("SELECT title FROM post where threadid = $theid order by dateline limit $j, 1"),"reply"); 
                print "</a></td></tr>";
            }    
        } 
        print "<tr><td height=40>&nbsp;</td></tr>";
    }
$i++; 

print "
        </table>
        ";     


?>
just save it as xxx.php

Show Your Support

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

Comments
  #2  
Old 07-05-2001, 09:45 AM
Projektil Projektil is offline
 
Join Date: Oct 2001
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

look at it
Reply With Quote
  #3  
Old 07-05-2001, 09:46 AM
Projektil Projektil is offline
 
Join Date: Oct 2001
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

single news display
Reply With Quote
  #4  
Old 07-05-2001, 11:41 AM
dost dost is offline
 
Join Date: Oct 2001
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great hack thanks!
Reply With Quote
  #5  
Old 07-05-2001, 02:24 PM
ztsky
Guest
 
Posts: n/a
Default

It seemed an error:
Parse error: parse error, expecting `')'' in c:\apache\htdocs\vb201\shownews.php on line 69
Reply With Quote
  #6  
Old 07-05-2001, 03:44 PM
JohnM's Avatar
JohnM JohnM is offline
 
Join Date: Oct 2001
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

lol

PHP Code:
$story mysql_result(mysql_query("SELECT pagetext FROM post where threadid = $theid order by dateline limit 0,1"),"pagetext"); 

$post mysql_result(mysql_query("SELECT postid FROM post where threadid = $theid order by dateline limit 0,1"),"postid"); 

$userid mysql_result(mysql_query("SELECT userid FROM post where threadid = $theid order by dateline limit 0,1"),"userid"); 
try:

PHP Code:
list($story,$post,$userid) = mysql_fetch_row(mysql_query("SELECT pagetext,postid,userid FROM post where threadid = $theid order by dateline limit 0,1")); 
Reply With Quote
  #7  
Old 07-05-2001, 03:50 PM
JohnM's Avatar
JohnM JohnM is offline
 
Join Date: Oct 2001
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$title mysql_result($result,$i,"title");
$theid mysql_result($result,$i,"threadid");
$name mysql_result($result,$i,"postusername");
$time mysql_result($result,$i,"dateline"); 
PHP Code:
$a mysql_fetch_array($result);
list (
$title,$theid,$name,$time) = list($a['title'],$a['threadid'],$a['postusername'],$a['dateline']); 
Reply With Quote
  #8  
Old 07-06-2001, 07:28 AM
Projektil Projektil is offline
 
Join Date: Oct 2001
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

but this was the first time i used php and mysql because i´m a flash5-actionscript/javascript/dhtml developer. TKS for your input...
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:48 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.05152 seconds
  • Memory Usage 2,317KB
  • Queries Executed 21 (?)
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
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (8)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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete