ThWboard Support-Forum (Archiv)

Ort: / Boardübersicht / English support board / thwbnews.php fixes for hacks


Seite 1 von 1

fingers schrieb am 07.05.2003 um 20:07 Uhr

This may not work for everyone but i found a lot of problems with the issued thwbnews.php, smilies not showing, url links split in half due to the fixed length of news row i made the changes/inclusions below
maybe it will work for you

<?php
/* $Id: thwbnews.php,v 1.4 2002/11/06 20:43:45 pbaecher Exp $ */

/*
 *  
 *  ThWboard News
 *
 *  WARNING: This script requires thwboard beta 2.8+
 *
 *  This is a basic newsscript using thwboard as news database.
 *  In order to use this script, you need to create a news board,
 *  and enter its ID below. You can post news by creating a new
 *  thread in this board and your users may comment these news
 *  by posting replies (optional)
 *
 *  To alter the layout/design you can edit the variable
 *  $tpl_newsrow. This is the template for a news item.
 *
 *  Then, simply include() this script on your main page. 
 *
 *
 *
 *  (c) 2002 ThWboard Development Team
 */

/* ----------------- config -------------------
   path to your thwboard directory (relative to this script)
   don't forget the slash at the end! */
$thwbpath            = '../';

/* should this script open a MySQL connection?
   1 - yes
   0 - no, use existing */
$mysqlconnect                    = 1;

/* print() news directly or store them in $news_output?
   1 - print() news
   0 - store output in $news_output */
$print_news                        = 1;

/* news are taken from this boardid */
$boardid            = 1;

/* amout of news to display at a time */
$newscount            = 10;

/* dont display more than $maxchars, link to the thread instead. 0 to disable */
$maxchars = 40;

/* the date format for your news -- see www.php.net/date */ 
$date_format                    = 'd.m.Y';

/* newsrow template. available inserts:
   {date}, {topic}, {text}, {author}, {commentcount}, {threadid}, {more} */
$tpl_newsrow = '
<b>{topic}</b><br>
<font size="1">{date} - {commentcount} <a href="'.$thwbpath.'showtopic.php?threadid={threadid}">Kommentar(e)</a></font><br>
<table width="20%" border="0" cellspacing="0" cellpadding="0">
   <tr>
    {text}
  </tr>
</table><table> <tr> <td>
{more}<br>
</td>
  </tr></table>
<br><br>
';

/* ------------ configuration end --------------------- */


require($thwbpath.'./inc/config.inc.php');
require($thwbpath.'./inc/functions.inc.php');
require($thwbpath.'./inc/thwbcode.inc.php');
if( $mysqlconnect )
{
    mysql_connect($mysql_h, $mysql_u, $mysql_p);
    mysql_select_db($mysql_db);
}

$oldquotes = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
################################################################################
//        Creating config array
################################################################################

//$lan_instruct = LANG_SELECT_INSTRUCT;
$r_registry = thwb_query("SELECT keyname, keyvalue, keytype FROM " . $pref . "registry");
while ( $registry = mysql_fetch_array($r_registry) )
{
    switch( $registry['keytype'] )
    {
        case 'integer':
        case 'boolean':
            $config[$registry['keyname']] = intval($registry['keyvalue']);
            break;
            
        case 'array':
            if( $registry['keyvalue'] )
            {
                $array = explode("\n", $registry['keyvalue']);
                while( list($k, $v) = @each($array) )
                    $array[$k] = '"'.addslashes(trim($v)).'"';
                eval("\$config[\$registry['keyname']] = array(".implode(',', $array).");");
            }
            break;
                
        default:
            $config[$registry['keyname']] = $registry['keyvalue'];
    }
}
{

    $r_style = thwb_query("SELECT styletemplate, colorbg, color1, CellA, CellB, color4, colorbgfont, col_he_fo_font, color_err, col_link, col_link_v, col_link_hover, stdfont, boardimage, newtopicimage, border_col    FROM ".$pref."style WHERE styleid=1");

$style = mysql_fetch_array($r_style);
$style['smallfont'] = '<font face="' . $style['stdfont'] . '" size="1">';
$style['smallfontend'] = '</font>';
$style['stdfont'] = '<font face="' . $style['stdfont'] . '" size="2">';
$style['stdfontend'] = '</font>';


}
/* select threads */
$r_thread = mysql_query('SELECT
        threadid,
        threadtopic,
        threadtime,
        threadauthor,
        threadreplies,
        threadcreationtime
    FROM '.$pref.'thread WHERE boardid='.$boardid.' ORDER BY threadcreationtime DESC LIMIT '.$newscount);

$a_thread = array();
$a_threadid = array();
while( $thread = mysql_fetch_array($r_thread) )
{
    $a_thread[$thread['threadid']] = $thread;
    $a_threadid[] = $thread['threadid'];
}
mysql_free_result($r_thread);


/* select postids */
$r_post = mysql_query('SELECT
        threadid,
        postid
    FROM '.$pref.'post WHERE threadid IN('.implode(',', $a_threadid).') ORDER BY posttime DESC');
$a_postid = array();
while( $post = mysql_fetch_array($r_post) )
    $a_postid[$post['threadid']] = $post['postid'];
mysql_free_result($r_post);


/* select posttexts */
$r_post = mysql_query('SELECT
        threadid,
        posttext
    FROM '.$pref.'post WHERE postid IN('.implode(',', $a_postid).')');
while( $post = mysql_fetch_array($r_post) )

    $a_thread[$post['threadid']]['posttext'] =    $post['posttext'];
    
    
    
    
mysql_free_result($r_post);



$news_output = '';
global $maxchars;

while( list(, $thread) = each($a_thread) )
{ 
    $pos2 = $maxchars;
    if( $maxchars && strlen($thread['posttext']) > $maxchars )
    { 
        if ( strpos($thread['posttext'], 'Attachment: [b]' ,1) ==true )
         {
           if ( strpos($thread['posttext'], 'Attachment: [b]' ,1) > $pos2 )
             {
              $pos2 = $maxchars ; 
             }
           else
             {
              $pos2 = strpos($thread['posttext'], 'Attachment: [b]');
             }
         }
        else
        {
          if ( strpos($thread['posttext'], '[code]' ) == true )
            {
             $pos2 = strpos($thread['posttext'], '[code]' ,1);
            }
          else
            {
              if ( strpos($thread['posttext'], '[url' ) == true )
               {
                $pos2 = strpos($thread['posttext'], '[url' ,1);
               }
              else
               {
                $counttext = substr($thread['posttext'], 0, $maxchars);
                $count = substr_count($counttext,']');
                 if (intval($count / 2) <> ($count / 2))
                  {
                   $pos = $count;
                   for ($i = 1; $i <= $count+ 1; $i++)
                    {
                     $pos = strpos($thread['posttext'], ']', $pos ) + 1;
                     $pos2 = $pos;
                    }  
                  } 
               }
             }
          }
        $newtext = substr($thread['posttext'], 0, $pos2);
        $more = '[<a href ="'.$thwbpath.'showtopic.php?threadid='.$thread['threadid'].'">more</a>]';
        $newtext .= "....";
        $pos2 = '';
        $pos = '';
        //HACK insert end

        $thread['posttext'] = $newtext;
    }
    else
    {
        $more = '';
    }
// change to suit your site preferences    
$backcolor =  '<td bgcolor="#c6c6c6">'.$style['stdfont'].'<FONT COLOR= WHITE>';
$backcolorend = $style['stdfontend'].'</FONT></td>';
    $row = $tpl_newsrow;
    $row = str_replace('{more}', $more, $row);
    $row = str_replace('{topic}', parse_code($thread['threadtopic']), $row);
    $row = str_replace('{text}', $backcolor.parse_code($thread['posttext'], 1, 1, 1, 1).$backcolorend, $row);
    $row = str_replace('{author}', $thread['threadauthor'], $row);
    $row = str_replace('{date}', date($date_format, $thread['threadcreationtime']), $row);
    $row = str_replace('{threadid}', $thread['threadid'], $row);
    $row = str_replace('{commentcount}', $thread['threadreplies'], $row);
    
    $news_output .= $row;

}

unset($a_thread);
set_magic_quotes_runtime($oldquotes);

if( $print_news )
// change to suit location of /templates folder (relative to this script)
   $smilieurl ='../templates';        
   $news_output = str_replace('templates', $smilieurl, $news_output);
  print $news_output;
?>

fingers schrieb am 08.05.2003 um 02:20 Uhr

aaaa

Sh4d0w schrieb am 29.06.2004 um 01:59 Uhr

hi fingers!
n1 job, great new thwbnews! i only have one problem! i replaced the template code with this:

<table width="100%" border="0" cellSpacing=1 cellpadding="3" align="center" bgColor="#1B6ECC">
<tr>
<td><b><font color="FFFFFF">{topic}</font></b></td>
</tr>
<tr bgColor="#FFFFFF">
<td>{text}<br>{more}</td>
</tr>
<tr>
<td><b><font size="1" color="FFFFFF">Erstellt von {author} am {date} Uhr - {commentcount} <a href="'.$thwbpath.'showtopic.php?threadid={threadid}">Kommentar(e)</a> - {views} Mal gelesen</font></b></td>
</tr>
</table>
<br><br>

in the old thwbnews.php, to have a table-design like @ thwh & it worked!
but in your script this code doesn't work properly! this is the result: HERE
many things are displaced, there' re tables that i' ve not created & the [more]-feature is above & not under the newstext! can you say me what is wrong in my html-code??? using tables like i have is not allowed in your script? *don't think so*

*hope my english is not so bad & you understand want i mean* :rolleyes:

/EURdit
HERE is how it should be!

fingers schrieb am 30.06.2004 um 19:46 Uhr

Sh4d0w
i just timed out
but it is in 2 lines
1 mine:
$backcolorend = $style['stdfontend'].'</FONT></td>';
(remove </td> here)


2 yours:
<td>{text}<br>{more}</td>
(remove <td> here)

dave

Sh4d0w schrieb am 01.07.2004 um 00:13 Uhr

wuhu, great one! BIG THX 4 your help! now everythings is nearly perfect! only some style-changes...

thx again! ;)

fingers schrieb am 01.07.2004 um 01:11 Uhr

no worries, glad to help
dave

hevtig schrieb am 01.07.2004 um 10:25 Uhr

looks fine. is this for the portalhack? or where do I include it?

Greets,

HeVTiG

Sh4d0w schrieb am 02.07.2004 um 04:03 Uhr

it's a bonus script written by the coders of the thwb to use threads of the forum as a newsscript for example on your own homepage. fingers has modified this script so that you're available to see the smilies and the quotes like in the forum and some other good changes.
you can find this script in the installfolder ./thwb/extras/extras.tar.gz or simply copy the code in fingers' 1st post!

auf deutsch @ hevtig (glaube du warst nen deutschsprachiger oder?)
das script is im original von den codern des thwb. geschriebn um threads aus dem forum als news für deine HP auszulesn... fingers hat es noch dahingehend modifiziert, dass auch smilies, quotes etc. pp wie im forum angezeigt werdn (und noch einiges).
liegn tut es im installationsordner und dann ./thwb/extras/extras.tar.gz oder einfach den code hier aus fingers erstm post nutzn!

HF...

hevtig schrieb am 02.07.2004 um 10:19 Uhr

Thx 4 response ;)
@ Sh4d0wjep, deutsch :)
Danke für die Antwort :D
Ich werd mir das dann mal anschauen ..

Seite 1 von 1